babylon.max.js 6.9 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory();
  4. else if(typeof define === 'function' && define.amd)
  5. define("babylonjs", [], factory);
  6. else if(typeof exports === 'object')
  7. exports["babylonjs"] = factory();
  8. else
  9. root["BABYLON"] = factory();
  10. })(window, function() {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  50. /******/ }
  51. /******/ };
  52. /******/
  53. /******/ // define __esModule on exports
  54. /******/ __webpack_require__.r = function(exports) {
  55. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  56. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  57. /******/ }
  58. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  59. /******/ };
  60. /******/
  61. /******/ // create a fake namespace object
  62. /******/ // mode & 1: value is a module id, require it
  63. /******/ // mode & 2: merge all properties of value into the ns
  64. /******/ // mode & 4: return value when already ns object
  65. /******/ // mode & 8|1: behave like require
  66. /******/ __webpack_require__.t = function(value, mode) {
  67. /******/ if(mode & 1) value = __webpack_require__(value);
  68. /******/ if(mode & 8) return value;
  69. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  70. /******/ var ns = Object.create(null);
  71. /******/ __webpack_require__.r(ns);
  72. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  73. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  74. /******/ return ns;
  75. /******/ };
  76. /******/
  77. /******/ // getDefaultExport function for compatibility with non-harmony modules
  78. /******/ __webpack_require__.n = function(module) {
  79. /******/ var getter = module && module.__esModule ?
  80. /******/ function getDefault() { return module['default']; } :
  81. /******/ function getModuleExports() { return module; };
  82. /******/ __webpack_require__.d(getter, 'a', getter);
  83. /******/ return getter;
  84. /******/ };
  85. /******/
  86. /******/ // Object.prototype.hasOwnProperty.call
  87. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  88. /******/
  89. /******/ // __webpack_public_path__
  90. /******/ __webpack_require__.p = "";
  91. /******/
  92. /******/
  93. /******/ // Load entry module and return exports
  94. /******/ return __webpack_require__(__webpack_require__.s = "./Legacy/legacy.ts");
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "../node_modules/tslib/tslib.es6.js":
  99. /*!******************************************!*\
  100. !*** ../node_modules/tslib/tslib.es6.js ***!
  101. \******************************************/
  102. /*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __exportStar, __values, __read, __spread, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault */
  103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104. "use strict";
  105. __webpack_require__.r(__webpack_exports__);
  106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
  107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
  108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
  109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
  110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
  111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
  112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
  113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
  114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
  115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
  116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
  117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
  118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  125. /*! *****************************************************************************
  126. Copyright (c) Microsoft Corporation. All rights reserved.
  127. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  128. this file except in compliance with the License. You may obtain a copy of the
  129. License at http://www.apache.org/licenses/LICENSE-2.0
  130. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  131. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  132. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  133. MERCHANTABLITY OR NON-INFRINGEMENT.
  134. See the Apache Version 2.0 License for specific language governing permissions
  135. and limitations under the License.
  136. ***************************************************************************** */
  137. /* global Reflect, Promise */
  138. var extendStatics = function(d, b) {
  139. extendStatics = Object.setPrototypeOf ||
  140. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  141. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  142. return extendStatics(d, b);
  143. };
  144. function __extends(d, b) {
  145. extendStatics(d, b);
  146. function __() { this.constructor = d; }
  147. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  148. }
  149. var __assign = function() {
  150. __assign = Object.assign || function __assign(t) {
  151. for (var s, i = 1, n = arguments.length; i < n; i++) {
  152. s = arguments[i];
  153. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  154. }
  155. return t;
  156. }
  157. return __assign.apply(this, arguments);
  158. }
  159. function __rest(s, e) {
  160. var t = {};
  161. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  162. t[p] = s[p];
  163. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  164. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
  165. t[p[i]] = s[p[i]];
  166. return t;
  167. }
  168. function __decorate(decorators, target, key, desc) {
  169. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  170. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  171. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  172. return c > 3 && r && Object.defineProperty(target, key, r), r;
  173. }
  174. function __param(paramIndex, decorator) {
  175. return function (target, key) { decorator(target, key, paramIndex); }
  176. }
  177. function __metadata(metadataKey, metadataValue) {
  178. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  179. }
  180. function __awaiter(thisArg, _arguments, P, generator) {
  181. return new (P || (P = Promise))(function (resolve, reject) {
  182. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  183. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  184. function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  185. step((generator = generator.apply(thisArg, _arguments || [])).next());
  186. });
  187. }
  188. function __generator(thisArg, body) {
  189. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  190. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  191. function verb(n) { return function (v) { return step([n, v]); }; }
  192. function step(op) {
  193. if (f) throw new TypeError("Generator is already executing.");
  194. while (_) try {
  195. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  196. if (y = 0, t) op = [op[0] & 2, t.value];
  197. switch (op[0]) {
  198. case 0: case 1: t = op; break;
  199. case 4: _.label++; return { value: op[1], done: false };
  200. case 5: _.label++; y = op[1]; op = [0]; continue;
  201. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  202. default:
  203. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  204. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  205. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  206. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  207. if (t[2]) _.ops.pop();
  208. _.trys.pop(); continue;
  209. }
  210. op = body.call(thisArg, _);
  211. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  212. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  213. }
  214. }
  215. function __exportStar(m, exports) {
  216. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  217. }
  218. function __values(o) {
  219. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  220. if (m) return m.call(o);
  221. return {
  222. next: function () {
  223. if (o && i >= o.length) o = void 0;
  224. return { value: o && o[i++], done: !o };
  225. }
  226. };
  227. }
  228. function __read(o, n) {
  229. var m = typeof Symbol === "function" && o[Symbol.iterator];
  230. if (!m) return o;
  231. var i = m.call(o), r, ar = [], e;
  232. try {
  233. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  234. }
  235. catch (error) { e = { error: error }; }
  236. finally {
  237. try {
  238. if (r && !r.done && (m = i["return"])) m.call(i);
  239. }
  240. finally { if (e) throw e.error; }
  241. }
  242. return ar;
  243. }
  244. function __spread() {
  245. for (var ar = [], i = 0; i < arguments.length; i++)
  246. ar = ar.concat(__read(arguments[i]));
  247. return ar;
  248. }
  249. function __await(v) {
  250. return this instanceof __await ? (this.v = v, this) : new __await(v);
  251. }
  252. function __asyncGenerator(thisArg, _arguments, generator) {
  253. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  254. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  255. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  256. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  257. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  258. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  259. function fulfill(value) { resume("next", value); }
  260. function reject(value) { resume("throw", value); }
  261. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  262. }
  263. function __asyncDelegator(o) {
  264. var i, p;
  265. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  266. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
  267. }
  268. function __asyncValues(o) {
  269. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  270. var m = o[Symbol.asyncIterator], i;
  271. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  272. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  273. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  274. }
  275. function __makeTemplateObject(cooked, raw) {
  276. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  277. return cooked;
  278. };
  279. function __importStar(mod) {
  280. if (mod && mod.__esModule) return mod;
  281. var result = {};
  282. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  283. result.default = mod;
  284. return result;
  285. }
  286. function __importDefault(mod) {
  287. return (mod && mod.__esModule) ? mod : { default: mod };
  288. }
  289. /***/ }),
  290. /***/ "../node_modules/webpack/buildin/global.js":
  291. /*!*************************************************!*\
  292. !*** ../node_modules/webpack/buildin/global.js ***!
  293. \*************************************************/
  294. /*! no static exports found */
  295. /***/ (function(module, exports) {
  296. var g;
  297. // This works in non-strict mode
  298. g = (function() {
  299. return this;
  300. })();
  301. try {
  302. // This works if eval is allowed (see CSP)
  303. g = g || new Function("return this")();
  304. } catch (e) {
  305. // This works if the window reference is available
  306. if (typeof window === "object") g = window;
  307. }
  308. // g can still be undefined, but nothing to do about it...
  309. // We return undefined, instead of nothing here, so it's
  310. // easier to handle this case. if(!global) { ...}
  311. module.exports = g;
  312. /***/ }),
  313. /***/ "./Actions/abstractActionManager.ts":
  314. /*!******************************************!*\
  315. !*** ./Actions/abstractActionManager.ts ***!
  316. \******************************************/
  317. /*! exports provided: AbstractActionManager */
  318. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  319. "use strict";
  320. __webpack_require__.r(__webpack_exports__);
  321. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractActionManager", function() { return AbstractActionManager; });
  322. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  323. /**
  324. * Abstract class used to decouple action Manager from scene and meshes.
  325. * Do not instantiate.
  326. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  327. */
  328. var AbstractActionManager = /** @class */ (function () {
  329. function AbstractActionManager() {
  330. /** Gets the cursor to use when hovering items */
  331. this.hoverCursor = '';
  332. /** Gets the list of actions */
  333. this.actions = new Array();
  334. /**
  335. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  336. */
  337. this.isRecursive = false;
  338. }
  339. Object.defineProperty(AbstractActionManager, "HasTriggers", {
  340. /**
  341. * Does exist one action manager with at least one trigger
  342. **/
  343. get: function () {
  344. for (var t in AbstractActionManager.Triggers) {
  345. if (AbstractActionManager.Triggers.hasOwnProperty(t)) {
  346. return true;
  347. }
  348. }
  349. return false;
  350. },
  351. enumerable: true,
  352. configurable: true
  353. });
  354. Object.defineProperty(AbstractActionManager, "HasPickTriggers", {
  355. /**
  356. * Does exist one action manager with at least one pick trigger
  357. **/
  358. get: function () {
  359. for (var t in AbstractActionManager.Triggers) {
  360. if (AbstractActionManager.Triggers.hasOwnProperty(t)) {
  361. var t_int = parseInt(t);
  362. if (t_int >= _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].ACTION_OnPickTrigger && t_int <= _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].ACTION_OnPickUpTrigger) {
  363. return true;
  364. }
  365. }
  366. }
  367. return false;
  368. },
  369. enumerable: true,
  370. configurable: true
  371. });
  372. /**
  373. * Does exist one action manager that handles actions of a given trigger
  374. * @param trigger defines the trigger to be tested
  375. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  376. **/
  377. AbstractActionManager.HasSpecificTrigger = function (trigger) {
  378. for (var t in AbstractActionManager.Triggers) {
  379. if (AbstractActionManager.Triggers.hasOwnProperty(t)) {
  380. var t_int = parseInt(t);
  381. if (t_int === trigger) {
  382. return true;
  383. }
  384. }
  385. }
  386. return false;
  387. };
  388. /** Gets the list of active triggers */
  389. AbstractActionManager.Triggers = {};
  390. return AbstractActionManager;
  391. }());
  392. /***/ }),
  393. /***/ "./Actions/action.ts":
  394. /*!***************************!*\
  395. !*** ./Actions/action.ts ***!
  396. \***************************/
  397. /*! exports provided: Action */
  398. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  399. "use strict";
  400. __webpack_require__.r(__webpack_exports__);
  401. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return Action; });
  402. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  403. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  404. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  405. /**
  406. * The action to be carried out following a trigger
  407. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  408. */
  409. var Action = /** @class */ (function () {
  410. /**
  411. * Creates a new Action
  412. * @param triggerOptions the trigger, with or without parameters, for the action
  413. * @param condition an optional determinant of action
  414. */
  415. function Action(
  416. /** the trigger, with or without parameters, for the action */
  417. triggerOptions, condition) {
  418. this.triggerOptions = triggerOptions;
  419. /**
  420. * An event triggered prior to action being executed.
  421. */
  422. this.onBeforeExecuteObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  423. if (triggerOptions.parameter) {
  424. this.trigger = triggerOptions.trigger;
  425. this._triggerParameter = triggerOptions.parameter;
  426. }
  427. else if (triggerOptions.trigger) {
  428. this.trigger = triggerOptions.trigger;
  429. }
  430. else {
  431. this.trigger = triggerOptions;
  432. }
  433. this._nextActiveAction = this;
  434. this._condition = condition;
  435. }
  436. /**
  437. * Internal only
  438. * @hidden
  439. */
  440. Action.prototype._prepare = function () {
  441. };
  442. /**
  443. * Gets the trigger parameters
  444. * @returns the trigger parameters
  445. */
  446. Action.prototype.getTriggerParameter = function () {
  447. return this._triggerParameter;
  448. };
  449. /**
  450. * Internal only - executes current action event
  451. * @hidden
  452. */
  453. Action.prototype._executeCurrent = function (evt) {
  454. if (this._nextActiveAction._condition) {
  455. var condition = this._nextActiveAction._condition;
  456. var currentRenderId = this._actionManager.getScene().getRenderId();
  457. // We cache the current evaluation for the current frame
  458. if (condition._evaluationId === currentRenderId) {
  459. if (!condition._currentResult) {
  460. return;
  461. }
  462. }
  463. else {
  464. condition._evaluationId = currentRenderId;
  465. if (!condition.isValid()) {
  466. condition._currentResult = false;
  467. return;
  468. }
  469. condition._currentResult = true;
  470. }
  471. }
  472. this.onBeforeExecuteObservable.notifyObservers(this);
  473. this._nextActiveAction.execute(evt);
  474. this.skipToNextActiveAction();
  475. };
  476. /**
  477. * Execute placeholder for child classes
  478. * @param evt optional action event
  479. */
  480. Action.prototype.execute = function (evt) {
  481. };
  482. /**
  483. * Skips to next active action
  484. */
  485. Action.prototype.skipToNextActiveAction = function () {
  486. if (this._nextActiveAction._child) {
  487. if (!this._nextActiveAction._child._actionManager) {
  488. this._nextActiveAction._child._actionManager = this._actionManager;
  489. }
  490. this._nextActiveAction = this._nextActiveAction._child;
  491. }
  492. else {
  493. this._nextActiveAction = this;
  494. }
  495. };
  496. /**
  497. * Adds action to chain of actions, may be a DoNothingAction
  498. * @param action defines the next action to execute
  499. * @returns The action passed in
  500. * @see https://www.babylonjs-playground.com/#1T30HR#0
  501. */
  502. Action.prototype.then = function (action) {
  503. this._child = action;
  504. action._actionManager = this._actionManager;
  505. action._prepare();
  506. return action;
  507. };
  508. /**
  509. * Internal only
  510. * @hidden
  511. */
  512. Action.prototype._getProperty = function (propertyPath) {
  513. return this._actionManager._getProperty(propertyPath);
  514. };
  515. /**
  516. * Internal only
  517. * @hidden
  518. */
  519. Action.prototype._getEffectiveTarget = function (target, propertyPath) {
  520. return this._actionManager._getEffectiveTarget(target, propertyPath);
  521. };
  522. /**
  523. * Serialize placeholder for child classes
  524. * @param parent of child
  525. * @returns the serialized object
  526. */
  527. Action.prototype.serialize = function (parent) {
  528. };
  529. /**
  530. * Internal only called by serialize
  531. * @hidden
  532. */
  533. Action.prototype._serialize = function (serializedAction, parent) {
  534. var serializationObject = {
  535. type: 1,
  536. children: [],
  537. name: serializedAction.name,
  538. properties: serializedAction.properties || []
  539. };
  540. // Serialize child
  541. if (this._child) {
  542. this._child.serialize(serializationObject);
  543. }
  544. // Check if "this" has a condition
  545. if (this._condition) {
  546. var serializedCondition = this._condition.serialize();
  547. serializedCondition.children.push(serializationObject);
  548. if (parent) {
  549. parent.children.push(serializedCondition);
  550. }
  551. return serializedCondition;
  552. }
  553. if (parent) {
  554. parent.children.push(serializationObject);
  555. }
  556. return serializationObject;
  557. };
  558. /**
  559. * Internal only
  560. * @hidden
  561. */
  562. Action._SerializeValueAsString = function (value) {
  563. if (typeof value === "number") {
  564. return value.toString();
  565. }
  566. if (typeof value === "boolean") {
  567. return value ? "true" : "false";
  568. }
  569. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]) {
  570. return value.x + ", " + value.y;
  571. }
  572. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]) {
  573. return value.x + ", " + value.y + ", " + value.z;
  574. }
  575. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"]) {
  576. return value.r + ", " + value.g + ", " + value.b;
  577. }
  578. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"]) {
  579. return value.r + ", " + value.g + ", " + value.b + ", " + value.a;
  580. }
  581. return value; // string
  582. };
  583. /**
  584. * Internal only
  585. * @hidden
  586. */
  587. Action._GetTargetProperty = function (target) {
  588. return {
  589. name: "target",
  590. targetType: target._isMesh ? "MeshProperties"
  591. : target._isLight ? "LightProperties"
  592. : target._isCamera ? "CameraProperties"
  593. : "SceneProperties",
  594. value: target._isScene ? "Scene" : target.name
  595. };
  596. };
  597. return Action;
  598. }());
  599. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.Action"] = Action;
  600. /***/ }),
  601. /***/ "./Actions/actionEvent.ts":
  602. /*!********************************!*\
  603. !*** ./Actions/actionEvent.ts ***!
  604. \********************************/
  605. /*! exports provided: ActionEvent */
  606. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  607. "use strict";
  608. __webpack_require__.r(__webpack_exports__);
  609. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return ActionEvent; });
  610. /**
  611. * ActionEvent is the event being sent when an action is triggered.
  612. */
  613. var ActionEvent = /** @class */ (function () {
  614. /**
  615. * Creates a new ActionEvent
  616. * @param source The mesh or sprite that triggered the action
  617. * @param pointerX The X mouse cursor position at the time of the event
  618. * @param pointerY The Y mouse cursor position at the time of the event
  619. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  620. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  621. * @param additionalData additional data for the event
  622. */
  623. function ActionEvent(
  624. /** The mesh or sprite that triggered the action */
  625. source,
  626. /** The X mouse cursor position at the time of the event */
  627. pointerX,
  628. /** The Y mouse cursor position at the time of the event */
  629. pointerY,
  630. /** The mesh that is currently pointed at (can be null) */
  631. meshUnderPointer,
  632. /** the original (browser) event that triggered the ActionEvent */
  633. sourceEvent,
  634. /** additional data for the event */
  635. additionalData) {
  636. this.source = source;
  637. this.pointerX = pointerX;
  638. this.pointerY = pointerY;
  639. this.meshUnderPointer = meshUnderPointer;
  640. this.sourceEvent = sourceEvent;
  641. this.additionalData = additionalData;
  642. }
  643. /**
  644. * Helper function to auto-create an ActionEvent from a source mesh.
  645. * @param source The source mesh that triggered the event
  646. * @param evt The original (browser) event
  647. * @param additionalData additional data for the event
  648. * @returns the new ActionEvent
  649. */
  650. ActionEvent.CreateNew = function (source, evt, additionalData) {
  651. var scene = source.getScene();
  652. return new ActionEvent(source, scene.pointerX, scene.pointerY, scene.meshUnderPointer, evt, additionalData);
  653. };
  654. /**
  655. * Helper function to auto-create an ActionEvent from a source sprite
  656. * @param source The source sprite that triggered the event
  657. * @param scene Scene associated with the sprite
  658. * @param evt The original (browser) event
  659. * @param additionalData additional data for the event
  660. * @returns the new ActionEvent
  661. */
  662. ActionEvent.CreateNewFromSprite = function (source, scene, evt, additionalData) {
  663. return new ActionEvent(source, scene.pointerX, scene.pointerY, scene.meshUnderPointer, evt, additionalData);
  664. };
  665. /**
  666. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  667. * @param scene the scene where the event occurred
  668. * @param evt The original (browser) event
  669. * @returns the new ActionEvent
  670. */
  671. ActionEvent.CreateNewFromScene = function (scene, evt) {
  672. return new ActionEvent(null, scene.pointerX, scene.pointerY, scene.meshUnderPointer, evt);
  673. };
  674. /**
  675. * Helper function to auto-create an ActionEvent from a primitive
  676. * @param prim defines the target primitive
  677. * @param pointerPos defines the pointer position
  678. * @param evt The original (browser) event
  679. * @param additionalData additional data for the event
  680. * @returns the new ActionEvent
  681. */
  682. ActionEvent.CreateNewFromPrimitive = function (prim, pointerPos, evt, additionalData) {
  683. return new ActionEvent(prim, pointerPos.x, pointerPos.y, null, evt, additionalData);
  684. };
  685. return ActionEvent;
  686. }());
  687. /***/ }),
  688. /***/ "./Actions/actionManager.ts":
  689. /*!**********************************!*\
  690. !*** ./Actions/actionManager.ts ***!
  691. \**********************************/
  692. /*! exports provided: ActionManager */
  693. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  694. "use strict";
  695. __webpack_require__.r(__webpack_exports__);
  696. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return ActionManager; });
  697. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  698. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  699. /* harmony import */ var _condition__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./condition */ "./Actions/condition.ts");
  700. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  701. /* harmony import */ var _directActions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./directActions */ "./Actions/directActions.ts");
  702. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  703. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  704. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  705. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  706. /* harmony import */ var _abstractActionManager__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./abstractActionManager */ "./Actions/abstractActionManager.ts");
  707. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  708. /**
  709. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  710. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  712. */
  713. var ActionManager = /** @class */ (function (_super) {
  714. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ActionManager, _super);
  715. /**
  716. * Creates a new action manager
  717. * @param scene defines the hosting scene
  718. */
  719. function ActionManager(scene) {
  720. var _this = _super.call(this) || this;
  721. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  722. scene.actionManagers.push(_this);
  723. return _this;
  724. }
  725. // Methods
  726. /**
  727. * Releases all associated resources
  728. */
  729. ActionManager.prototype.dispose = function () {
  730. var index = this._scene.actionManagers.indexOf(this);
  731. for (var i = 0; i < this.actions.length; i++) {
  732. var action = this.actions[i];
  733. ActionManager.Triggers[action.trigger]--;
  734. if (ActionManager.Triggers[action.trigger] === 0) {
  735. delete ActionManager.Triggers[action.trigger];
  736. }
  737. }
  738. if (index > -1) {
  739. this._scene.actionManagers.splice(index, 1);
  740. }
  741. };
  742. /**
  743. * Gets hosting scene
  744. * @returns the hosting scene
  745. */
  746. ActionManager.prototype.getScene = function () {
  747. return this._scene;
  748. };
  749. /**
  750. * Does this action manager handles actions of any of the given triggers
  751. * @param triggers defines the triggers to be tested
  752. * @return a boolean indicating whether one (or more) of the triggers is handled
  753. */
  754. ActionManager.prototype.hasSpecificTriggers = function (triggers) {
  755. for (var index = 0; index < this.actions.length; index++) {
  756. var action = this.actions[index];
  757. if (triggers.indexOf(action.trigger) > -1) {
  758. return true;
  759. }
  760. }
  761. return false;
  762. };
  763. /**
  764. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  765. * speed.
  766. * @param triggerA defines the trigger to be tested
  767. * @param triggerB defines the trigger to be tested
  768. * @return a boolean indicating whether one (or more) of the triggers is handled
  769. */
  770. ActionManager.prototype.hasSpecificTriggers2 = function (triggerA, triggerB) {
  771. for (var index = 0; index < this.actions.length; index++) {
  772. var action = this.actions[index];
  773. if (triggerA == action.trigger || triggerB == action.trigger) {
  774. return true;
  775. }
  776. }
  777. return false;
  778. };
  779. /**
  780. * Does this action manager handles actions of a given trigger
  781. * @param trigger defines the trigger to be tested
  782. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  783. * @return whether the trigger is handled
  784. */
  785. ActionManager.prototype.hasSpecificTrigger = function (trigger, parameterPredicate) {
  786. for (var index = 0; index < this.actions.length; index++) {
  787. var action = this.actions[index];
  788. if (action.trigger === trigger) {
  789. if (parameterPredicate) {
  790. if (parameterPredicate(action.getTriggerParameter())) {
  791. return true;
  792. }
  793. }
  794. else {
  795. return true;
  796. }
  797. }
  798. }
  799. return false;
  800. };
  801. Object.defineProperty(ActionManager.prototype, "hasPointerTriggers", {
  802. /**
  803. * Does this action manager has pointer triggers
  804. */
  805. get: function () {
  806. for (var index = 0; index < this.actions.length; index++) {
  807. var action = this.actions[index];
  808. if (action.trigger >= ActionManager.OnPickTrigger && action.trigger <= ActionManager.OnPointerOutTrigger) {
  809. return true;
  810. }
  811. }
  812. return false;
  813. },
  814. enumerable: true,
  815. configurable: true
  816. });
  817. Object.defineProperty(ActionManager.prototype, "hasPickTriggers", {
  818. /**
  819. * Does this action manager has pick triggers
  820. */
  821. get: function () {
  822. for (var index = 0; index < this.actions.length; index++) {
  823. var action = this.actions[index];
  824. if (action.trigger >= ActionManager.OnPickTrigger && action.trigger <= ActionManager.OnPickUpTrigger) {
  825. return true;
  826. }
  827. }
  828. return false;
  829. },
  830. enumerable: true,
  831. configurable: true
  832. });
  833. /**
  834. * Registers an action to this action manager
  835. * @param action defines the action to be registered
  836. * @return the action amended (prepared) after registration
  837. */
  838. ActionManager.prototype.registerAction = function (action) {
  839. if (action.trigger === ActionManager.OnEveryFrameTrigger) {
  840. if (this.getScene().actionManager !== this) {
  841. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Warn("OnEveryFrameTrigger can only be used with scene.actionManager");
  842. return null;
  843. }
  844. }
  845. this.actions.push(action);
  846. if (ActionManager.Triggers[action.trigger]) {
  847. ActionManager.Triggers[action.trigger]++;
  848. }
  849. else {
  850. ActionManager.Triggers[action.trigger] = 1;
  851. }
  852. action._actionManager = this;
  853. action._prepare();
  854. return action;
  855. };
  856. /**
  857. * Unregisters an action to this action manager
  858. * @param action defines the action to be unregistered
  859. * @return a boolean indicating whether the action has been unregistered
  860. */
  861. ActionManager.prototype.unregisterAction = function (action) {
  862. var index = this.actions.indexOf(action);
  863. if (index !== -1) {
  864. this.actions.splice(index, 1);
  865. ActionManager.Triggers[action.trigger] -= 1;
  866. if (ActionManager.Triggers[action.trigger] === 0) {
  867. delete ActionManager.Triggers[action.trigger];
  868. }
  869. delete action._actionManager;
  870. return true;
  871. }
  872. return false;
  873. };
  874. /**
  875. * Process a specific trigger
  876. * @param trigger defines the trigger to process
  877. * @param evt defines the event details to be processed
  878. */
  879. ActionManager.prototype.processTrigger = function (trigger, evt) {
  880. for (var index = 0; index < this.actions.length; index++) {
  881. var action = this.actions[index];
  882. if (action.trigger === trigger) {
  883. if (evt) {
  884. if (trigger === ActionManager.OnKeyUpTrigger
  885. || trigger === ActionManager.OnKeyDownTrigger) {
  886. var parameter = action.getTriggerParameter();
  887. if (parameter && parameter !== evt.sourceEvent.keyCode) {
  888. if (!parameter.toLowerCase) {
  889. continue;
  890. }
  891. var lowerCase = parameter.toLowerCase();
  892. if (lowerCase !== evt.sourceEvent.key) {
  893. var unicode = evt.sourceEvent.charCode ? evt.sourceEvent.charCode : evt.sourceEvent.keyCode;
  894. var actualkey = String.fromCharCode(unicode).toLowerCase();
  895. if (actualkey !== lowerCase) {
  896. continue;
  897. }
  898. }
  899. }
  900. }
  901. }
  902. action._executeCurrent(evt);
  903. }
  904. }
  905. };
  906. /** @hidden */
  907. ActionManager.prototype._getEffectiveTarget = function (target, propertyPath) {
  908. var properties = propertyPath.split(".");
  909. for (var index = 0; index < properties.length - 1; index++) {
  910. target = target[properties[index]];
  911. }
  912. return target;
  913. };
  914. /** @hidden */
  915. ActionManager.prototype._getProperty = function (propertyPath) {
  916. var properties = propertyPath.split(".");
  917. return properties[properties.length - 1];
  918. };
  919. /**
  920. * Serialize this manager to a JSON object
  921. * @param name defines the property name to store this manager
  922. * @returns a JSON representation of this manager
  923. */
  924. ActionManager.prototype.serialize = function (name) {
  925. var root = {
  926. children: new Array(),
  927. name: name,
  928. type: 3,
  929. properties: new Array() // Empty for root but required
  930. };
  931. for (var i = 0; i < this.actions.length; i++) {
  932. var triggerObject = {
  933. type: 0,
  934. children: new Array(),
  935. name: ActionManager.GetTriggerName(this.actions[i].trigger),
  936. properties: new Array()
  937. };
  938. var triggerOptions = this.actions[i].triggerOptions;
  939. if (triggerOptions && typeof triggerOptions !== "number") {
  940. if (triggerOptions.parameter instanceof Node) {
  941. triggerObject.properties.push(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(triggerOptions.parameter));
  942. }
  943. else {
  944. var parameter = {};
  945. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_7__["DeepCopier"].DeepCopy(triggerOptions.parameter, parameter, ["mesh"]);
  946. if (triggerOptions.parameter && triggerOptions.parameter.mesh) {
  947. parameter._meshId = triggerOptions.parameter.mesh.id;
  948. }
  949. triggerObject.properties.push({ name: "parameter", targetType: null, value: parameter });
  950. }
  951. }
  952. // Serialize child action, recursively
  953. this.actions[i].serialize(triggerObject);
  954. // Add serialized trigger
  955. root.children.push(triggerObject);
  956. }
  957. return root;
  958. };
  959. /**
  960. * Creates a new ActionManager from a JSON data
  961. * @param parsedActions defines the JSON data to read from
  962. * @param object defines the hosting mesh
  963. * @param scene defines the hosting scene
  964. */
  965. ActionManager.Parse = function (parsedActions, object, scene) {
  966. var actionManager = new ActionManager(scene);
  967. if (object === null) {
  968. scene.actionManager = actionManager;
  969. }
  970. else {
  971. object.actionManager = actionManager;
  972. }
  973. // instanciate a new object
  974. var instanciate = function (name, params) {
  975. var internalClassType = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass("BABYLON." + name);
  976. if (internalClassType) {
  977. var newInstance = Object.create(internalClassType.prototype);
  978. newInstance.constructor.apply(newInstance, params);
  979. return newInstance;
  980. }
  981. };
  982. var parseParameter = function (name, value, target, propertyPath) {
  983. if (propertyPath === null) {
  984. // String, boolean or float
  985. var floatValue = parseFloat(value);
  986. if (value === "true" || value === "false") {
  987. return value === "true";
  988. }
  989. else {
  990. return isNaN(floatValue) ? value : floatValue;
  991. }
  992. }
  993. var effectiveTarget = propertyPath.split(".");
  994. var values = value.split(",");
  995. // Get effective Target
  996. for (var i = 0; i < effectiveTarget.length; i++) {
  997. target = target[effectiveTarget[i]];
  998. }
  999. // Return appropriate value with its type
  1000. if (typeof (target) === "boolean") {
  1001. return values[0] === "true";
  1002. }
  1003. if (typeof (target) === "string") {
  1004. return values[0];
  1005. }
  1006. // Parameters with multiple values such as Vector3 etc.
  1007. var split = new Array();
  1008. for (var i = 0; i < values.length; i++) {
  1009. split.push(parseFloat(values[i]));
  1010. }
  1011. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]) {
  1012. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(split);
  1013. }
  1014. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"]) {
  1015. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"].FromArray(split);
  1016. }
  1017. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"]) {
  1018. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(split);
  1019. }
  1020. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"]) {
  1021. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].FromArray(split);
  1022. }
  1023. return parseFloat(values[0]);
  1024. };
  1025. // traverse graph per trigger
  1026. var traverse = function (parsedAction, trigger, condition, action, combineArray) {
  1027. if (combineArray === void 0) { combineArray = null; }
  1028. if (parsedAction.detached) {
  1029. return;
  1030. }
  1031. var parameters = new Array();
  1032. var target = null;
  1033. var propertyPath = null;
  1034. var combine = parsedAction.combine && parsedAction.combine.length > 0;
  1035. // Parameters
  1036. if (parsedAction.type === 2) {
  1037. parameters.push(actionManager);
  1038. }
  1039. else {
  1040. parameters.push(trigger);
  1041. }
  1042. if (combine) {
  1043. var actions = new Array();
  1044. for (var j = 0; j < parsedAction.combine.length; j++) {
  1045. traverse(parsedAction.combine[j], ActionManager.NothingTrigger, condition, action, actions);
  1046. }
  1047. parameters.push(actions);
  1048. }
  1049. else {
  1050. for (var i = 0; i < parsedAction.properties.length; i++) {
  1051. var value = parsedAction.properties[i].value;
  1052. var name = parsedAction.properties[i].name;
  1053. var targetType = parsedAction.properties[i].targetType;
  1054. if (name === "target") {
  1055. if (targetType !== null && targetType === "SceneProperties") {
  1056. value = target = scene;
  1057. }
  1058. else {
  1059. value = target = scene.getNodeByName(value);
  1060. }
  1061. }
  1062. else if (name === "parent") {
  1063. value = scene.getNodeByName(value);
  1064. }
  1065. else if (name === "sound") {
  1066. // Can not externalize to component, so only checks for the presence off the API.
  1067. if (scene.getSoundByName) {
  1068. value = scene.getSoundByName(value);
  1069. }
  1070. }
  1071. else if (name !== "propertyPath") {
  1072. if (parsedAction.type === 2 && name === "operator") {
  1073. value = _condition__WEBPACK_IMPORTED_MODULE_2__["ValueCondition"][value];
  1074. }
  1075. else {
  1076. value = parseParameter(name, value, target, name === "value" ? propertyPath : null);
  1077. }
  1078. }
  1079. else {
  1080. propertyPath = value;
  1081. }
  1082. parameters.push(value);
  1083. }
  1084. }
  1085. if (combineArray === null) {
  1086. parameters.push(condition);
  1087. }
  1088. else {
  1089. parameters.push(null);
  1090. }
  1091. // If interpolate value action
  1092. if (parsedAction.name === "InterpolateValueAction") {
  1093. var param = parameters[parameters.length - 2];
  1094. parameters[parameters.length - 1] = param;
  1095. parameters[parameters.length - 2] = condition;
  1096. }
  1097. // Action or condition(s) and not CombineAction
  1098. var newAction = instanciate(parsedAction.name, parameters);
  1099. if (newAction instanceof _condition__WEBPACK_IMPORTED_MODULE_2__["Condition"] && condition !== null) {
  1100. var nothing = new _directActions__WEBPACK_IMPORTED_MODULE_4__["DoNothingAction"](trigger, condition);
  1101. if (action) {
  1102. action.then(nothing);
  1103. }
  1104. else {
  1105. actionManager.registerAction(nothing);
  1106. }
  1107. action = nothing;
  1108. }
  1109. if (combineArray === null) {
  1110. if (newAction instanceof _condition__WEBPACK_IMPORTED_MODULE_2__["Condition"]) {
  1111. condition = newAction;
  1112. newAction = action;
  1113. }
  1114. else {
  1115. condition = null;
  1116. if (action) {
  1117. action.then(newAction);
  1118. }
  1119. else {
  1120. actionManager.registerAction(newAction);
  1121. }
  1122. }
  1123. }
  1124. else {
  1125. combineArray.push(newAction);
  1126. }
  1127. for (var i = 0; i < parsedAction.children.length; i++) {
  1128. traverse(parsedAction.children[i], trigger, condition, newAction, null);
  1129. }
  1130. };
  1131. // triggers
  1132. for (var i = 0; i < parsedActions.children.length; i++) {
  1133. var triggerParams;
  1134. var trigger = parsedActions.children[i];
  1135. if (trigger.properties.length > 0) {
  1136. var param = trigger.properties[0].value;
  1137. var value = trigger.properties[0].targetType === null ? param : scene.getMeshByName(param);
  1138. if (value._meshId) {
  1139. value.mesh = scene.getMeshByID(value._meshId);
  1140. }
  1141. triggerParams = { trigger: ActionManager[trigger.name], parameter: value };
  1142. }
  1143. else {
  1144. triggerParams = ActionManager[trigger.name];
  1145. }
  1146. for (var j = 0; j < trigger.children.length; j++) {
  1147. if (!trigger.detached) {
  1148. traverse(trigger.children[j], triggerParams, null, null);
  1149. }
  1150. }
  1151. }
  1152. };
  1153. /**
  1154. * Get a trigger name by index
  1155. * @param trigger defines the trigger index
  1156. * @returns a trigger name
  1157. */
  1158. ActionManager.GetTriggerName = function (trigger) {
  1159. switch (trigger) {
  1160. case 0: return "NothingTrigger";
  1161. case 1: return "OnPickTrigger";
  1162. case 2: return "OnLeftPickTrigger";
  1163. case 3: return "OnRightPickTrigger";
  1164. case 4: return "OnCenterPickTrigger";
  1165. case 5: return "OnPickDownTrigger";
  1166. case 6: return "OnPickUpTrigger";
  1167. case 7: return "OnLongPressTrigger";
  1168. case 8: return "OnPointerOverTrigger";
  1169. case 9: return "OnPointerOutTrigger";
  1170. case 10: return "OnEveryFrameTrigger";
  1171. case 11: return "OnIntersectionEnterTrigger";
  1172. case 12: return "OnIntersectionExitTrigger";
  1173. case 13: return "OnKeyDownTrigger";
  1174. case 14: return "OnKeyUpTrigger";
  1175. case 15: return "OnPickOutTrigger";
  1176. default: return "";
  1177. }
  1178. };
  1179. /**
  1180. * Nothing
  1181. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1182. */
  1183. ActionManager.NothingTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_NothingTrigger;
  1184. /**
  1185. * On pick
  1186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1187. */
  1188. ActionManager.OnPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPickTrigger;
  1189. /**
  1190. * On left pick
  1191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1192. */
  1193. ActionManager.OnLeftPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnLeftPickTrigger;
  1194. /**
  1195. * On right pick
  1196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1197. */
  1198. ActionManager.OnRightPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnRightPickTrigger;
  1199. /**
  1200. * On center pick
  1201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1202. */
  1203. ActionManager.OnCenterPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnCenterPickTrigger;
  1204. /**
  1205. * On pick down
  1206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1207. */
  1208. ActionManager.OnPickDownTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPickDownTrigger;
  1209. /**
  1210. * On double pick
  1211. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1212. */
  1213. ActionManager.OnDoublePickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnDoublePickTrigger;
  1214. /**
  1215. * On pick up
  1216. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1217. */
  1218. ActionManager.OnPickUpTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPickUpTrigger;
  1219. /**
  1220. * On pick out.
  1221. * This trigger will only be raised if you also declared a OnPickDown
  1222. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1223. */
  1224. ActionManager.OnPickOutTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPickOutTrigger;
  1225. /**
  1226. * On long press
  1227. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1228. */
  1229. ActionManager.OnLongPressTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnLongPressTrigger;
  1230. /**
  1231. * On pointer over
  1232. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1233. */
  1234. ActionManager.OnPointerOverTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPointerOverTrigger;
  1235. /**
  1236. * On pointer out
  1237. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1238. */
  1239. ActionManager.OnPointerOutTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPointerOutTrigger;
  1240. /**
  1241. * On every frame
  1242. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1243. */
  1244. ActionManager.OnEveryFrameTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnEveryFrameTrigger;
  1245. /**
  1246. * On intersection enter
  1247. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1248. */
  1249. ActionManager.OnIntersectionEnterTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnIntersectionEnterTrigger;
  1250. /**
  1251. * On intersection exit
  1252. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1253. */
  1254. ActionManager.OnIntersectionExitTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnIntersectionExitTrigger;
  1255. /**
  1256. * On key down
  1257. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1258. */
  1259. ActionManager.OnKeyDownTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnKeyDownTrigger;
  1260. /**
  1261. * On key up
  1262. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1263. */
  1264. ActionManager.OnKeyUpTrigger = 15;
  1265. return ActionManager;
  1266. }(_abstractActionManager__WEBPACK_IMPORTED_MODULE_9__["AbstractActionManager"]));
  1267. /***/ }),
  1268. /***/ "./Actions/condition.ts":
  1269. /*!******************************!*\
  1270. !*** ./Actions/condition.ts ***!
  1271. \******************************/
  1272. /*! exports provided: Condition, ValueCondition, PredicateCondition, StateCondition */
  1273. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1274. "use strict";
  1275. __webpack_require__.r(__webpack_exports__);
  1276. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return Condition; });
  1277. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return ValueCondition; });
  1278. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return PredicateCondition; });
  1279. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return StateCondition; });
  1280. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  1281. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  1282. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  1283. /**
  1284. * A Condition applied to an Action
  1285. */
  1286. var Condition = /** @class */ (function () {
  1287. /**
  1288. * Creates a new Condition
  1289. * @param actionManager the manager of the action the condition is applied to
  1290. */
  1291. function Condition(actionManager) {
  1292. this._actionManager = actionManager;
  1293. }
  1294. /**
  1295. * Check if the current condition is valid
  1296. * @returns a boolean
  1297. */
  1298. Condition.prototype.isValid = function () {
  1299. return true;
  1300. };
  1301. /**
  1302. * Internal only
  1303. * @hidden
  1304. */
  1305. Condition.prototype._getProperty = function (propertyPath) {
  1306. return this._actionManager._getProperty(propertyPath);
  1307. };
  1308. /**
  1309. * Internal only
  1310. * @hidden
  1311. */
  1312. Condition.prototype._getEffectiveTarget = function (target, propertyPath) {
  1313. return this._actionManager._getEffectiveTarget(target, propertyPath);
  1314. };
  1315. /**
  1316. * Serialize placeholder for child classes
  1317. * @returns the serialized object
  1318. */
  1319. Condition.prototype.serialize = function () {
  1320. };
  1321. /**
  1322. * Internal only
  1323. * @hidden
  1324. */
  1325. Condition.prototype._serialize = function (serializedCondition) {
  1326. return {
  1327. type: 2,
  1328. children: [],
  1329. name: serializedCondition.name,
  1330. properties: serializedCondition.properties
  1331. };
  1332. };
  1333. return Condition;
  1334. }());
  1335. /**
  1336. * Defines specific conditional operators as extensions of Condition
  1337. */
  1338. var ValueCondition = /** @class */ (function (_super) {
  1339. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ValueCondition, _super);
  1340. /**
  1341. * Creates a new ValueCondition
  1342. * @param actionManager manager for the action the condition applies to
  1343. * @param target for the action
  1344. * @param propertyPath path to specify the property of the target the conditional operator uses
  1345. * @param value the value compared by the conditional operator against the current value of the property
  1346. * @param operator the conditional operator, default ValueCondition.IsEqual
  1347. */
  1348. function ValueCondition(actionManager, target,
  1349. /** path to specify the property of the target the conditional operator uses */
  1350. propertyPath,
  1351. /** the value compared by the conditional operator against the current value of the property */
  1352. value,
  1353. /** the conditional operator, default ValueCondition.IsEqual */
  1354. operator) {
  1355. if (operator === void 0) { operator = ValueCondition.IsEqual; }
  1356. var _this = _super.call(this, actionManager) || this;
  1357. _this.propertyPath = propertyPath;
  1358. _this.value = value;
  1359. _this.operator = operator;
  1360. _this._target = target;
  1361. _this._effectiveTarget = _this._getEffectiveTarget(target, _this.propertyPath);
  1362. _this._property = _this._getProperty(_this.propertyPath);
  1363. return _this;
  1364. }
  1365. Object.defineProperty(ValueCondition, "IsEqual", {
  1366. /**
  1367. * returns the number for IsEqual
  1368. */
  1369. get: function () {
  1370. return ValueCondition._IsEqual;
  1371. },
  1372. enumerable: true,
  1373. configurable: true
  1374. });
  1375. Object.defineProperty(ValueCondition, "IsDifferent", {
  1376. /**
  1377. * Returns the number for IsDifferent
  1378. */
  1379. get: function () {
  1380. return ValueCondition._IsDifferent;
  1381. },
  1382. enumerable: true,
  1383. configurable: true
  1384. });
  1385. Object.defineProperty(ValueCondition, "IsGreater", {
  1386. /**
  1387. * Returns the number for IsGreater
  1388. */
  1389. get: function () {
  1390. return ValueCondition._IsGreater;
  1391. },
  1392. enumerable: true,
  1393. configurable: true
  1394. });
  1395. Object.defineProperty(ValueCondition, "IsLesser", {
  1396. /**
  1397. * Returns the number for IsLesser
  1398. */
  1399. get: function () {
  1400. return ValueCondition._IsLesser;
  1401. },
  1402. enumerable: true,
  1403. configurable: true
  1404. });
  1405. /**
  1406. * Compares the given value with the property value for the specified conditional operator
  1407. * @returns the result of the comparison
  1408. */
  1409. ValueCondition.prototype.isValid = function () {
  1410. switch (this.operator) {
  1411. case ValueCondition.IsGreater:
  1412. return this._effectiveTarget[this._property] > this.value;
  1413. case ValueCondition.IsLesser:
  1414. return this._effectiveTarget[this._property] < this.value;
  1415. case ValueCondition.IsEqual:
  1416. case ValueCondition.IsDifferent:
  1417. var check;
  1418. if (this.value.equals) {
  1419. check = this.value.equals(this._effectiveTarget[this._property]);
  1420. }
  1421. else {
  1422. check = this.value === this._effectiveTarget[this._property];
  1423. }
  1424. return this.operator === ValueCondition.IsEqual ? check : !check;
  1425. }
  1426. return false;
  1427. };
  1428. /**
  1429. * Serialize the ValueCondition into a JSON compatible object
  1430. * @returns serialization object
  1431. */
  1432. ValueCondition.prototype.serialize = function () {
  1433. return this._serialize({
  1434. name: "ValueCondition",
  1435. properties: [
  1436. _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._GetTargetProperty(this._target),
  1437. { name: "propertyPath", value: this.propertyPath },
  1438. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.value) },
  1439. { name: "operator", value: ValueCondition.GetOperatorName(this.operator) }
  1440. ]
  1441. });
  1442. };
  1443. /**
  1444. * Gets the name of the conditional operator for the ValueCondition
  1445. * @param operator the conditional operator
  1446. * @returns the name
  1447. */
  1448. ValueCondition.GetOperatorName = function (operator) {
  1449. switch (operator) {
  1450. case ValueCondition._IsEqual: return "IsEqual";
  1451. case ValueCondition._IsDifferent: return "IsDifferent";
  1452. case ValueCondition._IsGreater: return "IsGreater";
  1453. case ValueCondition._IsLesser: return "IsLesser";
  1454. default: return "";
  1455. }
  1456. };
  1457. /**
  1458. * Internal only
  1459. * @hidden
  1460. */
  1461. ValueCondition._IsEqual = 0;
  1462. /**
  1463. * Internal only
  1464. * @hidden
  1465. */
  1466. ValueCondition._IsDifferent = 1;
  1467. /**
  1468. * Internal only
  1469. * @hidden
  1470. */
  1471. ValueCondition._IsGreater = 2;
  1472. /**
  1473. * Internal only
  1474. * @hidden
  1475. */
  1476. ValueCondition._IsLesser = 3;
  1477. return ValueCondition;
  1478. }(Condition));
  1479. /**
  1480. * Defines a predicate condition as an extension of Condition
  1481. */
  1482. var PredicateCondition = /** @class */ (function (_super) {
  1483. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PredicateCondition, _super);
  1484. /**
  1485. * Creates a new PredicateCondition
  1486. * @param actionManager manager for the action the condition applies to
  1487. * @param predicate defines the predicate function used to validate the condition
  1488. */
  1489. function PredicateCondition(actionManager,
  1490. /** defines the predicate function used to validate the condition */
  1491. predicate) {
  1492. var _this = _super.call(this, actionManager) || this;
  1493. _this.predicate = predicate;
  1494. return _this;
  1495. }
  1496. /**
  1497. * @returns the validity of the predicate condition
  1498. */
  1499. PredicateCondition.prototype.isValid = function () {
  1500. return this.predicate();
  1501. };
  1502. return PredicateCondition;
  1503. }(Condition));
  1504. /**
  1505. * Defines a state condition as an extension of Condition
  1506. */
  1507. var StateCondition = /** @class */ (function (_super) {
  1508. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StateCondition, _super);
  1509. /**
  1510. * Creates a new StateCondition
  1511. * @param actionManager manager for the action the condition applies to
  1512. * @param target of the condition
  1513. * @param value to compare with target state
  1514. */
  1515. function StateCondition(actionManager, target,
  1516. /** Value to compare with target state */
  1517. value) {
  1518. var _this = _super.call(this, actionManager) || this;
  1519. _this.value = value;
  1520. _this._target = target;
  1521. return _this;
  1522. }
  1523. /**
  1524. * Gets a boolean indicating if the current condition is met
  1525. * @returns the validity of the state
  1526. */
  1527. StateCondition.prototype.isValid = function () {
  1528. return this._target.state === this.value;
  1529. };
  1530. /**
  1531. * Serialize the StateCondition into a JSON compatible object
  1532. * @returns serialization object
  1533. */
  1534. StateCondition.prototype.serialize = function () {
  1535. return this._serialize({
  1536. name: "StateCondition",
  1537. properties: [
  1538. _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._GetTargetProperty(this._target),
  1539. { name: "value", value: this.value }
  1540. ]
  1541. });
  1542. };
  1543. return StateCondition;
  1544. }(Condition));
  1545. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.ValueCondition"] = ValueCondition;
  1546. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.PredicateCondition"] = PredicateCondition;
  1547. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.StateCondition"] = StateCondition;
  1548. /***/ }),
  1549. /***/ "./Actions/directActions.ts":
  1550. /*!**********************************!*\
  1551. !*** ./Actions/directActions.ts ***!
  1552. \**********************************/
  1553. /*! exports provided: SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction */
  1554. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1555. "use strict";
  1556. __webpack_require__.r(__webpack_exports__);
  1557. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return SwitchBooleanAction; });
  1558. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return SetStateAction; });
  1559. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return SetValueAction; });
  1560. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return IncrementValueAction; });
  1561. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return PlayAnimationAction; });
  1562. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return StopAnimationAction; });
  1563. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return DoNothingAction; });
  1564. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return CombineAction; });
  1565. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return ExecuteCodeAction; });
  1566. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return SetParentAction; });
  1567. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  1568. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  1569. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  1570. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  1571. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  1572. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  1573. /**
  1574. * This defines an action responsible to toggle a boolean once triggered.
  1575. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1576. */
  1577. var SwitchBooleanAction = /** @class */ (function (_super) {
  1578. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SwitchBooleanAction, _super);
  1579. /**
  1580. * Instantiate the action
  1581. * @param triggerOptions defines the trigger options
  1582. * @param target defines the object containing the boolean
  1583. * @param propertyPath defines the path to the boolean property in the target object
  1584. * @param condition defines the trigger related conditions
  1585. */
  1586. function SwitchBooleanAction(triggerOptions, target, propertyPath, condition) {
  1587. var _this = _super.call(this, triggerOptions, condition) || this;
  1588. _this.propertyPath = propertyPath;
  1589. _this._target = _this._effectiveTarget = target;
  1590. return _this;
  1591. }
  1592. /** @hidden */
  1593. SwitchBooleanAction.prototype._prepare = function () {
  1594. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  1595. this._property = this._getProperty(this.propertyPath);
  1596. };
  1597. /**
  1598. * Execute the action toggle the boolean value.
  1599. */
  1600. SwitchBooleanAction.prototype.execute = function () {
  1601. this._effectiveTarget[this._property] = !this._effectiveTarget[this._property];
  1602. };
  1603. /**
  1604. * Serializes the actions and its related information.
  1605. * @param parent defines the object to serialize in
  1606. * @returns the serialized object
  1607. */
  1608. SwitchBooleanAction.prototype.serialize = function (parent) {
  1609. return _super.prototype._serialize.call(this, {
  1610. name: "SwitchBooleanAction",
  1611. properties: [
  1612. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1613. { name: "propertyPath", value: this.propertyPath }
  1614. ]
  1615. }, parent);
  1616. };
  1617. return SwitchBooleanAction;
  1618. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1619. /**
  1620. * This defines an action responsible to set a the state field of the target
  1621. * to a desired value once triggered.
  1622. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1623. */
  1624. var SetStateAction = /** @class */ (function (_super) {
  1625. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SetStateAction, _super);
  1626. /**
  1627. * Instantiate the action
  1628. * @param triggerOptions defines the trigger options
  1629. * @param target defines the object containing the state property
  1630. * @param value defines the value to store in the state field
  1631. * @param condition defines the trigger related conditions
  1632. */
  1633. function SetStateAction(triggerOptions, target, value, condition) {
  1634. var _this = _super.call(this, triggerOptions, condition) || this;
  1635. _this.value = value;
  1636. _this._target = target;
  1637. return _this;
  1638. }
  1639. /**
  1640. * Execute the action and store the value on the target state property.
  1641. */
  1642. SetStateAction.prototype.execute = function () {
  1643. this._target.state = this.value;
  1644. };
  1645. /**
  1646. * Serializes the actions and its related information.
  1647. * @param parent defines the object to serialize in
  1648. * @returns the serialized object
  1649. */
  1650. SetStateAction.prototype.serialize = function (parent) {
  1651. return _super.prototype._serialize.call(this, {
  1652. name: "SetStateAction",
  1653. properties: [
  1654. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1655. { name: "value", value: this.value }
  1656. ]
  1657. }, parent);
  1658. };
  1659. return SetStateAction;
  1660. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1661. /**
  1662. * This defines an action responsible to set a property of the target
  1663. * to a desired value once triggered.
  1664. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1665. */
  1666. var SetValueAction = /** @class */ (function (_super) {
  1667. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SetValueAction, _super);
  1668. /**
  1669. * Instantiate the action
  1670. * @param triggerOptions defines the trigger options
  1671. * @param target defines the object containing the property
  1672. * @param propertyPath defines the path of the property to set in the target
  1673. * @param value defines the value to set in the property
  1674. * @param condition defines the trigger related conditions
  1675. */
  1676. function SetValueAction(triggerOptions, target, propertyPath, value, condition) {
  1677. var _this = _super.call(this, triggerOptions, condition) || this;
  1678. _this.propertyPath = propertyPath;
  1679. _this.value = value;
  1680. _this._target = _this._effectiveTarget = target;
  1681. return _this;
  1682. }
  1683. /** @hidden */
  1684. SetValueAction.prototype._prepare = function () {
  1685. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  1686. this._property = this._getProperty(this.propertyPath);
  1687. };
  1688. /**
  1689. * Execute the action and set the targetted property to the desired value.
  1690. */
  1691. SetValueAction.prototype.execute = function () {
  1692. this._effectiveTarget[this._property] = this.value;
  1693. if (this._target.markAsDirty) {
  1694. this._target.markAsDirty(this._property);
  1695. }
  1696. };
  1697. /**
  1698. * Serializes the actions and its related information.
  1699. * @param parent defines the object to serialize in
  1700. * @returns the serialized object
  1701. */
  1702. SetValueAction.prototype.serialize = function (parent) {
  1703. return _super.prototype._serialize.call(this, {
  1704. name: "SetValueAction",
  1705. properties: [
  1706. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1707. { name: "propertyPath", value: this.propertyPath },
  1708. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._SerializeValueAsString(this.value) }
  1709. ]
  1710. }, parent);
  1711. };
  1712. return SetValueAction;
  1713. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1714. /**
  1715. * This defines an action responsible to increment the target value
  1716. * to a desired value once triggered.
  1717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1718. */
  1719. var IncrementValueAction = /** @class */ (function (_super) {
  1720. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](IncrementValueAction, _super);
  1721. /**
  1722. * Instantiate the action
  1723. * @param triggerOptions defines the trigger options
  1724. * @param target defines the object containing the property
  1725. * @param propertyPath defines the path of the property to increment in the target
  1726. * @param value defines the value value we should increment the property by
  1727. * @param condition defines the trigger related conditions
  1728. */
  1729. function IncrementValueAction(triggerOptions, target, propertyPath, value, condition) {
  1730. var _this = _super.call(this, triggerOptions, condition) || this;
  1731. _this.propertyPath = propertyPath;
  1732. _this.value = value;
  1733. _this._target = _this._effectiveTarget = target;
  1734. return _this;
  1735. }
  1736. /** @hidden */
  1737. IncrementValueAction.prototype._prepare = function () {
  1738. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  1739. this._property = this._getProperty(this.propertyPath);
  1740. if (typeof this._effectiveTarget[this._property] !== "number") {
  1741. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Warning: IncrementValueAction can only be used with number values");
  1742. }
  1743. };
  1744. /**
  1745. * Execute the action and increment the target of the value amount.
  1746. */
  1747. IncrementValueAction.prototype.execute = function () {
  1748. this._effectiveTarget[this._property] += this.value;
  1749. if (this._target.markAsDirty) {
  1750. this._target.markAsDirty(this._property);
  1751. }
  1752. };
  1753. /**
  1754. * Serializes the actions and its related information.
  1755. * @param parent defines the object to serialize in
  1756. * @returns the serialized object
  1757. */
  1758. IncrementValueAction.prototype.serialize = function (parent) {
  1759. return _super.prototype._serialize.call(this, {
  1760. name: "IncrementValueAction",
  1761. properties: [
  1762. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1763. { name: "propertyPath", value: this.propertyPath },
  1764. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._SerializeValueAsString(this.value) }
  1765. ]
  1766. }, parent);
  1767. };
  1768. return IncrementValueAction;
  1769. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1770. /**
  1771. * This defines an action responsible to start an animation once triggered.
  1772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1773. */
  1774. var PlayAnimationAction = /** @class */ (function (_super) {
  1775. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlayAnimationAction, _super);
  1776. /**
  1777. * Instantiate the action
  1778. * @param triggerOptions defines the trigger options
  1779. * @param target defines the target animation or animation name
  1780. * @param from defines from where the animation should start (animation frame)
  1781. * @param end defines where the animation should stop (animation frame)
  1782. * @param loop defines if the animation should loop or stop after the first play
  1783. * @param condition defines the trigger related conditions
  1784. */
  1785. function PlayAnimationAction(triggerOptions, target, from, to, loop, condition) {
  1786. var _this = _super.call(this, triggerOptions, condition) || this;
  1787. _this.from = from;
  1788. _this.to = to;
  1789. _this.loop = loop;
  1790. _this._target = target;
  1791. return _this;
  1792. }
  1793. /** @hidden */
  1794. PlayAnimationAction.prototype._prepare = function () {
  1795. };
  1796. /**
  1797. * Execute the action and play the animation.
  1798. */
  1799. PlayAnimationAction.prototype.execute = function () {
  1800. var scene = this._actionManager.getScene();
  1801. scene.beginAnimation(this._target, this.from, this.to, this.loop);
  1802. };
  1803. /**
  1804. * Serializes the actions and its related information.
  1805. * @param parent defines the object to serialize in
  1806. * @returns the serialized object
  1807. */
  1808. PlayAnimationAction.prototype.serialize = function (parent) {
  1809. return _super.prototype._serialize.call(this, {
  1810. name: "PlayAnimationAction",
  1811. properties: [
  1812. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1813. { name: "from", value: String(this.from) },
  1814. { name: "to", value: String(this.to) },
  1815. { name: "loop", value: _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._SerializeValueAsString(this.loop) || false }
  1816. ]
  1817. }, parent);
  1818. };
  1819. return PlayAnimationAction;
  1820. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1821. /**
  1822. * This defines an action responsible to stop an animation once triggered.
  1823. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1824. */
  1825. var StopAnimationAction = /** @class */ (function (_super) {
  1826. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StopAnimationAction, _super);
  1827. /**
  1828. * Instantiate the action
  1829. * @param triggerOptions defines the trigger options
  1830. * @param target defines the target animation or animation name
  1831. * @param condition defines the trigger related conditions
  1832. */
  1833. function StopAnimationAction(triggerOptions, target, condition) {
  1834. var _this = _super.call(this, triggerOptions, condition) || this;
  1835. _this._target = target;
  1836. return _this;
  1837. }
  1838. /** @hidden */
  1839. StopAnimationAction.prototype._prepare = function () {
  1840. };
  1841. /**
  1842. * Execute the action and stop the animation.
  1843. */
  1844. StopAnimationAction.prototype.execute = function () {
  1845. var scene = this._actionManager.getScene();
  1846. scene.stopAnimation(this._target);
  1847. };
  1848. /**
  1849. * Serializes the actions and its related information.
  1850. * @param parent defines the object to serialize in
  1851. * @returns the serialized object
  1852. */
  1853. StopAnimationAction.prototype.serialize = function (parent) {
  1854. return _super.prototype._serialize.call(this, {
  1855. name: "StopAnimationAction",
  1856. properties: [_action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target)]
  1857. }, parent);
  1858. };
  1859. return StopAnimationAction;
  1860. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1861. /**
  1862. * This defines an action responsible that does nothing once triggered.
  1863. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1864. */
  1865. var DoNothingAction = /** @class */ (function (_super) {
  1866. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DoNothingAction, _super);
  1867. /**
  1868. * Instantiate the action
  1869. * @param triggerOptions defines the trigger options
  1870. * @param condition defines the trigger related conditions
  1871. */
  1872. function DoNothingAction(triggerOptions, condition) {
  1873. if (triggerOptions === void 0) { triggerOptions = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_NothingTrigger; }
  1874. return _super.call(this, triggerOptions, condition) || this;
  1875. }
  1876. /**
  1877. * Execute the action and do nothing.
  1878. */
  1879. DoNothingAction.prototype.execute = function () {
  1880. };
  1881. /**
  1882. * Serializes the actions and its related information.
  1883. * @param parent defines the object to serialize in
  1884. * @returns the serialized object
  1885. */
  1886. DoNothingAction.prototype.serialize = function (parent) {
  1887. return _super.prototype._serialize.call(this, {
  1888. name: "DoNothingAction",
  1889. properties: []
  1890. }, parent);
  1891. };
  1892. return DoNothingAction;
  1893. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1894. /**
  1895. * This defines an action responsible to trigger several actions once triggered.
  1896. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1897. */
  1898. var CombineAction = /** @class */ (function (_super) {
  1899. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CombineAction, _super);
  1900. /**
  1901. * Instantiate the action
  1902. * @param triggerOptions defines the trigger options
  1903. * @param children defines the list of aggregated animations to run
  1904. * @param condition defines the trigger related conditions
  1905. */
  1906. function CombineAction(triggerOptions, children, condition) {
  1907. var _this = _super.call(this, triggerOptions, condition) || this;
  1908. _this.children = children;
  1909. return _this;
  1910. }
  1911. /** @hidden */
  1912. CombineAction.prototype._prepare = function () {
  1913. for (var index = 0; index < this.children.length; index++) {
  1914. this.children[index]._actionManager = this._actionManager;
  1915. this.children[index]._prepare();
  1916. }
  1917. };
  1918. /**
  1919. * Execute the action and executes all the aggregated actions.
  1920. */
  1921. CombineAction.prototype.execute = function (evt) {
  1922. for (var index = 0; index < this.children.length; index++) {
  1923. this.children[index].execute(evt);
  1924. }
  1925. };
  1926. /**
  1927. * Serializes the actions and its related information.
  1928. * @param parent defines the object to serialize in
  1929. * @returns the serialized object
  1930. */
  1931. CombineAction.prototype.serialize = function (parent) {
  1932. var serializationObject = _super.prototype._serialize.call(this, {
  1933. name: "CombineAction",
  1934. properties: [],
  1935. combine: []
  1936. }, parent);
  1937. for (var i = 0; i < this.children.length; i++) {
  1938. serializationObject.combine.push(this.children[i].serialize(null));
  1939. }
  1940. return serializationObject;
  1941. };
  1942. return CombineAction;
  1943. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1944. /**
  1945. * This defines an action responsible to run code (external event) once triggered.
  1946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1947. */
  1948. var ExecuteCodeAction = /** @class */ (function (_super) {
  1949. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExecuteCodeAction, _super);
  1950. /**
  1951. * Instantiate the action
  1952. * @param triggerOptions defines the trigger options
  1953. * @param func defines the callback function to run
  1954. * @param condition defines the trigger related conditions
  1955. */
  1956. function ExecuteCodeAction(triggerOptions, func, condition) {
  1957. var _this = _super.call(this, triggerOptions, condition) || this;
  1958. _this.func = func;
  1959. return _this;
  1960. }
  1961. /**
  1962. * Execute the action and run the attached code.
  1963. */
  1964. ExecuteCodeAction.prototype.execute = function (evt) {
  1965. this.func(evt);
  1966. };
  1967. return ExecuteCodeAction;
  1968. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1969. /**
  1970. * This defines an action responsible to set the parent property of the target once triggered.
  1971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1972. */
  1973. var SetParentAction = /** @class */ (function (_super) {
  1974. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SetParentAction, _super);
  1975. /**
  1976. * Instantiate the action
  1977. * @param triggerOptions defines the trigger options
  1978. * @param target defines the target containing the parent property
  1979. * @param parent defines from where the animation should start (animation frame)
  1980. * @param condition defines the trigger related conditions
  1981. */
  1982. function SetParentAction(triggerOptions, target, parent, condition) {
  1983. var _this = _super.call(this, triggerOptions, condition) || this;
  1984. _this._target = target;
  1985. _this._parent = parent;
  1986. return _this;
  1987. }
  1988. /** @hidden */
  1989. SetParentAction.prototype._prepare = function () {
  1990. };
  1991. /**
  1992. * Execute the action and set the parent property.
  1993. */
  1994. SetParentAction.prototype.execute = function () {
  1995. if (this._target.parent === this._parent) {
  1996. return;
  1997. }
  1998. var invertParentWorldMatrix = this._parent.getWorldMatrix().clone();
  1999. invertParentWorldMatrix.invert();
  2000. this._target.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this._target.position, invertParentWorldMatrix);
  2001. this._target.parent = this._parent;
  2002. };
  2003. /**
  2004. * Serializes the actions and its related information.
  2005. * @param parent defines the object to serialize in
  2006. * @returns the serialized object
  2007. */
  2008. SetParentAction.prototype.serialize = function (parent) {
  2009. return _super.prototype._serialize.call(this, {
  2010. name: "SetParentAction",
  2011. properties: [
  2012. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  2013. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._parent),
  2014. ]
  2015. }, parent);
  2016. };
  2017. return SetParentAction;
  2018. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  2019. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetParentAction"] = SetParentAction;
  2020. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.ExecuteCodeAction"] = ExecuteCodeAction;
  2021. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.DoNothingAction"] = DoNothingAction;
  2022. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.StopAnimationAction"] = StopAnimationAction;
  2023. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.PlayAnimationAction"] = PlayAnimationAction;
  2024. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.IncrementValueAction"] = IncrementValueAction;
  2025. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetValueAction"] = SetValueAction;
  2026. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetStateAction"] = SetStateAction;
  2027. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetParentAction"] = SetParentAction;
  2028. /***/ }),
  2029. /***/ "./Actions/directAudioActions.ts":
  2030. /*!***************************************!*\
  2031. !*** ./Actions/directAudioActions.ts ***!
  2032. \***************************************/
  2033. /*! exports provided: PlaySoundAction, StopSoundAction */
  2034. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2035. "use strict";
  2036. __webpack_require__.r(__webpack_exports__);
  2037. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return PlaySoundAction; });
  2038. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return StopSoundAction; });
  2039. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  2040. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  2041. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  2042. /**
  2043. * This defines an action helpful to play a defined sound on a triggered action.
  2044. */
  2045. var PlaySoundAction = /** @class */ (function (_super) {
  2046. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlaySoundAction, _super);
  2047. /**
  2048. * Instantiate the action
  2049. * @param triggerOptions defines the trigger options
  2050. * @param sound defines the sound to play
  2051. * @param condition defines the trigger related conditions
  2052. */
  2053. function PlaySoundAction(triggerOptions, sound, condition) {
  2054. var _this = _super.call(this, triggerOptions, condition) || this;
  2055. _this._sound = sound;
  2056. return _this;
  2057. }
  2058. /** @hidden */
  2059. PlaySoundAction.prototype._prepare = function () {
  2060. };
  2061. /**
  2062. * Execute the action and play the sound.
  2063. */
  2064. PlaySoundAction.prototype.execute = function () {
  2065. if (this._sound !== undefined) {
  2066. this._sound.play();
  2067. }
  2068. };
  2069. /**
  2070. * Serializes the actions and its related information.
  2071. * @param parent defines the object to serialize in
  2072. * @returns the serialized object
  2073. */
  2074. PlaySoundAction.prototype.serialize = function (parent) {
  2075. return _super.prototype._serialize.call(this, {
  2076. name: "PlaySoundAction",
  2077. properties: [{ name: "sound", value: this._sound.name }]
  2078. }, parent);
  2079. };
  2080. return PlaySoundAction;
  2081. }(_action__WEBPACK_IMPORTED_MODULE_1__["Action"]));
  2082. /**
  2083. * This defines an action helpful to stop a defined sound on a triggered action.
  2084. */
  2085. var StopSoundAction = /** @class */ (function (_super) {
  2086. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StopSoundAction, _super);
  2087. /**
  2088. * Instantiate the action
  2089. * @param triggerOptions defines the trigger options
  2090. * @param sound defines the sound to stop
  2091. * @param condition defines the trigger related conditions
  2092. */
  2093. function StopSoundAction(triggerOptions, sound, condition) {
  2094. var _this = _super.call(this, triggerOptions, condition) || this;
  2095. _this._sound = sound;
  2096. return _this;
  2097. }
  2098. /** @hidden */
  2099. StopSoundAction.prototype._prepare = function () {
  2100. };
  2101. /**
  2102. * Execute the action and stop the sound.
  2103. */
  2104. StopSoundAction.prototype.execute = function () {
  2105. if (this._sound !== undefined) {
  2106. this._sound.stop();
  2107. }
  2108. };
  2109. /**
  2110. * Serializes the actions and its related information.
  2111. * @param parent defines the object to serialize in
  2112. * @returns the serialized object
  2113. */
  2114. StopSoundAction.prototype.serialize = function (parent) {
  2115. return _super.prototype._serialize.call(this, {
  2116. name: "StopSoundAction",
  2117. properties: [{ name: "sound", value: this._sound.name }]
  2118. }, parent);
  2119. };
  2120. return StopSoundAction;
  2121. }(_action__WEBPACK_IMPORTED_MODULE_1__["Action"]));
  2122. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.PlaySoundAction"] = StopSoundAction;
  2123. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.StopSoundAction"] = StopSoundAction;
  2124. /***/ }),
  2125. /***/ "./Actions/index.ts":
  2126. /*!**************************!*\
  2127. !*** ./Actions/index.ts ***!
  2128. \**************************/
  2129. /*! exports provided: Action, ActionEvent, ActionManager, Condition, ValueCondition, PredicateCondition, StateCondition, SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction, PlaySoundAction, StopSoundAction, InterpolateValueAction */
  2130. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2131. "use strict";
  2132. __webpack_require__.r(__webpack_exports__);
  2133. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  2134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _action__WEBPACK_IMPORTED_MODULE_0__["Action"]; });
  2135. /* harmony import */ var _actionEvent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./actionEvent */ "./Actions/actionEvent.ts");
  2136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _actionEvent__WEBPACK_IMPORTED_MODULE_1__["ActionEvent"]; });
  2137. /* harmony import */ var _actionManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./actionManager */ "./Actions/actionManager.ts");
  2138. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _actionManager__WEBPACK_IMPORTED_MODULE_2__["ActionManager"]; });
  2139. /* harmony import */ var _condition__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./condition */ "./Actions/condition.ts");
  2140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["Condition"]; });
  2141. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["ValueCondition"]; });
  2142. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["PredicateCondition"]; });
  2143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["StateCondition"]; });
  2144. /* harmony import */ var _directActions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./directActions */ "./Actions/directActions.ts");
  2145. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SwitchBooleanAction"]; });
  2146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SetStateAction"]; });
  2147. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SetValueAction"]; });
  2148. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["IncrementValueAction"]; });
  2149. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["PlayAnimationAction"]; });
  2150. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["StopAnimationAction"]; });
  2151. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["DoNothingAction"]; });
  2152. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["CombineAction"]; });
  2153. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["ExecuteCodeAction"]; });
  2154. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SetParentAction"]; });
  2155. /* harmony import */ var _directAudioActions__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./directAudioActions */ "./Actions/directAudioActions.ts");
  2156. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _directAudioActions__WEBPACK_IMPORTED_MODULE_5__["PlaySoundAction"]; });
  2157. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _directAudioActions__WEBPACK_IMPORTED_MODULE_5__["StopSoundAction"]; });
  2158. /* harmony import */ var _interpolateValueAction__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./interpolateValueAction */ "./Actions/interpolateValueAction.ts");
  2159. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _interpolateValueAction__WEBPACK_IMPORTED_MODULE_6__["InterpolateValueAction"]; });
  2160. /***/ }),
  2161. /***/ "./Actions/interpolateValueAction.ts":
  2162. /*!*******************************************!*\
  2163. !*** ./Actions/interpolateValueAction.ts ***!
  2164. \*******************************************/
  2165. /*! exports provided: InterpolateValueAction */
  2166. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2167. "use strict";
  2168. __webpack_require__.r(__webpack_exports__);
  2169. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return InterpolateValueAction; });
  2170. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  2171. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  2172. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  2173. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  2174. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  2175. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  2176. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  2177. /**
  2178. * This defines an action responsible to change the value of a property
  2179. * by interpolating between its current value and the newly set one once triggered.
  2180. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2181. */
  2182. var InterpolateValueAction = /** @class */ (function (_super) {
  2183. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InterpolateValueAction, _super);
  2184. /**
  2185. * Instantiate the action
  2186. * @param triggerOptions defines the trigger options
  2187. * @param target defines the object containing the value to interpolate
  2188. * @param propertyPath defines the path to the property in the target object
  2189. * @param value defines the target value at the end of the interpolation
  2190. * @param duration deines the time it will take for the property to interpolate to the value.
  2191. * @param condition defines the trigger related conditions
  2192. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  2193. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  2194. */
  2195. function InterpolateValueAction(triggerOptions, target, propertyPath, value, duration, condition, stopOtherAnimations, onInterpolationDone) {
  2196. if (duration === void 0) { duration = 1000; }
  2197. var _this = _super.call(this, triggerOptions, condition) || this;
  2198. /**
  2199. * Defines the time it will take for the property to interpolate to the value.
  2200. */
  2201. _this.duration = 1000;
  2202. /**
  2203. * Observable triggered once the interpolation animation has been done.
  2204. */
  2205. _this.onInterpolationDoneObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  2206. _this.propertyPath = propertyPath;
  2207. _this.value = value;
  2208. _this.duration = duration;
  2209. _this.stopOtherAnimations = stopOtherAnimations;
  2210. _this.onInterpolationDone = onInterpolationDone;
  2211. _this._target = _this._effectiveTarget = target;
  2212. return _this;
  2213. }
  2214. /** @hidden */
  2215. InterpolateValueAction.prototype._prepare = function () {
  2216. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  2217. this._property = this._getProperty(this.propertyPath);
  2218. };
  2219. /**
  2220. * Execute the action starts the value interpolation.
  2221. */
  2222. InterpolateValueAction.prototype.execute = function () {
  2223. var _this = this;
  2224. var scene = this._actionManager.getScene();
  2225. var keys = [
  2226. {
  2227. frame: 0,
  2228. value: this._effectiveTarget[this._property]
  2229. }, {
  2230. frame: 100,
  2231. value: this.value
  2232. }
  2233. ];
  2234. var dataType;
  2235. if (typeof this.value === "number") {
  2236. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT;
  2237. }
  2238. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"]) {
  2239. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_COLOR3;
  2240. }
  2241. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"]) {
  2242. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_VECTOR3;
  2243. }
  2244. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]) {
  2245. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_MATRIX;
  2246. }
  2247. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"]) {
  2248. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_QUATERNION;
  2249. }
  2250. else {
  2251. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("InterpolateValueAction: Unsupported type (" + typeof this.value + ")");
  2252. return;
  2253. }
  2254. var animation = new _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"]("InterpolateValueAction", this._property, 100 * (1000.0 / this.duration), dataType, _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONLOOPMODE_CONSTANT);
  2255. animation.setKeys(keys);
  2256. if (this.stopOtherAnimations) {
  2257. scene.stopAnimation(this._effectiveTarget);
  2258. }
  2259. var wrapper = function () {
  2260. _this.onInterpolationDoneObservable.notifyObservers(_this);
  2261. if (_this.onInterpolationDone) {
  2262. _this.onInterpolationDone();
  2263. }
  2264. };
  2265. scene.beginDirectAnimation(this._effectiveTarget, [animation], 0, 100, false, 1, wrapper);
  2266. };
  2267. /**
  2268. * Serializes the actions and its related information.
  2269. * @param parent defines the object to serialize in
  2270. * @returns the serialized object
  2271. */
  2272. InterpolateValueAction.prototype.serialize = function (parent) {
  2273. return _super.prototype._serialize.call(this, {
  2274. name: "InterpolateValueAction",
  2275. properties: [
  2276. _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._GetTargetProperty(this._target),
  2277. { name: "propertyPath", value: this.propertyPath },
  2278. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.value) },
  2279. { name: "duration", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.duration) },
  2280. { name: "stopOtherAnimations", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.stopOtherAnimations) || false }
  2281. ]
  2282. }, parent);
  2283. };
  2284. return InterpolateValueAction;
  2285. }(_action__WEBPACK_IMPORTED_MODULE_1__["Action"]));
  2286. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_6__["_TypeStore"].RegisteredTypes["BABYLON.InterpolateValueAction"] = InterpolateValueAction;
  2287. /***/ }),
  2288. /***/ "./Animations/animatable.ts":
  2289. /*!**********************************!*\
  2290. !*** ./Animations/animatable.ts ***!
  2291. \**********************************/
  2292. /*! exports provided: Animatable */
  2293. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2294. "use strict";
  2295. __webpack_require__.r(__webpack_exports__);
  2296. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return Animatable; });
  2297. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  2298. /* harmony import */ var _runtimeAnimation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./runtimeAnimation */ "./Animations/runtimeAnimation.ts");
  2299. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  2300. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  2301. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  2302. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/precisionDate */ "./Misc/precisionDate.ts");
  2303. /* harmony import */ var _Bones_bone__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Bones/bone */ "./Bones/bone.ts");
  2304. /**
  2305. * Class used to store an actual running animation
  2306. */
  2307. var Animatable = /** @class */ (function () {
  2308. /**
  2309. * Creates a new Animatable
  2310. * @param scene defines the hosting scene
  2311. * @param target defines the target object
  2312. * @param fromFrame defines the starting frame number (default is 0)
  2313. * @param toFrame defines the ending frame number (default is 100)
  2314. * @param loopAnimation defines if the animation must loop (default is false)
  2315. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  2316. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  2317. * @param animations defines a group of animation to add to the new Animatable
  2318. * @param onAnimationLoop defines a callback to call when animation loops
  2319. */
  2320. function Animatable(scene,
  2321. /** defines the target object */
  2322. target,
  2323. /** defines the starting frame number (default is 0) */
  2324. fromFrame,
  2325. /** defines the ending frame number (default is 100) */
  2326. toFrame,
  2327. /** defines if the animation must loop (default is false) */
  2328. loopAnimation, speedRatio,
  2329. /** defines a callback to call when animation ends if it is not looping */
  2330. onAnimationEnd, animations,
  2331. /** defines a callback to call when animation loops */
  2332. onAnimationLoop) {
  2333. if (fromFrame === void 0) { fromFrame = 0; }
  2334. if (toFrame === void 0) { toFrame = 100; }
  2335. if (loopAnimation === void 0) { loopAnimation = false; }
  2336. if (speedRatio === void 0) { speedRatio = 1.0; }
  2337. this.target = target;
  2338. this.fromFrame = fromFrame;
  2339. this.toFrame = toFrame;
  2340. this.loopAnimation = loopAnimation;
  2341. this.onAnimationEnd = onAnimationEnd;
  2342. this.onAnimationLoop = onAnimationLoop;
  2343. this._localDelayOffset = null;
  2344. this._pausedDelay = null;
  2345. this._runtimeAnimations = new Array();
  2346. this._paused = false;
  2347. this._speedRatio = 1;
  2348. this._weight = -1.0;
  2349. /**
  2350. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  2351. * This will only apply for non looping animation (default is true)
  2352. */
  2353. this.disposeOnEnd = true;
  2354. /**
  2355. * Gets a boolean indicating if the animation has started
  2356. */
  2357. this.animationStarted = false;
  2358. /**
  2359. * Observer raised when the animation ends
  2360. */
  2361. this.onAnimationEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  2362. /**
  2363. * Observer raised when the animation loops
  2364. */
  2365. this.onAnimationLoopObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  2366. this._scene = scene;
  2367. if (animations) {
  2368. this.appendAnimations(target, animations);
  2369. }
  2370. this._speedRatio = speedRatio;
  2371. scene._activeAnimatables.push(this);
  2372. }
  2373. Object.defineProperty(Animatable.prototype, "syncRoot", {
  2374. /**
  2375. * Gets the root Animatable used to synchronize and normalize animations
  2376. */
  2377. get: function () {
  2378. return this._syncRoot;
  2379. },
  2380. enumerable: true,
  2381. configurable: true
  2382. });
  2383. Object.defineProperty(Animatable.prototype, "masterFrame", {
  2384. /**
  2385. * Gets the current frame of the first RuntimeAnimation
  2386. * Used to synchronize Animatables
  2387. */
  2388. get: function () {
  2389. if (this._runtimeAnimations.length === 0) {
  2390. return 0;
  2391. }
  2392. return this._runtimeAnimations[0].currentFrame;
  2393. },
  2394. enumerable: true,
  2395. configurable: true
  2396. });
  2397. Object.defineProperty(Animatable.prototype, "weight", {
  2398. /**
  2399. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  2400. */
  2401. get: function () {
  2402. return this._weight;
  2403. },
  2404. set: function (value) {
  2405. if (value === -1) { // -1 is ok and means no weight
  2406. this._weight = -1;
  2407. return;
  2408. }
  2409. // Else weight must be in [0, 1] range
  2410. this._weight = Math.min(Math.max(value, 0), 1.0);
  2411. },
  2412. enumerable: true,
  2413. configurable: true
  2414. });
  2415. Object.defineProperty(Animatable.prototype, "speedRatio", {
  2416. /**
  2417. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  2418. */
  2419. get: function () {
  2420. return this._speedRatio;
  2421. },
  2422. set: function (value) {
  2423. for (var index = 0; index < this._runtimeAnimations.length; index++) {
  2424. var animation = this._runtimeAnimations[index];
  2425. animation._prepareForSpeedRatioChange(value);
  2426. }
  2427. this._speedRatio = value;
  2428. },
  2429. enumerable: true,
  2430. configurable: true
  2431. });
  2432. // Methods
  2433. /**
  2434. * Synchronize and normalize current Animatable with a source Animatable
  2435. * This is useful when using animation weights and when animations are not of the same length
  2436. * @param root defines the root Animatable to synchronize with
  2437. * @returns the current Animatable
  2438. */
  2439. Animatable.prototype.syncWith = function (root) {
  2440. this._syncRoot = root;
  2441. if (root) {
  2442. // Make sure this animatable will animate after the root
  2443. var index = this._scene._activeAnimatables.indexOf(this);
  2444. if (index > -1) {
  2445. this._scene._activeAnimatables.splice(index, 1);
  2446. this._scene._activeAnimatables.push(this);
  2447. }
  2448. }
  2449. return this;
  2450. };
  2451. /**
  2452. * Gets the list of runtime animations
  2453. * @returns an array of RuntimeAnimation
  2454. */
  2455. Animatable.prototype.getAnimations = function () {
  2456. return this._runtimeAnimations;
  2457. };
  2458. /**
  2459. * Adds more animations to the current animatable
  2460. * @param target defines the target of the animations
  2461. * @param animations defines the new animations to add
  2462. */
  2463. Animatable.prototype.appendAnimations = function (target, animations) {
  2464. for (var index = 0; index < animations.length; index++) {
  2465. var animation = animations[index];
  2466. this._runtimeAnimations.push(new _runtimeAnimation__WEBPACK_IMPORTED_MODULE_1__["RuntimeAnimation"](target, animation, this._scene, this));
  2467. }
  2468. };
  2469. /**
  2470. * Gets the source animation for a specific property
  2471. * @param property defines the propertyu to look for
  2472. * @returns null or the source animation for the given property
  2473. */
  2474. Animatable.prototype.getAnimationByTargetProperty = function (property) {
  2475. var runtimeAnimations = this._runtimeAnimations;
  2476. for (var index = 0; index < runtimeAnimations.length; index++) {
  2477. if (runtimeAnimations[index].animation.targetProperty === property) {
  2478. return runtimeAnimations[index].animation;
  2479. }
  2480. }
  2481. return null;
  2482. };
  2483. /**
  2484. * Gets the runtime animation for a specific property
  2485. * @param property defines the propertyu to look for
  2486. * @returns null or the runtime animation for the given property
  2487. */
  2488. Animatable.prototype.getRuntimeAnimationByTargetProperty = function (property) {
  2489. var runtimeAnimations = this._runtimeAnimations;
  2490. for (var index = 0; index < runtimeAnimations.length; index++) {
  2491. if (runtimeAnimations[index].animation.targetProperty === property) {
  2492. return runtimeAnimations[index];
  2493. }
  2494. }
  2495. return null;
  2496. };
  2497. /**
  2498. * Resets the animatable to its original state
  2499. */
  2500. Animatable.prototype.reset = function () {
  2501. var runtimeAnimations = this._runtimeAnimations;
  2502. for (var index = 0; index < runtimeAnimations.length; index++) {
  2503. runtimeAnimations[index].reset(true);
  2504. }
  2505. this._localDelayOffset = null;
  2506. this._pausedDelay = null;
  2507. };
  2508. /**
  2509. * Allows the animatable to blend with current running animations
  2510. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  2511. * @param blendingSpeed defines the blending speed to use
  2512. */
  2513. Animatable.prototype.enableBlending = function (blendingSpeed) {
  2514. var runtimeAnimations = this._runtimeAnimations;
  2515. for (var index = 0; index < runtimeAnimations.length; index++) {
  2516. runtimeAnimations[index].animation.enableBlending = true;
  2517. runtimeAnimations[index].animation.blendingSpeed = blendingSpeed;
  2518. }
  2519. };
  2520. /**
  2521. * Disable animation blending
  2522. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  2523. */
  2524. Animatable.prototype.disableBlending = function () {
  2525. var runtimeAnimations = this._runtimeAnimations;
  2526. for (var index = 0; index < runtimeAnimations.length; index++) {
  2527. runtimeAnimations[index].animation.enableBlending = false;
  2528. }
  2529. };
  2530. /**
  2531. * Jump directly to a given frame
  2532. * @param frame defines the frame to jump to
  2533. */
  2534. Animatable.prototype.goToFrame = function (frame) {
  2535. var runtimeAnimations = this._runtimeAnimations;
  2536. if (runtimeAnimations[0]) {
  2537. var fps = runtimeAnimations[0].animation.framePerSecond;
  2538. var currentFrame = runtimeAnimations[0].currentFrame;
  2539. var adjustTime = frame - currentFrame;
  2540. var delay = adjustTime * 1000 / (fps * this.speedRatio);
  2541. if (this._localDelayOffset === null) {
  2542. this._localDelayOffset = 0;
  2543. }
  2544. this._localDelayOffset -= delay;
  2545. }
  2546. for (var index = 0; index < runtimeAnimations.length; index++) {
  2547. runtimeAnimations[index].goToFrame(frame);
  2548. }
  2549. };
  2550. /**
  2551. * Pause the animation
  2552. */
  2553. Animatable.prototype.pause = function () {
  2554. if (this._paused) {
  2555. return;
  2556. }
  2557. this._paused = true;
  2558. };
  2559. /**
  2560. * Restart the animation
  2561. */
  2562. Animatable.prototype.restart = function () {
  2563. this._paused = false;
  2564. };
  2565. Animatable.prototype._raiseOnAnimationEnd = function () {
  2566. if (this.onAnimationEnd) {
  2567. this.onAnimationEnd();
  2568. }
  2569. this.onAnimationEndObservable.notifyObservers(this);
  2570. };
  2571. /**
  2572. * Stop and delete the current animation
  2573. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  2574. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  2575. */
  2576. Animatable.prototype.stop = function (animationName, targetMask) {
  2577. if (animationName || targetMask) {
  2578. var idx = this._scene._activeAnimatables.indexOf(this);
  2579. if (idx > -1) {
  2580. var runtimeAnimations = this._runtimeAnimations;
  2581. for (var index = runtimeAnimations.length - 1; index >= 0; index--) {
  2582. var runtimeAnimation = runtimeAnimations[index];
  2583. if (animationName && runtimeAnimation.animation.name != animationName) {
  2584. continue;
  2585. }
  2586. if (targetMask && !targetMask(runtimeAnimation.target)) {
  2587. continue;
  2588. }
  2589. runtimeAnimation.dispose();
  2590. runtimeAnimations.splice(index, 1);
  2591. }
  2592. if (runtimeAnimations.length == 0) {
  2593. this._scene._activeAnimatables.splice(idx, 1);
  2594. this._raiseOnAnimationEnd();
  2595. }
  2596. }
  2597. }
  2598. else {
  2599. var index = this._scene._activeAnimatables.indexOf(this);
  2600. if (index > -1) {
  2601. this._scene._activeAnimatables.splice(index, 1);
  2602. var runtimeAnimations = this._runtimeAnimations;
  2603. for (var index = 0; index < runtimeAnimations.length; index++) {
  2604. runtimeAnimations[index].dispose();
  2605. }
  2606. this._raiseOnAnimationEnd();
  2607. }
  2608. }
  2609. };
  2610. /**
  2611. * Wait asynchronously for the animation to end
  2612. * @returns a promise which will be fullfilled when the animation ends
  2613. */
  2614. Animatable.prototype.waitAsync = function () {
  2615. var _this = this;
  2616. return new Promise(function (resolve, reject) {
  2617. _this.onAnimationEndObservable.add(function () {
  2618. resolve(_this);
  2619. }, undefined, undefined, _this, true);
  2620. });
  2621. };
  2622. /** @hidden */
  2623. Animatable.prototype._animate = function (delay) {
  2624. var _this = this;
  2625. if (this._paused) {
  2626. this.animationStarted = false;
  2627. if (this._pausedDelay === null) {
  2628. this._pausedDelay = delay;
  2629. }
  2630. return true;
  2631. }
  2632. if (this._localDelayOffset === null) {
  2633. this._localDelayOffset = delay;
  2634. this._pausedDelay = null;
  2635. }
  2636. else if (this._pausedDelay !== null) {
  2637. this._localDelayOffset += delay - this._pausedDelay;
  2638. this._pausedDelay = null;
  2639. }
  2640. if (this._weight === 0) { // We consider that an animation with a weight === 0 is "actively" paused
  2641. return true;
  2642. }
  2643. // Animating
  2644. var running = false;
  2645. var runtimeAnimations = this._runtimeAnimations;
  2646. var index;
  2647. for (index = 0; index < runtimeAnimations.length; index++) {
  2648. var animation = runtimeAnimations[index];
  2649. var isRunning = animation.animate(delay - this._localDelayOffset, this.fromFrame, this.toFrame, this.loopAnimation, this._speedRatio, this._weight, function () {
  2650. _this.onAnimationLoopObservable.notifyObservers(_this);
  2651. if (_this.onAnimationLoop) {
  2652. _this.onAnimationLoop();
  2653. }
  2654. });
  2655. running = running || isRunning;
  2656. }
  2657. this.animationStarted = running;
  2658. if (!running) {
  2659. if (this.disposeOnEnd) {
  2660. // Remove from active animatables
  2661. index = this._scene._activeAnimatables.indexOf(this);
  2662. this._scene._activeAnimatables.splice(index, 1);
  2663. // Dispose all runtime animations
  2664. for (index = 0; index < runtimeAnimations.length; index++) {
  2665. runtimeAnimations[index].dispose();
  2666. }
  2667. }
  2668. this._raiseOnAnimationEnd();
  2669. if (this.disposeOnEnd) {
  2670. this.onAnimationEnd = null;
  2671. this.onAnimationLoop = null;
  2672. this.onAnimationLoopObservable.clear();
  2673. this.onAnimationEndObservable.clear();
  2674. }
  2675. }
  2676. return running;
  2677. };
  2678. return Animatable;
  2679. }());
  2680. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._animate = function () {
  2681. if (!this.animationsEnabled || this._activeAnimatables.length === 0) {
  2682. return;
  2683. }
  2684. // Getting time
  2685. var now = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_5__["PrecisionDate"].Now;
  2686. if (!this._animationTimeLast) {
  2687. if (this._pendingData.length > 0) {
  2688. return;
  2689. }
  2690. this._animationTimeLast = now;
  2691. }
  2692. var deltaTime = this.useConstantAnimationDeltaTime ? 16.0 : (now - this._animationTimeLast) * this.animationTimeScale;
  2693. this._animationTime += deltaTime;
  2694. this._animationTimeLast = now;
  2695. for (var index = 0; index < this._activeAnimatables.length; index++) {
  2696. this._activeAnimatables[index]._animate(this._animationTime);
  2697. }
  2698. // Late animation bindings
  2699. this._processLateAnimationBindings();
  2700. };
  2701. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginWeightedAnimation = function (target, from, to, weight, loop, speedRatio, onAnimationEnd, animatable, targetMask, onAnimationLoop) {
  2702. if (weight === void 0) { weight = 1.0; }
  2703. if (speedRatio === void 0) { speedRatio = 1.0; }
  2704. var returnedAnimatable = this.beginAnimation(target, from, to, loop, speedRatio, onAnimationEnd, animatable, false, targetMask, onAnimationLoop);
  2705. returnedAnimatable.weight = weight;
  2706. return returnedAnimatable;
  2707. };
  2708. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginAnimation = function (target, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop) {
  2709. if (speedRatio === void 0) { speedRatio = 1.0; }
  2710. if (stopCurrent === void 0) { stopCurrent = true; }
  2711. if (from > to && speedRatio > 0) {
  2712. speedRatio *= -1;
  2713. }
  2714. if (stopCurrent) {
  2715. this.stopAnimation(target, undefined, targetMask);
  2716. }
  2717. if (!animatable) {
  2718. animatable = new Animatable(this, target, from, to, loop, speedRatio, onAnimationEnd, undefined, onAnimationLoop);
  2719. }
  2720. var shouldRunTargetAnimations = targetMask ? targetMask(target) : true;
  2721. // Local animations
  2722. if (target.animations && shouldRunTargetAnimations) {
  2723. animatable.appendAnimations(target, target.animations);
  2724. }
  2725. // Children animations
  2726. if (target.getAnimatables) {
  2727. var animatables = target.getAnimatables();
  2728. for (var index = 0; index < animatables.length; index++) {
  2729. this.beginAnimation(animatables[index], from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop);
  2730. }
  2731. }
  2732. animatable.reset();
  2733. return animatable;
  2734. };
  2735. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginHierarchyAnimation = function (target, directDescendantsOnly, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop) {
  2736. if (speedRatio === void 0) { speedRatio = 1.0; }
  2737. if (stopCurrent === void 0) { stopCurrent = true; }
  2738. var children = target.getDescendants(directDescendantsOnly);
  2739. var result = [];
  2740. result.push(this.beginAnimation(target, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask));
  2741. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  2742. var child = children_1[_i];
  2743. result.push(this.beginAnimation(child, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask));
  2744. }
  2745. return result;
  2746. };
  2747. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginDirectAnimation = function (target, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop) {
  2748. if (speedRatio === undefined) {
  2749. speedRatio = 1.0;
  2750. }
  2751. var animatable = new Animatable(this, target, from, to, loop, speedRatio, onAnimationEnd, animations, onAnimationLoop);
  2752. return animatable;
  2753. };
  2754. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginDirectHierarchyAnimation = function (target, directDescendantsOnly, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop) {
  2755. var children = target.getDescendants(directDescendantsOnly);
  2756. var result = [];
  2757. result.push(this.beginDirectAnimation(target, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop));
  2758. for (var _i = 0, children_2 = children; _i < children_2.length; _i++) {
  2759. var child = children_2[_i];
  2760. result.push(this.beginDirectAnimation(child, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop));
  2761. }
  2762. return result;
  2763. };
  2764. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.getAnimatableByTarget = function (target) {
  2765. for (var index = 0; index < this._activeAnimatables.length; index++) {
  2766. if (this._activeAnimatables[index].target === target) {
  2767. return this._activeAnimatables[index];
  2768. }
  2769. }
  2770. return null;
  2771. };
  2772. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.getAllAnimatablesByTarget = function (target) {
  2773. var result = [];
  2774. for (var index = 0; index < this._activeAnimatables.length; index++) {
  2775. if (this._activeAnimatables[index].target === target) {
  2776. result.push(this._activeAnimatables[index]);
  2777. }
  2778. }
  2779. return result;
  2780. };
  2781. /**
  2782. * Will stop the animation of the given target
  2783. * @param target - the target
  2784. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  2785. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  2786. */
  2787. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.stopAnimation = function (target, animationName, targetMask) {
  2788. var animatables = this.getAllAnimatablesByTarget(target);
  2789. for (var _i = 0, animatables_1 = animatables; _i < animatables_1.length; _i++) {
  2790. var animatable = animatables_1[_i];
  2791. animatable.stop(animationName, targetMask);
  2792. }
  2793. };
  2794. /**
  2795. * Stops and removes all animations that have been applied to the scene
  2796. */
  2797. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.stopAllAnimations = function () {
  2798. if (this._activeAnimatables) {
  2799. for (var i = 0; i < this._activeAnimatables.length; i++) {
  2800. this._activeAnimatables[i].stop();
  2801. }
  2802. this._activeAnimatables = [];
  2803. }
  2804. for (var _i = 0, _a = this.animationGroups; _i < _a.length; _i++) {
  2805. var group = _a[_i];
  2806. group.stop();
  2807. }
  2808. };
  2809. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._registerTargetForLateAnimationBinding = function (runtimeAnimation, originalValue) {
  2810. var target = runtimeAnimation.target;
  2811. this._registeredForLateAnimationBindings.pushNoDuplicate(target);
  2812. if (!target._lateAnimationHolders) {
  2813. target._lateAnimationHolders = {};
  2814. }
  2815. if (!target._lateAnimationHolders[runtimeAnimation.targetPath]) {
  2816. target._lateAnimationHolders[runtimeAnimation.targetPath] = {
  2817. totalWeight: 0,
  2818. animations: [],
  2819. originalValue: originalValue
  2820. };
  2821. }
  2822. target._lateAnimationHolders[runtimeAnimation.targetPath].animations.push(runtimeAnimation);
  2823. target._lateAnimationHolders[runtimeAnimation.targetPath].totalWeight += runtimeAnimation.weight;
  2824. };
  2825. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._processLateAnimationBindingsForMatrices = function (holder) {
  2826. var normalizer = 1.0;
  2827. var finalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[0];
  2828. var finalScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[1];
  2829. var finalQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Quaternion[0];
  2830. var startIndex = 0;
  2831. var originalAnimation = holder.animations[0];
  2832. var originalValue = holder.originalValue;
  2833. var scale = 1;
  2834. if (holder.totalWeight < 1.0) {
  2835. // We need to mix the original value in
  2836. originalValue.decompose(finalScaling, finalQuaternion, finalPosition);
  2837. scale = 1.0 - holder.totalWeight;
  2838. }
  2839. else {
  2840. startIndex = 1;
  2841. // We need to normalize the weights
  2842. normalizer = holder.totalWeight;
  2843. originalAnimation.currentValue.decompose(finalScaling, finalQuaternion, finalPosition);
  2844. scale = originalAnimation.weight / normalizer;
  2845. if (scale == 1) {
  2846. return originalAnimation.currentValue;
  2847. }
  2848. }
  2849. finalScaling.scaleInPlace(scale);
  2850. finalPosition.scaleInPlace(scale);
  2851. finalQuaternion.scaleInPlace(scale);
  2852. for (var animIndex = startIndex; animIndex < holder.animations.length; animIndex++) {
  2853. var runtimeAnimation = holder.animations[animIndex];
  2854. var scale = runtimeAnimation.weight / normalizer;
  2855. var currentPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[2];
  2856. var currentScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[3];
  2857. var currentQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Quaternion[1];
  2858. runtimeAnimation.currentValue.decompose(currentScaling, currentQuaternion, currentPosition);
  2859. currentScaling.scaleAndAddToRef(scale, finalScaling);
  2860. currentQuaternion.scaleAndAddToRef(scale, finalQuaternion);
  2861. currentPosition.scaleAndAddToRef(scale, finalPosition);
  2862. }
  2863. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].ComposeToRef(finalScaling, finalQuaternion, finalPosition, originalAnimation._workValue);
  2864. return originalAnimation._workValue;
  2865. };
  2866. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._processLateAnimationBindingsForQuaternions = function (holder, refQuaternion) {
  2867. var originalAnimation = holder.animations[0];
  2868. var originalValue = holder.originalValue;
  2869. if (holder.animations.length === 1) {
  2870. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(originalValue, originalAnimation.currentValue, Math.min(1.0, holder.totalWeight), refQuaternion);
  2871. return refQuaternion;
  2872. }
  2873. var normalizer = 1.0;
  2874. var quaternions;
  2875. var weights;
  2876. if (holder.totalWeight < 1.0) {
  2877. var scale = 1.0 - holder.totalWeight;
  2878. quaternions = [];
  2879. weights = [];
  2880. quaternions.push(originalValue);
  2881. weights.push(scale);
  2882. }
  2883. else {
  2884. if (holder.animations.length === 2) { // Slerp as soon as we can
  2885. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(holder.animations[0].currentValue, holder.animations[1].currentValue, holder.animations[1].weight / holder.totalWeight, refQuaternion);
  2886. return refQuaternion;
  2887. }
  2888. quaternions = [];
  2889. weights = [];
  2890. normalizer = holder.totalWeight;
  2891. }
  2892. for (var animIndex = 0; animIndex < holder.animations.length; animIndex++) {
  2893. var runtimeAnimation = holder.animations[animIndex];
  2894. quaternions.push(runtimeAnimation.currentValue);
  2895. weights.push(runtimeAnimation.weight / normalizer);
  2896. }
  2897. // https://gamedev.stackexchange.com/questions/62354/method-for-interpolation-between-3-quaternions
  2898. var cumulativeAmount = 0;
  2899. var cumulativeQuaternion = null;
  2900. for (var index = 0; index < quaternions.length;) {
  2901. if (!cumulativeQuaternion) {
  2902. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(quaternions[index], quaternions[index + 1], weights[index + 1] / (weights[index] + weights[index + 1]), refQuaternion);
  2903. cumulativeQuaternion = refQuaternion;
  2904. cumulativeAmount = weights[index] + weights[index + 1];
  2905. index += 2;
  2906. continue;
  2907. }
  2908. cumulativeAmount += weights[index];
  2909. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(cumulativeQuaternion, quaternions[index], weights[index] / cumulativeAmount, cumulativeQuaternion);
  2910. index++;
  2911. }
  2912. return cumulativeQuaternion;
  2913. };
  2914. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._processLateAnimationBindings = function () {
  2915. if (!this._registeredForLateAnimationBindings.length) {
  2916. return;
  2917. }
  2918. for (var index = 0; index < this._registeredForLateAnimationBindings.length; index++) {
  2919. var target = this._registeredForLateAnimationBindings.data[index];
  2920. for (var path in target._lateAnimationHolders) {
  2921. var holder = target._lateAnimationHolders[path];
  2922. var originalAnimation = holder.animations[0];
  2923. var originalValue = holder.originalValue;
  2924. var matrixDecomposeMode = _animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].AllowMatrixDecomposeForInterpolation && originalValue.m; // ie. data is matrix
  2925. var finalValue = target[path];
  2926. if (matrixDecomposeMode) {
  2927. finalValue = this._processLateAnimationBindingsForMatrices(holder);
  2928. }
  2929. else {
  2930. var quaternionMode = originalValue.w !== undefined;
  2931. if (quaternionMode) {
  2932. finalValue = this._processLateAnimationBindingsForQuaternions(holder, finalValue || _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity());
  2933. }
  2934. else {
  2935. var startIndex = 0;
  2936. var normalizer = 1.0;
  2937. if (holder.totalWeight < 1.0) {
  2938. // We need to mix the original value in
  2939. if (originalValue.scale) {
  2940. finalValue = originalValue.scale(1.0 - holder.totalWeight);
  2941. }
  2942. else {
  2943. finalValue = originalValue * (1.0 - holder.totalWeight);
  2944. }
  2945. }
  2946. else {
  2947. // We need to normalize the weights
  2948. normalizer = holder.totalWeight;
  2949. var scale_1 = originalAnimation.weight / normalizer;
  2950. if (scale_1 !== 1) {
  2951. if (originalAnimation.currentValue.scale) {
  2952. finalValue = originalAnimation.currentValue.scale(scale_1);
  2953. }
  2954. else {
  2955. finalValue = originalAnimation.currentValue * scale_1;
  2956. }
  2957. }
  2958. else {
  2959. finalValue = originalAnimation.currentValue;
  2960. }
  2961. startIndex = 1;
  2962. }
  2963. for (var animIndex = startIndex; animIndex < holder.animations.length; animIndex++) {
  2964. var runtimeAnimation = holder.animations[animIndex];
  2965. var scale = runtimeAnimation.weight / normalizer;
  2966. if (runtimeAnimation.currentValue.scaleAndAddToRef) {
  2967. runtimeAnimation.currentValue.scaleAndAddToRef(scale, finalValue);
  2968. }
  2969. else {
  2970. finalValue += runtimeAnimation.currentValue * scale;
  2971. }
  2972. }
  2973. }
  2974. }
  2975. target[path] = finalValue;
  2976. }
  2977. target._lateAnimationHolders = {};
  2978. }
  2979. this._registeredForLateAnimationBindings.reset();
  2980. };
  2981. _Bones_bone__WEBPACK_IMPORTED_MODULE_6__["Bone"].prototype.copyAnimationRange = function (source, rangeName, frameOffset, rescaleAsRequired, skelDimensionsRatio) {
  2982. if (rescaleAsRequired === void 0) { rescaleAsRequired = false; }
  2983. if (skelDimensionsRatio === void 0) { skelDimensionsRatio = null; }
  2984. // all animation may be coming from a library skeleton, so may need to create animation
  2985. if (this.animations.length === 0) {
  2986. this.animations.push(new _animation__WEBPACK_IMPORTED_MODULE_0__["Animation"](this.name, "_matrix", source.animations[0].framePerSecond, _animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].ANIMATIONTYPE_MATRIX, 0));
  2987. this.animations[0].setKeys([]);
  2988. }
  2989. // get animation info / verify there is such a range from the source bone
  2990. var sourceRange = source.animations[0].getRange(rangeName);
  2991. if (!sourceRange) {
  2992. return false;
  2993. }
  2994. var from = sourceRange.from;
  2995. var to = sourceRange.to;
  2996. var sourceKeys = source.animations[0].getKeys();
  2997. // rescaling prep
  2998. var sourceBoneLength = source.length;
  2999. var sourceParent = source.getParent();
  3000. var parent = this.getParent();
  3001. var parentScalingReqd = rescaleAsRequired && sourceParent && sourceBoneLength && this.length && sourceBoneLength !== this.length;
  3002. var parentRatio = parentScalingReqd && parent && sourceParent ? parent.length / sourceParent.length : 1;
  3003. var dimensionsScalingReqd = rescaleAsRequired && !parent && skelDimensionsRatio && (skelDimensionsRatio.x !== 1 || skelDimensionsRatio.y !== 1 || skelDimensionsRatio.z !== 1);
  3004. var destKeys = this.animations[0].getKeys();
  3005. // loop vars declaration
  3006. var orig;
  3007. var origTranslation;
  3008. var mat;
  3009. for (var key = 0, nKeys = sourceKeys.length; key < nKeys; key++) {
  3010. orig = sourceKeys[key];
  3011. if (orig.frame >= from && orig.frame <= to) {
  3012. if (rescaleAsRequired) {
  3013. mat = orig.value.clone();
  3014. // scale based on parent ratio, when bone has parent
  3015. if (parentScalingReqd) {
  3016. origTranslation = mat.getTranslation();
  3017. mat.setTranslation(origTranslation.scaleInPlace(parentRatio));
  3018. // scale based on skeleton dimension ratio when root bone, and value is passed
  3019. }
  3020. else if (dimensionsScalingReqd && skelDimensionsRatio) {
  3021. origTranslation = mat.getTranslation();
  3022. mat.setTranslation(origTranslation.multiplyInPlace(skelDimensionsRatio));
  3023. // use original when root bone, and no data for skelDimensionsRatio
  3024. }
  3025. else {
  3026. mat = orig.value;
  3027. }
  3028. }
  3029. else {
  3030. mat = orig.value;
  3031. }
  3032. destKeys.push({ frame: orig.frame + frameOffset, value: mat });
  3033. }
  3034. }
  3035. this.animations[0].createRange(rangeName, from + frameOffset, to + frameOffset);
  3036. return true;
  3037. };
  3038. /***/ }),
  3039. /***/ "./Animations/animation.ts":
  3040. /*!*********************************!*\
  3041. !*** ./Animations/animation.ts ***!
  3042. \*********************************/
  3043. /*! exports provided: Animation */
  3044. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3045. "use strict";
  3046. __webpack_require__.r(__webpack_exports__);
  3047. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return Animation; });
  3048. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  3049. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  3050. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  3051. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  3052. /* harmony import */ var _animationKey__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./animationKey */ "./Animations/animationKey.ts");
  3053. /* harmony import */ var _animationRange__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./animationRange */ "./Animations/animationRange.ts");
  3054. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  3055. /**
  3056. * Class used to store any kind of animation
  3057. */
  3058. var Animation = /** @class */ (function () {
  3059. /**
  3060. * Initializes the animation
  3061. * @param name Name of the animation
  3062. * @param targetProperty Property to animate
  3063. * @param framePerSecond The frames per second of the animation
  3064. * @param dataType The data type of the animation
  3065. * @param loopMode The loop mode of the animation
  3066. * @param enableBlending Specifies if blending should be enabled
  3067. */
  3068. function Animation(
  3069. /**Name of the animation */
  3070. name,
  3071. /**Property to animate */
  3072. targetProperty,
  3073. /**The frames per second of the animation */
  3074. framePerSecond,
  3075. /**The data type of the animation */
  3076. dataType,
  3077. /**The loop mode of the animation */
  3078. loopMode,
  3079. /**Specifies if blending should be enabled */
  3080. enableBlending) {
  3081. this.name = name;
  3082. this.targetProperty = targetProperty;
  3083. this.framePerSecond = framePerSecond;
  3084. this.dataType = dataType;
  3085. this.loopMode = loopMode;
  3086. this.enableBlending = enableBlending;
  3087. /**
  3088. * @hidden Internal use only
  3089. */
  3090. this._runtimeAnimations = new Array();
  3091. /**
  3092. * The set of event that will be linked to this animation
  3093. */
  3094. this._events = new Array();
  3095. /**
  3096. * Stores the blending speed of the animation
  3097. */
  3098. this.blendingSpeed = 0.01;
  3099. /**
  3100. * Stores the animation ranges for the animation
  3101. */
  3102. this._ranges = {};
  3103. this.targetPropertyPath = targetProperty.split(".");
  3104. this.dataType = dataType;
  3105. this.loopMode = loopMode === undefined ? Animation.ANIMATIONLOOPMODE_CYCLE : loopMode;
  3106. }
  3107. /**
  3108. * @hidden Internal use
  3109. */
  3110. Animation._PrepareAnimation = function (name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction) {
  3111. var dataType = undefined;
  3112. if (!isNaN(parseFloat(from)) && isFinite(from)) {
  3113. dataType = Animation.ANIMATIONTYPE_FLOAT;
  3114. }
  3115. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]) {
  3116. dataType = Animation.ANIMATIONTYPE_QUATERNION;
  3117. }
  3118. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]) {
  3119. dataType = Animation.ANIMATIONTYPE_VECTOR3;
  3120. }
  3121. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"]) {
  3122. dataType = Animation.ANIMATIONTYPE_VECTOR2;
  3123. }
  3124. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"]) {
  3125. dataType = Animation.ANIMATIONTYPE_COLOR3;
  3126. }
  3127. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"]) {
  3128. dataType = Animation.ANIMATIONTYPE_SIZE;
  3129. }
  3130. if (dataType == undefined) {
  3131. return null;
  3132. }
  3133. var animation = new Animation(name, targetProperty, framePerSecond, dataType, loopMode);
  3134. var keys = [{ frame: 0, value: from }, { frame: totalFrame, value: to }];
  3135. animation.setKeys(keys);
  3136. if (easingFunction !== undefined) {
  3137. animation.setEasingFunction(easingFunction);
  3138. }
  3139. return animation;
  3140. };
  3141. /**
  3142. * Sets up an animation
  3143. * @param property The property to animate
  3144. * @param animationType The animation type to apply
  3145. * @param framePerSecond The frames per second of the animation
  3146. * @param easingFunction The easing function used in the animation
  3147. * @returns The created animation
  3148. */
  3149. Animation.CreateAnimation = function (property, animationType, framePerSecond, easingFunction) {
  3150. var animation = new Animation(property + "Animation", property, framePerSecond, animationType, Animation.ANIMATIONLOOPMODE_CONSTANT);
  3151. animation.setEasingFunction(easingFunction);
  3152. return animation;
  3153. };
  3154. /**
  3155. * Create and start an animation on a node
  3156. * @param name defines the name of the global animation that will be run on all nodes
  3157. * @param node defines the root node where the animation will take place
  3158. * @param targetProperty defines property to animate
  3159. * @param framePerSecond defines the number of frame per second yo use
  3160. * @param totalFrame defines the number of frames in total
  3161. * @param from defines the initial value
  3162. * @param to defines the final value
  3163. * @param loopMode defines which loop mode you want to use (off by default)
  3164. * @param easingFunction defines the easing function to use (linear by default)
  3165. * @param onAnimationEnd defines the callback to call when animation end
  3166. * @returns the animatable created for this animation
  3167. */
  3168. Animation.CreateAndStartAnimation = function (name, node, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  3169. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  3170. if (!animation) {
  3171. return null;
  3172. }
  3173. return node.getScene().beginDirectAnimation(node, [animation], 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  3174. };
  3175. /**
  3176. * Create and start an animation on a node and its descendants
  3177. * @param name defines the name of the global animation that will be run on all nodes
  3178. * @param node defines the root node where the animation will take place
  3179. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used
  3180. * @param targetProperty defines property to animate
  3181. * @param framePerSecond defines the number of frame per second to use
  3182. * @param totalFrame defines the number of frames in total
  3183. * @param from defines the initial value
  3184. * @param to defines the final value
  3185. * @param loopMode defines which loop mode you want to use (off by default)
  3186. * @param easingFunction defines the easing function to use (linear by default)
  3187. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  3188. * @returns the list of animatables created for all nodes
  3189. * @example https://www.babylonjs-playground.com/#MH0VLI
  3190. */
  3191. Animation.CreateAndStartHierarchyAnimation = function (name, node, directDescendantsOnly, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  3192. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  3193. if (!animation) {
  3194. return null;
  3195. }
  3196. var scene = node.getScene();
  3197. return scene.beginDirectHierarchyAnimation(node, directDescendantsOnly, [animation], 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  3198. };
  3199. /**
  3200. * Creates a new animation, merges it with the existing animations and starts it
  3201. * @param name Name of the animation
  3202. * @param node Node which contains the scene that begins the animations
  3203. * @param targetProperty Specifies which property to animate
  3204. * @param framePerSecond The frames per second of the animation
  3205. * @param totalFrame The total number of frames
  3206. * @param from The frame at the beginning of the animation
  3207. * @param to The frame at the end of the animation
  3208. * @param loopMode Specifies the loop mode of the animation
  3209. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  3210. * @param onAnimationEnd Callback to run once the animation is complete
  3211. * @returns Nullable animation
  3212. */
  3213. Animation.CreateMergeAndStartAnimation = function (name, node, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  3214. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  3215. if (!animation) {
  3216. return null;
  3217. }
  3218. node.animations.push(animation);
  3219. return node.getScene().beginAnimation(node, 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  3220. };
  3221. /**
  3222. * Transition property of an host to the target Value
  3223. * @param property The property to transition
  3224. * @param targetValue The target Value of the property
  3225. * @param host The object where the property to animate belongs
  3226. * @param scene Scene used to run the animation
  3227. * @param frameRate Framerate (in frame/s) to use
  3228. * @param transition The transition type we want to use
  3229. * @param duration The duration of the animation, in milliseconds
  3230. * @param onAnimationEnd Callback trigger at the end of the animation
  3231. * @returns Nullable animation
  3232. */
  3233. Animation.TransitionTo = function (property, targetValue, host, scene, frameRate, transition, duration, onAnimationEnd) {
  3234. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  3235. if (duration <= 0) {
  3236. host[property] = targetValue;
  3237. if (onAnimationEnd) {
  3238. onAnimationEnd();
  3239. }
  3240. return null;
  3241. }
  3242. var endFrame = frameRate * (duration / 1000);
  3243. transition.setKeys([{
  3244. frame: 0,
  3245. value: host[property].clone ? host[property].clone() : host[property]
  3246. },
  3247. {
  3248. frame: endFrame,
  3249. value: targetValue
  3250. }]);
  3251. if (!host.animations) {
  3252. host.animations = [];
  3253. }
  3254. host.animations.push(transition);
  3255. var animation = scene.beginAnimation(host, 0, endFrame, false);
  3256. animation.onAnimationEnd = onAnimationEnd;
  3257. return animation;
  3258. };
  3259. Object.defineProperty(Animation.prototype, "runtimeAnimations", {
  3260. /**
  3261. * Return the array of runtime animations currently using this animation
  3262. */
  3263. get: function () {
  3264. return this._runtimeAnimations;
  3265. },
  3266. enumerable: true,
  3267. configurable: true
  3268. });
  3269. Object.defineProperty(Animation.prototype, "hasRunningRuntimeAnimations", {
  3270. /**
  3271. * Specifies if any of the runtime animations are currently running
  3272. */
  3273. get: function () {
  3274. for (var _i = 0, _a = this._runtimeAnimations; _i < _a.length; _i++) {
  3275. var runtimeAnimation = _a[_i];
  3276. if (!runtimeAnimation.isStopped) {
  3277. return true;
  3278. }
  3279. }
  3280. return false;
  3281. },
  3282. enumerable: true,
  3283. configurable: true
  3284. });
  3285. // Methods
  3286. /**
  3287. * Converts the animation to a string
  3288. * @param fullDetails support for multiple levels of logging within scene loading
  3289. * @returns String form of the animation
  3290. */
  3291. Animation.prototype.toString = function (fullDetails) {
  3292. var ret = "Name: " + this.name + ", property: " + this.targetProperty;
  3293. ret += ", datatype: " + (["Float", "Vector3", "Quaternion", "Matrix", "Color3", "Vector2"])[this.dataType];
  3294. ret += ", nKeys: " + (this._keys ? this._keys.length : "none");
  3295. ret += ", nRanges: " + (this._ranges ? Object.keys(this._ranges).length : "none");
  3296. if (fullDetails) {
  3297. ret += ", Ranges: {";
  3298. var first = true;
  3299. for (var name in this._ranges) {
  3300. if (first) {
  3301. ret += ", ";
  3302. first = false;
  3303. }
  3304. ret += name;
  3305. }
  3306. ret += "}";
  3307. }
  3308. return ret;
  3309. };
  3310. /**
  3311. * Add an event to this animation
  3312. * @param event Event to add
  3313. */
  3314. Animation.prototype.addEvent = function (event) {
  3315. this._events.push(event);
  3316. };
  3317. /**
  3318. * Remove all events found at the given frame
  3319. * @param frame The frame to remove events from
  3320. */
  3321. Animation.prototype.removeEvents = function (frame) {
  3322. for (var index = 0; index < this._events.length; index++) {
  3323. if (this._events[index].frame === frame) {
  3324. this._events.splice(index, 1);
  3325. index--;
  3326. }
  3327. }
  3328. };
  3329. /**
  3330. * Retrieves all the events from the animation
  3331. * @returns Events from the animation
  3332. */
  3333. Animation.prototype.getEvents = function () {
  3334. return this._events;
  3335. };
  3336. /**
  3337. * Creates an animation range
  3338. * @param name Name of the animation range
  3339. * @param from Starting frame of the animation range
  3340. * @param to Ending frame of the animation
  3341. */
  3342. Animation.prototype.createRange = function (name, from, to) {
  3343. // check name not already in use; could happen for bones after serialized
  3344. if (!this._ranges[name]) {
  3345. this._ranges[name] = new _animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, from, to);
  3346. }
  3347. };
  3348. /**
  3349. * Deletes an animation range by name
  3350. * @param name Name of the animation range to delete
  3351. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  3352. */
  3353. Animation.prototype.deleteRange = function (name, deleteFrames) {
  3354. if (deleteFrames === void 0) { deleteFrames = true; }
  3355. var range = this._ranges[name];
  3356. if (!range) {
  3357. return;
  3358. }
  3359. if (deleteFrames) {
  3360. var from = range.from;
  3361. var to = range.to;
  3362. // this loop MUST go high to low for multiple splices to work
  3363. for (var key = this._keys.length - 1; key >= 0; key--) {
  3364. if (this._keys[key].frame >= from && this._keys[key].frame <= to) {
  3365. this._keys.splice(key, 1);
  3366. }
  3367. }
  3368. }
  3369. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  3370. };
  3371. /**
  3372. * Gets the animation range by name, or null if not defined
  3373. * @param name Name of the animation range
  3374. * @returns Nullable animation range
  3375. */
  3376. Animation.prototype.getRange = function (name) {
  3377. return this._ranges[name];
  3378. };
  3379. /**
  3380. * Gets the key frames from the animation
  3381. * @returns The key frames of the animation
  3382. */
  3383. Animation.prototype.getKeys = function () {
  3384. return this._keys;
  3385. };
  3386. /**
  3387. * Gets the highest frame rate of the animation
  3388. * @returns Highest frame rate of the animation
  3389. */
  3390. Animation.prototype.getHighestFrame = function () {
  3391. var ret = 0;
  3392. for (var key = 0, nKeys = this._keys.length; key < nKeys; key++) {
  3393. if (ret < this._keys[key].frame) {
  3394. ret = this._keys[key].frame;
  3395. }
  3396. }
  3397. return ret;
  3398. };
  3399. /**
  3400. * Gets the easing function of the animation
  3401. * @returns Easing function of the animation
  3402. */
  3403. Animation.prototype.getEasingFunction = function () {
  3404. return this._easingFunction;
  3405. };
  3406. /**
  3407. * Sets the easing function of the animation
  3408. * @param easingFunction A custom mathematical formula for animation
  3409. */
  3410. Animation.prototype.setEasingFunction = function (easingFunction) {
  3411. this._easingFunction = easingFunction;
  3412. };
  3413. /**
  3414. * Interpolates a scalar linearly
  3415. * @param startValue Start value of the animation curve
  3416. * @param endValue End value of the animation curve
  3417. * @param gradient Scalar amount to interpolate
  3418. * @returns Interpolated scalar value
  3419. */
  3420. Animation.prototype.floatInterpolateFunction = function (startValue, endValue, gradient) {
  3421. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Lerp(startValue, endValue, gradient);
  3422. };
  3423. /**
  3424. * Interpolates a scalar cubically
  3425. * @param startValue Start value of the animation curve
  3426. * @param outTangent End tangent of the animation
  3427. * @param endValue End value of the animation curve
  3428. * @param inTangent Start tangent of the animation curve
  3429. * @param gradient Scalar amount to interpolate
  3430. * @returns Interpolated scalar value
  3431. */
  3432. Animation.prototype.floatInterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3433. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3434. };
  3435. /**
  3436. * Interpolates a quaternion using a spherical linear interpolation
  3437. * @param startValue Start value of the animation curve
  3438. * @param endValue End value of the animation curve
  3439. * @param gradient Scalar amount to interpolate
  3440. * @returns Interpolated quaternion value
  3441. */
  3442. Animation.prototype.quaternionInterpolateFunction = function (startValue, endValue, gradient) {
  3443. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Slerp(startValue, endValue, gradient);
  3444. };
  3445. /**
  3446. * Interpolates a quaternion cubically
  3447. * @param startValue Start value of the animation curve
  3448. * @param outTangent End tangent of the animation curve
  3449. * @param endValue End value of the animation curve
  3450. * @param inTangent Start tangent of the animation curve
  3451. * @param gradient Scalar amount to interpolate
  3452. * @returns Interpolated quaternion value
  3453. */
  3454. Animation.prototype.quaternionInterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3455. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Hermite(startValue, outTangent, endValue, inTangent, gradient).normalize();
  3456. };
  3457. /**
  3458. * Interpolates a Vector3 linearl
  3459. * @param startValue Start value of the animation curve
  3460. * @param endValue End value of the animation curve
  3461. * @param gradient Scalar amount to interpolate
  3462. * @returns Interpolated scalar value
  3463. */
  3464. Animation.prototype.vector3InterpolateFunction = function (startValue, endValue, gradient) {
  3465. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(startValue, endValue, gradient);
  3466. };
  3467. /**
  3468. * Interpolates a Vector3 cubically
  3469. * @param startValue Start value of the animation curve
  3470. * @param outTangent End tangent of the animation
  3471. * @param endValue End value of the animation curve
  3472. * @param inTangent Start tangent of the animation curve
  3473. * @param gradient Scalar amount to interpolate
  3474. * @returns InterpolatedVector3 value
  3475. */
  3476. Animation.prototype.vector3InterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3477. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3478. };
  3479. /**
  3480. * Interpolates a Vector2 linearly
  3481. * @param startValue Start value of the animation curve
  3482. * @param endValue End value of the animation curve
  3483. * @param gradient Scalar amount to interpolate
  3484. * @returns Interpolated Vector2 value
  3485. */
  3486. Animation.prototype.vector2InterpolateFunction = function (startValue, endValue, gradient) {
  3487. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(startValue, endValue, gradient);
  3488. };
  3489. /**
  3490. * Interpolates a Vector2 cubically
  3491. * @param startValue Start value of the animation curve
  3492. * @param outTangent End tangent of the animation
  3493. * @param endValue End value of the animation curve
  3494. * @param inTangent Start tangent of the animation curve
  3495. * @param gradient Scalar amount to interpolate
  3496. * @returns Interpolated Vector2 value
  3497. */
  3498. Animation.prototype.vector2InterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3499. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3500. };
  3501. /**
  3502. * Interpolates a size linearly
  3503. * @param startValue Start value of the animation curve
  3504. * @param endValue End value of the animation curve
  3505. * @param gradient Scalar amount to interpolate
  3506. * @returns Interpolated Size value
  3507. */
  3508. Animation.prototype.sizeInterpolateFunction = function (startValue, endValue, gradient) {
  3509. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"].Lerp(startValue, endValue, gradient);
  3510. };
  3511. /**
  3512. * Interpolates a Color3 linearly
  3513. * @param startValue Start value of the animation curve
  3514. * @param endValue End value of the animation curve
  3515. * @param gradient Scalar amount to interpolate
  3516. * @returns Interpolated Color3 value
  3517. */
  3518. Animation.prototype.color3InterpolateFunction = function (startValue, endValue, gradient) {
  3519. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Lerp(startValue, endValue, gradient);
  3520. };
  3521. /**
  3522. * @hidden Internal use only
  3523. */
  3524. Animation.prototype._getKeyValue = function (value) {
  3525. if (typeof value === "function") {
  3526. return value();
  3527. }
  3528. return value;
  3529. };
  3530. /**
  3531. * @hidden Internal use only
  3532. */
  3533. Animation.prototype._interpolate = function (currentFrame, repeatCount, workValue, loopMode, offsetValue, highLimitValue) {
  3534. if (loopMode === Animation.ANIMATIONLOOPMODE_CONSTANT && repeatCount > 0) {
  3535. return highLimitValue.clone ? highLimitValue.clone() : highLimitValue;
  3536. }
  3537. var keys = this.getKeys();
  3538. if (keys.length === 1) {
  3539. return this._getKeyValue(keys[0].value);
  3540. }
  3541. // Try to get a hash to find the right key
  3542. var startKeyIndex = Math.max(0, Math.min(keys.length - 1, Math.floor(keys.length * (currentFrame - keys[0].frame) / (keys[keys.length - 1].frame - keys[0].frame)) - 1));
  3543. if (keys[startKeyIndex].frame >= currentFrame) {
  3544. while (startKeyIndex - 1 >= 0 && keys[startKeyIndex].frame >= currentFrame) {
  3545. startKeyIndex--;
  3546. }
  3547. }
  3548. for (var key = startKeyIndex; key < keys.length; key++) {
  3549. var endKey = keys[key + 1];
  3550. if (endKey.frame >= currentFrame) {
  3551. var startKey = keys[key];
  3552. var startValue = this._getKeyValue(startKey.value);
  3553. if (startKey.interpolation === _animationKey__WEBPACK_IMPORTED_MODULE_4__["AnimationKeyInterpolation"].STEP) {
  3554. return startValue;
  3555. }
  3556. var endValue = this._getKeyValue(endKey.value);
  3557. var useTangent = startKey.outTangent !== undefined && endKey.inTangent !== undefined;
  3558. var frameDelta = endKey.frame - startKey.frame;
  3559. // gradient : percent of currentFrame between the frame inf and the frame sup
  3560. var gradient = (currentFrame - startKey.frame) / frameDelta;
  3561. // check for easingFunction and correction of gradient
  3562. var easingFunction = this.getEasingFunction();
  3563. if (easingFunction != null) {
  3564. gradient = easingFunction.ease(gradient);
  3565. }
  3566. switch (this.dataType) {
  3567. // Float
  3568. case Animation.ANIMATIONTYPE_FLOAT:
  3569. var floatValue = useTangent ? this.floatInterpolateFunctionWithTangents(startValue, startKey.outTangent * frameDelta, endValue, endKey.inTangent * frameDelta, gradient) : this.floatInterpolateFunction(startValue, endValue, gradient);
  3570. switch (loopMode) {
  3571. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3572. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3573. return floatValue;
  3574. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3575. return offsetValue * repeatCount + floatValue;
  3576. }
  3577. break;
  3578. // Quaternion
  3579. case Animation.ANIMATIONTYPE_QUATERNION:
  3580. var quatValue = useTangent ? this.quaternionInterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.quaternionInterpolateFunction(startValue, endValue, gradient);
  3581. switch (loopMode) {
  3582. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3583. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3584. return quatValue;
  3585. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3586. return quatValue.addInPlace(offsetValue.scale(repeatCount));
  3587. }
  3588. return quatValue;
  3589. // Vector3
  3590. case Animation.ANIMATIONTYPE_VECTOR3:
  3591. var vec3Value = useTangent ? this.vector3InterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.vector3InterpolateFunction(startValue, endValue, gradient);
  3592. switch (loopMode) {
  3593. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3594. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3595. return vec3Value;
  3596. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3597. return vec3Value.add(offsetValue.scale(repeatCount));
  3598. }
  3599. // Vector2
  3600. case Animation.ANIMATIONTYPE_VECTOR2:
  3601. var vec2Value = useTangent ? this.vector2InterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.vector2InterpolateFunction(startValue, endValue, gradient);
  3602. switch (loopMode) {
  3603. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3604. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3605. return vec2Value;
  3606. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3607. return vec2Value.add(offsetValue.scale(repeatCount));
  3608. }
  3609. // Size
  3610. case Animation.ANIMATIONTYPE_SIZE:
  3611. switch (loopMode) {
  3612. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3613. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3614. return this.sizeInterpolateFunction(startValue, endValue, gradient);
  3615. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3616. return this.sizeInterpolateFunction(startValue, endValue, gradient).add(offsetValue.scale(repeatCount));
  3617. }
  3618. // Color3
  3619. case Animation.ANIMATIONTYPE_COLOR3:
  3620. switch (loopMode) {
  3621. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3622. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3623. return this.color3InterpolateFunction(startValue, endValue, gradient);
  3624. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3625. return this.color3InterpolateFunction(startValue, endValue, gradient).add(offsetValue.scale(repeatCount));
  3626. }
  3627. // Matrix
  3628. case Animation.ANIMATIONTYPE_MATRIX:
  3629. switch (loopMode) {
  3630. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3631. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3632. if (Animation.AllowMatricesInterpolation) {
  3633. return this.matrixInterpolateFunction(startValue, endValue, gradient, workValue);
  3634. }
  3635. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3636. return startValue;
  3637. }
  3638. default:
  3639. break;
  3640. }
  3641. break;
  3642. }
  3643. }
  3644. return this._getKeyValue(keys[keys.length - 1].value);
  3645. };
  3646. /**
  3647. * Defines the function to use to interpolate matrices
  3648. * @param startValue defines the start matrix
  3649. * @param endValue defines the end matrix
  3650. * @param gradient defines the gradient between both matrices
  3651. * @param result defines an optional target matrix where to store the interpolation
  3652. * @returns the interpolated matrix
  3653. */
  3654. Animation.prototype.matrixInterpolateFunction = function (startValue, endValue, gradient, result) {
  3655. if (Animation.AllowMatrixDecomposeForInterpolation) {
  3656. if (result) {
  3657. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerpToRef(startValue, endValue, gradient, result);
  3658. return result;
  3659. }
  3660. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerp(startValue, endValue, gradient);
  3661. }
  3662. if (result) {
  3663. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LerpToRef(startValue, endValue, gradient, result);
  3664. return result;
  3665. }
  3666. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Lerp(startValue, endValue, gradient);
  3667. };
  3668. /**
  3669. * Makes a copy of the animation
  3670. * @returns Cloned animation
  3671. */
  3672. Animation.prototype.clone = function () {
  3673. var clone = new Animation(this.name, this.targetPropertyPath.join("."), this.framePerSecond, this.dataType, this.loopMode);
  3674. clone.enableBlending = this.enableBlending;
  3675. clone.blendingSpeed = this.blendingSpeed;
  3676. if (this._keys) {
  3677. clone.setKeys(this._keys);
  3678. }
  3679. if (this._ranges) {
  3680. clone._ranges = {};
  3681. for (var name in this._ranges) {
  3682. var range = this._ranges[name];
  3683. if (!range) {
  3684. continue;
  3685. }
  3686. clone._ranges[name] = range.clone();
  3687. }
  3688. }
  3689. return clone;
  3690. };
  3691. /**
  3692. * Sets the key frames of the animation
  3693. * @param values The animation key frames to set
  3694. */
  3695. Animation.prototype.setKeys = function (values) {
  3696. this._keys = values.slice(0);
  3697. };
  3698. /**
  3699. * Serializes the animation to an object
  3700. * @returns Serialized object
  3701. */
  3702. Animation.prototype.serialize = function () {
  3703. var serializationObject = {};
  3704. serializationObject.name = this.name;
  3705. serializationObject.property = this.targetProperty;
  3706. serializationObject.framePerSecond = this.framePerSecond;
  3707. serializationObject.dataType = this.dataType;
  3708. serializationObject.loopBehavior = this.loopMode;
  3709. serializationObject.enableBlending = this.enableBlending;
  3710. serializationObject.blendingSpeed = this.blendingSpeed;
  3711. var dataType = this.dataType;
  3712. serializationObject.keys = [];
  3713. var keys = this.getKeys();
  3714. for (var index = 0; index < keys.length; index++) {
  3715. var animationKey = keys[index];
  3716. var key = {};
  3717. key.frame = animationKey.frame;
  3718. switch (dataType) {
  3719. case Animation.ANIMATIONTYPE_FLOAT:
  3720. key.values = [animationKey.value];
  3721. break;
  3722. case Animation.ANIMATIONTYPE_QUATERNION:
  3723. case Animation.ANIMATIONTYPE_MATRIX:
  3724. case Animation.ANIMATIONTYPE_VECTOR3:
  3725. case Animation.ANIMATIONTYPE_COLOR3:
  3726. key.values = animationKey.value.asArray();
  3727. break;
  3728. }
  3729. serializationObject.keys.push(key);
  3730. }
  3731. serializationObject.ranges = [];
  3732. for (var name in this._ranges) {
  3733. var source = this._ranges[name];
  3734. if (!source) {
  3735. continue;
  3736. }
  3737. var range = {};
  3738. range.name = name;
  3739. range.from = source.from;
  3740. range.to = source.to;
  3741. serializationObject.ranges.push(range);
  3742. }
  3743. return serializationObject;
  3744. };
  3745. Object.defineProperty(Animation, "ANIMATIONTYPE_FLOAT", {
  3746. /**
  3747. * Get the float animation type
  3748. */
  3749. get: function () {
  3750. return Animation._ANIMATIONTYPE_FLOAT;
  3751. },
  3752. enumerable: true,
  3753. configurable: true
  3754. });
  3755. Object.defineProperty(Animation, "ANIMATIONTYPE_VECTOR3", {
  3756. /**
  3757. * Get the Vector3 animation type
  3758. */
  3759. get: function () {
  3760. return Animation._ANIMATIONTYPE_VECTOR3;
  3761. },
  3762. enumerable: true,
  3763. configurable: true
  3764. });
  3765. Object.defineProperty(Animation, "ANIMATIONTYPE_VECTOR2", {
  3766. /**
  3767. * Get the Vector2 animation type
  3768. */
  3769. get: function () {
  3770. return Animation._ANIMATIONTYPE_VECTOR2;
  3771. },
  3772. enumerable: true,
  3773. configurable: true
  3774. });
  3775. Object.defineProperty(Animation, "ANIMATIONTYPE_SIZE", {
  3776. /**
  3777. * Get the Size animation type
  3778. */
  3779. get: function () {
  3780. return Animation._ANIMATIONTYPE_SIZE;
  3781. },
  3782. enumerable: true,
  3783. configurable: true
  3784. });
  3785. Object.defineProperty(Animation, "ANIMATIONTYPE_QUATERNION", {
  3786. /**
  3787. * Get the Quaternion animation type
  3788. */
  3789. get: function () {
  3790. return Animation._ANIMATIONTYPE_QUATERNION;
  3791. },
  3792. enumerable: true,
  3793. configurable: true
  3794. });
  3795. Object.defineProperty(Animation, "ANIMATIONTYPE_MATRIX", {
  3796. /**
  3797. * Get the Matrix animation type
  3798. */
  3799. get: function () {
  3800. return Animation._ANIMATIONTYPE_MATRIX;
  3801. },
  3802. enumerable: true,
  3803. configurable: true
  3804. });
  3805. Object.defineProperty(Animation, "ANIMATIONTYPE_COLOR3", {
  3806. /**
  3807. * Get the Color3 animation type
  3808. */
  3809. get: function () {
  3810. return Animation._ANIMATIONTYPE_COLOR3;
  3811. },
  3812. enumerable: true,
  3813. configurable: true
  3814. });
  3815. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_RELATIVE", {
  3816. /**
  3817. * Get the Relative Loop Mode
  3818. */
  3819. get: function () {
  3820. return Animation._ANIMATIONLOOPMODE_RELATIVE;
  3821. },
  3822. enumerable: true,
  3823. configurable: true
  3824. });
  3825. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_CYCLE", {
  3826. /**
  3827. * Get the Cycle Loop Mode
  3828. */
  3829. get: function () {
  3830. return Animation._ANIMATIONLOOPMODE_CYCLE;
  3831. },
  3832. enumerable: true,
  3833. configurable: true
  3834. });
  3835. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_CONSTANT", {
  3836. /**
  3837. * Get the Constant Loop Mode
  3838. */
  3839. get: function () {
  3840. return Animation._ANIMATIONLOOPMODE_CONSTANT;
  3841. },
  3842. enumerable: true,
  3843. configurable: true
  3844. });
  3845. /** @hidden */
  3846. Animation._UniversalLerp = function (left, right, amount) {
  3847. var constructor = left.constructor;
  3848. if (constructor.Lerp) { // Lerp supported
  3849. return constructor.Lerp(left, right, amount);
  3850. }
  3851. else if (constructor.Slerp) { // Slerp supported
  3852. return constructor.Slerp(left, right, amount);
  3853. }
  3854. else if (left.toFixed) { // Number
  3855. return left * (1.0 - amount) + amount * right;
  3856. }
  3857. else { // Blending not supported
  3858. return right;
  3859. }
  3860. };
  3861. /**
  3862. * Parses an animation object and creates an animation
  3863. * @param parsedAnimation Parsed animation object
  3864. * @returns Animation object
  3865. */
  3866. Animation.Parse = function (parsedAnimation) {
  3867. var animation = new Animation(parsedAnimation.name, parsedAnimation.property, parsedAnimation.framePerSecond, parsedAnimation.dataType, parsedAnimation.loopBehavior);
  3868. var dataType = parsedAnimation.dataType;
  3869. var keys = [];
  3870. var data;
  3871. var index;
  3872. if (parsedAnimation.enableBlending) {
  3873. animation.enableBlending = parsedAnimation.enableBlending;
  3874. }
  3875. if (parsedAnimation.blendingSpeed) {
  3876. animation.blendingSpeed = parsedAnimation.blendingSpeed;
  3877. }
  3878. for (index = 0; index < parsedAnimation.keys.length; index++) {
  3879. var key = parsedAnimation.keys[index];
  3880. var inTangent;
  3881. var outTangent;
  3882. switch (dataType) {
  3883. case Animation.ANIMATIONTYPE_FLOAT:
  3884. data = key.values[0];
  3885. if (key.values.length >= 1) {
  3886. inTangent = key.values[1];
  3887. }
  3888. if (key.values.length >= 2) {
  3889. outTangent = key.values[2];
  3890. }
  3891. break;
  3892. case Animation.ANIMATIONTYPE_QUATERNION:
  3893. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values);
  3894. if (key.values.length >= 8) {
  3895. var _inTangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values.slice(4, 8));
  3896. if (!_inTangent.equals(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Zero())) {
  3897. inTangent = _inTangent;
  3898. }
  3899. }
  3900. if (key.values.length >= 12) {
  3901. var _outTangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values.slice(8, 12));
  3902. if (!_outTangent.equals(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Zero())) {
  3903. outTangent = _outTangent;
  3904. }
  3905. }
  3906. break;
  3907. case Animation.ANIMATIONTYPE_MATRIX:
  3908. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromArray(key.values);
  3909. break;
  3910. case Animation.ANIMATIONTYPE_COLOR3:
  3911. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].FromArray(key.values);
  3912. break;
  3913. case Animation.ANIMATIONTYPE_VECTOR3:
  3914. default:
  3915. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(key.values);
  3916. break;
  3917. }
  3918. var keyData = {};
  3919. keyData.frame = key.frame;
  3920. keyData.value = data;
  3921. if (inTangent != undefined) {
  3922. keyData.inTangent = inTangent;
  3923. }
  3924. if (outTangent != undefined) {
  3925. keyData.outTangent = outTangent;
  3926. }
  3927. keys.push(keyData);
  3928. }
  3929. animation.setKeys(keys);
  3930. if (parsedAnimation.ranges) {
  3931. for (index = 0; index < parsedAnimation.ranges.length; index++) {
  3932. data = parsedAnimation.ranges[index];
  3933. animation.createRange(data.name, data.from, data.to);
  3934. }
  3935. }
  3936. return animation;
  3937. };
  3938. /**
  3939. * Appends the serialized animations from the source animations
  3940. * @param source Source containing the animations
  3941. * @param destination Target to store the animations
  3942. */
  3943. Animation.AppendSerializedAnimations = function (source, destination) {
  3944. _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].AppendSerializedAnimations(source, destination);
  3945. };
  3946. /**
  3947. * Use matrix interpolation instead of using direct key value when animating matrices
  3948. */
  3949. Animation.AllowMatricesInterpolation = false;
  3950. /**
  3951. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3952. */
  3953. Animation.AllowMatrixDecomposeForInterpolation = true;
  3954. // Statics
  3955. /**
  3956. * Float animation type
  3957. */
  3958. Animation._ANIMATIONTYPE_FLOAT = 0;
  3959. /**
  3960. * Vector3 animation type
  3961. */
  3962. Animation._ANIMATIONTYPE_VECTOR3 = 1;
  3963. /**
  3964. * Quaternion animation type
  3965. */
  3966. Animation._ANIMATIONTYPE_QUATERNION = 2;
  3967. /**
  3968. * Matrix animation type
  3969. */
  3970. Animation._ANIMATIONTYPE_MATRIX = 3;
  3971. /**
  3972. * Color3 animation type
  3973. */
  3974. Animation._ANIMATIONTYPE_COLOR3 = 4;
  3975. /**
  3976. * Vector2 animation type
  3977. */
  3978. Animation._ANIMATIONTYPE_VECTOR2 = 5;
  3979. /**
  3980. * Size animation type
  3981. */
  3982. Animation._ANIMATIONTYPE_SIZE = 6;
  3983. /**
  3984. * Relative Loop Mode
  3985. */
  3986. Animation._ANIMATIONLOOPMODE_RELATIVE = 0;
  3987. /**
  3988. * Cycle Loop Mode
  3989. */
  3990. Animation._ANIMATIONLOOPMODE_CYCLE = 1;
  3991. /**
  3992. * Constant Loop Mode
  3993. */
  3994. Animation._ANIMATIONLOOPMODE_CONSTANT = 2;
  3995. return Animation;
  3996. }());
  3997. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.Animation"] = Animation;
  3998. _node__WEBPACK_IMPORTED_MODULE_6__["Node"]._AnimationRangeFactory = function (name, from, to) { return new _animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, from, to); };
  3999. /***/ }),
  4000. /***/ "./Animations/animationEvent.ts":
  4001. /*!**************************************!*\
  4002. !*** ./Animations/animationEvent.ts ***!
  4003. \**************************************/
  4004. /*! exports provided: AnimationEvent */
  4005. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4006. "use strict";
  4007. __webpack_require__.r(__webpack_exports__);
  4008. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return AnimationEvent; });
  4009. /**
  4010. * Composed of a frame, and an action function
  4011. */
  4012. var AnimationEvent = /** @class */ (function () {
  4013. /**
  4014. * Initializes the animation event
  4015. * @param frame The frame for which the event is triggered
  4016. * @param action The event to perform when triggered
  4017. * @param onlyOnce Specifies if the event should be triggered only once
  4018. */
  4019. function AnimationEvent(
  4020. /** The frame for which the event is triggered **/
  4021. frame,
  4022. /** The event to perform when triggered **/
  4023. action,
  4024. /** Specifies if the event should be triggered only once**/
  4025. onlyOnce) {
  4026. this.frame = frame;
  4027. this.action = action;
  4028. this.onlyOnce = onlyOnce;
  4029. /**
  4030. * Specifies if the animation event is done
  4031. */
  4032. this.isDone = false;
  4033. }
  4034. /** @hidden */
  4035. AnimationEvent.prototype._clone = function () {
  4036. return new AnimationEvent(this.frame, this.action, this.onlyOnce);
  4037. };
  4038. return AnimationEvent;
  4039. }());
  4040. /***/ }),
  4041. /***/ "./Animations/animationGroup.ts":
  4042. /*!**************************************!*\
  4043. !*** ./Animations/animationGroup.ts ***!
  4044. \**************************************/
  4045. /*! exports provided: TargetedAnimation, AnimationGroup */
  4046. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4047. "use strict";
  4048. __webpack_require__.r(__webpack_exports__);
  4049. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return TargetedAnimation; });
  4050. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return AnimationGroup; });
  4051. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  4052. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  4053. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  4054. /**
  4055. * This class defines the direct association between an animation and a target
  4056. */
  4057. var TargetedAnimation = /** @class */ (function () {
  4058. function TargetedAnimation() {
  4059. }
  4060. return TargetedAnimation;
  4061. }());
  4062. /**
  4063. * Use this class to create coordinated animations on multiple targets
  4064. */
  4065. var AnimationGroup = /** @class */ (function () {
  4066. /**
  4067. * Instantiates a new Animation Group.
  4068. * This helps managing several animations at once.
  4069. * @see http://doc.babylonjs.com/how_to/group
  4070. * @param name Defines the name of the group
  4071. * @param scene Defines the scene the group belongs to
  4072. */
  4073. function AnimationGroup(
  4074. /** The name of the animation group */
  4075. name, scene) {
  4076. if (scene === void 0) { scene = null; }
  4077. this.name = name;
  4078. this._targetedAnimations = new Array();
  4079. this._animatables = new Array();
  4080. this._from = Number.MAX_VALUE;
  4081. this._to = -Number.MAX_VALUE;
  4082. this._speedRatio = 1;
  4083. /**
  4084. * This observable will notify when one animation have ended
  4085. */
  4086. this.onAnimationEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4087. /**
  4088. * Observer raised when one animation loops
  4089. */
  4090. this.onAnimationLoopObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4091. /**
  4092. * This observable will notify when all animations have ended.
  4093. */
  4094. this.onAnimationGroupEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4095. /**
  4096. * This observable will notify when all animations have paused.
  4097. */
  4098. this.onAnimationGroupPauseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4099. /**
  4100. * This observable will notify when all animations are playing.
  4101. */
  4102. this.onAnimationGroupPlayObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4103. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  4104. this.uniqueId = this._scene.getUniqueId();
  4105. this._scene.animationGroups.push(this);
  4106. }
  4107. Object.defineProperty(AnimationGroup.prototype, "from", {
  4108. /**
  4109. * Gets the first frame
  4110. */
  4111. get: function () {
  4112. return this._from;
  4113. },
  4114. enumerable: true,
  4115. configurable: true
  4116. });
  4117. Object.defineProperty(AnimationGroup.prototype, "to", {
  4118. /**
  4119. * Gets the last frame
  4120. */
  4121. get: function () {
  4122. return this._to;
  4123. },
  4124. enumerable: true,
  4125. configurable: true
  4126. });
  4127. Object.defineProperty(AnimationGroup.prototype, "isStarted", {
  4128. /**
  4129. * Define if the animations are started
  4130. */
  4131. get: function () {
  4132. return this._isStarted;
  4133. },
  4134. enumerable: true,
  4135. configurable: true
  4136. });
  4137. Object.defineProperty(AnimationGroup.prototype, "isPlaying", {
  4138. /**
  4139. * Gets a value indicating that the current group is playing
  4140. */
  4141. get: function () {
  4142. return this._isStarted && !this._isPaused;
  4143. },
  4144. enumerable: true,
  4145. configurable: true
  4146. });
  4147. Object.defineProperty(AnimationGroup.prototype, "speedRatio", {
  4148. /**
  4149. * Gets or sets the speed ratio to use for all animations
  4150. */
  4151. get: function () {
  4152. return this._speedRatio;
  4153. },
  4154. /**
  4155. * Gets or sets the speed ratio to use for all animations
  4156. */
  4157. set: function (value) {
  4158. if (this._speedRatio === value) {
  4159. return;
  4160. }
  4161. this._speedRatio = value;
  4162. for (var index = 0; index < this._animatables.length; index++) {
  4163. var animatable = this._animatables[index];
  4164. animatable.speedRatio = this._speedRatio;
  4165. }
  4166. },
  4167. enumerable: true,
  4168. configurable: true
  4169. });
  4170. Object.defineProperty(AnimationGroup.prototype, "targetedAnimations", {
  4171. /**
  4172. * Gets the targeted animations for this animation group
  4173. */
  4174. get: function () {
  4175. return this._targetedAnimations;
  4176. },
  4177. enumerable: true,
  4178. configurable: true
  4179. });
  4180. Object.defineProperty(AnimationGroup.prototype, "animatables", {
  4181. /**
  4182. * returning the list of animatables controlled by this animation group.
  4183. */
  4184. get: function () {
  4185. return this._animatables;
  4186. },
  4187. enumerable: true,
  4188. configurable: true
  4189. });
  4190. /**
  4191. * Add an animation (with its target) in the group
  4192. * @param animation defines the animation we want to add
  4193. * @param target defines the target of the animation
  4194. * @returns the TargetedAnimation object
  4195. */
  4196. AnimationGroup.prototype.addTargetedAnimation = function (animation, target) {
  4197. var targetedAnimation = {
  4198. animation: animation,
  4199. target: target
  4200. };
  4201. var keys = animation.getKeys();
  4202. if (this._from > keys[0].frame) {
  4203. this._from = keys[0].frame;
  4204. }
  4205. if (this._to < keys[keys.length - 1].frame) {
  4206. this._to = keys[keys.length - 1].frame;
  4207. }
  4208. this._targetedAnimations.push(targetedAnimation);
  4209. return targetedAnimation;
  4210. };
  4211. /**
  4212. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4213. * It can add constant keys at begin or end
  4214. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4215. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4216. * @returns the animation group
  4217. */
  4218. AnimationGroup.prototype.normalize = function (beginFrame, endFrame) {
  4219. if (beginFrame === void 0) { beginFrame = null; }
  4220. if (endFrame === void 0) { endFrame = null; }
  4221. if (beginFrame == null) {
  4222. beginFrame = this._from;
  4223. }
  4224. if (endFrame == null) {
  4225. endFrame = this._to;
  4226. }
  4227. for (var index = 0; index < this._targetedAnimations.length; index++) {
  4228. var targetedAnimation = this._targetedAnimations[index];
  4229. var keys = targetedAnimation.animation.getKeys();
  4230. var startKey = keys[0];
  4231. var endKey = keys[keys.length - 1];
  4232. if (startKey.frame > beginFrame) {
  4233. var newKey = {
  4234. frame: beginFrame,
  4235. value: startKey.value,
  4236. inTangent: startKey.inTangent,
  4237. outTangent: startKey.outTangent,
  4238. interpolation: startKey.interpolation
  4239. };
  4240. keys.splice(0, 0, newKey);
  4241. }
  4242. if (endKey.frame < endFrame) {
  4243. var newKey = {
  4244. frame: endFrame,
  4245. value: endKey.value,
  4246. inTangent: endKey.outTangent,
  4247. outTangent: endKey.outTangent,
  4248. interpolation: endKey.interpolation
  4249. };
  4250. keys.push(newKey);
  4251. }
  4252. }
  4253. this._from = beginFrame;
  4254. this._to = endFrame;
  4255. return this;
  4256. };
  4257. /**
  4258. * Start all animations on given targets
  4259. * @param loop defines if animations must loop
  4260. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4261. * @param from defines the from key (optional)
  4262. * @param to defines the to key (optional)
  4263. * @returns the current animation group
  4264. */
  4265. AnimationGroup.prototype.start = function (loop, speedRatio, from, to) {
  4266. var _this = this;
  4267. if (loop === void 0) { loop = false; }
  4268. if (speedRatio === void 0) { speedRatio = 1; }
  4269. if (this._isStarted || this._targetedAnimations.length === 0) {
  4270. return this;
  4271. }
  4272. var _loop_1 = function (targetedAnimation) {
  4273. var animatable = this_1._scene.beginDirectAnimation(targetedAnimation.target, [targetedAnimation.animation], from !== undefined ? from : this_1._from, to !== undefined ? to : this_1._to, loop, speedRatio);
  4274. animatable.onAnimationEnd = function () {
  4275. _this.onAnimationEndObservable.notifyObservers(targetedAnimation);
  4276. _this._checkAnimationGroupEnded(animatable);
  4277. };
  4278. animatable.onAnimationLoop = function () {
  4279. _this.onAnimationLoopObservable.notifyObservers(targetedAnimation);
  4280. };
  4281. this_1._animatables.push(animatable);
  4282. };
  4283. var this_1 = this;
  4284. for (var _i = 0, _a = this._targetedAnimations; _i < _a.length; _i++) {
  4285. var targetedAnimation = _a[_i];
  4286. _loop_1(targetedAnimation);
  4287. }
  4288. this._speedRatio = speedRatio;
  4289. if (from !== undefined && to !== undefined && from > to && this._speedRatio > 0) {
  4290. this._speedRatio = -speedRatio;
  4291. }
  4292. this._isStarted = true;
  4293. this._isPaused = false;
  4294. this.onAnimationGroupPlayObservable.notifyObservers(this);
  4295. return this;
  4296. };
  4297. /**
  4298. * Pause all animations
  4299. * @returns the animation group
  4300. */
  4301. AnimationGroup.prototype.pause = function () {
  4302. if (!this._isStarted) {
  4303. return this;
  4304. }
  4305. this._isPaused = true;
  4306. for (var index = 0; index < this._animatables.length; index++) {
  4307. var animatable = this._animatables[index];
  4308. animatable.pause();
  4309. }
  4310. this.onAnimationGroupPauseObservable.notifyObservers(this);
  4311. return this;
  4312. };
  4313. /**
  4314. * Play all animations to initial state
  4315. * This function will start() the animations if they were not started or will restart() them if they were paused
  4316. * @param loop defines if animations must loop
  4317. * @returns the animation group
  4318. */
  4319. AnimationGroup.prototype.play = function (loop) {
  4320. // only if all animatables are ready and exist
  4321. if (this.isStarted && this._animatables.length === this._targetedAnimations.length) {
  4322. if (loop !== undefined) {
  4323. for (var index = 0; index < this._animatables.length; index++) {
  4324. var animatable = this._animatables[index];
  4325. animatable.loopAnimation = loop;
  4326. }
  4327. }
  4328. this.restart();
  4329. }
  4330. else {
  4331. this.stop();
  4332. this.start(loop, this._speedRatio);
  4333. }
  4334. this._isPaused = false;
  4335. return this;
  4336. };
  4337. /**
  4338. * Reset all animations to initial state
  4339. * @returns the animation group
  4340. */
  4341. AnimationGroup.prototype.reset = function () {
  4342. if (!this._isStarted) {
  4343. return this;
  4344. }
  4345. for (var index = 0; index < this._animatables.length; index++) {
  4346. var animatable = this._animatables[index];
  4347. animatable.reset();
  4348. }
  4349. return this;
  4350. };
  4351. /**
  4352. * Restart animations from key 0
  4353. * @returns the animation group
  4354. */
  4355. AnimationGroup.prototype.restart = function () {
  4356. if (!this._isStarted) {
  4357. return this;
  4358. }
  4359. for (var index = 0; index < this._animatables.length; index++) {
  4360. var animatable = this._animatables[index];
  4361. animatable.restart();
  4362. }
  4363. this.onAnimationGroupPlayObservable.notifyObservers(this);
  4364. return this;
  4365. };
  4366. /**
  4367. * Stop all animations
  4368. * @returns the animation group
  4369. */
  4370. AnimationGroup.prototype.stop = function () {
  4371. if (!this._isStarted) {
  4372. return this;
  4373. }
  4374. var list = this._animatables.slice();
  4375. for (var index = 0; index < list.length; index++) {
  4376. list[index].stop();
  4377. }
  4378. this._isStarted = false;
  4379. return this;
  4380. };
  4381. /**
  4382. * Set animation weight for all animatables
  4383. * @param weight defines the weight to use
  4384. * @return the animationGroup
  4385. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4386. */
  4387. AnimationGroup.prototype.setWeightForAllAnimatables = function (weight) {
  4388. for (var index = 0; index < this._animatables.length; index++) {
  4389. var animatable = this._animatables[index];
  4390. animatable.weight = weight;
  4391. }
  4392. return this;
  4393. };
  4394. /**
  4395. * Synchronize and normalize all animatables with a source animatable
  4396. * @param root defines the root animatable to synchronize with
  4397. * @return the animationGroup
  4398. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4399. */
  4400. AnimationGroup.prototype.syncAllAnimationsWith = function (root) {
  4401. for (var index = 0; index < this._animatables.length; index++) {
  4402. var animatable = this._animatables[index];
  4403. animatable.syncWith(root);
  4404. }
  4405. return this;
  4406. };
  4407. /**
  4408. * Goes to a specific frame in this animation group
  4409. * @param frame the frame number to go to
  4410. * @return the animationGroup
  4411. */
  4412. AnimationGroup.prototype.goToFrame = function (frame) {
  4413. if (!this._isStarted) {
  4414. return this;
  4415. }
  4416. for (var index = 0; index < this._animatables.length; index++) {
  4417. var animatable = this._animatables[index];
  4418. animatable.goToFrame(frame);
  4419. }
  4420. return this;
  4421. };
  4422. /**
  4423. * Dispose all associated resources
  4424. */
  4425. AnimationGroup.prototype.dispose = function () {
  4426. this._targetedAnimations = [];
  4427. this._animatables = [];
  4428. var index = this._scene.animationGroups.indexOf(this);
  4429. if (index > -1) {
  4430. this._scene.animationGroups.splice(index, 1);
  4431. }
  4432. this.onAnimationEndObservable.clear();
  4433. this.onAnimationGroupEndObservable.clear();
  4434. this.onAnimationGroupPauseObservable.clear();
  4435. this.onAnimationGroupPlayObservable.clear();
  4436. this.onAnimationLoopObservable.clear();
  4437. };
  4438. AnimationGroup.prototype._checkAnimationGroupEnded = function (animatable) {
  4439. // animatable should be taken out of the array
  4440. var idx = this._animatables.indexOf(animatable);
  4441. if (idx > -1) {
  4442. this._animatables.splice(idx, 1);
  4443. }
  4444. // all animatables were removed? animation group ended!
  4445. if (this._animatables.length === 0) {
  4446. this._isStarted = false;
  4447. this.onAnimationGroupEndObservable.notifyObservers(this);
  4448. }
  4449. };
  4450. /**
  4451. * Clone the current animation group and returns a copy
  4452. * @param newName defines the name of the new group
  4453. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  4454. * @returns the new aniamtion group
  4455. */
  4456. AnimationGroup.prototype.clone = function (newName, targetConverter) {
  4457. var newGroup = new AnimationGroup(newName || this.name, this._scene);
  4458. for (var _i = 0, _a = this._targetedAnimations; _i < _a.length; _i++) {
  4459. var targetAnimation = _a[_i];
  4460. newGroup.addTargetedAnimation(targetAnimation.animation.clone(), targetConverter ? targetConverter(targetAnimation.target) : targetAnimation.target);
  4461. }
  4462. return newGroup;
  4463. };
  4464. // Statics
  4465. /**
  4466. * Returns a new AnimationGroup object parsed from the source provided.
  4467. * @param parsedAnimationGroup defines the source
  4468. * @param scene defines the scene that will receive the animationGroup
  4469. * @returns a new AnimationGroup
  4470. */
  4471. AnimationGroup.Parse = function (parsedAnimationGroup, scene) {
  4472. var animationGroup = new AnimationGroup(parsedAnimationGroup.name, scene);
  4473. for (var i = 0; i < parsedAnimationGroup.targetedAnimations.length; i++) {
  4474. var targetedAnimation = parsedAnimationGroup.targetedAnimations[i];
  4475. var animation = _animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].Parse(targetedAnimation.animation);
  4476. var id = targetedAnimation.targetId;
  4477. if (targetedAnimation.animation.property === "influence") { // morph target animation
  4478. var morphTarget = scene.getMorphTargetById(id);
  4479. if (morphTarget) {
  4480. animationGroup.addTargetedAnimation(animation, morphTarget);
  4481. }
  4482. }
  4483. else {
  4484. var targetNode = scene.getNodeByID(id);
  4485. if (targetNode != null) {
  4486. animationGroup.addTargetedAnimation(animation, targetNode);
  4487. }
  4488. }
  4489. }
  4490. if (parsedAnimationGroup.from !== null && parsedAnimationGroup.from !== null) {
  4491. animationGroup.normalize(parsedAnimationGroup.from, parsedAnimationGroup.to);
  4492. }
  4493. return animationGroup;
  4494. };
  4495. /**
  4496. * Returns the string "AnimationGroup"
  4497. * @returns "AnimationGroup"
  4498. */
  4499. AnimationGroup.prototype.getClassName = function () {
  4500. return "AnimationGroup";
  4501. };
  4502. /**
  4503. * Creates a detailled string about the object
  4504. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  4505. * @returns a string representing the object
  4506. */
  4507. AnimationGroup.prototype.toString = function (fullDetails) {
  4508. var ret = "Name: " + this.name;
  4509. ret += ", type: " + this.getClassName();
  4510. if (fullDetails) {
  4511. ret += ", from: " + this._from;
  4512. ret += ", to: " + this._to;
  4513. ret += ", isStarted: " + this._isStarted;
  4514. ret += ", speedRatio: " + this._speedRatio;
  4515. ret += ", targetedAnimations length: " + this._targetedAnimations.length;
  4516. ret += ", animatables length: " + this._animatables;
  4517. }
  4518. return ret;
  4519. };
  4520. return AnimationGroup;
  4521. }());
  4522. /***/ }),
  4523. /***/ "./Animations/animationKey.ts":
  4524. /*!************************************!*\
  4525. !*** ./Animations/animationKey.ts ***!
  4526. \************************************/
  4527. /*! exports provided: AnimationKeyInterpolation */
  4528. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4529. "use strict";
  4530. __webpack_require__.r(__webpack_exports__);
  4531. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return AnimationKeyInterpolation; });
  4532. /**
  4533. * Enum for the animation key frame interpolation type
  4534. */
  4535. var AnimationKeyInterpolation;
  4536. (function (AnimationKeyInterpolation) {
  4537. /**
  4538. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  4539. */
  4540. AnimationKeyInterpolation[AnimationKeyInterpolation["STEP"] = 1] = "STEP";
  4541. })(AnimationKeyInterpolation || (AnimationKeyInterpolation = {}));
  4542. /***/ }),
  4543. /***/ "./Animations/animationPropertiesOverride.ts":
  4544. /*!***************************************************!*\
  4545. !*** ./Animations/animationPropertiesOverride.ts ***!
  4546. \***************************************************/
  4547. /*! exports provided: AnimationPropertiesOverride */
  4548. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4549. "use strict";
  4550. __webpack_require__.r(__webpack_exports__);
  4551. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return AnimationPropertiesOverride; });
  4552. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  4553. /**
  4554. * Class used to override all child animations of a given target
  4555. */
  4556. var AnimationPropertiesOverride = /** @class */ (function () {
  4557. function AnimationPropertiesOverride() {
  4558. /**
  4559. * Gets or sets a value indicating if animation blending must be used
  4560. */
  4561. this.enableBlending = false;
  4562. /**
  4563. * Gets or sets the blending speed to use when enableBlending is true
  4564. */
  4565. this.blendingSpeed = 0.01;
  4566. /**
  4567. * Gets or sets the default loop mode to use
  4568. */
  4569. this.loopMode = _Animations_animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].ANIMATIONLOOPMODE_CYCLE;
  4570. }
  4571. return AnimationPropertiesOverride;
  4572. }());
  4573. /***/ }),
  4574. /***/ "./Animations/animationRange.ts":
  4575. /*!**************************************!*\
  4576. !*** ./Animations/animationRange.ts ***!
  4577. \**************************************/
  4578. /*! exports provided: AnimationRange */
  4579. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4580. "use strict";
  4581. __webpack_require__.r(__webpack_exports__);
  4582. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return AnimationRange; });
  4583. /**
  4584. * Represents the range of an animation
  4585. */
  4586. var AnimationRange = /** @class */ (function () {
  4587. /**
  4588. * Initializes the range of an animation
  4589. * @param name The name of the animation range
  4590. * @param from The starting frame of the animation
  4591. * @param to The ending frame of the animation
  4592. */
  4593. function AnimationRange(
  4594. /**The name of the animation range**/
  4595. name,
  4596. /**The starting frame of the animation */
  4597. from,
  4598. /**The ending frame of the animation*/
  4599. to) {
  4600. this.name = name;
  4601. this.from = from;
  4602. this.to = to;
  4603. }
  4604. /**
  4605. * Makes a copy of the animation range
  4606. * @returns A copy of the animation range
  4607. */
  4608. AnimationRange.prototype.clone = function () {
  4609. return new AnimationRange(this.name, this.from, this.to);
  4610. };
  4611. return AnimationRange;
  4612. }());
  4613. /***/ }),
  4614. /***/ "./Animations/easing.ts":
  4615. /*!******************************!*\
  4616. !*** ./Animations/easing.ts ***!
  4617. \******************************/
  4618. /*! exports provided: EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase */
  4619. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4620. "use strict";
  4621. __webpack_require__.r(__webpack_exports__);
  4622. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return EasingFunction; });
  4623. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return CircleEase; });
  4624. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return BackEase; });
  4625. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return BounceEase; });
  4626. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return CubicEase; });
  4627. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return ElasticEase; });
  4628. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return ExponentialEase; });
  4629. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return PowerEase; });
  4630. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return QuadraticEase; });
  4631. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return QuarticEase; });
  4632. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return QuinticEase; });
  4633. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return SineEase; });
  4634. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return BezierCurveEase; });
  4635. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  4636. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  4637. /**
  4638. * Base class used for every default easing function.
  4639. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4640. */
  4641. var EasingFunction = /** @class */ (function () {
  4642. function EasingFunction() {
  4643. this._easingMode = EasingFunction.EASINGMODE_EASEIN;
  4644. }
  4645. /**
  4646. * Sets the easing mode of the current function.
  4647. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4648. */
  4649. EasingFunction.prototype.setEasingMode = function (easingMode) {
  4650. var n = Math.min(Math.max(easingMode, 0), 2);
  4651. this._easingMode = n;
  4652. };
  4653. /**
  4654. * Gets the current easing mode.
  4655. * @returns the easing mode
  4656. */
  4657. EasingFunction.prototype.getEasingMode = function () {
  4658. return this._easingMode;
  4659. };
  4660. /**
  4661. * @hidden
  4662. */
  4663. EasingFunction.prototype.easeInCore = function (gradient) {
  4664. throw new Error('You must implement this method');
  4665. };
  4666. /**
  4667. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4668. * of the easing function.
  4669. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4670. * @returns the corresponding value on the curve defined by the easing function
  4671. */
  4672. EasingFunction.prototype.ease = function (gradient) {
  4673. switch (this._easingMode) {
  4674. case EasingFunction.EASINGMODE_EASEIN:
  4675. return this.easeInCore(gradient);
  4676. case EasingFunction.EASINGMODE_EASEOUT:
  4677. return (1 - this.easeInCore(1 - gradient));
  4678. }
  4679. if (gradient >= 0.5) {
  4680. return (((1 - this.easeInCore((1 - gradient) * 2)) * 0.5) + 0.5);
  4681. }
  4682. return (this.easeInCore(gradient * 2) * 0.5);
  4683. };
  4684. /**
  4685. * Interpolation follows the mathematical formula associated with the easing function.
  4686. */
  4687. EasingFunction.EASINGMODE_EASEIN = 0;
  4688. /**
  4689. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4690. */
  4691. EasingFunction.EASINGMODE_EASEOUT = 1;
  4692. /**
  4693. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4694. */
  4695. EasingFunction.EASINGMODE_EASEINOUT = 2;
  4696. return EasingFunction;
  4697. }());
  4698. /**
  4699. * Easing function with a circle shape (see link below).
  4700. * @see https://easings.net/#easeInCirc
  4701. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4702. */
  4703. var CircleEase = /** @class */ (function (_super) {
  4704. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CircleEase, _super);
  4705. function CircleEase() {
  4706. return _super !== null && _super.apply(this, arguments) || this;
  4707. }
  4708. /** @hidden */
  4709. CircleEase.prototype.easeInCore = function (gradient) {
  4710. gradient = Math.max(0, Math.min(1, gradient));
  4711. return (1.0 - Math.sqrt(1.0 - (gradient * gradient)));
  4712. };
  4713. return CircleEase;
  4714. }(EasingFunction));
  4715. /**
  4716. * Easing function with a ease back shape (see link below).
  4717. * @see https://easings.net/#easeInBack
  4718. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4719. */
  4720. var BackEase = /** @class */ (function (_super) {
  4721. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackEase, _super);
  4722. /**
  4723. * Instantiates a back ease easing
  4724. * @see https://easings.net/#easeInBack
  4725. * @param amplitude Defines the amplitude of the function
  4726. */
  4727. function BackEase(
  4728. /** Defines the amplitude of the function */
  4729. amplitude) {
  4730. if (amplitude === void 0) { amplitude = 1; }
  4731. var _this = _super.call(this) || this;
  4732. _this.amplitude = amplitude;
  4733. return _this;
  4734. }
  4735. /** @hidden */
  4736. BackEase.prototype.easeInCore = function (gradient) {
  4737. var num = Math.max(0, this.amplitude);
  4738. return (Math.pow(gradient, 3.0) - ((gradient * num) * Math.sin(3.1415926535897931 * gradient)));
  4739. };
  4740. return BackEase;
  4741. }(EasingFunction));
  4742. /**
  4743. * Easing function with a bouncing shape (see link below).
  4744. * @see https://easings.net/#easeInBounce
  4745. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4746. */
  4747. var BounceEase = /** @class */ (function (_super) {
  4748. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BounceEase, _super);
  4749. /**
  4750. * Instantiates a bounce easing
  4751. * @see https://easings.net/#easeInBounce
  4752. * @param bounces Defines the number of bounces
  4753. * @param bounciness Defines the amplitude of the bounce
  4754. */
  4755. function BounceEase(
  4756. /** Defines the number of bounces */
  4757. bounces,
  4758. /** Defines the amplitude of the bounce */
  4759. bounciness) {
  4760. if (bounces === void 0) { bounces = 3; }
  4761. if (bounciness === void 0) { bounciness = 2; }
  4762. var _this = _super.call(this) || this;
  4763. _this.bounces = bounces;
  4764. _this.bounciness = bounciness;
  4765. return _this;
  4766. }
  4767. /** @hidden */
  4768. BounceEase.prototype.easeInCore = function (gradient) {
  4769. var y = Math.max(0.0, this.bounces);
  4770. var bounciness = this.bounciness;
  4771. if (bounciness <= 1.0) {
  4772. bounciness = 1.001;
  4773. }
  4774. var num9 = Math.pow(bounciness, y);
  4775. var num5 = 1.0 - bounciness;
  4776. var num4 = ((1.0 - num9) / num5) + (num9 * 0.5);
  4777. var num15 = gradient * num4;
  4778. var num65 = Math.log((-num15 * (1.0 - bounciness)) + 1.0) / Math.log(bounciness);
  4779. var num3 = Math.floor(num65);
  4780. var num13 = num3 + 1.0;
  4781. var num8 = (1.0 - Math.pow(bounciness, num3)) / (num5 * num4);
  4782. var num12 = (1.0 - Math.pow(bounciness, num13)) / (num5 * num4);
  4783. var num7 = (num8 + num12) * 0.5;
  4784. var num6 = gradient - num7;
  4785. var num2 = num7 - num8;
  4786. return (((-Math.pow(1.0 / bounciness, y - num3) / (num2 * num2)) * (num6 - num2)) * (num6 + num2));
  4787. };
  4788. return BounceEase;
  4789. }(EasingFunction));
  4790. /**
  4791. * Easing function with a power of 3 shape (see link below).
  4792. * @see https://easings.net/#easeInCubic
  4793. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4794. */
  4795. var CubicEase = /** @class */ (function (_super) {
  4796. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubicEase, _super);
  4797. function CubicEase() {
  4798. return _super !== null && _super.apply(this, arguments) || this;
  4799. }
  4800. /** @hidden */
  4801. CubicEase.prototype.easeInCore = function (gradient) {
  4802. return (gradient * gradient * gradient);
  4803. };
  4804. return CubicEase;
  4805. }(EasingFunction));
  4806. /**
  4807. * Easing function with an elastic shape (see link below).
  4808. * @see https://easings.net/#easeInElastic
  4809. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4810. */
  4811. var ElasticEase = /** @class */ (function (_super) {
  4812. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ElasticEase, _super);
  4813. /**
  4814. * Instantiates an elastic easing function
  4815. * @see https://easings.net/#easeInElastic
  4816. * @param oscillations Defines the number of oscillations
  4817. * @param springiness Defines the amplitude of the oscillations
  4818. */
  4819. function ElasticEase(
  4820. /** Defines the number of oscillations*/
  4821. oscillations,
  4822. /** Defines the amplitude of the oscillations*/
  4823. springiness) {
  4824. if (oscillations === void 0) { oscillations = 3; }
  4825. if (springiness === void 0) { springiness = 3; }
  4826. var _this = _super.call(this) || this;
  4827. _this.oscillations = oscillations;
  4828. _this.springiness = springiness;
  4829. return _this;
  4830. }
  4831. /** @hidden */
  4832. ElasticEase.prototype.easeInCore = function (gradient) {
  4833. var num2;
  4834. var num3 = Math.max(0.0, this.oscillations);
  4835. var num = Math.max(0.0, this.springiness);
  4836. if (num == 0) {
  4837. num2 = gradient;
  4838. }
  4839. else {
  4840. num2 = (Math.exp(num * gradient) - 1.0) / (Math.exp(num) - 1.0);
  4841. }
  4842. return (num2 * Math.sin(((6.2831853071795862 * num3) + 1.5707963267948966) * gradient));
  4843. };
  4844. return ElasticEase;
  4845. }(EasingFunction));
  4846. /**
  4847. * Easing function with an exponential shape (see link below).
  4848. * @see https://easings.net/#easeInExpo
  4849. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4850. */
  4851. var ExponentialEase = /** @class */ (function (_super) {
  4852. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExponentialEase, _super);
  4853. /**
  4854. * Instantiates an exponential easing function
  4855. * @see https://easings.net/#easeInExpo
  4856. * @param exponent Defines the exponent of the function
  4857. */
  4858. function ExponentialEase(
  4859. /** Defines the exponent of the function */
  4860. exponent) {
  4861. if (exponent === void 0) { exponent = 2; }
  4862. var _this = _super.call(this) || this;
  4863. _this.exponent = exponent;
  4864. return _this;
  4865. }
  4866. /** @hidden */
  4867. ExponentialEase.prototype.easeInCore = function (gradient) {
  4868. if (this.exponent <= 0) {
  4869. return gradient;
  4870. }
  4871. return ((Math.exp(this.exponent * gradient) - 1.0) / (Math.exp(this.exponent) - 1.0));
  4872. };
  4873. return ExponentialEase;
  4874. }(EasingFunction));
  4875. /**
  4876. * Easing function with a power shape (see link below).
  4877. * @see https://easings.net/#easeInQuad
  4878. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4879. */
  4880. var PowerEase = /** @class */ (function (_super) {
  4881. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PowerEase, _super);
  4882. /**
  4883. * Instantiates an power base easing function
  4884. * @see https://easings.net/#easeInQuad
  4885. * @param power Defines the power of the function
  4886. */
  4887. function PowerEase(
  4888. /** Defines the power of the function */
  4889. power) {
  4890. if (power === void 0) { power = 2; }
  4891. var _this = _super.call(this) || this;
  4892. _this.power = power;
  4893. return _this;
  4894. }
  4895. /** @hidden */
  4896. PowerEase.prototype.easeInCore = function (gradient) {
  4897. var y = Math.max(0.0, this.power);
  4898. return Math.pow(gradient, y);
  4899. };
  4900. return PowerEase;
  4901. }(EasingFunction));
  4902. /**
  4903. * Easing function with a power of 2 shape (see link below).
  4904. * @see https://easings.net/#easeInQuad
  4905. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4906. */
  4907. var QuadraticEase = /** @class */ (function (_super) {
  4908. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuadraticEase, _super);
  4909. function QuadraticEase() {
  4910. return _super !== null && _super.apply(this, arguments) || this;
  4911. }
  4912. /** @hidden */
  4913. QuadraticEase.prototype.easeInCore = function (gradient) {
  4914. return (gradient * gradient);
  4915. };
  4916. return QuadraticEase;
  4917. }(EasingFunction));
  4918. /**
  4919. * Easing function with a power of 4 shape (see link below).
  4920. * @see https://easings.net/#easeInQuart
  4921. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4922. */
  4923. var QuarticEase = /** @class */ (function (_super) {
  4924. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuarticEase, _super);
  4925. function QuarticEase() {
  4926. return _super !== null && _super.apply(this, arguments) || this;
  4927. }
  4928. /** @hidden */
  4929. QuarticEase.prototype.easeInCore = function (gradient) {
  4930. return (gradient * gradient * gradient * gradient);
  4931. };
  4932. return QuarticEase;
  4933. }(EasingFunction));
  4934. /**
  4935. * Easing function with a power of 5 shape (see link below).
  4936. * @see https://easings.net/#easeInQuint
  4937. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4938. */
  4939. var QuinticEase = /** @class */ (function (_super) {
  4940. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuinticEase, _super);
  4941. function QuinticEase() {
  4942. return _super !== null && _super.apply(this, arguments) || this;
  4943. }
  4944. /** @hidden */
  4945. QuinticEase.prototype.easeInCore = function (gradient) {
  4946. return (gradient * gradient * gradient * gradient * gradient);
  4947. };
  4948. return QuinticEase;
  4949. }(EasingFunction));
  4950. /**
  4951. * Easing function with a sin shape (see link below).
  4952. * @see https://easings.net/#easeInSine
  4953. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4954. */
  4955. var SineEase = /** @class */ (function (_super) {
  4956. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SineEase, _super);
  4957. function SineEase() {
  4958. return _super !== null && _super.apply(this, arguments) || this;
  4959. }
  4960. /** @hidden */
  4961. SineEase.prototype.easeInCore = function (gradient) {
  4962. return (1.0 - Math.sin(1.5707963267948966 * (1.0 - gradient)));
  4963. };
  4964. return SineEase;
  4965. }(EasingFunction));
  4966. /**
  4967. * Easing function with a bezier shape (see link below).
  4968. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4969. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4970. */
  4971. var BezierCurveEase = /** @class */ (function (_super) {
  4972. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BezierCurveEase, _super);
  4973. /**
  4974. * Instantiates a bezier function
  4975. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4976. * @param x1 Defines the x component of the start tangent in the bezier curve
  4977. * @param y1 Defines the y component of the start tangent in the bezier curve
  4978. * @param x2 Defines the x component of the end tangent in the bezier curve
  4979. * @param y2 Defines the y component of the end tangent in the bezier curve
  4980. */
  4981. function BezierCurveEase(
  4982. /** Defines the x component of the start tangent in the bezier curve */
  4983. x1,
  4984. /** Defines the y component of the start tangent in the bezier curve */
  4985. y1,
  4986. /** Defines the x component of the end tangent in the bezier curve */
  4987. x2,
  4988. /** Defines the y component of the end tangent in the bezier curve */
  4989. y2) {
  4990. if (x1 === void 0) { x1 = 0; }
  4991. if (y1 === void 0) { y1 = 0; }
  4992. if (x2 === void 0) { x2 = 1; }
  4993. if (y2 === void 0) { y2 = 1; }
  4994. var _this = _super.call(this) || this;
  4995. _this.x1 = x1;
  4996. _this.y1 = y1;
  4997. _this.x2 = x2;
  4998. _this.y2 = y2;
  4999. return _this;
  5000. }
  5001. /** @hidden */
  5002. BezierCurveEase.prototype.easeInCore = function (gradient) {
  5003. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["BezierCurve"].Interpolate(gradient, this.x1, this.y1, this.x2, this.y2);
  5004. };
  5005. return BezierCurveEase;
  5006. }(EasingFunction));
  5007. /***/ }),
  5008. /***/ "./Animations/index.ts":
  5009. /*!*****************************!*\
  5010. !*** ./Animations/index.ts ***!
  5011. \*****************************/
  5012. /*! exports provided: Animatable, Animation, TargetedAnimation, AnimationGroup, AnimationPropertiesOverride, EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase, RuntimeAnimation, AnimationEvent, AnimationKeyInterpolation, AnimationRange */
  5013. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5014. "use strict";
  5015. __webpack_require__.r(__webpack_exports__);
  5016. /* harmony import */ var _animatable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animatable */ "./Animations/animatable.ts");
  5017. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _animatable__WEBPACK_IMPORTED_MODULE_0__["Animatable"]; });
  5018. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  5019. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"]; });
  5020. /* harmony import */ var _animationGroup__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./animationGroup */ "./Animations/animationGroup.ts");
  5021. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _animationGroup__WEBPACK_IMPORTED_MODULE_2__["TargetedAnimation"]; });
  5022. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _animationGroup__WEBPACK_IMPORTED_MODULE_2__["AnimationGroup"]; });
  5023. /* harmony import */ var _animationPropertiesOverride__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./animationPropertiesOverride */ "./Animations/animationPropertiesOverride.ts");
  5024. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _animationPropertiesOverride__WEBPACK_IMPORTED_MODULE_3__["AnimationPropertiesOverride"]; });
  5025. /* harmony import */ var _easing__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./easing */ "./Animations/easing.ts");
  5026. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["EasingFunction"]; });
  5027. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["CircleEase"]; });
  5028. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BackEase"]; });
  5029. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BounceEase"]; });
  5030. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["CubicEase"]; });
  5031. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["ElasticEase"]; });
  5032. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["ExponentialEase"]; });
  5033. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["PowerEase"]; });
  5034. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuadraticEase"]; });
  5035. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuarticEase"]; });
  5036. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuinticEase"]; });
  5037. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["SineEase"]; });
  5038. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BezierCurveEase"]; });
  5039. /* harmony import */ var _runtimeAnimation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./runtimeAnimation */ "./Animations/runtimeAnimation.ts");
  5040. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _runtimeAnimation__WEBPACK_IMPORTED_MODULE_5__["RuntimeAnimation"]; });
  5041. /* harmony import */ var _animationEvent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./animationEvent */ "./Animations/animationEvent.ts");
  5042. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _animationEvent__WEBPACK_IMPORTED_MODULE_6__["AnimationEvent"]; });
  5043. /* empty/unused harmony star reexport *//* harmony import */ var _animationKey__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./animationKey */ "./Animations/animationKey.ts");
  5044. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _animationKey__WEBPACK_IMPORTED_MODULE_7__["AnimationKeyInterpolation"]; });
  5045. /* harmony import */ var _animationRange__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./animationRange */ "./Animations/animationRange.ts");
  5046. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _animationRange__WEBPACK_IMPORTED_MODULE_8__["AnimationRange"]; });
  5047. /***/ }),
  5048. /***/ "./Animations/runtimeAnimation.ts":
  5049. /*!****************************************!*\
  5050. !*** ./Animations/runtimeAnimation.ts ***!
  5051. \****************************************/
  5052. /*! exports provided: RuntimeAnimation */
  5053. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5054. "use strict";
  5055. __webpack_require__.r(__webpack_exports__);
  5056. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return RuntimeAnimation; });
  5057. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  5058. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  5059. // Static values to help the garbage collector
  5060. // Quaternion
  5061. var _staticOffsetValueQuaternion = Object.freeze(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"](0, 0, 0, 0));
  5062. // Vector3
  5063. var _staticOffsetValueVector3 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero());
  5064. // Vector2
  5065. var _staticOffsetValueVector2 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero());
  5066. // Size
  5067. var _staticOffsetValueSize = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"].Zero());
  5068. // Color3
  5069. var _staticOffsetValueColor3 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Black());
  5070. /**
  5071. * Defines a runtime animation
  5072. */
  5073. var RuntimeAnimation = /** @class */ (function () {
  5074. /**
  5075. * Create a new RuntimeAnimation object
  5076. * @param target defines the target of the animation
  5077. * @param animation defines the source animation object
  5078. * @param scene defines the hosting scene
  5079. * @param host defines the initiating Animatable
  5080. */
  5081. function RuntimeAnimation(target, animation, scene, host) {
  5082. var _this = this;
  5083. this._events = new Array();
  5084. /**
  5085. * The current frame of the runtime animation
  5086. */
  5087. this._currentFrame = 0;
  5088. /**
  5089. * The original value of the runtime animation
  5090. */
  5091. this._originalValue = new Array();
  5092. /**
  5093. * The offsets cache of the runtime animation
  5094. */
  5095. this._offsetsCache = {};
  5096. /**
  5097. * The high limits cache of the runtime animation
  5098. */
  5099. this._highLimitsCache = {};
  5100. /**
  5101. * Specifies if the runtime animation has been stopped
  5102. */
  5103. this._stopped = false;
  5104. /**
  5105. * The blending factor of the runtime animation
  5106. */
  5107. this._blendingFactor = 0;
  5108. /**
  5109. * The target path of the runtime animation
  5110. */
  5111. this._targetPath = "";
  5112. /**
  5113. * The weight of the runtime animation
  5114. */
  5115. this._weight = 1.0;
  5116. /**
  5117. * The ratio offset of the runtime animation
  5118. */
  5119. this._ratioOffset = 0;
  5120. /**
  5121. * The previous delay of the runtime animation
  5122. */
  5123. this._previousDelay = 0;
  5124. /**
  5125. * The previous ratio of the runtime animation
  5126. */
  5127. this._previousRatio = 0;
  5128. this._animation = animation;
  5129. this._target = target;
  5130. this._scene = scene;
  5131. this._host = host;
  5132. animation._runtimeAnimations.push(this);
  5133. // Cloning events locally
  5134. var events = animation.getEvents();
  5135. if (events && events.length > 0) {
  5136. events.forEach(function (e) {
  5137. _this._events.push(e._clone());
  5138. });
  5139. }
  5140. }
  5141. Object.defineProperty(RuntimeAnimation.prototype, "currentFrame", {
  5142. /**
  5143. * Gets the current frame of the runtime animation
  5144. */
  5145. get: function () {
  5146. return this._currentFrame;
  5147. },
  5148. enumerable: true,
  5149. configurable: true
  5150. });
  5151. Object.defineProperty(RuntimeAnimation.prototype, "weight", {
  5152. /**
  5153. * Gets the weight of the runtime animation
  5154. */
  5155. get: function () {
  5156. return this._weight;
  5157. },
  5158. enumerable: true,
  5159. configurable: true
  5160. });
  5161. Object.defineProperty(RuntimeAnimation.prototype, "currentValue", {
  5162. /**
  5163. * Gets the current value of the runtime animation
  5164. */
  5165. get: function () {
  5166. return this._currentValue;
  5167. },
  5168. enumerable: true,
  5169. configurable: true
  5170. });
  5171. Object.defineProperty(RuntimeAnimation.prototype, "targetPath", {
  5172. /**
  5173. * Gets the target path of the runtime animation
  5174. */
  5175. get: function () {
  5176. return this._targetPath;
  5177. },
  5178. enumerable: true,
  5179. configurable: true
  5180. });
  5181. Object.defineProperty(RuntimeAnimation.prototype, "target", {
  5182. /**
  5183. * Gets the actual target of the runtime animation
  5184. */
  5185. get: function () {
  5186. return this._activeTarget;
  5187. },
  5188. enumerable: true,
  5189. configurable: true
  5190. });
  5191. Object.defineProperty(RuntimeAnimation.prototype, "animation", {
  5192. /**
  5193. * Gets the animation from the runtime animation
  5194. */
  5195. get: function () {
  5196. return this._animation;
  5197. },
  5198. enumerable: true,
  5199. configurable: true
  5200. });
  5201. /**
  5202. * Resets the runtime animation to the beginning
  5203. * @param restoreOriginal defines whether to restore the target property to the original value
  5204. */
  5205. RuntimeAnimation.prototype.reset = function (restoreOriginal) {
  5206. if (restoreOriginal === void 0) { restoreOriginal = false; }
  5207. if (restoreOriginal) {
  5208. if (this._target instanceof Array) {
  5209. var index = 0;
  5210. for (var _i = 0, _a = this._target; _i < _a.length; _i++) {
  5211. var target = _a[_i];
  5212. if (this._originalValue[index] !== undefined) {
  5213. this._setValue(target, this._originalValue[index], -1);
  5214. }
  5215. index++;
  5216. }
  5217. }
  5218. else {
  5219. if (this._originalValue[0] !== undefined) {
  5220. this._setValue(this._target, this._originalValue[0], -1);
  5221. }
  5222. }
  5223. }
  5224. this._offsetsCache = {};
  5225. this._highLimitsCache = {};
  5226. this._currentFrame = 0;
  5227. this._blendingFactor = 0;
  5228. this._originalValue = new Array();
  5229. // Events
  5230. for (var index = 0; index < this._events.length; index++) {
  5231. this._events[index].isDone = false;
  5232. }
  5233. };
  5234. /**
  5235. * Specifies if the runtime animation is stopped
  5236. * @returns Boolean specifying if the runtime animation is stopped
  5237. */
  5238. RuntimeAnimation.prototype.isStopped = function () {
  5239. return this._stopped;
  5240. };
  5241. /**
  5242. * Disposes of the runtime animation
  5243. */
  5244. RuntimeAnimation.prototype.dispose = function () {
  5245. var index = this._animation.runtimeAnimations.indexOf(this);
  5246. if (index > -1) {
  5247. this._animation.runtimeAnimations.splice(index, 1);
  5248. }
  5249. };
  5250. /**
  5251. * Interpolates the animation from the current frame
  5252. * @param currentFrame The frame to interpolate the animation to
  5253. * @param repeatCount The number of times that the animation should loop
  5254. * @param loopMode The type of looping mode to use
  5255. * @param offsetValue Animation offset value
  5256. * @param highLimitValue The high limit value
  5257. * @returns The interpolated value
  5258. */
  5259. RuntimeAnimation.prototype._interpolate = function (currentFrame, repeatCount, loopMode, offsetValue, highLimitValue) {
  5260. this._currentFrame = currentFrame;
  5261. if (this._animation.dataType === _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_MATRIX && !this._workValue) {
  5262. this._workValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Zero();
  5263. }
  5264. return this._animation._interpolate(currentFrame, repeatCount, this._workValue, loopMode, offsetValue, highLimitValue);
  5265. };
  5266. /**
  5267. * Apply the interpolated value to the target
  5268. * @param currentValue defines the value computed by the animation
  5269. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  5270. */
  5271. RuntimeAnimation.prototype.setValue = function (currentValue, weight) {
  5272. if (weight === void 0) { weight = 1.0; }
  5273. if (this._target instanceof Array) {
  5274. var index = 0;
  5275. for (var _i = 0, _a = this._target; _i < _a.length; _i++) {
  5276. var target = _a[_i];
  5277. this._setValue(target, currentValue, weight, index);
  5278. index++;
  5279. }
  5280. }
  5281. else {
  5282. this._setValue(this._target, currentValue, weight);
  5283. }
  5284. };
  5285. RuntimeAnimation.prototype._setValue = function (target, currentValue, weight, targetIndex) {
  5286. if (targetIndex === void 0) { targetIndex = 0; }
  5287. // Set value
  5288. var path;
  5289. var destination;
  5290. var targetPropertyPath = this._animation.targetPropertyPath;
  5291. if (targetPropertyPath.length > 1) {
  5292. var property = target[targetPropertyPath[0]];
  5293. for (var index = 1; index < targetPropertyPath.length - 1; index++) {
  5294. property = property[targetPropertyPath[index]];
  5295. }
  5296. path = targetPropertyPath[targetPropertyPath.length - 1];
  5297. destination = property;
  5298. }
  5299. else {
  5300. path = targetPropertyPath[0];
  5301. destination = target;
  5302. }
  5303. this._targetPath = path;
  5304. this._activeTarget = destination;
  5305. this._weight = weight;
  5306. if (this._originalValue[targetIndex] === undefined) {
  5307. var originalValue = void 0;
  5308. if (destination.getRestPose && path === "_matrix") { // For bones
  5309. originalValue = destination.getRestPose();
  5310. }
  5311. else {
  5312. originalValue = destination[path];
  5313. }
  5314. if (originalValue && originalValue.clone) {
  5315. this._originalValue[targetIndex] = originalValue.clone();
  5316. }
  5317. else {
  5318. this._originalValue[targetIndex] = originalValue;
  5319. }
  5320. }
  5321. // Blending
  5322. var enableBlending = target && target.animationPropertiesOverride ? target.animationPropertiesOverride.enableBlending : this._animation.enableBlending;
  5323. if (enableBlending && this._blendingFactor <= 1.0) {
  5324. if (!this._originalBlendValue) {
  5325. var originalValue = destination[path];
  5326. if (originalValue.clone) {
  5327. this._originalBlendValue = originalValue.clone();
  5328. }
  5329. else {
  5330. this._originalBlendValue = originalValue;
  5331. }
  5332. }
  5333. if (this._originalBlendValue.m) { // Matrix
  5334. if (_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].AllowMatrixDecomposeForInterpolation) {
  5335. if (this._currentValue) {
  5336. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerpToRef(this._originalBlendValue, currentValue, this._blendingFactor, this._currentValue);
  5337. }
  5338. else {
  5339. this._currentValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5340. }
  5341. }
  5342. else {
  5343. if (this._currentValue) {
  5344. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LerpToRef(this._originalBlendValue, currentValue, this._blendingFactor, this._currentValue);
  5345. }
  5346. else {
  5347. this._currentValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Lerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5348. }
  5349. }
  5350. }
  5351. else {
  5352. this._currentValue = _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"]._UniversalLerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5353. }
  5354. var blendingSpeed = target && target.animationPropertiesOverride ? target.animationPropertiesOverride.blendingSpeed : this._animation.blendingSpeed;
  5355. this._blendingFactor += blendingSpeed;
  5356. }
  5357. else {
  5358. this._currentValue = currentValue;
  5359. }
  5360. if (weight !== -1.0) {
  5361. this._scene._registerTargetForLateAnimationBinding(this, this._originalValue[targetIndex]);
  5362. }
  5363. else {
  5364. destination[path] = this._currentValue;
  5365. }
  5366. if (target.markAsDirty) {
  5367. target.markAsDirty(this._animation.targetProperty);
  5368. }
  5369. };
  5370. /**
  5371. * Gets the loop pmode of the runtime animation
  5372. * @returns Loop Mode
  5373. */
  5374. RuntimeAnimation.prototype._getCorrectLoopMode = function () {
  5375. if (this._target && this._target.animationPropertiesOverride) {
  5376. return this._target.animationPropertiesOverride.loopMode;
  5377. }
  5378. return this._animation.loopMode;
  5379. };
  5380. /**
  5381. * Move the current animation to a given frame
  5382. * @param frame defines the frame to move to
  5383. */
  5384. RuntimeAnimation.prototype.goToFrame = function (frame) {
  5385. var keys = this._animation.getKeys();
  5386. if (frame < keys[0].frame) {
  5387. frame = keys[0].frame;
  5388. }
  5389. else if (frame > keys[keys.length - 1].frame) {
  5390. frame = keys[keys.length - 1].frame;
  5391. }
  5392. var currentValue = this._interpolate(frame, 0, this._getCorrectLoopMode());
  5393. this.setValue(currentValue, -1);
  5394. };
  5395. /**
  5396. * @hidden Internal use only
  5397. */
  5398. RuntimeAnimation.prototype._prepareForSpeedRatioChange = function (newSpeedRatio) {
  5399. var newRatio = this._previousDelay * (this._animation.framePerSecond * newSpeedRatio) / 1000.0;
  5400. this._ratioOffset = this._previousRatio - newRatio;
  5401. };
  5402. /**
  5403. * Execute the current animation
  5404. * @param delay defines the delay to add to the current frame
  5405. * @param from defines the lower bound of the animation range
  5406. * @param to defines the upper bound of the animation range
  5407. * @param loop defines if the current animation must loop
  5408. * @param speedRatio defines the current speed ratio
  5409. * @param weight defines the weight of the animation (default is -1 so no weight)
  5410. * @param onLoop optional callback called when animation loops
  5411. * @returns a boolean indicating if the animation is running
  5412. */
  5413. RuntimeAnimation.prototype.animate = function (delay, from, to, loop, speedRatio, weight, onLoop) {
  5414. if (weight === void 0) { weight = -1.0; }
  5415. var targetPropertyPath = this._animation.targetPropertyPath;
  5416. if (!targetPropertyPath || targetPropertyPath.length < 1) {
  5417. this._stopped = true;
  5418. return false;
  5419. }
  5420. var returnValue = true;
  5421. var keys = this._animation.getKeys();
  5422. var min = keys[0].frame;
  5423. var max = keys[keys.length - 1].frame;
  5424. // Add a start key at frame 0 if missing
  5425. if (min !== 0) {
  5426. var newKey = { frame: 0, value: keys[0].value };
  5427. keys.splice(0, 0, newKey);
  5428. }
  5429. // Check limits
  5430. if (from < min || from > max) {
  5431. from = min;
  5432. }
  5433. if (to < min || to > max) {
  5434. to = max;
  5435. }
  5436. var range = to - from;
  5437. var offsetValue;
  5438. // Compute ratio which represents the frame delta between from and to
  5439. var ratio = (delay * (this._animation.framePerSecond * speedRatio) / 1000.0) + this._ratioOffset;
  5440. var highLimitValue = 0;
  5441. this._previousDelay = delay;
  5442. this._previousRatio = ratio;
  5443. if (((to > from && ratio >= range) || (from > to && ratio <= range)) && !loop) { // If we are out of range and not looping get back to caller
  5444. returnValue = false;
  5445. highLimitValue = this._animation._getKeyValue(keys[keys.length - 1].value);
  5446. }
  5447. else {
  5448. // Get max value if required
  5449. if (this._getCorrectLoopMode() !== _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE) {
  5450. var keyOffset = to.toString() + from.toString();
  5451. if (!this._offsetsCache[keyOffset]) {
  5452. var fromValue = this._interpolate(from, 0, _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE);
  5453. var toValue = this._interpolate(to, 0, _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE);
  5454. switch (this._animation.dataType) {
  5455. // Float
  5456. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT:
  5457. this._offsetsCache[keyOffset] = toValue - fromValue;
  5458. break;
  5459. // Quaternion
  5460. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_QUATERNION:
  5461. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5462. break;
  5463. // Vector3
  5464. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR3:
  5465. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5466. // Vector2
  5467. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR2:
  5468. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5469. // Size
  5470. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_SIZE:
  5471. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5472. // Color3
  5473. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_COLOR3:
  5474. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5475. default:
  5476. break;
  5477. }
  5478. this._highLimitsCache[keyOffset] = toValue;
  5479. }
  5480. highLimitValue = this._highLimitsCache[keyOffset];
  5481. offsetValue = this._offsetsCache[keyOffset];
  5482. }
  5483. }
  5484. if (offsetValue === undefined) {
  5485. switch (this._animation.dataType) {
  5486. // Float
  5487. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT:
  5488. offsetValue = 0;
  5489. break;
  5490. // Quaternion
  5491. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_QUATERNION:
  5492. offsetValue = _staticOffsetValueQuaternion;
  5493. break;
  5494. // Vector3
  5495. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR3:
  5496. offsetValue = _staticOffsetValueVector3;
  5497. break;
  5498. // Vector2
  5499. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR2:
  5500. offsetValue = _staticOffsetValueVector2;
  5501. break;
  5502. // Size
  5503. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_SIZE:
  5504. offsetValue = _staticOffsetValueSize;
  5505. break;
  5506. // Color3
  5507. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_COLOR3:
  5508. offsetValue = _staticOffsetValueColor3;
  5509. }
  5510. }
  5511. // Compute value
  5512. var currentFrame = (returnValue && range !== 0) ? from + ratio % range : to;
  5513. // Need to normalize?
  5514. if (this._host && this._host.syncRoot) {
  5515. var syncRoot = this._host.syncRoot;
  5516. var hostNormalizedFrame = (syncRoot.masterFrame - syncRoot.fromFrame) / (syncRoot.toFrame - syncRoot.fromFrame);
  5517. currentFrame = from + (to - from) * hostNormalizedFrame;
  5518. }
  5519. // Reset events if looping
  5520. var events = this._events;
  5521. if (range > 0 && this.currentFrame > currentFrame ||
  5522. range < 0 && this.currentFrame < currentFrame) {
  5523. if (onLoop) {
  5524. onLoop();
  5525. }
  5526. // Need to reset animation events
  5527. for (var index = 0; index < events.length; index++) {
  5528. if (!events[index].onlyOnce) {
  5529. // reset event, the animation is looping
  5530. events[index].isDone = false;
  5531. }
  5532. }
  5533. }
  5534. var repeatCount = range === 0 ? 0 : (ratio / range) >> 0;
  5535. var currentValue = this._interpolate(currentFrame, repeatCount, this._getCorrectLoopMode(), offsetValue, highLimitValue);
  5536. // Set value
  5537. this.setValue(currentValue, weight);
  5538. // Check events
  5539. for (var index = 0; index < events.length; index++) {
  5540. // Make sure current frame has passed event frame and that event frame is within the current range
  5541. // Also, handle both forward and reverse animations
  5542. if ((range > 0 && currentFrame >= events[index].frame && events[index].frame >= from) ||
  5543. (range < 0 && currentFrame <= events[index].frame && events[index].frame <= from)) {
  5544. var event = events[index];
  5545. if (!event.isDone) {
  5546. // If event should be done only once, remove it.
  5547. if (event.onlyOnce) {
  5548. events.splice(index, 1);
  5549. index--;
  5550. }
  5551. event.isDone = true;
  5552. event.action(currentFrame);
  5553. } // Don't do anything if the event has already be done.
  5554. }
  5555. }
  5556. if (!returnValue) {
  5557. this._stopped = true;
  5558. }
  5559. return returnValue;
  5560. };
  5561. return RuntimeAnimation;
  5562. }());
  5563. /***/ }),
  5564. /***/ "./Audio/analyser.ts":
  5565. /*!***************************!*\
  5566. !*** ./Audio/analyser.ts ***!
  5567. \***************************/
  5568. /*! exports provided: Analyser */
  5569. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5570. "use strict";
  5571. __webpack_require__.r(__webpack_exports__);
  5572. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return Analyser; });
  5573. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  5574. /**
  5575. * Class used to work with sound analyzer using fast fourier transform (FFT)
  5576. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5577. */
  5578. var Analyser = /** @class */ (function () {
  5579. /**
  5580. * Creates a new analyser
  5581. * @param scene defines hosting scene
  5582. */
  5583. function Analyser(scene) {
  5584. /**
  5585. * Gets or sets the smoothing
  5586. * @ignorenaming
  5587. */
  5588. this.SMOOTHING = 0.75;
  5589. /**
  5590. * Gets or sets the FFT table size
  5591. * @ignorenaming
  5592. */
  5593. this.FFT_SIZE = 512;
  5594. /**
  5595. * Gets or sets the bar graph amplitude
  5596. * @ignorenaming
  5597. */
  5598. this.BARGRAPHAMPLITUDE = 256;
  5599. /**
  5600. * Gets or sets the position of the debug canvas
  5601. * @ignorenaming
  5602. */
  5603. this.DEBUGCANVASPOS = { x: 20, y: 20 };
  5604. /**
  5605. * Gets or sets the debug canvas size
  5606. * @ignorenaming
  5607. */
  5608. this.DEBUGCANVASSIZE = { width: 320, height: 200 };
  5609. this._scene = scene;
  5610. this._audioEngine = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine;
  5611. if (this._audioEngine.canUseWebAudio && this._audioEngine.audioContext) {
  5612. this._webAudioAnalyser = this._audioEngine.audioContext.createAnalyser();
  5613. this._webAudioAnalyser.minDecibels = -140;
  5614. this._webAudioAnalyser.maxDecibels = 0;
  5615. this._byteFreqs = new Uint8Array(this._webAudioAnalyser.frequencyBinCount);
  5616. this._byteTime = new Uint8Array(this._webAudioAnalyser.frequencyBinCount);
  5617. this._floatFreqs = new Float32Array(this._webAudioAnalyser.frequencyBinCount);
  5618. }
  5619. }
  5620. /**
  5621. * Get the number of data values you will have to play with for the visualization
  5622. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  5623. * @returns a number
  5624. */
  5625. Analyser.prototype.getFrequencyBinCount = function () {
  5626. if (this._audioEngine.canUseWebAudio) {
  5627. return this._webAudioAnalyser.frequencyBinCount;
  5628. }
  5629. else {
  5630. return 0;
  5631. }
  5632. };
  5633. /**
  5634. * Gets the current frequency data as a byte array
  5635. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5636. * @returns a Uint8Array
  5637. */
  5638. Analyser.prototype.getByteFrequencyData = function () {
  5639. if (this._audioEngine.canUseWebAudio) {
  5640. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5641. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5642. this._webAudioAnalyser.getByteFrequencyData(this._byteFreqs);
  5643. }
  5644. return this._byteFreqs;
  5645. };
  5646. /**
  5647. * Gets the current waveform as a byte array
  5648. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  5649. * @returns a Uint8Array
  5650. */
  5651. Analyser.prototype.getByteTimeDomainData = function () {
  5652. if (this._audioEngine.canUseWebAudio) {
  5653. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5654. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5655. this._webAudioAnalyser.getByteTimeDomainData(this._byteTime);
  5656. }
  5657. return this._byteTime;
  5658. };
  5659. /**
  5660. * Gets the current frequency data as a float array
  5661. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5662. * @returns a Float32Array
  5663. */
  5664. Analyser.prototype.getFloatFrequencyData = function () {
  5665. if (this._audioEngine.canUseWebAudio) {
  5666. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5667. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5668. this._webAudioAnalyser.getFloatFrequencyData(this._floatFreqs);
  5669. }
  5670. return this._floatFreqs;
  5671. };
  5672. /**
  5673. * Renders the debug canvas
  5674. */
  5675. Analyser.prototype.drawDebugCanvas = function () {
  5676. var _this = this;
  5677. if (this._audioEngine.canUseWebAudio) {
  5678. if (!this._debugCanvas) {
  5679. this._debugCanvas = document.createElement("canvas");
  5680. this._debugCanvas.width = this.DEBUGCANVASSIZE.width;
  5681. this._debugCanvas.height = this.DEBUGCANVASSIZE.height;
  5682. this._debugCanvas.style.position = "absolute";
  5683. this._debugCanvas.style.top = this.DEBUGCANVASPOS.y + "px";
  5684. this._debugCanvas.style.left = this.DEBUGCANVASPOS.x + "px";
  5685. this._debugCanvasContext = this._debugCanvas.getContext("2d");
  5686. document.body.appendChild(this._debugCanvas);
  5687. this._registerFunc = function () {
  5688. _this.drawDebugCanvas();
  5689. };
  5690. this._scene.registerBeforeRender(this._registerFunc);
  5691. }
  5692. if (this._registerFunc && this._debugCanvasContext) {
  5693. var workingArray = this.getByteFrequencyData();
  5694. this._debugCanvasContext.fillStyle = 'rgb(0, 0, 0)';
  5695. this._debugCanvasContext.fillRect(0, 0, this.DEBUGCANVASSIZE.width, this.DEBUGCANVASSIZE.height);
  5696. // Draw the frequency domain chart.
  5697. for (var i = 0; i < this.getFrequencyBinCount(); i++) {
  5698. var value = workingArray[i];
  5699. var percent = value / this.BARGRAPHAMPLITUDE;
  5700. var height = this.DEBUGCANVASSIZE.height * percent;
  5701. var offset = this.DEBUGCANVASSIZE.height - height - 1;
  5702. var barWidth = this.DEBUGCANVASSIZE.width / this.getFrequencyBinCount();
  5703. var hue = i / this.getFrequencyBinCount() * 360;
  5704. this._debugCanvasContext.fillStyle = 'hsl(' + hue + ', 100%, 50%)';
  5705. this._debugCanvasContext.fillRect(i * barWidth, offset, barWidth, height);
  5706. }
  5707. }
  5708. }
  5709. };
  5710. /**
  5711. * Stops rendering the debug canvas and removes it
  5712. */
  5713. Analyser.prototype.stopDebugCanvas = function () {
  5714. if (this._debugCanvas) {
  5715. if (this._registerFunc) {
  5716. this._scene.unregisterBeforeRender(this._registerFunc);
  5717. this._registerFunc = null;
  5718. }
  5719. document.body.removeChild(this._debugCanvas);
  5720. this._debugCanvas = null;
  5721. this._debugCanvasContext = null;
  5722. }
  5723. };
  5724. /**
  5725. * Connects two audio nodes
  5726. * @param inputAudioNode defines first node to connect
  5727. * @param outputAudioNode defines second node to connect
  5728. */
  5729. Analyser.prototype.connectAudioNodes = function (inputAudioNode, outputAudioNode) {
  5730. if (this._audioEngine.canUseWebAudio) {
  5731. inputAudioNode.connect(this._webAudioAnalyser);
  5732. this._webAudioAnalyser.connect(outputAudioNode);
  5733. }
  5734. };
  5735. /**
  5736. * Releases all associated resources
  5737. */
  5738. Analyser.prototype.dispose = function () {
  5739. if (this._audioEngine.canUseWebAudio) {
  5740. this._webAudioAnalyser.disconnect();
  5741. }
  5742. };
  5743. return Analyser;
  5744. }());
  5745. /***/ }),
  5746. /***/ "./Audio/audioEngine.ts":
  5747. /*!******************************!*\
  5748. !*** ./Audio/audioEngine.ts ***!
  5749. \******************************/
  5750. /*! exports provided: AudioEngine */
  5751. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5752. "use strict";
  5753. __webpack_require__.r(__webpack_exports__);
  5754. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return AudioEngine; });
  5755. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  5756. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  5757. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  5758. // Sets the default audio engine to Babylon.js
  5759. _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].AudioEngineFactory = function (hostElement) { return new AudioEngine(hostElement); };
  5760. /**
  5761. * This represents the default audio engine used in babylon.
  5762. * It is responsible to play, synchronize and analyse sounds throughout the application.
  5763. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5764. */
  5765. var AudioEngine = /** @class */ (function () {
  5766. /**
  5767. * Instantiates a new audio engine.
  5768. *
  5769. * There should be only one per page as some browsers restrict the number
  5770. * of audio contexts you can create.
  5771. * @param hostElement defines the host element where to display the mute icon if necessary
  5772. */
  5773. function AudioEngine(hostElement) {
  5774. if (hostElement === void 0) { hostElement = null; }
  5775. var _this = this;
  5776. this._audioContext = null;
  5777. this._audioContextInitialized = false;
  5778. this._muteButton = null;
  5779. /**
  5780. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5781. */
  5782. this.canUseWebAudio = false;
  5783. /**
  5784. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5785. * @ignoreNaming
  5786. */
  5787. this.WarnedWebAudioUnsupported = false;
  5788. /**
  5789. * Gets whether or not mp3 are supported by your browser.
  5790. */
  5791. this.isMP3supported = false;
  5792. /**
  5793. * Gets whether or not ogg are supported by your browser.
  5794. */
  5795. this.isOGGsupported = false;
  5796. /**
  5797. * Gets whether audio has been unlocked on the device.
  5798. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  5799. * a user interaction has happened.
  5800. */
  5801. this.unlocked = true;
  5802. /**
  5803. * Defines if the audio engine relies on a custom unlocked button.
  5804. * In this case, the embedded button will not be displayed.
  5805. */
  5806. this.useCustomUnlockedButton = false;
  5807. /**
  5808. * Event raised when audio has been unlocked on the browser.
  5809. */
  5810. this.onAudioUnlockedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  5811. /**
  5812. * Event raised when audio has been locked on the browser.
  5813. */
  5814. this.onAudioLockedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  5815. this._tryToRun = false;
  5816. this._onResize = function () {
  5817. _this._moveButtonToTopLeft();
  5818. };
  5819. if (typeof window.AudioContext !== 'undefined' || typeof window.webkitAudioContext !== 'undefined') {
  5820. window.AudioContext = window.AudioContext || window.webkitAudioContext;
  5821. this.canUseWebAudio = true;
  5822. }
  5823. var audioElem = document.createElement('audio');
  5824. this._hostElement = hostElement;
  5825. try {
  5826. if (audioElem && !!audioElem.canPlayType && audioElem.canPlayType('audio/mpeg; codecs="mp3"').replace(/^no$/, '')) {
  5827. this.isMP3supported = true;
  5828. }
  5829. }
  5830. catch (e) {
  5831. // protect error during capability check.
  5832. }
  5833. try {
  5834. if (audioElem && !!audioElem.canPlayType && audioElem.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, '')) {
  5835. this.isOGGsupported = true;
  5836. }
  5837. }
  5838. catch (e) {
  5839. // protect error during capability check.
  5840. }
  5841. }
  5842. Object.defineProperty(AudioEngine.prototype, "audioContext", {
  5843. /**
  5844. * Gets the current AudioContext if available.
  5845. */
  5846. get: function () {
  5847. if (!this._audioContextInitialized) {
  5848. this._initializeAudioContext();
  5849. }
  5850. else {
  5851. if (!this.unlocked && !this._muteButton) {
  5852. this._displayMuteButton();
  5853. }
  5854. }
  5855. return this._audioContext;
  5856. },
  5857. enumerable: true,
  5858. configurable: true
  5859. });
  5860. /**
  5861. * Flags the audio engine in Locked state.
  5862. * This happens due to new browser policies preventing audio to autoplay.
  5863. */
  5864. AudioEngine.prototype.lock = function () {
  5865. this._triggerSuspendedState();
  5866. };
  5867. /**
  5868. * Unlocks the audio engine once a user action has been done on the dom.
  5869. * This is helpful to resume play once browser policies have been satisfied.
  5870. */
  5871. AudioEngine.prototype.unlock = function () {
  5872. this._triggerRunningState();
  5873. };
  5874. AudioEngine.prototype._resumeAudioContext = function () {
  5875. var result;
  5876. if (this._audioContext.resume) {
  5877. result = this._audioContext.resume();
  5878. }
  5879. return result || Promise.resolve();
  5880. };
  5881. AudioEngine.prototype._initializeAudioContext = function () {
  5882. try {
  5883. if (this.canUseWebAudio) {
  5884. this._audioContext = new AudioContext();
  5885. // create a global volume gain node
  5886. this.masterGain = this._audioContext.createGain();
  5887. this.masterGain.gain.value = 1;
  5888. this.masterGain.connect(this._audioContext.destination);
  5889. this._audioContextInitialized = true;
  5890. if (this._audioContext.state === "running") {
  5891. // Do not wait for the promise to unlock.
  5892. this._triggerRunningState();
  5893. }
  5894. }
  5895. }
  5896. catch (e) {
  5897. this.canUseWebAudio = false;
  5898. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Web Audio: " + e.message);
  5899. }
  5900. };
  5901. AudioEngine.prototype._triggerRunningState = function () {
  5902. var _this = this;
  5903. if (this._tryToRun) {
  5904. return;
  5905. }
  5906. this._tryToRun = true;
  5907. this._resumeAudioContext()
  5908. .then(function () {
  5909. _this._tryToRun = false;
  5910. if (_this._muteButton) {
  5911. _this._hideMuteButton();
  5912. }
  5913. }).catch(function () {
  5914. _this._tryToRun = false;
  5915. _this.unlocked = false;
  5916. });
  5917. // Notify users that the audio stack is unlocked/unmuted
  5918. this.unlocked = true;
  5919. this.onAudioUnlockedObservable.notifyObservers(this);
  5920. };
  5921. AudioEngine.prototype._triggerSuspendedState = function () {
  5922. this.unlocked = false;
  5923. this.onAudioLockedObservable.notifyObservers(this);
  5924. this._displayMuteButton();
  5925. };
  5926. AudioEngine.prototype._displayMuteButton = function () {
  5927. var _this = this;
  5928. if (this.useCustomUnlockedButton || this._muteButton) {
  5929. return;
  5930. }
  5931. this._muteButton = document.createElement("BUTTON");
  5932. this._muteButton.className = "babylonUnmuteIcon";
  5933. this._muteButton.id = "babylonUnmuteIconBtn";
  5934. this._muteButton.title = "Unmute";
  5935. var css = ".babylonUnmuteIcon { position: absolute; left: 20px; top: 20px; height: 40px; width: 60px; background-color: rgba(51,51,51,0.7); background-image: url(data:image/svg+xml;charset=UTF-8,%3Csvg%20version%3D%221.1%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2239%22%20height%3D%2232%22%20viewBox%3D%220%200%2039%2032%22%3E%3Cpath%20fill%3D%22white%22%20d%3D%22M9.625%2018.938l-0.031%200.016h-4.953q-0.016%200-0.031-0.016v-12.453q0-0.016%200.031-0.016h4.953q0.031%200%200.031%200.016v12.453zM12.125%207.688l8.719-8.703v27.453l-8.719-8.719-0.016-0.047v-9.938zM23.359%207.875l1.406-1.406%204.219%204.203%204.203-4.203%201.422%201.406-4.219%204.219%204.219%204.203-1.484%201.359-4.141-4.156-4.219%204.219-1.406-1.422%204.219-4.203z%22%3E%3C%2Fpath%3E%3C%2Fsvg%3E); background-size: 80%; background-repeat:no-repeat; background-position: center; background-position-y: 4px; border: none; outline: none; transition: transform 0.125s ease-out; cursor: pointer; z-index: 9999; } .babylonUnmuteIcon:hover { transform: scale(1.05) } .babylonUnmuteIcon:active { background-color: rgba(51,51,51,1) }";
  5936. var style = document.createElement('style');
  5937. style.appendChild(document.createTextNode(css));
  5938. document.getElementsByTagName('head')[0].appendChild(style);
  5939. document.body.appendChild(this._muteButton);
  5940. this._moveButtonToTopLeft();
  5941. this._muteButton.addEventListener('touchend', function () {
  5942. _this._triggerRunningState();
  5943. }, true);
  5944. this._muteButton.addEventListener('click', function () {
  5945. _this._triggerRunningState();
  5946. }, true);
  5947. window.addEventListener("resize", this._onResize);
  5948. };
  5949. AudioEngine.prototype._moveButtonToTopLeft = function () {
  5950. if (this._hostElement && this._muteButton) {
  5951. this._muteButton.style.top = this._hostElement.offsetTop + 20 + "px";
  5952. this._muteButton.style.left = this._hostElement.offsetLeft + 20 + "px";
  5953. }
  5954. };
  5955. AudioEngine.prototype._hideMuteButton = function () {
  5956. if (this._muteButton) {
  5957. document.body.removeChild(this._muteButton);
  5958. this._muteButton = null;
  5959. }
  5960. };
  5961. /**
  5962. * Destroy and release the resources associated with the audio ccontext.
  5963. */
  5964. AudioEngine.prototype.dispose = function () {
  5965. if (this.canUseWebAudio && this._audioContextInitialized) {
  5966. if (this._connectedAnalyser && this._audioContext) {
  5967. this._connectedAnalyser.stopDebugCanvas();
  5968. this._connectedAnalyser.dispose();
  5969. this.masterGain.disconnect();
  5970. this.masterGain.connect(this._audioContext.destination);
  5971. this._connectedAnalyser = null;
  5972. }
  5973. this.masterGain.gain.value = 1;
  5974. }
  5975. this.WarnedWebAudioUnsupported = false;
  5976. this._hideMuteButton();
  5977. window.removeEventListener("resize", this._onResize);
  5978. this.onAudioUnlockedObservable.clear();
  5979. this.onAudioLockedObservable.clear();
  5980. };
  5981. /**
  5982. * Gets the global volume sets on the master gain.
  5983. * @returns the global volume if set or -1 otherwise
  5984. */
  5985. AudioEngine.prototype.getGlobalVolume = function () {
  5986. if (this.canUseWebAudio && this._audioContextInitialized) {
  5987. return this.masterGain.gain.value;
  5988. }
  5989. else {
  5990. return -1;
  5991. }
  5992. };
  5993. /**
  5994. * Sets the global volume of your experience (sets on the master gain).
  5995. * @param newVolume Defines the new global volume of the application
  5996. */
  5997. AudioEngine.prototype.setGlobalVolume = function (newVolume) {
  5998. if (this.canUseWebAudio && this._audioContextInitialized) {
  5999. this.masterGain.gain.value = newVolume;
  6000. }
  6001. };
  6002. /**
  6003. * Connect the audio engine to an audio analyser allowing some amazing
  6004. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  6005. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  6006. * @param analyser The analyser to connect to the engine
  6007. */
  6008. AudioEngine.prototype.connectToAnalyser = function (analyser) {
  6009. if (this._connectedAnalyser) {
  6010. this._connectedAnalyser.stopDebugCanvas();
  6011. }
  6012. if (this.canUseWebAudio && this._audioContextInitialized && this._audioContext) {
  6013. this._connectedAnalyser = analyser;
  6014. this.masterGain.disconnect();
  6015. this._connectedAnalyser.connectAudioNodes(this.masterGain, this._audioContext.destination);
  6016. }
  6017. };
  6018. return AudioEngine;
  6019. }());
  6020. /***/ }),
  6021. /***/ "./Audio/audioSceneComponent.ts":
  6022. /*!**************************************!*\
  6023. !*** ./Audio/audioSceneComponent.ts ***!
  6024. \**************************************/
  6025. /*! exports provided: AudioSceneComponent */
  6026. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6027. "use strict";
  6028. __webpack_require__.r(__webpack_exports__);
  6029. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return AudioSceneComponent; });
  6030. /* harmony import */ var _sound__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sound */ "./Audio/sound.ts");
  6031. /* harmony import */ var _soundTrack__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./soundTrack */ "./Audio/soundTrack.ts");
  6032. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  6033. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  6034. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  6035. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  6036. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  6037. // Adds the parser to the scene parsers.
  6038. _abstractScene__WEBPACK_IMPORTED_MODULE_6__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO, function (parsedData, scene, container, rootUrl) {
  6039. // TODO: add sound
  6040. var loadedSounds = [];
  6041. var loadedSound;
  6042. container.sounds = container.sounds || [];
  6043. if (parsedData.sounds !== undefined && parsedData.sounds !== null) {
  6044. for (var index = 0, cache = parsedData.sounds.length; index < cache; index++) {
  6045. var parsedSound = parsedData.sounds[index];
  6046. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].audioEngine.canUseWebAudio) {
  6047. if (!parsedSound.url) {
  6048. parsedSound.url = parsedSound.name;
  6049. }
  6050. if (!loadedSounds[parsedSound.url]) {
  6051. loadedSound = _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"].Parse(parsedSound, scene, rootUrl);
  6052. loadedSounds[parsedSound.url] = loadedSound;
  6053. container.sounds.push(loadedSound);
  6054. }
  6055. else {
  6056. container.sounds.push(_sound__WEBPACK_IMPORTED_MODULE_0__["Sound"].Parse(parsedSound, scene, rootUrl, loadedSounds[parsedSound.url]));
  6057. }
  6058. }
  6059. else {
  6060. container.sounds.push(new _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"](parsedSound.name, null, scene));
  6061. }
  6062. }
  6063. }
  6064. loadedSounds = [];
  6065. });
  6066. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "mainSoundTrack", {
  6067. get: function () {
  6068. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6069. if (!compo) {
  6070. compo = new AudioSceneComponent(this);
  6071. this._addComponent(compo);
  6072. }
  6073. if (!this._mainSoundTrack) {
  6074. this._mainSoundTrack = new _soundTrack__WEBPACK_IMPORTED_MODULE_1__["SoundTrack"](this, { mainTrack: true });
  6075. }
  6076. return this._mainSoundTrack;
  6077. },
  6078. enumerable: true,
  6079. configurable: true
  6080. });
  6081. _scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype.getSoundByName = function (name) {
  6082. var index;
  6083. for (index = 0; index < this.mainSoundTrack.soundCollection.length; index++) {
  6084. if (this.mainSoundTrack.soundCollection[index].name === name) {
  6085. return this.mainSoundTrack.soundCollection[index];
  6086. }
  6087. }
  6088. if (this.soundTracks) {
  6089. for (var sdIndex = 0; sdIndex < this.soundTracks.length; sdIndex++) {
  6090. for (index = 0; index < this.soundTracks[sdIndex].soundCollection.length; index++) {
  6091. if (this.soundTracks[sdIndex].soundCollection[index].name === name) {
  6092. return this.soundTracks[sdIndex].soundCollection[index];
  6093. }
  6094. }
  6095. }
  6096. }
  6097. return null;
  6098. };
  6099. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "audioEnabled", {
  6100. get: function () {
  6101. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6102. if (!compo) {
  6103. compo = new AudioSceneComponent(this);
  6104. this._addComponent(compo);
  6105. }
  6106. return compo.audioEnabled;
  6107. },
  6108. set: function (value) {
  6109. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6110. if (!compo) {
  6111. compo = new AudioSceneComponent(this);
  6112. this._addComponent(compo);
  6113. }
  6114. if (value) {
  6115. compo.enableAudio();
  6116. }
  6117. else {
  6118. compo.disableAudio();
  6119. }
  6120. },
  6121. enumerable: true,
  6122. configurable: true
  6123. });
  6124. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "headphone", {
  6125. get: function () {
  6126. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6127. if (!compo) {
  6128. compo = new AudioSceneComponent(this);
  6129. this._addComponent(compo);
  6130. }
  6131. return compo.headphone;
  6132. },
  6133. set: function (value) {
  6134. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6135. if (!compo) {
  6136. compo = new AudioSceneComponent(this);
  6137. this._addComponent(compo);
  6138. }
  6139. if (value) {
  6140. compo.switchAudioModeForHeadphones();
  6141. }
  6142. else {
  6143. compo.switchAudioModeForNormalSpeakers();
  6144. }
  6145. },
  6146. enumerable: true,
  6147. configurable: true
  6148. });
  6149. /**
  6150. * Defines the sound scene component responsible to manage any sounds
  6151. * in a given scene.
  6152. */
  6153. var AudioSceneComponent = /** @class */ (function () {
  6154. /**
  6155. * Creates a new instance of the component for the given scene
  6156. * @param scene Defines the scene to register the component in
  6157. */
  6158. function AudioSceneComponent(scene) {
  6159. /**
  6160. * The component name helpfull to identify the component in the list of scene components.
  6161. */
  6162. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO;
  6163. this._audioEnabled = true;
  6164. this._headphone = false;
  6165. this.scene = scene;
  6166. scene.soundTracks = new Array();
  6167. scene.sounds = new Array();
  6168. }
  6169. Object.defineProperty(AudioSceneComponent.prototype, "audioEnabled", {
  6170. /**
  6171. * Gets whether audio is enabled or not.
  6172. * Please use related enable/disable method to switch state.
  6173. */
  6174. get: function () {
  6175. return this._audioEnabled;
  6176. },
  6177. enumerable: true,
  6178. configurable: true
  6179. });
  6180. Object.defineProperty(AudioSceneComponent.prototype, "headphone", {
  6181. /**
  6182. * Gets whether audio is outputing to headphone or not.
  6183. * Please use the according Switch methods to change output.
  6184. */
  6185. get: function () {
  6186. return this._headphone;
  6187. },
  6188. enumerable: true,
  6189. configurable: true
  6190. });
  6191. /**
  6192. * Registers the component in a given scene
  6193. */
  6194. AudioSceneComponent.prototype.register = function () {
  6195. this.scene._afterRenderStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_AFTERRENDER_AUDIO, this, this._afterRender);
  6196. };
  6197. /**
  6198. * Rebuilds the elements related to this component in case of
  6199. * context lost for instance.
  6200. */
  6201. AudioSceneComponent.prototype.rebuild = function () {
  6202. // Nothing to do here. (Not rendering related)
  6203. };
  6204. /**
  6205. * Serializes the component data to the specified json object
  6206. * @param serializationObject The object to serialize to
  6207. */
  6208. AudioSceneComponent.prototype.serialize = function (serializationObject) {
  6209. serializationObject.sounds = [];
  6210. if (this.scene.soundTracks) {
  6211. for (var index = 0; index < this.scene.soundTracks.length; index++) {
  6212. var soundtrack = this.scene.soundTracks[index];
  6213. for (var soundId = 0; soundId < soundtrack.soundCollection.length; soundId++) {
  6214. serializationObject.sounds.push(soundtrack.soundCollection[soundId].serialize());
  6215. }
  6216. }
  6217. }
  6218. };
  6219. /**
  6220. * Adds all the element from the container to the scene
  6221. * @param container the container holding the elements
  6222. */
  6223. AudioSceneComponent.prototype.addFromContainer = function (container) {
  6224. var _this = this;
  6225. if (!container.sounds) {
  6226. return;
  6227. }
  6228. container.sounds.forEach(function (sound) {
  6229. sound.play();
  6230. sound.autoplay = true;
  6231. _this.scene.mainSoundTrack.AddSound(sound);
  6232. });
  6233. };
  6234. /**
  6235. * Removes all the elements in the container from the scene
  6236. * @param container contains the elements to remove
  6237. */
  6238. AudioSceneComponent.prototype.removeFromContainer = function (container) {
  6239. var _this = this;
  6240. if (!container.sounds) {
  6241. return;
  6242. }
  6243. container.sounds.forEach(function (sound) {
  6244. sound.stop();
  6245. sound.autoplay = false;
  6246. _this.scene.mainSoundTrack.RemoveSound(sound);
  6247. });
  6248. };
  6249. /**
  6250. * Disposes the component and the associated ressources.
  6251. */
  6252. AudioSceneComponent.prototype.dispose = function () {
  6253. var scene = this.scene;
  6254. if (scene._mainSoundTrack) {
  6255. scene.mainSoundTrack.dispose();
  6256. }
  6257. if (scene.soundTracks) {
  6258. for (var scIndex = 0; scIndex < scene.soundTracks.length; scIndex++) {
  6259. scene.soundTracks[scIndex].dispose();
  6260. }
  6261. }
  6262. };
  6263. /**
  6264. * Disables audio in the associated scene.
  6265. */
  6266. AudioSceneComponent.prototype.disableAudio = function () {
  6267. var scene = this.scene;
  6268. this._audioEnabled = false;
  6269. var i;
  6270. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6271. scene.mainSoundTrack.soundCollection[i].pause();
  6272. }
  6273. if (scene.soundTracks) {
  6274. for (i = 0; i < scene.soundTracks.length; i++) {
  6275. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6276. scene.soundTracks[i].soundCollection[j].pause();
  6277. }
  6278. }
  6279. }
  6280. };
  6281. /**
  6282. * Enables audio in the associated scene.
  6283. */
  6284. AudioSceneComponent.prototype.enableAudio = function () {
  6285. var scene = this.scene;
  6286. this._audioEnabled = true;
  6287. var i;
  6288. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6289. if (scene.mainSoundTrack.soundCollection[i].isPaused) {
  6290. scene.mainSoundTrack.soundCollection[i].play();
  6291. }
  6292. }
  6293. if (scene.soundTracks) {
  6294. for (i = 0; i < scene.soundTracks.length; i++) {
  6295. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6296. if (scene.soundTracks[i].soundCollection[j].isPaused) {
  6297. scene.soundTracks[i].soundCollection[j].play();
  6298. }
  6299. }
  6300. }
  6301. }
  6302. };
  6303. /**
  6304. * Switch audio to headphone output.
  6305. */
  6306. AudioSceneComponent.prototype.switchAudioModeForHeadphones = function () {
  6307. var scene = this.scene;
  6308. this._headphone = true;
  6309. scene.mainSoundTrack.switchPanningModelToHRTF();
  6310. if (scene.soundTracks) {
  6311. for (var i = 0; i < scene.soundTracks.length; i++) {
  6312. scene.soundTracks[i].switchPanningModelToHRTF();
  6313. }
  6314. }
  6315. };
  6316. /**
  6317. * Switch audio to normal speakers.
  6318. */
  6319. AudioSceneComponent.prototype.switchAudioModeForNormalSpeakers = function () {
  6320. var scene = this.scene;
  6321. this._headphone = false;
  6322. scene.mainSoundTrack.switchPanningModelToEqualPower();
  6323. if (scene.soundTracks) {
  6324. for (var i = 0; i < scene.soundTracks.length; i++) {
  6325. scene.soundTracks[i].switchPanningModelToEqualPower();
  6326. }
  6327. }
  6328. };
  6329. AudioSceneComponent.prototype._afterRender = function () {
  6330. var scene = this.scene;
  6331. if (!this._audioEnabled || !scene._mainSoundTrack || !scene.soundTracks || (scene._mainSoundTrack.soundCollection.length === 0 && scene.soundTracks.length === 1)) {
  6332. return;
  6333. }
  6334. var listeningCamera;
  6335. var audioEngine = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].audioEngine;
  6336. if (scene.activeCameras.length > 0) {
  6337. listeningCamera = scene.activeCameras[0];
  6338. }
  6339. else {
  6340. listeningCamera = scene.activeCamera;
  6341. }
  6342. if (listeningCamera && audioEngine.audioContext) {
  6343. audioEngine.audioContext.listener.setPosition(listeningCamera.position.x, listeningCamera.position.y, listeningCamera.position.z);
  6344. // for VR cameras
  6345. if (listeningCamera.rigCameras && listeningCamera.rigCameras.length > 0) {
  6346. listeningCamera = listeningCamera.rigCameras[0];
  6347. }
  6348. var mat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(listeningCamera.getViewMatrix());
  6349. var cameraDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1), mat);
  6350. cameraDirection.normalize();
  6351. // To avoid some errors on GearVR
  6352. if (!isNaN(cameraDirection.x) && !isNaN(cameraDirection.y) && !isNaN(cameraDirection.z)) {
  6353. audioEngine.audioContext.listener.setOrientation(cameraDirection.x, cameraDirection.y, cameraDirection.z, 0, 1, 0);
  6354. }
  6355. var i;
  6356. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6357. var sound = scene.mainSoundTrack.soundCollection[i];
  6358. if (sound.useCustomAttenuation) {
  6359. sound.updateDistanceFromListener();
  6360. }
  6361. }
  6362. if (scene.soundTracks) {
  6363. for (i = 0; i < scene.soundTracks.length; i++) {
  6364. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6365. sound = scene.soundTracks[i].soundCollection[j];
  6366. if (sound.useCustomAttenuation) {
  6367. sound.updateDistanceFromListener();
  6368. }
  6369. }
  6370. }
  6371. }
  6372. }
  6373. };
  6374. return AudioSceneComponent;
  6375. }());
  6376. _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"]._SceneComponentInitialization = function (scene) {
  6377. var compo = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6378. if (!compo) {
  6379. compo = new AudioSceneComponent(scene);
  6380. scene._addComponent(compo);
  6381. }
  6382. };
  6383. /***/ }),
  6384. /***/ "./Audio/index.ts":
  6385. /*!************************!*\
  6386. !*** ./Audio/index.ts ***!
  6387. \************************/
  6388. /*! exports provided: Analyser, AudioEngine, AudioSceneComponent, Sound, SoundTrack, WeightedSound */
  6389. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6390. "use strict";
  6391. __webpack_require__.r(__webpack_exports__);
  6392. /* harmony import */ var _analyser__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./analyser */ "./Audio/analyser.ts");
  6393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _analyser__WEBPACK_IMPORTED_MODULE_0__["Analyser"]; });
  6394. /* harmony import */ var _audioEngine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./audioEngine */ "./Audio/audioEngine.ts");
  6395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _audioEngine__WEBPACK_IMPORTED_MODULE_1__["AudioEngine"]; });
  6396. /* harmony import */ var _audioSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./audioSceneComponent */ "./Audio/audioSceneComponent.ts");
  6397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _audioSceneComponent__WEBPACK_IMPORTED_MODULE_2__["AudioSceneComponent"]; });
  6398. /* harmony import */ var _sound__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sound */ "./Audio/sound.ts");
  6399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _sound__WEBPACK_IMPORTED_MODULE_3__["Sound"]; });
  6400. /* harmony import */ var _soundTrack__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./soundTrack */ "./Audio/soundTrack.ts");
  6401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _soundTrack__WEBPACK_IMPORTED_MODULE_4__["SoundTrack"]; });
  6402. /* harmony import */ var _weightedsound__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./weightedsound */ "./Audio/weightedsound.ts");
  6403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _weightedsound__WEBPACK_IMPORTED_MODULE_5__["WeightedSound"]; });
  6404. /***/ }),
  6405. /***/ "./Audio/sound.ts":
  6406. /*!************************!*\
  6407. !*** ./Audio/sound.ts ***!
  6408. \************************/
  6409. /*! exports provided: Sound */
  6410. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6411. "use strict";
  6412. __webpack_require__.r(__webpack_exports__);
  6413. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return Sound; });
  6414. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  6415. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  6416. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  6417. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  6418. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  6419. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  6420. /**
  6421. * Defines a sound that can be played in the application.
  6422. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  6423. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  6424. */
  6425. var Sound = /** @class */ (function () {
  6426. /**
  6427. * Create a sound and attach it to a scene
  6428. * @param name Name of your sound
  6429. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  6430. * @param scene defines the scene the sound belongs to
  6431. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  6432. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  6433. */
  6434. function Sound(name, urlOrArrayBuffer, scene, readyToPlayCallback, options) {
  6435. if (readyToPlayCallback === void 0) { readyToPlayCallback = null; }
  6436. var _this = this;
  6437. /**
  6438. * Does the sound autoplay once loaded.
  6439. */
  6440. this.autoplay = false;
  6441. /**
  6442. * Does the sound loop after it finishes playing once.
  6443. */
  6444. this.loop = false;
  6445. /**
  6446. * Does the sound use a custom attenuation curve to simulate the falloff
  6447. * happening when the source gets further away from the camera.
  6448. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  6449. */
  6450. this.useCustomAttenuation = false;
  6451. /**
  6452. * Is this sound currently played.
  6453. */
  6454. this.isPlaying = false;
  6455. /**
  6456. * Is this sound currently paused.
  6457. */
  6458. this.isPaused = false;
  6459. /**
  6460. * Does this sound enables spatial sound.
  6461. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6462. */
  6463. this.spatialSound = false;
  6464. /**
  6465. * Define the reference distance the sound should be heard perfectly.
  6466. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6467. */
  6468. this.refDistance = 1;
  6469. /**
  6470. * Define the roll off factor of spatial sounds.
  6471. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6472. */
  6473. this.rolloffFactor = 1;
  6474. /**
  6475. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  6476. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6477. */
  6478. this.maxDistance = 100;
  6479. /**
  6480. * Define the distance attenuation model the sound will follow.
  6481. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6482. */
  6483. this.distanceModel = "linear";
  6484. /**
  6485. * Observable event when the current playing sound finishes.
  6486. */
  6487. this.onEndedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6488. this._panningModel = "equalpower";
  6489. this._playbackRate = 1;
  6490. this._streaming = false;
  6491. this._startTime = 0;
  6492. this._startOffset = 0;
  6493. this._position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  6494. /** @hidden */
  6495. this._positionInEmitterSpace = false;
  6496. this._localDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 0, 0);
  6497. this._volume = 1;
  6498. this._isReadyToPlay = false;
  6499. this._isDirectional = false;
  6500. // Used if you'd like to create a directional sound.
  6501. // If not set, the sound will be omnidirectional
  6502. this._coneInnerAngle = 360;
  6503. this._coneOuterAngle = 360;
  6504. this._coneOuterGain = 0;
  6505. this._isOutputConnected = false;
  6506. this._urlType = "Unknown";
  6507. this.name = name;
  6508. this._scene = scene;
  6509. Sound._SceneComponentInitialization(scene);
  6510. this._readyToPlayCallback = readyToPlayCallback;
  6511. // Default custom attenuation function is a linear attenuation
  6512. this._customAttenuationFunction = function (currentVolume, currentDistance, maxDistance, refDistance, rolloffFactor) {
  6513. if (currentDistance < maxDistance) {
  6514. return currentVolume * (1 - currentDistance / maxDistance);
  6515. }
  6516. else {
  6517. return 0;
  6518. }
  6519. };
  6520. if (options) {
  6521. this.autoplay = options.autoplay || false;
  6522. this.loop = options.loop || false;
  6523. // if volume === 0, we need another way to check this option
  6524. if (options.volume !== undefined) {
  6525. this._volume = options.volume;
  6526. }
  6527. this.spatialSound = options.spatialSound || false;
  6528. this.maxDistance = options.maxDistance || 100;
  6529. this.useCustomAttenuation = options.useCustomAttenuation || false;
  6530. this.rolloffFactor = options.rolloffFactor || 1;
  6531. this.refDistance = options.refDistance || 1;
  6532. this.distanceModel = options.distanceModel || "linear";
  6533. this._playbackRate = options.playbackRate || 1;
  6534. this._streaming = options.streaming || false;
  6535. }
  6536. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6537. this._soundGain = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createGain();
  6538. this._soundGain.gain.value = this._volume;
  6539. this._inputAudioNode = this._soundGain;
  6540. this._outputAudioNode = this._soundGain;
  6541. if (this.spatialSound) {
  6542. this._createSpatialParameters();
  6543. }
  6544. this._scene.mainSoundTrack.AddSound(this);
  6545. var validParameter = true;
  6546. // if no parameter is passed, you need to call setAudioBuffer yourself to prepare the sound
  6547. if (urlOrArrayBuffer) {
  6548. try {
  6549. if (typeof (urlOrArrayBuffer) === "string") {
  6550. this._urlType = "String";
  6551. }
  6552. else if (urlOrArrayBuffer instanceof ArrayBuffer) {
  6553. this._urlType = "ArrayBuffer";
  6554. }
  6555. else if (urlOrArrayBuffer instanceof MediaStream) {
  6556. this._urlType = "MediaStream";
  6557. }
  6558. else if (Array.isArray(urlOrArrayBuffer)) {
  6559. this._urlType = "Array";
  6560. }
  6561. var urls = [];
  6562. var codecSupportedFound = false;
  6563. switch (this._urlType) {
  6564. case "MediaStream":
  6565. this._streaming = true;
  6566. this._isReadyToPlay = true;
  6567. this._streamingSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createMediaElementSource(urlOrArrayBuffer);
  6568. if (this.autoplay) {
  6569. this.play();
  6570. }
  6571. if (this._readyToPlayCallback) {
  6572. this._readyToPlayCallback();
  6573. }
  6574. break;
  6575. case "ArrayBuffer":
  6576. if (urlOrArrayBuffer.byteLength > 0) {
  6577. codecSupportedFound = true;
  6578. this._soundLoaded(urlOrArrayBuffer);
  6579. }
  6580. break;
  6581. case "String":
  6582. urls.push(urlOrArrayBuffer);
  6583. case "Array":
  6584. if (urls.length === 0) {
  6585. urls = urlOrArrayBuffer;
  6586. }
  6587. // If we found a supported format, we load it immediately and stop the loop
  6588. for (var i = 0; i < urls.length; i++) {
  6589. var url = urls[i];
  6590. if (url.indexOf(".mp3", url.length - 4) !== -1 && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.isMP3supported) {
  6591. codecSupportedFound = true;
  6592. }
  6593. if (url.indexOf(".ogg", url.length - 4) !== -1 && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.isOGGsupported) {
  6594. codecSupportedFound = true;
  6595. }
  6596. if (url.indexOf(".wav", url.length - 4) !== -1) {
  6597. codecSupportedFound = true;
  6598. }
  6599. if (url.indexOf("blob:") !== -1) {
  6600. codecSupportedFound = true;
  6601. }
  6602. if (codecSupportedFound) {
  6603. // Loading sound using XHR2
  6604. if (!this._streaming) {
  6605. this._scene._loadFile(url, function (data) {
  6606. _this._soundLoaded(data);
  6607. }, undefined, true, true, function (exception) {
  6608. if (exception) {
  6609. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("XHR " + exception.status + " error on: " + url + ".");
  6610. }
  6611. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Sound creation aborted.");
  6612. _this._scene.mainSoundTrack.RemoveSound(_this);
  6613. });
  6614. }
  6615. // Streaming sound using HTML5 Audio tag
  6616. else {
  6617. this._htmlAudioElement = new Audio(url);
  6618. this._htmlAudioElement.controls = false;
  6619. this._htmlAudioElement.loop = this.loop;
  6620. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetCorsBehavior(url, this._htmlAudioElement);
  6621. this._htmlAudioElement.preload = "auto";
  6622. this._htmlAudioElement.addEventListener("canplaythrough", function () {
  6623. _this._isReadyToPlay = true;
  6624. if (_this.autoplay) {
  6625. _this.play();
  6626. }
  6627. if (_this._readyToPlayCallback) {
  6628. _this._readyToPlayCallback();
  6629. }
  6630. });
  6631. document.body.appendChild(this._htmlAudioElement);
  6632. this._htmlAudioElement.load();
  6633. }
  6634. break;
  6635. }
  6636. }
  6637. break;
  6638. default:
  6639. validParameter = false;
  6640. break;
  6641. }
  6642. if (!validParameter) {
  6643. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Parameter must be a URL to the sound, an Array of URLs (.mp3 & .ogg) or an ArrayBuffer of the sound.");
  6644. }
  6645. else {
  6646. if (!codecSupportedFound) {
  6647. this._isReadyToPlay = true;
  6648. // Simulating a ready to play event to avoid breaking code path
  6649. if (this._readyToPlayCallback) {
  6650. window.setTimeout(function () {
  6651. if (_this._readyToPlayCallback) {
  6652. _this._readyToPlayCallback();
  6653. }
  6654. }, 1000);
  6655. }
  6656. }
  6657. }
  6658. }
  6659. catch (ex) {
  6660. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Unexpected error. Sound creation aborted.");
  6661. this._scene.mainSoundTrack.RemoveSound(this);
  6662. }
  6663. }
  6664. }
  6665. else {
  6666. // Adding an empty sound to avoid breaking audio calls for non Web Audio browsers
  6667. this._scene.mainSoundTrack.AddSound(this);
  6668. if (!_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.WarnedWebAudioUnsupported) {
  6669. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Web Audio is not supported by your browser.");
  6670. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.WarnedWebAudioUnsupported = true;
  6671. }
  6672. // Simulating a ready to play event to avoid breaking code for non web audio browsers
  6673. if (this._readyToPlayCallback) {
  6674. window.setTimeout(function () {
  6675. if (_this._readyToPlayCallback) {
  6676. _this._readyToPlayCallback();
  6677. }
  6678. }, 1000);
  6679. }
  6680. }
  6681. }
  6682. /**
  6683. * Release the sound and its associated resources
  6684. */
  6685. Sound.prototype.dispose = function () {
  6686. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6687. if (this.isPlaying) {
  6688. this.stop();
  6689. }
  6690. this._isReadyToPlay = false;
  6691. if (this.soundTrackId === -1) {
  6692. this._scene.mainSoundTrack.RemoveSound(this);
  6693. }
  6694. else if (this._scene.soundTracks) {
  6695. this._scene.soundTracks[this.soundTrackId].RemoveSound(this);
  6696. }
  6697. if (this._soundGain) {
  6698. this._soundGain.disconnect();
  6699. this._soundGain = null;
  6700. }
  6701. if (this._soundPanner) {
  6702. this._soundPanner.disconnect();
  6703. this._soundPanner = null;
  6704. }
  6705. if (this._soundSource) {
  6706. this._soundSource.disconnect();
  6707. this._soundSource = null;
  6708. }
  6709. this._audioBuffer = null;
  6710. if (this._htmlAudioElement) {
  6711. this._htmlAudioElement.pause();
  6712. this._htmlAudioElement.src = "";
  6713. document.body.removeChild(this._htmlAudioElement);
  6714. }
  6715. if (this._streamingSource) {
  6716. this._streamingSource.disconnect();
  6717. }
  6718. if (this._connectedTransformNode && this._registerFunc) {
  6719. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  6720. this._connectedTransformNode = null;
  6721. }
  6722. }
  6723. };
  6724. /**
  6725. * Gets if the sounds is ready to be played or not.
  6726. * @returns true if ready, otherwise false
  6727. */
  6728. Sound.prototype.isReady = function () {
  6729. return this._isReadyToPlay;
  6730. };
  6731. Sound.prototype._soundLoaded = function (audioData) {
  6732. var _this = this;
  6733. if (!_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6734. return;
  6735. }
  6736. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.decodeAudioData(audioData, function (buffer) {
  6737. _this._audioBuffer = buffer;
  6738. _this._isReadyToPlay = true;
  6739. if (_this.autoplay) {
  6740. _this.play();
  6741. }
  6742. if (_this._readyToPlayCallback) {
  6743. _this._readyToPlayCallback();
  6744. }
  6745. }, function (err) { _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Error while decoding audio data for: " + _this.name + " / Error: " + err); });
  6746. };
  6747. /**
  6748. * Sets the data of the sound from an audiobuffer
  6749. * @param audioBuffer The audioBuffer containing the data
  6750. */
  6751. Sound.prototype.setAudioBuffer = function (audioBuffer) {
  6752. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6753. this._audioBuffer = audioBuffer;
  6754. this._isReadyToPlay = true;
  6755. }
  6756. };
  6757. /**
  6758. * Updates the current sounds options such as maxdistance, loop...
  6759. * @param options A JSON object containing values named as the object properties
  6760. */
  6761. Sound.prototype.updateOptions = function (options) {
  6762. if (options) {
  6763. this.loop = options.loop || this.loop;
  6764. this.maxDistance = options.maxDistance || this.maxDistance;
  6765. this.useCustomAttenuation = options.useCustomAttenuation || this.useCustomAttenuation;
  6766. this.rolloffFactor = options.rolloffFactor || this.rolloffFactor;
  6767. this.refDistance = options.refDistance || this.refDistance;
  6768. this.distanceModel = options.distanceModel || this.distanceModel;
  6769. this._playbackRate = options.playbackRate || this._playbackRate;
  6770. this._updateSpatialParameters();
  6771. if (this.isPlaying) {
  6772. if (this._streaming && this._htmlAudioElement) {
  6773. this._htmlAudioElement.playbackRate = this._playbackRate;
  6774. }
  6775. else {
  6776. if (this._soundSource) {
  6777. this._soundSource.playbackRate.value = this._playbackRate;
  6778. }
  6779. }
  6780. }
  6781. }
  6782. };
  6783. Sound.prototype._createSpatialParameters = function () {
  6784. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6785. if (this._scene.headphone) {
  6786. this._panningModel = "HRTF";
  6787. }
  6788. this._soundPanner = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createPanner();
  6789. this._updateSpatialParameters();
  6790. this._soundPanner.connect(this._outputAudioNode);
  6791. this._inputAudioNode = this._soundPanner;
  6792. }
  6793. };
  6794. Sound.prototype._updateSpatialParameters = function () {
  6795. if (this.spatialSound && this._soundPanner) {
  6796. if (this.useCustomAttenuation) {
  6797. // Tricks to disable in a way embedded Web Audio attenuation
  6798. this._soundPanner.distanceModel = "linear";
  6799. this._soundPanner.maxDistance = Number.MAX_VALUE;
  6800. this._soundPanner.refDistance = 1;
  6801. this._soundPanner.rolloffFactor = 1;
  6802. this._soundPanner.panningModel = this._panningModel;
  6803. }
  6804. else {
  6805. this._soundPanner.distanceModel = this.distanceModel;
  6806. this._soundPanner.maxDistance = this.maxDistance;
  6807. this._soundPanner.refDistance = this.refDistance;
  6808. this._soundPanner.rolloffFactor = this.rolloffFactor;
  6809. this._soundPanner.panningModel = this._panningModel;
  6810. }
  6811. }
  6812. };
  6813. /**
  6814. * Switch the panning model to HRTF:
  6815. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  6816. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6817. */
  6818. Sound.prototype.switchPanningModelToHRTF = function () {
  6819. this._panningModel = "HRTF";
  6820. this._switchPanningModel();
  6821. };
  6822. /**
  6823. * Switch the panning model to Equal Power:
  6824. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  6825. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6826. */
  6827. Sound.prototype.switchPanningModelToEqualPower = function () {
  6828. this._panningModel = "equalpower";
  6829. this._switchPanningModel();
  6830. };
  6831. Sound.prototype._switchPanningModel = function () {
  6832. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6833. this._soundPanner.panningModel = this._panningModel;
  6834. }
  6835. };
  6836. /**
  6837. * Connect this sound to a sound track audio node like gain...
  6838. * @param soundTrackAudioNode the sound track audio node to connect to
  6839. */
  6840. Sound.prototype.connectToSoundTrackAudioNode = function (soundTrackAudioNode) {
  6841. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6842. if (this._isOutputConnected) {
  6843. this._outputAudioNode.disconnect();
  6844. }
  6845. this._outputAudioNode.connect(soundTrackAudioNode);
  6846. this._isOutputConnected = true;
  6847. }
  6848. };
  6849. /**
  6850. * Transform this sound into a directional source
  6851. * @param coneInnerAngle Size of the inner cone in degree
  6852. * @param coneOuterAngle Size of the outer cone in degree
  6853. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  6854. */
  6855. Sound.prototype.setDirectionalCone = function (coneInnerAngle, coneOuterAngle, coneOuterGain) {
  6856. if (coneOuterAngle < coneInnerAngle) {
  6857. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle.");
  6858. return;
  6859. }
  6860. this._coneInnerAngle = coneInnerAngle;
  6861. this._coneOuterAngle = coneOuterAngle;
  6862. this._coneOuterGain = coneOuterGain;
  6863. this._isDirectional = true;
  6864. if (this.isPlaying && this.loop) {
  6865. this.stop();
  6866. this.play();
  6867. }
  6868. };
  6869. Object.defineProperty(Sound.prototype, "directionalConeInnerAngle", {
  6870. /**
  6871. * Gets or sets the inner angle for the directional cone.
  6872. */
  6873. get: function () {
  6874. return this._coneInnerAngle;
  6875. },
  6876. /**
  6877. * Gets or sets the inner angle for the directional cone.
  6878. */
  6879. set: function (value) {
  6880. if (value != this._coneInnerAngle) {
  6881. if (this._coneOuterAngle < value) {
  6882. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
  6883. return;
  6884. }
  6885. this._coneInnerAngle = value;
  6886. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6887. this._soundPanner.coneInnerAngle = this._coneInnerAngle;
  6888. }
  6889. }
  6890. },
  6891. enumerable: true,
  6892. configurable: true
  6893. });
  6894. Object.defineProperty(Sound.prototype, "directionalConeOuterAngle", {
  6895. /**
  6896. * Gets or sets the outer angle for the directional cone.
  6897. */
  6898. get: function () {
  6899. return this._coneOuterAngle;
  6900. },
  6901. /**
  6902. * Gets or sets the outer angle for the directional cone.
  6903. */
  6904. set: function (value) {
  6905. if (value != this._coneOuterAngle) {
  6906. if (value < this._coneInnerAngle) {
  6907. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
  6908. return;
  6909. }
  6910. this._coneOuterAngle = value;
  6911. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6912. this._soundPanner.coneOuterAngle = this._coneOuterAngle;
  6913. }
  6914. }
  6915. },
  6916. enumerable: true,
  6917. configurable: true
  6918. });
  6919. /**
  6920. * Sets the position of the emitter if spatial sound is enabled
  6921. * @param newPosition Defines the new posisiton
  6922. */
  6923. Sound.prototype.setPosition = function (newPosition) {
  6924. this._position = newPosition;
  6925. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner && !isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z)) {
  6926. this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z);
  6927. }
  6928. };
  6929. /**
  6930. * Sets the local direction of the emitter if spatial sound is enabled
  6931. * @param newLocalDirection Defines the new local direction
  6932. */
  6933. Sound.prototype.setLocalDirectionToMesh = function (newLocalDirection) {
  6934. this._localDirection = newLocalDirection;
  6935. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._connectedTransformNode && this.isPlaying) {
  6936. this._updateDirection();
  6937. }
  6938. };
  6939. Sound.prototype._updateDirection = function () {
  6940. if (!this._connectedTransformNode || !this._soundPanner) {
  6941. return;
  6942. }
  6943. var mat = this._connectedTransformNode.getWorldMatrix();
  6944. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormal(this._localDirection, mat);
  6945. direction.normalize();
  6946. this._soundPanner.setOrientation(direction.x, direction.y, direction.z);
  6947. };
  6948. /** @hidden */
  6949. Sound.prototype.updateDistanceFromListener = function () {
  6950. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._connectedTransformNode && this.useCustomAttenuation && this._soundGain && this._scene.activeCamera) {
  6951. var distance = this._connectedTransformNode.getDistanceToCamera(this._scene.activeCamera);
  6952. this._soundGain.gain.value = this._customAttenuationFunction(this._volume, distance, this.maxDistance, this.refDistance, this.rolloffFactor);
  6953. }
  6954. };
  6955. /**
  6956. * Sets a new custom attenuation function for the sound.
  6957. * @param callback Defines the function used for the attenuation
  6958. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  6959. */
  6960. Sound.prototype.setAttenuationFunction = function (callback) {
  6961. this._customAttenuationFunction = callback;
  6962. };
  6963. /**
  6964. * Play the sound
  6965. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  6966. * @param offset (optional) Start the sound setting it at a specific time
  6967. */
  6968. Sound.prototype.play = function (time, offset) {
  6969. var _this = this;
  6970. if (this._isReadyToPlay && this._scene.audioEnabled && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6971. try {
  6972. if (this._startOffset < 0) {
  6973. time = -this._startOffset;
  6974. this._startOffset = 0;
  6975. }
  6976. var startTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  6977. if (!this._soundSource || !this._streamingSource) {
  6978. if (this.spatialSound && this._soundPanner) {
  6979. if (!isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z)) {
  6980. this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z);
  6981. }
  6982. if (this._isDirectional) {
  6983. this._soundPanner.coneInnerAngle = this._coneInnerAngle;
  6984. this._soundPanner.coneOuterAngle = this._coneOuterAngle;
  6985. this._soundPanner.coneOuterGain = this._coneOuterGain;
  6986. if (this._connectedTransformNode) {
  6987. this._updateDirection();
  6988. }
  6989. else {
  6990. this._soundPanner.setOrientation(this._localDirection.x, this._localDirection.y, this._localDirection.z);
  6991. }
  6992. }
  6993. }
  6994. }
  6995. if (this._streaming) {
  6996. if (!this._streamingSource) {
  6997. this._streamingSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createMediaElementSource(this._htmlAudioElement);
  6998. this._htmlAudioElement.onended = function () { _this._onended(); };
  6999. this._htmlAudioElement.playbackRate = this._playbackRate;
  7000. }
  7001. this._streamingSource.disconnect();
  7002. this._streamingSource.connect(this._inputAudioNode);
  7003. if (this._htmlAudioElement) {
  7004. // required to manage properly the new suspended default state of Chrome
  7005. // When the option 'streaming: true' is used, we need first to wait for
  7006. // the audio engine to be unlocked by a user gesture before trying to play
  7007. // an HTML Audio elememt
  7008. var tryToPlay = function () {
  7009. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.unlocked) {
  7010. var playPromise = _this._htmlAudioElement.play();
  7011. // In browsers that don’t yet support this functionality,
  7012. // playPromise won’t be defined.
  7013. if (playPromise !== undefined) {
  7014. playPromise.catch(function (error) {
  7015. // Automatic playback failed.
  7016. // Waiting for the audio engine to be unlocked by user click on unmute
  7017. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.lock();
  7018. if (_this.loop || _this.autoplay) {
  7019. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7020. }
  7021. });
  7022. }
  7023. }
  7024. else {
  7025. if (_this.loop || _this.autoplay) {
  7026. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7027. }
  7028. }
  7029. };
  7030. tryToPlay();
  7031. }
  7032. }
  7033. else {
  7034. var tryToPlay = function () {
  7035. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7036. _this._soundSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createBufferSource();
  7037. _this._soundSource.buffer = _this._audioBuffer;
  7038. _this._soundSource.connect(_this._inputAudioNode);
  7039. _this._soundSource.loop = _this.loop;
  7040. _this._soundSource.playbackRate.value = _this._playbackRate;
  7041. _this._soundSource.onended = function () { _this._onended(); };
  7042. startTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  7043. _this._soundSource.start(startTime, _this.isPaused ? _this._startOffset % _this._soundSource.buffer.duration : offset ? offset : 0);
  7044. }
  7045. };
  7046. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.state === "suspended") {
  7047. // Wait a bit for FF as context seems late to be ready.
  7048. setTimeout(function () {
  7049. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.state === "suspended") {
  7050. // Automatic playback failed.
  7051. // Waiting for the audio engine to be unlocked by user click on unmute
  7052. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.lock();
  7053. if (_this.loop || _this.autoplay) {
  7054. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7055. }
  7056. }
  7057. else {
  7058. tryToPlay();
  7059. }
  7060. }, 500);
  7061. }
  7062. else {
  7063. tryToPlay();
  7064. }
  7065. }
  7066. this._startTime = startTime;
  7067. this.isPlaying = true;
  7068. this.isPaused = false;
  7069. }
  7070. catch (ex) {
  7071. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Error while trying to play audio: " + this.name + ", " + ex.message);
  7072. }
  7073. }
  7074. };
  7075. Sound.prototype._onended = function () {
  7076. this.isPlaying = false;
  7077. if (this.onended) {
  7078. this.onended();
  7079. }
  7080. this.onEndedObservable.notifyObservers(this);
  7081. };
  7082. /**
  7083. * Stop the sound
  7084. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  7085. */
  7086. Sound.prototype.stop = function (time) {
  7087. if (this.isPlaying) {
  7088. if (this._streaming) {
  7089. if (this._htmlAudioElement) {
  7090. this._htmlAudioElement.pause();
  7091. // Test needed for Firefox or it will generate an Invalid State Error
  7092. if (this._htmlAudioElement.currentTime > 0) {
  7093. this._htmlAudioElement.currentTime = 0;
  7094. }
  7095. }
  7096. else {
  7097. this._streamingSource.disconnect();
  7098. }
  7099. }
  7100. else if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext && this._soundSource) {
  7101. var stopTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  7102. this._soundSource.stop(stopTime);
  7103. this._soundSource.onended = function () { };
  7104. if (!this.isPaused) {
  7105. this._startOffset = 0;
  7106. }
  7107. }
  7108. this.isPlaying = false;
  7109. }
  7110. };
  7111. /**
  7112. * Put the sound in pause
  7113. */
  7114. Sound.prototype.pause = function () {
  7115. if (this.isPlaying) {
  7116. this.isPaused = true;
  7117. if (this._streaming) {
  7118. if (this._htmlAudioElement) {
  7119. this._htmlAudioElement.pause();
  7120. }
  7121. else {
  7122. this._streamingSource.disconnect();
  7123. }
  7124. }
  7125. else if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7126. this.stop(0);
  7127. this._startOffset += _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime - this._startTime;
  7128. }
  7129. }
  7130. };
  7131. /**
  7132. * Sets a dedicated volume for this sounds
  7133. * @param newVolume Define the new volume of the sound
  7134. * @param time Define in how long the sound should be at this value
  7135. */
  7136. Sound.prototype.setVolume = function (newVolume, time) {
  7137. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._soundGain) {
  7138. if (time && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7139. this._soundGain.gain.cancelScheduledValues(_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime);
  7140. this._soundGain.gain.setValueAtTime(this._soundGain.gain.value, _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime);
  7141. this._soundGain.gain.linearRampToValueAtTime(newVolume, _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time);
  7142. }
  7143. else {
  7144. this._soundGain.gain.value = newVolume;
  7145. }
  7146. }
  7147. this._volume = newVolume;
  7148. };
  7149. /**
  7150. * Set the sound play back rate
  7151. * @param newPlaybackRate Define the playback rate the sound should be played at
  7152. */
  7153. Sound.prototype.setPlaybackRate = function (newPlaybackRate) {
  7154. this._playbackRate = newPlaybackRate;
  7155. if (this.isPlaying) {
  7156. if (this._streaming && this._htmlAudioElement) {
  7157. this._htmlAudioElement.playbackRate = this._playbackRate;
  7158. }
  7159. else if (this._soundSource) {
  7160. this._soundSource.playbackRate.value = this._playbackRate;
  7161. }
  7162. }
  7163. };
  7164. /**
  7165. * Gets the volume of the sound.
  7166. * @returns the volume of the sound
  7167. */
  7168. Sound.prototype.getVolume = function () {
  7169. return this._volume;
  7170. };
  7171. /**
  7172. * Attach the sound to a dedicated mesh
  7173. * @param transformNode The transform node to connect the sound with
  7174. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  7175. */
  7176. Sound.prototype.attachToMesh = function (transformNode) {
  7177. var _this = this;
  7178. if (this._connectedTransformNode && this._registerFunc) {
  7179. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  7180. this._registerFunc = null;
  7181. }
  7182. this._connectedTransformNode = transformNode;
  7183. if (!this.spatialSound) {
  7184. this.spatialSound = true;
  7185. this._createSpatialParameters();
  7186. if (this.isPlaying && this.loop) {
  7187. this.stop();
  7188. this.play();
  7189. }
  7190. }
  7191. this._onRegisterAfterWorldMatrixUpdate(this._connectedTransformNode);
  7192. this._registerFunc = function (transformNode) { return _this._onRegisterAfterWorldMatrixUpdate(transformNode); };
  7193. this._connectedTransformNode.registerAfterWorldMatrixUpdate(this._registerFunc);
  7194. };
  7195. /**
  7196. * Detach the sound from the previously attached mesh
  7197. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  7198. */
  7199. Sound.prototype.detachFromMesh = function () {
  7200. if (this._connectedTransformNode && this._registerFunc) {
  7201. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  7202. this._registerFunc = null;
  7203. this._connectedTransformNode = null;
  7204. }
  7205. };
  7206. Sound.prototype._onRegisterAfterWorldMatrixUpdate = function (node) {
  7207. if (!node.getBoundingInfo) {
  7208. return;
  7209. }
  7210. var mesh = node;
  7211. if (this._positionInEmitterSpace) {
  7212. mesh.worldMatrixFromCache.invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[0]);
  7213. this.setPosition(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[0].getTranslation());
  7214. }
  7215. else {
  7216. var boundingInfo = mesh.getBoundingInfo();
  7217. this.setPosition(boundingInfo.boundingSphere.centerWorld);
  7218. }
  7219. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._isDirectional && this.isPlaying) {
  7220. this._updateDirection();
  7221. }
  7222. };
  7223. /**
  7224. * Clone the current sound in the scene.
  7225. * @returns the new sound clone
  7226. */
  7227. Sound.prototype.clone = function () {
  7228. var _this = this;
  7229. if (!this._streaming) {
  7230. var setBufferAndRun = function () {
  7231. if (_this._isReadyToPlay) {
  7232. clonedSound._audioBuffer = _this.getAudioBuffer();
  7233. clonedSound._isReadyToPlay = true;
  7234. if (clonedSound.autoplay) {
  7235. clonedSound.play();
  7236. }
  7237. }
  7238. else {
  7239. window.setTimeout(setBufferAndRun, 300);
  7240. }
  7241. };
  7242. var currentOptions = {
  7243. autoplay: this.autoplay, loop: this.loop,
  7244. volume: this._volume, spatialSound: this.spatialSound, maxDistance: this.maxDistance,
  7245. useCustomAttenuation: this.useCustomAttenuation, rolloffFactor: this.rolloffFactor,
  7246. refDistance: this.refDistance, distanceModel: this.distanceModel
  7247. };
  7248. var clonedSound = new Sound(this.name + "_cloned", new ArrayBuffer(0), this._scene, null, currentOptions);
  7249. if (this.useCustomAttenuation) {
  7250. clonedSound.setAttenuationFunction(this._customAttenuationFunction);
  7251. }
  7252. clonedSound.setPosition(this._position);
  7253. clonedSound.setPlaybackRate(this._playbackRate);
  7254. setBufferAndRun();
  7255. return clonedSound;
  7256. }
  7257. // Can't clone a streaming sound
  7258. else {
  7259. return null;
  7260. }
  7261. };
  7262. /**
  7263. * Gets the current underlying audio buffer containing the data
  7264. * @returns the audio buffer
  7265. */
  7266. Sound.prototype.getAudioBuffer = function () {
  7267. return this._audioBuffer;
  7268. };
  7269. /**
  7270. * Serializes the Sound in a JSON representation
  7271. * @returns the JSON representation of the sound
  7272. */
  7273. Sound.prototype.serialize = function () {
  7274. var serializationObject = {
  7275. name: this.name,
  7276. url: this.name,
  7277. autoplay: this.autoplay,
  7278. loop: this.loop,
  7279. volume: this._volume,
  7280. spatialSound: this.spatialSound,
  7281. maxDistance: this.maxDistance,
  7282. rolloffFactor: this.rolloffFactor,
  7283. refDistance: this.refDistance,
  7284. distanceModel: this.distanceModel,
  7285. playbackRate: this._playbackRate,
  7286. panningModel: this._panningModel,
  7287. soundTrackId: this.soundTrackId
  7288. };
  7289. if (this.spatialSound) {
  7290. if (this._connectedTransformNode) {
  7291. serializationObject.connectedMeshId = this._connectedTransformNode.id;
  7292. }
  7293. serializationObject.position = this._position.asArray();
  7294. serializationObject.refDistance = this.refDistance;
  7295. serializationObject.distanceModel = this.distanceModel;
  7296. serializationObject.isDirectional = this._isDirectional;
  7297. serializationObject.localDirectionToMesh = this._localDirection.asArray();
  7298. serializationObject.coneInnerAngle = this._coneInnerAngle;
  7299. serializationObject.coneOuterAngle = this._coneOuterAngle;
  7300. serializationObject.coneOuterGain = this._coneOuterGain;
  7301. }
  7302. return serializationObject;
  7303. };
  7304. /**
  7305. * Parse a JSON representation of a sound to innstantiate in a given scene
  7306. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  7307. * @param scene Define the scene the new parsed sound should be created in
  7308. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  7309. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  7310. * @returns the newly parsed sound
  7311. */
  7312. Sound.Parse = function (parsedSound, scene, rootUrl, sourceSound) {
  7313. var soundName = parsedSound.name;
  7314. var soundUrl;
  7315. if (parsedSound.url) {
  7316. soundUrl = rootUrl + parsedSound.url;
  7317. }
  7318. else {
  7319. soundUrl = rootUrl + soundName;
  7320. }
  7321. var options = {
  7322. autoplay: parsedSound.autoplay, loop: parsedSound.loop, volume: parsedSound.volume,
  7323. spatialSound: parsedSound.spatialSound, maxDistance: parsedSound.maxDistance,
  7324. rolloffFactor: parsedSound.rolloffFactor,
  7325. refDistance: parsedSound.refDistance,
  7326. distanceModel: parsedSound.distanceModel,
  7327. playbackRate: parsedSound.playbackRate
  7328. };
  7329. var newSound;
  7330. if (!sourceSound) {
  7331. newSound = new Sound(soundName, soundUrl, scene, function () { scene._removePendingData(newSound); }, options);
  7332. scene._addPendingData(newSound);
  7333. }
  7334. else {
  7335. var setBufferAndRun = function () {
  7336. if (sourceSound._isReadyToPlay) {
  7337. newSound._audioBuffer = sourceSound.getAudioBuffer();
  7338. newSound._isReadyToPlay = true;
  7339. if (newSound.autoplay) {
  7340. newSound.play();
  7341. }
  7342. }
  7343. else {
  7344. window.setTimeout(setBufferAndRun, 300);
  7345. }
  7346. };
  7347. newSound = new Sound(soundName, new ArrayBuffer(0), scene, null, options);
  7348. setBufferAndRun();
  7349. }
  7350. if (parsedSound.position) {
  7351. var soundPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSound.position);
  7352. newSound.setPosition(soundPosition);
  7353. }
  7354. if (parsedSound.isDirectional) {
  7355. newSound.setDirectionalCone(parsedSound.coneInnerAngle || 360, parsedSound.coneOuterAngle || 360, parsedSound.coneOuterGain || 0);
  7356. if (parsedSound.localDirectionToMesh) {
  7357. var localDirectionToMesh = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSound.localDirectionToMesh);
  7358. newSound.setLocalDirectionToMesh(localDirectionToMesh);
  7359. }
  7360. }
  7361. if (parsedSound.connectedMeshId) {
  7362. var connectedMesh = scene.getMeshByID(parsedSound.connectedMeshId);
  7363. if (connectedMesh) {
  7364. newSound.attachToMesh(connectedMesh);
  7365. }
  7366. }
  7367. return newSound;
  7368. };
  7369. /** @hidden */
  7370. Sound._SceneComponentInitialization = function (_) {
  7371. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__["_DevTools"].WarnImport("AudioSceneComponent");
  7372. };
  7373. return Sound;
  7374. }());
  7375. /***/ }),
  7376. /***/ "./Audio/soundTrack.ts":
  7377. /*!*****************************!*\
  7378. !*** ./Audio/soundTrack.ts ***!
  7379. \*****************************/
  7380. /*! exports provided: SoundTrack */
  7381. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7382. "use strict";
  7383. __webpack_require__.r(__webpack_exports__);
  7384. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return SoundTrack; });
  7385. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  7386. /**
  7387. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  7388. * It will be also used in a future release to apply effects on a specific track.
  7389. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  7390. */
  7391. var SoundTrack = /** @class */ (function () {
  7392. /**
  7393. * Creates a new sound track.
  7394. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  7395. * @param scene Define the scene the sound track belongs to
  7396. * @param options
  7397. */
  7398. function SoundTrack(scene, options) {
  7399. if (options === void 0) { options = {}; }
  7400. /**
  7401. * The unique identifier of the sound track in the scene.
  7402. */
  7403. this.id = -1;
  7404. this._isMainTrack = false;
  7405. this._isInitialized = false;
  7406. this._scene = scene;
  7407. this.soundCollection = new Array();
  7408. this._options = options;
  7409. if (!this._isMainTrack && this._scene.soundTracks) {
  7410. this._scene.soundTracks.push(this);
  7411. this.id = this._scene.soundTracks.length - 1;
  7412. }
  7413. }
  7414. SoundTrack.prototype._initializeSoundTrackAudioGraph = function () {
  7415. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.audioContext) {
  7416. this._outputAudioNode = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.audioContext.createGain();
  7417. this._outputAudioNode.connect(_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.masterGain);
  7418. if (this._options) {
  7419. if (this._options.volume) {
  7420. this._outputAudioNode.gain.value = this._options.volume;
  7421. }
  7422. if (this._options.mainTrack) {
  7423. this._isMainTrack = this._options.mainTrack;
  7424. }
  7425. }
  7426. this._isInitialized = true;
  7427. }
  7428. };
  7429. /**
  7430. * Release the sound track and its associated resources
  7431. */
  7432. SoundTrack.prototype.dispose = function () {
  7433. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine && _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7434. if (this._connectedAnalyser) {
  7435. this._connectedAnalyser.stopDebugCanvas();
  7436. }
  7437. while (this.soundCollection.length) {
  7438. this.soundCollection[0].dispose();
  7439. }
  7440. if (this._outputAudioNode) {
  7441. this._outputAudioNode.disconnect();
  7442. }
  7443. this._outputAudioNode = null;
  7444. }
  7445. };
  7446. /**
  7447. * Adds a sound to this sound track
  7448. * @param sound define the cound to add
  7449. * @ignoreNaming
  7450. */
  7451. SoundTrack.prototype.AddSound = function (sound) {
  7452. if (!this._isInitialized) {
  7453. this._initializeSoundTrackAudioGraph();
  7454. }
  7455. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7456. sound.connectToSoundTrackAudioNode(this._outputAudioNode);
  7457. }
  7458. if (sound.soundTrackId) {
  7459. if (sound.soundTrackId === -1) {
  7460. this._scene.mainSoundTrack.RemoveSound(sound);
  7461. }
  7462. else if (this._scene.soundTracks) {
  7463. this._scene.soundTracks[sound.soundTrackId].RemoveSound(sound);
  7464. }
  7465. }
  7466. this.soundCollection.push(sound);
  7467. sound.soundTrackId = this.id;
  7468. };
  7469. /**
  7470. * Removes a sound to this sound track
  7471. * @param sound define the cound to remove
  7472. * @ignoreNaming
  7473. */
  7474. SoundTrack.prototype.RemoveSound = function (sound) {
  7475. var index = this.soundCollection.indexOf(sound);
  7476. if (index !== -1) {
  7477. this.soundCollection.splice(index, 1);
  7478. }
  7479. };
  7480. /**
  7481. * Set a global volume for the full sound track.
  7482. * @param newVolume Define the new volume of the sound track
  7483. */
  7484. SoundTrack.prototype.setVolume = function (newVolume) {
  7485. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7486. this._outputAudioNode.gain.value = newVolume;
  7487. }
  7488. };
  7489. /**
  7490. * Switch the panning model to HRTF:
  7491. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  7492. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  7493. */
  7494. SoundTrack.prototype.switchPanningModelToHRTF = function () {
  7495. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7496. for (var i = 0; i < this.soundCollection.length; i++) {
  7497. this.soundCollection[i].switchPanningModelToHRTF();
  7498. }
  7499. }
  7500. };
  7501. /**
  7502. * Switch the panning model to Equal Power:
  7503. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  7504. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  7505. */
  7506. SoundTrack.prototype.switchPanningModelToEqualPower = function () {
  7507. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7508. for (var i = 0; i < this.soundCollection.length; i++) {
  7509. this.soundCollection[i].switchPanningModelToEqualPower();
  7510. }
  7511. }
  7512. };
  7513. /**
  7514. * Connect the sound track to an audio analyser allowing some amazing
  7515. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  7516. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  7517. * @param analyser The analyser to connect to the engine
  7518. */
  7519. SoundTrack.prototype.connectToAnalyser = function (analyser) {
  7520. if (this._connectedAnalyser) {
  7521. this._connectedAnalyser.stopDebugCanvas();
  7522. }
  7523. this._connectedAnalyser = analyser;
  7524. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7525. this._outputAudioNode.disconnect();
  7526. this._connectedAnalyser.connectAudioNodes(this._outputAudioNode, _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.masterGain);
  7527. }
  7528. };
  7529. return SoundTrack;
  7530. }());
  7531. /***/ }),
  7532. /***/ "./Audio/weightedsound.ts":
  7533. /*!********************************!*\
  7534. !*** ./Audio/weightedsound.ts ***!
  7535. \********************************/
  7536. /*! exports provided: WeightedSound */
  7537. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7538. "use strict";
  7539. __webpack_require__.r(__webpack_exports__);
  7540. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return WeightedSound; });
  7541. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  7542. /**
  7543. * Wraps one or more Sound objects and selects one with random weight for playback.
  7544. */
  7545. var WeightedSound = /** @class */ (function () {
  7546. /**
  7547. * Creates a new WeightedSound from the list of sounds given.
  7548. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  7549. * @param sounds Array of Sounds that will be selected from.
  7550. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  7551. */
  7552. function WeightedSound(loop, sounds, weights) {
  7553. var _this = this;
  7554. /** When true a Sound will be selected and played when the current playing Sound completes. */
  7555. this.loop = false;
  7556. this._coneInnerAngle = 360;
  7557. this._coneOuterAngle = 360;
  7558. this._volume = 1;
  7559. /** A Sound is currently playing. */
  7560. this.isPlaying = false;
  7561. /** A Sound is currently paused. */
  7562. this.isPaused = false;
  7563. this._sounds = [];
  7564. this._weights = [];
  7565. if (sounds.length !== weights.length) {
  7566. throw new Error('Sounds length does not equal weights length');
  7567. }
  7568. this.loop = loop;
  7569. this._weights = weights;
  7570. // Normalize the weights
  7571. var weightSum = 0;
  7572. for (var _i = 0, weights_1 = weights; _i < weights_1.length; _i++) {
  7573. var weight = weights_1[_i];
  7574. weightSum += weight;
  7575. }
  7576. var invWeightSum = weightSum > 0 ? 1 / weightSum : 0;
  7577. for (var i = 0; i < this._weights.length; i++) {
  7578. this._weights[i] *= invWeightSum;
  7579. }
  7580. this._sounds = sounds;
  7581. for (var _a = 0, _b = this._sounds; _a < _b.length; _a++) {
  7582. var sound = _b[_a];
  7583. sound.onEndedObservable.add(function () { _this._onended(); });
  7584. }
  7585. }
  7586. Object.defineProperty(WeightedSound.prototype, "directionalConeInnerAngle", {
  7587. /**
  7588. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  7589. */
  7590. get: function () {
  7591. return this._coneInnerAngle;
  7592. },
  7593. /**
  7594. * The size of cone in degress for a directional sound in which there will be no attenuation.
  7595. */
  7596. set: function (value) {
  7597. if (value !== this._coneInnerAngle) {
  7598. if (this._coneOuterAngle < value) {
  7599. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
  7600. return;
  7601. }
  7602. this._coneInnerAngle = value;
  7603. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7604. var sound = _a[_i];
  7605. sound.directionalConeInnerAngle = value;
  7606. }
  7607. }
  7608. },
  7609. enumerable: true,
  7610. configurable: true
  7611. });
  7612. Object.defineProperty(WeightedSound.prototype, "directionalConeOuterAngle", {
  7613. /**
  7614. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  7615. * Listener angles between innerAngle and outerAngle will falloff linearly.
  7616. */
  7617. get: function () {
  7618. return this._coneOuterAngle;
  7619. },
  7620. /**
  7621. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  7622. * Listener angles between innerAngle and outerAngle will falloff linearly.
  7623. */
  7624. set: function (value) {
  7625. if (value !== this._coneOuterAngle) {
  7626. if (value < this._coneInnerAngle) {
  7627. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
  7628. return;
  7629. }
  7630. this._coneOuterAngle = value;
  7631. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7632. var sound = _a[_i];
  7633. sound.directionalConeOuterAngle = value;
  7634. }
  7635. }
  7636. },
  7637. enumerable: true,
  7638. configurable: true
  7639. });
  7640. Object.defineProperty(WeightedSound.prototype, "volume", {
  7641. /**
  7642. * Playback volume.
  7643. */
  7644. get: function () {
  7645. return this._volume;
  7646. },
  7647. /**
  7648. * Playback volume.
  7649. */
  7650. set: function (value) {
  7651. if (value !== this._volume) {
  7652. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7653. var sound = _a[_i];
  7654. sound.setVolume(value);
  7655. }
  7656. }
  7657. },
  7658. enumerable: true,
  7659. configurable: true
  7660. });
  7661. WeightedSound.prototype._onended = function () {
  7662. if (this._currentIndex !== undefined) {
  7663. this._sounds[this._currentIndex].autoplay = false;
  7664. }
  7665. if (this.loop && this.isPlaying) {
  7666. this.play();
  7667. }
  7668. else {
  7669. this.isPlaying = false;
  7670. }
  7671. };
  7672. /**
  7673. * Suspend playback
  7674. */
  7675. WeightedSound.prototype.pause = function () {
  7676. this.isPaused = true;
  7677. if (this._currentIndex !== undefined) {
  7678. this._sounds[this._currentIndex].pause();
  7679. }
  7680. };
  7681. /**
  7682. * Stop playback
  7683. */
  7684. WeightedSound.prototype.stop = function () {
  7685. this.isPlaying = false;
  7686. if (this._currentIndex !== undefined) {
  7687. this._sounds[this._currentIndex].stop();
  7688. }
  7689. };
  7690. /**
  7691. * Start playback.
  7692. * @param startOffset Position the clip head at a specific time in seconds.
  7693. */
  7694. WeightedSound.prototype.play = function (startOffset) {
  7695. if (!this.isPaused) {
  7696. this.stop();
  7697. var randomValue = Math.random();
  7698. var total = 0;
  7699. for (var i = 0; i < this._weights.length; i++) {
  7700. total += this._weights[i];
  7701. if (randomValue <= total) {
  7702. this._currentIndex = i;
  7703. break;
  7704. }
  7705. }
  7706. }
  7707. var sound = this._sounds[this._currentIndex];
  7708. if (sound.isReady()) {
  7709. sound.play(0, this.isPaused ? undefined : startOffset);
  7710. }
  7711. else {
  7712. sound.autoplay = true;
  7713. }
  7714. this.isPlaying = true;
  7715. this.isPaused = false;
  7716. };
  7717. return WeightedSound;
  7718. }());
  7719. /***/ }),
  7720. /***/ "./Behaviors/Cameras/autoRotationBehavior.ts":
  7721. /*!***************************************************!*\
  7722. !*** ./Behaviors/Cameras/autoRotationBehavior.ts ***!
  7723. \***************************************************/
  7724. /*! exports provided: AutoRotationBehavior */
  7725. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7726. "use strict";
  7727. __webpack_require__.r(__webpack_exports__);
  7728. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return AutoRotationBehavior; });
  7729. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  7730. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/precisionDate */ "./Misc/precisionDate.ts");
  7731. /**
  7732. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  7733. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7734. */
  7735. var AutoRotationBehavior = /** @class */ (function () {
  7736. function AutoRotationBehavior() {
  7737. this._zoomStopsAnimation = false;
  7738. this._idleRotationSpeed = 0.05;
  7739. this._idleRotationWaitTime = 2000;
  7740. this._idleRotationSpinupTime = 2000;
  7741. this._isPointerDown = false;
  7742. this._lastFrameTime = null;
  7743. this._lastInteractionTime = -Infinity;
  7744. this._cameraRotationSpeed = 0;
  7745. this._lastFrameRadius = 0;
  7746. }
  7747. Object.defineProperty(AutoRotationBehavior.prototype, "name", {
  7748. /**
  7749. * Gets the name of the behavior.
  7750. */
  7751. get: function () {
  7752. return "AutoRotation";
  7753. },
  7754. enumerable: true,
  7755. configurable: true
  7756. });
  7757. Object.defineProperty(AutoRotationBehavior.prototype, "zoomStopsAnimation", {
  7758. /**
  7759. * Gets the flag that indicates if user zooming should stop animation.
  7760. */
  7761. get: function () {
  7762. return this._zoomStopsAnimation;
  7763. },
  7764. /**
  7765. * Sets the flag that indicates if user zooming should stop animation.
  7766. */
  7767. set: function (flag) {
  7768. this._zoomStopsAnimation = flag;
  7769. },
  7770. enumerable: true,
  7771. configurable: true
  7772. });
  7773. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationSpeed", {
  7774. /**
  7775. * Gets the default speed at which the camera rotates around the model.
  7776. */
  7777. get: function () {
  7778. return this._idleRotationSpeed;
  7779. },
  7780. /**
  7781. * Sets the default speed at which the camera rotates around the model.
  7782. */
  7783. set: function (speed) {
  7784. this._idleRotationSpeed = speed;
  7785. },
  7786. enumerable: true,
  7787. configurable: true
  7788. });
  7789. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationWaitTime", {
  7790. /**
  7791. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  7792. */
  7793. get: function () {
  7794. return this._idleRotationWaitTime;
  7795. },
  7796. /**
  7797. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  7798. */
  7799. set: function (time) {
  7800. this._idleRotationWaitTime = time;
  7801. },
  7802. enumerable: true,
  7803. configurable: true
  7804. });
  7805. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationSpinupTime", {
  7806. /**
  7807. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  7808. */
  7809. get: function () {
  7810. return this._idleRotationSpinupTime;
  7811. },
  7812. /**
  7813. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  7814. */
  7815. set: function (time) {
  7816. this._idleRotationSpinupTime = time;
  7817. },
  7818. enumerable: true,
  7819. configurable: true
  7820. });
  7821. Object.defineProperty(AutoRotationBehavior.prototype, "rotationInProgress", {
  7822. /**
  7823. * Gets a value indicating if the camera is currently rotating because of this behavior
  7824. */
  7825. get: function () {
  7826. return Math.abs(this._cameraRotationSpeed) > 0;
  7827. },
  7828. enumerable: true,
  7829. configurable: true
  7830. });
  7831. /**
  7832. * Initializes the behavior.
  7833. */
  7834. AutoRotationBehavior.prototype.init = function () {
  7835. // Do notihng
  7836. };
  7837. /**
  7838. * Attaches the behavior to its arc rotate camera.
  7839. * @param camera Defines the camera to attach the behavior to
  7840. */
  7841. AutoRotationBehavior.prototype.attach = function (camera) {
  7842. var _this = this;
  7843. this._attachedCamera = camera;
  7844. var scene = this._attachedCamera.getScene();
  7845. this._onPrePointerObservableObserver = scene.onPrePointerObservable.add(function (pointerInfoPre) {
  7846. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  7847. _this._isPointerDown = true;
  7848. return;
  7849. }
  7850. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  7851. _this._isPointerDown = false;
  7852. }
  7853. });
  7854. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  7855. var now = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__["PrecisionDate"].Now;
  7856. var dt = 0;
  7857. if (_this._lastFrameTime != null) {
  7858. dt = now - _this._lastFrameTime;
  7859. }
  7860. _this._lastFrameTime = now;
  7861. // Stop the animation if there is user interaction and the animation should stop for this interaction
  7862. _this._applyUserInteraction();
  7863. var timeToRotation = now - _this._lastInteractionTime - _this._idleRotationWaitTime;
  7864. var scale = Math.max(Math.min(timeToRotation / (_this._idleRotationSpinupTime), 1), 0);
  7865. _this._cameraRotationSpeed = _this._idleRotationSpeed * scale;
  7866. // Step camera rotation by rotation speed
  7867. if (_this._attachedCamera) {
  7868. _this._attachedCamera.alpha -= _this._cameraRotationSpeed * (dt / 1000);
  7869. }
  7870. });
  7871. };
  7872. /**
  7873. * Detaches the behavior from its current arc rotate camera.
  7874. */
  7875. AutoRotationBehavior.prototype.detach = function () {
  7876. if (!this._attachedCamera) {
  7877. return;
  7878. }
  7879. var scene = this._attachedCamera.getScene();
  7880. if (this._onPrePointerObservableObserver) {
  7881. scene.onPrePointerObservable.remove(this._onPrePointerObservableObserver);
  7882. }
  7883. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  7884. this._attachedCamera = null;
  7885. };
  7886. /**
  7887. * Returns true if user is scrolling.
  7888. * @return true if user is scrolling.
  7889. */
  7890. AutoRotationBehavior.prototype._userIsZooming = function () {
  7891. if (!this._attachedCamera) {
  7892. return false;
  7893. }
  7894. return this._attachedCamera.inertialRadiusOffset !== 0;
  7895. };
  7896. AutoRotationBehavior.prototype._shouldAnimationStopForInteraction = function () {
  7897. if (!this._attachedCamera) {
  7898. return false;
  7899. }
  7900. var zoomHasHitLimit = false;
  7901. if (this._lastFrameRadius === this._attachedCamera.radius && this._attachedCamera.inertialRadiusOffset !== 0) {
  7902. zoomHasHitLimit = true;
  7903. }
  7904. // Update the record of previous radius - works as an approx. indicator of hitting radius limits
  7905. this._lastFrameRadius = this._attachedCamera.radius;
  7906. return this._zoomStopsAnimation ? zoomHasHitLimit : this._userIsZooming();
  7907. };
  7908. /**
  7909. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  7910. */
  7911. AutoRotationBehavior.prototype._applyUserInteraction = function () {
  7912. if (this._userIsMoving() && !this._shouldAnimationStopForInteraction()) {
  7913. this._lastInteractionTime = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__["PrecisionDate"].Now;
  7914. }
  7915. };
  7916. // Tools
  7917. AutoRotationBehavior.prototype._userIsMoving = function () {
  7918. if (!this._attachedCamera) {
  7919. return false;
  7920. }
  7921. return this._attachedCamera.inertialAlphaOffset !== 0 ||
  7922. this._attachedCamera.inertialBetaOffset !== 0 ||
  7923. this._attachedCamera.inertialRadiusOffset !== 0 ||
  7924. this._attachedCamera.inertialPanningX !== 0 ||
  7925. this._attachedCamera.inertialPanningY !== 0 ||
  7926. this._isPointerDown;
  7927. };
  7928. return AutoRotationBehavior;
  7929. }());
  7930. /***/ }),
  7931. /***/ "./Behaviors/Cameras/bouncingBehavior.ts":
  7932. /*!***********************************************!*\
  7933. !*** ./Behaviors/Cameras/bouncingBehavior.ts ***!
  7934. \***********************************************/
  7935. /*! exports provided: BouncingBehavior */
  7936. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7937. "use strict";
  7938. __webpack_require__.r(__webpack_exports__);
  7939. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return BouncingBehavior; });
  7940. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  7941. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  7942. /**
  7943. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  7944. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7945. */
  7946. var BouncingBehavior = /** @class */ (function () {
  7947. function BouncingBehavior() {
  7948. /**
  7949. * The duration of the animation, in milliseconds
  7950. */
  7951. this.transitionDuration = 450;
  7952. /**
  7953. * Length of the distance animated by the transition when lower radius is reached
  7954. */
  7955. this.lowerRadiusTransitionRange = 2;
  7956. /**
  7957. * Length of the distance animated by the transition when upper radius is reached
  7958. */
  7959. this.upperRadiusTransitionRange = -2;
  7960. this._autoTransitionRange = false;
  7961. // Animations
  7962. this._radiusIsAnimating = false;
  7963. this._radiusBounceTransition = null;
  7964. this._animatables = new Array();
  7965. }
  7966. Object.defineProperty(BouncingBehavior.prototype, "name", {
  7967. /**
  7968. * Gets the name of the behavior.
  7969. */
  7970. get: function () {
  7971. return "Bouncing";
  7972. },
  7973. enumerable: true,
  7974. configurable: true
  7975. });
  7976. Object.defineProperty(BouncingBehavior.prototype, "autoTransitionRange", {
  7977. /**
  7978. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  7979. */
  7980. get: function () {
  7981. return this._autoTransitionRange;
  7982. },
  7983. /**
  7984. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  7985. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  7986. */
  7987. set: function (value) {
  7988. var _this = this;
  7989. if (this._autoTransitionRange === value) {
  7990. return;
  7991. }
  7992. this._autoTransitionRange = value;
  7993. var camera = this._attachedCamera;
  7994. if (!camera) {
  7995. return;
  7996. }
  7997. if (value) {
  7998. this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add(function (mesh) {
  7999. if (!mesh) {
  8000. return;
  8001. }
  8002. mesh.computeWorldMatrix(true);
  8003. var diagonal = mesh.getBoundingInfo().diagonalLength;
  8004. _this.lowerRadiusTransitionRange = diagonal * 0.05;
  8005. _this.upperRadiusTransitionRange = diagonal * 0.05;
  8006. });
  8007. }
  8008. else if (this._onMeshTargetChangedObserver) {
  8009. camera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8010. }
  8011. },
  8012. enumerable: true,
  8013. configurable: true
  8014. });
  8015. /**
  8016. * Initializes the behavior.
  8017. */
  8018. BouncingBehavior.prototype.init = function () {
  8019. // Do notihng
  8020. };
  8021. /**
  8022. * Attaches the behavior to its arc rotate camera.
  8023. * @param camera Defines the camera to attach the behavior to
  8024. */
  8025. BouncingBehavior.prototype.attach = function (camera) {
  8026. var _this = this;
  8027. this._attachedCamera = camera;
  8028. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  8029. if (!_this._attachedCamera) {
  8030. return;
  8031. }
  8032. // Add the bounce animation to the lower radius limit
  8033. if (_this._isRadiusAtLimit(_this._attachedCamera.lowerRadiusLimit)) {
  8034. _this._applyBoundRadiusAnimation(_this.lowerRadiusTransitionRange);
  8035. }
  8036. // Add the bounce animation to the upper radius limit
  8037. if (_this._isRadiusAtLimit(_this._attachedCamera.upperRadiusLimit)) {
  8038. _this._applyBoundRadiusAnimation(_this.upperRadiusTransitionRange);
  8039. }
  8040. });
  8041. };
  8042. /**
  8043. * Detaches the behavior from its current arc rotate camera.
  8044. */
  8045. BouncingBehavior.prototype.detach = function () {
  8046. if (!this._attachedCamera) {
  8047. return;
  8048. }
  8049. if (this._onAfterCheckInputsObserver) {
  8050. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  8051. }
  8052. if (this._onMeshTargetChangedObserver) {
  8053. this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8054. }
  8055. this._attachedCamera = null;
  8056. };
  8057. /**
  8058. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  8059. * @param radiusLimit The limit to check against.
  8060. * @return Bool to indicate if at limit.
  8061. */
  8062. BouncingBehavior.prototype._isRadiusAtLimit = function (radiusLimit) {
  8063. if (!this._attachedCamera) {
  8064. return false;
  8065. }
  8066. if (this._attachedCamera.radius === radiusLimit && !this._radiusIsAnimating) {
  8067. return true;
  8068. }
  8069. return false;
  8070. };
  8071. /**
  8072. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  8073. * @param radiusDelta The delta by which to animate to. Can be negative.
  8074. */
  8075. BouncingBehavior.prototype._applyBoundRadiusAnimation = function (radiusDelta) {
  8076. var _this = this;
  8077. if (!this._attachedCamera) {
  8078. return;
  8079. }
  8080. if (!this._radiusBounceTransition) {
  8081. BouncingBehavior.EasingFunction.setEasingMode(BouncingBehavior.EasingMode);
  8082. this._radiusBounceTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].CreateAnimation("radius", _Animations_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT, 60, BouncingBehavior.EasingFunction);
  8083. }
  8084. // Prevent zoom until bounce has completed
  8085. this._cachedWheelPrecision = this._attachedCamera.wheelPrecision;
  8086. this._attachedCamera.wheelPrecision = Infinity;
  8087. this._attachedCamera.inertialRadiusOffset = 0;
  8088. // Animate to the radius limit
  8089. this.stopAllAnimations();
  8090. this._radiusIsAnimating = true;
  8091. var animatable = _Animations_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].TransitionTo("radius", this._attachedCamera.radius + radiusDelta, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusBounceTransition, this.transitionDuration, function () { return _this._clearAnimationLocks(); });
  8092. if (animatable) {
  8093. this._animatables.push(animatable);
  8094. }
  8095. };
  8096. /**
  8097. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  8098. */
  8099. BouncingBehavior.prototype._clearAnimationLocks = function () {
  8100. this._radiusIsAnimating = false;
  8101. if (this._attachedCamera) {
  8102. this._attachedCamera.wheelPrecision = this._cachedWheelPrecision;
  8103. }
  8104. };
  8105. /**
  8106. * Stops and removes all animations that have been applied to the camera
  8107. */
  8108. BouncingBehavior.prototype.stopAllAnimations = function () {
  8109. if (this._attachedCamera) {
  8110. this._attachedCamera.animations = [];
  8111. }
  8112. while (this._animatables.length) {
  8113. this._animatables[0].onAnimationEnd = null;
  8114. this._animatables[0].stop();
  8115. this._animatables.shift();
  8116. }
  8117. };
  8118. /**
  8119. * The easing function used by animations
  8120. */
  8121. BouncingBehavior.EasingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["BackEase"](0.3);
  8122. /**
  8123. * The easing mode used by animations
  8124. */
  8125. BouncingBehavior.EasingMode = _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"].EASINGMODE_EASEOUT;
  8126. return BouncingBehavior;
  8127. }());
  8128. /***/ }),
  8129. /***/ "./Behaviors/Cameras/framingBehavior.ts":
  8130. /*!**********************************************!*\
  8131. !*** ./Behaviors/Cameras/framingBehavior.ts ***!
  8132. \**********************************************/
  8133. /*! exports provided: FramingBehavior */
  8134. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8135. "use strict";
  8136. __webpack_require__.r(__webpack_exports__);
  8137. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return FramingBehavior; });
  8138. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  8139. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  8140. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  8141. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/precisionDate */ "./Misc/precisionDate.ts");
  8142. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8143. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  8144. /**
  8145. * The framing behavior (FramingBehavior) is designed to automatically position an ArcRotateCamera when its target is set to a mesh. It is also useful if you want to prevent the camera to go under a virtual horizontal plane.
  8146. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  8147. */
  8148. var FramingBehavior = /** @class */ (function () {
  8149. function FramingBehavior() {
  8150. this._mode = FramingBehavior.FitFrustumSidesMode;
  8151. this._radiusScale = 1.0;
  8152. this._positionScale = 0.5;
  8153. this._defaultElevation = 0.3;
  8154. this._elevationReturnTime = 1500;
  8155. this._elevationReturnWaitTime = 1000;
  8156. this._zoomStopsAnimation = false;
  8157. this._framingTime = 1500;
  8158. /**
  8159. * Define if the behavior should automatically change the configured
  8160. * camera limits and sensibilities.
  8161. */
  8162. this.autoCorrectCameraLimitsAndSensibility = true;
  8163. this._isPointerDown = false;
  8164. this._lastInteractionTime = -Infinity;
  8165. // Framing control
  8166. this._animatables = new Array();
  8167. this._betaIsAnimating = false;
  8168. }
  8169. Object.defineProperty(FramingBehavior.prototype, "name", {
  8170. /**
  8171. * Gets the name of the behavior.
  8172. */
  8173. get: function () {
  8174. return "Framing";
  8175. },
  8176. enumerable: true,
  8177. configurable: true
  8178. });
  8179. Object.defineProperty(FramingBehavior.prototype, "mode", {
  8180. /**
  8181. * Gets current mode used by the behavior.
  8182. */
  8183. get: function () {
  8184. return this._mode;
  8185. },
  8186. /**
  8187. * Sets the current mode used by the behavior
  8188. */
  8189. set: function (mode) {
  8190. this._mode = mode;
  8191. },
  8192. enumerable: true,
  8193. configurable: true
  8194. });
  8195. Object.defineProperty(FramingBehavior.prototype, "radiusScale", {
  8196. /**
  8197. * Gets the scale applied to the radius
  8198. */
  8199. get: function () {
  8200. return this._radiusScale;
  8201. },
  8202. /**
  8203. * Sets the scale applied to the radius (1 by default)
  8204. */
  8205. set: function (radius) {
  8206. this._radiusScale = radius;
  8207. },
  8208. enumerable: true,
  8209. configurable: true
  8210. });
  8211. Object.defineProperty(FramingBehavior.prototype, "positionScale", {
  8212. /**
  8213. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  8214. */
  8215. get: function () {
  8216. return this._positionScale;
  8217. },
  8218. /**
  8219. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  8220. */
  8221. set: function (scale) {
  8222. this._positionScale = scale;
  8223. },
  8224. enumerable: true,
  8225. configurable: true
  8226. });
  8227. Object.defineProperty(FramingBehavior.prototype, "defaultElevation", {
  8228. /**
  8229. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  8230. * behaviour is triggered, in radians.
  8231. */
  8232. get: function () {
  8233. return this._defaultElevation;
  8234. },
  8235. /**
  8236. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  8237. * behaviour is triggered, in radians.
  8238. */
  8239. set: function (elevation) {
  8240. this._defaultElevation = elevation;
  8241. },
  8242. enumerable: true,
  8243. configurable: true
  8244. });
  8245. Object.defineProperty(FramingBehavior.prototype, "elevationReturnTime", {
  8246. /**
  8247. * Gets the time (in milliseconds) taken to return to the default beta position.
  8248. * Negative value indicates camera should not return to default.
  8249. */
  8250. get: function () {
  8251. return this._elevationReturnTime;
  8252. },
  8253. /**
  8254. * Sets the time (in milliseconds) taken to return to the default beta position.
  8255. * Negative value indicates camera should not return to default.
  8256. */
  8257. set: function (speed) {
  8258. this._elevationReturnTime = speed;
  8259. },
  8260. enumerable: true,
  8261. configurable: true
  8262. });
  8263. Object.defineProperty(FramingBehavior.prototype, "elevationReturnWaitTime", {
  8264. /**
  8265. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  8266. */
  8267. get: function () {
  8268. return this._elevationReturnWaitTime;
  8269. },
  8270. /**
  8271. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  8272. */
  8273. set: function (time) {
  8274. this._elevationReturnWaitTime = time;
  8275. },
  8276. enumerable: true,
  8277. configurable: true
  8278. });
  8279. Object.defineProperty(FramingBehavior.prototype, "zoomStopsAnimation", {
  8280. /**
  8281. * Gets the flag that indicates if user zooming should stop animation.
  8282. */
  8283. get: function () {
  8284. return this._zoomStopsAnimation;
  8285. },
  8286. /**
  8287. * Sets the flag that indicates if user zooming should stop animation.
  8288. */
  8289. set: function (flag) {
  8290. this._zoomStopsAnimation = flag;
  8291. },
  8292. enumerable: true,
  8293. configurable: true
  8294. });
  8295. Object.defineProperty(FramingBehavior.prototype, "framingTime", {
  8296. /**
  8297. * Gets the transition time when framing the mesh, in milliseconds
  8298. */
  8299. get: function () {
  8300. return this._framingTime;
  8301. },
  8302. /**
  8303. * Sets the transition time when framing the mesh, in milliseconds
  8304. */
  8305. set: function (time) {
  8306. this._framingTime = time;
  8307. },
  8308. enumerable: true,
  8309. configurable: true
  8310. });
  8311. /**
  8312. * Initializes the behavior.
  8313. */
  8314. FramingBehavior.prototype.init = function () {
  8315. // Do notihng
  8316. };
  8317. /**
  8318. * Attaches the behavior to its arc rotate camera.
  8319. * @param camera Defines the camera to attach the behavior to
  8320. */
  8321. FramingBehavior.prototype.attach = function (camera) {
  8322. var _this = this;
  8323. this._attachedCamera = camera;
  8324. var scene = this._attachedCamera.getScene();
  8325. FramingBehavior.EasingFunction.setEasingMode(FramingBehavior.EasingMode);
  8326. this._onPrePointerObservableObserver = scene.onPrePointerObservable.add(function (pointerInfoPre) {
  8327. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  8328. _this._isPointerDown = true;
  8329. return;
  8330. }
  8331. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  8332. _this._isPointerDown = false;
  8333. }
  8334. });
  8335. this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add(function (mesh) {
  8336. if (mesh) {
  8337. _this.zoomOnMesh(mesh);
  8338. }
  8339. });
  8340. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  8341. // Stop the animation if there is user interaction and the animation should stop for this interaction
  8342. _this._applyUserInteraction();
  8343. // Maintain the camera above the ground. If the user pulls the camera beneath the ground plane, lift it
  8344. // back to the default position after a given timeout
  8345. _this._maintainCameraAboveGround();
  8346. });
  8347. };
  8348. /**
  8349. * Detaches the behavior from its current arc rotate camera.
  8350. */
  8351. FramingBehavior.prototype.detach = function () {
  8352. if (!this._attachedCamera) {
  8353. return;
  8354. }
  8355. var scene = this._attachedCamera.getScene();
  8356. if (this._onPrePointerObservableObserver) {
  8357. scene.onPrePointerObservable.remove(this._onPrePointerObservableObserver);
  8358. }
  8359. if (this._onAfterCheckInputsObserver) {
  8360. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  8361. }
  8362. if (this._onMeshTargetChangedObserver) {
  8363. this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8364. }
  8365. this._attachedCamera = null;
  8366. };
  8367. /**
  8368. * Targets the given mesh and updates zoom level accordingly.
  8369. * @param mesh The mesh to target.
  8370. * @param radius Optional. If a cached radius position already exists, overrides default.
  8371. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8372. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8373. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8374. */
  8375. FramingBehavior.prototype.zoomOnMesh = function (mesh, focusOnOriginXZ, onAnimationEnd) {
  8376. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8377. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8378. mesh.computeWorldMatrix(true);
  8379. var boundingBox = mesh.getBoundingInfo().boundingBox;
  8380. this.zoomOnBoundingInfo(boundingBox.minimumWorld, boundingBox.maximumWorld, focusOnOriginXZ, onAnimationEnd);
  8381. };
  8382. /**
  8383. * Targets the given mesh with its children and updates zoom level accordingly.
  8384. * @param mesh The mesh to target.
  8385. * @param radius Optional. If a cached radius position already exists, overrides default.
  8386. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8387. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8388. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8389. */
  8390. FramingBehavior.prototype.zoomOnMeshHierarchy = function (mesh, focusOnOriginXZ, onAnimationEnd) {
  8391. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8392. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8393. mesh.computeWorldMatrix(true);
  8394. var boundingBox = mesh.getHierarchyBoundingVectors(true);
  8395. this.zoomOnBoundingInfo(boundingBox.min, boundingBox.max, focusOnOriginXZ, onAnimationEnd);
  8396. };
  8397. /**
  8398. * Targets the given meshes with their children and updates zoom level accordingly.
  8399. * @param meshes The mesh to target.
  8400. * @param radius Optional. If a cached radius position already exists, overrides default.
  8401. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8402. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8403. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8404. */
  8405. FramingBehavior.prototype.zoomOnMeshesHierarchy = function (meshes, focusOnOriginXZ, onAnimationEnd) {
  8406. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8407. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8408. var min = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  8409. var max = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  8410. for (var i = 0; i < meshes.length; i++) {
  8411. var boundingInfo = meshes[i].getHierarchyBoundingVectors(true);
  8412. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].CheckExtends(boundingInfo.min, min, max);
  8413. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].CheckExtends(boundingInfo.max, min, max);
  8414. }
  8415. this.zoomOnBoundingInfo(min, max, focusOnOriginXZ, onAnimationEnd);
  8416. };
  8417. /**
  8418. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  8419. * @param minimumWorld Determines the smaller position of the bounding box extend
  8420. * @param maximumWorld Determines the bigger position of the bounding box extend
  8421. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8422. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8423. */
  8424. FramingBehavior.prototype.zoomOnBoundingInfo = function (minimumWorld, maximumWorld, focusOnOriginXZ, onAnimationEnd) {
  8425. var _this = this;
  8426. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8427. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8428. var zoomTarget;
  8429. if (!this._attachedCamera) {
  8430. return;
  8431. }
  8432. // Find target by interpolating from bottom of bounding box in world-space to top via framingPositionY
  8433. var bottom = minimumWorld.y;
  8434. var top = maximumWorld.y;
  8435. var zoomTargetY = bottom + (top - bottom) * this._positionScale;
  8436. var radiusWorld = maximumWorld.subtract(minimumWorld).scale(0.5);
  8437. if (focusOnOriginXZ) {
  8438. zoomTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, zoomTargetY, 0);
  8439. }
  8440. else {
  8441. var centerWorld = minimumWorld.add(radiusWorld);
  8442. zoomTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](centerWorld.x, zoomTargetY, centerWorld.z);
  8443. }
  8444. if (!this._vectorTransition) {
  8445. this._vectorTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("target", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_VECTOR3, 60, FramingBehavior.EasingFunction);
  8446. }
  8447. this._betaIsAnimating = true;
  8448. var animatable = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("target", zoomTarget, this._attachedCamera, this._attachedCamera.getScene(), 60, this._vectorTransition, this._framingTime);
  8449. if (animatable) {
  8450. this._animatables.push(animatable);
  8451. }
  8452. // sets the radius and lower radius bounds
  8453. // Small delta ensures camera is not always at lower zoom limit.
  8454. var radius = 0;
  8455. if (this._mode === FramingBehavior.FitFrustumSidesMode) {
  8456. var position = this._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld);
  8457. if (this.autoCorrectCameraLimitsAndSensibility) {
  8458. this._attachedCamera.lowerRadiusLimit = radiusWorld.length() + this._attachedCamera.minZ;
  8459. }
  8460. radius = position;
  8461. }
  8462. else if (this._mode === FramingBehavior.IgnoreBoundsSizeMode) {
  8463. radius = this._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld);
  8464. if (this.autoCorrectCameraLimitsAndSensibility && this._attachedCamera.lowerRadiusLimit === null) {
  8465. this._attachedCamera.lowerRadiusLimit = this._attachedCamera.minZ;
  8466. }
  8467. }
  8468. // Set sensibilities
  8469. if (this.autoCorrectCameraLimitsAndSensibility) {
  8470. var extend = maximumWorld.subtract(minimumWorld).length();
  8471. this._attachedCamera.panningSensibility = 5000 / extend;
  8472. this._attachedCamera.wheelPrecision = 100 / radius;
  8473. }
  8474. // transition to new radius
  8475. if (!this._radiusTransition) {
  8476. this._radiusTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("radius", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
  8477. }
  8478. animatable = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("radius", radius, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusTransition, this._framingTime, function () {
  8479. _this.stopAllAnimations();
  8480. if (onAnimationEnd) {
  8481. onAnimationEnd();
  8482. }
  8483. if (_this._attachedCamera && _this._attachedCamera.useInputToRestoreState) {
  8484. _this._attachedCamera.storeState();
  8485. }
  8486. });
  8487. if (animatable) {
  8488. this._animatables.push(animatable);
  8489. }
  8490. };
  8491. /**
  8492. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  8493. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  8494. * frustum width.
  8495. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  8496. * to fully enclose the mesh in the viewing frustum.
  8497. */
  8498. FramingBehavior.prototype._calculateLowerRadiusFromModelBoundingSphere = function (minimumWorld, maximumWorld) {
  8499. var size = maximumWorld.subtract(minimumWorld);
  8500. var boxVectorGlobalDiagonal = size.length();
  8501. var frustumSlope = this._getFrustumSlope();
  8502. // Formula for setting distance
  8503. // (Good explanation: http://stackoverflow.com/questions/2866350/move-camera-to-fit-3d-scene)
  8504. var radiusWithoutFraming = boxVectorGlobalDiagonal * 0.5;
  8505. // Horizon distance
  8506. var radius = radiusWithoutFraming * this._radiusScale;
  8507. var distanceForHorizontalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.x * frustumSlope.x));
  8508. var distanceForVerticalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.y * frustumSlope.y));
  8509. var distance = Math.max(distanceForHorizontalFrustum, distanceForVerticalFrustum);
  8510. var camera = this._attachedCamera;
  8511. if (!camera) {
  8512. return 0;
  8513. }
  8514. if (camera.lowerRadiusLimit && this._mode === FramingBehavior.IgnoreBoundsSizeMode) {
  8515. // Don't exceed the requested limit
  8516. distance = distance < camera.lowerRadiusLimit ? camera.lowerRadiusLimit : distance;
  8517. }
  8518. // Don't exceed the upper radius limit
  8519. if (camera.upperRadiusLimit) {
  8520. distance = distance > camera.upperRadiusLimit ? camera.upperRadiusLimit : distance;
  8521. }
  8522. return distance;
  8523. };
  8524. /**
  8525. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  8526. * is automatically returned to its default position (expected to be above ground plane).
  8527. */
  8528. FramingBehavior.prototype._maintainCameraAboveGround = function () {
  8529. var _this = this;
  8530. if (this._elevationReturnTime < 0) {
  8531. return;
  8532. }
  8533. var timeSinceInteraction = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__["PrecisionDate"].Now - this._lastInteractionTime;
  8534. var defaultBeta = Math.PI * 0.5 - this._defaultElevation;
  8535. var limitBeta = Math.PI * 0.5;
  8536. // Bring the camera back up if below the ground plane
  8537. if (this._attachedCamera && !this._betaIsAnimating && this._attachedCamera.beta > limitBeta && timeSinceInteraction >= this._elevationReturnWaitTime) {
  8538. this._betaIsAnimating = true;
  8539. //Transition to new position
  8540. this.stopAllAnimations();
  8541. if (!this._betaTransition) {
  8542. this._betaTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("beta", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
  8543. }
  8544. var animatabe = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("beta", defaultBeta, this._attachedCamera, this._attachedCamera.getScene(), 60, this._betaTransition, this._elevationReturnTime, function () {
  8545. _this._clearAnimationLocks();
  8546. _this.stopAllAnimations();
  8547. });
  8548. if (animatabe) {
  8549. this._animatables.push(animatabe);
  8550. }
  8551. }
  8552. };
  8553. /**
  8554. * Returns the frustum slope based on the canvas ratio and camera FOV
  8555. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  8556. */
  8557. FramingBehavior.prototype._getFrustumSlope = function () {
  8558. // Calculate the viewport ratio
  8559. // Aspect Ratio is Height/Width.
  8560. var camera = this._attachedCamera;
  8561. if (!camera) {
  8562. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector2"].Zero();
  8563. }
  8564. var engine = camera.getScene().getEngine();
  8565. var aspectRatio = engine.getAspectRatio(camera);
  8566. // Camera FOV is the vertical field of view (top-bottom) in radians.
  8567. // Slope of the frustum top/bottom planes in view space, relative to the forward vector.
  8568. var frustumSlopeY = Math.tan(camera.fov / 2);
  8569. // Slope of the frustum left/right planes in view space, relative to the forward vector.
  8570. // Provides the amount that one side (e.g. left) of the frustum gets wider for every unit
  8571. // along the forward vector.
  8572. var frustumSlopeX = frustumSlopeY * aspectRatio;
  8573. return new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector2"](frustumSlopeX, frustumSlopeY);
  8574. };
  8575. /**
  8576. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  8577. */
  8578. FramingBehavior.prototype._clearAnimationLocks = function () {
  8579. this._betaIsAnimating = false;
  8580. };
  8581. /**
  8582. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  8583. */
  8584. FramingBehavior.prototype._applyUserInteraction = function () {
  8585. if (this.isUserIsMoving) {
  8586. this._lastInteractionTime = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__["PrecisionDate"].Now;
  8587. this.stopAllAnimations();
  8588. this._clearAnimationLocks();
  8589. }
  8590. };
  8591. /**
  8592. * Stops and removes all animations that have been applied to the camera
  8593. */
  8594. FramingBehavior.prototype.stopAllAnimations = function () {
  8595. if (this._attachedCamera) {
  8596. this._attachedCamera.animations = [];
  8597. }
  8598. while (this._animatables.length) {
  8599. if (this._animatables[0]) {
  8600. this._animatables[0].onAnimationEnd = null;
  8601. this._animatables[0].stop();
  8602. }
  8603. this._animatables.shift();
  8604. }
  8605. };
  8606. Object.defineProperty(FramingBehavior.prototype, "isUserIsMoving", {
  8607. /**
  8608. * Gets a value indicating if the user is moving the camera
  8609. */
  8610. get: function () {
  8611. if (!this._attachedCamera) {
  8612. return false;
  8613. }
  8614. return this._attachedCamera.inertialAlphaOffset !== 0 ||
  8615. this._attachedCamera.inertialBetaOffset !== 0 ||
  8616. this._attachedCamera.inertialRadiusOffset !== 0 ||
  8617. this._attachedCamera.inertialPanningX !== 0 ||
  8618. this._attachedCamera.inertialPanningY !== 0 ||
  8619. this._isPointerDown;
  8620. },
  8621. enumerable: true,
  8622. configurable: true
  8623. });
  8624. /**
  8625. * The easing function used by animations
  8626. */
  8627. FramingBehavior.EasingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["ExponentialEase"]();
  8628. /**
  8629. * The easing mode used by animations
  8630. */
  8631. FramingBehavior.EasingMode = _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"].EASINGMODE_EASEINOUT;
  8632. // Statics
  8633. /**
  8634. * The camera can move all the way towards the mesh.
  8635. */
  8636. FramingBehavior.IgnoreBoundsSizeMode = 0;
  8637. /**
  8638. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  8639. */
  8640. FramingBehavior.FitFrustumSidesMode = 1;
  8641. return FramingBehavior;
  8642. }());
  8643. /***/ }),
  8644. /***/ "./Behaviors/Cameras/index.ts":
  8645. /*!************************************!*\
  8646. !*** ./Behaviors/Cameras/index.ts ***!
  8647. \************************************/
  8648. /*! exports provided: AutoRotationBehavior, BouncingBehavior, FramingBehavior */
  8649. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8650. "use strict";
  8651. __webpack_require__.r(__webpack_exports__);
  8652. /* harmony import */ var _autoRotationBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./autoRotationBehavior */ "./Behaviors/Cameras/autoRotationBehavior.ts");
  8653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _autoRotationBehavior__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  8654. /* harmony import */ var _bouncingBehavior__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./bouncingBehavior */ "./Behaviors/Cameras/bouncingBehavior.ts");
  8655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _bouncingBehavior__WEBPACK_IMPORTED_MODULE_1__["BouncingBehavior"]; });
  8656. /* harmony import */ var _framingBehavior__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./framingBehavior */ "./Behaviors/Cameras/framingBehavior.ts");
  8657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _framingBehavior__WEBPACK_IMPORTED_MODULE_2__["FramingBehavior"]; });
  8658. /***/ }),
  8659. /***/ "./Behaviors/Meshes/attachToBoxBehavior.ts":
  8660. /*!*************************************************!*\
  8661. !*** ./Behaviors/Meshes/attachToBoxBehavior.ts ***!
  8662. \*************************************************/
  8663. /*! exports provided: AttachToBoxBehavior */
  8664. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8665. "use strict";
  8666. __webpack_require__.r(__webpack_exports__);
  8667. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return AttachToBoxBehavior; });
  8668. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8669. /**
  8670. * @hidden
  8671. */
  8672. var FaceDirectionInfo = /** @class */ (function () {
  8673. function FaceDirectionInfo(direction, rotatedDirection, diff, ignore) {
  8674. if (rotatedDirection === void 0) { rotatedDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](); }
  8675. if (diff === void 0) { diff = 0; }
  8676. if (ignore === void 0) { ignore = false; }
  8677. this.direction = direction;
  8678. this.rotatedDirection = rotatedDirection;
  8679. this.diff = diff;
  8680. this.ignore = ignore;
  8681. }
  8682. return FaceDirectionInfo;
  8683. }());
  8684. /**
  8685. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  8686. */
  8687. var AttachToBoxBehavior = /** @class */ (function () {
  8688. /**
  8689. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  8690. * @param ui The transform node that should be attched to the mesh
  8691. */
  8692. function AttachToBoxBehavior(ui) {
  8693. this.ui = ui;
  8694. /**
  8695. * The name of the behavior
  8696. */
  8697. this.name = "AttachToBoxBehavior";
  8698. /**
  8699. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  8700. */
  8701. this.distanceAwayFromFace = 0.15;
  8702. /**
  8703. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  8704. */
  8705. this.distanceAwayFromBottomOfFace = 0.15;
  8706. this._faceVectors = [new FaceDirectionInfo(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up()), new FaceDirectionInfo(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Down()), new FaceDirectionInfo(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Left()), new FaceDirectionInfo(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Right()), new FaceDirectionInfo(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Forward()), new FaceDirectionInfo(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Forward().scaleInPlace(-1))];
  8707. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  8708. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  8709. this._zeroVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  8710. this._lookAtTmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  8711. /* Does nothing */
  8712. }
  8713. /**
  8714. * Initializes the behavior
  8715. */
  8716. AttachToBoxBehavior.prototype.init = function () {
  8717. /* Does nothing */
  8718. };
  8719. AttachToBoxBehavior.prototype._closestFace = function (targetDirection) {
  8720. var _this = this;
  8721. // Go over each face and calculate the angle between the face's normal and targetDirection
  8722. this._faceVectors.forEach(function (v) {
  8723. if (!_this._target.rotationQuaternion) {
  8724. _this._target.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(_this._target.rotation.y, _this._target.rotation.x, _this._target.rotation.z);
  8725. }
  8726. _this._target.rotationQuaternion.toRotationMatrix(_this._tmpMatrix);
  8727. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(v.direction, _this._tmpMatrix, v.rotatedDirection);
  8728. v.diff = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].GetAngleBetweenVectors(v.rotatedDirection, targetDirection, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(v.rotatedDirection, targetDirection));
  8729. });
  8730. // Return the face information of the one with the normal closeset to target direction
  8731. return this._faceVectors.reduce(function (min, p) {
  8732. if (min.ignore) {
  8733. return p;
  8734. }
  8735. else if (p.ignore) {
  8736. return min;
  8737. }
  8738. else {
  8739. return min.diff < p.diff ? min : p;
  8740. }
  8741. }, this._faceVectors[0]);
  8742. };
  8743. AttachToBoxBehavior.prototype._lookAtToRef = function (pos, up, ref) {
  8744. if (up === void 0) { up = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0); }
  8745. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LookAtLHToRef(this._zeroVector, pos, up, this._lookAtTmpMatrix);
  8746. this._lookAtTmpMatrix.invert();
  8747. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._lookAtTmpMatrix, ref);
  8748. };
  8749. /**
  8750. * Attaches the AttachToBoxBehavior to the passed in mesh
  8751. * @param target The mesh that the specified node will be attached to
  8752. */
  8753. AttachToBoxBehavior.prototype.attach = function (target) {
  8754. var _this = this;
  8755. this._target = target;
  8756. this._scene = this._target.getScene();
  8757. // Every frame, update the app bars position
  8758. this._onRenderObserver = this._scene.onBeforeRenderObservable.add(function () {
  8759. if (!_this._scene.activeCamera) {
  8760. return;
  8761. }
  8762. // Find the face closest to the cameras position
  8763. var cameraPos = _this._scene.activeCamera.position;
  8764. if (_this._scene.activeCamera.devicePosition) {
  8765. cameraPos = _this._scene.activeCamera.devicePosition;
  8766. }
  8767. var facing = _this._closestFace(cameraPos.subtract(target.position));
  8768. if (_this._scene.activeCamera.leftCamera) {
  8769. _this._scene.activeCamera.leftCamera.computeWorldMatrix().getRotationMatrixToRef(_this._tmpMatrix);
  8770. }
  8771. else {
  8772. _this._scene.activeCamera.computeWorldMatrix().getRotationMatrixToRef(_this._tmpMatrix);
  8773. }
  8774. // Get camera up direction
  8775. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), _this._tmpMatrix, _this._tmpVector);
  8776. // Ignore faces to not select a parrelel face for the up vector of the UI
  8777. _this._faceVectors.forEach(function (v) {
  8778. if (facing.direction.x && v.direction.x) {
  8779. v.ignore = true;
  8780. }
  8781. if (facing.direction.y && v.direction.y) {
  8782. v.ignore = true;
  8783. }
  8784. if (facing.direction.z && v.direction.z) {
  8785. v.ignore = true;
  8786. }
  8787. });
  8788. var facingUp = _this._closestFace(_this._tmpVector);
  8789. // Unignore faces
  8790. _this._faceVectors.forEach(function (v) {
  8791. v.ignore = false;
  8792. });
  8793. // Position the app bar on that face
  8794. _this.ui.position.copyFrom(target.position);
  8795. if (facing.direction.x) {
  8796. facing.rotatedDirection.scaleToRef((target.scaling.x / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8797. _this.ui.position.addInPlace(_this._tmpVector);
  8798. }
  8799. if (facing.direction.y) {
  8800. facing.rotatedDirection.scaleToRef((target.scaling.y / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8801. _this.ui.position.addInPlace(_this._tmpVector);
  8802. }
  8803. if (facing.direction.z) {
  8804. facing.rotatedDirection.scaleToRef((target.scaling.z / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8805. _this.ui.position.addInPlace(_this._tmpVector);
  8806. }
  8807. // Rotate to be oriented properly to the camera
  8808. if (!_this.ui.rotationQuaternion) {
  8809. _this.ui.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(_this.ui.rotation.y, _this.ui.rotation.x, _this.ui.rotation.z);
  8810. }
  8811. facing.rotatedDirection.scaleToRef(-1, _this._tmpVector);
  8812. _this._lookAtToRef(_this._tmpVector, facingUp.rotatedDirection, _this.ui.rotationQuaternion);
  8813. // Place ui the correct distance from the bottom of the mesh
  8814. if (facingUp.direction.x) {
  8815. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.x / 2, _this._tmpVector);
  8816. }
  8817. if (facingUp.direction.y) {
  8818. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.y / 2, _this._tmpVector);
  8819. }
  8820. if (facingUp.direction.z) {
  8821. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.z / 2, _this._tmpVector);
  8822. }
  8823. _this.ui.position.addInPlace(_this._tmpVector);
  8824. });
  8825. };
  8826. /**
  8827. * Detaches the behavior from the mesh
  8828. */
  8829. AttachToBoxBehavior.prototype.detach = function () {
  8830. this._scene.onBeforeRenderObservable.remove(this._onRenderObserver);
  8831. };
  8832. return AttachToBoxBehavior;
  8833. }());
  8834. /***/ }),
  8835. /***/ "./Behaviors/Meshes/fadeInOutBehavior.ts":
  8836. /*!***********************************************!*\
  8837. !*** ./Behaviors/Meshes/fadeInOutBehavior.ts ***!
  8838. \***********************************************/
  8839. /*! exports provided: FadeInOutBehavior */
  8840. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8841. "use strict";
  8842. __webpack_require__.r(__webpack_exports__);
  8843. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return FadeInOutBehavior; });
  8844. /**
  8845. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  8846. */
  8847. var FadeInOutBehavior = /** @class */ (function () {
  8848. /**
  8849. * Instatiates the FadeInOutBehavior
  8850. */
  8851. function FadeInOutBehavior() {
  8852. var _this = this;
  8853. /**
  8854. * Time in milliseconds to delay before fading in (Default: 0)
  8855. */
  8856. this.delay = 0;
  8857. /**
  8858. * Time in milliseconds for the mesh to fade in (Default: 300)
  8859. */
  8860. this.fadeInTime = 300;
  8861. this._millisecondsPerFrame = 1000 / 60;
  8862. this._hovered = false;
  8863. this._hoverValue = 0;
  8864. this._ownerNode = null;
  8865. this._update = function () {
  8866. if (_this._ownerNode) {
  8867. _this._hoverValue += _this._hovered ? _this._millisecondsPerFrame : -_this._millisecondsPerFrame;
  8868. _this._setAllVisibility(_this._ownerNode, (_this._hoverValue - _this.delay) / _this.fadeInTime);
  8869. if (_this._ownerNode.visibility > 1) {
  8870. _this._setAllVisibility(_this._ownerNode, 1);
  8871. _this._hoverValue = _this.fadeInTime + _this.delay;
  8872. return;
  8873. }
  8874. else if (_this._ownerNode.visibility < 0) {
  8875. _this._setAllVisibility(_this._ownerNode, 0);
  8876. if (_this._hoverValue < 0) {
  8877. _this._hoverValue = 0;
  8878. return;
  8879. }
  8880. }
  8881. setTimeout(_this._update, _this._millisecondsPerFrame);
  8882. }
  8883. };
  8884. }
  8885. Object.defineProperty(FadeInOutBehavior.prototype, "name", {
  8886. /**
  8887. * The name of the behavior
  8888. */
  8889. get: function () {
  8890. return "FadeInOut";
  8891. },
  8892. enumerable: true,
  8893. configurable: true
  8894. });
  8895. /**
  8896. * Initializes the behavior
  8897. */
  8898. FadeInOutBehavior.prototype.init = function () {
  8899. };
  8900. /**
  8901. * Attaches the fade behavior on the passed in mesh
  8902. * @param ownerNode The mesh that will be faded in/out once attached
  8903. */
  8904. FadeInOutBehavior.prototype.attach = function (ownerNode) {
  8905. this._ownerNode = ownerNode;
  8906. this._setAllVisibility(this._ownerNode, 0);
  8907. };
  8908. /**
  8909. * Detaches the behavior from the mesh
  8910. */
  8911. FadeInOutBehavior.prototype.detach = function () {
  8912. this._ownerNode = null;
  8913. };
  8914. /**
  8915. * Triggers the mesh to begin fading in or out
  8916. * @param value if the object should fade in or out (true to fade in)
  8917. */
  8918. FadeInOutBehavior.prototype.fadeIn = function (value) {
  8919. this._hovered = value;
  8920. this._update();
  8921. };
  8922. FadeInOutBehavior.prototype._setAllVisibility = function (mesh, value) {
  8923. var _this = this;
  8924. mesh.visibility = value;
  8925. mesh.getChildMeshes().forEach(function (c) {
  8926. _this._setAllVisibility(c, value);
  8927. });
  8928. };
  8929. return FadeInOutBehavior;
  8930. }());
  8931. /***/ }),
  8932. /***/ "./Behaviors/Meshes/index.ts":
  8933. /*!***********************************!*\
  8934. !*** ./Behaviors/Meshes/index.ts ***!
  8935. \***********************************/
  8936. /*! exports provided: AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior */
  8937. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8938. "use strict";
  8939. __webpack_require__.r(__webpack_exports__);
  8940. /* harmony import */ var _attachToBoxBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./attachToBoxBehavior */ "./Behaviors/Meshes/attachToBoxBehavior.ts");
  8941. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _attachToBoxBehavior__WEBPACK_IMPORTED_MODULE_0__["AttachToBoxBehavior"]; });
  8942. /* harmony import */ var _fadeInOutBehavior__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./fadeInOutBehavior */ "./Behaviors/Meshes/fadeInOutBehavior.ts");
  8943. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _fadeInOutBehavior__WEBPACK_IMPORTED_MODULE_1__["FadeInOutBehavior"]; });
  8944. /* harmony import */ var _multiPointerScaleBehavior__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./multiPointerScaleBehavior */ "./Behaviors/Meshes/multiPointerScaleBehavior.ts");
  8945. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _multiPointerScaleBehavior__WEBPACK_IMPORTED_MODULE_2__["MultiPointerScaleBehavior"]; });
  8946. /* harmony import */ var _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  8947. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_3__["PointerDragBehavior"]; });
  8948. /* harmony import */ var _sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./sixDofDragBehavior */ "./Behaviors/Meshes/sixDofDragBehavior.ts");
  8949. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_4__["SixDofDragBehavior"]; });
  8950. /***/ }),
  8951. /***/ "./Behaviors/Meshes/multiPointerScaleBehavior.ts":
  8952. /*!*******************************************************!*\
  8953. !*** ./Behaviors/Meshes/multiPointerScaleBehavior.ts ***!
  8954. \*******************************************************/
  8955. /*! exports provided: MultiPointerScaleBehavior */
  8956. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8957. "use strict";
  8958. __webpack_require__.r(__webpack_exports__);
  8959. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return MultiPointerScaleBehavior; });
  8960. /* harmony import */ var _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  8961. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8962. /**
  8963. * A behavior that when attached to a mesh will allow the mesh to be scaled
  8964. */
  8965. var MultiPointerScaleBehavior = /** @class */ (function () {
  8966. /**
  8967. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  8968. */
  8969. function MultiPointerScaleBehavior() {
  8970. this._startDistance = 0;
  8971. this._initialScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0);
  8972. this._targetScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0);
  8973. this._sceneRenderObserver = null;
  8974. this._dragBehaviorA = new _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]({});
  8975. this._dragBehaviorA.moveAttached = false;
  8976. this._dragBehaviorB = new _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]({});
  8977. this._dragBehaviorB.moveAttached = false;
  8978. }
  8979. Object.defineProperty(MultiPointerScaleBehavior.prototype, "name", {
  8980. /**
  8981. * The name of the behavior
  8982. */
  8983. get: function () {
  8984. return "MultiPointerScale";
  8985. },
  8986. enumerable: true,
  8987. configurable: true
  8988. });
  8989. /**
  8990. * Initializes the behavior
  8991. */
  8992. MultiPointerScaleBehavior.prototype.init = function () { };
  8993. MultiPointerScaleBehavior.prototype._getCurrentDistance = function () {
  8994. return this._dragBehaviorA.lastDragPosition.subtract(this._dragBehaviorB.lastDragPosition).length();
  8995. };
  8996. /**
  8997. * Attaches the scale behavior the passed in mesh
  8998. * @param ownerNode The mesh that will be scaled around once attached
  8999. */
  9000. MultiPointerScaleBehavior.prototype.attach = function (ownerNode) {
  9001. var _this = this;
  9002. this._ownerNode = ownerNode;
  9003. // Create 2 drag behaviors such that each will only be triggered by a separate pointer
  9004. this._dragBehaviorA.onDragStartObservable.add(function (e) {
  9005. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9006. if (_this._dragBehaviorA.currentDraggingPointerID == _this._dragBehaviorB.currentDraggingPointerID) {
  9007. _this._dragBehaviorA.releaseDrag();
  9008. }
  9009. else {
  9010. _this._initialScale.copyFrom(ownerNode.scaling);
  9011. _this._startDistance = _this._getCurrentDistance();
  9012. }
  9013. }
  9014. });
  9015. this._dragBehaviorB.onDragStartObservable.add(function (e) {
  9016. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9017. if (_this._dragBehaviorA.currentDraggingPointerID == _this._dragBehaviorB.currentDraggingPointerID) {
  9018. _this._dragBehaviorB.releaseDrag();
  9019. }
  9020. else {
  9021. _this._initialScale.copyFrom(ownerNode.scaling);
  9022. _this._startDistance = _this._getCurrentDistance();
  9023. }
  9024. }
  9025. });
  9026. // Once both drag behaviors are active scale based on the distance between the two pointers
  9027. [this._dragBehaviorA, this._dragBehaviorB].forEach(function (behavior) {
  9028. behavior.onDragObservable.add(function () {
  9029. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9030. var ratio = _this._getCurrentDistance() / _this._startDistance;
  9031. _this._initialScale.scaleToRef(ratio, _this._targetScale);
  9032. }
  9033. });
  9034. });
  9035. ownerNode.addBehavior(this._dragBehaviorA);
  9036. ownerNode.addBehavior(this._dragBehaviorB);
  9037. // On every frame move towards target scaling to avoid jitter caused by vr controllers
  9038. this._sceneRenderObserver = ownerNode.getScene().onBeforeRenderObservable.add(function () {
  9039. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9040. var change = _this._targetScale.subtract(ownerNode.scaling).scaleInPlace(0.1);
  9041. if (change.length() > 0.01) {
  9042. ownerNode.scaling.addInPlace(change);
  9043. }
  9044. }
  9045. });
  9046. };
  9047. /**
  9048. * Detaches the behavior from the mesh
  9049. */
  9050. MultiPointerScaleBehavior.prototype.detach = function () {
  9051. var _this = this;
  9052. this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver);
  9053. [this._dragBehaviorA, this._dragBehaviorB].forEach(function (behavior) {
  9054. behavior.onDragStartObservable.clear();
  9055. behavior.onDragObservable.clear();
  9056. _this._ownerNode.removeBehavior(behavior);
  9057. });
  9058. };
  9059. return MultiPointerScaleBehavior;
  9060. }());
  9061. /***/ }),
  9062. /***/ "./Behaviors/Meshes/pointerDragBehavior.ts":
  9063. /*!*************************************************!*\
  9064. !*** ./Behaviors/Meshes/pointerDragBehavior.ts ***!
  9065. \*************************************************/
  9066. /*! exports provided: PointerDragBehavior */
  9067. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9068. "use strict";
  9069. __webpack_require__.r(__webpack_exports__);
  9070. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return PointerDragBehavior; });
  9071. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  9072. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  9073. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  9074. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  9075. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  9076. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  9077. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/pivotTools */ "./Misc/pivotTools.ts");
  9078. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  9079. /**
  9080. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  9081. */
  9082. var PointerDragBehavior = /** @class */ (function () {
  9083. /**
  9084. * Creates a pointer drag behavior that can be attached to a mesh
  9085. * @param options The drag axis or normal of the plane that will be dragged across. If no options are specified the drag plane will always face the ray's origin (eg. camera)
  9086. */
  9087. function PointerDragBehavior(options) {
  9088. this._useAlternatePickedPointAboveMaxDragAngleDragSpeed = -1.1;
  9089. /**
  9090. * The maximum tolerated angle between the drag plane and dragging pointer rays to trigger pointer events. Set to 0 to allow any angle (default: 0)
  9091. */
  9092. this.maxDragAngle = 0;
  9093. /**
  9094. * @hidden
  9095. */
  9096. this._useAlternatePickedPointAboveMaxDragAngle = false;
  9097. /**
  9098. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  9099. */
  9100. this.currentDraggingPointerID = -1;
  9101. /**
  9102. * If the behavior is currently in a dragging state
  9103. */
  9104. this.dragging = false;
  9105. /**
  9106. * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)
  9107. */
  9108. this.dragDeltaRatio = 0.2;
  9109. /**
  9110. * If the drag plane orientation should be updated during the dragging (Default: true)
  9111. */
  9112. this.updateDragPlane = true;
  9113. // Debug mode will display drag planes to help visualize behavior
  9114. this._debugMode = false;
  9115. this._moving = false;
  9116. /**
  9117. * Fires each time the attached mesh is dragged with the pointer
  9118. * * delta between last drag position and current drag position in world space
  9119. * * dragDistance along the drag axis
  9120. * * dragPlaneNormal normal of the current drag plane used during the drag
  9121. * * dragPlanePoint in world space where the drag intersects the drag plane
  9122. */
  9123. this.onDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  9124. /**
  9125. * Fires each time a drag begins (eg. mouse down on mesh)
  9126. */
  9127. this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  9128. /**
  9129. * Fires each time a drag ends (eg. mouse release after drag)
  9130. */
  9131. this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  9132. /**
  9133. * If the attached mesh should be moved when dragged
  9134. */
  9135. this.moveAttached = true;
  9136. /**
  9137. * If the drag behavior will react to drag events (Default: true)
  9138. */
  9139. this.enabled = true;
  9140. /**
  9141. * If camera controls should be detached during the drag
  9142. */
  9143. this.detachCameraControls = true;
  9144. /**
  9145. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  9146. */
  9147. this.useObjectOrienationForDragging = true;
  9148. /**
  9149. * Predicate to determine if it is valid to move the object to a new position when it is moved
  9150. */
  9151. this.validateDrag = function (targetPosition) { return true; };
  9152. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9153. this._alternatePickedPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9154. this._worldDragAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9155. this._targetPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9156. this._attachedElement = null;
  9157. this._startDragRay = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]());
  9158. this._lastPointerRay = {};
  9159. this._dragDelta = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  9160. // Variables to avoid instantiation in the below method
  9161. this._pointA = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9162. this._pointB = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9163. this._pointC = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9164. this._lineA = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9165. this._lineB = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9166. this._localAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9167. this._lookAt = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9168. this._options = options ? options : {};
  9169. var optionCount = 0;
  9170. if (this._options.dragAxis) {
  9171. optionCount++;
  9172. }
  9173. if (this._options.dragPlaneNormal) {
  9174. optionCount++;
  9175. }
  9176. if (optionCount > 1) {
  9177. throw "Multiple drag modes specified in dragBehavior options. Only one expected";
  9178. }
  9179. }
  9180. Object.defineProperty(PointerDragBehavior.prototype, "name", {
  9181. /**
  9182. * The name of the behavior
  9183. */
  9184. get: function () {
  9185. return "PointerDrag";
  9186. },
  9187. enumerable: true,
  9188. configurable: true
  9189. });
  9190. /**
  9191. * Initializes the behavior
  9192. */
  9193. PointerDragBehavior.prototype.init = function () { };
  9194. /**
  9195. * Attaches the drag behavior the passed in mesh
  9196. * @param ownerNode The mesh that will be dragged around once attached
  9197. */
  9198. PointerDragBehavior.prototype.attach = function (ownerNode) {
  9199. var _this = this;
  9200. this._scene = ownerNode.getScene();
  9201. this._attachedNode = ownerNode;
  9202. // Initialize drag plane to not interfere with existing scene
  9203. if (!PointerDragBehavior._planeScene) {
  9204. if (this._debugMode) {
  9205. PointerDragBehavior._planeScene = this._scene;
  9206. }
  9207. else {
  9208. PointerDragBehavior._planeScene = new _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"](this._scene.getEngine());
  9209. PointerDragBehavior._planeScene.detachControl();
  9210. this._scene.getEngine().scenes.pop();
  9211. this._scene.onDisposeObservable.addOnce(function () {
  9212. PointerDragBehavior._planeScene.dispose();
  9213. PointerDragBehavior._planeScene = null;
  9214. });
  9215. }
  9216. }
  9217. this._dragPlane = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreatePlane("pointerDragPlane", this._debugMode ? 1 : 10000, PointerDragBehavior._planeScene, false, _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].DOUBLESIDE);
  9218. // State of the drag
  9219. this.lastDragPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9220. var pickPredicate = function (m) {
  9221. return _this._attachedNode == m || m.isDescendantOf(_this._attachedNode);
  9222. };
  9223. this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
  9224. if (!_this.enabled) {
  9225. return;
  9226. }
  9227. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOWN) {
  9228. if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.pickedPoint && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
  9229. _this._startDrag(pointerInfo.event.pointerId, pointerInfo.pickInfo.ray, pointerInfo.pickInfo.pickedPoint);
  9230. }
  9231. }
  9232. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERUP) {
  9233. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId) {
  9234. _this.releaseDrag();
  9235. }
  9236. }
  9237. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE) {
  9238. var pointerId = pointerInfo.event.pointerId;
  9239. // If drag was started with anyMouseID specified, set pointerID to the next mouse that moved
  9240. if (_this.currentDraggingPointerID === PointerDragBehavior._AnyMouseID && pointerId !== PointerDragBehavior._AnyMouseID && pointerInfo.event.pointerType == "mouse") {
  9241. if (_this._lastPointerRay[_this.currentDraggingPointerID]) {
  9242. _this._lastPointerRay[pointerId] = _this._lastPointerRay[_this.currentDraggingPointerID];
  9243. delete _this._lastPointerRay[_this.currentDraggingPointerID];
  9244. }
  9245. _this.currentDraggingPointerID = pointerId;
  9246. }
  9247. // Keep track of last pointer ray, this is used simulating the start of a drag in startDrag()
  9248. if (!_this._lastPointerRay[pointerId]) {
  9249. _this._lastPointerRay[pointerId] = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]());
  9250. }
  9251. if (pointerInfo.pickInfo && pointerInfo.pickInfo.ray) {
  9252. _this._lastPointerRay[pointerId].origin.copyFrom(pointerInfo.pickInfo.ray.origin);
  9253. _this._lastPointerRay[pointerId].direction.copyFrom(pointerInfo.pickInfo.ray.direction);
  9254. if (_this.currentDraggingPointerID == pointerId && _this.dragging) {
  9255. _this._moveDrag(pointerInfo.pickInfo.ray);
  9256. }
  9257. }
  9258. }
  9259. });
  9260. this._beforeRenderObserver = this._scene.onBeforeRenderObservable.add(function () {
  9261. if (_this._moving && _this.moveAttached) {
  9262. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(_this._attachedNode);
  9263. // Slowly move mesh to avoid jitter
  9264. _this._targetPosition.subtractToRef((_this._attachedNode).absolutePosition, _this._tmpVector);
  9265. _this._tmpVector.scaleInPlace(_this.dragDeltaRatio);
  9266. (_this._attachedNode).getAbsolutePosition().addToRef(_this._tmpVector, _this._tmpVector);
  9267. if (_this.validateDrag(_this._tmpVector)) {
  9268. (_this._attachedNode).setAbsolutePosition(_this._tmpVector);
  9269. }
  9270. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(_this._attachedNode);
  9271. }
  9272. });
  9273. };
  9274. /**
  9275. * Force relase the drag action by code.
  9276. */
  9277. PointerDragBehavior.prototype.releaseDrag = function () {
  9278. this.dragging = false;
  9279. this.onDragEndObservable.notifyObservers({ dragPlanePoint: this.lastDragPosition, pointerId: this.currentDraggingPointerID });
  9280. this.currentDraggingPointerID = -1;
  9281. this._moving = false;
  9282. // Reattach camera controls
  9283. if (this.detachCameraControls && this._attachedElement && this._scene.activeCamera && !this._scene.activeCamera.leftCamera) {
  9284. this._scene.activeCamera.attachControl(this._attachedElement, true);
  9285. }
  9286. };
  9287. /**
  9288. * Simulates the start of a pointer drag event on the behavior
  9289. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  9290. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  9291. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  9292. */
  9293. PointerDragBehavior.prototype.startDrag = function (pointerId, fromRay, startPickedPoint) {
  9294. if (pointerId === void 0) { pointerId = PointerDragBehavior._AnyMouseID; }
  9295. this._startDrag(pointerId, fromRay, startPickedPoint);
  9296. var lastRay = this._lastPointerRay[pointerId];
  9297. if (pointerId === PointerDragBehavior._AnyMouseID) {
  9298. lastRay = this._lastPointerRay[Object.keys(this._lastPointerRay)[0]];
  9299. }
  9300. if (lastRay) {
  9301. // if there was a last pointer ray drag the object there
  9302. this._moveDrag(lastRay);
  9303. }
  9304. };
  9305. PointerDragBehavior.prototype._startDrag = function (pointerId, fromRay, startPickedPoint) {
  9306. if (!this._scene.activeCamera || this.dragging || !this._attachedNode) {
  9307. return;
  9308. }
  9309. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(this._attachedNode);
  9310. // Create start ray from the camera to the object
  9311. if (fromRay) {
  9312. this._startDragRay.direction.copyFrom(fromRay.direction);
  9313. this._startDragRay.origin.copyFrom(fromRay.origin);
  9314. }
  9315. else {
  9316. this._startDragRay.origin.copyFrom(this._scene.activeCamera.position);
  9317. this._attachedNode.getWorldMatrix().getTranslationToRef(this._tmpVector);
  9318. this._tmpVector.subtractToRef(this._scene.activeCamera.position, this._startDragRay.direction);
  9319. }
  9320. this._updateDragPlanePosition(this._startDragRay, startPickedPoint ? startPickedPoint : this._tmpVector);
  9321. var pickedPoint = this._pickWithRayOnDragPlane(this._startDragRay);
  9322. if (pickedPoint) {
  9323. this.dragging = true;
  9324. this.currentDraggingPointerID = pointerId;
  9325. this.lastDragPosition.copyFrom(pickedPoint);
  9326. this.onDragStartObservable.notifyObservers({ dragPlanePoint: pickedPoint, pointerId: this.currentDraggingPointerID });
  9327. this._targetPosition.copyFrom((this._attachedNode).absolutePosition);
  9328. // Detatch camera controls
  9329. if (this.detachCameraControls && this._scene.activeCamera && !this._scene.activeCamera.leftCamera) {
  9330. if (this._scene.activeCamera.inputs.attachedElement) {
  9331. this._attachedElement = this._scene.activeCamera.inputs.attachedElement;
  9332. this._scene.activeCamera.detachControl(this._scene.activeCamera.inputs.attachedElement);
  9333. }
  9334. else {
  9335. this._attachedElement = null;
  9336. }
  9337. }
  9338. }
  9339. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(this._attachedNode);
  9340. };
  9341. PointerDragBehavior.prototype._moveDrag = function (ray) {
  9342. this._moving = true;
  9343. var pickedPoint = this._pickWithRayOnDragPlane(ray);
  9344. if (pickedPoint) {
  9345. if (this.updateDragPlane) {
  9346. this._updateDragPlanePosition(ray, pickedPoint);
  9347. }
  9348. var dragLength = 0;
  9349. // depending on the drag mode option drag accordingly
  9350. if (this._options.dragAxis) {
  9351. // Convert local drag axis to world
  9352. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._options.dragAxis, this._attachedNode.getWorldMatrix().getRotationMatrix(), this._worldDragAxis);
  9353. // Project delta drag from the drag plane onto the drag axis
  9354. pickedPoint.subtractToRef(this.lastDragPosition, this._tmpVector);
  9355. dragLength = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._tmpVector, this._worldDragAxis);
  9356. this._worldDragAxis.scaleToRef(dragLength, this._dragDelta);
  9357. }
  9358. else {
  9359. dragLength = this._dragDelta.length();
  9360. pickedPoint.subtractToRef(this.lastDragPosition, this._dragDelta);
  9361. }
  9362. this._targetPosition.addInPlace(this._dragDelta);
  9363. this.onDragObservable.notifyObservers({ dragDistance: dragLength, delta: this._dragDelta, dragPlanePoint: pickedPoint, dragPlaneNormal: this._dragPlane.forward, pointerId: this.currentDraggingPointerID });
  9364. this.lastDragPosition.copyFrom(pickedPoint);
  9365. }
  9366. };
  9367. PointerDragBehavior.prototype._pickWithRayOnDragPlane = function (ray) {
  9368. var _this = this;
  9369. if (!ray) {
  9370. return null;
  9371. }
  9372. // Calculate angle between plane normal and ray
  9373. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._dragPlane.forward, ray.direction));
  9374. // Correct if ray is casted from oposite side
  9375. if (angle > Math.PI / 2) {
  9376. angle = Math.PI - angle;
  9377. }
  9378. // If the angle is too perpendicular to the plane pick another point on the plane where it is looking
  9379. if (this.maxDragAngle > 0 && angle > this.maxDragAngle) {
  9380. if (this._useAlternatePickedPointAboveMaxDragAngle) {
  9381. // Invert ray direction along the towards object axis
  9382. this._tmpVector.copyFrom(ray.direction);
  9383. (this._attachedNode).absolutePosition.subtractToRef(ray.origin, this._alternatePickedPoint);
  9384. this._alternatePickedPoint.normalize();
  9385. this._alternatePickedPoint.scaleInPlace(this._useAlternatePickedPointAboveMaxDragAngleDragSpeed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._alternatePickedPoint, this._tmpVector));
  9386. this._tmpVector.addInPlace(this._alternatePickedPoint);
  9387. // Project resulting vector onto the drag plane and add it to the attached nodes absolute position to get a picked point
  9388. var dot = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._dragPlane.forward, this._tmpVector);
  9389. this._dragPlane.forward.scaleToRef(-dot, this._alternatePickedPoint);
  9390. this._alternatePickedPoint.addInPlace(this._tmpVector);
  9391. this._alternatePickedPoint.addInPlace((this._attachedNode).absolutePosition);
  9392. return this._alternatePickedPoint;
  9393. }
  9394. else {
  9395. return null;
  9396. }
  9397. }
  9398. var pickResult = PointerDragBehavior._planeScene.pickWithRay(ray, function (m) { return m == _this._dragPlane; });
  9399. if (pickResult && pickResult.hit && pickResult.pickedMesh && pickResult.pickedPoint) {
  9400. return pickResult.pickedPoint;
  9401. }
  9402. else {
  9403. return null;
  9404. }
  9405. };
  9406. // Position the drag plane based on the attached mesh position, for single axis rotate the plane along the axis to face the camera
  9407. PointerDragBehavior.prototype._updateDragPlanePosition = function (ray, dragPlanePosition) {
  9408. this._pointA.copyFrom(dragPlanePosition);
  9409. if (this._options.dragAxis) {
  9410. this.useObjectOrienationForDragging ? _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._options.dragAxis, this._attachedNode.getWorldMatrix().getRotationMatrix(), this._localAxis) : this._localAxis.copyFrom(this._options.dragAxis);
  9411. // Calculate plane normal in direction of camera but perpendicular to drag axis
  9412. this._pointA.addToRef(this._localAxis, this._pointB); // towards drag axis
  9413. ray.origin.subtractToRef(this._pointA, this._pointC);
  9414. this._pointA.addToRef(this._pointC.normalize(), this._pointC); // towards camera
  9415. // Get perpendicular line from direction to camera and drag axis
  9416. this._pointB.subtractToRef(this._pointA, this._lineA);
  9417. this._pointC.subtractToRef(this._pointA, this._lineB);
  9418. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(this._lineA, this._lineB, this._lookAt);
  9419. // Get perpendicular line from previous result and drag axis to adjust lineB to be perpendiculat to camera
  9420. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(this._lineA, this._lookAt, this._lookAt);
  9421. this._lookAt.normalize();
  9422. this._dragPlane.position.copyFrom(this._pointA);
  9423. this._pointA.addToRef(this._lookAt, this._lookAt);
  9424. this._dragPlane.lookAt(this._lookAt);
  9425. }
  9426. else if (this._options.dragPlaneNormal) {
  9427. this.useObjectOrienationForDragging ? _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._options.dragPlaneNormal, this._attachedNode.getWorldMatrix().getRotationMatrix(), this._localAxis) : this._localAxis.copyFrom(this._options.dragPlaneNormal);
  9428. this._dragPlane.position.copyFrom(this._pointA);
  9429. this._pointA.addToRef(this._localAxis, this._lookAt);
  9430. this._dragPlane.lookAt(this._lookAt);
  9431. }
  9432. else {
  9433. this._dragPlane.position.copyFrom(this._pointA);
  9434. this._dragPlane.lookAt(ray.origin);
  9435. }
  9436. // Update the position of the drag plane so it doesn't get out of sync with the node (eg. when moving back and forth quickly)
  9437. this._dragPlane.position.copyFrom(this._attachedNode.absolutePosition);
  9438. this._dragPlane.computeWorldMatrix(true);
  9439. };
  9440. /**
  9441. * Detaches the behavior from the mesh
  9442. */
  9443. PointerDragBehavior.prototype.detach = function () {
  9444. if (this._pointerObserver) {
  9445. this._scene.onPointerObservable.remove(this._pointerObserver);
  9446. }
  9447. if (this._beforeRenderObserver) {
  9448. this._scene.onBeforeRenderObservable.remove(this._beforeRenderObserver);
  9449. }
  9450. };
  9451. PointerDragBehavior._AnyMouseID = -2;
  9452. return PointerDragBehavior;
  9453. }());
  9454. /***/ }),
  9455. /***/ "./Behaviors/Meshes/sixDofDragBehavior.ts":
  9456. /*!************************************************!*\
  9457. !*** ./Behaviors/Meshes/sixDofDragBehavior.ts ***!
  9458. \************************************************/
  9459. /*! exports provided: SixDofDragBehavior */
  9460. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9461. "use strict";
  9462. __webpack_require__.r(__webpack_exports__);
  9463. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return SixDofDragBehavior; });
  9464. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  9465. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  9466. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  9467. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  9468. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  9469. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  9470. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/pivotTools */ "./Misc/pivotTools.ts");
  9471. /**
  9472. * A behavior that when attached to a mesh will allow the mesh to be dragged around based on directions and origin of the pointer's ray
  9473. */
  9474. var SixDofDragBehavior = /** @class */ (function () {
  9475. /**
  9476. * Instantiates a behavior that when attached to a mesh will allow the mesh to be dragged around based on directions and origin of the pointer's ray
  9477. */
  9478. function SixDofDragBehavior() {
  9479. this._sceneRenderObserver = null;
  9480. this._targetPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9481. this._moving = false;
  9482. this._startingOrientation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9483. /**
  9484. * How much faster the object should move when the controller is moving towards it. This is useful to bring objects that are far away from the user to them faster. Set this to 0 to avoid any speed increase. (Default: 3)
  9485. */
  9486. this.zDragFactor = 3;
  9487. /**
  9488. * If the object should rotate to face the drag origin
  9489. */
  9490. this.rotateDraggedObject = true;
  9491. /**
  9492. * If the behavior is currently in a dragging state
  9493. */
  9494. this.dragging = false;
  9495. /**
  9496. * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)
  9497. */
  9498. this.dragDeltaRatio = 0.2;
  9499. /**
  9500. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  9501. */
  9502. this.currentDraggingPointerID = -1;
  9503. /**
  9504. * If camera controls should be detached during the drag
  9505. */
  9506. this.detachCameraControls = true;
  9507. /**
  9508. * Fires each time a drag starts
  9509. */
  9510. this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  9511. /**
  9512. * Fires each time a drag ends (eg. mouse release after drag)
  9513. */
  9514. this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  9515. }
  9516. Object.defineProperty(SixDofDragBehavior.prototype, "name", {
  9517. /**
  9518. * The name of the behavior
  9519. */
  9520. get: function () {
  9521. return "SixDofDrag";
  9522. },
  9523. enumerable: true,
  9524. configurable: true
  9525. });
  9526. /**
  9527. * Initializes the behavior
  9528. */
  9529. SixDofDragBehavior.prototype.init = function () { };
  9530. /**
  9531. * Attaches the scale behavior the passed in mesh
  9532. * @param ownerNode The mesh that will be scaled around once attached
  9533. */
  9534. SixDofDragBehavior.prototype.attach = function (ownerNode) {
  9535. var _this = this;
  9536. this._ownerNode = ownerNode;
  9537. this._scene = this._ownerNode.getScene();
  9538. if (!SixDofDragBehavior._virtualScene) {
  9539. SixDofDragBehavior._virtualScene = new _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"](this._scene.getEngine());
  9540. SixDofDragBehavior._virtualScene.detachControl();
  9541. this._scene.getEngine().scenes.pop();
  9542. }
  9543. var pickedMesh = null;
  9544. var lastSixDofOriginPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9545. // Setup virtual meshes to be used for dragging without dirtying the existing scene
  9546. this._virtualOriginMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]("", SixDofDragBehavior._virtualScene);
  9547. this._virtualOriginMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9548. this._virtualDragMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]("", SixDofDragBehavior._virtualScene);
  9549. this._virtualDragMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9550. var pickPredicate = function (m) {
  9551. return _this._ownerNode == m || m.isDescendantOf(_this._ownerNode);
  9552. };
  9553. var attachedElement = null;
  9554. this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
  9555. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  9556. if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
  9557. if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].RIG_MODE_NONE) {
  9558. pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.globalPosition);
  9559. }
  9560. pickedMesh = _this._ownerNode;
  9561. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(pickedMesh);
  9562. lastSixDofOriginPosition.copyFrom(pointerInfo.pickInfo.ray.origin);
  9563. // Set position and orientation of the controller
  9564. _this._virtualOriginMesh.position.copyFrom(pointerInfo.pickInfo.ray.origin);
  9565. _this._virtualOriginMesh.lookAt(pointerInfo.pickInfo.ray.origin.add(pointerInfo.pickInfo.ray.direction));
  9566. // Attach the virtual drag mesh to the virtual origin mesh so it can be dragged
  9567. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9568. pickedMesh.computeWorldMatrix();
  9569. _this._virtualDragMesh.position.copyFrom(pickedMesh.absolutePosition);
  9570. if (!pickedMesh.rotationQuaternion) {
  9571. pickedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(pickedMesh.rotation.y, pickedMesh.rotation.x, pickedMesh.rotation.z);
  9572. }
  9573. var oldParent = pickedMesh.parent;
  9574. pickedMesh.setParent(null);
  9575. _this._virtualDragMesh.rotationQuaternion.copyFrom(pickedMesh.rotationQuaternion);
  9576. pickedMesh.setParent(oldParent);
  9577. _this._virtualOriginMesh.addChild(_this._virtualDragMesh);
  9578. // Update state
  9579. _this._targetPosition.copyFrom(_this._virtualDragMesh.absolutePosition);
  9580. _this.dragging = true;
  9581. _this.currentDraggingPointerID = pointerInfo.event.pointerId;
  9582. // Detatch camera controls
  9583. if (_this.detachCameraControls && _this._scene.activeCamera && !_this._scene.activeCamera.leftCamera) {
  9584. if (_this._scene.activeCamera.inputs.attachedElement) {
  9585. attachedElement = _this._scene.activeCamera.inputs.attachedElement;
  9586. _this._scene.activeCamera.detachControl(_this._scene.activeCamera.inputs.attachedElement);
  9587. }
  9588. else {
  9589. attachedElement = null;
  9590. }
  9591. }
  9592. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(pickedMesh);
  9593. _this.onDragStartObservable.notifyObservers({});
  9594. }
  9595. }
  9596. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP) {
  9597. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId) {
  9598. _this.dragging = false;
  9599. _this._moving = false;
  9600. _this.currentDraggingPointerID = -1;
  9601. pickedMesh = null;
  9602. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9603. // Reattach camera controls
  9604. if (_this.detachCameraControls && attachedElement && _this._scene.activeCamera && !_this._scene.activeCamera.leftCamera) {
  9605. _this._scene.activeCamera.attachControl(attachedElement, true);
  9606. }
  9607. _this.onDragEndObservable.notifyObservers({});
  9608. }
  9609. }
  9610. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERMOVE) {
  9611. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId && _this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.ray && pickedMesh) {
  9612. var zDragFactor = _this.zDragFactor;
  9613. if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].RIG_MODE_NONE) {
  9614. pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.globalPosition);
  9615. zDragFactor = 0;
  9616. }
  9617. // Calculate controller drag distance in controller space
  9618. var originDragDifference = pointerInfo.pickInfo.ray.origin.subtract(lastSixDofOriginPosition);
  9619. lastSixDofOriginPosition.copyFrom(pointerInfo.pickInfo.ray.origin);
  9620. var localOriginDragDifference = -_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(originDragDifference, pointerInfo.pickInfo.ray.direction);
  9621. _this._virtualOriginMesh.addChild(_this._virtualDragMesh);
  9622. // Determine how much the controller moved to/away towards the dragged object and use this to move the object further when its further away
  9623. _this._virtualDragMesh.position.z -= _this._virtualDragMesh.position.z < 1 ? localOriginDragDifference * _this.zDragFactor : localOriginDragDifference * zDragFactor * _this._virtualDragMesh.position.z;
  9624. if (_this._virtualDragMesh.position.z < 0) {
  9625. _this._virtualDragMesh.position.z = 0;
  9626. }
  9627. // Update the controller position
  9628. _this._virtualOriginMesh.position.copyFrom(pointerInfo.pickInfo.ray.origin);
  9629. _this._virtualOriginMesh.lookAt(pointerInfo.pickInfo.ray.origin.add(pointerInfo.pickInfo.ray.direction));
  9630. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9631. // Move the virtualObjectsPosition into the picked mesh's space if needed
  9632. _this._targetPosition.copyFrom(_this._virtualDragMesh.absolutePosition);
  9633. if (pickedMesh.parent) {
  9634. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._targetPosition, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(pickedMesh.parent.getWorldMatrix()), _this._targetPosition);
  9635. }
  9636. if (!_this._moving) {
  9637. _this._startingOrientation.copyFrom(_this._virtualDragMesh.rotationQuaternion);
  9638. }
  9639. _this._moving = true;
  9640. }
  9641. }
  9642. });
  9643. var tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9644. // On every frame move towards target scaling to avoid jitter caused by vr controllers
  9645. this._sceneRenderObserver = ownerNode.getScene().onBeforeRenderObservable.add(function () {
  9646. if (_this.dragging && _this._moving && pickedMesh) {
  9647. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(pickedMesh);
  9648. // Slowly move mesh to avoid jitter
  9649. pickedMesh.position.addInPlace(_this._targetPosition.subtract(pickedMesh.position).scale(_this.dragDeltaRatio));
  9650. if (_this.rotateDraggedObject) {
  9651. // Get change in rotation
  9652. tmpQuaternion.copyFrom(_this._startingOrientation);
  9653. tmpQuaternion.x = -tmpQuaternion.x;
  9654. tmpQuaternion.y = -tmpQuaternion.y;
  9655. tmpQuaternion.z = -tmpQuaternion.z;
  9656. _this._virtualDragMesh.rotationQuaternion.multiplyToRef(tmpQuaternion, tmpQuaternion);
  9657. // Convert change in rotation to only y axis rotation
  9658. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(tmpQuaternion.toEulerAngles("xyz").y, 0, 0, tmpQuaternion);
  9659. tmpQuaternion.multiplyToRef(_this._startingOrientation, tmpQuaternion);
  9660. // Slowly move mesh to avoid jitter
  9661. var oldParent = pickedMesh.parent;
  9662. // Only rotate the mesh if it's parent has uniform scaling
  9663. if (!oldParent || (oldParent.scaling && !oldParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  9664. pickedMesh.setParent(null);
  9665. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(pickedMesh.rotationQuaternion, tmpQuaternion, _this.dragDeltaRatio, pickedMesh.rotationQuaternion);
  9666. pickedMesh.setParent(oldParent);
  9667. }
  9668. }
  9669. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(pickedMesh);
  9670. }
  9671. });
  9672. };
  9673. /**
  9674. * Detaches the behavior from the mesh
  9675. */
  9676. SixDofDragBehavior.prototype.detach = function () {
  9677. if (this._scene) {
  9678. this._scene.onPointerObservable.remove(this._pointerObserver);
  9679. }
  9680. if (this._ownerNode) {
  9681. this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver);
  9682. }
  9683. if (this._virtualOriginMesh) {
  9684. this._virtualOriginMesh.dispose();
  9685. }
  9686. if (this._virtualDragMesh) {
  9687. this._virtualDragMesh.dispose();
  9688. }
  9689. this.onDragEndObservable.clear();
  9690. this.onDragStartObservable.clear();
  9691. };
  9692. return SixDofDragBehavior;
  9693. }());
  9694. /***/ }),
  9695. /***/ "./Behaviors/index.ts":
  9696. /*!****************************!*\
  9697. !*** ./Behaviors/index.ts ***!
  9698. \****************************/
  9699. /*! exports provided: AutoRotationBehavior, BouncingBehavior, FramingBehavior, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior */
  9700. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9701. "use strict";
  9702. __webpack_require__.r(__webpack_exports__);
  9703. /* harmony import */ var _Cameras_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Cameras/index */ "./Behaviors/Cameras/index.ts");
  9704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  9705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["BouncingBehavior"]; });
  9706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["FramingBehavior"]; });
  9707. /* harmony import */ var _Meshes_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Meshes/index */ "./Behaviors/Meshes/index.ts");
  9708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["AttachToBoxBehavior"]; });
  9709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["FadeInOutBehavior"]; });
  9710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["MultiPointerScaleBehavior"]; });
  9711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["PointerDragBehavior"]; });
  9712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["SixDofDragBehavior"]; });
  9713. /***/ }),
  9714. /***/ "./Bones/bone.ts":
  9715. /*!***********************!*\
  9716. !*** ./Bones/bone.ts ***!
  9717. \***********************/
  9718. /*! exports provided: Bone */
  9719. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9720. "use strict";
  9721. __webpack_require__.r(__webpack_exports__);
  9722. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return Bone; });
  9723. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  9724. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  9725. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  9726. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  9727. /**
  9728. * Class used to store bone information
  9729. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  9730. */
  9731. var Bone = /** @class */ (function (_super) {
  9732. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Bone, _super);
  9733. /**
  9734. * Create a new bone
  9735. * @param name defines the bone name
  9736. * @param skeleton defines the parent skeleton
  9737. * @param parentBone defines the parent (can be null if the bone is the root)
  9738. * @param localMatrix defines the local matrix
  9739. * @param restPose defines the rest pose matrix
  9740. * @param baseMatrix defines the base matrix
  9741. * @param index defines index of the bone in the hiearchy
  9742. */
  9743. function Bone(
  9744. /**
  9745. * defines the bone name
  9746. */
  9747. name, skeleton, parentBone, localMatrix, restPose, baseMatrix, index) {
  9748. if (parentBone === void 0) { parentBone = null; }
  9749. if (localMatrix === void 0) { localMatrix = null; }
  9750. if (restPose === void 0) { restPose = null; }
  9751. if (baseMatrix === void 0) { baseMatrix = null; }
  9752. if (index === void 0) { index = null; }
  9753. var _this = _super.call(this, name, skeleton.getScene(), false) || this;
  9754. _this.name = name;
  9755. /**
  9756. * Gets the list of child bones
  9757. */
  9758. _this.children = new Array();
  9759. /** Gets the animations associated with this bone */
  9760. _this.animations = new Array();
  9761. /**
  9762. * @hidden Internal only
  9763. * Set this value to map this bone to a different index in the transform matrices
  9764. * Set this value to -1 to exclude the bone from the transform matrices
  9765. */
  9766. _this._index = null;
  9767. _this._absoluteTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9768. _this._invertedAbsoluteTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9769. _this._scalingDeterminant = 1;
  9770. _this._worldTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9771. _this._needToDecompose = true;
  9772. _this._needToCompose = false;
  9773. /** @hidden */
  9774. _this._linkedTransformNode = null;
  9775. _this._skeleton = skeleton;
  9776. _this._localMatrix = localMatrix ? localMatrix.clone() : _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  9777. _this._restPose = restPose ? restPose : _this._localMatrix.clone();
  9778. _this._baseMatrix = baseMatrix ? baseMatrix : _this._localMatrix.clone();
  9779. _this._index = index;
  9780. skeleton.bones.push(_this);
  9781. _this.setParent(parentBone, false);
  9782. if (baseMatrix || localMatrix) {
  9783. _this._updateDifferenceMatrix();
  9784. }
  9785. return _this;
  9786. }
  9787. Object.defineProperty(Bone.prototype, "_matrix", {
  9788. /** @hidden */
  9789. get: function () {
  9790. this._compose();
  9791. return this._localMatrix;
  9792. },
  9793. /** @hidden */
  9794. set: function (value) {
  9795. this._localMatrix.copyFrom(value);
  9796. this._needToDecompose = true;
  9797. },
  9798. enumerable: true,
  9799. configurable: true
  9800. });
  9801. /**
  9802. * Gets the current object class name.
  9803. * @return the class name
  9804. */
  9805. Bone.prototype.getClassName = function () {
  9806. return "Bone";
  9807. };
  9808. // Members
  9809. /**
  9810. * Gets the parent skeleton
  9811. * @returns a skeleton
  9812. */
  9813. Bone.prototype.getSkeleton = function () {
  9814. return this._skeleton;
  9815. };
  9816. /**
  9817. * Gets parent bone
  9818. * @returns a bone or null if the bone is the root of the bone hierarchy
  9819. */
  9820. Bone.prototype.getParent = function () {
  9821. return this._parent;
  9822. };
  9823. /**
  9824. * Returns an array containing the root bones
  9825. * @returns an array containing the root bones
  9826. */
  9827. Bone.prototype.getChildren = function () {
  9828. return this.children;
  9829. };
  9830. /**
  9831. * Sets the parent bone
  9832. * @param parent defines the parent (can be null if the bone is the root)
  9833. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9834. */
  9835. Bone.prototype.setParent = function (parent, updateDifferenceMatrix) {
  9836. if (updateDifferenceMatrix === void 0) { updateDifferenceMatrix = true; }
  9837. if (this._parent === parent) {
  9838. return;
  9839. }
  9840. if (this._parent) {
  9841. var index = this._parent.children.indexOf(this);
  9842. if (index !== -1) {
  9843. this._parent.children.splice(index, 1);
  9844. }
  9845. }
  9846. this._parent = parent;
  9847. if (this._parent) {
  9848. this._parent.children.push(this);
  9849. }
  9850. if (updateDifferenceMatrix) {
  9851. this._updateDifferenceMatrix();
  9852. }
  9853. this.markAsDirty();
  9854. };
  9855. /**
  9856. * Gets the local matrix
  9857. * @returns a matrix
  9858. */
  9859. Bone.prototype.getLocalMatrix = function () {
  9860. this._compose();
  9861. return this._localMatrix;
  9862. };
  9863. /**
  9864. * Gets the base matrix (initial matrix which remains unchanged)
  9865. * @returns a matrix
  9866. */
  9867. Bone.prototype.getBaseMatrix = function () {
  9868. return this._baseMatrix;
  9869. };
  9870. /**
  9871. * Gets the rest pose matrix
  9872. * @returns a matrix
  9873. */
  9874. Bone.prototype.getRestPose = function () {
  9875. return this._restPose;
  9876. };
  9877. /**
  9878. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  9879. */
  9880. Bone.prototype.getWorldMatrix = function () {
  9881. return this._worldTransform;
  9882. };
  9883. /**
  9884. * Sets the local matrix to rest pose matrix
  9885. */
  9886. Bone.prototype.returnToRest = function () {
  9887. this.updateMatrix(this._restPose.clone());
  9888. };
  9889. /**
  9890. * Gets the inverse of the absolute transform matrix.
  9891. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  9892. * @returns a matrix
  9893. */
  9894. Bone.prototype.getInvertedAbsoluteTransform = function () {
  9895. return this._invertedAbsoluteTransform;
  9896. };
  9897. /**
  9898. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  9899. * @returns a matrix
  9900. */
  9901. Bone.prototype.getAbsoluteTransform = function () {
  9902. return this._absoluteTransform;
  9903. };
  9904. /**
  9905. * Links with the given transform node.
  9906. * The local matrix of this bone is copied from the transform node every frame.
  9907. * @param transformNode defines the transform node to link to
  9908. */
  9909. Bone.prototype.linkTransformNode = function (transformNode) {
  9910. if (this._linkedTransformNode) {
  9911. this._skeleton._numBonesWithLinkedTransformNode--;
  9912. }
  9913. this._linkedTransformNode = transformNode;
  9914. if (this._linkedTransformNode) {
  9915. this._skeleton._numBonesWithLinkedTransformNode++;
  9916. }
  9917. };
  9918. Object.defineProperty(Bone.prototype, "position", {
  9919. // Properties (matches AbstractMesh properties)
  9920. /** Gets or sets current position (in local space) */
  9921. get: function () {
  9922. this._decompose();
  9923. return this._localPosition;
  9924. },
  9925. set: function (newPosition) {
  9926. this._decompose();
  9927. this._localPosition.copyFrom(newPosition);
  9928. this._markAsDirtyAndCompose();
  9929. },
  9930. enumerable: true,
  9931. configurable: true
  9932. });
  9933. Object.defineProperty(Bone.prototype, "rotation", {
  9934. /** Gets or sets current rotation (in local space) */
  9935. get: function () {
  9936. return this.getRotation();
  9937. },
  9938. set: function (newRotation) {
  9939. this.setRotation(newRotation);
  9940. },
  9941. enumerable: true,
  9942. configurable: true
  9943. });
  9944. Object.defineProperty(Bone.prototype, "rotationQuaternion", {
  9945. /** Gets or sets current rotation quaternion (in local space) */
  9946. get: function () {
  9947. this._decompose();
  9948. return this._localRotation;
  9949. },
  9950. set: function (newRotation) {
  9951. this.setRotationQuaternion(newRotation);
  9952. },
  9953. enumerable: true,
  9954. configurable: true
  9955. });
  9956. Object.defineProperty(Bone.prototype, "scaling", {
  9957. /** Gets or sets current scaling (in local space) */
  9958. get: function () {
  9959. return this.getScale();
  9960. },
  9961. set: function (newScaling) {
  9962. this.setScale(newScaling);
  9963. },
  9964. enumerable: true,
  9965. configurable: true
  9966. });
  9967. Object.defineProperty(Bone.prototype, "animationPropertiesOverride", {
  9968. /**
  9969. * Gets the animation properties override
  9970. */
  9971. get: function () {
  9972. return this._skeleton.animationPropertiesOverride;
  9973. },
  9974. enumerable: true,
  9975. configurable: true
  9976. });
  9977. // Methods
  9978. Bone.prototype._decompose = function () {
  9979. if (!this._needToDecompose) {
  9980. return;
  9981. }
  9982. this._needToDecompose = false;
  9983. if (!this._localScaling) {
  9984. this._localScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  9985. this._localRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Zero();
  9986. this._localPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  9987. }
  9988. this._localMatrix.decompose(this._localScaling, this._localRotation, this._localPosition);
  9989. };
  9990. Bone.prototype._compose = function () {
  9991. if (!this._needToCompose) {
  9992. return;
  9993. }
  9994. this._needToCompose = false;
  9995. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ComposeToRef(this._localScaling, this._localRotation, this._localPosition, this._localMatrix);
  9996. };
  9997. /**
  9998. * Update the base and local matrices
  9999. * @param matrix defines the new base or local matrix
  10000. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  10001. * @param updateLocalMatrix defines if the local matrix should be updated
  10002. */
  10003. Bone.prototype.updateMatrix = function (matrix, updateDifferenceMatrix, updateLocalMatrix) {
  10004. if (updateDifferenceMatrix === void 0) { updateDifferenceMatrix = true; }
  10005. if (updateLocalMatrix === void 0) { updateLocalMatrix = true; }
  10006. this._baseMatrix.copyFrom(matrix);
  10007. if (updateDifferenceMatrix) {
  10008. this._updateDifferenceMatrix();
  10009. }
  10010. if (updateLocalMatrix) {
  10011. this._localMatrix.copyFrom(matrix);
  10012. this._markAsDirtyAndDecompose();
  10013. }
  10014. else {
  10015. this.markAsDirty();
  10016. }
  10017. };
  10018. /** @hidden */
  10019. Bone.prototype._updateDifferenceMatrix = function (rootMatrix, updateChildren) {
  10020. if (updateChildren === void 0) { updateChildren = true; }
  10021. if (!rootMatrix) {
  10022. rootMatrix = this._baseMatrix;
  10023. }
  10024. if (this._parent) {
  10025. rootMatrix.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform);
  10026. }
  10027. else {
  10028. this._absoluteTransform.copyFrom(rootMatrix);
  10029. }
  10030. this._absoluteTransform.invertToRef(this._invertedAbsoluteTransform);
  10031. if (updateChildren) {
  10032. for (var index = 0; index < this.children.length; index++) {
  10033. this.children[index]._updateDifferenceMatrix();
  10034. }
  10035. }
  10036. this._scalingDeterminant = (this._absoluteTransform.determinant() < 0 ? -1 : 1);
  10037. };
  10038. /**
  10039. * Flag the bone as dirty (Forcing it to update everything)
  10040. */
  10041. Bone.prototype.markAsDirty = function () {
  10042. this._currentRenderId++;
  10043. this._childRenderId++;
  10044. this._skeleton._markAsDirty();
  10045. };
  10046. Bone.prototype._markAsDirtyAndCompose = function () {
  10047. this.markAsDirty();
  10048. this._needToCompose = true;
  10049. };
  10050. Bone.prototype._markAsDirtyAndDecompose = function () {
  10051. this.markAsDirty();
  10052. this._needToDecompose = true;
  10053. };
  10054. /**
  10055. * Translate the bone in local or world space
  10056. * @param vec The amount to translate the bone
  10057. * @param space The space that the translation is in
  10058. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10059. */
  10060. Bone.prototype.translate = function (vec, space, mesh) {
  10061. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10062. var lm = this.getLocalMatrix();
  10063. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10064. lm.addAtIndex(12, vec.x);
  10065. lm.addAtIndex(13, vec.y);
  10066. lm.addAtIndex(14, vec.z);
  10067. }
  10068. else {
  10069. var wm = null;
  10070. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10071. if (mesh) {
  10072. wm = mesh.getWorldMatrix();
  10073. }
  10074. this._skeleton.computeAbsoluteTransforms();
  10075. var tmat = Bone._tmpMats[0];
  10076. var tvec = Bone._tmpVecs[0];
  10077. if (this._parent) {
  10078. if (mesh && wm) {
  10079. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10080. tmat.multiplyToRef(wm, tmat);
  10081. }
  10082. else {
  10083. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10084. }
  10085. }
  10086. tmat.setTranslationFromFloats(0, 0, 0);
  10087. tmat.invert();
  10088. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(vec, tmat, tvec);
  10089. lm.addAtIndex(12, tvec.x);
  10090. lm.addAtIndex(13, tvec.y);
  10091. lm.addAtIndex(14, tvec.z);
  10092. }
  10093. this._markAsDirtyAndDecompose();
  10094. };
  10095. /**
  10096. * Set the postion of the bone in local or world space
  10097. * @param position The position to set the bone
  10098. * @param space The space that the position is in
  10099. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10100. */
  10101. Bone.prototype.setPosition = function (position, space, mesh) {
  10102. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10103. var lm = this.getLocalMatrix();
  10104. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10105. lm.setTranslationFromFloats(position.x, position.y, position.z);
  10106. }
  10107. else {
  10108. var wm = null;
  10109. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10110. if (mesh) {
  10111. wm = mesh.getWorldMatrix();
  10112. }
  10113. this._skeleton.computeAbsoluteTransforms();
  10114. var tmat = Bone._tmpMats[0];
  10115. var vec = Bone._tmpVecs[0];
  10116. if (this._parent) {
  10117. if (mesh && wm) {
  10118. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10119. tmat.multiplyToRef(wm, tmat);
  10120. }
  10121. else {
  10122. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10123. }
  10124. }
  10125. tmat.invert();
  10126. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, vec);
  10127. lm.setTranslationFromFloats(vec.x, vec.y, vec.z);
  10128. }
  10129. this._markAsDirtyAndDecompose();
  10130. };
  10131. /**
  10132. * Set the absolute position of the bone (world space)
  10133. * @param position The position to set the bone
  10134. * @param mesh The mesh that this bone is attached to
  10135. */
  10136. Bone.prototype.setAbsolutePosition = function (position, mesh) {
  10137. this.setPosition(position, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh);
  10138. };
  10139. /**
  10140. * Scale the bone on the x, y and z axes (in local space)
  10141. * @param x The amount to scale the bone on the x axis
  10142. * @param y The amount to scale the bone on the y axis
  10143. * @param z The amount to scale the bone on the z axis
  10144. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  10145. */
  10146. Bone.prototype.scale = function (x, y, z, scaleChildren) {
  10147. if (scaleChildren === void 0) { scaleChildren = false; }
  10148. var locMat = this.getLocalMatrix();
  10149. // Apply new scaling on top of current local matrix
  10150. var scaleMat = Bone._tmpMats[0];
  10151. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ScalingToRef(x, y, z, scaleMat);
  10152. scaleMat.multiplyToRef(locMat, locMat);
  10153. // Invert scaling matrix and apply the inverse to all children
  10154. scaleMat.invert();
  10155. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  10156. var child = _a[_i];
  10157. var cm = child.getLocalMatrix();
  10158. cm.multiplyToRef(scaleMat, cm);
  10159. cm.multiplyAtIndex(12, x);
  10160. cm.multiplyAtIndex(13, y);
  10161. cm.multiplyAtIndex(14, z);
  10162. child._markAsDirtyAndDecompose();
  10163. }
  10164. this._markAsDirtyAndDecompose();
  10165. if (scaleChildren) {
  10166. for (var _b = 0, _c = this.children; _b < _c.length; _b++) {
  10167. var child = _c[_b];
  10168. child.scale(x, y, z, scaleChildren);
  10169. }
  10170. }
  10171. };
  10172. /**
  10173. * Set the bone scaling in local space
  10174. * @param scale defines the scaling vector
  10175. */
  10176. Bone.prototype.setScale = function (scale) {
  10177. this._decompose();
  10178. this._localScaling.copyFrom(scale);
  10179. this._markAsDirtyAndCompose();
  10180. };
  10181. /**
  10182. * Gets the current scaling in local space
  10183. * @returns the current scaling vector
  10184. */
  10185. Bone.prototype.getScale = function () {
  10186. this._decompose();
  10187. return this._localScaling;
  10188. };
  10189. /**
  10190. * Gets the current scaling in local space and stores it in a target vector
  10191. * @param result defines the target vector
  10192. */
  10193. Bone.prototype.getScaleToRef = function (result) {
  10194. this._decompose();
  10195. result.copyFrom(this._localScaling);
  10196. };
  10197. /**
  10198. * Set the yaw, pitch, and roll of the bone in local or world space
  10199. * @param yaw The rotation of the bone on the y axis
  10200. * @param pitch The rotation of the bone on the x axis
  10201. * @param roll The rotation of the bone on the z axis
  10202. * @param space The space that the axes of rotation are in
  10203. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10204. */
  10205. Bone.prototype.setYawPitchRoll = function (yaw, pitch, roll, space, mesh) {
  10206. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10207. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10208. var quat = Bone._tmpQuat;
  10209. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].RotationYawPitchRollToRef(yaw, pitch, roll, quat);
  10210. this.setRotationQuaternion(quat, space, mesh);
  10211. return;
  10212. }
  10213. var rotMatInv = Bone._tmpMats[0];
  10214. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10215. return;
  10216. }
  10217. var rotMat = Bone._tmpMats[1];
  10218. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yaw, pitch, roll, rotMat);
  10219. rotMatInv.multiplyToRef(rotMat, rotMat);
  10220. this._rotateWithMatrix(rotMat, space, mesh);
  10221. };
  10222. /**
  10223. * Add a rotation to the bone on an axis in local or world space
  10224. * @param axis The axis to rotate the bone on
  10225. * @param amount The amount to rotate the bone
  10226. * @param space The space that the axis is in
  10227. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10228. */
  10229. Bone.prototype.rotate = function (axis, amount, space, mesh) {
  10230. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10231. var rmat = Bone._tmpMats[0];
  10232. rmat.setTranslationFromFloats(0, 0, 0);
  10233. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationAxisToRef(axis, amount, rmat);
  10234. this._rotateWithMatrix(rmat, space, mesh);
  10235. };
  10236. /**
  10237. * Set the rotation of the bone to a particular axis angle in local or world space
  10238. * @param axis The axis to rotate the bone on
  10239. * @param angle The angle that the bone should be rotated to
  10240. * @param space The space that the axis is in
  10241. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10242. */
  10243. Bone.prototype.setAxisAngle = function (axis, angle, space, mesh) {
  10244. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10245. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10246. var quat = Bone._tmpQuat;
  10247. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].RotationAxisToRef(axis, angle, quat);
  10248. this.setRotationQuaternion(quat, space, mesh);
  10249. return;
  10250. }
  10251. var rotMatInv = Bone._tmpMats[0];
  10252. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10253. return;
  10254. }
  10255. var rotMat = Bone._tmpMats[1];
  10256. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationAxisToRef(axis, angle, rotMat);
  10257. rotMatInv.multiplyToRef(rotMat, rotMat);
  10258. this._rotateWithMatrix(rotMat, space, mesh);
  10259. };
  10260. /**
  10261. * Set the euler rotation of the bone in local of world space
  10262. * @param rotation The euler rotation that the bone should be set to
  10263. * @param space The space that the rotation is in
  10264. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10265. */
  10266. Bone.prototype.setRotation = function (rotation, space, mesh) {
  10267. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10268. this.setYawPitchRoll(rotation.y, rotation.x, rotation.z, space, mesh);
  10269. };
  10270. /**
  10271. * Set the quaternion rotation of the bone in local of world space
  10272. * @param quat The quaternion rotation that the bone should be set to
  10273. * @param space The space that the rotation is in
  10274. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10275. */
  10276. Bone.prototype.setRotationQuaternion = function (quat, space, mesh) {
  10277. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10278. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10279. this._decompose();
  10280. this._localRotation.copyFrom(quat);
  10281. this._markAsDirtyAndCompose();
  10282. return;
  10283. }
  10284. var rotMatInv = Bone._tmpMats[0];
  10285. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10286. return;
  10287. }
  10288. var rotMat = Bone._tmpMats[1];
  10289. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromQuaternionToRef(quat, rotMat);
  10290. rotMatInv.multiplyToRef(rotMat, rotMat);
  10291. this._rotateWithMatrix(rotMat, space, mesh);
  10292. };
  10293. /**
  10294. * Set the rotation matrix of the bone in local of world space
  10295. * @param rotMat The rotation matrix that the bone should be set to
  10296. * @param space The space that the rotation is in
  10297. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10298. */
  10299. Bone.prototype.setRotationMatrix = function (rotMat, space, mesh) {
  10300. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10301. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10302. var quat = Bone._tmpQuat;
  10303. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(rotMat, quat);
  10304. this.setRotationQuaternion(quat, space, mesh);
  10305. return;
  10306. }
  10307. var rotMatInv = Bone._tmpMats[0];
  10308. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10309. return;
  10310. }
  10311. var rotMat2 = Bone._tmpMats[1];
  10312. rotMat2.copyFrom(rotMat);
  10313. rotMatInv.multiplyToRef(rotMat, rotMat2);
  10314. this._rotateWithMatrix(rotMat2, space, mesh);
  10315. };
  10316. Bone.prototype._rotateWithMatrix = function (rmat, space, mesh) {
  10317. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10318. var lmat = this.getLocalMatrix();
  10319. var lx = lmat.m[12];
  10320. var ly = lmat.m[13];
  10321. var lz = lmat.m[14];
  10322. var parent = this.getParent();
  10323. var parentScale = Bone._tmpMats[3];
  10324. var parentScaleInv = Bone._tmpMats[4];
  10325. if (parent && space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD) {
  10326. if (mesh) {
  10327. parentScale.copyFrom(mesh.getWorldMatrix());
  10328. parent.getAbsoluteTransform().multiplyToRef(parentScale, parentScale);
  10329. }
  10330. else {
  10331. parentScale.copyFrom(parent.getAbsoluteTransform());
  10332. }
  10333. parentScaleInv.copyFrom(parentScale);
  10334. parentScaleInv.invert();
  10335. lmat.multiplyToRef(parentScale, lmat);
  10336. lmat.multiplyToRef(rmat, lmat);
  10337. lmat.multiplyToRef(parentScaleInv, lmat);
  10338. }
  10339. else {
  10340. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD && mesh) {
  10341. parentScale.copyFrom(mesh.getWorldMatrix());
  10342. parentScaleInv.copyFrom(parentScale);
  10343. parentScaleInv.invert();
  10344. lmat.multiplyToRef(parentScale, lmat);
  10345. lmat.multiplyToRef(rmat, lmat);
  10346. lmat.multiplyToRef(parentScaleInv, lmat);
  10347. }
  10348. else {
  10349. lmat.multiplyToRef(rmat, lmat);
  10350. }
  10351. }
  10352. lmat.setTranslationFromFloats(lx, ly, lz);
  10353. this.computeAbsoluteTransforms();
  10354. this._markAsDirtyAndDecompose();
  10355. };
  10356. Bone.prototype._getNegativeRotationToRef = function (rotMatInv, mesh) {
  10357. var scaleMatrix = Bone._tmpMats[2];
  10358. rotMatInv.copyFrom(this.getAbsoluteTransform());
  10359. if (mesh) {
  10360. rotMatInv.multiplyToRef(mesh.getWorldMatrix(), rotMatInv);
  10361. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ScalingToRef(mesh.scaling.x, mesh.scaling.y, mesh.scaling.z, scaleMatrix);
  10362. }
  10363. rotMatInv.invert();
  10364. if (isNaN(rotMatInv.m[0])) {
  10365. // Matrix failed to invert.
  10366. // This can happen if scale is zero for example.
  10367. return false;
  10368. }
  10369. scaleMatrix.multiplyAtIndex(0, this._scalingDeterminant);
  10370. rotMatInv.multiplyToRef(scaleMatrix, rotMatInv);
  10371. return true;
  10372. };
  10373. /**
  10374. * Get the position of the bone in local or world space
  10375. * @param space The space that the returned position is in
  10376. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10377. * @returns The position of the bone
  10378. */
  10379. Bone.prototype.getPosition = function (space, mesh) {
  10380. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10381. if (mesh === void 0) { mesh = null; }
  10382. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10383. this.getPositionToRef(space, mesh, pos);
  10384. return pos;
  10385. };
  10386. /**
  10387. * Copy the position of the bone to a vector3 in local or world space
  10388. * @param space The space that the returned position is in
  10389. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10390. * @param result The vector3 to copy the position to
  10391. */
  10392. Bone.prototype.getPositionToRef = function (space, mesh, result) {
  10393. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10394. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10395. var lm = this.getLocalMatrix();
  10396. result.x = lm.m[12];
  10397. result.y = lm.m[13];
  10398. result.z = lm.m[14];
  10399. }
  10400. else {
  10401. var wm = null;
  10402. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10403. if (mesh) {
  10404. wm = mesh.getWorldMatrix();
  10405. }
  10406. this._skeleton.computeAbsoluteTransforms();
  10407. var tmat = Bone._tmpMats[0];
  10408. if (mesh && wm) {
  10409. tmat.copyFrom(this.getAbsoluteTransform());
  10410. tmat.multiplyToRef(wm, tmat);
  10411. }
  10412. else {
  10413. tmat = this.getAbsoluteTransform();
  10414. }
  10415. result.x = tmat.m[12];
  10416. result.y = tmat.m[13];
  10417. result.z = tmat.m[14];
  10418. }
  10419. };
  10420. /**
  10421. * Get the absolute position of the bone (world space)
  10422. * @param mesh The mesh that this bone is attached to
  10423. * @returns The absolute position of the bone
  10424. */
  10425. Bone.prototype.getAbsolutePosition = function (mesh) {
  10426. if (mesh === void 0) { mesh = null; }
  10427. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10428. this.getPositionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh, pos);
  10429. return pos;
  10430. };
  10431. /**
  10432. * Copy the absolute position of the bone (world space) to the result param
  10433. * @param mesh The mesh that this bone is attached to
  10434. * @param result The vector3 to copy the absolute position to
  10435. */
  10436. Bone.prototype.getAbsolutePositionToRef = function (mesh, result) {
  10437. this.getPositionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh, result);
  10438. };
  10439. /**
  10440. * Compute the absolute transforms of this bone and its children
  10441. */
  10442. Bone.prototype.computeAbsoluteTransforms = function () {
  10443. this._compose();
  10444. if (this._parent) {
  10445. this._localMatrix.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform);
  10446. }
  10447. else {
  10448. this._absoluteTransform.copyFrom(this._localMatrix);
  10449. var poseMatrix = this._skeleton.getPoseMatrix();
  10450. if (poseMatrix) {
  10451. this._absoluteTransform.multiplyToRef(poseMatrix, this._absoluteTransform);
  10452. }
  10453. }
  10454. var children = this.children;
  10455. var len = children.length;
  10456. for (var i = 0; i < len; i++) {
  10457. children[i].computeAbsoluteTransforms();
  10458. }
  10459. };
  10460. /**
  10461. * Get the world direction from an axis that is in the local space of the bone
  10462. * @param localAxis The local direction that is used to compute the world direction
  10463. * @param mesh The mesh that this bone is attached to
  10464. * @returns The world direction
  10465. */
  10466. Bone.prototype.getDirection = function (localAxis, mesh) {
  10467. if (mesh === void 0) { mesh = null; }
  10468. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10469. this.getDirectionToRef(localAxis, mesh, result);
  10470. return result;
  10471. };
  10472. /**
  10473. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  10474. * @param localAxis The local direction that is used to compute the world direction
  10475. * @param mesh The mesh that this bone is attached to
  10476. * @param result The vector3 that the world direction will be copied to
  10477. */
  10478. Bone.prototype.getDirectionToRef = function (localAxis, mesh, result) {
  10479. if (mesh === void 0) { mesh = null; }
  10480. var wm = null;
  10481. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10482. if (mesh) {
  10483. wm = mesh.getWorldMatrix();
  10484. }
  10485. this._skeleton.computeAbsoluteTransforms();
  10486. var mat = Bone._tmpMats[0];
  10487. mat.copyFrom(this.getAbsoluteTransform());
  10488. if (mesh && wm) {
  10489. mat.multiplyToRef(wm, mat);
  10490. }
  10491. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(localAxis, mat, result);
  10492. result.normalize();
  10493. };
  10494. /**
  10495. * Get the euler rotation of the bone in local or world space
  10496. * @param space The space that the rotation should be in
  10497. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10498. * @returns The euler rotation
  10499. */
  10500. Bone.prototype.getRotation = function (space, mesh) {
  10501. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10502. if (mesh === void 0) { mesh = null; }
  10503. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10504. this.getRotationToRef(space, mesh, result);
  10505. return result;
  10506. };
  10507. /**
  10508. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  10509. * @param space The space that the rotation should be in
  10510. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10511. * @param result The vector3 that the rotation should be copied to
  10512. */
  10513. Bone.prototype.getRotationToRef = function (space, mesh, result) {
  10514. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10515. if (mesh === void 0) { mesh = null; }
  10516. var quat = Bone._tmpQuat;
  10517. this.getRotationQuaternionToRef(space, mesh, quat);
  10518. quat.toEulerAnglesToRef(result);
  10519. };
  10520. /**
  10521. * Get the quaternion rotation of the bone in either local or world space
  10522. * @param space The space that the rotation should be in
  10523. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10524. * @returns The quaternion rotation
  10525. */
  10526. Bone.prototype.getRotationQuaternion = function (space, mesh) {
  10527. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10528. if (mesh === void 0) { mesh = null; }
  10529. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10530. this.getRotationQuaternionToRef(space, mesh, result);
  10531. return result;
  10532. };
  10533. /**
  10534. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  10535. * @param space The space that the rotation should be in
  10536. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10537. * @param result The quaternion that the rotation should be copied to
  10538. */
  10539. Bone.prototype.getRotationQuaternionToRef = function (space, mesh, result) {
  10540. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10541. if (mesh === void 0) { mesh = null; }
  10542. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10543. this._decompose();
  10544. result.copyFrom(this._localRotation);
  10545. }
  10546. else {
  10547. var mat = Bone._tmpMats[0];
  10548. var amat = this.getAbsoluteTransform();
  10549. if (mesh) {
  10550. amat.multiplyToRef(mesh.getWorldMatrix(), mat);
  10551. }
  10552. else {
  10553. mat.copyFrom(amat);
  10554. }
  10555. mat.multiplyAtIndex(0, this._scalingDeterminant);
  10556. mat.multiplyAtIndex(1, this._scalingDeterminant);
  10557. mat.multiplyAtIndex(2, this._scalingDeterminant);
  10558. mat.decompose(undefined, result, undefined);
  10559. }
  10560. };
  10561. /**
  10562. * Get the rotation matrix of the bone in local or world space
  10563. * @param space The space that the rotation should be in
  10564. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10565. * @returns The rotation matrix
  10566. */
  10567. Bone.prototype.getRotationMatrix = function (space, mesh) {
  10568. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10569. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  10570. this.getRotationMatrixToRef(space, mesh, result);
  10571. return result;
  10572. };
  10573. /**
  10574. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  10575. * @param space The space that the rotation should be in
  10576. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10577. * @param result The quaternion that the rotation should be copied to
  10578. */
  10579. Bone.prototype.getRotationMatrixToRef = function (space, mesh, result) {
  10580. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10581. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10582. this.getLocalMatrix().getRotationMatrixToRef(result);
  10583. }
  10584. else {
  10585. var mat = Bone._tmpMats[0];
  10586. var amat = this.getAbsoluteTransform();
  10587. if (mesh) {
  10588. amat.multiplyToRef(mesh.getWorldMatrix(), mat);
  10589. }
  10590. else {
  10591. mat.copyFrom(amat);
  10592. }
  10593. mat.multiplyAtIndex(0, this._scalingDeterminant);
  10594. mat.multiplyAtIndex(1, this._scalingDeterminant);
  10595. mat.multiplyAtIndex(2, this._scalingDeterminant);
  10596. mat.getRotationMatrixToRef(result);
  10597. }
  10598. };
  10599. /**
  10600. * Get the world position of a point that is in the local space of the bone
  10601. * @param position The local position
  10602. * @param mesh The mesh that this bone is attached to
  10603. * @returns The world position
  10604. */
  10605. Bone.prototype.getAbsolutePositionFromLocal = function (position, mesh) {
  10606. if (mesh === void 0) { mesh = null; }
  10607. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10608. this.getAbsolutePositionFromLocalToRef(position, mesh, result);
  10609. return result;
  10610. };
  10611. /**
  10612. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  10613. * @param position The local position
  10614. * @param mesh The mesh that this bone is attached to
  10615. * @param result The vector3 that the world position should be copied to
  10616. */
  10617. Bone.prototype.getAbsolutePositionFromLocalToRef = function (position, mesh, result) {
  10618. if (mesh === void 0) { mesh = null; }
  10619. var wm = null;
  10620. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10621. if (mesh) {
  10622. wm = mesh.getWorldMatrix();
  10623. }
  10624. this._skeleton.computeAbsoluteTransforms();
  10625. var tmat = Bone._tmpMats[0];
  10626. if (mesh && wm) {
  10627. tmat.copyFrom(this.getAbsoluteTransform());
  10628. tmat.multiplyToRef(wm, tmat);
  10629. }
  10630. else {
  10631. tmat = this.getAbsoluteTransform();
  10632. }
  10633. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, result);
  10634. };
  10635. /**
  10636. * Get the local position of a point that is in world space
  10637. * @param position The world position
  10638. * @param mesh The mesh that this bone is attached to
  10639. * @returns The local position
  10640. */
  10641. Bone.prototype.getLocalPositionFromAbsolute = function (position, mesh) {
  10642. if (mesh === void 0) { mesh = null; }
  10643. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10644. this.getLocalPositionFromAbsoluteToRef(position, mesh, result);
  10645. return result;
  10646. };
  10647. /**
  10648. * Get the local position of a point that is in world space and copy it to the result param
  10649. * @param position The world position
  10650. * @param mesh The mesh that this bone is attached to
  10651. * @param result The vector3 that the local position should be copied to
  10652. */
  10653. Bone.prototype.getLocalPositionFromAbsoluteToRef = function (position, mesh, result) {
  10654. if (mesh === void 0) { mesh = null; }
  10655. var wm = null;
  10656. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10657. if (mesh) {
  10658. wm = mesh.getWorldMatrix();
  10659. }
  10660. this._skeleton.computeAbsoluteTransforms();
  10661. var tmat = Bone._tmpMats[0];
  10662. tmat.copyFrom(this.getAbsoluteTransform());
  10663. if (mesh && wm) {
  10664. tmat.multiplyToRef(wm, tmat);
  10665. }
  10666. tmat.invert();
  10667. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, result);
  10668. };
  10669. Bone._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(2, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  10670. Bone._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10671. Bone._tmpMats = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(5, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity);
  10672. return Bone;
  10673. }(_node__WEBPACK_IMPORTED_MODULE_3__["Node"]));
  10674. /***/ }),
  10675. /***/ "./Bones/boneIKController.ts":
  10676. /*!***********************************!*\
  10677. !*** ./Bones/boneIKController.ts ***!
  10678. \***********************************/
  10679. /*! exports provided: BoneIKController */
  10680. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10681. "use strict";
  10682. __webpack_require__.r(__webpack_exports__);
  10683. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return BoneIKController; });
  10684. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  10685. /**
  10686. * Class used to apply inverse kinematics to bones
  10687. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  10688. */
  10689. var BoneIKController = /** @class */ (function () {
  10690. /**
  10691. * Creates a new BoneIKController
  10692. * @param mesh defines the mesh to control
  10693. * @param bone defines the bone to control
  10694. * @param options defines options to set up the controller
  10695. */
  10696. function BoneIKController(mesh, bone, options) {
  10697. /**
  10698. * Gets or sets the target position
  10699. */
  10700. this.targetPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10701. /**
  10702. * Gets or sets the pole target position
  10703. */
  10704. this.poleTargetPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10705. /**
  10706. * Gets or sets the pole target local offset
  10707. */
  10708. this.poleTargetLocalOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10709. /**
  10710. * Gets or sets the pole angle
  10711. */
  10712. this.poleAngle = 0;
  10713. /**
  10714. * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp)
  10715. */
  10716. this.slerpAmount = 1;
  10717. this._bone1Quat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Identity();
  10718. this._bone1Mat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity();
  10719. this._bone2Ang = Math.PI;
  10720. this._maxAngle = Math.PI;
  10721. this._rightHandedSystem = false;
  10722. this._bendAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Right();
  10723. this._slerping = false;
  10724. this._adjustRoll = 0;
  10725. this._bone2 = bone;
  10726. this._bone1 = bone.getParent();
  10727. if (!this._bone1) {
  10728. return;
  10729. }
  10730. this.mesh = mesh;
  10731. var bonePos = bone.getPosition();
  10732. if (bone.getAbsoluteTransform().determinant() > 0) {
  10733. this._rightHandedSystem = true;
  10734. this._bendAxis.x = 0;
  10735. this._bendAxis.y = 0;
  10736. this._bendAxis.z = -1;
  10737. if (bonePos.x > bonePos.y && bonePos.x > bonePos.z) {
  10738. this._adjustRoll = Math.PI * .5;
  10739. this._bendAxis.z = 1;
  10740. }
  10741. }
  10742. if (this._bone1.length) {
  10743. var boneScale1 = this._bone1.getScale();
  10744. var boneScale2 = this._bone2.getScale();
  10745. this._bone1Length = this._bone1.length * boneScale1.y * this.mesh.scaling.y;
  10746. this._bone2Length = this._bone2.length * boneScale2.y * this.mesh.scaling.y;
  10747. }
  10748. else if (this._bone1.children[0]) {
  10749. mesh.computeWorldMatrix(true);
  10750. var pos1 = this._bone2.children[0].getAbsolutePosition(mesh);
  10751. var pos2 = this._bone2.getAbsolutePosition(mesh);
  10752. var pos3 = this._bone1.getAbsolutePosition(mesh);
  10753. this._bone1Length = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(pos1, pos2);
  10754. this._bone2Length = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(pos2, pos3);
  10755. }
  10756. this._bone1.getRotationMatrixToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, mesh, this._bone1Mat);
  10757. this.maxAngle = Math.PI;
  10758. if (options) {
  10759. if (options.targetMesh) {
  10760. this.targetMesh = options.targetMesh;
  10761. this.targetMesh.computeWorldMatrix(true);
  10762. }
  10763. if (options.poleTargetMesh) {
  10764. this.poleTargetMesh = options.poleTargetMesh;
  10765. this.poleTargetMesh.computeWorldMatrix(true);
  10766. }
  10767. else if (options.poleTargetBone) {
  10768. this.poleTargetBone = options.poleTargetBone;
  10769. }
  10770. else if (this._bone1.getParent()) {
  10771. this.poleTargetBone = this._bone1.getParent();
  10772. }
  10773. if (options.poleTargetLocalOffset) {
  10774. this.poleTargetLocalOffset.copyFrom(options.poleTargetLocalOffset);
  10775. }
  10776. if (options.poleAngle) {
  10777. this.poleAngle = options.poleAngle;
  10778. }
  10779. if (options.bendAxis) {
  10780. this._bendAxis.copyFrom(options.bendAxis);
  10781. }
  10782. if (options.maxAngle) {
  10783. this.maxAngle = options.maxAngle;
  10784. }
  10785. if (options.slerpAmount) {
  10786. this.slerpAmount = options.slerpAmount;
  10787. }
  10788. }
  10789. }
  10790. Object.defineProperty(BoneIKController.prototype, "maxAngle", {
  10791. /**
  10792. * Gets or sets maximum allowed angle
  10793. */
  10794. get: function () {
  10795. return this._maxAngle;
  10796. },
  10797. set: function (value) {
  10798. this._setMaxAngle(value);
  10799. },
  10800. enumerable: true,
  10801. configurable: true
  10802. });
  10803. BoneIKController.prototype._setMaxAngle = function (ang) {
  10804. if (ang < 0) {
  10805. ang = 0;
  10806. }
  10807. if (ang > Math.PI || ang == undefined) {
  10808. ang = Math.PI;
  10809. }
  10810. this._maxAngle = ang;
  10811. var a = this._bone1Length;
  10812. var b = this._bone2Length;
  10813. this._maxReach = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(ang));
  10814. };
  10815. /**
  10816. * Force the controller to update the bones
  10817. */
  10818. BoneIKController.prototype.update = function () {
  10819. var bone1 = this._bone1;
  10820. if (!bone1) {
  10821. return;
  10822. }
  10823. var target = this.targetPosition;
  10824. var poleTarget = this.poleTargetPosition;
  10825. var mat1 = BoneIKController._tmpMats[0];
  10826. var mat2 = BoneIKController._tmpMats[1];
  10827. if (this.targetMesh) {
  10828. target.copyFrom(this.targetMesh.getAbsolutePosition());
  10829. }
  10830. if (this.poleTargetBone) {
  10831. this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset, this.mesh, poleTarget);
  10832. }
  10833. else if (this.poleTargetMesh) {
  10834. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this.poleTargetLocalOffset, this.poleTargetMesh.getWorldMatrix(), poleTarget);
  10835. }
  10836. var bonePos = BoneIKController._tmpVecs[0];
  10837. var zaxis = BoneIKController._tmpVecs[1];
  10838. var xaxis = BoneIKController._tmpVecs[2];
  10839. var yaxis = BoneIKController._tmpVecs[3];
  10840. var upAxis = BoneIKController._tmpVecs[4];
  10841. var _tmpQuat = BoneIKController._tmpQuat;
  10842. bone1.getAbsolutePositionToRef(this.mesh, bonePos);
  10843. poleTarget.subtractToRef(bonePos, upAxis);
  10844. if (upAxis.x == 0 && upAxis.y == 0 && upAxis.z == 0) {
  10845. upAxis.y = 1;
  10846. }
  10847. else {
  10848. upAxis.normalize();
  10849. }
  10850. target.subtractToRef(bonePos, yaxis);
  10851. yaxis.normalize();
  10852. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(yaxis, upAxis, zaxis);
  10853. zaxis.normalize();
  10854. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(yaxis, zaxis, xaxis);
  10855. xaxis.normalize();
  10856. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromXYZAxesToRef(xaxis, yaxis, zaxis, mat1);
  10857. var a = this._bone1Length;
  10858. var b = this._bone2Length;
  10859. var c = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(bonePos, target);
  10860. if (this._maxReach > 0) {
  10861. c = Math.min(this._maxReach, c);
  10862. }
  10863. var acosa = (b * b + c * c - a * a) / (2 * b * c);
  10864. var acosb = (c * c + a * a - b * b) / (2 * c * a);
  10865. if (acosa > 1) {
  10866. acosa = 1;
  10867. }
  10868. if (acosb > 1) {
  10869. acosb = 1;
  10870. }
  10871. if (acosa < -1) {
  10872. acosa = -1;
  10873. }
  10874. if (acosb < -1) {
  10875. acosb = -1;
  10876. }
  10877. var angA = Math.acos(acosa);
  10878. var angB = Math.acos(acosb);
  10879. var angC = -angA - angB;
  10880. if (this._rightHandedSystem) {
  10881. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationYawPitchRollToRef(0, 0, this._adjustRoll, mat2);
  10882. mat2.multiplyToRef(mat1, mat1);
  10883. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(this._bendAxis, angB, mat2);
  10884. mat2.multiplyToRef(mat1, mat1);
  10885. }
  10886. else {
  10887. var _tmpVec = BoneIKController._tmpVecs[5];
  10888. _tmpVec.copyFrom(this._bendAxis);
  10889. _tmpVec.x *= -1;
  10890. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(_tmpVec, -angB, mat2);
  10891. mat2.multiplyToRef(mat1, mat1);
  10892. }
  10893. if (this.poleAngle) {
  10894. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(yaxis, this.poleAngle, mat2);
  10895. mat1.multiplyToRef(mat2, mat1);
  10896. }
  10897. if (this._bone1) {
  10898. if (this.slerpAmount < 1) {
  10899. if (!this._slerping) {
  10900. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._bone1Mat, this._bone1Quat);
  10901. }
  10902. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(mat1, _tmpQuat);
  10903. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].SlerpToRef(this._bone1Quat, _tmpQuat, this.slerpAmount, this._bone1Quat);
  10904. angC = this._bone2Ang * (1.0 - this.slerpAmount) + angC * this.slerpAmount;
  10905. this._bone1.setRotationQuaternion(this._bone1Quat, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, this.mesh);
  10906. this._slerping = true;
  10907. }
  10908. else {
  10909. this._bone1.setRotationMatrix(mat1, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, this.mesh);
  10910. this._bone1Mat.copyFrom(mat1);
  10911. this._slerping = false;
  10912. }
  10913. }
  10914. this._bone2.setAxisAngle(this._bendAxis, angC, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].LOCAL);
  10915. this._bone2Ang = angC;
  10916. };
  10917. BoneIKController._tmpVecs = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero()];
  10918. BoneIKController._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Identity();
  10919. BoneIKController._tmpMats = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity()];
  10920. return BoneIKController;
  10921. }());
  10922. /***/ }),
  10923. /***/ "./Bones/boneLookController.ts":
  10924. /*!*************************************!*\
  10925. !*** ./Bones/boneLookController.ts ***!
  10926. \*************************************/
  10927. /*! exports provided: BoneLookController */
  10928. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10929. "use strict";
  10930. __webpack_require__.r(__webpack_exports__);
  10931. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return BoneLookController; });
  10932. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  10933. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  10934. /**
  10935. * Class used to make a bone look toward a point in space
  10936. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  10937. */
  10938. var BoneLookController = /** @class */ (function () {
  10939. /**
  10940. * Create a BoneLookController
  10941. * @param mesh the mesh that the bone belongs to
  10942. * @param bone the bone that will be looking to the target
  10943. * @param target the target Vector3 to look at
  10944. * @param options optional settings:
  10945. * * maxYaw: the maximum angle the bone will yaw to
  10946. * * minYaw: the minimum angle the bone will yaw to
  10947. * * maxPitch: the maximum angle the bone will pitch to
  10948. * * minPitch: the minimum angle the bone will yaw to
  10949. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  10950. * * upAxis: the up axis of the coordinate system
  10951. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  10952. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  10953. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  10954. * * adjustYaw: used to make an adjustment to the yaw of the bone
  10955. * * adjustPitch: used to make an adjustment to the pitch of the bone
  10956. * * adjustRoll: used to make an adjustment to the roll of the bone
  10957. **/
  10958. function BoneLookController(mesh, bone, target, options) {
  10959. /**
  10960. * The up axis of the coordinate system that is used when the bone is rotated
  10961. */
  10962. this.upAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up();
  10963. /**
  10964. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  10965. */
  10966. this.upAxisSpace = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL;
  10967. /**
  10968. * Used to make an adjustment to the yaw of the bone
  10969. */
  10970. this.adjustYaw = 0;
  10971. /**
  10972. * Used to make an adjustment to the pitch of the bone
  10973. */
  10974. this.adjustPitch = 0;
  10975. /**
  10976. * Used to make an adjustment to the roll of the bone
  10977. */
  10978. this.adjustRoll = 0;
  10979. /**
  10980. * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp)
  10981. */
  10982. this.slerpAmount = 1;
  10983. this._boneQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10984. this._slerping = false;
  10985. this._firstFrameSkipped = false;
  10986. this._fowardAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Forward();
  10987. this.mesh = mesh;
  10988. this.bone = bone;
  10989. this.target = target;
  10990. if (options) {
  10991. if (options.adjustYaw) {
  10992. this.adjustYaw = options.adjustYaw;
  10993. }
  10994. if (options.adjustPitch) {
  10995. this.adjustPitch = options.adjustPitch;
  10996. }
  10997. if (options.adjustRoll) {
  10998. this.adjustRoll = options.adjustRoll;
  10999. }
  11000. if (options.maxYaw != null) {
  11001. this.maxYaw = options.maxYaw;
  11002. }
  11003. else {
  11004. this.maxYaw = Math.PI;
  11005. }
  11006. if (options.minYaw != null) {
  11007. this.minYaw = options.minYaw;
  11008. }
  11009. else {
  11010. this.minYaw = -Math.PI;
  11011. }
  11012. if (options.maxPitch != null) {
  11013. this.maxPitch = options.maxPitch;
  11014. }
  11015. else {
  11016. this.maxPitch = Math.PI;
  11017. }
  11018. if (options.minPitch != null) {
  11019. this.minPitch = options.minPitch;
  11020. }
  11021. else {
  11022. this.minPitch = -Math.PI;
  11023. }
  11024. if (options.slerpAmount != null) {
  11025. this.slerpAmount = options.slerpAmount;
  11026. }
  11027. if (options.upAxis != null) {
  11028. this.upAxis = options.upAxis;
  11029. }
  11030. if (options.upAxisSpace != null) {
  11031. this.upAxisSpace = options.upAxisSpace;
  11032. }
  11033. if (options.yawAxis != null || options.pitchAxis != null) {
  11034. var newYawAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y;
  11035. var newPitchAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].X;
  11036. if (options.yawAxis != null) {
  11037. newYawAxis = options.yawAxis.clone();
  11038. newYawAxis.normalize();
  11039. }
  11040. if (options.pitchAxis != null) {
  11041. newPitchAxis = options.pitchAxis.clone();
  11042. newPitchAxis.normalize();
  11043. }
  11044. var newRollAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(newPitchAxis, newYawAxis);
  11045. this._transformYawPitch = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  11046. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(newPitchAxis, newYawAxis, newRollAxis, this._transformYawPitch);
  11047. this._transformYawPitchInv = this._transformYawPitch.clone();
  11048. this._transformYawPitch.invert();
  11049. }
  11050. }
  11051. if (!bone.getParent() && this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE) {
  11052. this.upAxisSpace = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL;
  11053. }
  11054. }
  11055. Object.defineProperty(BoneLookController.prototype, "minYaw", {
  11056. /**
  11057. * Gets or sets the minimum yaw angle that the bone can look to
  11058. */
  11059. get: function () {
  11060. return this._minYaw;
  11061. },
  11062. set: function (value) {
  11063. this._minYaw = value;
  11064. this._minYawSin = Math.sin(value);
  11065. this._minYawCos = Math.cos(value);
  11066. if (this._maxYaw != null) {
  11067. this._midYawConstraint = this._getAngleDiff(this._minYaw, this._maxYaw) * .5 + this._minYaw;
  11068. this._yawRange = this._maxYaw - this._minYaw;
  11069. }
  11070. },
  11071. enumerable: true,
  11072. configurable: true
  11073. });
  11074. Object.defineProperty(BoneLookController.prototype, "maxYaw", {
  11075. /**
  11076. * Gets or sets the maximum yaw angle that the bone can look to
  11077. */
  11078. get: function () {
  11079. return this._maxYaw;
  11080. },
  11081. set: function (value) {
  11082. this._maxYaw = value;
  11083. this._maxYawSin = Math.sin(value);
  11084. this._maxYawCos = Math.cos(value);
  11085. if (this._minYaw != null) {
  11086. this._midYawConstraint = this._getAngleDiff(this._minYaw, this._maxYaw) * .5 + this._minYaw;
  11087. this._yawRange = this._maxYaw - this._minYaw;
  11088. }
  11089. },
  11090. enumerable: true,
  11091. configurable: true
  11092. });
  11093. Object.defineProperty(BoneLookController.prototype, "minPitch", {
  11094. /**
  11095. * Gets or sets the minimum pitch angle that the bone can look to
  11096. */
  11097. get: function () {
  11098. return this._minPitch;
  11099. },
  11100. set: function (value) {
  11101. this._minPitch = value;
  11102. this._minPitchTan = Math.tan(value);
  11103. },
  11104. enumerable: true,
  11105. configurable: true
  11106. });
  11107. Object.defineProperty(BoneLookController.prototype, "maxPitch", {
  11108. /**
  11109. * Gets or sets the maximum pitch angle that the bone can look to
  11110. */
  11111. get: function () {
  11112. return this._maxPitch;
  11113. },
  11114. set: function (value) {
  11115. this._maxPitch = value;
  11116. this._maxPitchTan = Math.tan(value);
  11117. },
  11118. enumerable: true,
  11119. configurable: true
  11120. });
  11121. /**
  11122. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  11123. */
  11124. BoneLookController.prototype.update = function () {
  11125. //skip the first frame when slerping so that the mesh rotation is correct
  11126. if (this.slerpAmount < 1 && !this._firstFrameSkipped) {
  11127. this._firstFrameSkipped = true;
  11128. return;
  11129. }
  11130. var bone = this.bone;
  11131. var bonePos = BoneLookController._tmpVecs[0];
  11132. bone.getAbsolutePositionToRef(this.mesh, bonePos);
  11133. var target = this.target;
  11134. var _tmpMat1 = BoneLookController._tmpMats[0];
  11135. var _tmpMat2 = BoneLookController._tmpMats[1];
  11136. var mesh = this.mesh;
  11137. var parentBone = bone.getParent();
  11138. var upAxis = BoneLookController._tmpVecs[1];
  11139. upAxis.copyFrom(this.upAxis);
  11140. if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE && parentBone) {
  11141. if (this._transformYawPitch) {
  11142. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(upAxis, this._transformYawPitchInv, upAxis);
  11143. }
  11144. parentBone.getDirectionToRef(upAxis, this.mesh, upAxis);
  11145. }
  11146. else if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  11147. mesh.getDirectionToRef(upAxis, upAxis);
  11148. if (mesh.scaling.x != 1 || mesh.scaling.y != 1 || mesh.scaling.z != 1) {
  11149. upAxis.normalize();
  11150. }
  11151. }
  11152. var checkYaw = false;
  11153. var checkPitch = false;
  11154. if (this._maxYaw != Math.PI || this._minYaw != -Math.PI) {
  11155. checkYaw = true;
  11156. }
  11157. if (this._maxPitch != Math.PI || this._minPitch != -Math.PI) {
  11158. checkPitch = true;
  11159. }
  11160. if (checkYaw || checkPitch) {
  11161. var spaceMat = BoneLookController._tmpMats[2];
  11162. var spaceMatInv = BoneLookController._tmpMats[3];
  11163. if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE && upAxis.y == 1 && parentBone) {
  11164. parentBone.getRotationMatrixToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh, spaceMat);
  11165. }
  11166. else if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL && upAxis.y == 1 && !parentBone) {
  11167. spaceMat.copyFrom(mesh.getWorldMatrix());
  11168. }
  11169. else {
  11170. var forwardAxis = BoneLookController._tmpVecs[2];
  11171. forwardAxis.copyFrom(this._fowardAxis);
  11172. if (this._transformYawPitch) {
  11173. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(forwardAxis, this._transformYawPitchInv, forwardAxis);
  11174. }
  11175. if (parentBone) {
  11176. parentBone.getDirectionToRef(forwardAxis, this.mesh, forwardAxis);
  11177. }
  11178. else {
  11179. mesh.getDirectionToRef(forwardAxis, forwardAxis);
  11180. }
  11181. var rightAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(upAxis, forwardAxis);
  11182. rightAxis.normalize();
  11183. var forwardAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(rightAxis, upAxis);
  11184. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(rightAxis, upAxis, forwardAxis, spaceMat);
  11185. }
  11186. spaceMat.invertToRef(spaceMatInv);
  11187. var xzlen = null;
  11188. if (checkPitch) {
  11189. var localTarget = BoneLookController._tmpVecs[3];
  11190. target.subtractToRef(bonePos, localTarget);
  11191. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMatInv, localTarget);
  11192. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11193. var pitch = Math.atan2(localTarget.y, xzlen);
  11194. var newPitch = pitch;
  11195. if (pitch > this._maxPitch) {
  11196. localTarget.y = this._maxPitchTan * xzlen;
  11197. newPitch = this._maxPitch;
  11198. }
  11199. else if (pitch < this._minPitch) {
  11200. localTarget.y = this._minPitchTan * xzlen;
  11201. newPitch = this._minPitch;
  11202. }
  11203. if (pitch != newPitch) {
  11204. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMat, localTarget);
  11205. localTarget.addInPlace(bonePos);
  11206. target = localTarget;
  11207. }
  11208. }
  11209. if (checkYaw) {
  11210. var localTarget = BoneLookController._tmpVecs[4];
  11211. target.subtractToRef(bonePos, localTarget);
  11212. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMatInv, localTarget);
  11213. var yaw = Math.atan2(localTarget.x, localTarget.z);
  11214. var newYaw = yaw;
  11215. if (yaw > this._maxYaw || yaw < this._minYaw) {
  11216. if (xzlen == null) {
  11217. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11218. }
  11219. if (this._yawRange > Math.PI) {
  11220. if (this._isAngleBetween(yaw, this._maxYaw, this._midYawConstraint)) {
  11221. localTarget.z = this._maxYawCos * xzlen;
  11222. localTarget.x = this._maxYawSin * xzlen;
  11223. newYaw = this._maxYaw;
  11224. }
  11225. else if (this._isAngleBetween(yaw, this._midYawConstraint, this._minYaw)) {
  11226. localTarget.z = this._minYawCos * xzlen;
  11227. localTarget.x = this._minYawSin * xzlen;
  11228. newYaw = this._minYaw;
  11229. }
  11230. }
  11231. else {
  11232. if (yaw > this._maxYaw) {
  11233. localTarget.z = this._maxYawCos * xzlen;
  11234. localTarget.x = this._maxYawSin * xzlen;
  11235. newYaw = this._maxYaw;
  11236. }
  11237. else if (yaw < this._minYaw) {
  11238. localTarget.z = this._minYawCos * xzlen;
  11239. localTarget.x = this._minYawSin * xzlen;
  11240. newYaw = this._minYaw;
  11241. }
  11242. }
  11243. }
  11244. if (this._slerping && this._yawRange > Math.PI) {
  11245. //are we going to be crossing into the min/max region?
  11246. var boneFwd = BoneLookController._tmpVecs[8];
  11247. boneFwd.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].Z);
  11248. if (this._transformYawPitch) {
  11249. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, this._transformYawPitchInv, boneFwd);
  11250. }
  11251. var boneRotMat = BoneLookController._tmpMats[4];
  11252. this._boneQuat.toRotationMatrix(boneRotMat);
  11253. this.mesh.getWorldMatrix().multiplyToRef(boneRotMat, boneRotMat);
  11254. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, boneRotMat, boneFwd);
  11255. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, spaceMatInv, boneFwd);
  11256. var boneYaw = Math.atan2(boneFwd.x, boneFwd.z);
  11257. var angBtwTar = this._getAngleBetween(boneYaw, yaw);
  11258. var angBtwMidYaw = this._getAngleBetween(boneYaw, this._midYawConstraint);
  11259. if (angBtwTar > angBtwMidYaw) {
  11260. if (xzlen == null) {
  11261. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11262. }
  11263. var angBtwMax = this._getAngleBetween(boneYaw, this._maxYaw);
  11264. var angBtwMin = this._getAngleBetween(boneYaw, this._minYaw);
  11265. if (angBtwMin < angBtwMax) {
  11266. newYaw = boneYaw + Math.PI * .75;
  11267. localTarget.z = Math.cos(newYaw) * xzlen;
  11268. localTarget.x = Math.sin(newYaw) * xzlen;
  11269. }
  11270. else {
  11271. newYaw = boneYaw - Math.PI * .75;
  11272. localTarget.z = Math.cos(newYaw) * xzlen;
  11273. localTarget.x = Math.sin(newYaw) * xzlen;
  11274. }
  11275. }
  11276. }
  11277. if (yaw != newYaw) {
  11278. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMat, localTarget);
  11279. localTarget.addInPlace(bonePos);
  11280. target = localTarget;
  11281. }
  11282. }
  11283. }
  11284. var zaxis = BoneLookController._tmpVecs[5];
  11285. var xaxis = BoneLookController._tmpVecs[6];
  11286. var yaxis = BoneLookController._tmpVecs[7];
  11287. var _tmpQuat = BoneLookController._tmpQuat;
  11288. target.subtractToRef(bonePos, zaxis);
  11289. zaxis.normalize();
  11290. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(upAxis, zaxis, xaxis);
  11291. xaxis.normalize();
  11292. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(zaxis, xaxis, yaxis);
  11293. yaxis.normalize();
  11294. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(xaxis, yaxis, zaxis, _tmpMat1);
  11295. if (xaxis.x === 0 && xaxis.y === 0 && xaxis.z === 0) {
  11296. return;
  11297. }
  11298. if (yaxis.x === 0 && yaxis.y === 0 && yaxis.z === 0) {
  11299. return;
  11300. }
  11301. if (zaxis.x === 0 && zaxis.y === 0 && zaxis.z === 0) {
  11302. return;
  11303. }
  11304. if (this.adjustYaw || this.adjustPitch || this.adjustRoll) {
  11305. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(this.adjustYaw, this.adjustPitch, this.adjustRoll, _tmpMat2);
  11306. _tmpMat2.multiplyToRef(_tmpMat1, _tmpMat1);
  11307. }
  11308. if (this.slerpAmount < 1) {
  11309. if (!this._slerping) {
  11310. this.bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh, this._boneQuat);
  11311. }
  11312. if (this._transformYawPitch) {
  11313. this._transformYawPitch.multiplyToRef(_tmpMat1, _tmpMat1);
  11314. }
  11315. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(_tmpMat1, _tmpQuat);
  11316. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].SlerpToRef(this._boneQuat, _tmpQuat, this.slerpAmount, this._boneQuat);
  11317. this.bone.setRotationQuaternion(this._boneQuat, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh);
  11318. this._slerping = true;
  11319. }
  11320. else {
  11321. if (this._transformYawPitch) {
  11322. this._transformYawPitch.multiplyToRef(_tmpMat1, _tmpMat1);
  11323. }
  11324. this.bone.setRotationMatrix(_tmpMat1, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh);
  11325. this._slerping = false;
  11326. }
  11327. };
  11328. BoneLookController.prototype._getAngleDiff = function (ang1, ang2) {
  11329. var angDiff = ang2 - ang1;
  11330. angDiff %= Math.PI * 2;
  11331. if (angDiff > Math.PI) {
  11332. angDiff -= Math.PI * 2;
  11333. }
  11334. else if (angDiff < -Math.PI) {
  11335. angDiff += Math.PI * 2;
  11336. }
  11337. return angDiff;
  11338. };
  11339. BoneLookController.prototype._getAngleBetween = function (ang1, ang2) {
  11340. ang1 %= (2 * Math.PI);
  11341. ang1 = (ang1 < 0) ? ang1 + (2 * Math.PI) : ang1;
  11342. ang2 %= (2 * Math.PI);
  11343. ang2 = (ang2 < 0) ? ang2 + (2 * Math.PI) : ang2;
  11344. var ab = 0;
  11345. if (ang1 < ang2) {
  11346. ab = ang2 - ang1;
  11347. }
  11348. else {
  11349. ab = ang1 - ang2;
  11350. }
  11351. if (ab > Math.PI) {
  11352. ab = Math.PI * 2 - ab;
  11353. }
  11354. return ab;
  11355. };
  11356. BoneLookController.prototype._isAngleBetween = function (ang, ang1, ang2) {
  11357. ang %= (2 * Math.PI);
  11358. ang = (ang < 0) ? ang + (2 * Math.PI) : ang;
  11359. ang1 %= (2 * Math.PI);
  11360. ang1 = (ang1 < 0) ? ang1 + (2 * Math.PI) : ang1;
  11361. ang2 %= (2 * Math.PI);
  11362. ang2 = (ang2 < 0) ? ang2 + (2 * Math.PI) : ang2;
  11363. if (ang1 < ang2) {
  11364. if (ang > ang1 && ang < ang2) {
  11365. return true;
  11366. }
  11367. }
  11368. else {
  11369. if (ang > ang2 && ang < ang1) {
  11370. return true;
  11371. }
  11372. }
  11373. return false;
  11374. };
  11375. BoneLookController._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(10, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  11376. BoneLookController._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  11377. BoneLookController._tmpMats = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(5, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity);
  11378. return BoneLookController;
  11379. }());
  11380. /***/ }),
  11381. /***/ "./Bones/index.ts":
  11382. /*!************************!*\
  11383. !*** ./Bones/index.ts ***!
  11384. \************************/
  11385. /*! exports provided: Bone, BoneIKController, BoneLookController, Skeleton */
  11386. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11387. "use strict";
  11388. __webpack_require__.r(__webpack_exports__);
  11389. /* harmony import */ var _bone__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bone */ "./Bones/bone.ts");
  11390. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"]; });
  11391. /* harmony import */ var _boneIKController__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boneIKController */ "./Bones/boneIKController.ts");
  11392. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _boneIKController__WEBPACK_IMPORTED_MODULE_1__["BoneIKController"]; });
  11393. /* harmony import */ var _boneLookController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boneLookController */ "./Bones/boneLookController.ts");
  11394. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _boneLookController__WEBPACK_IMPORTED_MODULE_2__["BoneLookController"]; });
  11395. /* harmony import */ var _skeleton__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./skeleton */ "./Bones/skeleton.ts");
  11396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _skeleton__WEBPACK_IMPORTED_MODULE_3__["Skeleton"]; });
  11397. /***/ }),
  11398. /***/ "./Bones/skeleton.ts":
  11399. /*!***************************!*\
  11400. !*** ./Bones/skeleton.ts ***!
  11401. \***************************/
  11402. /*! exports provided: Skeleton */
  11403. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11404. "use strict";
  11405. __webpack_require__.r(__webpack_exports__);
  11406. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return Skeleton; });
  11407. /* harmony import */ var _bone__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bone */ "./Bones/bone.ts");
  11408. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  11409. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  11410. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  11411. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  11412. /* harmony import */ var _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Animations/animationRange */ "./Animations/animationRange.ts");
  11413. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  11414. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  11415. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  11416. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  11417. /**
  11418. * Class used to handle skinning animations
  11419. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  11420. */
  11421. var Skeleton = /** @class */ (function () {
  11422. /**
  11423. * Creates a new skeleton
  11424. * @param name defines the skeleton name
  11425. * @param id defines the skeleton Id
  11426. * @param scene defines the hosting scene
  11427. */
  11428. function Skeleton(
  11429. /** defines the skeleton name */
  11430. name,
  11431. /** defines the skeleton Id */
  11432. id, scene) {
  11433. this.name = name;
  11434. this.id = id;
  11435. /**
  11436. * Defines the list of child bones
  11437. */
  11438. this.bones = new Array();
  11439. /**
  11440. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  11441. */
  11442. this.needInitialSkinMatrix = false;
  11443. /**
  11444. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  11445. */
  11446. this.overrideMesh = null;
  11447. this._isDirty = true;
  11448. this._meshesWithPoseMatrix = new Array();
  11449. this._identity = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  11450. this._ranges = {};
  11451. this._lastAbsoluteTransformsUpdateId = -1;
  11452. this._canUseTextureForBones = false;
  11453. /** @hidden */
  11454. this._numBonesWithLinkedTransformNode = 0;
  11455. /**
  11456. * Specifies if the skeleton should be serialized
  11457. */
  11458. this.doNotSerialize = false;
  11459. /**
  11460. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  11461. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  11462. */
  11463. this.useTextureToStoreBoneMatrices = true;
  11464. this._animationPropertiesOverride = null;
  11465. // Events
  11466. /**
  11467. * An observable triggered before computing the skeleton's matrices
  11468. */
  11469. this.onBeforeComputeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11470. this.bones = [];
  11471. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__["EngineStore"].LastCreatedScene;
  11472. this._scene.skeletons.push(this);
  11473. //make sure it will recalculate the matrix next time prepare is called.
  11474. this._isDirty = true;
  11475. var engineCaps = this._scene.getEngine().getCaps();
  11476. this._canUseTextureForBones = engineCaps.textureFloat && engineCaps.maxVertexTextureImageUnits > 0;
  11477. }
  11478. Object.defineProperty(Skeleton.prototype, "animationPropertiesOverride", {
  11479. /**
  11480. * Gets or sets the animation properties override
  11481. */
  11482. get: function () {
  11483. if (!this._animationPropertiesOverride) {
  11484. return this._scene.animationPropertiesOverride;
  11485. }
  11486. return this._animationPropertiesOverride;
  11487. },
  11488. set: function (value) {
  11489. this._animationPropertiesOverride = value;
  11490. },
  11491. enumerable: true,
  11492. configurable: true
  11493. });
  11494. Object.defineProperty(Skeleton.prototype, "isUsingTextureForMatrices", {
  11495. /**
  11496. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  11497. */
  11498. get: function () {
  11499. return this.useTextureToStoreBoneMatrices && this._canUseTextureForBones && !this.needInitialSkinMatrix;
  11500. },
  11501. enumerable: true,
  11502. configurable: true
  11503. });
  11504. /**
  11505. * Gets the current object class name.
  11506. * @return the class name
  11507. */
  11508. Skeleton.prototype.getClassName = function () {
  11509. return "Skeleton";
  11510. };
  11511. /**
  11512. * Returns an array containing the root bones
  11513. * @returns an array containing the root bones
  11514. */
  11515. Skeleton.prototype.getChildren = function () {
  11516. return this.bones.filter(function (b) { return !b.getParent(); });
  11517. };
  11518. // Members
  11519. /**
  11520. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  11521. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  11522. * @returns a Float32Array containing matrices data
  11523. */
  11524. Skeleton.prototype.getTransformMatrices = function (mesh) {
  11525. if (this.needInitialSkinMatrix && mesh._bonesTransformMatrices) {
  11526. return mesh._bonesTransformMatrices;
  11527. }
  11528. if (!this._transformMatrices) {
  11529. this.prepare();
  11530. }
  11531. return this._transformMatrices;
  11532. };
  11533. /**
  11534. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  11535. * @returns a raw texture containing the data
  11536. */
  11537. Skeleton.prototype.getTransformMatrixTexture = function () {
  11538. return this._transformMatrixTexture;
  11539. };
  11540. /**
  11541. * Gets the current hosting scene
  11542. * @returns a scene object
  11543. */
  11544. Skeleton.prototype.getScene = function () {
  11545. return this._scene;
  11546. };
  11547. // Methods
  11548. /**
  11549. * Gets a string representing the current skeleton data
  11550. * @param fullDetails defines a boolean indicating if we want a verbose version
  11551. * @returns a string representing the current skeleton data
  11552. */
  11553. Skeleton.prototype.toString = function (fullDetails) {
  11554. var ret = "Name: " + this.name + ", nBones: " + this.bones.length;
  11555. ret += ", nAnimationRanges: " + (this._ranges ? Object.keys(this._ranges).length : "none");
  11556. if (fullDetails) {
  11557. ret += ", Ranges: {";
  11558. var first = true;
  11559. for (var name_1 in this._ranges) {
  11560. if (first) {
  11561. ret += ", ";
  11562. first = false;
  11563. }
  11564. ret += name_1;
  11565. }
  11566. ret += "}";
  11567. }
  11568. return ret;
  11569. };
  11570. /**
  11571. * Get bone's index searching by name
  11572. * @param name defines bone's name to search for
  11573. * @return the indice of the bone. Returns -1 if not found
  11574. */
  11575. Skeleton.prototype.getBoneIndexByName = function (name) {
  11576. for (var boneIndex = 0, cache = this.bones.length; boneIndex < cache; boneIndex++) {
  11577. if (this.bones[boneIndex].name === name) {
  11578. return boneIndex;
  11579. }
  11580. }
  11581. return -1;
  11582. };
  11583. /**
  11584. * Creater a new animation range
  11585. * @param name defines the name of the range
  11586. * @param from defines the start key
  11587. * @param to defines the end key
  11588. */
  11589. Skeleton.prototype.createAnimationRange = function (name, from, to) {
  11590. // check name not already in use
  11591. if (!this._ranges[name]) {
  11592. this._ranges[name] = new _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, from, to);
  11593. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11594. if (this.bones[i].animations[0]) {
  11595. this.bones[i].animations[0].createRange(name, from, to);
  11596. }
  11597. }
  11598. }
  11599. };
  11600. /**
  11601. * Delete a specific animation range
  11602. * @param name defines the name of the range
  11603. * @param deleteFrames defines if frames must be removed as well
  11604. */
  11605. Skeleton.prototype.deleteAnimationRange = function (name, deleteFrames) {
  11606. if (deleteFrames === void 0) { deleteFrames = true; }
  11607. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11608. if (this.bones[i].animations[0]) {
  11609. this.bones[i].animations[0].deleteRange(name, deleteFrames);
  11610. }
  11611. }
  11612. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  11613. };
  11614. /**
  11615. * Gets a specific animation range
  11616. * @param name defines the name of the range to look for
  11617. * @returns the requested animation range or null if not found
  11618. */
  11619. Skeleton.prototype.getAnimationRange = function (name) {
  11620. return this._ranges[name];
  11621. };
  11622. /**
  11623. * Gets the list of all animation ranges defined on this skeleton
  11624. * @returns an array
  11625. */
  11626. Skeleton.prototype.getAnimationRanges = function () {
  11627. var animationRanges = [];
  11628. var name;
  11629. for (name in this._ranges) {
  11630. animationRanges.push(this._ranges[name]);
  11631. }
  11632. return animationRanges;
  11633. };
  11634. /**
  11635. * Copy animation range from a source skeleton.
  11636. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  11637. * @param source defines the source skeleton
  11638. * @param name defines the name of the range to copy
  11639. * @param rescaleAsRequired defines if rescaling must be applied if required
  11640. * @returns true if operation was successful
  11641. */
  11642. Skeleton.prototype.copyAnimationRange = function (source, name, rescaleAsRequired) {
  11643. if (rescaleAsRequired === void 0) { rescaleAsRequired = false; }
  11644. if (this._ranges[name] || !source.getAnimationRange(name)) {
  11645. return false;
  11646. }
  11647. var ret = true;
  11648. var frameOffset = this._getHighestAnimationFrame() + 1;
  11649. // make a dictionary of source skeleton's bones, so exact same order or doublely nested loop is not required
  11650. var boneDict = {};
  11651. var sourceBones = source.bones;
  11652. var nBones;
  11653. var i;
  11654. for (i = 0, nBones = sourceBones.length; i < nBones; i++) {
  11655. boneDict[sourceBones[i].name] = sourceBones[i];
  11656. }
  11657. if (this.bones.length !== sourceBones.length) {
  11658. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Warn("copyAnimationRange: this rig has " + this.bones.length + " bones, while source as " + sourceBones.length);
  11659. ret = false;
  11660. }
  11661. var skelDimensionsRatio = (rescaleAsRequired && this.dimensionsAtRest && source.dimensionsAtRest) ? this.dimensionsAtRest.divide(source.dimensionsAtRest) : null;
  11662. for (i = 0, nBones = this.bones.length; i < nBones; i++) {
  11663. var boneName = this.bones[i].name;
  11664. var sourceBone = boneDict[boneName];
  11665. if (sourceBone) {
  11666. ret = ret && this.bones[i].copyAnimationRange(sourceBone, name, frameOffset, rescaleAsRequired, skelDimensionsRatio);
  11667. }
  11668. else {
  11669. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Warn("copyAnimationRange: not same rig, missing source bone " + boneName);
  11670. ret = false;
  11671. }
  11672. }
  11673. // do not call createAnimationRange(), since it also is done to bones, which was already done
  11674. var range = source.getAnimationRange(name);
  11675. if (range) {
  11676. this._ranges[name] = new _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, range.from + frameOffset, range.to + frameOffset);
  11677. }
  11678. return ret;
  11679. };
  11680. /**
  11681. * Forces the skeleton to go to rest pose
  11682. */
  11683. Skeleton.prototype.returnToRest = function () {
  11684. for (var index = 0; index < this.bones.length; index++) {
  11685. this.bones[index].returnToRest();
  11686. }
  11687. };
  11688. Skeleton.prototype._getHighestAnimationFrame = function () {
  11689. var ret = 0;
  11690. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11691. if (this.bones[i].animations[0]) {
  11692. var highest = this.bones[i].animations[0].getHighestFrame();
  11693. if (ret < highest) {
  11694. ret = highest;
  11695. }
  11696. }
  11697. }
  11698. return ret;
  11699. };
  11700. /**
  11701. * Begin a specific animation range
  11702. * @param name defines the name of the range to start
  11703. * @param loop defines if looping must be turned on (false by default)
  11704. * @param speedRatio defines the speed ratio to apply (1 by default)
  11705. * @param onAnimationEnd defines a callback which will be called when animation will end
  11706. * @returns a new animatable
  11707. */
  11708. Skeleton.prototype.beginAnimation = function (name, loop, speedRatio, onAnimationEnd) {
  11709. var range = this.getAnimationRange(name);
  11710. if (!range) {
  11711. return null;
  11712. }
  11713. return this._scene.beginAnimation(this, range.from, range.to, loop, speedRatio, onAnimationEnd);
  11714. };
  11715. /** @hidden */
  11716. Skeleton.prototype._markAsDirty = function () {
  11717. this._isDirty = true;
  11718. };
  11719. /** @hidden */
  11720. Skeleton.prototype._registerMeshWithPoseMatrix = function (mesh) {
  11721. this._meshesWithPoseMatrix.push(mesh);
  11722. };
  11723. /** @hidden */
  11724. Skeleton.prototype._unregisterMeshWithPoseMatrix = function (mesh) {
  11725. var index = this._meshesWithPoseMatrix.indexOf(mesh);
  11726. if (index > -1) {
  11727. this._meshesWithPoseMatrix.splice(index, 1);
  11728. }
  11729. };
  11730. Skeleton.prototype._computeTransformMatrices = function (targetMatrix, initialSkinMatrix) {
  11731. this.onBeforeComputeObservable.notifyObservers(this);
  11732. for (var index = 0; index < this.bones.length; index++) {
  11733. var bone = this.bones[index];
  11734. var parentBone = bone.getParent();
  11735. if (parentBone) {
  11736. bone.getLocalMatrix().multiplyToRef(parentBone.getWorldMatrix(), bone.getWorldMatrix());
  11737. }
  11738. else {
  11739. if (initialSkinMatrix) {
  11740. bone.getLocalMatrix().multiplyToRef(initialSkinMatrix, bone.getWorldMatrix());
  11741. }
  11742. else {
  11743. bone.getWorldMatrix().copyFrom(bone.getLocalMatrix());
  11744. }
  11745. }
  11746. if (bone._index !== -1) {
  11747. var mappedIndex = bone._index === null ? index : bone._index;
  11748. bone.getInvertedAbsoluteTransform().multiplyToArray(bone.getWorldMatrix(), targetMatrix, mappedIndex * 16);
  11749. }
  11750. }
  11751. this._identity.copyToArray(targetMatrix, this.bones.length * 16);
  11752. };
  11753. /**
  11754. * Build all resources required to render a skeleton
  11755. */
  11756. Skeleton.prototype.prepare = function () {
  11757. // Update the local matrix of bones with linked transform nodes.
  11758. if (this._numBonesWithLinkedTransformNode > 0) {
  11759. for (var _i = 0, _a = this.bones; _i < _a.length; _i++) {
  11760. var bone_1 = _a[_i];
  11761. if (bone_1._linkedTransformNode) {
  11762. // Computing the world matrix also computes the local matrix.
  11763. bone_1._linkedTransformNode.computeWorldMatrix();
  11764. bone_1._matrix = bone_1._linkedTransformNode._localMatrix;
  11765. bone_1.markAsDirty();
  11766. }
  11767. }
  11768. }
  11769. if (!this._isDirty) {
  11770. return;
  11771. }
  11772. if (this.needInitialSkinMatrix) {
  11773. for (var index = 0; index < this._meshesWithPoseMatrix.length; index++) {
  11774. var mesh = this._meshesWithPoseMatrix[index];
  11775. var poseMatrix = mesh.getPoseMatrix();
  11776. if (!mesh._bonesTransformMatrices || mesh._bonesTransformMatrices.length !== 16 * (this.bones.length + 1)) {
  11777. mesh._bonesTransformMatrices = new Float32Array(16 * (this.bones.length + 1));
  11778. }
  11779. if (this._synchronizedWithMesh !== mesh) {
  11780. this._synchronizedWithMesh = mesh;
  11781. // Prepare bones
  11782. for (var boneIndex = 0; boneIndex < this.bones.length; boneIndex++) {
  11783. var bone = this.bones[boneIndex];
  11784. if (!bone.getParent()) {
  11785. var matrix = bone.getBaseMatrix();
  11786. matrix.multiplyToRef(poseMatrix, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[1]);
  11787. bone._updateDifferenceMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[1]);
  11788. }
  11789. }
  11790. }
  11791. this._computeTransformMatrices(mesh._bonesTransformMatrices, poseMatrix);
  11792. }
  11793. }
  11794. else {
  11795. if (!this._transformMatrices || this._transformMatrices.length !== 16 * (this.bones.length + 1)) {
  11796. this._transformMatrices = new Float32Array(16 * (this.bones.length + 1));
  11797. if (this.isUsingTextureForMatrices) {
  11798. if (this._transformMatrixTexture) {
  11799. this._transformMatrixTexture.dispose();
  11800. }
  11801. this._transformMatrixTexture = _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_3__["RawTexture"].CreateRGBATexture(this._transformMatrices, (this.bones.length + 1) * 4, 1, this._scene, false, false, _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE, _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_FLOAT);
  11802. }
  11803. }
  11804. this._computeTransformMatrices(this._transformMatrices, null);
  11805. if (this.isUsingTextureForMatrices && this._transformMatrixTexture) {
  11806. this._transformMatrixTexture.update(this._transformMatrices);
  11807. }
  11808. }
  11809. this._isDirty = false;
  11810. this._scene._activeBones.addCount(this.bones.length, false);
  11811. };
  11812. /**
  11813. * Gets the list of animatables currently running for this skeleton
  11814. * @returns an array of animatables
  11815. */
  11816. Skeleton.prototype.getAnimatables = function () {
  11817. if (!this._animatables || this._animatables.length !== this.bones.length) {
  11818. this._animatables = [];
  11819. for (var index = 0; index < this.bones.length; index++) {
  11820. this._animatables.push(this.bones[index]);
  11821. }
  11822. }
  11823. return this._animatables;
  11824. };
  11825. /**
  11826. * Clone the current skeleton
  11827. * @param name defines the name of the new skeleton
  11828. * @param id defines the id of the enw skeleton
  11829. * @returns the new skeleton
  11830. */
  11831. Skeleton.prototype.clone = function (name, id) {
  11832. var result = new Skeleton(name, id || name, this._scene);
  11833. result.needInitialSkinMatrix = this.needInitialSkinMatrix;
  11834. for (var index = 0; index < this.bones.length; index++) {
  11835. var source = this.bones[index];
  11836. var parentBone = null;
  11837. var parent_1 = source.getParent();
  11838. if (parent_1) {
  11839. var parentIndex = this.bones.indexOf(parent_1);
  11840. parentBone = result.bones[parentIndex];
  11841. }
  11842. var bone = new _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"](source.name, result, parentBone, source.getBaseMatrix().clone(), source.getRestPose().clone());
  11843. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_9__["DeepCopier"].DeepCopy(source.animations, bone.animations);
  11844. }
  11845. if (this._ranges) {
  11846. result._ranges = {};
  11847. for (var rangeName in this._ranges) {
  11848. var range = this._ranges[rangeName];
  11849. if (range) {
  11850. result._ranges[rangeName] = range.clone();
  11851. }
  11852. }
  11853. }
  11854. this._isDirty = true;
  11855. return result;
  11856. };
  11857. /**
  11858. * Enable animation blending for this skeleton
  11859. * @param blendingSpeed defines the blending speed to apply
  11860. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  11861. */
  11862. Skeleton.prototype.enableBlending = function (blendingSpeed) {
  11863. if (blendingSpeed === void 0) { blendingSpeed = 0.01; }
  11864. this.bones.forEach(function (bone) {
  11865. bone.animations.forEach(function (animation) {
  11866. animation.enableBlending = true;
  11867. animation.blendingSpeed = blendingSpeed;
  11868. });
  11869. });
  11870. };
  11871. /**
  11872. * Releases all resources associated with the current skeleton
  11873. */
  11874. Skeleton.prototype.dispose = function () {
  11875. this._meshesWithPoseMatrix = [];
  11876. // Animations
  11877. this.getScene().stopAnimation(this);
  11878. // Remove from scene
  11879. this.getScene().removeSkeleton(this);
  11880. if (this._transformMatrixTexture) {
  11881. this._transformMatrixTexture.dispose();
  11882. this._transformMatrixTexture = null;
  11883. }
  11884. };
  11885. /**
  11886. * Serialize the skeleton in a JSON object
  11887. * @returns a JSON object
  11888. */
  11889. Skeleton.prototype.serialize = function () {
  11890. var serializationObject = {};
  11891. serializationObject.name = this.name;
  11892. serializationObject.id = this.id;
  11893. if (this.dimensionsAtRest) {
  11894. serializationObject.dimensionsAtRest = this.dimensionsAtRest.asArray();
  11895. }
  11896. serializationObject.bones = [];
  11897. serializationObject.needInitialSkinMatrix = this.needInitialSkinMatrix;
  11898. for (var index = 0; index < this.bones.length; index++) {
  11899. var bone = this.bones[index];
  11900. var parent_2 = bone.getParent();
  11901. var serializedBone = {
  11902. parentBoneIndex: parent_2 ? this.bones.indexOf(parent_2) : -1,
  11903. name: bone.name,
  11904. matrix: bone.getBaseMatrix().toArray(),
  11905. rest: bone.getRestPose().toArray()
  11906. };
  11907. serializationObject.bones.push(serializedBone);
  11908. if (bone.length) {
  11909. serializedBone.length = bone.length;
  11910. }
  11911. if (bone.metadata) {
  11912. serializedBone.metadata = bone.metadata;
  11913. }
  11914. if (bone.animations && bone.animations.length > 0) {
  11915. serializedBone.animation = bone.animations[0].serialize();
  11916. }
  11917. serializationObject.ranges = [];
  11918. for (var name in this._ranges) {
  11919. var source = this._ranges[name];
  11920. if (!source) {
  11921. continue;
  11922. }
  11923. var range = {};
  11924. range.name = name;
  11925. range.from = source.from;
  11926. range.to = source.to;
  11927. serializationObject.ranges.push(range);
  11928. }
  11929. }
  11930. return serializationObject;
  11931. };
  11932. /**
  11933. * Creates a new skeleton from serialized data
  11934. * @param parsedSkeleton defines the serialized data
  11935. * @param scene defines the hosting scene
  11936. * @returns a new skeleton
  11937. */
  11938. Skeleton.Parse = function (parsedSkeleton, scene) {
  11939. var skeleton = new Skeleton(parsedSkeleton.name, parsedSkeleton.id, scene);
  11940. if (parsedSkeleton.dimensionsAtRest) {
  11941. skeleton.dimensionsAtRest = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSkeleton.dimensionsAtRest);
  11942. }
  11943. skeleton.needInitialSkinMatrix = parsedSkeleton.needInitialSkinMatrix;
  11944. var index;
  11945. for (index = 0; index < parsedSkeleton.bones.length; index++) {
  11946. var parsedBone = parsedSkeleton.bones[index];
  11947. var parentBone = null;
  11948. if (parsedBone.parentBoneIndex > -1) {
  11949. parentBone = skeleton.bones[parsedBone.parentBoneIndex];
  11950. }
  11951. var rest = parsedBone.rest ? _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(parsedBone.rest) : null;
  11952. var bone = new _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"](parsedBone.name, skeleton, parentBone, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(parsedBone.matrix), rest);
  11953. if (parsedBone.id !== undefined && parsedBone.id !== null) {
  11954. bone.id = parsedBone.id;
  11955. }
  11956. if (parsedBone.length) {
  11957. bone.length = parsedBone.length;
  11958. }
  11959. if (parsedBone.metadata) {
  11960. bone.metadata = parsedBone.metadata;
  11961. }
  11962. if (parsedBone.animation) {
  11963. bone.animations.push(_Animations_animation__WEBPACK_IMPORTED_MODULE_4__["Animation"].Parse(parsedBone.animation));
  11964. }
  11965. }
  11966. // placed after bones, so createAnimationRange can cascade down
  11967. if (parsedSkeleton.ranges) {
  11968. for (index = 0; index < parsedSkeleton.ranges.length; index++) {
  11969. var data = parsedSkeleton.ranges[index];
  11970. skeleton.createAnimationRange(data.name, data.from, data.to);
  11971. }
  11972. }
  11973. return skeleton;
  11974. };
  11975. /**
  11976. * Compute all node absolute transforms
  11977. * @param forceUpdate defines if computation must be done even if cache is up to date
  11978. */
  11979. Skeleton.prototype.computeAbsoluteTransforms = function (forceUpdate) {
  11980. if (forceUpdate === void 0) { forceUpdate = false; }
  11981. var renderId = this._scene.getRenderId();
  11982. if (this._lastAbsoluteTransformsUpdateId != renderId || forceUpdate) {
  11983. this.bones[0].computeAbsoluteTransforms();
  11984. this._lastAbsoluteTransformsUpdateId = renderId;
  11985. }
  11986. };
  11987. /**
  11988. * Gets the root pose matrix
  11989. * @returns a matrix
  11990. */
  11991. Skeleton.prototype.getPoseMatrix = function () {
  11992. var poseMatrix = null;
  11993. if (this._meshesWithPoseMatrix.length > 0) {
  11994. poseMatrix = this._meshesWithPoseMatrix[0].getPoseMatrix();
  11995. }
  11996. return poseMatrix;
  11997. };
  11998. /**
  11999. * Sorts bones per internal index
  12000. */
  12001. Skeleton.prototype.sortBones = function () {
  12002. var bones = new Array();
  12003. var visited = new Array(this.bones.length);
  12004. for (var index = 0; index < this.bones.length; index++) {
  12005. this._sortBones(index, bones, visited);
  12006. }
  12007. this.bones = bones;
  12008. };
  12009. Skeleton.prototype._sortBones = function (index, bones, visited) {
  12010. if (visited[index]) {
  12011. return;
  12012. }
  12013. visited[index] = true;
  12014. var bone = this.bones[index];
  12015. if (bone._index === undefined) {
  12016. bone._index = index;
  12017. }
  12018. var parentBone = bone.getParent();
  12019. if (parentBone) {
  12020. this._sortBones(this.bones.indexOf(parentBone), bones, visited);
  12021. }
  12022. bones.push(bone);
  12023. };
  12024. return Skeleton;
  12025. }());
  12026. /***/ }),
  12027. /***/ "./Cameras/Inputs/BaseCameraPointersInput.ts":
  12028. /*!***************************************************!*\
  12029. !*** ./Cameras/Inputs/BaseCameraPointersInput.ts ***!
  12030. \***************************************************/
  12031. /*! exports provided: BaseCameraPointersInput */
  12032. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12033. "use strict";
  12034. __webpack_require__.r(__webpack_exports__);
  12035. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseCameraPointersInput", function() { return BaseCameraPointersInput; });
  12036. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12037. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12038. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  12039. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  12040. /**
  12041. * Base class for Camera Pointer Inputs.
  12042. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  12043. * for example usage.
  12044. */
  12045. var BaseCameraPointersInput = /** @class */ (function () {
  12046. function BaseCameraPointersInput() {
  12047. /**
  12048. * Defines the buttons associated with the input to handle camera move.
  12049. */
  12050. this.buttons = [0, 1, 2];
  12051. }
  12052. /**
  12053. * Attach the input controls to a specific dom element to get the input from.
  12054. * @param element Defines the element the controls should be listened from
  12055. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12056. */
  12057. BaseCameraPointersInput.prototype.attachControl = function (element, noPreventDefault) {
  12058. var _this = this;
  12059. var engine = this.camera.getEngine();
  12060. var pointA = null;
  12061. var pointB = null;
  12062. var previousPinchSquaredDistance = 0;
  12063. var previousMultiTouchPanPosition = null;
  12064. this._altKey = false;
  12065. this._ctrlKey = false;
  12066. this._metaKey = false;
  12067. this._shiftKey = false;
  12068. this._buttonsPressed = 0;
  12069. this._pointerInput = function (p, s) {
  12070. var evt = p.event;
  12071. var isTouch = evt.pointerType === "touch";
  12072. if (engine.isInVRExclusivePointerMode) {
  12073. return;
  12074. }
  12075. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE &&
  12076. _this.buttons.indexOf(evt.button) === -1) {
  12077. return;
  12078. }
  12079. var srcElement = (evt.srcElement || evt.target);
  12080. _this._altKey = evt.altKey;
  12081. _this._ctrlKey = evt.ctrlKey;
  12082. _this._metaKey = evt.metaKey;
  12083. _this._shiftKey = evt.shiftKey;
  12084. _this._buttonsPressed = evt.buttons;
  12085. if (engine.isPointerLock) {
  12086. var offsetX = evt.movementX ||
  12087. evt.mozMovementX ||
  12088. evt.webkitMovementX ||
  12089. evt.msMovementX ||
  12090. 0;
  12091. var offsetY = evt.movementY ||
  12092. evt.mozMovementY ||
  12093. evt.webkitMovementY ||
  12094. evt.msMovementY ||
  12095. 0;
  12096. _this.onTouch(null, offsetX, offsetY);
  12097. pointA = null;
  12098. pointB = null;
  12099. }
  12100. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN && srcElement) {
  12101. try {
  12102. srcElement.setPointerCapture(evt.pointerId);
  12103. }
  12104. catch (e) {
  12105. //Nothing to do with the error. Execution will continue.
  12106. }
  12107. if (pointA === null) {
  12108. pointA = { x: evt.clientX,
  12109. y: evt.clientY,
  12110. pointerId: evt.pointerId,
  12111. type: evt.pointerType };
  12112. }
  12113. else if (pointB === null) {
  12114. pointB = { x: evt.clientX,
  12115. y: evt.clientY,
  12116. pointerId: evt.pointerId,
  12117. type: evt.pointerType };
  12118. }
  12119. _this.onButtonDown(evt, pointB ? 2 : 1);
  12120. if (!noPreventDefault) {
  12121. evt.preventDefault();
  12122. element.focus();
  12123. }
  12124. }
  12125. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOUBLETAP) {
  12126. _this.onDoubleTap(evt.pointerType);
  12127. }
  12128. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP && srcElement) {
  12129. try {
  12130. srcElement.releasePointerCapture(evt.pointerId);
  12131. }
  12132. catch (e) {
  12133. //Nothing to do with the error.
  12134. }
  12135. if (!isTouch) {
  12136. pointB = null; // Mouse and pen are mono pointer
  12137. }
  12138. //would be better to use pointers.remove(evt.pointerId) for multitouch gestures,
  12139. //but emptying completely pointers collection is required to fix a bug on iPhone :
  12140. //when changing orientation while pinching camera,
  12141. //one pointer stay pressed forever if we don't release all pointers
  12142. //will be ok to put back pointers.remove(evt.pointerId); when iPhone bug corrected
  12143. if (engine._badOS) {
  12144. pointA = pointB = null;
  12145. }
  12146. else {
  12147. //only remove the impacted pointer in case of multitouch allowing on most
  12148. //platforms switching from rotate to zoom and pan seamlessly.
  12149. if (pointB && pointA && pointA.pointerId == evt.pointerId) {
  12150. pointA = pointB;
  12151. pointB = null;
  12152. }
  12153. else if (pointA && pointB && pointB.pointerId == evt.pointerId) {
  12154. pointB = null;
  12155. }
  12156. else {
  12157. pointA = pointB = null;
  12158. }
  12159. }
  12160. if (previousPinchSquaredDistance !== 0 || previousMultiTouchPanPosition) {
  12161. // Previous pinch data is populated but a button has been lifted
  12162. // so pinch has ended.
  12163. _this.onMultiTouch(pointA, pointB, previousPinchSquaredDistance, 0, // pinchSquaredDistance
  12164. previousMultiTouchPanPosition, null // multiTouchPanPosition
  12165. );
  12166. previousPinchSquaredDistance = 0;
  12167. previousMultiTouchPanPosition = null;
  12168. }
  12169. _this.onButtonUp(evt);
  12170. if (!noPreventDefault) {
  12171. evt.preventDefault();
  12172. }
  12173. }
  12174. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  12175. if (!noPreventDefault) {
  12176. evt.preventDefault();
  12177. }
  12178. // One button down
  12179. if (pointA && pointB === null) {
  12180. var offsetX = evt.clientX - pointA.x;
  12181. var offsetY = evt.clientY - pointA.y;
  12182. _this.onTouch(pointA, offsetX, offsetY);
  12183. pointA.x = evt.clientX;
  12184. pointA.y = evt.clientY;
  12185. }
  12186. // Two buttons down: pinch
  12187. else if (pointA && pointB) {
  12188. var ed = (pointA.pointerId === evt.pointerId) ? pointA : pointB;
  12189. ed.x = evt.clientX;
  12190. ed.y = evt.clientY;
  12191. var distX = pointA.x - pointB.x;
  12192. var distY = pointA.y - pointB.y;
  12193. var pinchSquaredDistance = (distX * distX) + (distY * distY);
  12194. var multiTouchPanPosition = { x: (pointA.x + pointB.x) / 2,
  12195. y: (pointA.y + pointB.y) / 2,
  12196. pointerId: evt.pointerId,
  12197. type: p.type };
  12198. _this.onMultiTouch(pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition);
  12199. previousMultiTouchPanPosition = multiTouchPanPosition;
  12200. previousPinchSquaredDistance = pinchSquaredDistance;
  12201. }
  12202. }
  12203. };
  12204. this._observer = this.camera.getScene().onPointerObservable.add(this._pointerInput, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP |
  12205. _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE);
  12206. this._onLostFocus = function () {
  12207. pointA = pointB = null;
  12208. previousPinchSquaredDistance = 0;
  12209. previousMultiTouchPanPosition = null;
  12210. _this.onLostFocus();
  12211. };
  12212. element.addEventListener("contextmenu", this.onContextMenu.bind(this), false);
  12213. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].RegisterTopRootEvents([
  12214. { name: "blur", handler: this._onLostFocus }
  12215. ]);
  12216. };
  12217. /**
  12218. * Detach the current controls from the specified dom element.
  12219. * @param element Defines the element to stop listening the inputs from
  12220. */
  12221. BaseCameraPointersInput.prototype.detachControl = function (element) {
  12222. if (this._onLostFocus) {
  12223. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].UnregisterTopRootEvents([
  12224. { name: "blur", handler: this._onLostFocus }
  12225. ]);
  12226. }
  12227. if (element && this._observer) {
  12228. this.camera.getScene().onPointerObservable.remove(this._observer);
  12229. this._observer = null;
  12230. if (this.onContextMenu) {
  12231. element.removeEventListener("contextmenu", this.onContextMenu);
  12232. }
  12233. this._onLostFocus = null;
  12234. }
  12235. this._altKey = false;
  12236. this._ctrlKey = false;
  12237. this._metaKey = false;
  12238. this._shiftKey = false;
  12239. this._buttonsPressed = 0;
  12240. };
  12241. /**
  12242. * Gets the class name of the current input.
  12243. * @returns the class name
  12244. */
  12245. BaseCameraPointersInput.prototype.getClassName = function () {
  12246. return "BaseCameraPointersInput";
  12247. };
  12248. /**
  12249. * Get the friendly name associated with the input class.
  12250. * @returns the input friendly name
  12251. */
  12252. BaseCameraPointersInput.prototype.getSimpleName = function () {
  12253. return "pointers";
  12254. };
  12255. /**
  12256. * Called on pointer POINTERDOUBLETAP event.
  12257. * Override this method to provide functionality on POINTERDOUBLETAP event.
  12258. */
  12259. BaseCameraPointersInput.prototype.onDoubleTap = function (type) {
  12260. };
  12261. /**
  12262. * Called on pointer POINTERMOVE event if only a single touch is active.
  12263. * Override this method to provide functionality.
  12264. */
  12265. BaseCameraPointersInput.prototype.onTouch = function (point, offsetX, offsetY) {
  12266. };
  12267. /**
  12268. * Called on pointer POINTERMOVE event if multiple touches are active.
  12269. * Override this method to provide functionality.
  12270. */
  12271. BaseCameraPointersInput.prototype.onMultiTouch = function (pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition) {
  12272. };
  12273. /**
  12274. * Called on JS contextmenu event.
  12275. * Override this method to provide functionality.
  12276. */
  12277. BaseCameraPointersInput.prototype.onContextMenu = function (evt) {
  12278. evt.preventDefault();
  12279. };
  12280. /**
  12281. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  12282. * press.
  12283. * Override this method to provide functionality.
  12284. */
  12285. BaseCameraPointersInput.prototype.onButtonDown = function (evt, buttonCount) {
  12286. };
  12287. /**
  12288. * Called each time a new POINTERUP event occurs. Ie, for each button
  12289. * release.
  12290. * Override this method to provide functionality.
  12291. */
  12292. BaseCameraPointersInput.prototype.onButtonUp = function (evt) {
  12293. };
  12294. /**
  12295. * Called when window becomes inactive.
  12296. * Override this method to provide functionality.
  12297. */
  12298. BaseCameraPointersInput.prototype.onLostFocus = function () {
  12299. };
  12300. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12301. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12302. ], BaseCameraPointersInput.prototype, "buttons", void 0);
  12303. return BaseCameraPointersInput;
  12304. }());
  12305. /***/ }),
  12306. /***/ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts":
  12307. /*!*******************************************************!*\
  12308. !*** ./Cameras/Inputs/arcRotateCameraGamepadInput.ts ***!
  12309. \*******************************************************/
  12310. /*! exports provided: ArcRotateCameraGamepadInput */
  12311. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12312. "use strict";
  12313. __webpack_require__.r(__webpack_exports__);
  12314. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return ArcRotateCameraGamepadInput; });
  12315. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12316. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12317. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12318. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  12319. /**
  12320. * Manage the gamepad inputs to control an arc rotate camera.
  12321. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12322. */
  12323. var ArcRotateCameraGamepadInput = /** @class */ (function () {
  12324. function ArcRotateCameraGamepadInput() {
  12325. /**
  12326. * Defines the gamepad rotation sensiblity.
  12327. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  12328. */
  12329. this.gamepadRotationSensibility = 80;
  12330. /**
  12331. * Defines the gamepad move sensiblity.
  12332. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  12333. */
  12334. this.gamepadMoveSensibility = 40;
  12335. }
  12336. /**
  12337. * Attach the input controls to a specific dom element to get the input from.
  12338. * @param element Defines the element the controls should be listened from
  12339. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12340. */
  12341. ArcRotateCameraGamepadInput.prototype.attachControl = function (element, noPreventDefault) {
  12342. var _this = this;
  12343. var manager = this.camera.getScene().gamepadManager;
  12344. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  12345. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].POSE_ENABLED) {
  12346. // prioritize XBOX gamepads.
  12347. if (!_this.gamepad || gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].XBOX) {
  12348. _this.gamepad = gamepad;
  12349. }
  12350. }
  12351. });
  12352. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  12353. if (_this.gamepad === gamepad) {
  12354. _this.gamepad = null;
  12355. }
  12356. });
  12357. this.gamepad = manager.getGamepadByType(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].XBOX);
  12358. };
  12359. /**
  12360. * Detach the current controls from the specified dom element.
  12361. * @param element Defines the element to stop listening the inputs from
  12362. */
  12363. ArcRotateCameraGamepadInput.prototype.detachControl = function (element) {
  12364. this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  12365. this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  12366. this.gamepad = null;
  12367. };
  12368. /**
  12369. * Update the current camera state depending on the inputs that have been used this frame.
  12370. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12371. */
  12372. ArcRotateCameraGamepadInput.prototype.checkInputs = function () {
  12373. if (this.gamepad) {
  12374. var camera = this.camera;
  12375. var RSValues = this.gamepad.rightStick;
  12376. if (RSValues) {
  12377. if (RSValues.x != 0) {
  12378. var normalizedRX = RSValues.x / this.gamepadRotationSensibility;
  12379. if (normalizedRX != 0 && Math.abs(normalizedRX) > 0.005) {
  12380. camera.inertialAlphaOffset += normalizedRX;
  12381. }
  12382. }
  12383. if (RSValues.y != 0) {
  12384. var normalizedRY = RSValues.y / this.gamepadRotationSensibility;
  12385. if (normalizedRY != 0 && Math.abs(normalizedRY) > 0.005) {
  12386. camera.inertialBetaOffset += normalizedRY;
  12387. }
  12388. }
  12389. }
  12390. var LSValues = this.gamepad.leftStick;
  12391. if (LSValues && LSValues.y != 0) {
  12392. var normalizedLY = LSValues.y / this.gamepadMoveSensibility;
  12393. if (normalizedLY != 0 && Math.abs(normalizedLY) > 0.005) {
  12394. this.camera.inertialRadiusOffset -= normalizedLY;
  12395. }
  12396. }
  12397. }
  12398. };
  12399. /**
  12400. * Gets the class name of the current intput.
  12401. * @returns the class name
  12402. */
  12403. ArcRotateCameraGamepadInput.prototype.getClassName = function () {
  12404. return "ArcRotateCameraGamepadInput";
  12405. };
  12406. /**
  12407. * Get the friendly name associated with the input class.
  12408. * @returns the input friendly name
  12409. */
  12410. ArcRotateCameraGamepadInput.prototype.getSimpleName = function () {
  12411. return "gamepad";
  12412. };
  12413. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12414. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12415. ], ArcRotateCameraGamepadInput.prototype, "gamepadRotationSensibility", void 0);
  12416. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12417. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12418. ], ArcRotateCameraGamepadInput.prototype, "gamepadMoveSensibility", void 0);
  12419. return ArcRotateCameraGamepadInput;
  12420. }());
  12421. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraGamepadInput"] = ArcRotateCameraGamepadInput;
  12422. /***/ }),
  12423. /***/ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts":
  12424. /*!************************************************************!*\
  12425. !*** ./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts ***!
  12426. \************************************************************/
  12427. /*! exports provided: ArcRotateCameraKeyboardMoveInput */
  12428. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12429. "use strict";
  12430. __webpack_require__.r(__webpack_exports__);
  12431. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return ArcRotateCameraKeyboardMoveInput; });
  12432. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12433. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12434. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12435. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  12436. /**
  12437. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  12438. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12439. */
  12440. var ArcRotateCameraKeyboardMoveInput = /** @class */ (function () {
  12441. function ArcRotateCameraKeyboardMoveInput() {
  12442. /**
  12443. * Defines the list of key codes associated with the up action (increase alpha)
  12444. */
  12445. this.keysUp = [38];
  12446. /**
  12447. * Defines the list of key codes associated with the down action (decrease alpha)
  12448. */
  12449. this.keysDown = [40];
  12450. /**
  12451. * Defines the list of key codes associated with the left action (increase beta)
  12452. */
  12453. this.keysLeft = [37];
  12454. /**
  12455. * Defines the list of key codes associated with the right action (decrease beta)
  12456. */
  12457. this.keysRight = [39];
  12458. /**
  12459. * Defines the list of key codes associated with the reset action.
  12460. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  12461. */
  12462. this.keysReset = [220];
  12463. /**
  12464. * Defines the panning sensibility of the inputs.
  12465. * (How fast is the camera paning)
  12466. */
  12467. this.panningSensibility = 50.0;
  12468. /**
  12469. * Defines the zooming sensibility of the inputs.
  12470. * (How fast is the camera zooming)
  12471. */
  12472. this.zoomingSensibility = 25.0;
  12473. /**
  12474. * Defines wether maintaining the alt key down switch the movement mode from
  12475. * orientation to zoom.
  12476. */
  12477. this.useAltToZoom = true;
  12478. /**
  12479. * Rotation speed of the camera
  12480. */
  12481. this.angularSpeed = 0.01;
  12482. this._keys = new Array();
  12483. }
  12484. /**
  12485. * Attach the input controls to a specific dom element to get the input from.
  12486. * @param element Defines the element the controls should be listened from
  12487. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12488. */
  12489. ArcRotateCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  12490. var _this = this;
  12491. if (this._onCanvasBlurObserver) {
  12492. return;
  12493. }
  12494. this._scene = this.camera.getScene();
  12495. this._engine = this._scene.getEngine();
  12496. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  12497. _this._keys = [];
  12498. });
  12499. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  12500. var evt = info.event;
  12501. if (!evt.metaKey) {
  12502. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  12503. _this._ctrlPressed = evt.ctrlKey;
  12504. _this._altPressed = evt.altKey;
  12505. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  12506. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  12507. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  12508. _this.keysRight.indexOf(evt.keyCode) !== -1 ||
  12509. _this.keysReset.indexOf(evt.keyCode) !== -1) {
  12510. var index = _this._keys.indexOf(evt.keyCode);
  12511. if (index === -1) {
  12512. _this._keys.push(evt.keyCode);
  12513. }
  12514. if (evt.preventDefault) {
  12515. if (!noPreventDefault) {
  12516. evt.preventDefault();
  12517. }
  12518. }
  12519. }
  12520. }
  12521. else {
  12522. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  12523. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  12524. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  12525. _this.keysRight.indexOf(evt.keyCode) !== -1 ||
  12526. _this.keysReset.indexOf(evt.keyCode) !== -1) {
  12527. var index = _this._keys.indexOf(evt.keyCode);
  12528. if (index >= 0) {
  12529. _this._keys.splice(index, 1);
  12530. }
  12531. if (evt.preventDefault) {
  12532. if (!noPreventDefault) {
  12533. evt.preventDefault();
  12534. }
  12535. }
  12536. }
  12537. }
  12538. }
  12539. });
  12540. };
  12541. /**
  12542. * Detach the current controls from the specified dom element.
  12543. * @param element Defines the element to stop listening the inputs from
  12544. */
  12545. ArcRotateCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  12546. if (this._scene) {
  12547. if (this._onKeyboardObserver) {
  12548. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  12549. }
  12550. if (this._onCanvasBlurObserver) {
  12551. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  12552. }
  12553. this._onKeyboardObserver = null;
  12554. this._onCanvasBlurObserver = null;
  12555. }
  12556. this._keys = [];
  12557. };
  12558. /**
  12559. * Update the current camera state depending on the inputs that have been used this frame.
  12560. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12561. */
  12562. ArcRotateCameraKeyboardMoveInput.prototype.checkInputs = function () {
  12563. if (this._onKeyboardObserver) {
  12564. var camera = this.camera;
  12565. for (var index = 0; index < this._keys.length; index++) {
  12566. var keyCode = this._keys[index];
  12567. if (this.keysLeft.indexOf(keyCode) !== -1) {
  12568. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12569. camera.inertialPanningX -= 1 / this.panningSensibility;
  12570. }
  12571. else {
  12572. camera.inertialAlphaOffset -= this.angularSpeed;
  12573. }
  12574. }
  12575. else if (this.keysUp.indexOf(keyCode) !== -1) {
  12576. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12577. camera.inertialPanningY += 1 / this.panningSensibility;
  12578. }
  12579. else if (this._altPressed && this.useAltToZoom) {
  12580. camera.inertialRadiusOffset += 1 / this.zoomingSensibility;
  12581. }
  12582. else {
  12583. camera.inertialBetaOffset -= this.angularSpeed;
  12584. }
  12585. }
  12586. else if (this.keysRight.indexOf(keyCode) !== -1) {
  12587. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12588. camera.inertialPanningX += 1 / this.panningSensibility;
  12589. }
  12590. else {
  12591. camera.inertialAlphaOffset += this.angularSpeed;
  12592. }
  12593. }
  12594. else if (this.keysDown.indexOf(keyCode) !== -1) {
  12595. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12596. camera.inertialPanningY -= 1 / this.panningSensibility;
  12597. }
  12598. else if (this._altPressed && this.useAltToZoom) {
  12599. camera.inertialRadiusOffset -= 1 / this.zoomingSensibility;
  12600. }
  12601. else {
  12602. camera.inertialBetaOffset += this.angularSpeed;
  12603. }
  12604. }
  12605. else if (this.keysReset.indexOf(keyCode) !== -1) {
  12606. if (camera.useInputToRestoreState) {
  12607. camera.restoreState();
  12608. }
  12609. }
  12610. }
  12611. }
  12612. };
  12613. /**
  12614. * Gets the class name of the current intput.
  12615. * @returns the class name
  12616. */
  12617. ArcRotateCameraKeyboardMoveInput.prototype.getClassName = function () {
  12618. return "ArcRotateCameraKeyboardMoveInput";
  12619. };
  12620. /**
  12621. * Get the friendly name associated with the input class.
  12622. * @returns the input friendly name
  12623. */
  12624. ArcRotateCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  12625. return "keyboard";
  12626. };
  12627. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12628. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12629. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysUp", void 0);
  12630. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12631. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12632. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysDown", void 0);
  12633. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12634. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12635. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
  12636. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12637. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12638. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysRight", void 0);
  12639. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12640. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12641. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysReset", void 0);
  12642. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12643. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12644. ], ArcRotateCameraKeyboardMoveInput.prototype, "panningSensibility", void 0);
  12645. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12646. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12647. ], ArcRotateCameraKeyboardMoveInput.prototype, "zoomingSensibility", void 0);
  12648. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12649. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12650. ], ArcRotateCameraKeyboardMoveInput.prototype, "useAltToZoom", void 0);
  12651. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12652. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12653. ], ArcRotateCameraKeyboardMoveInput.prototype, "angularSpeed", void 0);
  12654. return ArcRotateCameraKeyboardMoveInput;
  12655. }());
  12656. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraKeyboardMoveInput"] = ArcRotateCameraKeyboardMoveInput;
  12657. /***/ }),
  12658. /***/ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts":
  12659. /*!**********************************************************!*\
  12660. !*** ./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts ***!
  12661. \**********************************************************/
  12662. /*! exports provided: ArcRotateCameraMouseWheelInput */
  12663. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12664. "use strict";
  12665. __webpack_require__.r(__webpack_exports__);
  12666. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return ArcRotateCameraMouseWheelInput; });
  12667. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12668. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12669. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12670. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  12671. /**
  12672. * Manage the mouse wheel inputs to control an arc rotate camera.
  12673. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12674. */
  12675. var ArcRotateCameraMouseWheelInput = /** @class */ (function () {
  12676. function ArcRotateCameraMouseWheelInput() {
  12677. /**
  12678. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  12679. */
  12680. this.wheelPrecision = 3.0;
  12681. /**
  12682. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  12683. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  12684. */
  12685. this.wheelDeltaPercentage = 0;
  12686. }
  12687. /**
  12688. * Attach the input controls to a specific dom element to get the input from.
  12689. * @param element Defines the element the controls should be listened from
  12690. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12691. */
  12692. ArcRotateCameraMouseWheelInput.prototype.attachControl = function (element, noPreventDefault) {
  12693. var _this = this;
  12694. this._wheel = function (p, s) {
  12695. //sanity check - this should be a PointerWheel event.
  12696. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL) {
  12697. return;
  12698. }
  12699. var event = p.event;
  12700. var delta = 0;
  12701. var mouseWheelLegacyEvent = event;
  12702. if (mouseWheelLegacyEvent.wheelDelta) {
  12703. if (_this.wheelDeltaPercentage) {
  12704. var wheelDelta = (mouseWheelLegacyEvent.wheelDelta * 0.01 * _this.wheelDeltaPercentage) * _this.camera.radius;
  12705. if (mouseWheelLegacyEvent.wheelDelta > 0) {
  12706. delta = wheelDelta / (1.0 + _this.wheelDeltaPercentage);
  12707. }
  12708. else {
  12709. delta = wheelDelta * (1.0 + _this.wheelDeltaPercentage);
  12710. }
  12711. }
  12712. else {
  12713. delta = mouseWheelLegacyEvent.wheelDelta / (_this.wheelPrecision * 40);
  12714. }
  12715. }
  12716. else {
  12717. var deltaValue = event.deltaY || event.detail;
  12718. delta = -deltaValue / _this.wheelPrecision;
  12719. }
  12720. if (delta) {
  12721. _this.camera.inertialRadiusOffset += delta;
  12722. }
  12723. if (event.preventDefault) {
  12724. if (!noPreventDefault) {
  12725. event.preventDefault();
  12726. }
  12727. }
  12728. };
  12729. this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL);
  12730. };
  12731. /**
  12732. * Detach the current controls from the specified dom element.
  12733. * @param element Defines the element to stop listening the inputs from
  12734. */
  12735. ArcRotateCameraMouseWheelInput.prototype.detachControl = function (element) {
  12736. if (this._observer && element) {
  12737. this.camera.getScene().onPointerObservable.remove(this._observer);
  12738. this._observer = null;
  12739. this._wheel = null;
  12740. }
  12741. };
  12742. /**
  12743. * Gets the class name of the current intput.
  12744. * @returns the class name
  12745. */
  12746. ArcRotateCameraMouseWheelInput.prototype.getClassName = function () {
  12747. return "ArcRotateCameraMouseWheelInput";
  12748. };
  12749. /**
  12750. * Get the friendly name associated with the input class.
  12751. * @returns the input friendly name
  12752. */
  12753. ArcRotateCameraMouseWheelInput.prototype.getSimpleName = function () {
  12754. return "mousewheel";
  12755. };
  12756. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12757. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12758. ], ArcRotateCameraMouseWheelInput.prototype, "wheelPrecision", void 0);
  12759. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12760. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12761. ], ArcRotateCameraMouseWheelInput.prototype, "wheelDeltaPercentage", void 0);
  12762. return ArcRotateCameraMouseWheelInput;
  12763. }());
  12764. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraMouseWheelInput"] = ArcRotateCameraMouseWheelInput;
  12765. /***/ }),
  12766. /***/ "./Cameras/Inputs/arcRotateCameraPointersInput.ts":
  12767. /*!********************************************************!*\
  12768. !*** ./Cameras/Inputs/arcRotateCameraPointersInput.ts ***!
  12769. \********************************************************/
  12770. /*! exports provided: ArcRotateCameraPointersInput */
  12771. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12772. "use strict";
  12773. __webpack_require__.r(__webpack_exports__);
  12774. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return ArcRotateCameraPointersInput; });
  12775. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12776. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12777. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12778. /* harmony import */ var _Cameras_Inputs_BaseCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/Inputs/BaseCameraPointersInput */ "./Cameras/Inputs/BaseCameraPointersInput.ts");
  12779. /**
  12780. * Manage the pointers inputs to control an arc rotate camera.
  12781. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12782. */
  12783. var ArcRotateCameraPointersInput = /** @class */ (function (_super) {
  12784. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCameraPointersInput, _super);
  12785. function ArcRotateCameraPointersInput() {
  12786. var _this = _super !== null && _super.apply(this, arguments) || this;
  12787. /**
  12788. * Defines the buttons associated with the input to handle camera move.
  12789. */
  12790. _this.buttons = [0, 1, 2];
  12791. /**
  12792. * Defines the pointer angular sensibility along the X axis or how fast is
  12793. * the camera rotating.
  12794. */
  12795. _this.angularSensibilityX = 1000.0;
  12796. /**
  12797. * Defines the pointer angular sensibility along the Y axis or how fast is
  12798. * the camera rotating.
  12799. */
  12800. _this.angularSensibilityY = 1000.0;
  12801. /**
  12802. * Defines the pointer pinch precision or how fast is the camera zooming.
  12803. */
  12804. _this.pinchPrecision = 12.0;
  12805. /**
  12806. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  12807. * from 0.
  12808. * It defines the percentage of current camera.radius to use as delta when
  12809. * pinch zoom is used.
  12810. */
  12811. _this.pinchDeltaPercentage = 0;
  12812. /**
  12813. * Defines the pointer panning sensibility or how fast is the camera moving.
  12814. */
  12815. _this.panningSensibility = 1000.0;
  12816. /**
  12817. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  12818. */
  12819. _this.multiTouchPanning = true;
  12820. /**
  12821. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  12822. * zoom (pinch) through multitouch.
  12823. */
  12824. _this.multiTouchPanAndZoom = true;
  12825. /**
  12826. * Revers pinch action direction.
  12827. */
  12828. _this.pinchInwards = true;
  12829. _this._isPanClick = false;
  12830. _this._twoFingerActivityCount = 0;
  12831. _this._isPinching = false;
  12832. return _this;
  12833. }
  12834. /**
  12835. * Gets the class name of the current input.
  12836. * @returns the class name
  12837. */
  12838. ArcRotateCameraPointersInput.prototype.getClassName = function () {
  12839. return "ArcRotateCameraPointersInput";
  12840. };
  12841. /**
  12842. * Called on pointer POINTERMOVE event if only a single touch is active.
  12843. */
  12844. ArcRotateCameraPointersInput.prototype.onTouch = function (point, offsetX, offsetY) {
  12845. if (this.panningSensibility !== 0 &&
  12846. ((this._ctrlKey && this.camera._useCtrlForPanning) || this._isPanClick)) {
  12847. this.camera.inertialPanningX += -offsetX / this.panningSensibility;
  12848. this.camera.inertialPanningY += offsetY / this.panningSensibility;
  12849. }
  12850. else {
  12851. this.camera.inertialAlphaOffset -= offsetX / this.angularSensibilityX;
  12852. this.camera.inertialBetaOffset -= offsetY / this.angularSensibilityY;
  12853. }
  12854. };
  12855. /**
  12856. * Called on pointer POINTERDOUBLETAP event.
  12857. */
  12858. ArcRotateCameraPointersInput.prototype.onDoubleTap = function (type) {
  12859. if (this.camera.useInputToRestoreState) {
  12860. this.camera.restoreState();
  12861. }
  12862. };
  12863. /**
  12864. * Called on pointer POINTERMOVE event if multiple touches are active.
  12865. */
  12866. ArcRotateCameraPointersInput.prototype.onMultiTouch = function (pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition) {
  12867. if (previousPinchSquaredDistance === 0 && previousMultiTouchPanPosition === null) {
  12868. // First time this method is called for new pinch.
  12869. // Next time this is called there will be a
  12870. // previousPinchSquaredDistance and pinchSquaredDistance to compare.
  12871. return;
  12872. }
  12873. if (pinchSquaredDistance === 0 && multiTouchPanPosition === null) {
  12874. // Last time this method is called at the end of a pinch.
  12875. return;
  12876. }
  12877. var direction = this.pinchInwards ? 1 : -1;
  12878. if (this.multiTouchPanAndZoom) {
  12879. if (this.pinchDeltaPercentage) {
  12880. this.camera.inertialRadiusOffset +=
  12881. (pinchSquaredDistance - previousPinchSquaredDistance) * 0.001 *
  12882. this.camera.radius * this.pinchDeltaPercentage;
  12883. }
  12884. else {
  12885. this.camera.inertialRadiusOffset +=
  12886. (pinchSquaredDistance - previousPinchSquaredDistance) /
  12887. (this.pinchPrecision * direction *
  12888. (this.angularSensibilityX + this.angularSensibilityY) / 2);
  12889. }
  12890. if (this.panningSensibility !== 0 &&
  12891. previousMultiTouchPanPosition && multiTouchPanPosition) {
  12892. var moveDeltaX = multiTouchPanPosition.x - previousMultiTouchPanPosition.x;
  12893. var moveDeltaY = multiTouchPanPosition.y - previousMultiTouchPanPosition.y;
  12894. this.camera.inertialPanningX += -moveDeltaX / this.panningSensibility;
  12895. this.camera.inertialPanningY += moveDeltaY / this.panningSensibility;
  12896. }
  12897. }
  12898. else {
  12899. this._twoFingerActivityCount++;
  12900. var previousPinchDistance = Math.sqrt(previousPinchSquaredDistance);
  12901. var pinchDistance = Math.sqrt(pinchSquaredDistance);
  12902. if (this._isPinching ||
  12903. (this._twoFingerActivityCount < 20 &&
  12904. Math.abs(pinchDistance - previousPinchDistance) >
  12905. this.camera.pinchToPanMaxDistance)) {
  12906. // Since pinch has not been active long, assume we intend to zoom.
  12907. if (this.pinchDeltaPercentage) {
  12908. this.camera.inertialRadiusOffset +=
  12909. (pinchSquaredDistance - previousPinchSquaredDistance) * 0.001 *
  12910. this.camera.radius * this.pinchDeltaPercentage;
  12911. }
  12912. else {
  12913. this.camera.inertialRadiusOffset +=
  12914. (pinchSquaredDistance - previousPinchSquaredDistance) /
  12915. (this.pinchPrecision * direction *
  12916. (this.angularSensibilityX + this.angularSensibilityY) / 2);
  12917. }
  12918. // Since we are pinching, remain pinching on next iteration.
  12919. this._isPinching = true;
  12920. }
  12921. else {
  12922. // Pause between pinch starting and moving implies not a zoom event.
  12923. // Pan instead.
  12924. if (this.panningSensibility !== 0 && this.multiTouchPanning &&
  12925. multiTouchPanPosition && previousMultiTouchPanPosition) {
  12926. var moveDeltaX = multiTouchPanPosition.x - previousMultiTouchPanPosition.x;
  12927. var moveDeltaY = multiTouchPanPosition.y - previousMultiTouchPanPosition.y;
  12928. this.camera.inertialPanningX += -moveDeltaX / this.panningSensibility;
  12929. this.camera.inertialPanningY += moveDeltaY / this.panningSensibility;
  12930. }
  12931. }
  12932. }
  12933. };
  12934. /**
  12935. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  12936. * press.
  12937. */
  12938. ArcRotateCameraPointersInput.prototype.onButtonDown = function (evt, buttonCount) {
  12939. this._isPanClick = evt.button === this.camera._panningMouseButton;
  12940. };
  12941. /**
  12942. * Called each time a new POINTERUP event occurs. Ie, for each button
  12943. * release.
  12944. */
  12945. ArcRotateCameraPointersInput.prototype.onButtonUp = function (evt) {
  12946. this._twoFingerActivityCount = 0;
  12947. this._isPinching = false;
  12948. };
  12949. /**
  12950. * Called when window becomes inactive.
  12951. */
  12952. ArcRotateCameraPointersInput.prototype.onLostFocus = function () {
  12953. this._isPanClick = false;
  12954. this._twoFingerActivityCount = 0;
  12955. this._isPinching = false;
  12956. };
  12957. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12958. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12959. ], ArcRotateCameraPointersInput.prototype, "buttons", void 0);
  12960. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12961. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12962. ], ArcRotateCameraPointersInput.prototype, "angularSensibilityX", void 0);
  12963. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12964. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12965. ], ArcRotateCameraPointersInput.prototype, "angularSensibilityY", void 0);
  12966. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12967. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12968. ], ArcRotateCameraPointersInput.prototype, "pinchPrecision", void 0);
  12969. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12970. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12971. ], ArcRotateCameraPointersInput.prototype, "pinchDeltaPercentage", void 0);
  12972. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12973. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12974. ], ArcRotateCameraPointersInput.prototype, "panningSensibility", void 0);
  12975. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12976. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12977. ], ArcRotateCameraPointersInput.prototype, "multiTouchPanning", void 0);
  12978. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12979. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12980. ], ArcRotateCameraPointersInput.prototype, "multiTouchPanAndZoom", void 0);
  12981. return ArcRotateCameraPointersInput;
  12982. }(_Cameras_Inputs_BaseCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__["BaseCameraPointersInput"]));
  12983. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraPointersInput"] =
  12984. ArcRotateCameraPointersInput;
  12985. /***/ }),
  12986. /***/ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts":
  12987. /*!*******************************************************************!*\
  12988. !*** ./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts ***!
  12989. \*******************************************************************/
  12990. /*! exports provided: ArcRotateCameraVRDeviceOrientationInput */
  12991. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12992. "use strict";
  12993. __webpack_require__.r(__webpack_exports__);
  12994. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return ArcRotateCameraVRDeviceOrientationInput; });
  12995. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12996. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  12997. /**
  12998. * Add orientation input support to the input manager.
  12999. * @returns the current input manager
  13000. */
  13001. _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraInputsManager"].prototype.addVRDeviceOrientation = function () {
  13002. this.add(new ArcRotateCameraVRDeviceOrientationInput());
  13003. return this;
  13004. };
  13005. /**
  13006. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  13007. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13008. */
  13009. var ArcRotateCameraVRDeviceOrientationInput = /** @class */ (function () {
  13010. /**
  13011. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  13012. */
  13013. function ArcRotateCameraVRDeviceOrientationInput() {
  13014. /**
  13015. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  13016. */
  13017. this.alphaCorrection = 1;
  13018. /**
  13019. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  13020. */
  13021. this.gammaCorrection = 1;
  13022. this._alpha = 0;
  13023. this._gamma = 0;
  13024. this._dirty = false;
  13025. this._deviceOrientationHandler = this._onOrientationEvent.bind(this);
  13026. }
  13027. /**
  13028. * Attach the input controls to a specific dom element to get the input from.
  13029. * @param element Defines the element the controls should be listened from
  13030. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13031. */
  13032. ArcRotateCameraVRDeviceOrientationInput.prototype.attachControl = function (element, noPreventDefault) {
  13033. this.camera.attachControl(element, noPreventDefault);
  13034. window.addEventListener("deviceorientation", this._deviceOrientationHandler);
  13035. };
  13036. /** @hidden */
  13037. ArcRotateCameraVRDeviceOrientationInput.prototype._onOrientationEvent = function (evt) {
  13038. if (evt.alpha !== null) {
  13039. this._alpha = (+evt.alpha | 0) * this.alphaCorrection;
  13040. }
  13041. if (evt.gamma !== null) {
  13042. this._gamma = (+evt.gamma | 0) * this.gammaCorrection;
  13043. }
  13044. this._dirty = true;
  13045. };
  13046. /**
  13047. * Update the current camera state depending on the inputs that have been used this frame.
  13048. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13049. */
  13050. ArcRotateCameraVRDeviceOrientationInput.prototype.checkInputs = function () {
  13051. if (this._dirty) {
  13052. this._dirty = false;
  13053. if (this._gamma < 0) {
  13054. this._gamma = 180 + this._gamma;
  13055. }
  13056. this.camera.alpha = (-this._alpha / 180.0 * Math.PI) % Math.PI * 2;
  13057. this.camera.beta = (this._gamma / 180.0 * Math.PI);
  13058. }
  13059. };
  13060. /**
  13061. * Detach the current controls from the specified dom element.
  13062. * @param element Defines the element to stop listening the inputs from
  13063. */
  13064. ArcRotateCameraVRDeviceOrientationInput.prototype.detachControl = function (element) {
  13065. window.removeEventListener("deviceorientation", this._deviceOrientationHandler);
  13066. };
  13067. /**
  13068. * Gets the class name of the current intput.
  13069. * @returns the class name
  13070. */
  13071. ArcRotateCameraVRDeviceOrientationInput.prototype.getClassName = function () {
  13072. return "ArcRotateCameraVRDeviceOrientationInput";
  13073. };
  13074. /**
  13075. * Get the friendly name associated with the input class.
  13076. * @returns the input friendly name
  13077. */
  13078. ArcRotateCameraVRDeviceOrientationInput.prototype.getSimpleName = function () {
  13079. return "VRDeviceOrientation";
  13080. };
  13081. return ArcRotateCameraVRDeviceOrientationInput;
  13082. }());
  13083. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]["ArcRotateCameraVRDeviceOrientationInput"] = ArcRotateCameraVRDeviceOrientationInput;
  13084. /***/ }),
  13085. /***/ "./Cameras/Inputs/flyCameraKeyboardInput.ts":
  13086. /*!**************************************************!*\
  13087. !*** ./Cameras/Inputs/flyCameraKeyboardInput.ts ***!
  13088. \**************************************************/
  13089. /*! exports provided: FlyCameraKeyboardInput */
  13090. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13091. "use strict";
  13092. __webpack_require__.r(__webpack_exports__);
  13093. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return FlyCameraKeyboardInput; });
  13094. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13095. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13096. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13097. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  13098. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13099. /**
  13100. * Listen to keyboard events to control the camera.
  13101. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13102. */
  13103. var FlyCameraKeyboardInput = /** @class */ (function () {
  13104. function FlyCameraKeyboardInput() {
  13105. /**
  13106. * The list of keyboard keys used to control the forward move of the camera.
  13107. */
  13108. this.keysForward = [87];
  13109. /**
  13110. * The list of keyboard keys used to control the backward move of the camera.
  13111. */
  13112. this.keysBackward = [83];
  13113. /**
  13114. * The list of keyboard keys used to control the forward move of the camera.
  13115. */
  13116. this.keysUp = [69];
  13117. /**
  13118. * The list of keyboard keys used to control the backward move of the camera.
  13119. */
  13120. this.keysDown = [81];
  13121. /**
  13122. * The list of keyboard keys used to control the right strafe move of the camera.
  13123. */
  13124. this.keysRight = [68];
  13125. /**
  13126. * The list of keyboard keys used to control the left strafe move of the camera.
  13127. */
  13128. this.keysLeft = [65];
  13129. this._keys = new Array();
  13130. }
  13131. /**
  13132. * Attach the input controls to a specific dom element to get the input from.
  13133. * @param element Defines the element the controls should be listened from
  13134. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13135. */
  13136. FlyCameraKeyboardInput.prototype.attachControl = function (element, noPreventDefault) {
  13137. var _this = this;
  13138. if (this._onCanvasBlurObserver) {
  13139. return;
  13140. }
  13141. this._scene = this.camera.getScene();
  13142. this._engine = this._scene.getEngine();
  13143. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  13144. _this._keys = [];
  13145. });
  13146. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  13147. var evt = info.event;
  13148. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  13149. if (_this.keysForward.indexOf(evt.keyCode) !== -1 ||
  13150. _this.keysBackward.indexOf(evt.keyCode) !== -1 ||
  13151. _this.keysUp.indexOf(evt.keyCode) !== -1 ||
  13152. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  13153. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  13154. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  13155. var index = _this._keys.indexOf(evt.keyCode);
  13156. if (index === -1) {
  13157. _this._keys.push(evt.keyCode);
  13158. }
  13159. if (!noPreventDefault) {
  13160. evt.preventDefault();
  13161. }
  13162. }
  13163. }
  13164. else {
  13165. if (_this.keysForward.indexOf(evt.keyCode) !== -1 ||
  13166. _this.keysBackward.indexOf(evt.keyCode) !== -1 ||
  13167. _this.keysUp.indexOf(evt.keyCode) !== -1 ||
  13168. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  13169. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  13170. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  13171. var index = _this._keys.indexOf(evt.keyCode);
  13172. if (index >= 0) {
  13173. _this._keys.splice(index, 1);
  13174. }
  13175. if (!noPreventDefault) {
  13176. evt.preventDefault();
  13177. }
  13178. }
  13179. }
  13180. });
  13181. };
  13182. /**
  13183. * Detach the current controls from the specified dom element.
  13184. * @param element Defines the element to stop listening the inputs from
  13185. */
  13186. FlyCameraKeyboardInput.prototype.detachControl = function (element) {
  13187. if (this._scene) {
  13188. if (this._onKeyboardObserver) {
  13189. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  13190. }
  13191. if (this._onCanvasBlurObserver) {
  13192. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  13193. }
  13194. this._onKeyboardObserver = null;
  13195. this._onCanvasBlurObserver = null;
  13196. }
  13197. this._keys = [];
  13198. };
  13199. /**
  13200. * Gets the class name of the current intput.
  13201. * @returns the class name
  13202. */
  13203. FlyCameraKeyboardInput.prototype.getClassName = function () {
  13204. return "FlyCameraKeyboardInput";
  13205. };
  13206. /** @hidden */
  13207. FlyCameraKeyboardInput.prototype._onLostFocus = function (e) {
  13208. this._keys = [];
  13209. };
  13210. /**
  13211. * Get the friendly name associated with the input class.
  13212. * @returns the input friendly name
  13213. */
  13214. FlyCameraKeyboardInput.prototype.getSimpleName = function () {
  13215. return "keyboard";
  13216. };
  13217. /**
  13218. * Update the current camera state depending on the inputs that have been used this frame.
  13219. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13220. */
  13221. FlyCameraKeyboardInput.prototype.checkInputs = function () {
  13222. if (this._onKeyboardObserver) {
  13223. var camera = this.camera;
  13224. // Keyboard
  13225. for (var index = 0; index < this._keys.length; index++) {
  13226. var keyCode = this._keys[index];
  13227. var speed = camera._computeLocalCameraSpeed();
  13228. if (this.keysForward.indexOf(keyCode) !== -1) {
  13229. camera._localDirection.copyFromFloats(0, 0, speed);
  13230. }
  13231. else if (this.keysBackward.indexOf(keyCode) !== -1) {
  13232. camera._localDirection.copyFromFloats(0, 0, -speed);
  13233. }
  13234. else if (this.keysUp.indexOf(keyCode) !== -1) {
  13235. camera._localDirection.copyFromFloats(0, speed, 0);
  13236. }
  13237. else if (this.keysDown.indexOf(keyCode) !== -1) {
  13238. camera._localDirection.copyFromFloats(0, -speed, 0);
  13239. }
  13240. else if (this.keysRight.indexOf(keyCode) !== -1) {
  13241. camera._localDirection.copyFromFloats(speed, 0, 0);
  13242. }
  13243. else if (this.keysLeft.indexOf(keyCode) !== -1) {
  13244. camera._localDirection.copyFromFloats(-speed, 0, 0);
  13245. }
  13246. if (camera.getScene().useRightHandedSystem) {
  13247. camera._localDirection.z *= -1;
  13248. }
  13249. camera.getViewMatrix().invertToRef(camera._cameraTransformMatrix);
  13250. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormalToRef(camera._localDirection, camera._cameraTransformMatrix, camera._transformedDirection);
  13251. camera.cameraDirection.addInPlace(camera._transformedDirection);
  13252. }
  13253. }
  13254. };
  13255. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13256. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13257. ], FlyCameraKeyboardInput.prototype, "keysForward", void 0);
  13258. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13259. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13260. ], FlyCameraKeyboardInput.prototype, "keysBackward", void 0);
  13261. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13262. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13263. ], FlyCameraKeyboardInput.prototype, "keysUp", void 0);
  13264. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13265. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13266. ], FlyCameraKeyboardInput.prototype, "keysDown", void 0);
  13267. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13268. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13269. ], FlyCameraKeyboardInput.prototype, "keysRight", void 0);
  13270. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13271. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13272. ], FlyCameraKeyboardInput.prototype, "keysLeft", void 0);
  13273. return FlyCameraKeyboardInput;
  13274. }());
  13275. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FlyCameraKeyboardInput"] = FlyCameraKeyboardInput;
  13276. /***/ }),
  13277. /***/ "./Cameras/Inputs/flyCameraMouseInput.ts":
  13278. /*!***********************************************!*\
  13279. !*** ./Cameras/Inputs/flyCameraMouseInput.ts ***!
  13280. \***********************************************/
  13281. /*! exports provided: FlyCameraMouseInput */
  13282. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13283. "use strict";
  13284. __webpack_require__.r(__webpack_exports__);
  13285. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return FlyCameraMouseInput; });
  13286. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13287. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13288. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13289. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  13290. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13291. /**
  13292. * Listen to mouse events to control the camera.
  13293. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13294. */
  13295. var FlyCameraMouseInput = /** @class */ (function () {
  13296. /**
  13297. * Listen to mouse events to control the camera.
  13298. * @param touchEnabled Define if touch is enabled. (Default is true.)
  13299. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13300. */
  13301. function FlyCameraMouseInput(touchEnabled) {
  13302. if (touchEnabled === void 0) { touchEnabled = true; }
  13303. /**
  13304. * Defines the buttons associated with the input to handle camera rotation.
  13305. */
  13306. this.buttons = [0, 1, 2];
  13307. /**
  13308. * Assign buttons for Yaw control.
  13309. */
  13310. this.buttonsYaw = [-1, 0, 1];
  13311. /**
  13312. * Assign buttons for Pitch control.
  13313. */
  13314. this.buttonsPitch = [-1, 0, 1];
  13315. /**
  13316. * Assign buttons for Roll control.
  13317. */
  13318. this.buttonsRoll = [2];
  13319. /**
  13320. * Detect if any button is being pressed while mouse is moved.
  13321. * -1 = Mouse locked.
  13322. * 0 = Left button.
  13323. * 1 = Middle Button.
  13324. * 2 = Right Button.
  13325. */
  13326. this.activeButton = -1;
  13327. /**
  13328. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  13329. * Higher values reduce its sensitivity.
  13330. */
  13331. this.angularSensibility = 1000.0;
  13332. this.previousPosition = null;
  13333. }
  13334. /**
  13335. * Attach the mouse control to the HTML DOM element.
  13336. * @param element Defines the element that listens to the input events.
  13337. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  13338. */
  13339. FlyCameraMouseInput.prototype.attachControl = function (element, noPreventDefault) {
  13340. var _this = this;
  13341. this.element = element;
  13342. this.noPreventDefault = noPreventDefault;
  13343. this._observer = this.camera.getScene().onPointerObservable.add(function (p, s) {
  13344. _this._pointerInput(p, s);
  13345. }, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE);
  13346. // Correct Roll by rate, if enabled.
  13347. this._rollObserver = this.camera.getScene().onBeforeRenderObservable.add(function () {
  13348. if (_this.camera.rollCorrect) {
  13349. _this.camera.restoreRoll(_this.camera.rollCorrect);
  13350. }
  13351. });
  13352. // Helper function to keep 'this'.
  13353. this._mousemoveCallback = function (e) {
  13354. _this._onMouseMove(e);
  13355. };
  13356. element.addEventListener("mousemove", this._mousemoveCallback, false);
  13357. };
  13358. /**
  13359. * Detach the current controls from the specified dom element.
  13360. * @param element Defines the element to stop listening the inputs from
  13361. */
  13362. FlyCameraMouseInput.prototype.detachControl = function (element) {
  13363. if (this._observer && element) {
  13364. this.camera.getScene().onPointerObservable.remove(this._observer);
  13365. this.camera.getScene().onBeforeRenderObservable.remove(this._rollObserver);
  13366. if (this._mousemoveCallback) {
  13367. element.removeEventListener("mousemove", this._mousemoveCallback);
  13368. }
  13369. this._observer = null;
  13370. this._rollObserver = null;
  13371. this.previousPosition = null;
  13372. this.noPreventDefault = undefined;
  13373. }
  13374. };
  13375. /**
  13376. * Gets the class name of the current input.
  13377. * @returns the class name.
  13378. */
  13379. FlyCameraMouseInput.prototype.getClassName = function () {
  13380. return "FlyCameraMouseInput";
  13381. };
  13382. /**
  13383. * Get the friendly name associated with the input class.
  13384. * @returns the input's friendly name.
  13385. */
  13386. FlyCameraMouseInput.prototype.getSimpleName = function () {
  13387. return "mouse";
  13388. };
  13389. // Track mouse movement, when the pointer is not locked.
  13390. FlyCameraMouseInput.prototype._pointerInput = function (p, s) {
  13391. var e = p.event;
  13392. var camera = this.camera;
  13393. var engine = camera.getEngine();
  13394. if (engine.isInVRExclusivePointerMode) {
  13395. return;
  13396. }
  13397. if (!this.touchEnabled && e.pointerType === "touch") {
  13398. return;
  13399. }
  13400. // Mouse is moved but an unknown mouse button is pressed.
  13401. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE && this.buttons.indexOf(e.button) === -1) {
  13402. return;
  13403. }
  13404. var srcElement = (e.srcElement || e.target);
  13405. // Mouse down.
  13406. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN && srcElement) {
  13407. try {
  13408. srcElement.setPointerCapture(e.pointerId);
  13409. }
  13410. catch (e) {
  13411. // Nothing to do with the error. Execution continues.
  13412. }
  13413. this.previousPosition = {
  13414. x: e.clientX,
  13415. y: e.clientY
  13416. };
  13417. this.activeButton = e.button;
  13418. if (!this.noPreventDefault) {
  13419. e.preventDefault();
  13420. this.element.focus();
  13421. }
  13422. }
  13423. else
  13424. // Mouse up.
  13425. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP && srcElement) {
  13426. try {
  13427. srcElement.releasePointerCapture(e.pointerId);
  13428. }
  13429. catch (e) {
  13430. // Nothing to do with the error. Execution continues.
  13431. }
  13432. this.activeButton = -1;
  13433. this.previousPosition = null;
  13434. if (!this.noPreventDefault) {
  13435. e.preventDefault();
  13436. }
  13437. }
  13438. else
  13439. // Mouse move.
  13440. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  13441. if (!this.previousPosition || engine.isPointerLock) {
  13442. return;
  13443. }
  13444. var offsetX = e.clientX - this.previousPosition.x;
  13445. var offsetY = e.clientY - this.previousPosition.y;
  13446. this.rotateCamera(offsetX, offsetY);
  13447. this.previousPosition = {
  13448. x: e.clientX,
  13449. y: e.clientY
  13450. };
  13451. if (!this.noPreventDefault) {
  13452. e.preventDefault();
  13453. }
  13454. }
  13455. };
  13456. // Track mouse movement, when pointer is locked.
  13457. FlyCameraMouseInput.prototype._onMouseMove = function (e) {
  13458. var camera = this.camera;
  13459. var engine = camera.getEngine();
  13460. if (!engine.isPointerLock || engine.isInVRExclusivePointerMode) {
  13461. return;
  13462. }
  13463. var offsetX = e.movementX || e.mozMovementX || e.webkitMovementX || e.msMovementX || 0;
  13464. var offsetY = e.movementY || e.mozMovementY || e.webkitMovementY || e.msMovementY || 0;
  13465. this.rotateCamera(offsetX, offsetY);
  13466. this.previousPosition = null;
  13467. if (!this.noPreventDefault) {
  13468. e.preventDefault();
  13469. }
  13470. };
  13471. /**
  13472. * Rotate camera by mouse offset.
  13473. */
  13474. FlyCameraMouseInput.prototype.rotateCamera = function (offsetX, offsetY) {
  13475. var _this = this;
  13476. var camera = this.camera;
  13477. var scene = this.camera.getScene();
  13478. if (scene.useRightHandedSystem) {
  13479. offsetX *= -1;
  13480. }
  13481. if (camera.parent && camera.parent._getWorldMatrixDeterminant() < 0) {
  13482. offsetX *= -1;
  13483. }
  13484. var x = offsetX / this.angularSensibility;
  13485. var y = offsetY / this.angularSensibility;
  13486. // Initialize to current rotation.
  13487. var currentRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationYawPitchRoll(camera.rotation.y, camera.rotation.x, camera.rotation.z);
  13488. var rotationChange;
  13489. // Pitch.
  13490. if (this.buttonsPitch.some(function (v) { return v === _this.activeButton; })) {
  13491. // Apply change in Radians to vector Angle.
  13492. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].X, y);
  13493. // Apply Pitch to quaternion.
  13494. currentRotation.multiplyInPlace(rotationChange);
  13495. }
  13496. // Yaw.
  13497. if (this.buttonsYaw.some(function (v) { return v === _this.activeButton; })) {
  13498. // Apply change in Radians to vector Angle.
  13499. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Y, x);
  13500. // Apply Yaw to quaternion.
  13501. currentRotation.multiplyInPlace(rotationChange);
  13502. // Add Roll, if banked turning is enabled, within Roll limit.
  13503. var limit = (camera.bankedTurnLimit) + camera._trackRoll; // Defaults to 90° plus manual roll.
  13504. if (camera.bankedTurn && -limit < camera.rotation.z && camera.rotation.z < limit) {
  13505. var bankingDelta = camera.bankedTurnMultiplier * -x;
  13506. // Apply change in Radians to vector Angle.
  13507. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Z, bankingDelta);
  13508. // Apply Yaw to quaternion.
  13509. currentRotation.multiplyInPlace(rotationChange);
  13510. }
  13511. }
  13512. // Roll.
  13513. if (this.buttonsRoll.some(function (v) { return v === _this.activeButton; })) {
  13514. // Apply change in Radians to vector Angle.
  13515. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Z, -x);
  13516. // Track Rolling.
  13517. camera._trackRoll -= x;
  13518. // Apply Pitch to quaternion.
  13519. currentRotation.multiplyInPlace(rotationChange);
  13520. }
  13521. // Apply rotationQuaternion to Euler camera.rotation.
  13522. currentRotation.toEulerAnglesToRef(camera.rotation);
  13523. };
  13524. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13525. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13526. ], FlyCameraMouseInput.prototype, "buttons", void 0);
  13527. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13528. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13529. ], FlyCameraMouseInput.prototype, "angularSensibility", void 0);
  13530. return FlyCameraMouseInput;
  13531. }());
  13532. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FlyCameraMouseInput"] = FlyCameraMouseInput;
  13533. /***/ }),
  13534. /***/ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts":
  13535. /*!*********************************************************!*\
  13536. !*** ./Cameras/Inputs/followCameraKeyboardMoveInput.ts ***!
  13537. \*********************************************************/
  13538. /*! exports provided: FollowCameraKeyboardMoveInput */
  13539. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13540. "use strict";
  13541. __webpack_require__.r(__webpack_exports__);
  13542. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return FollowCameraKeyboardMoveInput; });
  13543. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13544. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13545. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13546. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  13547. /**
  13548. * Manage the keyboard inputs to control the movement of a follow camera.
  13549. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13550. */
  13551. var FollowCameraKeyboardMoveInput = /** @class */ (function () {
  13552. function FollowCameraKeyboardMoveInput() {
  13553. /**
  13554. * Defines the list of key codes associated with the up action (increase heightOffset)
  13555. */
  13556. this.keysHeightOffsetIncr = [38];
  13557. /**
  13558. * Defines the list of key codes associated with the down action (decrease heightOffset)
  13559. */
  13560. this.keysHeightOffsetDecr = [40];
  13561. /**
  13562. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  13563. */
  13564. this.keysHeightOffsetModifierAlt = false;
  13565. /**
  13566. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  13567. */
  13568. this.keysHeightOffsetModifierCtrl = false;
  13569. /**
  13570. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  13571. */
  13572. this.keysHeightOffsetModifierShift = false;
  13573. /**
  13574. * Defines the list of key codes associated with the left action (increase rotationOffset)
  13575. */
  13576. this.keysRotationOffsetIncr = [37];
  13577. /**
  13578. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  13579. */
  13580. this.keysRotationOffsetDecr = [39];
  13581. /**
  13582. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  13583. */
  13584. this.keysRotationOffsetModifierAlt = false;
  13585. /**
  13586. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  13587. */
  13588. this.keysRotationOffsetModifierCtrl = false;
  13589. /**
  13590. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  13591. */
  13592. this.keysRotationOffsetModifierShift = false;
  13593. /**
  13594. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  13595. */
  13596. this.keysRadiusIncr = [40];
  13597. /**
  13598. * Defines the list of key codes associated with the zoom-out action (increase radius)
  13599. */
  13600. this.keysRadiusDecr = [38];
  13601. /**
  13602. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  13603. */
  13604. this.keysRadiusModifierAlt = true;
  13605. /**
  13606. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  13607. */
  13608. this.keysRadiusModifierCtrl = false;
  13609. /**
  13610. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  13611. */
  13612. this.keysRadiusModifierShift = false;
  13613. /**
  13614. * Defines the rate of change of heightOffset.
  13615. */
  13616. this.heightSensibility = 1;
  13617. /**
  13618. * Defines the rate of change of rotationOffset.
  13619. */
  13620. this.rotationSensibility = 1;
  13621. /**
  13622. * Defines the rate of change of radius.
  13623. */
  13624. this.radiusSensibility = 1;
  13625. this._keys = new Array();
  13626. }
  13627. /**
  13628. * Attach the input controls to a specific dom element to get the input from.
  13629. * @param element Defines the element the controls should be listened from
  13630. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13631. */
  13632. FollowCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  13633. var _this = this;
  13634. if (this._onCanvasBlurObserver) {
  13635. return;
  13636. }
  13637. this._scene = this.camera.getScene();
  13638. this._engine = this._scene.getEngine();
  13639. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  13640. _this._keys = [];
  13641. });
  13642. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  13643. var evt = info.event;
  13644. if (!evt.metaKey) {
  13645. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  13646. _this._ctrlPressed = evt.ctrlKey;
  13647. _this._altPressed = evt.altKey;
  13648. _this._shiftPressed = evt.shiftKey;
  13649. if (_this.keysHeightOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13650. _this.keysHeightOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13651. _this.keysRotationOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13652. _this.keysRotationOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13653. _this.keysRadiusIncr.indexOf(evt.keyCode) !== -1 ||
  13654. _this.keysRadiusDecr.indexOf(evt.keyCode) !== -1) {
  13655. var index = _this._keys.indexOf(evt.keyCode);
  13656. if (index === -1) {
  13657. _this._keys.push(evt.keyCode);
  13658. }
  13659. if (evt.preventDefault) {
  13660. if (!noPreventDefault) {
  13661. evt.preventDefault();
  13662. }
  13663. }
  13664. }
  13665. }
  13666. else {
  13667. if (_this.keysHeightOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13668. _this.keysHeightOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13669. _this.keysRotationOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13670. _this.keysRotationOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13671. _this.keysRadiusIncr.indexOf(evt.keyCode) !== -1 ||
  13672. _this.keysRadiusDecr.indexOf(evt.keyCode) !== -1) {
  13673. var index = _this._keys.indexOf(evt.keyCode);
  13674. if (index >= 0) {
  13675. _this._keys.splice(index, 1);
  13676. }
  13677. if (evt.preventDefault) {
  13678. if (!noPreventDefault) {
  13679. evt.preventDefault();
  13680. }
  13681. }
  13682. }
  13683. }
  13684. }
  13685. });
  13686. };
  13687. /**
  13688. * Detach the current controls from the specified dom element.
  13689. * @param element Defines the element to stop listening the inputs from
  13690. */
  13691. FollowCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  13692. if (this._scene) {
  13693. if (this._onKeyboardObserver) {
  13694. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  13695. }
  13696. if (this._onCanvasBlurObserver) {
  13697. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  13698. }
  13699. this._onKeyboardObserver = null;
  13700. this._onCanvasBlurObserver = null;
  13701. }
  13702. this._keys = [];
  13703. };
  13704. /**
  13705. * Update the current camera state depending on the inputs that have been used this frame.
  13706. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13707. */
  13708. FollowCameraKeyboardMoveInput.prototype.checkInputs = function () {
  13709. var _this = this;
  13710. if (this._onKeyboardObserver) {
  13711. this._keys.forEach(function (keyCode) {
  13712. if (_this.keysHeightOffsetIncr.indexOf(keyCode) !== -1 &&
  13713. _this._modifierHeightOffset()) {
  13714. _this.camera.heightOffset += _this.heightSensibility;
  13715. }
  13716. else if (_this.keysHeightOffsetDecr.indexOf(keyCode) !== -1 &&
  13717. _this._modifierHeightOffset()) {
  13718. _this.camera.heightOffset -= _this.heightSensibility;
  13719. }
  13720. else if (_this.keysRotationOffsetIncr.indexOf(keyCode) !== -1 &&
  13721. _this._modifierRotationOffset()) {
  13722. _this.camera.rotationOffset += _this.rotationSensibility;
  13723. _this.camera.rotationOffset %= 360;
  13724. }
  13725. else if (_this.keysRotationOffsetDecr.indexOf(keyCode) !== -1 &&
  13726. _this._modifierRotationOffset()) {
  13727. _this.camera.rotationOffset -= _this.rotationSensibility;
  13728. _this.camera.rotationOffset %= 360;
  13729. }
  13730. else if (_this.keysRadiusIncr.indexOf(keyCode) !== -1 &&
  13731. _this._modifierRadius()) {
  13732. _this.camera.radius += _this.radiusSensibility;
  13733. }
  13734. else if (_this.keysRadiusDecr.indexOf(keyCode) !== -1 &&
  13735. _this._modifierRadius()) {
  13736. _this.camera.radius -= _this.radiusSensibility;
  13737. }
  13738. });
  13739. }
  13740. };
  13741. /**
  13742. * Gets the class name of the current input.
  13743. * @returns the class name
  13744. */
  13745. FollowCameraKeyboardMoveInput.prototype.getClassName = function () {
  13746. return "FollowCameraKeyboardMoveInput";
  13747. };
  13748. /**
  13749. * Get the friendly name associated with the input class.
  13750. * @returns the input friendly name
  13751. */
  13752. FollowCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  13753. return "keyboard";
  13754. };
  13755. /**
  13756. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  13757. * allow modification of the heightOffset value.
  13758. */
  13759. FollowCameraKeyboardMoveInput.prototype._modifierHeightOffset = function () {
  13760. return (this.keysHeightOffsetModifierAlt === this._altPressed &&
  13761. this.keysHeightOffsetModifierCtrl === this._ctrlPressed &&
  13762. this.keysHeightOffsetModifierShift === this._shiftPressed);
  13763. };
  13764. /**
  13765. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  13766. * allow modification of the rotationOffset value.
  13767. */
  13768. FollowCameraKeyboardMoveInput.prototype._modifierRotationOffset = function () {
  13769. return (this.keysRotationOffsetModifierAlt === this._altPressed &&
  13770. this.keysRotationOffsetModifierCtrl === this._ctrlPressed &&
  13771. this.keysRotationOffsetModifierShift === this._shiftPressed);
  13772. };
  13773. /**
  13774. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  13775. * allow modification of the radius value.
  13776. */
  13777. FollowCameraKeyboardMoveInput.prototype._modifierRadius = function () {
  13778. return (this.keysRadiusModifierAlt === this._altPressed &&
  13779. this.keysRadiusModifierCtrl === this._ctrlPressed &&
  13780. this.keysRadiusModifierShift === this._shiftPressed);
  13781. };
  13782. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13783. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13784. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetIncr", void 0);
  13785. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13786. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13787. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetDecr", void 0);
  13788. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13789. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13790. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierAlt", void 0);
  13791. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13792. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13793. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierCtrl", void 0);
  13794. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13795. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13796. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierShift", void 0);
  13797. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13798. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13799. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetIncr", void 0);
  13800. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13801. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13802. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetDecr", void 0);
  13803. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13804. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13805. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierAlt", void 0);
  13806. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13807. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13808. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierCtrl", void 0);
  13809. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13810. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13811. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierShift", void 0);
  13812. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13813. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13814. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusIncr", void 0);
  13815. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13816. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13817. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusDecr", void 0);
  13818. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13819. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13820. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierAlt", void 0);
  13821. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13822. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13823. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierCtrl", void 0);
  13824. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13825. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13826. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierShift", void 0);
  13827. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13828. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13829. ], FollowCameraKeyboardMoveInput.prototype, "heightSensibility", void 0);
  13830. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13831. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13832. ], FollowCameraKeyboardMoveInput.prototype, "rotationSensibility", void 0);
  13833. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13834. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13835. ], FollowCameraKeyboardMoveInput.prototype, "radiusSensibility", void 0);
  13836. return FollowCameraKeyboardMoveInput;
  13837. }());
  13838. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]["FollowCameraKeyboardMoveInput"] = FollowCameraKeyboardMoveInput;
  13839. /***/ }),
  13840. /***/ "./Cameras/Inputs/followCameraMouseWheelInput.ts":
  13841. /*!*******************************************************!*\
  13842. !*** ./Cameras/Inputs/followCameraMouseWheelInput.ts ***!
  13843. \*******************************************************/
  13844. /*! exports provided: FollowCameraMouseWheelInput */
  13845. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13846. "use strict";
  13847. __webpack_require__.r(__webpack_exports__);
  13848. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return FollowCameraMouseWheelInput; });
  13849. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13850. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13851. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13852. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  13853. /**
  13854. * Manage the mouse wheel inputs to control a follow camera.
  13855. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13856. */
  13857. var FollowCameraMouseWheelInput = /** @class */ (function () {
  13858. function FollowCameraMouseWheelInput() {
  13859. /**
  13860. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  13861. */
  13862. this.axisControlRadius = true;
  13863. /**
  13864. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  13865. */
  13866. this.axisControlHeight = false;
  13867. /**
  13868. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  13869. */
  13870. this.axisControlRotation = false;
  13871. /**
  13872. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  13873. * relation to mouseWheel events.
  13874. */
  13875. this.wheelPrecision = 3.0;
  13876. /**
  13877. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  13878. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  13879. */
  13880. this.wheelDeltaPercentage = 0;
  13881. }
  13882. /**
  13883. * Attach the input controls to a specific dom element to get the input from.
  13884. * @param element Defines the element the controls should be listened from
  13885. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13886. */
  13887. FollowCameraMouseWheelInput.prototype.attachControl = function (element, noPreventDefault) {
  13888. var _this = this;
  13889. this._wheel = function (p, s) {
  13890. // sanity check - this should be a PointerWheel event.
  13891. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL) {
  13892. return;
  13893. }
  13894. var event = p.event;
  13895. var delta = 0;
  13896. // Chrome, Safari: event.deltaY
  13897. // IE: event.wheelDelta
  13898. // Firefox: event.detail (inverted)
  13899. var wheelDelta = Math.max(-1, Math.min(1, (event.deltaY || event.wheelDelta || -event.detail)));
  13900. if (_this.wheelDeltaPercentage) {
  13901. console.assert((_this.axisControlRadius +
  13902. _this.axisControlHeight +
  13903. _this.axisControlRotation) <= 1, "wheelDeltaPercentage only usable when mouse wheel " +
  13904. "controlls ONE axis. " +
  13905. "Currently enabled: " +
  13906. "axisControlRadius: " + _this.axisControlRadius +
  13907. ", axisControlHeightOffset: " + _this.axisControlHeight +
  13908. ", axisControlRotationOffset: " + _this.axisControlRotation);
  13909. if (_this.axisControlRadius) {
  13910. delta =
  13911. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  13912. _this.camera.radius;
  13913. }
  13914. else if (_this.axisControlHeight) {
  13915. delta =
  13916. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  13917. _this.camera.heightOffset;
  13918. }
  13919. else if (_this.axisControlRotation) {
  13920. delta =
  13921. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  13922. _this.camera.rotationOffset;
  13923. }
  13924. }
  13925. else {
  13926. delta = wheelDelta * _this.wheelPrecision;
  13927. }
  13928. if (delta) {
  13929. if (_this.axisControlRadius) {
  13930. _this.camera.radius += delta;
  13931. }
  13932. else if (_this.axisControlHeight) {
  13933. _this.camera.heightOffset -= delta;
  13934. }
  13935. else if (_this.axisControlRotation) {
  13936. _this.camera.rotationOffset -= delta;
  13937. }
  13938. }
  13939. if (event.preventDefault) {
  13940. if (!noPreventDefault) {
  13941. event.preventDefault();
  13942. }
  13943. }
  13944. };
  13945. this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL);
  13946. };
  13947. /**
  13948. * Detach the current controls from the specified dom element.
  13949. * @param element Defines the element to stop listening the inputs from
  13950. */
  13951. FollowCameraMouseWheelInput.prototype.detachControl = function (element) {
  13952. if (this._observer && element) {
  13953. this.camera.getScene().onPointerObservable.remove(this._observer);
  13954. this._observer = null;
  13955. this._wheel = null;
  13956. }
  13957. };
  13958. /**
  13959. * Gets the class name of the current intput.
  13960. * @returns the class name
  13961. */
  13962. FollowCameraMouseWheelInput.prototype.getClassName = function () {
  13963. return "ArcRotateCameraMouseWheelInput";
  13964. };
  13965. /**
  13966. * Get the friendly name associated with the input class.
  13967. * @returns the input friendly name
  13968. */
  13969. FollowCameraMouseWheelInput.prototype.getSimpleName = function () {
  13970. return "mousewheel";
  13971. };
  13972. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13973. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13974. ], FollowCameraMouseWheelInput.prototype, "axisControlRadius", void 0);
  13975. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13976. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13977. ], FollowCameraMouseWheelInput.prototype, "axisControlHeight", void 0);
  13978. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13979. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13980. ], FollowCameraMouseWheelInput.prototype, "axisControlRotation", void 0);
  13981. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13982. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13983. ], FollowCameraMouseWheelInput.prototype, "wheelPrecision", void 0);
  13984. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13985. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13986. ], FollowCameraMouseWheelInput.prototype, "wheelDeltaPercentage", void 0);
  13987. return FollowCameraMouseWheelInput;
  13988. }());
  13989. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FollowCameraMouseWheelInput"] = FollowCameraMouseWheelInput;
  13990. /***/ }),
  13991. /***/ "./Cameras/Inputs/followCameraPointersInput.ts":
  13992. /*!*****************************************************!*\
  13993. !*** ./Cameras/Inputs/followCameraPointersInput.ts ***!
  13994. \*****************************************************/
  13995. /*! exports provided: FollowCameraPointersInput */
  13996. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13997. "use strict";
  13998. __webpack_require__.r(__webpack_exports__);
  13999. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return FollowCameraPointersInput; });
  14000. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14001. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14002. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14003. /* harmony import */ var _Cameras_Inputs_BaseCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/Inputs/BaseCameraPointersInput */ "./Cameras/Inputs/BaseCameraPointersInput.ts");
  14004. /**
  14005. * Manage the pointers inputs to control an follow camera.
  14006. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14007. */
  14008. var FollowCameraPointersInput = /** @class */ (function (_super) {
  14009. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCameraPointersInput, _super);
  14010. function FollowCameraPointersInput() {
  14011. var _this = _super !== null && _super.apply(this, arguments) || this;
  14012. /**
  14013. * Defines the pointer angular sensibility along the X axis or how fast is
  14014. * the camera rotating.
  14015. * A negative number will reverse the axis direction.
  14016. */
  14017. _this.angularSensibilityX = 1;
  14018. /**
  14019. * Defines the pointer angular sensibility along the Y axis or how fast is
  14020. * the camera rotating.
  14021. * A negative number will reverse the axis direction.
  14022. */
  14023. _this.angularSensibilityY = 1;
  14024. /**
  14025. * Defines the pointer pinch precision or how fast is the camera zooming.
  14026. * A negative number will reverse the axis direction.
  14027. */
  14028. _this.pinchPrecision = 10000.0;
  14029. /**
  14030. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  14031. * from 0.
  14032. * It defines the percentage of current camera.radius to use as delta when
  14033. * pinch zoom is used.
  14034. */
  14035. _this.pinchDeltaPercentage = 0;
  14036. /**
  14037. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  14038. */
  14039. _this.axisXControlRadius = false;
  14040. /**
  14041. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  14042. */
  14043. _this.axisXControlHeight = false;
  14044. /**
  14045. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  14046. */
  14047. _this.axisXControlRotation = true;
  14048. /**
  14049. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  14050. */
  14051. _this.axisYControlRadius = false;
  14052. /**
  14053. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  14054. */
  14055. _this.axisYControlHeight = true;
  14056. /**
  14057. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  14058. */
  14059. _this.axisYControlRotation = false;
  14060. /**
  14061. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  14062. */
  14063. _this.axisPinchControlRadius = true;
  14064. /**
  14065. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  14066. */
  14067. _this.axisPinchControlHeight = false;
  14068. /**
  14069. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  14070. */
  14071. _this.axisPinchControlRotation = false;
  14072. /**
  14073. * Log error messages if basic misconfiguration has occurred.
  14074. */
  14075. _this.warningEnable = true;
  14076. /* Check for obvious misconfiguration. */
  14077. _this._warningCounter = 0;
  14078. return _this;
  14079. }
  14080. /**
  14081. * Gets the class name of the current input.
  14082. * @returns the class name
  14083. */
  14084. FollowCameraPointersInput.prototype.getClassName = function () {
  14085. return "FollowCameraPointersInput";
  14086. };
  14087. FollowCameraPointersInput.prototype.onTouch = function (pointA, offsetX, offsetY) {
  14088. this._warning();
  14089. if (this.axisXControlRotation) {
  14090. this.camera.rotationOffset += offsetX / this.angularSensibilityX;
  14091. }
  14092. else if (this.axisYControlRotation) {
  14093. this.camera.rotationOffset += offsetY / this.angularSensibilityX;
  14094. }
  14095. if (this.axisXControlHeight) {
  14096. this.camera.heightOffset += offsetX / this.angularSensibilityY;
  14097. }
  14098. else if (this.axisYControlHeight) {
  14099. this.camera.heightOffset += offsetY / this.angularSensibilityY;
  14100. }
  14101. if (this.axisXControlRadius) {
  14102. this.camera.radius -= offsetX / this.angularSensibilityY;
  14103. }
  14104. else if (this.axisYControlRadius) {
  14105. this.camera.radius -= offsetY / this.angularSensibilityY;
  14106. }
  14107. };
  14108. FollowCameraPointersInput.prototype.onMultiTouch = function (pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition) {
  14109. if (previousPinchSquaredDistance === 0 && previousMultiTouchPanPosition === null) {
  14110. // First time this method is called for new pinch.
  14111. // Next time this is called there will be a
  14112. // previousPinchSquaredDistance and pinchSquaredDistance to compare.
  14113. return;
  14114. }
  14115. if (pinchSquaredDistance === 0 && multiTouchPanPosition === null) {
  14116. // Last time this method is called at the end of a pinch.
  14117. return;
  14118. }
  14119. var pinchDelta = (pinchSquaredDistance - previousPinchSquaredDistance) /
  14120. (this.pinchPrecision * (this.angularSensibilityX + this.angularSensibilityY) / 2);
  14121. if (this.pinchDeltaPercentage) {
  14122. pinchDelta *= 0.01 * this.pinchDeltaPercentage;
  14123. if (this.axisPinchControlRotation) {
  14124. this.camera.rotationOffset += pinchDelta * this.camera.rotationOffset;
  14125. }
  14126. if (this.axisPinchControlHeight) {
  14127. this.camera.heightOffset += pinchDelta * this.camera.heightOffset;
  14128. }
  14129. if (this.axisPinchControlRadius) {
  14130. this.camera.radius -= pinchDelta * this.camera.radius;
  14131. }
  14132. }
  14133. else {
  14134. if (this.axisPinchControlRotation) {
  14135. this.camera.rotationOffset += pinchDelta;
  14136. }
  14137. if (this.axisPinchControlHeight) {
  14138. this.camera.heightOffset += pinchDelta;
  14139. }
  14140. if (this.axisPinchControlRadius) {
  14141. this.camera.radius -= pinchDelta;
  14142. }
  14143. }
  14144. };
  14145. FollowCameraPointersInput.prototype._warning = function () {
  14146. if (!this.warningEnable || this._warningCounter++ % 100 !== 0) {
  14147. return;
  14148. }
  14149. var warn = "It probably only makes sense to control ONE camera " +
  14150. "property with each pointer axis. Set 'warningEnable = false' " +
  14151. "if you are sure. Currently enabled: ";
  14152. console.assert((this.axisXControlRotation +
  14153. this.axisXControlHeight +
  14154. this.axisXControlRadius) <= 1, warn +
  14155. "axisXControlRotation: " + this.axisXControlRotation +
  14156. ", axisXControlHeight: " + this.axisXControlHeight +
  14157. ", axisXControlRadius: " + this.axisXControlRadius);
  14158. console.assert((this.axisYControlRotation +
  14159. this.axisYControlHeight +
  14160. this.axisYControlRadius) <= 1, warn +
  14161. "axisYControlRotation: " + this.axisYControlRotation +
  14162. ", axisYControlHeight: " + this.axisYControlHeight +
  14163. ", axisYControlRadius: " + this.axisYControlRadius);
  14164. console.assert((this.axisPinchControlRotation +
  14165. this.axisPinchControlHeight +
  14166. this.axisPinchControlRadius) <= 1, warn +
  14167. "axisPinchControlRotation: " + this.axisPinchControlRotation +
  14168. ", axisPinchControlHeight: " + this.axisPinchControlHeight +
  14169. ", axisPinchControlRadius: " + this.axisPinchControlRadius);
  14170. };
  14171. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14172. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14173. ], FollowCameraPointersInput.prototype, "angularSensibilityX", void 0);
  14174. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14175. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14176. ], FollowCameraPointersInput.prototype, "angularSensibilityY", void 0);
  14177. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14178. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14179. ], FollowCameraPointersInput.prototype, "pinchPrecision", void 0);
  14180. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14181. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14182. ], FollowCameraPointersInput.prototype, "pinchDeltaPercentage", void 0);
  14183. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14184. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14185. ], FollowCameraPointersInput.prototype, "axisXControlRadius", void 0);
  14186. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14187. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14188. ], FollowCameraPointersInput.prototype, "axisXControlHeight", void 0);
  14189. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14190. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14191. ], FollowCameraPointersInput.prototype, "axisXControlRotation", void 0);
  14192. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14193. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14194. ], FollowCameraPointersInput.prototype, "axisYControlRadius", void 0);
  14195. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14196. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14197. ], FollowCameraPointersInput.prototype, "axisYControlHeight", void 0);
  14198. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14199. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14200. ], FollowCameraPointersInput.prototype, "axisYControlRotation", void 0);
  14201. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14202. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14203. ], FollowCameraPointersInput.prototype, "axisPinchControlRadius", void 0);
  14204. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14205. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14206. ], FollowCameraPointersInput.prototype, "axisPinchControlHeight", void 0);
  14207. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14208. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14209. ], FollowCameraPointersInput.prototype, "axisPinchControlRotation", void 0);
  14210. return FollowCameraPointersInput;
  14211. }(_Cameras_Inputs_BaseCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__["BaseCameraPointersInput"]));
  14212. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FollowCameraPointersInput"] = FollowCameraPointersInput;
  14213. /***/ }),
  14214. /***/ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts":
  14215. /*!************************************************************!*\
  14216. !*** ./Cameras/Inputs/freeCameraDeviceOrientationInput.ts ***!
  14217. \************************************************************/
  14218. /*! exports provided: FreeCameraDeviceOrientationInput */
  14219. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14220. "use strict";
  14221. __webpack_require__.r(__webpack_exports__);
  14222. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return FreeCameraDeviceOrientationInput; });
  14223. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14224. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14225. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  14226. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  14227. /**
  14228. * Add orientation input support to the input manager.
  14229. * @returns the current input manager
  14230. */
  14231. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addDeviceOrientation = function () {
  14232. this.add(new FreeCameraDeviceOrientationInput());
  14233. return this;
  14234. };
  14235. /**
  14236. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  14237. * Screen rotation is taken into account.
  14238. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14239. */
  14240. var FreeCameraDeviceOrientationInput = /** @class */ (function () {
  14241. /**
  14242. * Instantiates a new input
  14243. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14244. */
  14245. function FreeCameraDeviceOrientationInput() {
  14246. var _this = this;
  14247. this._screenOrientationAngle = 0;
  14248. this._screenQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  14249. this._alpha = 0;
  14250. this._beta = 0;
  14251. this._gamma = 0;
  14252. this._orientationChanged = function () {
  14253. _this._screenOrientationAngle = (window.orientation !== undefined ? +window.orientation : (window.screen.orientation && (window.screen.orientation)['angle'] ? (window.screen.orientation).angle : 0));
  14254. _this._screenOrientationAngle = -_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(_this._screenOrientationAngle / 2);
  14255. _this._screenQuaternion.copyFromFloats(0, Math.sin(_this._screenOrientationAngle), 0, Math.cos(_this._screenOrientationAngle));
  14256. };
  14257. this._deviceOrientation = function (evt) {
  14258. _this._alpha = evt.alpha !== null ? evt.alpha : 0;
  14259. _this._beta = evt.beta !== null ? evt.beta : 0;
  14260. _this._gamma = evt.gamma !== null ? evt.gamma : 0;
  14261. };
  14262. this._constantTranform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](-Math.sqrt(0.5), 0, 0, Math.sqrt(0.5));
  14263. this._orientationChanged();
  14264. }
  14265. Object.defineProperty(FreeCameraDeviceOrientationInput.prototype, "camera", {
  14266. /**
  14267. * Define the camera controlled by the input.
  14268. */
  14269. get: function () {
  14270. return this._camera;
  14271. },
  14272. set: function (camera) {
  14273. this._camera = camera;
  14274. if (this._camera != null && !this._camera.rotationQuaternion) {
  14275. this._camera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  14276. }
  14277. },
  14278. enumerable: true,
  14279. configurable: true
  14280. });
  14281. /**
  14282. * Attach the input controls to a specific dom element to get the input from.
  14283. * @param element Defines the element the controls should be listened from
  14284. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14285. */
  14286. FreeCameraDeviceOrientationInput.prototype.attachControl = function (element, noPreventDefault) {
  14287. window.addEventListener("orientationchange", this._orientationChanged);
  14288. window.addEventListener("deviceorientation", this._deviceOrientation);
  14289. //In certain cases, the attach control is called AFTER orientation was changed,
  14290. //So this is needed.
  14291. this._orientationChanged();
  14292. };
  14293. /**
  14294. * Detach the current controls from the specified dom element.
  14295. * @param element Defines the element to stop listening the inputs from
  14296. */
  14297. FreeCameraDeviceOrientationInput.prototype.detachControl = function (element) {
  14298. window.removeEventListener("orientationchange", this._orientationChanged);
  14299. window.removeEventListener("deviceorientation", this._deviceOrientation);
  14300. this._alpha = 0;
  14301. };
  14302. /**
  14303. * Update the current camera state depending on the inputs that have been used this frame.
  14304. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14305. */
  14306. FreeCameraDeviceOrientationInput.prototype.checkInputs = function () {
  14307. //if no device orientation provided, don't update the rotation.
  14308. //Only testing against alpha under the assumption thatnorientation will never be so exact when set.
  14309. if (!this._alpha) {
  14310. return;
  14311. }
  14312. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].RotationYawPitchRollToRef(_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(this._alpha), _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(this._beta), -_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(this._gamma), this.camera.rotationQuaternion);
  14313. this._camera.rotationQuaternion.multiplyInPlace(this._screenQuaternion);
  14314. this._camera.rotationQuaternion.multiplyInPlace(this._constantTranform);
  14315. //Mirror on XY Plane
  14316. this._camera.rotationQuaternion.z *= -1;
  14317. this._camera.rotationQuaternion.w *= -1;
  14318. };
  14319. /**
  14320. * Gets the class name of the current intput.
  14321. * @returns the class name
  14322. */
  14323. FreeCameraDeviceOrientationInput.prototype.getClassName = function () {
  14324. return "FreeCameraDeviceOrientationInput";
  14325. };
  14326. /**
  14327. * Get the friendly name associated with the input class.
  14328. * @returns the input friendly name
  14329. */
  14330. FreeCameraDeviceOrientationInput.prototype.getSimpleName = function () {
  14331. return "deviceOrientation";
  14332. };
  14333. return FreeCameraDeviceOrientationInput;
  14334. }());
  14335. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]["FreeCameraDeviceOrientationInput"] = FreeCameraDeviceOrientationInput;
  14336. /***/ }),
  14337. /***/ "./Cameras/Inputs/freeCameraGamepadInput.ts":
  14338. /*!**************************************************!*\
  14339. !*** ./Cameras/Inputs/freeCameraGamepadInput.ts ***!
  14340. \**************************************************/
  14341. /*! exports provided: FreeCameraGamepadInput */
  14342. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14343. "use strict";
  14344. __webpack_require__.r(__webpack_exports__);
  14345. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return FreeCameraGamepadInput; });
  14346. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14347. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14348. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14349. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14350. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  14351. /**
  14352. * Manage the gamepad inputs to control a free camera.
  14353. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14354. */
  14355. var FreeCameraGamepadInput = /** @class */ (function () {
  14356. function FreeCameraGamepadInput() {
  14357. /**
  14358. * Defines the gamepad rotation sensiblity.
  14359. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  14360. */
  14361. this.gamepadAngularSensibility = 200;
  14362. /**
  14363. * Defines the gamepad move sensiblity.
  14364. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  14365. */
  14366. this.gamepadMoveSensibility = 40;
  14367. this._cameraTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  14368. this._deltaTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  14369. this._vector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  14370. this._vector2 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  14371. }
  14372. /**
  14373. * Attach the input controls to a specific dom element to get the input from.
  14374. * @param element Defines the element the controls should be listened from
  14375. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14376. */
  14377. FreeCameraGamepadInput.prototype.attachControl = function (element, noPreventDefault) {
  14378. var _this = this;
  14379. var manager = this.camera.getScene().gamepadManager;
  14380. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  14381. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].POSE_ENABLED) {
  14382. // prioritize XBOX gamepads.
  14383. if (!_this.gamepad || gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].XBOX) {
  14384. _this.gamepad = gamepad;
  14385. }
  14386. }
  14387. });
  14388. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  14389. if (_this.gamepad === gamepad) {
  14390. _this.gamepad = null;
  14391. }
  14392. });
  14393. this.gamepad = manager.getGamepadByType(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].XBOX);
  14394. };
  14395. /**
  14396. * Detach the current controls from the specified dom element.
  14397. * @param element Defines the element to stop listening the inputs from
  14398. */
  14399. FreeCameraGamepadInput.prototype.detachControl = function (element) {
  14400. this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  14401. this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  14402. this.gamepad = null;
  14403. };
  14404. /**
  14405. * Update the current camera state depending on the inputs that have been used this frame.
  14406. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14407. */
  14408. FreeCameraGamepadInput.prototype.checkInputs = function () {
  14409. if (this.gamepad && this.gamepad.leftStick) {
  14410. var camera = this.camera;
  14411. var LSValues = this.gamepad.leftStick;
  14412. var normalizedLX = LSValues.x / this.gamepadMoveSensibility;
  14413. var normalizedLY = LSValues.y / this.gamepadMoveSensibility;
  14414. LSValues.x = Math.abs(normalizedLX) > 0.005 ? 0 + normalizedLX : 0;
  14415. LSValues.y = Math.abs(normalizedLY) > 0.005 ? 0 + normalizedLY : 0;
  14416. var RSValues = this.gamepad.rightStick;
  14417. if (RSValues) {
  14418. var normalizedRX = RSValues.x / this.gamepadAngularSensibility;
  14419. var normalizedRY = RSValues.y / this.gamepadAngularSensibility;
  14420. RSValues.x = Math.abs(normalizedRX) > 0.001 ? 0 + normalizedRX : 0;
  14421. RSValues.y = Math.abs(normalizedRY) > 0.001 ? 0 + normalizedRY : 0;
  14422. }
  14423. else {
  14424. RSValues = { x: 0, y: 0 };
  14425. }
  14426. if (!camera.rotationQuaternion) {
  14427. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, this._cameraTransform);
  14428. }
  14429. else {
  14430. camera.rotationQuaternion.toRotationMatrix(this._cameraTransform);
  14431. }
  14432. var speed = camera._computeLocalCameraSpeed() * 50.0;
  14433. this._vector3.copyFromFloats(LSValues.x * speed, 0, -LSValues.y * speed);
  14434. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._vector3, this._cameraTransform, this._deltaTransform);
  14435. camera.cameraDirection.addInPlace(this._deltaTransform);
  14436. this._vector2.copyFromFloats(RSValues.y, RSValues.x);
  14437. camera.cameraRotation.addInPlace(this._vector2);
  14438. }
  14439. };
  14440. /**
  14441. * Gets the class name of the current intput.
  14442. * @returns the class name
  14443. */
  14444. FreeCameraGamepadInput.prototype.getClassName = function () {
  14445. return "FreeCameraGamepadInput";
  14446. };
  14447. /**
  14448. * Get the friendly name associated with the input class.
  14449. * @returns the input friendly name
  14450. */
  14451. FreeCameraGamepadInput.prototype.getSimpleName = function () {
  14452. return "gamepad";
  14453. };
  14454. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14455. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14456. ], FreeCameraGamepadInput.prototype, "gamepadAngularSensibility", void 0);
  14457. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14458. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14459. ], FreeCameraGamepadInput.prototype, "gamepadMoveSensibility", void 0);
  14460. return FreeCameraGamepadInput;
  14461. }());
  14462. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraGamepadInput"] = FreeCameraGamepadInput;
  14463. /***/ }),
  14464. /***/ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts":
  14465. /*!*******************************************************!*\
  14466. !*** ./Cameras/Inputs/freeCameraKeyboardMoveInput.ts ***!
  14467. \*******************************************************/
  14468. /*! exports provided: FreeCameraKeyboardMoveInput */
  14469. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14470. "use strict";
  14471. __webpack_require__.r(__webpack_exports__);
  14472. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return FreeCameraKeyboardMoveInput; });
  14473. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14474. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14475. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14476. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  14477. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14478. /**
  14479. * Manage the keyboard inputs to control the movement of a free camera.
  14480. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14481. */
  14482. var FreeCameraKeyboardMoveInput = /** @class */ (function () {
  14483. function FreeCameraKeyboardMoveInput() {
  14484. /**
  14485. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  14486. */
  14487. this.keysUp = [38];
  14488. /**
  14489. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  14490. */
  14491. this.keysDown = [40];
  14492. /**
  14493. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  14494. */
  14495. this.keysLeft = [37];
  14496. /**
  14497. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  14498. */
  14499. this.keysRight = [39];
  14500. this._keys = new Array();
  14501. }
  14502. /**
  14503. * Attach the input controls to a specific dom element to get the input from.
  14504. * @param element Defines the element the controls should be listened from
  14505. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14506. */
  14507. FreeCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  14508. var _this = this;
  14509. if (this._onCanvasBlurObserver) {
  14510. return;
  14511. }
  14512. this._scene = this.camera.getScene();
  14513. this._engine = this._scene.getEngine();
  14514. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  14515. _this._keys = [];
  14516. });
  14517. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  14518. var evt = info.event;
  14519. if (!evt.metaKey) {
  14520. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  14521. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  14522. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  14523. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  14524. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  14525. var index = _this._keys.indexOf(evt.keyCode);
  14526. if (index === -1) {
  14527. _this._keys.push(evt.keyCode);
  14528. }
  14529. if (!noPreventDefault) {
  14530. evt.preventDefault();
  14531. }
  14532. }
  14533. }
  14534. else {
  14535. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  14536. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  14537. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  14538. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  14539. var index = _this._keys.indexOf(evt.keyCode);
  14540. if (index >= 0) {
  14541. _this._keys.splice(index, 1);
  14542. }
  14543. if (!noPreventDefault) {
  14544. evt.preventDefault();
  14545. }
  14546. }
  14547. }
  14548. }
  14549. });
  14550. };
  14551. /**
  14552. * Detach the current controls from the specified dom element.
  14553. * @param element Defines the element to stop listening the inputs from
  14554. */
  14555. FreeCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  14556. if (this._scene) {
  14557. if (this._onKeyboardObserver) {
  14558. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  14559. }
  14560. if (this._onCanvasBlurObserver) {
  14561. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  14562. }
  14563. this._onKeyboardObserver = null;
  14564. this._onCanvasBlurObserver = null;
  14565. }
  14566. this._keys = [];
  14567. };
  14568. /**
  14569. * Update the current camera state depending on the inputs that have been used this frame.
  14570. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14571. */
  14572. FreeCameraKeyboardMoveInput.prototype.checkInputs = function () {
  14573. if (this._onKeyboardObserver) {
  14574. var camera = this.camera;
  14575. // Keyboard
  14576. for (var index = 0; index < this._keys.length; index++) {
  14577. var keyCode = this._keys[index];
  14578. var speed = camera._computeLocalCameraSpeed();
  14579. if (this.keysLeft.indexOf(keyCode) !== -1) {
  14580. camera._localDirection.copyFromFloats(-speed, 0, 0);
  14581. }
  14582. else if (this.keysUp.indexOf(keyCode) !== -1) {
  14583. camera._localDirection.copyFromFloats(0, 0, speed);
  14584. }
  14585. else if (this.keysRight.indexOf(keyCode) !== -1) {
  14586. camera._localDirection.copyFromFloats(speed, 0, 0);
  14587. }
  14588. else if (this.keysDown.indexOf(keyCode) !== -1) {
  14589. camera._localDirection.copyFromFloats(0, 0, -speed);
  14590. }
  14591. if (camera.getScene().useRightHandedSystem) {
  14592. camera._localDirection.z *= -1;
  14593. }
  14594. camera.getViewMatrix().invertToRef(camera._cameraTransformMatrix);
  14595. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormalToRef(camera._localDirection, camera._cameraTransformMatrix, camera._transformedDirection);
  14596. camera.cameraDirection.addInPlace(camera._transformedDirection);
  14597. }
  14598. }
  14599. };
  14600. /**
  14601. * Gets the class name of the current intput.
  14602. * @returns the class name
  14603. */
  14604. FreeCameraKeyboardMoveInput.prototype.getClassName = function () {
  14605. return "FreeCameraKeyboardMoveInput";
  14606. };
  14607. /** @hidden */
  14608. FreeCameraKeyboardMoveInput.prototype._onLostFocus = function () {
  14609. this._keys = [];
  14610. };
  14611. /**
  14612. * Get the friendly name associated with the input class.
  14613. * @returns the input friendly name
  14614. */
  14615. FreeCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  14616. return "keyboard";
  14617. };
  14618. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14619. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14620. ], FreeCameraKeyboardMoveInput.prototype, "keysUp", void 0);
  14621. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14622. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14623. ], FreeCameraKeyboardMoveInput.prototype, "keysDown", void 0);
  14624. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14625. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14626. ], FreeCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
  14627. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14628. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14629. ], FreeCameraKeyboardMoveInput.prototype, "keysRight", void 0);
  14630. return FreeCameraKeyboardMoveInput;
  14631. }());
  14632. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraKeyboardMoveInput"] = FreeCameraKeyboardMoveInput;
  14633. /***/ }),
  14634. /***/ "./Cameras/Inputs/freeCameraMouseInput.ts":
  14635. /*!************************************************!*\
  14636. !*** ./Cameras/Inputs/freeCameraMouseInput.ts ***!
  14637. \************************************************/
  14638. /*! exports provided: FreeCameraMouseInput */
  14639. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14640. "use strict";
  14641. __webpack_require__.r(__webpack_exports__);
  14642. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return FreeCameraMouseInput; });
  14643. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14644. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14645. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14646. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  14647. /**
  14648. * Manage the mouse inputs to control the movement of a free camera.
  14649. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14650. */
  14651. var FreeCameraMouseInput = /** @class */ (function () {
  14652. /**
  14653. * Manage the mouse inputs to control the movement of a free camera.
  14654. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14655. * @param touchEnabled Defines if touch is enabled or not
  14656. */
  14657. function FreeCameraMouseInput(
  14658. /**
  14659. * Define if touch is enabled in the mouse input
  14660. */
  14661. touchEnabled) {
  14662. if (touchEnabled === void 0) { touchEnabled = true; }
  14663. this.touchEnabled = touchEnabled;
  14664. /**
  14665. * Defines the buttons associated with the input to handle camera move.
  14666. */
  14667. this.buttons = [0, 1, 2];
  14668. /**
  14669. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  14670. */
  14671. this.angularSensibility = 2000.0;
  14672. this.previousPosition = null;
  14673. }
  14674. /**
  14675. * Attach the input controls to a specific dom element to get the input from.
  14676. * @param element Defines the element the controls should be listened from
  14677. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14678. */
  14679. FreeCameraMouseInput.prototype.attachControl = function (element, noPreventDefault) {
  14680. var _this = this;
  14681. var engine = this.camera.getEngine();
  14682. if (!this._pointerInput) {
  14683. this._pointerInput = function (p) {
  14684. var evt = p.event;
  14685. if (engine.isInVRExclusivePointerMode) {
  14686. return;
  14687. }
  14688. if (!_this.touchEnabled && evt.pointerType === "touch") {
  14689. return;
  14690. }
  14691. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE && _this.buttons.indexOf(evt.button) === -1) {
  14692. return;
  14693. }
  14694. var srcElement = (evt.srcElement || evt.target);
  14695. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN && srcElement) {
  14696. try {
  14697. srcElement.setPointerCapture(evt.pointerId);
  14698. }
  14699. catch (e) {
  14700. //Nothing to do with the error. Execution will continue.
  14701. }
  14702. _this.previousPosition = {
  14703. x: evt.clientX,
  14704. y: evt.clientY
  14705. };
  14706. if (!noPreventDefault) {
  14707. evt.preventDefault();
  14708. element.focus();
  14709. }
  14710. }
  14711. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP && srcElement) {
  14712. try {
  14713. srcElement.releasePointerCapture(evt.pointerId);
  14714. }
  14715. catch (e) {
  14716. //Nothing to do with the error.
  14717. }
  14718. _this.previousPosition = null;
  14719. if (!noPreventDefault) {
  14720. evt.preventDefault();
  14721. }
  14722. }
  14723. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  14724. if (!_this.previousPosition || engine.isPointerLock) {
  14725. return;
  14726. }
  14727. var offsetX = evt.clientX - _this.previousPosition.x;
  14728. if (_this.camera.getScene().useRightHandedSystem) {
  14729. offsetX *= -1;
  14730. }
  14731. if (_this.camera.parent && _this.camera.parent._getWorldMatrixDeterminant() < 0) {
  14732. offsetX *= -1;
  14733. }
  14734. _this.camera.cameraRotation.y += offsetX / _this.angularSensibility;
  14735. var offsetY = evt.clientY - _this.previousPosition.y;
  14736. _this.camera.cameraRotation.x += offsetY / _this.angularSensibility;
  14737. _this.previousPosition = {
  14738. x: evt.clientX,
  14739. y: evt.clientY
  14740. };
  14741. if (!noPreventDefault) {
  14742. evt.preventDefault();
  14743. }
  14744. }
  14745. };
  14746. }
  14747. this._onMouseMove = function (evt) {
  14748. if (!engine.isPointerLock) {
  14749. return;
  14750. }
  14751. if (engine.isInVRExclusivePointerMode) {
  14752. return;
  14753. }
  14754. var offsetX = evt.movementX || evt.mozMovementX || evt.webkitMovementX || evt.msMovementX || 0;
  14755. if (_this.camera.getScene().useRightHandedSystem) {
  14756. offsetX *= -1;
  14757. }
  14758. if (_this.camera.parent && _this.camera.parent._getWorldMatrixDeterminant() < 0) {
  14759. offsetX *= -1;
  14760. }
  14761. _this.camera.cameraRotation.y += offsetX / _this.angularSensibility;
  14762. var offsetY = evt.movementY || evt.mozMovementY || evt.webkitMovementY || evt.msMovementY || 0;
  14763. _this.camera.cameraRotation.x += offsetY / _this.angularSensibility;
  14764. _this.previousPosition = null;
  14765. if (!noPreventDefault) {
  14766. evt.preventDefault();
  14767. }
  14768. };
  14769. this._observer = this.camera.getScene().onPointerObservable.add(this._pointerInput, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE);
  14770. element.addEventListener("mousemove", this._onMouseMove, false);
  14771. };
  14772. /**
  14773. * Detach the current controls from the specified dom element.
  14774. * @param element Defines the element to stop listening the inputs from
  14775. */
  14776. FreeCameraMouseInput.prototype.detachControl = function (element) {
  14777. if (this._observer && element) {
  14778. this.camera.getScene().onPointerObservable.remove(this._observer);
  14779. if (this._onMouseMove) {
  14780. element.removeEventListener("mousemove", this._onMouseMove);
  14781. }
  14782. this._observer = null;
  14783. this._onMouseMove = null;
  14784. this.previousPosition = null;
  14785. }
  14786. };
  14787. /**
  14788. * Gets the class name of the current intput.
  14789. * @returns the class name
  14790. */
  14791. FreeCameraMouseInput.prototype.getClassName = function () {
  14792. return "FreeCameraMouseInput";
  14793. };
  14794. /**
  14795. * Get the friendly name associated with the input class.
  14796. * @returns the input friendly name
  14797. */
  14798. FreeCameraMouseInput.prototype.getSimpleName = function () {
  14799. return "mouse";
  14800. };
  14801. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14802. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14803. ], FreeCameraMouseInput.prototype, "buttons", void 0);
  14804. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14805. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14806. ], FreeCameraMouseInput.prototype, "angularSensibility", void 0);
  14807. return FreeCameraMouseInput;
  14808. }());
  14809. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraMouseInput"] = FreeCameraMouseInput;
  14810. /***/ }),
  14811. /***/ "./Cameras/Inputs/freeCameraTouchInput.ts":
  14812. /*!************************************************!*\
  14813. !*** ./Cameras/Inputs/freeCameraTouchInput.ts ***!
  14814. \************************************************/
  14815. /*! exports provided: FreeCameraTouchInput */
  14816. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14817. "use strict";
  14818. __webpack_require__.r(__webpack_exports__);
  14819. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return FreeCameraTouchInput; });
  14820. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14821. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14822. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14823. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  14824. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14825. /**
  14826. * Manage the touch inputs to control the movement of a free camera.
  14827. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14828. */
  14829. var FreeCameraTouchInput = /** @class */ (function () {
  14830. function FreeCameraTouchInput() {
  14831. /**
  14832. * Defines the touch sensibility for rotation.
  14833. * The higher the faster.
  14834. */
  14835. this.touchAngularSensibility = 200000.0;
  14836. /**
  14837. * Defines the touch sensibility for move.
  14838. * The higher the faster.
  14839. */
  14840. this.touchMoveSensibility = 250.0;
  14841. this._offsetX = null;
  14842. this._offsetY = null;
  14843. this._pointerPressed = new Array();
  14844. }
  14845. /**
  14846. * Attach the input controls to a specific dom element to get the input from.
  14847. * @param element Defines the element the controls should be listened from
  14848. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14849. */
  14850. FreeCameraTouchInput.prototype.attachControl = function (element, noPreventDefault) {
  14851. var _this = this;
  14852. var previousPosition = null;
  14853. if (this._pointerInput === undefined) {
  14854. this._onLostFocus = function () {
  14855. _this._offsetX = null;
  14856. _this._offsetY = null;
  14857. };
  14858. this._pointerInput = function (p) {
  14859. var evt = p.event;
  14860. if (evt.pointerType === "mouse") {
  14861. return;
  14862. }
  14863. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN) {
  14864. if (!noPreventDefault) {
  14865. evt.preventDefault();
  14866. }
  14867. _this._pointerPressed.push(evt.pointerId);
  14868. if (_this._pointerPressed.length !== 1) {
  14869. return;
  14870. }
  14871. previousPosition = {
  14872. x: evt.clientX,
  14873. y: evt.clientY
  14874. };
  14875. }
  14876. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP) {
  14877. if (!noPreventDefault) {
  14878. evt.preventDefault();
  14879. }
  14880. var index = _this._pointerPressed.indexOf(evt.pointerId);
  14881. if (index === -1) {
  14882. return;
  14883. }
  14884. _this._pointerPressed.splice(index, 1);
  14885. if (index != 0) {
  14886. return;
  14887. }
  14888. previousPosition = null;
  14889. _this._offsetX = null;
  14890. _this._offsetY = null;
  14891. }
  14892. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  14893. if (!noPreventDefault) {
  14894. evt.preventDefault();
  14895. }
  14896. if (!previousPosition) {
  14897. return;
  14898. }
  14899. var index = _this._pointerPressed.indexOf(evt.pointerId);
  14900. if (index != 0) {
  14901. return;
  14902. }
  14903. _this._offsetX = evt.clientX - previousPosition.x;
  14904. _this._offsetY = -(evt.clientY - previousPosition.y);
  14905. }
  14906. };
  14907. }
  14908. 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);
  14909. if (this._onLostFocus) {
  14910. element.addEventListener("blur", this._onLostFocus);
  14911. }
  14912. };
  14913. /**
  14914. * Detach the current controls from the specified dom element.
  14915. * @param element Defines the element to stop listening the inputs from
  14916. */
  14917. FreeCameraTouchInput.prototype.detachControl = function (element) {
  14918. if (this._pointerInput && element) {
  14919. if (this._observer) {
  14920. this.camera.getScene().onPointerObservable.remove(this._observer);
  14921. this._observer = null;
  14922. }
  14923. if (this._onLostFocus) {
  14924. element.removeEventListener("blur", this._onLostFocus);
  14925. this._onLostFocus = null;
  14926. }
  14927. this._pointerPressed = [];
  14928. this._offsetX = null;
  14929. this._offsetY = null;
  14930. }
  14931. };
  14932. /**
  14933. * Update the current camera state depending on the inputs that have been used this frame.
  14934. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14935. */
  14936. FreeCameraTouchInput.prototype.checkInputs = function () {
  14937. if (this._offsetX && this._offsetY) {
  14938. var camera = this.camera;
  14939. camera.cameraRotation.y += this._offsetX / this.touchAngularSensibility;
  14940. if (this._pointerPressed.length > 1) {
  14941. camera.cameraRotation.x += -this._offsetY / this.touchAngularSensibility;
  14942. }
  14943. else {
  14944. var speed = camera._computeLocalCameraSpeed();
  14945. var direction = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 0, speed * this._offsetY / this.touchMoveSensibility);
  14946. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, camera._cameraRotationMatrix);
  14947. camera.cameraDirection.addInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinates(direction, camera._cameraRotationMatrix));
  14948. }
  14949. }
  14950. };
  14951. /**
  14952. * Gets the class name of the current intput.
  14953. * @returns the class name
  14954. */
  14955. FreeCameraTouchInput.prototype.getClassName = function () {
  14956. return "FreeCameraTouchInput";
  14957. };
  14958. /**
  14959. * Get the friendly name associated with the input class.
  14960. * @returns the input friendly name
  14961. */
  14962. FreeCameraTouchInput.prototype.getSimpleName = function () {
  14963. return "touch";
  14964. };
  14965. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14966. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14967. ], FreeCameraTouchInput.prototype, "touchAngularSensibility", void 0);
  14968. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14969. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14970. ], FreeCameraTouchInput.prototype, "touchMoveSensibility", void 0);
  14971. return FreeCameraTouchInput;
  14972. }());
  14973. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraTouchInput"] = FreeCameraTouchInput;
  14974. /***/ }),
  14975. /***/ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts":
  14976. /*!**********************************************************!*\
  14977. !*** ./Cameras/Inputs/freeCameraVirtualJoystickInput.ts ***!
  14978. \**********************************************************/
  14979. /*! exports provided: FreeCameraVirtualJoystickInput */
  14980. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14981. "use strict";
  14982. __webpack_require__.r(__webpack_exports__);
  14983. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return FreeCameraVirtualJoystickInput; });
  14984. /* harmony import */ var _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/virtualJoystick */ "./Misc/virtualJoystick.ts");
  14985. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14986. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14987. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  14988. /**
  14989. * Add virtual joystick input support to the input manager.
  14990. * @returns the current input manager
  14991. */
  14992. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addVirtualJoystick = function () {
  14993. this.add(new FreeCameraVirtualJoystickInput());
  14994. return this;
  14995. };
  14996. /**
  14997. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  14998. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14999. */
  15000. var FreeCameraVirtualJoystickInput = /** @class */ (function () {
  15001. function FreeCameraVirtualJoystickInput() {
  15002. }
  15003. /**
  15004. * Gets the left stick of the virtual joystick.
  15005. * @returns The virtual Joystick
  15006. */
  15007. FreeCameraVirtualJoystickInput.prototype.getLeftJoystick = function () {
  15008. return this._leftjoystick;
  15009. };
  15010. /**
  15011. * Gets the right stick of the virtual joystick.
  15012. * @returns The virtual Joystick
  15013. */
  15014. FreeCameraVirtualJoystickInput.prototype.getRightJoystick = function () {
  15015. return this._rightjoystick;
  15016. };
  15017. /**
  15018. * Update the current camera state depending on the inputs that have been used this frame.
  15019. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  15020. */
  15021. FreeCameraVirtualJoystickInput.prototype.checkInputs = function () {
  15022. if (this._leftjoystick) {
  15023. var camera = this.camera;
  15024. var speed = camera._computeLocalCameraSpeed() * 50;
  15025. var cameraTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].RotationYawPitchRoll(camera.rotation.y, camera.rotation.x, 0);
  15026. 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);
  15027. camera.cameraDirection = camera.cameraDirection.add(deltaTransform);
  15028. camera.cameraRotation = camera.cameraRotation.addVector3(this._rightjoystick.deltaPosition);
  15029. if (!this._leftjoystick.pressed) {
  15030. this._leftjoystick.deltaPosition = this._leftjoystick.deltaPosition.scale(0.9);
  15031. }
  15032. if (!this._rightjoystick.pressed) {
  15033. this._rightjoystick.deltaPosition = this._rightjoystick.deltaPosition.scale(0.9);
  15034. }
  15035. }
  15036. };
  15037. /**
  15038. * Attach the input controls to a specific dom element to get the input from.
  15039. * @param element Defines the element the controls should be listened from
  15040. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  15041. */
  15042. FreeCameraVirtualJoystickInput.prototype.attachControl = function (element, noPreventDefault) {
  15043. this._leftjoystick = new _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"](true);
  15044. this._leftjoystick.setAxisForUpDown(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].Z);
  15045. this._leftjoystick.setAxisForLeftRight(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].X);
  15046. this._leftjoystick.setJoystickSensibility(0.15);
  15047. this._rightjoystick = new _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"](false);
  15048. this._rightjoystick.setAxisForUpDown(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].X);
  15049. this._rightjoystick.setAxisForLeftRight(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].Y);
  15050. this._rightjoystick.reverseUpDown = true;
  15051. this._rightjoystick.setJoystickSensibility(0.05);
  15052. this._rightjoystick.setJoystickColor("yellow");
  15053. };
  15054. /**
  15055. * Detach the current controls from the specified dom element.
  15056. * @param element Defines the element to stop listening the inputs from
  15057. */
  15058. FreeCameraVirtualJoystickInput.prototype.detachControl = function (element) {
  15059. this._leftjoystick.releaseCanvas();
  15060. this._rightjoystick.releaseCanvas();
  15061. };
  15062. /**
  15063. * Gets the class name of the current intput.
  15064. * @returns the class name
  15065. */
  15066. FreeCameraVirtualJoystickInput.prototype.getClassName = function () {
  15067. return "FreeCameraVirtualJoystickInput";
  15068. };
  15069. /**
  15070. * Get the friendly name associated with the input class.
  15071. * @returns the input friendly name
  15072. */
  15073. FreeCameraVirtualJoystickInput.prototype.getSimpleName = function () {
  15074. return "virtualJoystick";
  15075. };
  15076. return FreeCameraVirtualJoystickInput;
  15077. }());
  15078. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]["FreeCameraVirtualJoystickInput"] = FreeCameraVirtualJoystickInput;
  15079. /***/ }),
  15080. /***/ "./Cameras/Inputs/index.ts":
  15081. /*!*********************************!*\
  15082. !*** ./Cameras/Inputs/index.ts ***!
  15083. \*********************************/
  15084. /*! exports provided: ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FollowCameraKeyboardMoveInput, FollowCameraMouseWheelInput, FollowCameraPointersInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput */
  15085. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15086. "use strict";
  15087. __webpack_require__.r(__webpack_exports__);
  15088. /* harmony import */ var _arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./arcRotateCameraGamepadInput */ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts");
  15089. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  15090. /* harmony import */ var _arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./arcRotateCameraKeyboardMoveInput */ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts");
  15091. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraKeyboardMoveInput"]; });
  15092. /* harmony import */ var _arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./arcRotateCameraMouseWheelInput */ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts");
  15093. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCameraMouseWheelInput"]; });
  15094. /* harmony import */ var _arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./arcRotateCameraPointersInput */ "./Cameras/Inputs/arcRotateCameraPointersInput.ts");
  15095. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__["ArcRotateCameraPointersInput"]; });
  15096. /* harmony import */ var _arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./arcRotateCameraVRDeviceOrientationInput */ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts");
  15097. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__["ArcRotateCameraVRDeviceOrientationInput"]; });
  15098. /* harmony import */ var _flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./flyCameraKeyboardInput */ "./Cameras/Inputs/flyCameraKeyboardInput.ts");
  15099. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_5__["FlyCameraKeyboardInput"]; });
  15100. /* harmony import */ var _flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./flyCameraMouseInput */ "./Cameras/Inputs/flyCameraMouseInput.ts");
  15101. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_6__["FlyCameraMouseInput"]; });
  15102. /* harmony import */ var _followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./followCameraKeyboardMoveInput */ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts");
  15103. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return _followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_7__["FollowCameraKeyboardMoveInput"]; });
  15104. /* harmony import */ var _followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./followCameraMouseWheelInput */ "./Cameras/Inputs/followCameraMouseWheelInput.ts");
  15105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return _followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_8__["FollowCameraMouseWheelInput"]; });
  15106. /* harmony import */ var _followCameraPointersInput__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./followCameraPointersInput */ "./Cameras/Inputs/followCameraPointersInput.ts");
  15107. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return _followCameraPointersInput__WEBPACK_IMPORTED_MODULE_9__["FollowCameraPointersInput"]; });
  15108. /* harmony import */ var _freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./freeCameraDeviceOrientationInput */ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts");
  15109. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_10__["FreeCameraDeviceOrientationInput"]; });
  15110. /* harmony import */ var _freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./freeCameraGamepadInput */ "./Cameras/Inputs/freeCameraGamepadInput.ts");
  15111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_11__["FreeCameraGamepadInput"]; });
  15112. /* harmony import */ var _freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./freeCameraKeyboardMoveInput */ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts");
  15113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_12__["FreeCameraKeyboardMoveInput"]; });
  15114. /* harmony import */ var _freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./freeCameraMouseInput */ "./Cameras/Inputs/freeCameraMouseInput.ts");
  15115. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_13__["FreeCameraMouseInput"]; });
  15116. /* harmony import */ var _freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./freeCameraTouchInput */ "./Cameras/Inputs/freeCameraTouchInput.ts");
  15117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_14__["FreeCameraTouchInput"]; });
  15118. /* harmony import */ var _freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./freeCameraVirtualJoystickInput */ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts");
  15119. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_15__["FreeCameraVirtualJoystickInput"]; });
  15120. /***/ }),
  15121. /***/ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts":
  15122. /*!*********************************************************!*\
  15123. !*** ./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts ***!
  15124. \*********************************************************/
  15125. /*! no exports provided */
  15126. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15127. "use strict";
  15128. __webpack_require__.r(__webpack_exports__);
  15129. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  15130. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  15131. /* harmony import */ var _PostProcesses_anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/anaglyphPostProcess */ "./PostProcesses/anaglyphPostProcess.ts");
  15132. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setStereoscopicAnaglyphRigMode = function (camera) {
  15133. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__["PassPostProcess"](camera.name + "_passthru", 1.0, camera._rigCameras[0]);
  15134. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_2__["AnaglyphPostProcess"](camera.name + "_anaglyph", 1.0, camera._rigCameras);
  15135. };
  15136. /***/ }),
  15137. /***/ "./Cameras/RigModes/stereoscopicRigMode.ts":
  15138. /*!*************************************************!*\
  15139. !*** ./Cameras/RigModes/stereoscopicRigMode.ts ***!
  15140. \*************************************************/
  15141. /*! no exports provided */
  15142. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15143. "use strict";
  15144. __webpack_require__.r(__webpack_exports__);
  15145. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  15146. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  15147. /* harmony import */ var _PostProcesses_stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/stereoscopicInterlacePostProcess */ "./PostProcesses/stereoscopicInterlacePostProcess.ts");
  15148. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setStereoscopicRigMode = function (camera) {
  15149. 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;
  15150. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__["PassPostProcess"](camera.name + "_passthru", 1.0, camera._rigCameras[0]);
  15151. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_2__["StereoscopicInterlacePostProcess"](camera.name + "_stereoInterlace", camera._rigCameras, isStereoscopicHoriz);
  15152. };
  15153. /***/ }),
  15154. /***/ "./Cameras/RigModes/vrRigMode.ts":
  15155. /*!***************************************!*\
  15156. !*** ./Cameras/RigModes/vrRigMode.ts ***!
  15157. \***************************************/
  15158. /*! no exports provided */
  15159. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15160. "use strict";
  15161. __webpack_require__.r(__webpack_exports__);
  15162. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  15163. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15164. /* harmony import */ var _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/vrDistortionCorrectionPostProcess */ "./PostProcesses/vrDistortionCorrectionPostProcess.ts");
  15165. /* harmony import */ var _VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../VR/vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15166. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setVRRigMode = function (camera, rigParams) {
  15167. var metrics = rigParams.vrCameraMetrics || _VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault();
  15168. camera._rigCameras[0]._cameraRigParams.vrMetrics = metrics;
  15169. camera._rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  15170. camera._rigCameras[0]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  15171. camera._rigCameras[0]._cameraRigParams.vrHMatrix = metrics.leftHMatrix;
  15172. camera._rigCameras[0]._cameraRigParams.vrPreViewMatrix = metrics.leftPreViewMatrix;
  15173. camera._rigCameras[0].getProjectionMatrix = camera._rigCameras[0]._getVRProjectionMatrix;
  15174. camera._rigCameras[1]._cameraRigParams.vrMetrics = metrics;
  15175. camera._rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  15176. camera._rigCameras[1]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  15177. camera._rigCameras[1]._cameraRigParams.vrHMatrix = metrics.rightHMatrix;
  15178. camera._rigCameras[1]._cameraRigParams.vrPreViewMatrix = metrics.rightPreViewMatrix;
  15179. camera._rigCameras[1].getProjectionMatrix = camera._rigCameras[1]._getVRProjectionMatrix;
  15180. if (metrics.compensateDistortion) {
  15181. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__["VRDistortionCorrectionPostProcess"]("VR_Distort_Compensation_Left", camera._rigCameras[0], false, metrics);
  15182. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__["VRDistortionCorrectionPostProcess"]("VR_Distort_Compensation_Right", camera._rigCameras[1], true, metrics);
  15183. }
  15184. };
  15185. /***/ }),
  15186. /***/ "./Cameras/RigModes/webVRRigMode.ts":
  15187. /*!******************************************!*\
  15188. !*** ./Cameras/RigModes/webVRRigMode.ts ***!
  15189. \******************************************/
  15190. /*! no exports provided */
  15191. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15192. "use strict";
  15193. __webpack_require__.r(__webpack_exports__);
  15194. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  15195. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15196. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setWebVRRigMode = function (camera, rigParams) {
  15197. if (rigParams.vrDisplay) {
  15198. var leftEye = rigParams.vrDisplay.getEyeParameters('left');
  15199. var rightEye = rigParams.vrDisplay.getEyeParameters('right');
  15200. //Left eye
  15201. camera._rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  15202. camera._rigCameras[0].setCameraRigParameter("left", true);
  15203. //leaving this for future reference
  15204. camera._rigCameras[0].setCameraRigParameter("specs", rigParams.specs);
  15205. camera._rigCameras[0].setCameraRigParameter("eyeParameters", leftEye);
  15206. camera._rigCameras[0].setCameraRigParameter("frameData", rigParams.frameData);
  15207. camera._rigCameras[0].setCameraRigParameter("parentCamera", rigParams.parentCamera);
  15208. camera._rigCameras[0]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  15209. camera._rigCameras[0].getProjectionMatrix = camera._getWebVRProjectionMatrix;
  15210. camera._rigCameras[0].parent = camera;
  15211. camera._rigCameras[0]._getViewMatrix = camera._getWebVRViewMatrix;
  15212. //Right eye
  15213. camera._rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  15214. camera._rigCameras[1].setCameraRigParameter('eyeParameters', rightEye);
  15215. camera._rigCameras[1].setCameraRigParameter("specs", rigParams.specs);
  15216. camera._rigCameras[1].setCameraRigParameter("frameData", rigParams.frameData);
  15217. camera._rigCameras[1].setCameraRigParameter("parentCamera", rigParams.parentCamera);
  15218. camera._rigCameras[1]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  15219. camera._rigCameras[1].getProjectionMatrix = camera._getWebVRProjectionMatrix;
  15220. camera._rigCameras[1].parent = camera;
  15221. camera._rigCameras[1]._getViewMatrix = camera._getWebVRViewMatrix;
  15222. if (_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].UseAlternateWebVRRendering) {
  15223. camera._rigCameras[1]._skipRendering = true;
  15224. camera._rigCameras[0]._alternateCamera = camera._rigCameras[1];
  15225. }
  15226. }
  15227. };
  15228. /***/ }),
  15229. /***/ "./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts":
  15230. /*!*********************************************************!*\
  15231. !*** ./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts ***!
  15232. \*********************************************************/
  15233. /*! exports provided: AnaglyphArcRotateCamera */
  15234. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15235. "use strict";
  15236. __webpack_require__.r(__webpack_exports__);
  15237. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return AnaglyphArcRotateCamera; });
  15238. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15239. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15240. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  15241. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15242. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15243. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  15244. // Side effect import to define the stereoscopic mode.
  15245. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphArcRotateCamera", function (name, scene, options) {
  15246. return function () { return new AnaglyphArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15247. });
  15248. /**
  15249. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  15250. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15251. */
  15252. var AnaglyphArcRotateCamera = /** @class */ (function (_super) {
  15253. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphArcRotateCamera, _super);
  15254. /**
  15255. * Creates a new AnaglyphArcRotateCamera
  15256. * @param name defines camera name
  15257. * @param alpha defines alpha angle (in radians)
  15258. * @param beta defines beta angle (in radians)
  15259. * @param radius defines radius
  15260. * @param target defines camera target
  15261. * @param interaxialDistance defines distance between each color axis
  15262. * @param scene defines the hosting scene
  15263. */
  15264. function AnaglyphArcRotateCamera(name, alpha, beta, radius, target, interaxialDistance, scene) {
  15265. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  15266. _this.interaxialDistance = interaxialDistance;
  15267. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  15268. return _this;
  15269. }
  15270. /**
  15271. * Gets camera class name
  15272. * @returns AnaglyphArcRotateCamera
  15273. */
  15274. AnaglyphArcRotateCamera.prototype.getClassName = function () {
  15275. return "AnaglyphArcRotateCamera";
  15276. };
  15277. return AnaglyphArcRotateCamera;
  15278. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  15279. /***/ }),
  15280. /***/ "./Cameras/Stereoscopic/anaglyphFreeCamera.ts":
  15281. /*!****************************************************!*\
  15282. !*** ./Cameras/Stereoscopic/anaglyphFreeCamera.ts ***!
  15283. \****************************************************/
  15284. /*! exports provided: AnaglyphFreeCamera */
  15285. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15286. "use strict";
  15287. __webpack_require__.r(__webpack_exports__);
  15288. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return AnaglyphFreeCamera; });
  15289. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15290. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15291. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  15292. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15293. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15294. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  15295. // Side effect import to define the stereoscopic mode.
  15296. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphFreeCamera", function (name, scene, options) {
  15297. return function () { return new AnaglyphFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15298. });
  15299. /**
  15300. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  15301. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15302. */
  15303. var AnaglyphFreeCamera = /** @class */ (function (_super) {
  15304. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphFreeCamera, _super);
  15305. /**
  15306. * Creates a new AnaglyphFreeCamera
  15307. * @param name defines camera name
  15308. * @param position defines initial position
  15309. * @param interaxialDistance defines distance between each color axis
  15310. * @param scene defines the hosting scene
  15311. */
  15312. function AnaglyphFreeCamera(name, position, interaxialDistance, scene) {
  15313. var _this = _super.call(this, name, position, scene) || this;
  15314. _this.interaxialDistance = interaxialDistance;
  15315. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  15316. return _this;
  15317. }
  15318. /**
  15319. * Gets camera class name
  15320. * @returns AnaglyphFreeCamera
  15321. */
  15322. AnaglyphFreeCamera.prototype.getClassName = function () {
  15323. return "AnaglyphFreeCamera";
  15324. };
  15325. return AnaglyphFreeCamera;
  15326. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  15327. /***/ }),
  15328. /***/ "./Cameras/Stereoscopic/anaglyphGamepadCamera.ts":
  15329. /*!*******************************************************!*\
  15330. !*** ./Cameras/Stereoscopic/anaglyphGamepadCamera.ts ***!
  15331. \*******************************************************/
  15332. /*! exports provided: AnaglyphGamepadCamera */
  15333. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15334. "use strict";
  15335. __webpack_require__.r(__webpack_exports__);
  15336. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return AnaglyphGamepadCamera; });
  15337. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15338. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15339. /* harmony import */ var _Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/gamepadCamera */ "./Cameras/gamepadCamera.ts");
  15340. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15341. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15342. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  15343. // Side effect import to define the stereoscopic mode.
  15344. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphGamepadCamera", function (name, scene, options) {
  15345. return function () { return new AnaglyphGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15346. });
  15347. /**
  15348. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  15349. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15350. */
  15351. var AnaglyphGamepadCamera = /** @class */ (function (_super) {
  15352. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphGamepadCamera, _super);
  15353. /**
  15354. * Creates a new AnaglyphGamepadCamera
  15355. * @param name defines camera name
  15356. * @param position defines initial position
  15357. * @param interaxialDistance defines distance between each color axis
  15358. * @param scene defines the hosting scene
  15359. */
  15360. function AnaglyphGamepadCamera(name, position, interaxialDistance, scene) {
  15361. var _this = _super.call(this, name, position, scene) || this;
  15362. _this.interaxialDistance = interaxialDistance;
  15363. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  15364. return _this;
  15365. }
  15366. /**
  15367. * Gets camera class name
  15368. * @returns AnaglyphGamepadCamera
  15369. */
  15370. AnaglyphGamepadCamera.prototype.getClassName = function () {
  15371. return "AnaglyphGamepadCamera";
  15372. };
  15373. return AnaglyphGamepadCamera;
  15374. }(_Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__["GamepadCamera"]));
  15375. /***/ }),
  15376. /***/ "./Cameras/Stereoscopic/anaglyphUniversalCamera.ts":
  15377. /*!*********************************************************!*\
  15378. !*** ./Cameras/Stereoscopic/anaglyphUniversalCamera.ts ***!
  15379. \*********************************************************/
  15380. /*! exports provided: AnaglyphUniversalCamera */
  15381. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15382. "use strict";
  15383. __webpack_require__.r(__webpack_exports__);
  15384. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return AnaglyphUniversalCamera; });
  15385. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15386. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15387. /* harmony import */ var _Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/universalCamera */ "./Cameras/universalCamera.ts");
  15388. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15389. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15390. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  15391. // Side effect import to define the stereoscopic mode.
  15392. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphUniversalCamera", function (name, scene, options) {
  15393. return function () { return new AnaglyphUniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15394. });
  15395. /**
  15396. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  15397. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15398. */
  15399. var AnaglyphUniversalCamera = /** @class */ (function (_super) {
  15400. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphUniversalCamera, _super);
  15401. /**
  15402. * Creates a new AnaglyphUniversalCamera
  15403. * @param name defines camera name
  15404. * @param position defines initial position
  15405. * @param interaxialDistance defines distance between each color axis
  15406. * @param scene defines the hosting scene
  15407. */
  15408. function AnaglyphUniversalCamera(name, position, interaxialDistance, scene) {
  15409. var _this = _super.call(this, name, position, scene) || this;
  15410. _this.interaxialDistance = interaxialDistance;
  15411. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  15412. return _this;
  15413. }
  15414. /**
  15415. * Gets camera class name
  15416. * @returns AnaglyphUniversalCamera
  15417. */
  15418. AnaglyphUniversalCamera.prototype.getClassName = function () {
  15419. return "AnaglyphUniversalCamera";
  15420. };
  15421. return AnaglyphUniversalCamera;
  15422. }(_Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__["UniversalCamera"]));
  15423. /***/ }),
  15424. /***/ "./Cameras/Stereoscopic/index.ts":
  15425. /*!***************************************!*\
  15426. !*** ./Cameras/Stereoscopic/index.ts ***!
  15427. \***************************************/
  15428. /*! exports provided: AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera */
  15429. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15430. "use strict";
  15431. __webpack_require__.r(__webpack_exports__);
  15432. /* harmony import */ var _anaglyphArcRotateCamera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./anaglyphArcRotateCamera */ "./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts");
  15433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _anaglyphArcRotateCamera__WEBPACK_IMPORTED_MODULE_0__["AnaglyphArcRotateCamera"]; });
  15434. /* harmony import */ var _anaglyphFreeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./anaglyphFreeCamera */ "./Cameras/Stereoscopic/anaglyphFreeCamera.ts");
  15435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _anaglyphFreeCamera__WEBPACK_IMPORTED_MODULE_1__["AnaglyphFreeCamera"]; });
  15436. /* harmony import */ var _anaglyphGamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./anaglyphGamepadCamera */ "./Cameras/Stereoscopic/anaglyphGamepadCamera.ts");
  15437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _anaglyphGamepadCamera__WEBPACK_IMPORTED_MODULE_2__["AnaglyphGamepadCamera"]; });
  15438. /* harmony import */ var _anaglyphUniversalCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./anaglyphUniversalCamera */ "./Cameras/Stereoscopic/anaglyphUniversalCamera.ts");
  15439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _anaglyphUniversalCamera__WEBPACK_IMPORTED_MODULE_3__["AnaglyphUniversalCamera"]; });
  15440. /* harmony import */ var _stereoscopicArcRotateCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./stereoscopicArcRotateCamera */ "./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts");
  15441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _stereoscopicArcRotateCamera__WEBPACK_IMPORTED_MODULE_4__["StereoscopicArcRotateCamera"]; });
  15442. /* harmony import */ var _stereoscopicFreeCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./stereoscopicFreeCamera */ "./Cameras/Stereoscopic/stereoscopicFreeCamera.ts");
  15443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _stereoscopicFreeCamera__WEBPACK_IMPORTED_MODULE_5__["StereoscopicFreeCamera"]; });
  15444. /* harmony import */ var _stereoscopicGamepadCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./stereoscopicGamepadCamera */ "./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts");
  15445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _stereoscopicGamepadCamera__WEBPACK_IMPORTED_MODULE_6__["StereoscopicGamepadCamera"]; });
  15446. /* harmony import */ var _stereoscopicUniversalCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./stereoscopicUniversalCamera */ "./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts");
  15447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _stereoscopicUniversalCamera__WEBPACK_IMPORTED_MODULE_7__["StereoscopicUniversalCamera"]; });
  15448. /***/ }),
  15449. /***/ "./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts":
  15450. /*!*************************************************************!*\
  15451. !*** ./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts ***!
  15452. \*************************************************************/
  15453. /*! exports provided: StereoscopicArcRotateCamera */
  15454. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15455. "use strict";
  15456. __webpack_require__.r(__webpack_exports__);
  15457. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return StereoscopicArcRotateCamera; });
  15458. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15459. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15460. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  15461. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15462. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15463. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15464. // Side effect import to define the stereoscopic mode.
  15465. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicArcRotateCamera", function (name, scene, options) {
  15466. return function () { return new StereoscopicArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15467. });
  15468. /**
  15469. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  15470. * @see http://doc.babylonjs.com/features/cameras
  15471. */
  15472. var StereoscopicArcRotateCamera = /** @class */ (function (_super) {
  15473. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicArcRotateCamera, _super);
  15474. /**
  15475. * Creates a new StereoscopicArcRotateCamera
  15476. * @param name defines camera name
  15477. * @param alpha defines alpha angle (in radians)
  15478. * @param beta defines beta angle (in radians)
  15479. * @param radius defines radius
  15480. * @param target defines camera target
  15481. * @param interaxialDistance defines distance between each color axis
  15482. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15483. * @param scene defines the hosting scene
  15484. */
  15485. function StereoscopicArcRotateCamera(name, alpha, beta, radius, target, interaxialDistance, isStereoscopicSideBySide, scene) {
  15486. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  15487. _this.interaxialDistance = interaxialDistance;
  15488. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15489. _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 });
  15490. return _this;
  15491. }
  15492. /**
  15493. * Gets camera class name
  15494. * @returns StereoscopicArcRotateCamera
  15495. */
  15496. StereoscopicArcRotateCamera.prototype.getClassName = function () {
  15497. return "StereoscopicArcRotateCamera";
  15498. };
  15499. return StereoscopicArcRotateCamera;
  15500. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  15501. /***/ }),
  15502. /***/ "./Cameras/Stereoscopic/stereoscopicFreeCamera.ts":
  15503. /*!********************************************************!*\
  15504. !*** ./Cameras/Stereoscopic/stereoscopicFreeCamera.ts ***!
  15505. \********************************************************/
  15506. /*! exports provided: StereoscopicFreeCamera */
  15507. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15508. "use strict";
  15509. __webpack_require__.r(__webpack_exports__);
  15510. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return StereoscopicFreeCamera; });
  15511. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15512. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15513. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  15514. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15515. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15516. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15517. // Side effect import to define the stereoscopic mode.
  15518. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicFreeCamera", function (name, scene, options) {
  15519. return function () { return new StereoscopicFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15520. });
  15521. /**
  15522. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  15523. * @see http://doc.babylonjs.com/features/cameras
  15524. */
  15525. var StereoscopicFreeCamera = /** @class */ (function (_super) {
  15526. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicFreeCamera, _super);
  15527. /**
  15528. * Creates a new StereoscopicFreeCamera
  15529. * @param name defines camera name
  15530. * @param position defines initial position
  15531. * @param interaxialDistance defines distance between each color axis
  15532. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15533. * @param scene defines the hosting scene
  15534. */
  15535. function StereoscopicFreeCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15536. var _this = _super.call(this, name, position, scene) || this;
  15537. _this.interaxialDistance = interaxialDistance;
  15538. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15539. _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 });
  15540. return _this;
  15541. }
  15542. /**
  15543. * Gets camera class name
  15544. * @returns StereoscopicFreeCamera
  15545. */
  15546. StereoscopicFreeCamera.prototype.getClassName = function () {
  15547. return "StereoscopicFreeCamera";
  15548. };
  15549. return StereoscopicFreeCamera;
  15550. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  15551. /***/ }),
  15552. /***/ "./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts":
  15553. /*!***********************************************************!*\
  15554. !*** ./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts ***!
  15555. \***********************************************************/
  15556. /*! exports provided: StereoscopicGamepadCamera */
  15557. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15558. "use strict";
  15559. __webpack_require__.r(__webpack_exports__);
  15560. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return StereoscopicGamepadCamera; });
  15561. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15562. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15563. /* harmony import */ var _Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/gamepadCamera */ "./Cameras/gamepadCamera.ts");
  15564. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15565. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15566. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15567. // Side effect import to define the stereoscopic mode.
  15568. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicGamepadCamera", function (name, scene, options) {
  15569. return function () { return new StereoscopicGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15570. });
  15571. /**
  15572. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  15573. * @see http://doc.babylonjs.com/features/cameras
  15574. */
  15575. var StereoscopicGamepadCamera = /** @class */ (function (_super) {
  15576. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicGamepadCamera, _super);
  15577. /**
  15578. * Creates a new StereoscopicGamepadCamera
  15579. * @param name defines camera name
  15580. * @param position defines initial position
  15581. * @param interaxialDistance defines distance between each color axis
  15582. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15583. * @param scene defines the hosting scene
  15584. */
  15585. function StereoscopicGamepadCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15586. var _this = _super.call(this, name, position, scene) || this;
  15587. _this.interaxialDistance = interaxialDistance;
  15588. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15589. _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 });
  15590. return _this;
  15591. }
  15592. /**
  15593. * Gets camera class name
  15594. * @returns StereoscopicGamepadCamera
  15595. */
  15596. StereoscopicGamepadCamera.prototype.getClassName = function () {
  15597. return "StereoscopicGamepadCamera";
  15598. };
  15599. return StereoscopicGamepadCamera;
  15600. }(_Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__["GamepadCamera"]));
  15601. /***/ }),
  15602. /***/ "./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts":
  15603. /*!*************************************************************!*\
  15604. !*** ./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts ***!
  15605. \*************************************************************/
  15606. /*! exports provided: StereoscopicUniversalCamera */
  15607. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15608. "use strict";
  15609. __webpack_require__.r(__webpack_exports__);
  15610. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return StereoscopicUniversalCamera; });
  15611. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15612. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15613. /* harmony import */ var _Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/universalCamera */ "./Cameras/universalCamera.ts");
  15614. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15615. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15616. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15617. // Side effect import to define the stereoscopic mode.
  15618. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicFreeCamera", function (name, scene, options) {
  15619. return function () { return new StereoscopicUniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15620. });
  15621. /**
  15622. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  15623. * @see http://doc.babylonjs.com/features/cameras
  15624. */
  15625. var StereoscopicUniversalCamera = /** @class */ (function (_super) {
  15626. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicUniversalCamera, _super);
  15627. /**
  15628. * Creates a new StereoscopicUniversalCamera
  15629. * @param name defines camera name
  15630. * @param position defines initial position
  15631. * @param interaxialDistance defines distance between each color axis
  15632. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15633. * @param scene defines the hosting scene
  15634. */
  15635. function StereoscopicUniversalCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15636. var _this = _super.call(this, name, position, scene) || this;
  15637. _this.interaxialDistance = interaxialDistance;
  15638. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15639. _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 });
  15640. return _this;
  15641. }
  15642. /**
  15643. * Gets camera class name
  15644. * @returns StereoscopicUniversalCamera
  15645. */
  15646. StereoscopicUniversalCamera.prototype.getClassName = function () {
  15647. return "StereoscopicUniversalCamera";
  15648. };
  15649. return StereoscopicUniversalCamera;
  15650. }(_Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__["UniversalCamera"]));
  15651. /***/ }),
  15652. /***/ "./Cameras/VR/index.ts":
  15653. /*!*****************************!*\
  15654. !*** ./Cameras/VR/index.ts ***!
  15655. \*****************************/
  15656. /*! exports provided: VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, OnAfterEnteringVRObservableEvent, VRExperienceHelper, WebVRFreeCamera */
  15657. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15658. "use strict";
  15659. __webpack_require__.r(__webpack_exports__);
  15660. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_0__["VRCameraMetrics"]; });
  15662. /* harmony import */ var _vrDeviceOrientationArcRotateCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./vrDeviceOrientationArcRotateCamera */ "./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts");
  15663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _vrDeviceOrientationArcRotateCamera__WEBPACK_IMPORTED_MODULE_1__["VRDeviceOrientationArcRotateCamera"]; });
  15664. /* harmony import */ var _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  15665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_2__["VRDeviceOrientationFreeCamera"]; });
  15666. /* harmony import */ var _vrDeviceOrientationGamepadCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrDeviceOrientationGamepadCamera */ "./Cameras/VR/vrDeviceOrientationGamepadCamera.ts");
  15667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _vrDeviceOrientationGamepadCamera__WEBPACK_IMPORTED_MODULE_3__["VRDeviceOrientationGamepadCamera"]; });
  15668. /* harmony import */ var _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./vrExperienceHelper */ "./Cameras/VR/vrExperienceHelper.ts");
  15669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__["OnAfterEnteringVRObservableEvent"]; });
  15670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__["VRExperienceHelper"]; });
  15671. /* harmony import */ var _webVRCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./webVRCamera */ "./Cameras/VR/webVRCamera.ts");
  15672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _webVRCamera__WEBPACK_IMPORTED_MODULE_5__["WebVRFreeCamera"]; });
  15673. /***/ }),
  15674. /***/ "./Cameras/VR/vrCameraMetrics.ts":
  15675. /*!***************************************!*\
  15676. !*** ./Cameras/VR/vrCameraMetrics.ts ***!
  15677. \***************************************/
  15678. /*! exports provided: VRCameraMetrics */
  15679. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15680. "use strict";
  15681. __webpack_require__.r(__webpack_exports__);
  15682. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return VRCameraMetrics; });
  15683. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15684. /**
  15685. * This represents all the required metrics to create a VR camera.
  15686. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  15687. */
  15688. var VRCameraMetrics = /** @class */ (function () {
  15689. function VRCameraMetrics() {
  15690. /**
  15691. * Define if the current vr camera should compensate the distortion of the lense or not.
  15692. */
  15693. this.compensateDistortion = true;
  15694. }
  15695. Object.defineProperty(VRCameraMetrics.prototype, "aspectRatio", {
  15696. /**
  15697. * Gets the rendering aspect ratio based on the provided resolutions.
  15698. */
  15699. get: function () {
  15700. return this.hResolution / (2 * this.vResolution);
  15701. },
  15702. enumerable: true,
  15703. configurable: true
  15704. });
  15705. Object.defineProperty(VRCameraMetrics.prototype, "aspectRatioFov", {
  15706. /**
  15707. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  15708. */
  15709. get: function () {
  15710. return (2 * Math.atan((this.postProcessScaleFactor * this.vScreenSize) / (2 * this.eyeToScreenDistance)));
  15711. },
  15712. enumerable: true,
  15713. configurable: true
  15714. });
  15715. Object.defineProperty(VRCameraMetrics.prototype, "leftHMatrix", {
  15716. /**
  15717. * @hidden
  15718. */
  15719. get: function () {
  15720. var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
  15721. var h = (4 * meters) / this.hScreenSize;
  15722. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(h, 0, 0);
  15723. },
  15724. enumerable: true,
  15725. configurable: true
  15726. });
  15727. Object.defineProperty(VRCameraMetrics.prototype, "rightHMatrix", {
  15728. /**
  15729. * @hidden
  15730. */
  15731. get: function () {
  15732. var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
  15733. var h = (4 * meters) / this.hScreenSize;
  15734. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(-h, 0, 0);
  15735. },
  15736. enumerable: true,
  15737. configurable: true
  15738. });
  15739. Object.defineProperty(VRCameraMetrics.prototype, "leftPreViewMatrix", {
  15740. /**
  15741. * @hidden
  15742. */
  15743. get: function () {
  15744. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(0.5 * this.interpupillaryDistance, 0, 0);
  15745. },
  15746. enumerable: true,
  15747. configurable: true
  15748. });
  15749. Object.defineProperty(VRCameraMetrics.prototype, "rightPreViewMatrix", {
  15750. /**
  15751. * @hidden
  15752. */
  15753. get: function () {
  15754. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(-0.5 * this.interpupillaryDistance, 0, 0);
  15755. },
  15756. enumerable: true,
  15757. configurable: true
  15758. });
  15759. /**
  15760. * Get the default VRMetrics based on the most generic setup.
  15761. * @returns the default vr metrics
  15762. */
  15763. VRCameraMetrics.GetDefault = function () {
  15764. var result = new VRCameraMetrics();
  15765. result.hResolution = 1280;
  15766. result.vResolution = 800;
  15767. result.hScreenSize = 0.149759993;
  15768. result.vScreenSize = 0.0935999975;
  15769. result.vScreenCenter = 0.0467999987;
  15770. result.eyeToScreenDistance = 0.0410000011;
  15771. result.lensSeparationDistance = 0.0635000020;
  15772. result.interpupillaryDistance = 0.0640000030;
  15773. result.distortionK = [1.0, 0.219999999, 0.239999995, 0.0];
  15774. result.chromaAbCorrection = [0.995999992, -0.00400000019, 1.01400006, 0.0];
  15775. result.postProcessScaleFactor = 1.714605507808412;
  15776. result.lensCenterOffset = 0.151976421;
  15777. return result;
  15778. };
  15779. return VRCameraMetrics;
  15780. }());
  15781. /***/ }),
  15782. /***/ "./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts":
  15783. /*!**********************************************************!*\
  15784. !*** ./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts ***!
  15785. \**********************************************************/
  15786. /*! exports provided: VRDeviceOrientationArcRotateCamera */
  15787. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15788. "use strict";
  15789. __webpack_require__.r(__webpack_exports__);
  15790. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return VRDeviceOrientationArcRotateCamera; });
  15791. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15792. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15793. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  15794. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15795. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15796. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15797. /* harmony import */ var _Inputs_arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Inputs/arcRotateCameraVRDeviceOrientationInput */ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts");
  15798. /* harmony import */ var _RigModes_vrRigMode__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../RigModes/vrRigMode */ "./Cameras/RigModes/vrRigMode.ts");
  15799. // Side effect import to define the stereoscopic mode.
  15800. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("VRDeviceOrientationFreeCamera", function (name, scene) {
  15801. return function () { return new VRDeviceOrientationArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  15802. });
  15803. /**
  15804. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  15805. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  15806. */
  15807. var VRDeviceOrientationArcRotateCamera = /** @class */ (function (_super) {
  15808. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationArcRotateCamera, _super);
  15809. /**
  15810. * Creates a new VRDeviceOrientationArcRotateCamera
  15811. * @param name defines camera name
  15812. * @param alpha defines the camera rotation along the logitudinal axis
  15813. * @param beta defines the camera rotation along the latitudinal axis
  15814. * @param radius defines the camera distance from its target
  15815. * @param target defines the camera target
  15816. * @param scene defines the scene the camera belongs to
  15817. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  15818. * @param vrCameraMetrics defines the vr metrics associated to the camera
  15819. */
  15820. function VRDeviceOrientationArcRotateCamera(name, alpha, beta, radius, target, scene, compensateDistortion, vrCameraMetrics) {
  15821. if (compensateDistortion === void 0) { compensateDistortion = true; }
  15822. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault(); }
  15823. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  15824. vrCameraMetrics.compensateDistortion = compensateDistortion;
  15825. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_VR, { vrCameraMetrics: vrCameraMetrics });
  15826. _this.inputs.addVRDeviceOrientation();
  15827. return _this;
  15828. }
  15829. /**
  15830. * Gets camera class name
  15831. * @returns VRDeviceOrientationArcRotateCamera
  15832. */
  15833. VRDeviceOrientationArcRotateCamera.prototype.getClassName = function () {
  15834. return "VRDeviceOrientationArcRotateCamera";
  15835. };
  15836. return VRDeviceOrientationArcRotateCamera;
  15837. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  15838. /***/ }),
  15839. /***/ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts":
  15840. /*!*****************************************************!*\
  15841. !*** ./Cameras/VR/vrDeviceOrientationFreeCamera.ts ***!
  15842. \*****************************************************/
  15843. /*! exports provided: VRDeviceOrientationFreeCamera */
  15844. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15845. "use strict";
  15846. __webpack_require__.r(__webpack_exports__);
  15847. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return VRDeviceOrientationFreeCamera; });
  15848. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15849. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15850. /* harmony import */ var _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  15851. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15852. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15853. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15854. /* harmony import */ var _RigModes_vrRigMode__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../RigModes/vrRigMode */ "./Cameras/RigModes/vrRigMode.ts");
  15855. // Side effect import to define the stereoscopic mode.
  15856. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("VRDeviceOrientationFreeCamera", function (name, scene) {
  15857. return function () { return new VRDeviceOrientationFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  15858. });
  15859. /**
  15860. * Camera used to simulate VR rendering (based on FreeCamera)
  15861. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  15862. */
  15863. var VRDeviceOrientationFreeCamera = /** @class */ (function (_super) {
  15864. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationFreeCamera, _super);
  15865. /**
  15866. * Creates a new VRDeviceOrientationFreeCamera
  15867. * @param name defines camera name
  15868. * @param position defines the start position of the camera
  15869. * @param scene defines the scene the camera belongs to
  15870. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  15871. * @param vrCameraMetrics defines the vr metrics associated to the camera
  15872. */
  15873. function VRDeviceOrientationFreeCamera(name, position, scene, compensateDistortion, vrCameraMetrics) {
  15874. if (compensateDistortion === void 0) { compensateDistortion = true; }
  15875. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault(); }
  15876. var _this = _super.call(this, name, position, scene) || this;
  15877. vrCameraMetrics.compensateDistortion = compensateDistortion;
  15878. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_VR, { vrCameraMetrics: vrCameraMetrics });
  15879. return _this;
  15880. }
  15881. /**
  15882. * Gets camera class name
  15883. * @returns VRDeviceOrientationFreeCamera
  15884. */
  15885. VRDeviceOrientationFreeCamera.prototype.getClassName = function () {
  15886. return "VRDeviceOrientationFreeCamera";
  15887. };
  15888. return VRDeviceOrientationFreeCamera;
  15889. }(_Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_2__["DeviceOrientationCamera"]));
  15890. /***/ }),
  15891. /***/ "./Cameras/VR/vrDeviceOrientationGamepadCamera.ts":
  15892. /*!********************************************************!*\
  15893. !*** ./Cameras/VR/vrDeviceOrientationGamepadCamera.ts ***!
  15894. \********************************************************/
  15895. /*! exports provided: VRDeviceOrientationGamepadCamera */
  15896. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15897. "use strict";
  15898. __webpack_require__.r(__webpack_exports__);
  15899. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return VRDeviceOrientationGamepadCamera; });
  15900. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15901. /* harmony import */ var _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  15902. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15903. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15904. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15905. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("VRDeviceOrientationGamepadCamera", function (name, scene) {
  15906. return function () { return new VRDeviceOrientationGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  15907. });
  15908. /**
  15909. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  15910. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  15911. */
  15912. var VRDeviceOrientationGamepadCamera = /** @class */ (function (_super) {
  15913. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationGamepadCamera, _super);
  15914. /**
  15915. * Creates a new VRDeviceOrientationGamepadCamera
  15916. * @param name defines camera name
  15917. * @param position defines the start position of the camera
  15918. * @param scene defines the scene the camera belongs to
  15919. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  15920. * @param vrCameraMetrics defines the vr metrics associated to the camera
  15921. */
  15922. function VRDeviceOrientationGamepadCamera(name, position, scene, compensateDistortion, vrCameraMetrics) {
  15923. if (compensateDistortion === void 0) { compensateDistortion = true; }
  15924. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_2__["VRCameraMetrics"].GetDefault(); }
  15925. var _this = _super.call(this, name, position, scene, compensateDistortion, vrCameraMetrics) || this;
  15926. _this.inputs.addGamepad();
  15927. return _this;
  15928. }
  15929. /**
  15930. * Gets camera class name
  15931. * @returns VRDeviceOrientationGamepadCamera
  15932. */
  15933. VRDeviceOrientationGamepadCamera.prototype.getClassName = function () {
  15934. return "VRDeviceOrientationGamepadCamera";
  15935. };
  15936. return VRDeviceOrientationGamepadCamera;
  15937. }(_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_1__["VRDeviceOrientationFreeCamera"]));
  15938. /***/ }),
  15939. /***/ "./Cameras/VR/vrExperienceHelper.ts":
  15940. /*!******************************************!*\
  15941. !*** ./Cameras/VR/vrExperienceHelper.ts ***!
  15942. \******************************************/
  15943. /*! exports provided: OnAfterEnteringVRObservableEvent, VRExperienceHelper */
  15944. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15945. "use strict";
  15946. __webpack_require__.r(__webpack_exports__);
  15947. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return OnAfterEnteringVRObservableEvent; });
  15948. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return VRExperienceHelper; });
  15949. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15950. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  15951. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  15952. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  15953. /* harmony import */ var _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Cameras/targetCamera */ "./Cameras/targetCamera.ts");
  15954. /* harmony import */ var _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Cameras/deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  15955. /* harmony import */ var _Cameras_VR_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Cameras/VR/vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  15956. /* harmony import */ var _Cameras_VR_webVRCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Cameras/VR/webVRCamera */ "./Cameras/VR/webVRCamera.ts");
  15957. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  15958. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15959. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  15960. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  15961. /* harmony import */ var _Gamepads_Controllers_webVRController__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Gamepads/Controllers/webVRController */ "./Gamepads/Controllers/webVRController.ts");
  15962. /* harmony import */ var _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Gamepads/xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  15963. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  15964. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  15965. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  15966. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  15967. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  15968. /* harmony import */ var _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../PostProcesses/imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  15969. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  15970. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  15971. /* harmony import */ var _Meshes_Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../../Meshes/Builders/groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  15972. /* harmony import */ var _Meshes_Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../../Meshes/Builders/torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  15973. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ../../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  15974. /* harmony import */ var _Gamepads_gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ../../Gamepads/gamepadSceneComponent */ "./Gamepads/gamepadSceneComponent.ts");
  15975. /* harmony import */ var _Animations_animatable__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ../../Animations/animatable */ "./Animations/animatable.ts");
  15976. var VRExperienceHelperGazer = /** @class */ (function () {
  15977. function VRExperienceHelperGazer(scene, gazeTrackerToClone) {
  15978. if (gazeTrackerToClone === void 0) { gazeTrackerToClone = null; }
  15979. this.scene = scene;
  15980. /** @hidden */
  15981. this._pointerDownOnMeshAsked = false;
  15982. /** @hidden */
  15983. this._isActionableMesh = false;
  15984. /** @hidden */
  15985. this._teleportationRequestInitiated = false;
  15986. /** @hidden */
  15987. this._teleportationBackRequestInitiated = false;
  15988. /** @hidden */
  15989. this._rotationRightAsked = false;
  15990. /** @hidden */
  15991. this._rotationLeftAsked = false;
  15992. /** @hidden */
  15993. this._dpadPressed = true;
  15994. /** @hidden */
  15995. this._activePointer = false;
  15996. this._id = VRExperienceHelperGazer._idCounter++;
  15997. // Gaze tracker
  15998. if (!gazeTrackerToClone) {
  15999. this._gazeTracker = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateTorus("gazeTracker", 0.0035, 0.0025, 20, scene, false);
  16000. this._gazeTracker.bakeCurrentTransformIntoVertices();
  16001. this._gazeTracker.isPickable = false;
  16002. this._gazeTracker.isVisible = false;
  16003. var targetMat = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("targetMat", scene);
  16004. targetMat.specularColor = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"].Black();
  16005. targetMat.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7);
  16006. targetMat.backFaceCulling = false;
  16007. this._gazeTracker.material = targetMat;
  16008. }
  16009. else {
  16010. this._gazeTracker = gazeTrackerToClone.clone("gazeTracker");
  16011. }
  16012. }
  16013. /** @hidden */
  16014. VRExperienceHelperGazer.prototype._getForwardRay = function (length) {
  16015. 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));
  16016. };
  16017. /** @hidden */
  16018. VRExperienceHelperGazer.prototype._selectionPointerDown = function () {
  16019. this._pointerDownOnMeshAsked = true;
  16020. if (this._currentHit) {
  16021. this.scene.simulatePointerDown(this._currentHit, { pointerId: this._id });
  16022. }
  16023. };
  16024. /** @hidden */
  16025. VRExperienceHelperGazer.prototype._selectionPointerUp = function () {
  16026. if (this._currentHit) {
  16027. this.scene.simulatePointerUp(this._currentHit, { pointerId: this._id });
  16028. }
  16029. this._pointerDownOnMeshAsked = false;
  16030. };
  16031. /** @hidden */
  16032. VRExperienceHelperGazer.prototype._activatePointer = function () {
  16033. this._activePointer = true;
  16034. };
  16035. /** @hidden */
  16036. VRExperienceHelperGazer.prototype._deactivatePointer = function () {
  16037. this._activePointer = false;
  16038. };
  16039. /** @hidden */
  16040. VRExperienceHelperGazer.prototype._updatePointerDistance = function (distance) {
  16041. if (distance === void 0) { distance = 100; }
  16042. };
  16043. VRExperienceHelperGazer.prototype.dispose = function () {
  16044. this._interactionsEnabled = false;
  16045. this._teleportationEnabled = false;
  16046. if (this._gazeTracker) {
  16047. this._gazeTracker.dispose();
  16048. }
  16049. };
  16050. VRExperienceHelperGazer._idCounter = 0;
  16051. return VRExperienceHelperGazer;
  16052. }());
  16053. var VRExperienceHelperControllerGazer = /** @class */ (function (_super) {
  16054. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRExperienceHelperControllerGazer, _super);
  16055. function VRExperienceHelperControllerGazer(webVRController, scene, gazeTrackerToClone) {
  16056. var _this = _super.call(this, scene, gazeTrackerToClone) || this;
  16057. _this.webVRController = webVRController;
  16058. // Laser pointer
  16059. _this._laserPointer = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateCylinder("laserPointer", 1, 0.004, 0.0002, 20, 1, scene, false);
  16060. var laserPointerMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("laserPointerMat", scene);
  16061. laserPointerMaterial.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7);
  16062. laserPointerMaterial.alpha = 0.6;
  16063. _this._laserPointer.material = laserPointerMaterial;
  16064. _this._laserPointer.rotation.x = Math.PI / 2;
  16065. _this._laserPointer.position.z = -0.5;
  16066. _this._laserPointer.isVisible = false;
  16067. _this._laserPointer.isPickable = false;
  16068. if (!webVRController.mesh) {
  16069. // Create an empty mesh that is used prior to loading the high quality model
  16070. var preloadMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"]("preloadControllerMesh", scene);
  16071. var preloadPointerPose = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"](_Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledController"].POINTING_POSE, scene);
  16072. preloadPointerPose.rotation.x = -0.7;
  16073. preloadMesh.addChild(preloadPointerPose);
  16074. webVRController.attachToMesh(preloadMesh);
  16075. }
  16076. _this._setLaserPointerParent(webVRController.mesh);
  16077. _this._meshAttachedObserver = webVRController._meshAttachedObservable.add(function (mesh) {
  16078. _this._setLaserPointerParent(mesh);
  16079. });
  16080. return _this;
  16081. }
  16082. VRExperienceHelperControllerGazer.prototype._getForwardRay = function (length) {
  16083. return this.webVRController.getForwardRay(length);
  16084. };
  16085. /** @hidden */
  16086. VRExperienceHelperControllerGazer.prototype._activatePointer = function () {
  16087. _super.prototype._activatePointer.call(this);
  16088. this._laserPointer.isVisible = true;
  16089. };
  16090. /** @hidden */
  16091. VRExperienceHelperControllerGazer.prototype._deactivatePointer = function () {
  16092. _super.prototype._deactivatePointer.call(this);
  16093. this._laserPointer.isVisible = false;
  16094. };
  16095. /** @hidden */
  16096. VRExperienceHelperControllerGazer.prototype._setLaserPointerColor = function (color) {
  16097. this._laserPointer.material.emissiveColor = color;
  16098. };
  16099. /** @hidden */
  16100. VRExperienceHelperControllerGazer.prototype._setLaserPointerParent = function (mesh) {
  16101. var makeNotPick = function (root) {
  16102. root.isPickable = false;
  16103. root.getChildMeshes().forEach(function (c) {
  16104. makeNotPick(c);
  16105. });
  16106. };
  16107. makeNotPick(mesh);
  16108. var meshChildren = mesh.getChildren(undefined, false);
  16109. var laserParent = mesh;
  16110. this.webVRController._pointingPoseNode = null;
  16111. for (var i = 0; i < meshChildren.length; i++) {
  16112. if (meshChildren[i].name && meshChildren[i].name.indexOf(_Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledController"].POINTING_POSE) >= 0) {
  16113. laserParent = meshChildren[i];
  16114. this.webVRController._pointingPoseNode = laserParent;
  16115. break;
  16116. }
  16117. }
  16118. this._laserPointer.parent = laserParent;
  16119. };
  16120. VRExperienceHelperControllerGazer.prototype._updatePointerDistance = function (distance) {
  16121. if (distance === void 0) { distance = 100; }
  16122. this._laserPointer.scaling.y = distance;
  16123. this._laserPointer.position.z = -distance / 2;
  16124. };
  16125. VRExperienceHelperControllerGazer.prototype.dispose = function () {
  16126. _super.prototype.dispose.call(this);
  16127. this._laserPointer.dispose();
  16128. if (this._meshAttachedObserver) {
  16129. this.webVRController._meshAttachedObservable.remove(this._meshAttachedObserver);
  16130. }
  16131. };
  16132. return VRExperienceHelperControllerGazer;
  16133. }(VRExperienceHelperGazer));
  16134. var VRExperienceHelperCameraGazer = /** @class */ (function (_super) {
  16135. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRExperienceHelperCameraGazer, _super);
  16136. function VRExperienceHelperCameraGazer(getCamera, scene) {
  16137. var _this = _super.call(this, scene) || this;
  16138. _this.getCamera = getCamera;
  16139. return _this;
  16140. }
  16141. VRExperienceHelperCameraGazer.prototype._getForwardRay = function (length) {
  16142. var camera = this.getCamera();
  16143. if (camera) {
  16144. return camera.getForwardRay(length);
  16145. }
  16146. else {
  16147. 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());
  16148. }
  16149. };
  16150. return VRExperienceHelperCameraGazer;
  16151. }(VRExperienceHelperGazer));
  16152. /**
  16153. * Event containing information after VR has been entered
  16154. */
  16155. var OnAfterEnteringVRObservableEvent = /** @class */ (function () {
  16156. function OnAfterEnteringVRObservableEvent() {
  16157. }
  16158. return OnAfterEnteringVRObservableEvent;
  16159. }());
  16160. /**
  16161. * Helps to quickly add VR support to an existing scene.
  16162. * See http://doc.babylonjs.com/how_to/webvr_helper
  16163. */
  16164. var VRExperienceHelper = /** @class */ (function () {
  16165. /**
  16166. * Instantiates a VRExperienceHelper.
  16167. * Helps to quickly add VR support to an existing scene.
  16168. * @param scene The scene the VRExperienceHelper belongs to.
  16169. * @param webVROptions Options to modify the vr experience helper's behavior.
  16170. */
  16171. function VRExperienceHelper(scene,
  16172. /** Options to modify the vr experience helper's behavior. */
  16173. webVROptions) {
  16174. if (webVROptions === void 0) { webVROptions = {}; }
  16175. var _this = this;
  16176. this.webVROptions = webVROptions;
  16177. // Can the system support WebVR, even if a headset isn't plugged in?
  16178. this._webVRsupported = false;
  16179. // If WebVR is supported, is a headset plugged in and are we ready to present?
  16180. this._webVRready = false;
  16181. // Are we waiting for the requestPresent callback to complete?
  16182. this._webVRrequesting = false;
  16183. // Are we presenting to the headset right now? (this is the vrDevice state)
  16184. this._webVRpresenting = false;
  16185. // Are we presenting in the fullscreen fallback?
  16186. this._fullscreenVRpresenting = false;
  16187. /**
  16188. * Observable raised right before entering VR.
  16189. */
  16190. this.onEnteringVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16191. /**
  16192. * Observable raised when entering VR has completed.
  16193. */
  16194. this.onAfterEnteringVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16195. /**
  16196. * Observable raised when exiting VR.
  16197. */
  16198. this.onExitingVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16199. /**
  16200. * Observable raised when controller mesh is loaded.
  16201. */
  16202. this.onControllerMeshLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16203. this._useCustomVRButton = false;
  16204. this._teleportationRequested = false;
  16205. this._teleportActive = false;
  16206. this._floorMeshesCollection = [];
  16207. this._rotationAllowed = true;
  16208. this._teleportBackwardsVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, -1, -1);
  16209. this._isDefaultTeleportationTarget = true;
  16210. this._teleportationFillColor = "#444444";
  16211. this._teleportationBorderColor = "#FFFFFF";
  16212. this._rotationAngle = 0;
  16213. this._haloCenter = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, 0, 0);
  16214. this._padSensibilityUp = 0.65;
  16215. this._padSensibilityDown = 0.35;
  16216. this._leftController = null;
  16217. this._rightController = null;
  16218. /**
  16219. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  16220. */
  16221. this.onNewMeshSelected = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16222. /**
  16223. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  16224. */
  16225. this.onNewMeshPicked = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16226. /**
  16227. * Observable raised before camera teleportation
  16228. */
  16229. this.onBeforeCameraTeleport = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16230. /**
  16231. * Observable raised after camera teleportation
  16232. */
  16233. this.onAfterCameraTeleport = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16234. /**
  16235. * Observable raised when current selected mesh gets unselected
  16236. */
  16237. this.onSelectedMeshUnselected = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16238. /**
  16239. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  16240. */
  16241. this.teleportationEnabled = true;
  16242. this._teleportationInitialized = false;
  16243. this._interactionsEnabled = false;
  16244. this._interactionsRequested = false;
  16245. this._displayGaze = true;
  16246. this._displayLaserPointer = true;
  16247. /**
  16248. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  16249. */
  16250. this.updateGazeTrackerScale = true;
  16251. /**
  16252. * If the gaze trackers color should be updated when selecting meshes
  16253. */
  16254. this.updateGazeTrackerColor = true;
  16255. /**
  16256. * Defines wether or not Pointer lock should be requested when switching to
  16257. * full screen.
  16258. */
  16259. this.requestPointerLockOnFullScreen = true;
  16260. this._onResize = function () {
  16261. _this.moveButtonToBottomRight();
  16262. if (_this._fullscreenVRpresenting && _this._webVRready) {
  16263. _this.exitVR();
  16264. }
  16265. };
  16266. this._onFullscreenChange = function () {
  16267. if (document.fullscreen !== undefined) {
  16268. _this._fullscreenVRpresenting = document.fullscreen;
  16269. }
  16270. else if (document.mozFullScreen !== undefined) {
  16271. _this._fullscreenVRpresenting = document.mozFullScreen;
  16272. }
  16273. else if (document.webkitIsFullScreen !== undefined) {
  16274. _this._fullscreenVRpresenting = document.webkitIsFullScreen;
  16275. }
  16276. else if (document.msIsFullScreen !== undefined) {
  16277. _this._fullscreenVRpresenting = document.msIsFullScreen;
  16278. }
  16279. else if (document.msFullscreenElement !== undefined) {
  16280. _this._fullscreenVRpresenting = document.msFullscreenElement;
  16281. }
  16282. if (!_this._fullscreenVRpresenting && _this._canvas) {
  16283. _this.exitVR();
  16284. if (!_this._useCustomVRButton) {
  16285. _this._btnVR.style.top = _this._canvas.offsetTop + _this._canvas.offsetHeight - 70 + "px";
  16286. _this._btnVR.style.left = _this._canvas.offsetLeft + _this._canvas.offsetWidth - 100 + "px";
  16287. }
  16288. }
  16289. };
  16290. this._cachedAngularSensibility = { angularSensibilityX: null, angularSensibilityY: null, angularSensibility: null };
  16291. this.beforeRender = function () {
  16292. if (_this._leftController && _this._leftController._activePointer) {
  16293. _this._castRayAndSelectObject(_this._leftController);
  16294. }
  16295. if (_this._rightController && _this._rightController._activePointer) {
  16296. _this._castRayAndSelectObject(_this._rightController);
  16297. }
  16298. if (_this._noControllerIsActive) {
  16299. _this._castRayAndSelectObject(_this._cameraGazer);
  16300. }
  16301. else {
  16302. _this._cameraGazer._gazeTracker.isVisible = false;
  16303. }
  16304. };
  16305. this._onNewGamepadConnected = function (gamepad) {
  16306. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__["Gamepad"].POSE_ENABLED) {
  16307. if (gamepad.leftStick) {
  16308. gamepad.onleftstickchanged(function (stickValues) {
  16309. if (_this._teleportationInitialized && _this.teleportationEnabled) {
  16310. // Listening to classic/xbox gamepad only if no VR controller is active
  16311. if ((!_this._leftController && !_this._rightController) ||
  16312. ((_this._leftController && !_this._leftController._activePointer) &&
  16313. (_this._rightController && !_this._rightController._activePointer))) {
  16314. _this._checkTeleportWithRay(stickValues, _this._cameraGazer);
  16315. _this._checkTeleportBackwards(stickValues, _this._cameraGazer);
  16316. }
  16317. }
  16318. });
  16319. }
  16320. if (gamepad.rightStick) {
  16321. gamepad.onrightstickchanged(function (stickValues) {
  16322. if (_this._teleportationInitialized) {
  16323. _this._checkRotate(stickValues, _this._cameraGazer);
  16324. }
  16325. });
  16326. }
  16327. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__["Gamepad"].XBOX) {
  16328. gamepad.onbuttondown(function (buttonPressed) {
  16329. if (_this._interactionsEnabled && buttonPressed === _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"].A) {
  16330. _this._cameraGazer._selectionPointerDown();
  16331. }
  16332. });
  16333. gamepad.onbuttonup(function (buttonPressed) {
  16334. if (_this._interactionsEnabled && buttonPressed === _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"].A) {
  16335. _this._cameraGazer._selectionPointerUp();
  16336. }
  16337. });
  16338. }
  16339. }
  16340. else {
  16341. var webVRController = gamepad;
  16342. var controller = new VRExperienceHelperControllerGazer(webVRController, _this._scene, _this._cameraGazer._gazeTracker);
  16343. if (webVRController.hand === "right" || (_this._leftController && _this._leftController.webVRController != webVRController)) {
  16344. _this._rightController = controller;
  16345. }
  16346. else {
  16347. _this._leftController = controller;
  16348. }
  16349. _this._tryEnableInteractionOnController(controller);
  16350. }
  16351. };
  16352. // 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
  16353. this._tryEnableInteractionOnController = function (controller) {
  16354. if (_this._interactionsRequested && !controller._interactionsEnabled) {
  16355. _this._enableInteractionOnController(controller);
  16356. }
  16357. if (_this._teleportationRequested && !controller._teleportationEnabled) {
  16358. _this._enableTeleportationOnController(controller);
  16359. }
  16360. };
  16361. this._onNewGamepadDisconnected = function (gamepad) {
  16362. if (gamepad instanceof _Gamepads_Controllers_webVRController__WEBPACK_IMPORTED_MODULE_12__["WebVRController"]) {
  16363. if (gamepad.hand === "left" && _this._leftController != null) {
  16364. _this._leftController.dispose();
  16365. _this._leftController = null;
  16366. }
  16367. if (gamepad.hand === "right" && _this._rightController != null) {
  16368. _this._rightController.dispose();
  16369. _this._rightController = null;
  16370. }
  16371. }
  16372. };
  16373. this._workingVector = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Zero();
  16374. this._workingQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].Identity();
  16375. this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Matrix"].Identity();
  16376. this._scene = scene;
  16377. this._canvas = scene.getEngine().getRenderingCanvas();
  16378. // Parse options
  16379. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera === undefined) {
  16380. webVROptions.createFallbackVRDeviceOrientationFreeCamera = true;
  16381. }
  16382. if (webVROptions.createDeviceOrientationCamera === undefined) {
  16383. webVROptions.createDeviceOrientationCamera = true;
  16384. }
  16385. if (webVROptions.laserToggle === undefined) {
  16386. webVROptions.laserToggle = true;
  16387. }
  16388. if (webVROptions.defaultHeight === undefined) {
  16389. webVROptions.defaultHeight = 1.7;
  16390. }
  16391. if (webVROptions.useCustomVRButton) {
  16392. this._useCustomVRButton = true;
  16393. if (webVROptions.customVRButton) {
  16394. this._btnVR = webVROptions.customVRButton;
  16395. }
  16396. }
  16397. if (webVROptions.rayLength) {
  16398. this._rayLength = webVROptions.rayLength;
  16399. }
  16400. this._defaultHeight = webVROptions.defaultHeight;
  16401. if (webVROptions.positionScale) {
  16402. this._rayLength *= webVROptions.positionScale;
  16403. this._defaultHeight *= webVROptions.positionScale;
  16404. }
  16405. this._hasEnteredVR = false;
  16406. // Set position
  16407. if (this._scene.activeCamera) {
  16408. this._position = this._scene.activeCamera.position.clone();
  16409. }
  16410. else {
  16411. this._position = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, this._defaultHeight, 0);
  16412. }
  16413. // Set non-vr camera
  16414. if (webVROptions.createDeviceOrientationCamera || !this._scene.activeCamera) {
  16415. this._deviceOrientationCamera = new _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_5__["DeviceOrientationCamera"]("deviceOrientationVRHelper", this._position.clone(), scene);
  16416. // Copy data from existing camera
  16417. if (this._scene.activeCamera) {
  16418. this._deviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
  16419. this._deviceOrientationCamera.maxZ = this._scene.activeCamera.maxZ;
  16420. // Set rotation from previous camera
  16421. if (this._scene.activeCamera instanceof _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"] && this._scene.activeCamera.rotation) {
  16422. var targetCamera = this._scene.activeCamera;
  16423. if (targetCamera.rotationQuaternion) {
  16424. this._deviceOrientationCamera.rotationQuaternion.copyFrom(targetCamera.rotationQuaternion);
  16425. }
  16426. else {
  16427. this._deviceOrientationCamera.rotationQuaternion.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].RotationYawPitchRoll(targetCamera.rotation.y, targetCamera.rotation.x, targetCamera.rotation.z));
  16428. }
  16429. this._deviceOrientationCamera.rotation = targetCamera.rotation.clone();
  16430. }
  16431. }
  16432. this._scene.activeCamera = this._deviceOrientationCamera;
  16433. if (this._canvas) {
  16434. this._scene.activeCamera.attachControl(this._canvas);
  16435. }
  16436. }
  16437. else {
  16438. this._existingCamera = this._scene.activeCamera;
  16439. }
  16440. // Create VR cameras
  16441. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera) {
  16442. this._vrDeviceOrientationCamera = new _Cameras_VR_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_6__["VRDeviceOrientationFreeCamera"]("VRDeviceOrientationVRHelper", this._position, this._scene, true, webVROptions.vrDeviceOrientationCameraMetrics);
  16443. this._vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE;
  16444. }
  16445. this._webVRCamera = new _Cameras_VR_webVRCamera__WEBPACK_IMPORTED_MODULE_7__["WebVRFreeCamera"]("WebVRHelper", this._position, this._scene, webVROptions);
  16446. this._webVRCamera.useStandingMatrix();
  16447. this._cameraGazer = new VRExperienceHelperCameraGazer(function () { return _this.currentVRCamera; }, scene);
  16448. // Create default button
  16449. if (!this._useCustomVRButton) {
  16450. this._btnVR = document.createElement("BUTTON");
  16451. this._btnVR.className = "babylonVRicon";
  16452. this._btnVR.id = "babylonVRiconbtn";
  16453. this._btnVR.title = "Click to switch to VR";
  16454. 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) }";
  16455. css += ".babylonVRicon.vrdisplaypresenting { display: none; }";
  16456. // TODO: Add user feedback so that they know what state the VRDisplay is in (disconnected, connected, entering-VR)
  16457. // css += ".babylonVRicon.vrdisplaysupported { }";
  16458. // css += ".babylonVRicon.vrdisplayready { }";
  16459. // css += ".babylonVRicon.vrdisplayrequesting { }";
  16460. var style = document.createElement('style');
  16461. style.appendChild(document.createTextNode(css));
  16462. document.getElementsByTagName('head')[0].appendChild(style);
  16463. this.moveButtonToBottomRight();
  16464. }
  16465. // VR button click event
  16466. if (this._btnVR) {
  16467. this._btnVR.addEventListener("click", function () {
  16468. if (!_this.isInVRMode) {
  16469. _this.enterVR();
  16470. }
  16471. else {
  16472. _this.exitVR();
  16473. }
  16474. });
  16475. }
  16476. // Window events
  16477. window.addEventListener("resize", this._onResize);
  16478. document.addEventListener("fullscreenchange", this._onFullscreenChange, false);
  16479. document.addEventListener("mozfullscreenchange", this._onFullscreenChange, false);
  16480. document.addEventListener("webkitfullscreenchange", this._onFullscreenChange, false);
  16481. document.addEventListener("msfullscreenchange", this._onFullscreenChange, false);
  16482. document.onmsfullscreenchange = this._onFullscreenChange;
  16483. // Display vr button when headset is connected
  16484. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera) {
  16485. this.displayVRButton();
  16486. }
  16487. else {
  16488. this._scene.getEngine().onVRDisplayChangedObservable.add(function (e) {
  16489. if (e.vrDisplay) {
  16490. _this.displayVRButton();
  16491. }
  16492. });
  16493. }
  16494. // Exiting VR mode using 'ESC' key on desktop
  16495. this._onKeyDown = function (event) {
  16496. if (event.keyCode === 27 && _this.isInVRMode) {
  16497. _this.exitVR();
  16498. }
  16499. };
  16500. document.addEventListener("keydown", this._onKeyDown);
  16501. // Exiting VR mode double tapping the touch screen
  16502. this._scene.onPrePointerObservable.add(function () {
  16503. if (_this.isInVRMode) {
  16504. _this.exitVR();
  16505. if (_this._fullscreenVRpresenting) {
  16506. _this._scene.getEngine().exitFullscreen();
  16507. }
  16508. }
  16509. }, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_8__["PointerEventTypes"].POINTERDOUBLETAP, false);
  16510. // Listen for WebVR display changes
  16511. this._onVRDisplayChanged = function (eventArgs) { return _this.onVRDisplayChanged(eventArgs); };
  16512. this._onVrDisplayPresentChange = function () { return _this.onVrDisplayPresentChange(); };
  16513. this._onVRRequestPresentStart = function () {
  16514. _this._webVRrequesting = true;
  16515. _this.updateButtonVisibility();
  16516. };
  16517. this._onVRRequestPresentComplete = function () {
  16518. _this._webVRrequesting = false;
  16519. _this.updateButtonVisibility();
  16520. };
  16521. scene.getEngine().onVRDisplayChangedObservable.add(this._onVRDisplayChanged);
  16522. scene.getEngine().onVRRequestPresentStart.add(this._onVRRequestPresentStart);
  16523. scene.getEngine().onVRRequestPresentComplete.add(this._onVRRequestPresentComplete);
  16524. window.addEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  16525. scene.onDisposeObservable.add(function () {
  16526. _this.dispose();
  16527. });
  16528. // Gamepad connection events
  16529. this._webVRCamera.onControllerMeshLoadedObservable.add(function (webVRController) { return _this._onDefaultMeshLoaded(webVRController); });
  16530. this._scene.gamepadManager.onGamepadConnectedObservable.add(this._onNewGamepadConnected);
  16531. this._scene.gamepadManager.onGamepadDisconnectedObservable.add(this._onNewGamepadDisconnected);
  16532. this.updateButtonVisibility();
  16533. //create easing functions
  16534. this._circleEase = new _Animations_easing__WEBPACK_IMPORTED_MODULE_20__["CircleEase"]();
  16535. this._circleEase.setEasingMode(_Animations_easing__WEBPACK_IMPORTED_MODULE_20__["EasingFunction"].EASINGMODE_EASEINOUT);
  16536. if (this.webVROptions.floorMeshes) {
  16537. this.enableTeleportation({ floorMeshes: this.webVROptions.floorMeshes });
  16538. }
  16539. }
  16540. Object.defineProperty(VRExperienceHelper.prototype, "onEnteringVR", {
  16541. /** Return this.onEnteringVRObservable
  16542. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  16543. */
  16544. get: function () {
  16545. return this.onEnteringVRObservable;
  16546. },
  16547. enumerable: true,
  16548. configurable: true
  16549. });
  16550. Object.defineProperty(VRExperienceHelper.prototype, "onExitingVR", {
  16551. /** Return this.onExitingVRObservable
  16552. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  16553. */
  16554. get: function () {
  16555. return this.onExitingVRObservable;
  16556. },
  16557. enumerable: true,
  16558. configurable: true
  16559. });
  16560. Object.defineProperty(VRExperienceHelper.prototype, "onControllerMeshLoaded", {
  16561. /** Return this.onControllerMeshLoadedObservable
  16562. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  16563. */
  16564. get: function () {
  16565. return this.onControllerMeshLoadedObservable;
  16566. },
  16567. enumerable: true,
  16568. configurable: true
  16569. });
  16570. Object.defineProperty(VRExperienceHelper.prototype, "teleportationTarget", {
  16571. /**
  16572. * The mesh used to display where the user is going to teleport.
  16573. */
  16574. get: function () {
  16575. return this._teleportationTarget;
  16576. },
  16577. /**
  16578. * Sets the mesh to be used to display where the user is going to teleport.
  16579. */
  16580. set: function (value) {
  16581. if (value) {
  16582. value.name = "teleportationTarget";
  16583. this._isDefaultTeleportationTarget = false;
  16584. this._teleportationTarget = value;
  16585. }
  16586. },
  16587. enumerable: true,
  16588. configurable: true
  16589. });
  16590. Object.defineProperty(VRExperienceHelper.prototype, "gazeTrackerMesh", {
  16591. /**
  16592. * 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
  16593. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  16594. * See http://doc.babylonjs.com/resources/baking_transformations
  16595. */
  16596. get: function () {
  16597. return this._cameraGazer._gazeTracker;
  16598. },
  16599. set: function (value) {
  16600. if (value) {
  16601. // Dispose of existing meshes
  16602. if (this._cameraGazer._gazeTracker) {
  16603. this._cameraGazer._gazeTracker.dispose();
  16604. }
  16605. if (this._leftController && this._leftController._gazeTracker) {
  16606. this._leftController._gazeTracker.dispose();
  16607. }
  16608. if (this._rightController && this._rightController._gazeTracker) {
  16609. this._rightController._gazeTracker.dispose();
  16610. }
  16611. // Set and create gaze trackers on head and controllers
  16612. this._cameraGazer._gazeTracker = value;
  16613. this._cameraGazer._gazeTracker.bakeCurrentTransformIntoVertices();
  16614. this._cameraGazer._gazeTracker.isPickable = false;
  16615. this._cameraGazer._gazeTracker.isVisible = false;
  16616. this._cameraGazer._gazeTracker.name = "gazeTracker";
  16617. if (this._leftController) {
  16618. this._leftController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker");
  16619. }
  16620. if (this._rightController) {
  16621. this._rightController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker");
  16622. }
  16623. }
  16624. },
  16625. enumerable: true,
  16626. configurable: true
  16627. });
  16628. Object.defineProperty(VRExperienceHelper.prototype, "leftControllerGazeTrackerMesh", {
  16629. /**
  16630. * The gaze tracking mesh corresponding to the left controller
  16631. */
  16632. get: function () {
  16633. if (this._leftController) {
  16634. return this._leftController._gazeTracker;
  16635. }
  16636. return null;
  16637. },
  16638. enumerable: true,
  16639. configurable: true
  16640. });
  16641. Object.defineProperty(VRExperienceHelper.prototype, "rightControllerGazeTrackerMesh", {
  16642. /**
  16643. * The gaze tracking mesh corresponding to the right controller
  16644. */
  16645. get: function () {
  16646. if (this._rightController) {
  16647. return this._rightController._gazeTracker;
  16648. }
  16649. return null;
  16650. },
  16651. enumerable: true,
  16652. configurable: true
  16653. });
  16654. Object.defineProperty(VRExperienceHelper.prototype, "displayGaze", {
  16655. /**
  16656. * If the ray of the gaze should be displayed.
  16657. */
  16658. get: function () {
  16659. return this._displayGaze;
  16660. },
  16661. /**
  16662. * Sets if the ray of the gaze should be displayed.
  16663. */
  16664. set: function (value) {
  16665. this._displayGaze = value;
  16666. if (!value) {
  16667. this._cameraGazer._gazeTracker.isVisible = false;
  16668. if (this._leftController) {
  16669. this._leftController._gazeTracker.isVisible = false;
  16670. }
  16671. if (this._rightController) {
  16672. this._rightController._gazeTracker.isVisible = false;
  16673. }
  16674. }
  16675. },
  16676. enumerable: true,
  16677. configurable: true
  16678. });
  16679. Object.defineProperty(VRExperienceHelper.prototype, "displayLaserPointer", {
  16680. /**
  16681. * If the ray of the LaserPointer should be displayed.
  16682. */
  16683. get: function () {
  16684. return this._displayLaserPointer;
  16685. },
  16686. /**
  16687. * Sets if the ray of the LaserPointer should be displayed.
  16688. */
  16689. set: function (value) {
  16690. this._displayLaserPointer = value;
  16691. if (!value) {
  16692. if (this._rightController) {
  16693. this._rightController._deactivatePointer();
  16694. this._rightController._gazeTracker.isVisible = false;
  16695. }
  16696. if (this._leftController) {
  16697. this._leftController._deactivatePointer();
  16698. this._leftController._gazeTracker.isVisible = false;
  16699. }
  16700. }
  16701. else {
  16702. if (this._rightController) {
  16703. this._rightController._activatePointer();
  16704. }
  16705. if (this._leftController) {
  16706. this._leftController._activatePointer();
  16707. }
  16708. }
  16709. },
  16710. enumerable: true,
  16711. configurable: true
  16712. });
  16713. Object.defineProperty(VRExperienceHelper.prototype, "deviceOrientationCamera", {
  16714. /**
  16715. * The deviceOrientationCamera used as the camera when not in VR.
  16716. */
  16717. get: function () {
  16718. return this._deviceOrientationCamera;
  16719. },
  16720. enumerable: true,
  16721. configurable: true
  16722. });
  16723. Object.defineProperty(VRExperienceHelper.prototype, "currentVRCamera", {
  16724. /**
  16725. * Based on the current WebVR support, returns the current VR camera used.
  16726. */
  16727. get: function () {
  16728. if (this._webVRready) {
  16729. return this._webVRCamera;
  16730. }
  16731. else {
  16732. return this._scene.activeCamera;
  16733. }
  16734. },
  16735. enumerable: true,
  16736. configurable: true
  16737. });
  16738. Object.defineProperty(VRExperienceHelper.prototype, "webVRCamera", {
  16739. /**
  16740. * The webVRCamera which is used when in VR.
  16741. */
  16742. get: function () {
  16743. return this._webVRCamera;
  16744. },
  16745. enumerable: true,
  16746. configurable: true
  16747. });
  16748. Object.defineProperty(VRExperienceHelper.prototype, "vrDeviceOrientationCamera", {
  16749. /**
  16750. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  16751. */
  16752. get: function () {
  16753. return this._vrDeviceOrientationCamera;
  16754. },
  16755. enumerable: true,
  16756. configurable: true
  16757. });
  16758. Object.defineProperty(VRExperienceHelper.prototype, "_teleportationRequestInitiated", {
  16759. get: function () {
  16760. var result = this._cameraGazer._teleportationRequestInitiated
  16761. || (this._leftController !== null && this._leftController._teleportationRequestInitiated)
  16762. || (this._rightController !== null && this._rightController._teleportationRequestInitiated);
  16763. return result;
  16764. },
  16765. enumerable: true,
  16766. configurable: true
  16767. });
  16768. // Raised when one of the controller has loaded successfully its associated default mesh
  16769. VRExperienceHelper.prototype._onDefaultMeshLoaded = function (webVRController) {
  16770. if (this._leftController && this._leftController.webVRController == webVRController) {
  16771. if (webVRController.mesh) {
  16772. this._leftController._setLaserPointerParent(webVRController.mesh);
  16773. }
  16774. }
  16775. if (this._rightController && this._rightController.webVRController == webVRController) {
  16776. if (webVRController.mesh) {
  16777. this._rightController._setLaserPointerParent(webVRController.mesh);
  16778. }
  16779. }
  16780. try {
  16781. this.onControllerMeshLoadedObservable.notifyObservers(webVRController);
  16782. }
  16783. catch (err) {
  16784. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onControllerMeshLoaded: " + err);
  16785. }
  16786. };
  16787. Object.defineProperty(VRExperienceHelper.prototype, "isInVRMode", {
  16788. /**
  16789. * Gets a value indicating if we are currently in VR mode.
  16790. */
  16791. get: function () {
  16792. return this._webVRpresenting || this._fullscreenVRpresenting;
  16793. },
  16794. enumerable: true,
  16795. configurable: true
  16796. });
  16797. VRExperienceHelper.prototype.onVrDisplayPresentChange = function () {
  16798. var vrDisplay = this._scene.getEngine().getVRDevice();
  16799. if (vrDisplay) {
  16800. var wasPresenting = this._webVRpresenting;
  16801. this._webVRpresenting = vrDisplay.isPresenting;
  16802. if (wasPresenting && !this._webVRpresenting) {
  16803. this.exitVR();
  16804. }
  16805. }
  16806. else {
  16807. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Detected VRDisplayPresentChange on an unknown VRDisplay. Did you can enterVR on the vrExperienceHelper?');
  16808. }
  16809. this.updateButtonVisibility();
  16810. };
  16811. VRExperienceHelper.prototype.onVRDisplayChanged = function (eventArgs) {
  16812. this._webVRsupported = eventArgs.vrSupported;
  16813. this._webVRready = !!eventArgs.vrDisplay;
  16814. this._webVRpresenting = eventArgs.vrDisplay && eventArgs.vrDisplay.isPresenting;
  16815. this.updateButtonVisibility();
  16816. };
  16817. VRExperienceHelper.prototype.moveButtonToBottomRight = function () {
  16818. if (this._canvas && !this._useCustomVRButton) {
  16819. this._btnVR.style.top = this._canvas.offsetTop + this._canvas.offsetHeight - 70 + "px";
  16820. this._btnVR.style.left = this._canvas.offsetLeft + this._canvas.offsetWidth - 100 + "px";
  16821. }
  16822. };
  16823. VRExperienceHelper.prototype.displayVRButton = function () {
  16824. if (!this._useCustomVRButton && !this._btnVRDisplayed) {
  16825. document.body.appendChild(this._btnVR);
  16826. this._btnVRDisplayed = true;
  16827. }
  16828. };
  16829. VRExperienceHelper.prototype.updateButtonVisibility = function () {
  16830. if (!this._btnVR || this._useCustomVRButton) {
  16831. return;
  16832. }
  16833. this._btnVR.className = "babylonVRicon";
  16834. if (this.isInVRMode) {
  16835. this._btnVR.className += " vrdisplaypresenting";
  16836. }
  16837. else {
  16838. if (this._webVRready) {
  16839. this._btnVR.className += " vrdisplayready";
  16840. }
  16841. if (this._webVRsupported) {
  16842. this._btnVR.className += " vrdisplaysupported";
  16843. }
  16844. if (this._webVRrequesting) {
  16845. this._btnVR.className += " vrdisplayrequesting";
  16846. }
  16847. }
  16848. };
  16849. /**
  16850. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  16851. * Otherwise, will use the fullscreen API.
  16852. */
  16853. VRExperienceHelper.prototype.enterVR = function () {
  16854. var _this = this;
  16855. if (this.onEnteringVRObservable) {
  16856. try {
  16857. this.onEnteringVRObservable.notifyObservers(this);
  16858. }
  16859. catch (err) {
  16860. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onEnteringVR: " + err);
  16861. }
  16862. }
  16863. if (this._scene.activeCamera) {
  16864. this._position = this._scene.activeCamera.position.clone();
  16865. if (this.vrDeviceOrientationCamera) {
  16866. this.vrDeviceOrientationCamera.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles();
  16867. this.vrDeviceOrientationCamera.angularSensibility = 2000;
  16868. }
  16869. if (this.webVRCamera) {
  16870. var currentYRotation = this.webVRCamera.deviceRotationQuaternion.toEulerAngles().y;
  16871. var desiredYRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles().y;
  16872. var delta = desiredYRotation - currentYRotation;
  16873. var currentGlobalRotation = this.webVRCamera.rotationQuaternion.toEulerAngles().y;
  16874. this.webVRCamera.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromEulerAngles(0, currentGlobalRotation + delta, 0);
  16875. }
  16876. // make sure that we return to the last active camera
  16877. this._existingCamera = this._scene.activeCamera;
  16878. // Remove and cache angular sensability to avoid camera rotation when in VR
  16879. if (this._existingCamera.angularSensibilityX) {
  16880. this._cachedAngularSensibility.angularSensibilityX = this._existingCamera.angularSensibilityX;
  16881. this._existingCamera.angularSensibilityX = Number.MAX_VALUE;
  16882. }
  16883. if (this._existingCamera.angularSensibilityY) {
  16884. this._cachedAngularSensibility.angularSensibilityY = this._existingCamera.angularSensibilityY;
  16885. this._existingCamera.angularSensibilityY = Number.MAX_VALUE;
  16886. }
  16887. if (this._existingCamera.angularSensibility) {
  16888. this._cachedAngularSensibility.angularSensibility = this._existingCamera.angularSensibility;
  16889. this._existingCamera.angularSensibility = Number.MAX_VALUE;
  16890. }
  16891. }
  16892. if (this._webVRrequesting) {
  16893. return;
  16894. }
  16895. // If WebVR is supported and a headset is connected
  16896. if (this._webVRready) {
  16897. if (!this._webVRpresenting) {
  16898. this._scene.getEngine().onVRRequestPresentComplete.addOnce(function (result) {
  16899. _this.onAfterEnteringVRObservable.notifyObservers({ success: result });
  16900. });
  16901. this._webVRCamera.position = this._position;
  16902. this._scene.activeCamera = this._webVRCamera;
  16903. }
  16904. }
  16905. else if (this._vrDeviceOrientationCamera) {
  16906. this._vrDeviceOrientationCamera.position = this._position;
  16907. if (this._scene.activeCamera) {
  16908. this._vrDeviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
  16909. }
  16910. this._scene.activeCamera = this._vrDeviceOrientationCamera;
  16911. this._scene.getEngine().enterFullscreen(this.requestPointerLockOnFullScreen);
  16912. this.updateButtonVisibility();
  16913. this._vrDeviceOrientationCamera.onViewMatrixChangedObservable.addOnce(function () {
  16914. _this.onAfterEnteringVRObservable.notifyObservers({ success: true });
  16915. });
  16916. }
  16917. if (this._scene.activeCamera && this._canvas) {
  16918. this._scene.activeCamera.attachControl(this._canvas);
  16919. }
  16920. if (this._interactionsEnabled) {
  16921. this._scene.registerBeforeRender(this.beforeRender);
  16922. }
  16923. if (this._displayLaserPointer) {
  16924. [this._leftController, this._rightController].forEach(function (controller) {
  16925. if (controller) {
  16926. controller._activatePointer();
  16927. }
  16928. });
  16929. }
  16930. this._hasEnteredVR = true;
  16931. };
  16932. /**
  16933. * Attempt to exit VR, or fullscreen.
  16934. */
  16935. VRExperienceHelper.prototype.exitVR = function () {
  16936. if (this._hasEnteredVR) {
  16937. if (this.onExitingVRObservable) {
  16938. try {
  16939. this.onExitingVRObservable.notifyObservers(this);
  16940. }
  16941. catch (err) {
  16942. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onExitingVR: " + err);
  16943. }
  16944. }
  16945. if (this._webVRpresenting) {
  16946. this._scene.getEngine().disableVR();
  16947. }
  16948. if (this._scene.activeCamera) {
  16949. this._position = this._scene.activeCamera.position.clone();
  16950. }
  16951. if (this.vrDeviceOrientationCamera) {
  16952. this.vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE;
  16953. }
  16954. if (this._deviceOrientationCamera) {
  16955. this._deviceOrientationCamera.position = this._position;
  16956. this._scene.activeCamera = this._deviceOrientationCamera;
  16957. if (this._canvas) {
  16958. this._scene.activeCamera.attachControl(this._canvas);
  16959. }
  16960. // Restore angular sensibility
  16961. if (this._cachedAngularSensibility.angularSensibilityX) {
  16962. this._deviceOrientationCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX;
  16963. this._cachedAngularSensibility.angularSensibilityX = null;
  16964. }
  16965. if (this._cachedAngularSensibility.angularSensibilityY) {
  16966. this._deviceOrientationCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY;
  16967. this._cachedAngularSensibility.angularSensibilityY = null;
  16968. }
  16969. if (this._cachedAngularSensibility.angularSensibility) {
  16970. this._deviceOrientationCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility;
  16971. this._cachedAngularSensibility.angularSensibility = null;
  16972. }
  16973. }
  16974. else if (this._existingCamera) {
  16975. this._existingCamera.position = this._position;
  16976. this._scene.activeCamera = this._existingCamera;
  16977. // Restore angular sensibility
  16978. if (this._cachedAngularSensibility.angularSensibilityX) {
  16979. this._existingCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX;
  16980. this._cachedAngularSensibility.angularSensibilityX = null;
  16981. }
  16982. if (this._cachedAngularSensibility.angularSensibilityY) {
  16983. this._existingCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY;
  16984. this._cachedAngularSensibility.angularSensibilityY = null;
  16985. }
  16986. if (this._cachedAngularSensibility.angularSensibility) {
  16987. this._existingCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility;
  16988. this._cachedAngularSensibility.angularSensibility = null;
  16989. }
  16990. }
  16991. this.updateButtonVisibility();
  16992. if (this._interactionsEnabled) {
  16993. this._scene.unregisterBeforeRender(this.beforeRender);
  16994. this._cameraGazer._gazeTracker.isVisible = false;
  16995. if (this._leftController) {
  16996. this._leftController._gazeTracker.isVisible = false;
  16997. }
  16998. if (this._rightController) {
  16999. this._rightController._gazeTracker.isVisible = false;
  17000. }
  17001. }
  17002. // resize to update width and height when exiting vr exits fullscreen
  17003. this._scene.getEngine().resize();
  17004. [this._leftController, this._rightController].forEach(function (controller) {
  17005. if (controller) {
  17006. controller._deactivatePointer();
  17007. }
  17008. });
  17009. this._hasEnteredVR = false;
  17010. }
  17011. };
  17012. Object.defineProperty(VRExperienceHelper.prototype, "position", {
  17013. /**
  17014. * The position of the vr experience helper.
  17015. */
  17016. get: function () {
  17017. return this._position;
  17018. },
  17019. /**
  17020. * Sets the position of the vr experience helper.
  17021. */
  17022. set: function (value) {
  17023. this._position = value;
  17024. if (this._scene.activeCamera) {
  17025. this._scene.activeCamera.position = value;
  17026. }
  17027. },
  17028. enumerable: true,
  17029. configurable: true
  17030. });
  17031. /**
  17032. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  17033. */
  17034. VRExperienceHelper.prototype.enableInteractions = function () {
  17035. var _this = this;
  17036. if (!this._interactionsEnabled) {
  17037. this._interactionsRequested = true;
  17038. if (this._leftController) {
  17039. this._enableInteractionOnController(this._leftController);
  17040. }
  17041. if (this._rightController) {
  17042. this._enableInteractionOnController(this._rightController);
  17043. }
  17044. this.raySelectionPredicate = function (mesh) {
  17045. return mesh.isVisible && (mesh.isPickable || mesh.name === _this._floorMeshName);
  17046. };
  17047. this.meshSelectionPredicate = function () {
  17048. return true;
  17049. };
  17050. this._raySelectionPredicate = function (mesh) {
  17051. if (_this._isTeleportationFloor(mesh) || (mesh.name.indexOf("gazeTracker") === -1
  17052. && mesh.name.indexOf("teleportationTarget") === -1
  17053. && mesh.name.indexOf("torusTeleportation") === -1)) {
  17054. return _this.raySelectionPredicate(mesh);
  17055. }
  17056. return false;
  17057. };
  17058. this._interactionsEnabled = true;
  17059. }
  17060. };
  17061. Object.defineProperty(VRExperienceHelper.prototype, "_noControllerIsActive", {
  17062. get: function () {
  17063. return !(this._leftController && this._leftController._activePointer) && !(this._rightController && this._rightController._activePointer);
  17064. },
  17065. enumerable: true,
  17066. configurable: true
  17067. });
  17068. VRExperienceHelper.prototype._isTeleportationFloor = function (mesh) {
  17069. for (var i = 0; i < this._floorMeshesCollection.length; i++) {
  17070. if (this._floorMeshesCollection[i].id === mesh.id) {
  17071. return true;
  17072. }
  17073. }
  17074. if (this._floorMeshName && mesh.name === this._floorMeshName) {
  17075. return true;
  17076. }
  17077. return false;
  17078. };
  17079. /**
  17080. * Adds a floor mesh to be used for teleportation.
  17081. * @param floorMesh the mesh to be used for teleportation.
  17082. */
  17083. VRExperienceHelper.prototype.addFloorMesh = function (floorMesh) {
  17084. if (!this._floorMeshesCollection) {
  17085. return;
  17086. }
  17087. if (this._floorMeshesCollection.indexOf(floorMesh) > -1) {
  17088. return;
  17089. }
  17090. this._floorMeshesCollection.push(floorMesh);
  17091. };
  17092. /**
  17093. * Removes a floor mesh from being used for teleportation.
  17094. * @param floorMesh the mesh to be removed.
  17095. */
  17096. VRExperienceHelper.prototype.removeFloorMesh = function (floorMesh) {
  17097. if (!this._floorMeshesCollection) {
  17098. return;
  17099. }
  17100. var meshIndex = this._floorMeshesCollection.indexOf(floorMesh);
  17101. if (meshIndex !== -1) {
  17102. this._floorMeshesCollection.splice(meshIndex, 1);
  17103. }
  17104. };
  17105. /**
  17106. * Enables interactions and teleportation using the VR controllers and gaze.
  17107. * @param vrTeleportationOptions options to modify teleportation behavior.
  17108. */
  17109. VRExperienceHelper.prototype.enableTeleportation = function (vrTeleportationOptions) {
  17110. if (vrTeleportationOptions === void 0) { vrTeleportationOptions = {}; }
  17111. if (!this._teleportationInitialized) {
  17112. this._teleportationRequested = true;
  17113. this.enableInteractions();
  17114. if (vrTeleportationOptions.floorMeshName) {
  17115. this._floorMeshName = vrTeleportationOptions.floorMeshName;
  17116. }
  17117. if (vrTeleportationOptions.floorMeshes) {
  17118. this._floorMeshesCollection = vrTeleportationOptions.floorMeshes;
  17119. }
  17120. if (this._leftController != null) {
  17121. this._enableTeleportationOnController(this._leftController);
  17122. }
  17123. if (this._rightController != null) {
  17124. this._enableTeleportationOnController(this._rightController);
  17125. }
  17126. // Creates an image processing post process for the vignette not relying
  17127. // on the main scene configuration for image processing to reduce setup and spaces
  17128. // (gamma/linear) conflicts.
  17129. var imageProcessingConfiguration = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_16__["ImageProcessingConfiguration"]();
  17130. imageProcessingConfiguration.vignetteColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color4"](0, 0, 0, 0);
  17131. imageProcessingConfiguration.vignetteEnabled = true;
  17132. this._postProcessMove = new _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_19__["ImageProcessingPostProcess"]("postProcessMove", 1.0, this._webVRCamera, undefined, undefined, undefined, undefined, imageProcessingConfiguration);
  17133. this._webVRCamera.detachPostProcess(this._postProcessMove);
  17134. this._teleportationInitialized = true;
  17135. if (this._isDefaultTeleportationTarget) {
  17136. this._createTeleportationCircles();
  17137. this._teleportationTarget.scaling.scaleInPlace(this._webVRCamera.deviceScaleFactor);
  17138. }
  17139. }
  17140. };
  17141. VRExperienceHelper.prototype._enableInteractionOnController = function (controller) {
  17142. var _this = this;
  17143. var controllerMesh = controller.webVRController.mesh;
  17144. if (controllerMesh) {
  17145. controller._interactionsEnabled = true;
  17146. if (this.isInVRMode && this._displayLaserPointer) {
  17147. controller._activatePointer();
  17148. }
  17149. if (this.webVROptions.laserToggle) {
  17150. controller.webVRController.onMainButtonStateChangedObservable.add(function (stateObject) {
  17151. // Enabling / disabling laserPointer
  17152. if (_this._displayLaserPointer && stateObject.value === 1) {
  17153. if (controller._activePointer) {
  17154. controller._deactivatePointer();
  17155. }
  17156. else {
  17157. controller._activatePointer();
  17158. }
  17159. if (_this.displayGaze) {
  17160. controller._gazeTracker.isVisible = controller._activePointer;
  17161. }
  17162. }
  17163. });
  17164. }
  17165. controller.webVRController.onTriggerStateChangedObservable.add(function (stateObject) {
  17166. var gazer = controller;
  17167. if (_this._noControllerIsActive) {
  17168. gazer = _this._cameraGazer;
  17169. }
  17170. if (!gazer._pointerDownOnMeshAsked) {
  17171. if (stateObject.value > _this._padSensibilityUp) {
  17172. gazer._selectionPointerDown();
  17173. }
  17174. }
  17175. else if (stateObject.value < _this._padSensibilityDown) {
  17176. gazer._selectionPointerUp();
  17177. }
  17178. });
  17179. }
  17180. };
  17181. VRExperienceHelper.prototype._checkTeleportWithRay = function (stateObject, gazer) {
  17182. // Dont teleport if another gaze already requested teleportation
  17183. if (this._teleportationRequestInitiated && !gazer._teleportationRequestInitiated) {
  17184. return;
  17185. }
  17186. if (!gazer._teleportationRequestInitiated) {
  17187. if (stateObject.y < -this._padSensibilityUp && gazer._dpadPressed) {
  17188. gazer._activatePointer();
  17189. gazer._teleportationRequestInitiated = true;
  17190. }
  17191. }
  17192. else {
  17193. // Listening to the proper controller values changes to confirm teleportation
  17194. if (Math.sqrt(stateObject.y * stateObject.y + stateObject.x * stateObject.x) < this._padSensibilityDown) {
  17195. if (this._teleportActive) {
  17196. this.teleportCamera(this._haloCenter);
  17197. }
  17198. gazer._teleportationRequestInitiated = false;
  17199. }
  17200. }
  17201. };
  17202. VRExperienceHelper.prototype._checkRotate = function (stateObject, gazer) {
  17203. // Only rotate when user is not currently selecting a teleportation location
  17204. if (gazer._teleportationRequestInitiated) {
  17205. return;
  17206. }
  17207. if (!gazer._rotationLeftAsked) {
  17208. if (stateObject.x < -this._padSensibilityUp && gazer._dpadPressed) {
  17209. gazer._rotationLeftAsked = true;
  17210. if (this._rotationAllowed) {
  17211. this._rotateCamera(false);
  17212. }
  17213. }
  17214. }
  17215. else {
  17216. if (stateObject.x > -this._padSensibilityDown) {
  17217. gazer._rotationLeftAsked = false;
  17218. }
  17219. }
  17220. if (!gazer._rotationRightAsked) {
  17221. if (stateObject.x > this._padSensibilityUp && gazer._dpadPressed) {
  17222. gazer._rotationRightAsked = true;
  17223. if (this._rotationAllowed) {
  17224. this._rotateCamera(true);
  17225. }
  17226. }
  17227. }
  17228. else {
  17229. if (stateObject.x < this._padSensibilityDown) {
  17230. gazer._rotationRightAsked = false;
  17231. }
  17232. }
  17233. };
  17234. VRExperienceHelper.prototype._checkTeleportBackwards = function (stateObject, gazer) {
  17235. // Only teleport backwards when user is not currently selecting a teleportation location
  17236. if (gazer._teleportationRequestInitiated) {
  17237. return;
  17238. }
  17239. // Teleport backwards
  17240. if (stateObject.y > this._padSensibilityUp && gazer._dpadPressed) {
  17241. if (!gazer._teleportationBackRequestInitiated) {
  17242. if (!this.currentVRCamera) {
  17243. return;
  17244. }
  17245. // Get rotation and position of the current camera
  17246. var rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this.currentVRCamera.getWorldMatrix().getRotationMatrix());
  17247. var position = this.currentVRCamera.position;
  17248. // If the camera has device position, use that instead
  17249. if (this.currentVRCamera.devicePosition && this.currentVRCamera.deviceRotationQuaternion) {
  17250. rotation = this.currentVRCamera.deviceRotationQuaternion;
  17251. position = this.currentVRCamera.devicePosition;
  17252. }
  17253. // Get matrix with only the y rotation of the device rotation
  17254. rotation.toEulerAnglesToRef(this._workingVector);
  17255. this._workingVector.z = 0;
  17256. this._workingVector.x = 0;
  17257. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].RotationYawPitchRollToRef(this._workingVector.y, this._workingVector.x, this._workingVector.z, this._workingQuaternion);
  17258. this._workingQuaternion.toRotationMatrix(this._workingMatrix);
  17259. // Rotate backwards ray by device rotation to cast at the ground behind the user
  17260. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].TransformCoordinatesToRef(this._teleportBackwardsVector, this._workingMatrix, this._workingVector);
  17261. // Teleport if ray hit the ground and is not to far away eg. backwards off a cliff
  17262. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_15__["Ray"](position, this._workingVector);
  17263. var hit = this._scene.pickWithRay(ray, this._raySelectionPredicate);
  17264. if (hit && hit.pickedPoint && hit.pickedMesh && this._isTeleportationFloor(hit.pickedMesh) && hit.distance < 5) {
  17265. this.teleportCamera(hit.pickedPoint);
  17266. }
  17267. gazer._teleportationBackRequestInitiated = true;
  17268. }
  17269. }
  17270. else {
  17271. gazer._teleportationBackRequestInitiated = false;
  17272. }
  17273. };
  17274. VRExperienceHelper.prototype._enableTeleportationOnController = function (controller) {
  17275. var _this = this;
  17276. var controllerMesh = controller.webVRController.mesh;
  17277. if (controllerMesh) {
  17278. if (!controller._interactionsEnabled) {
  17279. this._enableInteractionOnController(controller);
  17280. }
  17281. controller._interactionsEnabled = true;
  17282. controller._teleportationEnabled = true;
  17283. if (controller.webVRController.controllerType === _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledControllerType"].VIVE) {
  17284. controller._dpadPressed = false;
  17285. controller.webVRController.onPadStateChangedObservable.add(function (stateObject) {
  17286. controller._dpadPressed = stateObject.pressed;
  17287. if (!controller._dpadPressed) {
  17288. controller._rotationLeftAsked = false;
  17289. controller._rotationRightAsked = false;
  17290. controller._teleportationBackRequestInitiated = false;
  17291. }
  17292. });
  17293. }
  17294. controller.webVRController.onPadValuesChangedObservable.add(function (stateObject) {
  17295. if (_this.teleportationEnabled) {
  17296. _this._checkTeleportBackwards(stateObject, controller);
  17297. _this._checkTeleportWithRay(stateObject, controller);
  17298. }
  17299. _this._checkRotate(stateObject, controller);
  17300. });
  17301. }
  17302. };
  17303. VRExperienceHelper.prototype._createTeleportationCircles = function () {
  17304. this._teleportationTarget = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateGround("teleportationTarget", 2, 2, 2, this._scene);
  17305. this._teleportationTarget.isPickable = false;
  17306. var length = 512;
  17307. var dynamicTexture = new _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_18__["DynamicTexture"]("DynamicTexture", length, this._scene, true);
  17308. dynamicTexture.hasAlpha = true;
  17309. var context = dynamicTexture.getContext();
  17310. var centerX = length / 2;
  17311. var centerY = length / 2;
  17312. var radius = 200;
  17313. context.beginPath();
  17314. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  17315. context.fillStyle = this._teleportationFillColor;
  17316. context.fill();
  17317. context.lineWidth = 10;
  17318. context.strokeStyle = this._teleportationBorderColor;
  17319. context.stroke();
  17320. context.closePath();
  17321. dynamicTexture.update();
  17322. var teleportationCircleMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("TextPlaneMaterial", this._scene);
  17323. teleportationCircleMaterial.diffuseTexture = dynamicTexture;
  17324. this._teleportationTarget.material = teleportationCircleMaterial;
  17325. var torus = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateTorus("torusTeleportation", 0.75, 0.1, 25, this._scene, false);
  17326. torus.isPickable = false;
  17327. torus.parent = this._teleportationTarget;
  17328. 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);
  17329. var keys = [];
  17330. keys.push({
  17331. frame: 0,
  17332. value: 0
  17333. });
  17334. keys.push({
  17335. frame: 30,
  17336. value: 0.4
  17337. });
  17338. keys.push({
  17339. frame: 60,
  17340. value: 0
  17341. });
  17342. animationInnerCircle.setKeys(keys);
  17343. var easingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_20__["SineEase"]();
  17344. easingFunction.setEasingMode(_Animations_easing__WEBPACK_IMPORTED_MODULE_20__["EasingFunction"].EASINGMODE_EASEINOUT);
  17345. animationInnerCircle.setEasingFunction(easingFunction);
  17346. torus.animations = [];
  17347. torus.animations.push(animationInnerCircle);
  17348. this._scene.beginAnimation(torus, 0, 60, true);
  17349. this._hideTeleportationTarget();
  17350. };
  17351. VRExperienceHelper.prototype._displayTeleportationTarget = function () {
  17352. this._teleportActive = true;
  17353. if (this._teleportationInitialized) {
  17354. this._teleportationTarget.isVisible = true;
  17355. if (this._isDefaultTeleportationTarget) {
  17356. this._teleportationTarget.getChildren()[0].isVisible = true;
  17357. }
  17358. }
  17359. };
  17360. VRExperienceHelper.prototype._hideTeleportationTarget = function () {
  17361. this._teleportActive = false;
  17362. if (this._teleportationInitialized) {
  17363. this._teleportationTarget.isVisible = false;
  17364. if (this._isDefaultTeleportationTarget) {
  17365. this._teleportationTarget.getChildren()[0].isVisible = false;
  17366. }
  17367. }
  17368. };
  17369. VRExperienceHelper.prototype._rotateCamera = function (right) {
  17370. var _this = this;
  17371. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  17372. return;
  17373. }
  17374. if (right) {
  17375. this._rotationAngle++;
  17376. }
  17377. else {
  17378. this._rotationAngle--;
  17379. }
  17380. this.currentVRCamera.animations = [];
  17381. var target = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Matrix"].RotationY(Math.PI / 4 * this._rotationAngle));
  17382. 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);
  17383. var animationRotationKeys = [];
  17384. animationRotationKeys.push({
  17385. frame: 0,
  17386. value: this.currentVRCamera.rotationQuaternion
  17387. });
  17388. animationRotationKeys.push({
  17389. frame: 6,
  17390. value: target
  17391. });
  17392. animationRotation.setKeys(animationRotationKeys);
  17393. animationRotation.setEasingFunction(this._circleEase);
  17394. this.currentVRCamera.animations.push(animationRotation);
  17395. this._postProcessMove.animations = [];
  17396. 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);
  17397. var vignetteWeightKeys = [];
  17398. vignetteWeightKeys.push({
  17399. frame: 0,
  17400. value: 0
  17401. });
  17402. vignetteWeightKeys.push({
  17403. frame: 3,
  17404. value: 4
  17405. });
  17406. vignetteWeightKeys.push({
  17407. frame: 6,
  17408. value: 0
  17409. });
  17410. animationPP.setKeys(vignetteWeightKeys);
  17411. animationPP.setEasingFunction(this._circleEase);
  17412. this._postProcessMove.animations.push(animationPP);
  17413. 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);
  17414. var vignetteStretchKeys = [];
  17415. vignetteStretchKeys.push({
  17416. frame: 0,
  17417. value: 0
  17418. });
  17419. vignetteStretchKeys.push({
  17420. frame: 3,
  17421. value: 10
  17422. });
  17423. vignetteStretchKeys.push({
  17424. frame: 6,
  17425. value: 0
  17426. });
  17427. animationPP2.setKeys(vignetteStretchKeys);
  17428. animationPP2.setEasingFunction(this._circleEase);
  17429. this._postProcessMove.animations.push(animationPP2);
  17430. this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0;
  17431. this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0;
  17432. this._postProcessMove.samples = 4;
  17433. this._webVRCamera.attachPostProcess(this._postProcessMove);
  17434. this._scene.beginAnimation(this._postProcessMove, 0, 6, false, 1, function () {
  17435. _this._webVRCamera.detachPostProcess(_this._postProcessMove);
  17436. });
  17437. this._scene.beginAnimation(this.currentVRCamera, 0, 6, false, 1);
  17438. };
  17439. VRExperienceHelper.prototype._moveTeleportationSelectorTo = function (hit, gazer, ray) {
  17440. if (hit.pickedPoint) {
  17441. if (gazer._teleportationRequestInitiated) {
  17442. this._displayTeleportationTarget();
  17443. this._haloCenter.copyFrom(hit.pickedPoint);
  17444. this._teleportationTarget.position.copyFrom(hit.pickedPoint);
  17445. }
  17446. var pickNormal = this._convertNormalToDirectionOfRay(hit.getNormal(true, false), ray);
  17447. if (pickNormal) {
  17448. var axis1 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Axis"].Y, pickNormal);
  17449. var axis2 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(pickNormal, axis1);
  17450. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].RotationFromAxisToRef(axis2, pickNormal, axis1, this._teleportationTarget.rotation);
  17451. }
  17452. this._teleportationTarget.position.y += 0.1;
  17453. }
  17454. };
  17455. /**
  17456. * Teleports the users feet to the desired location
  17457. * @param location The location where the user's feet should be placed
  17458. */
  17459. VRExperienceHelper.prototype.teleportCamera = function (location) {
  17460. var _this = this;
  17461. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  17462. return;
  17463. }
  17464. // Teleport the hmd to where the user is looking by moving the anchor to where they are looking minus the
  17465. // offset of the headset from the anchor.
  17466. if (this.webVRCamera.leftCamera) {
  17467. this._workingVector.copyFrom(this.webVRCamera.leftCamera.globalPosition);
  17468. this._workingVector.subtractInPlace(this.webVRCamera.position);
  17469. location.subtractToRef(this._workingVector, this._workingVector);
  17470. }
  17471. else {
  17472. this._workingVector.copyFrom(location);
  17473. }
  17474. // Add height to account for user's height offset
  17475. if (this.isInVRMode) {
  17476. this._workingVector.y += this.webVRCamera.deviceDistanceToRoomGround() * this._webVRCamera.deviceScaleFactor;
  17477. }
  17478. else {
  17479. this._workingVector.y += this._defaultHeight;
  17480. }
  17481. this.onBeforeCameraTeleport.notifyObservers(this._workingVector);
  17482. // Create animation from the camera's position to the new location
  17483. this.currentVRCamera.animations = [];
  17484. 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);
  17485. var animationCameraTeleportationKeys = [{
  17486. frame: 0,
  17487. value: this.currentVRCamera.position
  17488. },
  17489. {
  17490. frame: 11,
  17491. value: this._workingVector
  17492. }
  17493. ];
  17494. animationCameraTeleportation.setKeys(animationCameraTeleportationKeys);
  17495. animationCameraTeleportation.setEasingFunction(this._circleEase);
  17496. this.currentVRCamera.animations.push(animationCameraTeleportation);
  17497. this._postProcessMove.animations = [];
  17498. 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);
  17499. var vignetteWeightKeys = [];
  17500. vignetteWeightKeys.push({
  17501. frame: 0,
  17502. value: 0
  17503. });
  17504. vignetteWeightKeys.push({
  17505. frame: 5,
  17506. value: 8
  17507. });
  17508. vignetteWeightKeys.push({
  17509. frame: 11,
  17510. value: 0
  17511. });
  17512. animationPP.setKeys(vignetteWeightKeys);
  17513. this._postProcessMove.animations.push(animationPP);
  17514. 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);
  17515. var vignetteStretchKeys = [];
  17516. vignetteStretchKeys.push({
  17517. frame: 0,
  17518. value: 0
  17519. });
  17520. vignetteStretchKeys.push({
  17521. frame: 5,
  17522. value: 10
  17523. });
  17524. vignetteStretchKeys.push({
  17525. frame: 11,
  17526. value: 0
  17527. });
  17528. animationPP2.setKeys(vignetteStretchKeys);
  17529. this._postProcessMove.animations.push(animationPP2);
  17530. this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0;
  17531. this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0;
  17532. this._webVRCamera.attachPostProcess(this._postProcessMove);
  17533. this._scene.beginAnimation(this._postProcessMove, 0, 11, false, 1, function () {
  17534. _this._webVRCamera.detachPostProcess(_this._postProcessMove);
  17535. });
  17536. this._scene.beginAnimation(this.currentVRCamera, 0, 11, false, 1, function () {
  17537. _this.onAfterCameraTeleport.notifyObservers(_this._workingVector);
  17538. });
  17539. this._hideTeleportationTarget();
  17540. };
  17541. VRExperienceHelper.prototype._convertNormalToDirectionOfRay = function (normal, ray) {
  17542. if (normal) {
  17543. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Dot(normal, ray.direction));
  17544. if (angle < Math.PI / 2) {
  17545. normal.scaleInPlace(-1);
  17546. }
  17547. }
  17548. return normal;
  17549. };
  17550. VRExperienceHelper.prototype._castRayAndSelectObject = function (gazer) {
  17551. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  17552. return;
  17553. }
  17554. var ray = gazer._getForwardRay(this._rayLength);
  17555. var hit = this._scene.pickWithRay(ray, this._raySelectionPredicate);
  17556. if (hit) {
  17557. // Populate the contrllers mesh that can be used for drag/drop
  17558. if (gazer._laserPointer) {
  17559. hit.originMesh = gazer._laserPointer.parent;
  17560. }
  17561. this._scene.simulatePointerMove(hit, { pointerId: gazer._id });
  17562. }
  17563. gazer._currentHit = hit;
  17564. // Moving the gazeTracker on the mesh face targetted
  17565. if (hit && hit.pickedPoint) {
  17566. if (this._displayGaze) {
  17567. var multiplier = 1;
  17568. gazer._gazeTracker.isVisible = true;
  17569. if (gazer._isActionableMesh) {
  17570. multiplier = 3;
  17571. }
  17572. if (this.updateGazeTrackerScale) {
  17573. gazer._gazeTracker.scaling.x = hit.distance * multiplier;
  17574. gazer._gazeTracker.scaling.y = hit.distance * multiplier;
  17575. gazer._gazeTracker.scaling.z = hit.distance * multiplier;
  17576. }
  17577. var pickNormal = this._convertNormalToDirectionOfRay(hit.getNormal(), ray);
  17578. // To avoid z-fighting
  17579. var deltaFighting = 0.002;
  17580. if (pickNormal) {
  17581. var axis1 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Axis"].Y, pickNormal);
  17582. var axis2 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(pickNormal, axis1);
  17583. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].RotationFromAxisToRef(axis2, pickNormal, axis1, gazer._gazeTracker.rotation);
  17584. }
  17585. gazer._gazeTracker.position.copyFrom(hit.pickedPoint);
  17586. if (gazer._gazeTracker.position.x < 0) {
  17587. gazer._gazeTracker.position.x += deltaFighting;
  17588. }
  17589. else {
  17590. gazer._gazeTracker.position.x -= deltaFighting;
  17591. }
  17592. if (gazer._gazeTracker.position.y < 0) {
  17593. gazer._gazeTracker.position.y += deltaFighting;
  17594. }
  17595. else {
  17596. gazer._gazeTracker.position.y -= deltaFighting;
  17597. }
  17598. if (gazer._gazeTracker.position.z < 0) {
  17599. gazer._gazeTracker.position.z += deltaFighting;
  17600. }
  17601. else {
  17602. gazer._gazeTracker.position.z -= deltaFighting;
  17603. }
  17604. }
  17605. // Changing the size of the laser pointer based on the distance from the targetted point
  17606. gazer._updatePointerDistance(hit.distance);
  17607. }
  17608. else {
  17609. gazer._updatePointerDistance();
  17610. gazer._gazeTracker.isVisible = false;
  17611. }
  17612. if (hit && hit.pickedMesh) {
  17613. // The object selected is the floor, we're in a teleportation scenario
  17614. if (this._teleportationInitialized && this._isTeleportationFloor(hit.pickedMesh) && hit.pickedPoint) {
  17615. // Moving the teleportation area to this targetted point
  17616. //Raise onSelectedMeshUnselected observable if ray collided floor mesh/meshes and a non floor mesh was previously selected
  17617. if (gazer._currentMeshSelected && !this._isTeleportationFloor(gazer._currentMeshSelected)) {
  17618. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  17619. }
  17620. gazer._currentMeshSelected = null;
  17621. if (gazer._teleportationRequestInitiated) {
  17622. this._moveTeleportationSelectorTo(hit, gazer, ray);
  17623. }
  17624. return;
  17625. }
  17626. // If not, we're in a selection scenario
  17627. //this._teleportationAllowed = false;
  17628. if (hit.pickedMesh !== gazer._currentMeshSelected) {
  17629. if (this.meshSelectionPredicate(hit.pickedMesh)) {
  17630. this.onNewMeshPicked.notifyObservers(hit);
  17631. gazer._currentMeshSelected = hit.pickedMesh;
  17632. if (hit.pickedMesh.isPickable && hit.pickedMesh.actionManager) {
  17633. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0, 0, 1));
  17634. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.2, 0.2, 1));
  17635. gazer._isActionableMesh = true;
  17636. }
  17637. else {
  17638. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17639. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17640. gazer._isActionableMesh = false;
  17641. }
  17642. try {
  17643. this.onNewMeshSelected.notifyObservers(hit.pickedMesh);
  17644. }
  17645. catch (err) {
  17646. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onNewMeshSelected: " + err);
  17647. }
  17648. }
  17649. else {
  17650. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  17651. gazer._currentMeshSelected = null;
  17652. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17653. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17654. }
  17655. }
  17656. }
  17657. else {
  17658. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  17659. gazer._currentMeshSelected = null;
  17660. //this._teleportationAllowed = false;
  17661. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17662. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17663. }
  17664. };
  17665. VRExperienceHelper.prototype._notifySelectedMeshUnselected = function (mesh) {
  17666. if (mesh) {
  17667. this.onSelectedMeshUnselected.notifyObservers(mesh);
  17668. }
  17669. };
  17670. /**
  17671. * Sets the color of the laser ray from the vr controllers.
  17672. * @param color new color for the ray.
  17673. */
  17674. VRExperienceHelper.prototype.changeLaserColor = function (color) {
  17675. if (this._leftController) {
  17676. this._leftController._setLaserPointerColor(color);
  17677. }
  17678. if (this._rightController) {
  17679. this._rightController._setLaserPointerColor(color);
  17680. }
  17681. };
  17682. /**
  17683. * Sets the color of the ray from the vr headsets gaze.
  17684. * @param color new color for the ray.
  17685. */
  17686. VRExperienceHelper.prototype.changeGazeColor = function (color) {
  17687. if (!this.updateGazeTrackerColor) {
  17688. return;
  17689. }
  17690. if (!this._cameraGazer._gazeTracker.material) {
  17691. return;
  17692. }
  17693. this._cameraGazer._gazeTracker.material.emissiveColor = color;
  17694. if (this._leftController) {
  17695. this._leftController._gazeTracker.material.emissiveColor = color;
  17696. }
  17697. if (this._rightController) {
  17698. this._rightController._gazeTracker.material.emissiveColor = color;
  17699. }
  17700. };
  17701. /**
  17702. * Exits VR and disposes of the vr experience helper
  17703. */
  17704. VRExperienceHelper.prototype.dispose = function () {
  17705. if (this.isInVRMode) {
  17706. this.exitVR();
  17707. }
  17708. if (this._postProcessMove) {
  17709. this._postProcessMove.dispose();
  17710. }
  17711. if (this._webVRCamera) {
  17712. this._webVRCamera.dispose();
  17713. }
  17714. if (this._vrDeviceOrientationCamera) {
  17715. this._vrDeviceOrientationCamera.dispose();
  17716. }
  17717. if (!this._useCustomVRButton && this._btnVR.parentNode) {
  17718. document.body.removeChild(this._btnVR);
  17719. }
  17720. if (this._deviceOrientationCamera && (this._scene.activeCamera != this._deviceOrientationCamera)) {
  17721. this._deviceOrientationCamera.dispose();
  17722. }
  17723. if (this._cameraGazer) {
  17724. this._cameraGazer.dispose();
  17725. }
  17726. if (this._leftController) {
  17727. this._leftController.dispose();
  17728. }
  17729. if (this._rightController) {
  17730. this._rightController.dispose();
  17731. }
  17732. if (this._teleportationTarget) {
  17733. this._teleportationTarget.dispose();
  17734. }
  17735. this._floorMeshesCollection = [];
  17736. document.removeEventListener("keydown", this._onKeyDown);
  17737. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  17738. window.removeEventListener("resize", this._onResize);
  17739. document.removeEventListener("fullscreenchange", this._onFullscreenChange);
  17740. document.removeEventListener("mozfullscreenchange", this._onFullscreenChange);
  17741. document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange);
  17742. document.removeEventListener("msfullscreenchange", this._onFullscreenChange);
  17743. document.onmsfullscreenchange = null;
  17744. this._scene.getEngine().onVRDisplayChangedObservable.removeCallback(this._onVRDisplayChanged);
  17745. this._scene.getEngine().onVRRequestPresentStart.removeCallback(this._onVRRequestPresentStart);
  17746. this._scene.getEngine().onVRRequestPresentComplete.removeCallback(this._onVRRequestPresentComplete);
  17747. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  17748. this._scene.gamepadManager.onGamepadConnectedObservable.removeCallback(this._onNewGamepadConnected);
  17749. this._scene.gamepadManager.onGamepadDisconnectedObservable.removeCallback(this._onNewGamepadDisconnected);
  17750. this._scene.unregisterBeforeRender(this.beforeRender);
  17751. };
  17752. /**
  17753. * Gets the name of the VRExperienceHelper class
  17754. * @returns "VRExperienceHelper"
  17755. */
  17756. VRExperienceHelper.prototype.getClassName = function () {
  17757. return "VRExperienceHelper";
  17758. };
  17759. return VRExperienceHelper;
  17760. }());
  17761. /***/ }),
  17762. /***/ "./Cameras/VR/webVRCamera.ts":
  17763. /*!***********************************!*\
  17764. !*** ./Cameras/VR/webVRCamera.ts ***!
  17765. \***********************************/
  17766. /*! exports provided: WebVRFreeCamera */
  17767. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17768. "use strict";
  17769. __webpack_require__.r(__webpack_exports__);
  17770. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return WebVRFreeCamera; });
  17771. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  17772. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  17773. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  17774. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  17775. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  17776. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  17777. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  17778. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../node */ "./node.ts");
  17779. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  17780. /* harmony import */ var _RigModes_webVRRigMode__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../RigModes/webVRRigMode */ "./Cameras/RigModes/webVRRigMode.ts");
  17781. // Side effect import to define the stereoscopic mode.
  17782. _node__WEBPACK_IMPORTED_MODULE_7__["Node"].AddNodeConstructor("WebVRFreeCamera", function (name, scene) {
  17783. return function () { return new WebVRFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  17784. });
  17785. _node__WEBPACK_IMPORTED_MODULE_7__["Node"].AddNodeConstructor("WebVRGamepadCamera", function (name, scene) {
  17786. return function () { return new WebVRFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  17787. });
  17788. /**
  17789. * This represents a WebVR camera.
  17790. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  17791. * @example http://doc.babylonjs.com/how_to/webvr_camera
  17792. */
  17793. var WebVRFreeCamera = /** @class */ (function (_super) {
  17794. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebVRFreeCamera, _super);
  17795. /**
  17796. * Instantiates a WebVRFreeCamera.
  17797. * @param name The name of the WebVRFreeCamera
  17798. * @param position The starting anchor position for the camera
  17799. * @param scene The scene the camera belongs to
  17800. * @param webVROptions a set of customizable options for the webVRCamera
  17801. */
  17802. function WebVRFreeCamera(name, position, scene, webVROptions) {
  17803. if (webVROptions === void 0) { webVROptions = {}; }
  17804. var _this = _super.call(this, name, position, scene) || this;
  17805. _this.webVROptions = webVROptions;
  17806. /**
  17807. * @hidden
  17808. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  17809. */
  17810. _this._vrDevice = null;
  17811. /**
  17812. * The rawPose of the vrDevice.
  17813. */
  17814. _this.rawPose = null;
  17815. _this._specsVersion = "1.1";
  17816. _this._attached = false;
  17817. _this._descendants = [];
  17818. // Represents device position and rotation in room space. Should only be used to help calculate babylon space values
  17819. _this._deviceRoomPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17820. /** @hidden */
  17821. _this._deviceRoomRotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity();
  17822. _this._standingMatrix = null;
  17823. /**
  17824. * Represents device position in babylon space.
  17825. */
  17826. _this.devicePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17827. /**
  17828. * Represents device rotation in babylon space.
  17829. */
  17830. _this.deviceRotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity();
  17831. /**
  17832. * The scale of the device to be used when translating from device space to babylon space.
  17833. */
  17834. _this.deviceScaleFactor = 1;
  17835. _this._deviceToWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17836. _this._worldToDevice = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17837. /**
  17838. * References to the webVR controllers for the vrDevice.
  17839. */
  17840. _this.controllers = [];
  17841. /**
  17842. * Emits an event when a controller is attached.
  17843. */
  17844. _this.onControllersAttachedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17845. /**
  17846. * Emits an event when a controller's mesh has been loaded;
  17847. */
  17848. _this.onControllerMeshLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17849. /**
  17850. * Emits an event when the HMD's pose has been updated.
  17851. */
  17852. _this.onPoseUpdatedFromDeviceObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17853. _this._poseSet = false;
  17854. /**
  17855. * If the rig cameras be used as parent instead of this camera.
  17856. */
  17857. _this.rigParenting = true;
  17858. _this._defaultHeight = undefined;
  17859. _this._htmlElementAttached = null;
  17860. _this._detachIfAttached = function () {
  17861. var vrDisplay = _this.getEngine().getVRDevice();
  17862. if (vrDisplay && !vrDisplay.isPresenting && _this._htmlElementAttached) {
  17863. _this.detachControl(_this._htmlElementAttached);
  17864. }
  17865. };
  17866. _this._workingVector = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17867. _this._oneVector = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].One();
  17868. _this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17869. _this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  17870. _this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17871. if (webVROptions.defaultHeight) {
  17872. _this._defaultHeight = webVROptions.defaultHeight;
  17873. _this.position.y = _this._defaultHeight;
  17874. }
  17875. _this.minZ = 0.1;
  17876. //legacy support - the compensation boolean was removed.
  17877. if (arguments.length === 5) {
  17878. _this.webVROptions = arguments[4];
  17879. }
  17880. // default webVR options
  17881. if (_this.webVROptions.trackPosition == undefined) {
  17882. _this.webVROptions.trackPosition = true;
  17883. }
  17884. if (_this.webVROptions.controllerMeshes == undefined) {
  17885. _this.webVROptions.controllerMeshes = true;
  17886. }
  17887. if (_this.webVROptions.defaultLightingOnControllers == undefined) {
  17888. _this.webVROptions.defaultLightingOnControllers = true;
  17889. }
  17890. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"]();
  17891. if (_this.webVROptions && _this.webVROptions.positionScale) {
  17892. _this.deviceScaleFactor = _this.webVROptions.positionScale;
  17893. }
  17894. //enable VR
  17895. var engine = _this.getEngine();
  17896. _this._onVREnabled = function (success) { if (success) {
  17897. _this.initControllers();
  17898. } };
  17899. engine.onVRRequestPresentComplete.add(_this._onVREnabled);
  17900. engine.initWebVR().add(function (event) {
  17901. if (!event.vrDisplay || _this._vrDevice === event.vrDisplay) {
  17902. return;
  17903. }
  17904. _this._vrDevice = event.vrDisplay;
  17905. //reset the rig parameters.
  17906. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_3__["Camera"].RIG_MODE_WEBVR, { parentCamera: _this, vrDisplay: _this._vrDevice, frameData: _this._frameData, specs: _this._specsVersion });
  17907. if (_this._attached) {
  17908. _this.getEngine().enableVR();
  17909. }
  17910. });
  17911. if (typeof (VRFrameData) !== "undefined") {
  17912. _this._frameData = new VRFrameData();
  17913. }
  17914. /**
  17915. * The idea behind the following lines:
  17916. * objects that have the camera as parent should actually have the rig cameras as a parent.
  17917. * BUT, each of those cameras has a different view matrix, which means that if we set the parent to the first rig camera,
  17918. * the second will not show it correctly.
  17919. *
  17920. * To solve this - each object that has the camera as parent will be added to a protected array.
  17921. * When the rig camera renders, it will take this array and set all of those to be its children.
  17922. * This way, the right camera will be used as a parent, and the mesh will be rendered correctly.
  17923. * Amazing!
  17924. */
  17925. scene.onBeforeCameraRenderObservable.add(function (camera) {
  17926. if (camera.parent === _this && _this.rigParenting) {
  17927. _this._descendants = _this.getDescendants(true, function (n) {
  17928. // don't take the cameras or the controllers!
  17929. var isController = _this.controllers.some(function (controller) { return controller._mesh === n; });
  17930. var isRigCamera = _this._rigCameras.indexOf(n) !== -1;
  17931. return !isController && !isRigCamera;
  17932. });
  17933. _this._descendants.forEach(function (node) {
  17934. node.parent = camera;
  17935. });
  17936. }
  17937. });
  17938. scene.onAfterCameraRenderObservable.add(function (camera) {
  17939. if (camera.parent === _this && _this.rigParenting) {
  17940. _this._descendants.forEach(function (node) {
  17941. node.parent = _this;
  17942. });
  17943. }
  17944. });
  17945. return _this;
  17946. }
  17947. /**
  17948. * Gets the device distance from the ground in meters.
  17949. * @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.
  17950. */
  17951. WebVRFreeCamera.prototype.deviceDistanceToRoomGround = function () {
  17952. if (this._standingMatrix) {
  17953. // Add standing matrix offset to get real offset from ground in room
  17954. this._standingMatrix.getTranslationToRef(this._workingVector);
  17955. return this._deviceRoomPosition.y + this._workingVector.y;
  17956. }
  17957. //If VRDisplay does not inform stage parameters and no default height is set we fallback to zero.
  17958. return this._defaultHeight || 0;
  17959. };
  17960. /**
  17961. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  17962. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  17963. */
  17964. WebVRFreeCamera.prototype.useStandingMatrix = function (callback) {
  17965. var _this = this;
  17966. if (callback === void 0) { callback = function (bool) { }; }
  17967. // Use standing matrix if available
  17968. this.getEngine().initWebVRAsync().then(function (result) {
  17969. if (!result.vrDisplay || !result.vrDisplay.stageParameters || !result.vrDisplay.stageParameters.sittingToStandingTransform || !_this.webVROptions.trackPosition) {
  17970. callback(false);
  17971. }
  17972. else {
  17973. _this._standingMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  17974. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromFloat32ArrayToRefScaled(result.vrDisplay.stageParameters.sittingToStandingTransform, 0, 1, _this._standingMatrix);
  17975. if (!_this.getScene().useRightHandedSystem) {
  17976. if (_this._standingMatrix) {
  17977. _this._standingMatrix.toggleModelMatrixHandInPlace();
  17978. }
  17979. }
  17980. callback(true);
  17981. }
  17982. });
  17983. };
  17984. /**
  17985. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  17986. * @returns A promise with a boolean set to if the standing matrix is supported.
  17987. */
  17988. WebVRFreeCamera.prototype.useStandingMatrixAsync = function () {
  17989. var _this = this;
  17990. return new Promise(function (res) {
  17991. _this.useStandingMatrix(function (supported) {
  17992. res(supported);
  17993. });
  17994. });
  17995. };
  17996. /**
  17997. * Disposes the camera
  17998. */
  17999. WebVRFreeCamera.prototype.dispose = function () {
  18000. this._detachIfAttached();
  18001. this.getEngine().onVRRequestPresentComplete.removeCallback(this._onVREnabled);
  18002. if (this._updateCacheWhenTrackingDisabledObserver) {
  18003. this._scene.onBeforeRenderObservable.remove(this._updateCacheWhenTrackingDisabledObserver);
  18004. }
  18005. _super.prototype.dispose.call(this);
  18006. };
  18007. /**
  18008. * Gets a vrController by name.
  18009. * @param name The name of the controller to retreive
  18010. * @returns the controller matching the name specified or null if not found
  18011. */
  18012. WebVRFreeCamera.prototype.getControllerByName = function (name) {
  18013. for (var _i = 0, _a = this.controllers; _i < _a.length; _i++) {
  18014. var gp = _a[_i];
  18015. if (gp.hand === name) {
  18016. return gp;
  18017. }
  18018. }
  18019. return null;
  18020. };
  18021. Object.defineProperty(WebVRFreeCamera.prototype, "leftController", {
  18022. /**
  18023. * The controller corrisponding to the users left hand.
  18024. */
  18025. get: function () {
  18026. if (!this._leftController) {
  18027. this._leftController = this.getControllerByName("left");
  18028. }
  18029. return this._leftController;
  18030. },
  18031. enumerable: true,
  18032. configurable: true
  18033. });
  18034. Object.defineProperty(WebVRFreeCamera.prototype, "rightController", {
  18035. /**
  18036. * The controller corrisponding to the users right hand.
  18037. */
  18038. get: function () {
  18039. if (!this._rightController) {
  18040. this._rightController = this.getControllerByName("right");
  18041. }
  18042. return this._rightController;
  18043. },
  18044. enumerable: true,
  18045. configurable: true
  18046. });
  18047. /**
  18048. * Casts a ray forward from the vrCamera's gaze.
  18049. * @param length Length of the ray (default: 100)
  18050. * @returns the ray corrisponding to the gaze
  18051. */
  18052. WebVRFreeCamera.prototype.getForwardRay = function (length) {
  18053. if (length === void 0) { length = 100; }
  18054. if (this.leftCamera) {
  18055. // Use left eye to avoid computation to compute center on every call
  18056. return _super.prototype.getForwardRay.call(this, length, this.leftCamera.getWorldMatrix(), this.leftCamera.globalPosition); // Need the actual rendered camera
  18057. }
  18058. else {
  18059. return _super.prototype.getForwardRay.call(this, length);
  18060. }
  18061. };
  18062. /**
  18063. * @hidden
  18064. * Updates the camera based on device's frame data
  18065. */
  18066. WebVRFreeCamera.prototype._checkInputs = function () {
  18067. if (this._vrDevice && this._vrDevice.isPresenting) {
  18068. this._vrDevice.getFrameData(this._frameData);
  18069. this.updateFromDevice(this._frameData.pose);
  18070. }
  18071. _super.prototype._checkInputs.call(this);
  18072. };
  18073. /**
  18074. * Updates the poseControlled values based on the input device pose.
  18075. * @param poseData Pose coming from the device
  18076. */
  18077. WebVRFreeCamera.prototype.updateFromDevice = function (poseData) {
  18078. if (poseData && poseData.orientation) {
  18079. this.rawPose = poseData;
  18080. this._deviceRoomRotationQuaternion.copyFromFloats(poseData.orientation[0], poseData.orientation[1], -poseData.orientation[2], -poseData.orientation[3]);
  18081. if (this.getScene().useRightHandedSystem) {
  18082. this._deviceRoomRotationQuaternion.z *= -1;
  18083. this._deviceRoomRotationQuaternion.w *= -1;
  18084. }
  18085. if (this.webVROptions.trackPosition && this.rawPose.position) {
  18086. this._deviceRoomPosition.copyFromFloats(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2]);
  18087. if (this.getScene().useRightHandedSystem) {
  18088. this._deviceRoomPosition.z *= -1;
  18089. }
  18090. }
  18091. this._poseSet = true;
  18092. }
  18093. };
  18094. /**
  18095. * WebVR's attach control will start broadcasting frames to the device.
  18096. * Note that in certain browsers (chrome for example) this function must be called
  18097. * within a user-interaction callback. Example:
  18098. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  18099. *
  18100. * @param element html element to attach the vrDevice to
  18101. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  18102. */
  18103. WebVRFreeCamera.prototype.attachControl = function (element, noPreventDefault) {
  18104. _super.prototype.attachControl.call(this, element, noPreventDefault);
  18105. this._attached = true;
  18106. this._htmlElementAttached = element;
  18107. noPreventDefault = _Cameras_camera__WEBPACK_IMPORTED_MODULE_3__["Camera"].ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;
  18108. if (this._vrDevice) {
  18109. this.getEngine().enableVR();
  18110. }
  18111. window.addEventListener('vrdisplaypresentchange', this._detachIfAttached);
  18112. };
  18113. /**
  18114. * Detaches the camera from the html element and disables VR
  18115. *
  18116. * @param element html element to detach from
  18117. */
  18118. WebVRFreeCamera.prototype.detachControl = function (element) {
  18119. this.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  18120. this.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  18121. _super.prototype.detachControl.call(this, element);
  18122. this._attached = false;
  18123. this.getEngine().disableVR();
  18124. window.removeEventListener('vrdisplaypresentchange', this._detachIfAttached);
  18125. };
  18126. /**
  18127. * @returns the name of this class
  18128. */
  18129. WebVRFreeCamera.prototype.getClassName = function () {
  18130. return "WebVRFreeCamera";
  18131. };
  18132. /**
  18133. * Calls resetPose on the vrDisplay
  18134. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  18135. */
  18136. WebVRFreeCamera.prototype.resetToCurrentRotation = function () {
  18137. //uses the vrDisplay's "resetPose()".
  18138. //pitch and roll won't be affected.
  18139. this._vrDevice.resetPose();
  18140. };
  18141. /**
  18142. * @hidden
  18143. * Updates the rig cameras (left and right eye)
  18144. */
  18145. WebVRFreeCamera.prototype._updateRigCameras = function () {
  18146. var camLeft = this._rigCameras[0];
  18147. var camRight = this._rigCameras[1];
  18148. camLeft.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion);
  18149. camRight.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion);
  18150. camLeft.position.copyFrom(this._deviceRoomPosition);
  18151. camRight.position.copyFrom(this._deviceRoomPosition);
  18152. };
  18153. // Remove translation from 6dof headset if trackposition is set to false
  18154. WebVRFreeCamera.prototype._correctPositionIfNotTrackPosition = function (matrix, isViewMatrix) {
  18155. if (isViewMatrix === void 0) { isViewMatrix = false; }
  18156. if (this.rawPose && this.rawPose.position && !this.webVROptions.trackPosition) {
  18157. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].TranslationToRef(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2], this._tmpMatrix);
  18158. if (!isViewMatrix) {
  18159. this._tmpMatrix.invert();
  18160. }
  18161. this._tmpMatrix.multiplyToRef(matrix, matrix);
  18162. }
  18163. };
  18164. /**
  18165. * @hidden
  18166. * Updates the cached values of the camera
  18167. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  18168. */
  18169. WebVRFreeCamera.prototype._updateCache = function (ignoreParentClass) {
  18170. var _this = this;
  18171. if (!this.rotationQuaternion.equals(this._cache.rotationQuaternion) || !this.position.equals(this._cache.position)) {
  18172. // Update to ensure devicePosition is up to date with most recent _deviceRoomPosition
  18173. if (!this.updateCacheCalled) {
  18174. // make sure it is only called once per loop. this.update() might cause an infinite loop.
  18175. this.updateCacheCalled = true;
  18176. this.update();
  18177. }
  18178. // Set working vector to the device position in room space rotated by the new rotation
  18179. this.rotationQuaternion.toRotationMatrix(this._workingMatrix);
  18180. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._deviceRoomPosition, this._workingMatrix, this._workingVector);
  18181. // Subtract this vector from the current device position in world to get the translation for the device world matrix
  18182. this.devicePosition.subtractToRef(this._workingVector, this._workingVector);
  18183. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].ComposeToRef(this._oneVector, this.rotationQuaternion, this._workingVector, this._deviceToWorld);
  18184. // Add translation from anchor position
  18185. this._deviceToWorld.getTranslationToRef(this._workingVector);
  18186. this._workingVector.addInPlace(this.position);
  18187. this._workingVector.subtractInPlace(this._cache.position);
  18188. this._deviceToWorld.setTranslation(this._workingVector);
  18189. // Set an inverted matrix to be used when updating the camera
  18190. this._deviceToWorld.invertToRef(this._worldToDevice);
  18191. // Update the gamepad to ensure the mesh is updated on the same frame as camera
  18192. this.controllers.forEach(function (controller) {
  18193. controller._deviceToWorld.copyFrom(_this._deviceToWorld);
  18194. _this._correctPositionIfNotTrackPosition(controller._deviceToWorld);
  18195. controller.update();
  18196. });
  18197. }
  18198. if (!ignoreParentClass) {
  18199. _super.prototype._updateCache.call(this);
  18200. }
  18201. this.updateCacheCalled = false;
  18202. };
  18203. /**
  18204. * @hidden
  18205. * Get current device position in babylon world
  18206. */
  18207. WebVRFreeCamera.prototype._computeDevicePosition = function () {
  18208. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._deviceRoomPosition, this._deviceToWorld, this.devicePosition);
  18209. };
  18210. /**
  18211. * Updates the current device position and rotation in the babylon world
  18212. */
  18213. WebVRFreeCamera.prototype.update = function () {
  18214. this._computeDevicePosition();
  18215. // Get current device rotation in babylon world
  18216. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromQuaternionToRef(this._deviceRoomRotationQuaternion, this._workingMatrix);
  18217. this._workingMatrix.multiplyToRef(this._deviceToWorld, this._workingMatrix);
  18218. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion);
  18219. if (this._poseSet) {
  18220. this.onPoseUpdatedFromDeviceObservable.notifyObservers(null);
  18221. }
  18222. _super.prototype.update.call(this);
  18223. };
  18224. /**
  18225. * @hidden
  18226. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  18227. * @returns an identity matrix
  18228. */
  18229. WebVRFreeCamera.prototype._getViewMatrix = function () {
  18230. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  18231. };
  18232. /**
  18233. * This function is called by the two RIG cameras.
  18234. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  18235. * @hidden
  18236. */
  18237. WebVRFreeCamera.prototype._getWebVRViewMatrix = function () {
  18238. // Update the parent camera prior to using a child camera to avoid desynchronization
  18239. var parentCamera = this._cameraRigParams["parentCamera"];
  18240. parentCamera._updateCache();
  18241. //WebVR 1.1
  18242. var viewArray = this._cameraRigParams["left"] ? this._cameraRigParams["frameData"].leftViewMatrix : this._cameraRigParams["frameData"].rightViewMatrix;
  18243. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArrayToRef(viewArray, 0, this._webvrViewMatrix);
  18244. if (!this.getScene().useRightHandedSystem) {
  18245. this._webvrViewMatrix.toggleModelMatrixHandInPlace();
  18246. }
  18247. // update the camera rotation matrix
  18248. this._webvrViewMatrix.getRotationMatrixToRef(this._cameraRotationMatrix);
  18249. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
  18250. // Computing target and final matrix
  18251. this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
  18252. // should the view matrix be updated with scale and position offset?
  18253. if (parentCamera.deviceScaleFactor !== 1) {
  18254. this._webvrViewMatrix.invert();
  18255. // scale the position, if set
  18256. if (parentCamera.deviceScaleFactor) {
  18257. this._webvrViewMatrix.multiplyAtIndex(12, parentCamera.deviceScaleFactor);
  18258. this._webvrViewMatrix.multiplyAtIndex(13, parentCamera.deviceScaleFactor);
  18259. this._webvrViewMatrix.multiplyAtIndex(14, parentCamera.deviceScaleFactor);
  18260. }
  18261. this._webvrViewMatrix.invert();
  18262. }
  18263. // Remove translation from 6dof headset if trackposition is set to false
  18264. parentCamera._correctPositionIfNotTrackPosition(this._webvrViewMatrix, true);
  18265. parentCamera._worldToDevice.multiplyToRef(this._webvrViewMatrix, this._webvrViewMatrix);
  18266. // Compute global position
  18267. this._workingMatrix = this._workingMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  18268. this._webvrViewMatrix.invertToRef(this._workingMatrix);
  18269. this._workingMatrix.multiplyToRef(parentCamera.getWorldMatrix(), this._workingMatrix);
  18270. this._workingMatrix.getTranslationToRef(this._globalPosition);
  18271. this._markSyncedWithParent();
  18272. return this._webvrViewMatrix;
  18273. };
  18274. /** @hidden */
  18275. WebVRFreeCamera.prototype._getWebVRProjectionMatrix = function () {
  18276. var parentCamera = this.parent;
  18277. parentCamera._vrDevice.depthNear = parentCamera.minZ;
  18278. parentCamera._vrDevice.depthFar = parentCamera.maxZ;
  18279. var projectionArray = this._cameraRigParams["left"] ? this._cameraRigParams["frameData"].leftProjectionMatrix : this._cameraRigParams["frameData"].rightProjectionMatrix;
  18280. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArrayToRef(projectionArray, 0, this._projectionMatrix);
  18281. //babylon compatible matrix
  18282. if (!this.getScene().useRightHandedSystem) {
  18283. this._projectionMatrix.toggleProjectionMatrixHandInPlace();
  18284. }
  18285. return this._projectionMatrix;
  18286. };
  18287. /**
  18288. * Initializes the controllers and their meshes
  18289. */
  18290. WebVRFreeCamera.prototype.initControllers = function () {
  18291. var _this = this;
  18292. this.controllers = [];
  18293. var manager = this.getScene().gamepadManager;
  18294. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  18295. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED) {
  18296. var webVrController = gamepad;
  18297. if (webVrController.defaultModel) {
  18298. webVrController.defaultModel.setEnabled(false);
  18299. }
  18300. if (webVrController.hand === "right") {
  18301. _this._rightController = null;
  18302. }
  18303. if (webVrController.hand === "left") {
  18304. _this._leftController = null;
  18305. }
  18306. var controllerIndex = _this.controllers.indexOf(webVrController);
  18307. if (controllerIndex !== -1) {
  18308. _this.controllers.splice(controllerIndex, 1);
  18309. }
  18310. }
  18311. });
  18312. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  18313. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED) {
  18314. var webVrController_1 = gamepad;
  18315. if (!_this.webVROptions.trackPosition) {
  18316. webVrController_1._disableTrackPosition(new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](webVrController_1.hand == "left" ? -0.15 : 0.15, -0.5, 0.25));
  18317. // Cache must be updated before rendering controllers to avoid them being one frame behind
  18318. if (!_this._updateCacheWhenTrackingDisabledObserver) {
  18319. _this._updateCacheWhenTrackingDisabledObserver = _this._scene.onBeforeRenderObservable.add(function () {
  18320. _this._updateCache();
  18321. });
  18322. }
  18323. }
  18324. webVrController_1.deviceScaleFactor = _this.deviceScaleFactor;
  18325. webVrController_1._deviceToWorld.copyFrom(_this._deviceToWorld);
  18326. _this._correctPositionIfNotTrackPosition(webVrController_1._deviceToWorld);
  18327. if (_this.webVROptions.controllerMeshes) {
  18328. if (webVrController_1.defaultModel) {
  18329. webVrController_1.defaultModel.setEnabled(true);
  18330. }
  18331. else {
  18332. // Load the meshes
  18333. webVrController_1.initControllerMesh(_this.getScene(), function (loadedMesh) {
  18334. loadedMesh.scaling.scaleInPlace(_this.deviceScaleFactor);
  18335. _this.onControllerMeshLoadedObservable.notifyObservers(webVrController_1);
  18336. if (_this.webVROptions.defaultLightingOnControllers) {
  18337. if (!_this._lightOnControllers) {
  18338. _this._lightOnControllers = new _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_8__["HemisphericLight"]("vrControllersLight", new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 1, 0), _this.getScene());
  18339. }
  18340. var activateLightOnSubMeshes_1 = function (mesh, light) {
  18341. var children = mesh.getChildren();
  18342. if (children && children.length !== 0) {
  18343. children.forEach(function (mesh) {
  18344. light.includedOnlyMeshes.push(mesh);
  18345. activateLightOnSubMeshes_1(mesh, light);
  18346. });
  18347. }
  18348. };
  18349. _this._lightOnControllers.includedOnlyMeshes.push(loadedMesh);
  18350. activateLightOnSubMeshes_1(loadedMesh, _this._lightOnControllers);
  18351. }
  18352. });
  18353. }
  18354. }
  18355. webVrController_1.attachToPoseControlledCamera(_this);
  18356. // since this is async - sanity check. Is the controller already stored?
  18357. if (_this.controllers.indexOf(webVrController_1) === -1) {
  18358. //add to the controllers array
  18359. _this.controllers.push(webVrController_1);
  18360. // Forced to add some control code for Vive as it doesn't always fill properly the "hand" property
  18361. // Sometimes, both controllers are set correctly (left and right), sometimes none, sometimes only one of them...
  18362. // So we're overriding setting left & right manually to be sure
  18363. var firstViveWandDetected = false;
  18364. for (var i = 0; i < _this.controllers.length; i++) {
  18365. if (_this.controllers[i].controllerType === _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_6__["PoseEnabledControllerType"].VIVE) {
  18366. if (!firstViveWandDetected) {
  18367. firstViveWandDetected = true;
  18368. _this.controllers[i].hand = "left";
  18369. }
  18370. else {
  18371. _this.controllers[i].hand = "right";
  18372. }
  18373. }
  18374. }
  18375. //did we find enough controllers? Great! let the developer know.
  18376. if (_this.controllers.length >= 2) {
  18377. _this.onControllersAttachedObservable.notifyObservers(_this.controllers);
  18378. }
  18379. }
  18380. }
  18381. });
  18382. };
  18383. return WebVRFreeCamera;
  18384. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  18385. /***/ }),
  18386. /***/ "./Cameras/XR/index.ts":
  18387. /*!*****************************!*\
  18388. !*** ./Cameras/XR/index.ts ***!
  18389. \*****************************/
  18390. /*! exports provided: WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager */
  18391. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18392. "use strict";
  18393. __webpack_require__.r(__webpack_exports__);
  18394. /* harmony import */ var _webXRCamera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webXRCamera */ "./Cameras/XR/webXRCamera.ts");
  18395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _webXRCamera__WEBPACK_IMPORTED_MODULE_0__["WebXRCamera"]; });
  18396. /* harmony import */ var _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./webXREnterExitUI */ "./Cameras/XR/webXREnterExitUI.ts");
  18397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUIButton"]; });
  18398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUIOptions"]; });
  18399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUI"]; });
  18400. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  18401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"]; });
  18402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRExperienceHelper"]; });
  18403. /* harmony import */ var _webXRInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webXRInput */ "./Cameras/XR/webXRInput.ts");
  18404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _webXRInput__WEBPACK_IMPORTED_MODULE_3__["WebXRController"]; });
  18405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _webXRInput__WEBPACK_IMPORTED_MODULE_3__["WebXRInput"]; });
  18406. /* harmony import */ var _webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webXRManagedOutputCanvas */ "./Cameras/XR/webXRManagedOutputCanvas.ts");
  18407. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_4__["WebXRManagedOutputCanvas"]; });
  18408. /* harmony import */ var _webXRSessionManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./webXRSessionManager */ "./Cameras/XR/webXRSessionManager.ts");
  18409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _webXRSessionManager__WEBPACK_IMPORTED_MODULE_5__["WebXRSessionManager"]; });
  18410. /***/ }),
  18411. /***/ "./Cameras/XR/webXRCamera.ts":
  18412. /*!***********************************!*\
  18413. !*** ./Cameras/XR/webXRCamera.ts ***!
  18414. \***********************************/
  18415. /*! exports provided: WebXRCamera */
  18416. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18417. "use strict";
  18418. __webpack_require__.r(__webpack_exports__);
  18419. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return WebXRCamera; });
  18420. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  18421. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18422. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  18423. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  18424. /* harmony import */ var _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Cameras/targetCamera */ "./Cameras/targetCamera.ts");
  18425. /**
  18426. * WebXR Camera which holds the views for the xrSession
  18427. * @see https://doc.babylonjs.com/how_to/webxr
  18428. */
  18429. var WebXRCamera = /** @class */ (function (_super) {
  18430. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebXRCamera, _super);
  18431. /**
  18432. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  18433. * @param name the name of the camera
  18434. * @param scene the scene to add the camera to
  18435. */
  18436. function WebXRCamera(name, scene) {
  18437. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), scene) || this;
  18438. // Initial camera configuration
  18439. _this.minZ = 0;
  18440. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  18441. _this.cameraRigMode = _Cameras_camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_CUSTOM;
  18442. _this.updateUpVectorFromRotation = true;
  18443. _this._updateNumberOfRigCameras(1);
  18444. return _this;
  18445. }
  18446. WebXRCamera.prototype._updateNumberOfRigCameras = function (viewCount) {
  18447. if (viewCount === void 0) { viewCount = 1; }
  18448. while (this.rigCameras.length < viewCount) {
  18449. var newCamera = new _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]("view: " + this.rigCameras.length, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), this.getScene());
  18450. newCamera.minZ = 0;
  18451. newCamera.parent = this;
  18452. newCamera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  18453. newCamera.updateUpVectorFromRotation = true;
  18454. this.rigCameras.push(newCamera);
  18455. }
  18456. while (this.rigCameras.length > viewCount) {
  18457. var removedCamera = this.rigCameras.pop();
  18458. if (removedCamera) {
  18459. removedCamera.dispose();
  18460. }
  18461. }
  18462. };
  18463. /** @hidden */
  18464. WebXRCamera.prototype._updateForDualEyeDebugging = function (pupilDistance) {
  18465. if (pupilDistance === void 0) { pupilDistance = 0.01; }
  18466. // Create initial camera rigs
  18467. this._updateNumberOfRigCameras(2);
  18468. this.rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  18469. this.rigCameras[0].position.x = -pupilDistance / 2;
  18470. this.rigCameras[0].outputRenderTarget = null;
  18471. this.rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  18472. this.rigCameras[1].position.x = pupilDistance / 2;
  18473. this.rigCameras[1].outputRenderTarget = null;
  18474. };
  18475. /**
  18476. * Updates the cameras position from the current pose information of the XR session
  18477. * @param xrSessionManager the session containing pose information
  18478. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  18479. */
  18480. WebXRCamera.prototype.updateFromXRSessionManager = function (xrSessionManager) {
  18481. var _this = this;
  18482. // Ensure all frame data is available
  18483. if (!xrSessionManager._currentXRFrame || !xrSessionManager._currentXRFrame.getDevicePose) {
  18484. return false;
  18485. }
  18486. var pose = xrSessionManager._currentXRFrame.getDevicePose(xrSessionManager._frameOfReference);
  18487. if (!pose || !pose.poseModelMatrix) {
  18488. return false;
  18489. }
  18490. // Update the parent cameras matrix
  18491. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(pose.poseModelMatrix, 0, 1, WebXRCamera._TmpMatrix);
  18492. if (!this._scene.useRightHandedSystem) {
  18493. WebXRCamera._TmpMatrix.toggleModelMatrixHandInPlace();
  18494. }
  18495. WebXRCamera._TmpMatrix.getTranslationToRef(this.position);
  18496. WebXRCamera._TmpMatrix.getRotationMatrixToRef(WebXRCamera._TmpMatrix);
  18497. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(WebXRCamera._TmpMatrix, this.rotationQuaternion);
  18498. this.computeWorldMatrix();
  18499. // Update camera rigs
  18500. this._updateNumberOfRigCameras(xrSessionManager._currentXRFrame.views.length);
  18501. xrSessionManager._currentXRFrame.views.forEach(function (view, i) {
  18502. // Update view/projection matrix
  18503. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(pose.getViewMatrix(view), 0, 1, _this.rigCameras[i]._computedViewMatrix);
  18504. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(view.projectionMatrix, 0, 1, _this.rigCameras[i]._projectionMatrix);
  18505. if (!_this._scene.useRightHandedSystem) {
  18506. _this.rigCameras[i]._computedViewMatrix.toggleModelMatrixHandInPlace();
  18507. _this.rigCameras[i]._projectionMatrix.toggleProjectionMatrixHandInPlace();
  18508. }
  18509. // Update viewport
  18510. var viewport = xrSessionManager._xrSession.baseLayer.getViewport(view);
  18511. var width = xrSessionManager._xrSession.baseLayer.framebufferWidth;
  18512. var height = xrSessionManager._xrSession.baseLayer.framebufferHeight;
  18513. _this.rigCameras[i].viewport.width = viewport.width / width;
  18514. _this.rigCameras[i].viewport.height = viewport.height / height;
  18515. _this.rigCameras[i].viewport.x = viewport.x / width;
  18516. _this.rigCameras[i].viewport.y = viewport.y / height;
  18517. // Set cameras to render to the session's render target
  18518. _this.rigCameras[i].outputRenderTarget = xrSessionManager._sessionRenderTargetTexture;
  18519. });
  18520. return true;
  18521. };
  18522. WebXRCamera._TmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  18523. return WebXRCamera;
  18524. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"]));
  18525. /***/ }),
  18526. /***/ "./Cameras/XR/webXREnterExitUI.ts":
  18527. /*!****************************************!*\
  18528. !*** ./Cameras/XR/webXREnterExitUI.ts ***!
  18529. \****************************************/
  18530. /*! exports provided: WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI */
  18531. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18532. "use strict";
  18533. __webpack_require__.r(__webpack_exports__);
  18534. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return WebXREnterExitUIButton; });
  18535. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return WebXREnterExitUIOptions; });
  18536. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return WebXREnterExitUI; });
  18537. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  18538. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  18539. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  18540. /**
  18541. * Button which can be used to enter a different mode of XR
  18542. */
  18543. var WebXREnterExitUIButton = /** @class */ (function () {
  18544. /**
  18545. * Creates a WebXREnterExitUIButton
  18546. * @param element button element
  18547. * @param initializationOptions XR initialization options for the button
  18548. */
  18549. function WebXREnterExitUIButton(
  18550. /** button element */
  18551. element,
  18552. /** XR initialization options for the button */
  18553. initializationOptions) {
  18554. this.element = element;
  18555. this.initializationOptions = initializationOptions;
  18556. }
  18557. /**
  18558. * Overwritable function which can be used to update the button's visuals when the state changes
  18559. * @param activeButton the current active button in the UI
  18560. */
  18561. WebXREnterExitUIButton.prototype.update = function (activeButton) {
  18562. };
  18563. return WebXREnterExitUIButton;
  18564. }());
  18565. /**
  18566. * Options to create the webXR UI
  18567. */
  18568. var WebXREnterExitUIOptions = /** @class */ (function () {
  18569. function WebXREnterExitUIOptions() {
  18570. }
  18571. return WebXREnterExitUIOptions;
  18572. }());
  18573. /**
  18574. * UI to allow the user to enter/exit XR mode
  18575. */
  18576. var WebXREnterExitUI = /** @class */ (function () {
  18577. function WebXREnterExitUI(scene, options) {
  18578. var _this = this;
  18579. this.scene = scene;
  18580. this._buttons = [];
  18581. this._activeButton = null;
  18582. /**
  18583. * Fired every time the active button is changed.
  18584. *
  18585. * When xr is entered via a button that launches xr that button will be the callback parameter
  18586. *
  18587. * When exiting xr the callback parameter will be null)
  18588. */
  18589. this.activeButtonChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  18590. this._overlay = document.createElement("div");
  18591. this._overlay.style.cssText = "z-index:11;position: absolute; right: 20px;bottom: 50px;";
  18592. if (options.customButtons) {
  18593. this._buttons = options.customButtons;
  18594. }
  18595. else {
  18596. var hmdBtn = document.createElement("button");
  18597. 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;";
  18598. hmdBtn.innerText = "HMD";
  18599. this._buttons.push(new WebXREnterExitUIButton(hmdBtn, { immersive: true, outputContext: options.outputCanvasContext }));
  18600. this._buttons[this._buttons.length - 1].update = function (activeButton) {
  18601. this.element.style.display = (activeButton === null || activeButton === this) ? "" : "none";
  18602. this.element.innerText = activeButton === this ? "EXIT" : "HMD";
  18603. };
  18604. var windowBtn = document.createElement("button");
  18605. windowBtn.style.cssText = hmdBtn.style.cssText;
  18606. windowBtn.innerText = "Window";
  18607. this._buttons.push(new WebXREnterExitUIButton(windowBtn, { immersive: false, environmentIntegration: true, outputContext: options.outputCanvasContext }));
  18608. this._buttons[this._buttons.length - 1].update = function (activeButton) {
  18609. this.element.style.display = (activeButton === null || activeButton === this) ? "" : "none";
  18610. this.element.innerText = activeButton === this ? "EXIT" : "Window";
  18611. };
  18612. this._updateButtons(null);
  18613. }
  18614. var renderCanvas = scene.getEngine().getRenderingCanvas();
  18615. if (renderCanvas && renderCanvas.parentNode) {
  18616. renderCanvas.parentNode.appendChild(this._overlay);
  18617. scene.onDisposeObservable.addOnce(function () {
  18618. _this.dispose();
  18619. });
  18620. }
  18621. }
  18622. /**
  18623. * Creates UI to allow the user to enter/exit XR mode
  18624. * @param scene the scene to add the ui to
  18625. * @param helper the xr experience helper to enter/exit xr with
  18626. * @param options options to configure the UI
  18627. * @returns the created ui
  18628. */
  18629. WebXREnterExitUI.CreateAsync = function (scene, helper, options) {
  18630. var _this = this;
  18631. var ui = new WebXREnterExitUI(scene, options);
  18632. var supportedPromises = ui._buttons.map(function (btn) {
  18633. return helper.supportsSessionAsync(btn.initializationOptions);
  18634. });
  18635. helper.onStateChangedObservable.add(function (state) {
  18636. if (state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].NOT_IN_XR) {
  18637. ui._updateButtons(null);
  18638. }
  18639. });
  18640. return Promise.all(supportedPromises).then(function (results) {
  18641. results.forEach(function (supported, i) {
  18642. if (supported) {
  18643. ui._overlay.appendChild(ui._buttons[i].element);
  18644. ui._buttons[i].element.onclick = function () { return tslib__WEBPACK_IMPORTED_MODULE_0__["__awaiter"](_this, void 0, void 0, function () {
  18645. return tslib__WEBPACK_IMPORTED_MODULE_0__["__generator"](this, function (_a) {
  18646. switch (_a.label) {
  18647. case 0:
  18648. if (!(helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].IN_XR)) return [3 /*break*/, 2];
  18649. ui._updateButtons(null);
  18650. return [4 /*yield*/, helper.exitXRAsync()];
  18651. case 1:
  18652. _a.sent();
  18653. return [2 /*return*/];
  18654. case 2:
  18655. if (!(helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].NOT_IN_XR)) return [3 /*break*/, 4];
  18656. ui._updateButtons(ui._buttons[i]);
  18657. return [4 /*yield*/, helper.enterXRAsync(ui._buttons[i].initializationOptions, "eye-level")];
  18658. case 3:
  18659. _a.sent();
  18660. _a.label = 4;
  18661. case 4: return [2 /*return*/];
  18662. }
  18663. });
  18664. }); };
  18665. }
  18666. });
  18667. return ui;
  18668. });
  18669. };
  18670. WebXREnterExitUI.prototype._updateButtons = function (activeButton) {
  18671. var _this = this;
  18672. this._activeButton = activeButton;
  18673. this._buttons.forEach(function (b) {
  18674. b.update(_this._activeButton);
  18675. });
  18676. this.activeButtonChangedObservable.notifyObservers(this._activeButton);
  18677. };
  18678. /**
  18679. * Disposes of the object
  18680. */
  18681. WebXREnterExitUI.prototype.dispose = function () {
  18682. var renderCanvas = this.scene.getEngine().getRenderingCanvas();
  18683. if (renderCanvas && renderCanvas.parentNode && renderCanvas.parentNode.contains(this._overlay)) {
  18684. renderCanvas.parentNode.removeChild(this._overlay);
  18685. }
  18686. this.activeButtonChangedObservable.clear();
  18687. };
  18688. return WebXREnterExitUI;
  18689. }());
  18690. /***/ }),
  18691. /***/ "./Cameras/XR/webXRExperienceHelper.ts":
  18692. /*!*********************************************!*\
  18693. !*** ./Cameras/XR/webXRExperienceHelper.ts ***!
  18694. \*********************************************/
  18695. /*! exports provided: WebXRState, WebXRExperienceHelper */
  18696. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18697. "use strict";
  18698. __webpack_require__.r(__webpack_exports__);
  18699. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return WebXRState; });
  18700. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return WebXRExperienceHelper; });
  18701. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  18702. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18703. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  18704. /* harmony import */ var _webXRSessionManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webXRSessionManager */ "./Cameras/XR/webXRSessionManager.ts");
  18705. /* harmony import */ var _webXRCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webXRCamera */ "./Cameras/XR/webXRCamera.ts");
  18706. /**
  18707. * States of the webXR experience
  18708. */
  18709. var WebXRState;
  18710. (function (WebXRState) {
  18711. /**
  18712. * Transitioning to being in XR mode
  18713. */
  18714. WebXRState[WebXRState["ENTERING_XR"] = 0] = "ENTERING_XR";
  18715. /**
  18716. * Transitioning to non XR mode
  18717. */
  18718. WebXRState[WebXRState["EXITING_XR"] = 1] = "EXITING_XR";
  18719. /**
  18720. * In XR mode and presenting
  18721. */
  18722. WebXRState[WebXRState["IN_XR"] = 2] = "IN_XR";
  18723. /**
  18724. * Not entered XR mode
  18725. */
  18726. WebXRState[WebXRState["NOT_IN_XR"] = 3] = "NOT_IN_XR";
  18727. })(WebXRState || (WebXRState = {}));
  18728. /**
  18729. * Helper class used to enable XR
  18730. * @see https://doc.babylonjs.com/how_to/webxr
  18731. */
  18732. var WebXRExperienceHelper = /** @class */ (function () {
  18733. /**
  18734. * Creates a WebXRExperienceHelper
  18735. * @param scene The scene the helper should be created in
  18736. */
  18737. function WebXRExperienceHelper(scene) {
  18738. this.scene = scene;
  18739. /**
  18740. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  18741. */
  18742. this.state = WebXRState.NOT_IN_XR;
  18743. /**
  18744. * Fires when the state of the experience helper has changed
  18745. */
  18746. this.onStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  18747. this._nonVRCamera = null;
  18748. this._originalSceneAutoClear = true;
  18749. this._supported = false;
  18750. this.camera = new _webXRCamera__WEBPACK_IMPORTED_MODULE_4__["WebXRCamera"]("", scene);
  18751. this._sessionManager = new _webXRSessionManager__WEBPACK_IMPORTED_MODULE_3__["WebXRSessionManager"](scene);
  18752. this.container = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]("", scene);
  18753. this.camera.parent = this.container;
  18754. }
  18755. WebXRExperienceHelper.prototype._setState = function (val) {
  18756. this.state = val;
  18757. this.onStateChangedObservable.notifyObservers(this.state);
  18758. };
  18759. /**
  18760. * Creates the experience helper
  18761. * @param scene the scene to attach the experience helper to
  18762. * @returns a promise for the experience helper
  18763. */
  18764. WebXRExperienceHelper.CreateAsync = function (scene) {
  18765. var helper = new WebXRExperienceHelper(scene);
  18766. return helper._sessionManager.initializeAsync().then(function () {
  18767. helper._supported = true;
  18768. return helper;
  18769. }).catch(function () {
  18770. return helper;
  18771. });
  18772. };
  18773. /**
  18774. * Exits XR mode and returns the scene to its original state
  18775. * @returns promise that resolves after xr mode has exited
  18776. */
  18777. WebXRExperienceHelper.prototype.exitXRAsync = function () {
  18778. this._setState(WebXRState.EXITING_XR);
  18779. return this._sessionManager.exitXRAsync();
  18780. };
  18781. /**
  18782. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  18783. * @param sessionCreationOptions options for the XR session
  18784. * @param frameOfReference frame of reference of the XR session
  18785. * @returns promise that resolves after xr mode has entered
  18786. */
  18787. WebXRExperienceHelper.prototype.enterXRAsync = function (sessionCreationOptions, frameOfReference) {
  18788. var _this = this;
  18789. if (!this._supported) {
  18790. throw "XR session not supported by this browser";
  18791. }
  18792. this._setState(WebXRState.ENTERING_XR);
  18793. return this._sessionManager.enterXRAsync(sessionCreationOptions, frameOfReference).then(function () {
  18794. // Cache pre xr scene settings
  18795. _this._originalSceneAutoClear = _this.scene.autoClear;
  18796. _this._nonVRCamera = _this.scene.activeCamera;
  18797. // Overwrite current scene settings
  18798. _this.scene.autoClear = false;
  18799. _this.scene.activeCamera = _this.camera;
  18800. _this._sessionManager.onXRFrameObservable.add(function () {
  18801. _this.camera.updateFromXRSessionManager(_this._sessionManager);
  18802. });
  18803. _this._sessionManager.onXRSessionEnded.addOnce(function () {
  18804. // Reset camera rigs output render target to ensure sessions render target is not drawn after it ends
  18805. _this.camera.rigCameras.forEach(function (c) {
  18806. c.outputRenderTarget = null;
  18807. });
  18808. // Restore scene settings
  18809. _this.scene.autoClear = _this._originalSceneAutoClear;
  18810. _this.scene.activeCamera = _this._nonVRCamera;
  18811. _this._sessionManager.onXRFrameObservable.clear();
  18812. _this._setState(WebXRState.NOT_IN_XR);
  18813. });
  18814. _this._setState(WebXRState.IN_XR);
  18815. });
  18816. };
  18817. /**
  18818. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  18819. * @param ray ray to cast into the environment
  18820. * @returns Promise which resolves with a collision point in the environment if it exists
  18821. */
  18822. WebXRExperienceHelper.prototype.environmentPointHitTestAsync = function (ray) {
  18823. return this._sessionManager.environmentPointHitTestAsync(ray);
  18824. };
  18825. /**
  18826. * Updates the global position of the camera by moving the camera's container
  18827. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  18828. * @param position The desired global position of the camera
  18829. */
  18830. WebXRExperienceHelper.prototype.setPositionOfCameraUsingContainer = function (position) {
  18831. this.camera.globalPosition.subtractToRef(position, WebXRExperienceHelper._TmpVector);
  18832. this.container.position.subtractInPlace(WebXRExperienceHelper._TmpVector);
  18833. };
  18834. /**
  18835. * Rotates the xr camera by rotating the camera's container around the camera's position
  18836. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  18837. * @param rotation the desired quaternion rotation to apply to the camera
  18838. */
  18839. WebXRExperienceHelper.prototype.rotateCameraByQuaternionUsingContainer = function (rotation) {
  18840. if (!this.container.rotationQuaternion) {
  18841. this.container.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromEulerVector(this.container.rotation);
  18842. }
  18843. this.container.rotationQuaternion.multiplyInPlace(rotation);
  18844. this.container.position.rotateByQuaternionAroundPointToRef(rotation, this.camera.globalPosition, this.container.position);
  18845. };
  18846. /**
  18847. * Checks if the creation options are supported by the xr session
  18848. * @param options creation options
  18849. * @returns true if supported
  18850. */
  18851. WebXRExperienceHelper.prototype.supportsSessionAsync = function (options) {
  18852. if (!this._supported) {
  18853. return Promise.resolve(false);
  18854. }
  18855. return this._sessionManager.supportsSessionAsync(options);
  18856. };
  18857. /**
  18858. * Disposes of the experience helper
  18859. */
  18860. WebXRExperienceHelper.prototype.dispose = function () {
  18861. this.camera.dispose();
  18862. this.container.dispose();
  18863. this.onStateChangedObservable.clear();
  18864. this._sessionManager.dispose();
  18865. };
  18866. WebXRExperienceHelper._TmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]();
  18867. return WebXRExperienceHelper;
  18868. }());
  18869. /***/ }),
  18870. /***/ "./Cameras/XR/webXRInput.ts":
  18871. /*!**********************************!*\
  18872. !*** ./Cameras/XR/webXRInput.ts ***!
  18873. \**********************************/
  18874. /*! exports provided: WebXRController, WebXRInput */
  18875. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18876. "use strict";
  18877. __webpack_require__.r(__webpack_exports__);
  18878. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return WebXRController; });
  18879. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return WebXRInput; });
  18880. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18881. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  18882. /**
  18883. * Represents an XR input
  18884. */
  18885. var WebXRController = /** @class */ (function () {
  18886. /**
  18887. * Creates the controller
  18888. * @see https://doc.babylonjs.com/how_to/webxr
  18889. * @param scene the scene which the controller should be associated to
  18890. */
  18891. function WebXRController(scene) {
  18892. this.pointer = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("controllerPointer", scene);
  18893. }
  18894. /**
  18895. * Disposes of the object
  18896. */
  18897. WebXRController.prototype.dispose = function () {
  18898. if (this.grip) {
  18899. this.grip.dispose();
  18900. }
  18901. this.pointer.dispose();
  18902. };
  18903. return WebXRController;
  18904. }());
  18905. /**
  18906. * XR input used to track XR inputs such as controllers/rays
  18907. */
  18908. var WebXRInput = /** @class */ (function () {
  18909. /**
  18910. * Initializes the WebXRInput
  18911. * @param helper experience helper which the input should be created for
  18912. */
  18913. function WebXRInput(helper) {
  18914. var _this = this;
  18915. this.helper = helper;
  18916. /**
  18917. * XR controllers being tracked
  18918. */
  18919. this.controllers = [];
  18920. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  18921. this._frameObserver = helper._sessionManager.onXRFrameObservable.add(function () {
  18922. if (!helper._sessionManager._currentXRFrame || !helper._sessionManager._currentXRFrame.getDevicePose) {
  18923. return;
  18924. }
  18925. var xrFrame = helper._sessionManager._currentXRFrame;
  18926. var inputSources = helper._sessionManager._xrSession.getInputSources();
  18927. inputSources.forEach(function (input, i) {
  18928. var inputPose = xrFrame.getInputPose(input, helper._sessionManager._frameOfReference);
  18929. if (inputPose) {
  18930. if (_this.controllers.length <= i) {
  18931. _this.controllers.push(new WebXRController(helper.container.getScene()));
  18932. }
  18933. var controller = _this.controllers[i];
  18934. // Manage the grip if it exists
  18935. if (inputPose.gripMatrix) {
  18936. if (!controller.grip) {
  18937. controller.grip = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("controllerGrip", helper.container.getScene());
  18938. }
  18939. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromFloat32ArrayToRefScaled(inputPose.gripMatrix, 0, 1, _this._tmpMatrix);
  18940. if (!controller.grip.getScene().useRightHandedSystem) {
  18941. _this._tmpMatrix.toggleModelMatrixHandInPlace();
  18942. }
  18943. if (!controller.grip.rotationQuaternion) {
  18944. controller.grip.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  18945. }
  18946. _this._tmpMatrix.decompose(controller.grip.scaling, controller.grip.rotationQuaternion, controller.grip.position);
  18947. }
  18948. // Manager pointer of controller
  18949. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromFloat32ArrayToRefScaled(inputPose.targetRay.transformMatrix, 0, 1, _this._tmpMatrix);
  18950. if (!controller.pointer.getScene().useRightHandedSystem) {
  18951. _this._tmpMatrix.toggleModelMatrixHandInPlace();
  18952. }
  18953. if (!controller.pointer.rotationQuaternion) {
  18954. controller.pointer.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  18955. }
  18956. _this._tmpMatrix.decompose(controller.pointer.scaling, controller.pointer.rotationQuaternion, controller.pointer.position);
  18957. }
  18958. });
  18959. });
  18960. }
  18961. /**
  18962. * Disposes of the object
  18963. */
  18964. WebXRInput.prototype.dispose = function () {
  18965. this.controllers.forEach(function (c) {
  18966. c.dispose();
  18967. });
  18968. this.helper._sessionManager.onXRFrameObservable.remove(this._frameObserver);
  18969. };
  18970. return WebXRInput;
  18971. }());
  18972. /***/ }),
  18973. /***/ "./Cameras/XR/webXRManagedOutputCanvas.ts":
  18974. /*!************************************************!*\
  18975. !*** ./Cameras/XR/webXRManagedOutputCanvas.ts ***!
  18976. \************************************************/
  18977. /*! exports provided: WebXRManagedOutputCanvas */
  18978. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18979. "use strict";
  18980. __webpack_require__.r(__webpack_exports__);
  18981. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return WebXRManagedOutputCanvas; });
  18982. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  18983. /**
  18984. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  18985. */
  18986. var WebXRManagedOutputCanvas = /** @class */ (function () {
  18987. /**
  18988. * Initializes the canvas to be added/removed upon entering/exiting xr
  18989. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  18990. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  18991. */
  18992. function WebXRManagedOutputCanvas(helper, canvas) {
  18993. var _this = this;
  18994. this._canvas = null;
  18995. /**
  18996. * xrpresent context of the canvas which can be used to display/mirror xr content
  18997. */
  18998. this.canvasContext = null;
  18999. if (!canvas) {
  19000. canvas = document.createElement('canvas');
  19001. canvas.style.cssText = "position:absolute; bottom:0px;right:0px;z-index:10;width:100%;height:100%;background-color: #000000;";
  19002. }
  19003. this._setManagedOutputCanvas(canvas);
  19004. helper.onStateChangedObservable.add(function (stateInfo) {
  19005. if (stateInfo == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__["WebXRState"].ENTERING_XR) {
  19006. // 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
  19007. _this._addCanvas();
  19008. }
  19009. else if (helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__["WebXRState"].NOT_IN_XR) {
  19010. _this._removeCanvas();
  19011. }
  19012. });
  19013. }
  19014. /**
  19015. * Disposes of the object
  19016. */
  19017. WebXRManagedOutputCanvas.prototype.dispose = function () {
  19018. this._removeCanvas();
  19019. this._setManagedOutputCanvas(null);
  19020. };
  19021. WebXRManagedOutputCanvas.prototype._setManagedOutputCanvas = function (canvas) {
  19022. this._removeCanvas();
  19023. if (!canvas) {
  19024. this._canvas = null;
  19025. this.canvasContext = null;
  19026. }
  19027. else {
  19028. this._canvas = canvas;
  19029. this.canvasContext = this._canvas.getContext('xrpresent');
  19030. }
  19031. };
  19032. WebXRManagedOutputCanvas.prototype._addCanvas = function () {
  19033. if (this._canvas) {
  19034. document.body.appendChild(this._canvas);
  19035. }
  19036. };
  19037. WebXRManagedOutputCanvas.prototype._removeCanvas = function () {
  19038. if (this._canvas && document.body.contains(this._canvas)) {
  19039. document.body.removeChild(this._canvas);
  19040. }
  19041. };
  19042. return WebXRManagedOutputCanvas;
  19043. }());
  19044. /***/ }),
  19045. /***/ "./Cameras/XR/webXRSessionManager.ts":
  19046. /*!*******************************************!*\
  19047. !*** ./Cameras/XR/webXRSessionManager.ts ***!
  19048. \*******************************************/
  19049. /*! exports provided: WebXRSessionManager */
  19050. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19051. "use strict";
  19052. __webpack_require__.r(__webpack_exports__);
  19053. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return WebXRSessionManager; });
  19054. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  19055. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  19056. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  19057. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  19058. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  19059. /**
  19060. * Manages an XRSession
  19061. * @see https://doc.babylonjs.com/how_to/webxr
  19062. */
  19063. var WebXRSessionManager = /** @class */ (function () {
  19064. /**
  19065. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  19066. * @param scene The scene which the session should be created for
  19067. */
  19068. function WebXRSessionManager(scene) {
  19069. this.scene = scene;
  19070. /**
  19071. * Fires every time a new xrFrame arrives which can be used to update the camera
  19072. */
  19073. this.onXRFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  19074. /**
  19075. * Fires when the xr session is ended either by the device or manually done
  19076. */
  19077. this.onXRSessionEnded = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  19078. /** @hidden */
  19079. this._sessionRenderTargetTexture = null;
  19080. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  19081. }
  19082. /**
  19083. * Initializes the manager
  19084. * After initialization enterXR can be called to start an XR session
  19085. * @returns Promise which resolves after it is initialized
  19086. */
  19087. WebXRSessionManager.prototype.initializeAsync = function () {
  19088. var _this = this;
  19089. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("The WebXR APIs are still under development and are subject to change in the future.");
  19090. // Check if the browser supports webXR
  19091. this._xrNavigator = navigator;
  19092. if (!this._xrNavigator.xr) {
  19093. return Promise.reject("webXR not supported by this browser");
  19094. }
  19095. // Request the webXR device
  19096. return this._xrNavigator.xr.requestDevice().then(function (device) {
  19097. _this._xrDevice = device;
  19098. return _this.scene.getEngine()._gl.setCompatibleXRDevice(_this._xrDevice);
  19099. });
  19100. };
  19101. /**
  19102. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  19103. * @param sessionCreationOptions xr options to create the session with
  19104. * @param frameOfReferenceType option to configure how the xr pose is expressed
  19105. * @returns Promise which resolves after it enters XR
  19106. */
  19107. WebXRSessionManager.prototype.enterXRAsync = function (sessionCreationOptions, frameOfReferenceType) {
  19108. var _this = this;
  19109. // initialize session
  19110. return this._xrDevice.requestSession(sessionCreationOptions).then(function (session) {
  19111. _this._xrSession = session;
  19112. // handle when the session is ended (By calling session.end or device ends its own session eg. pressing home button on phone)
  19113. _this._xrSession.addEventListener("end", function () {
  19114. // Remove render target texture and notify frame obervers
  19115. _this._sessionRenderTargetTexture = null;
  19116. // Restore frame buffer to avoid clear on xr framebuffer after session end
  19117. _this.scene.getEngine().restoreDefaultFramebuffer();
  19118. // Need to restart render loop as after the session is ended the last request for new frame will never call callback
  19119. _this.scene.getEngine().customAnimationFrameRequester = null;
  19120. _this.onXRSessionEnded.notifyObservers(null);
  19121. _this.scene.getEngine()._renderLoop();
  19122. }, { once: true });
  19123. _this._xrSession.baseLayer = new XRWebGLLayer(_this._xrSession, _this.scene.getEngine()._gl);
  19124. return _this._xrSession.requestFrameOfReference(frameOfReferenceType);
  19125. }).then(function (frameOfRef) {
  19126. _this._frameOfReference = frameOfRef;
  19127. // Tell the engine's render loop to be driven by the xr session's refresh rate and provide xr pose information
  19128. _this.scene.getEngine().customAnimationFrameRequester = {
  19129. requestAnimationFrame: _this._xrSession.requestAnimationFrame.bind(_this._xrSession),
  19130. renderFunction: function (timestamp, xrFrame) {
  19131. // Store the XR frame in the manager to be consumed by the XR camera to update pose
  19132. _this._currentXRFrame = xrFrame;
  19133. _this.onXRFrameObservable.notifyObservers(null);
  19134. _this.scene.getEngine()._renderLoop();
  19135. }
  19136. };
  19137. // Create render target texture from xr's webgl render target
  19138. _this._sessionRenderTargetTexture = WebXRSessionManager._CreateRenderTargetTextureFromSession(_this._xrSession, _this.scene);
  19139. // Stop window's animation frame and trigger sessions animation frame
  19140. window.cancelAnimationFrame(_this.scene.getEngine()._frameHandler);
  19141. _this.scene.getEngine()._renderLoop();
  19142. });
  19143. };
  19144. /**
  19145. * Stops the xrSession and restores the renderloop
  19146. * @returns Promise which resolves after it exits XR
  19147. */
  19148. WebXRSessionManager.prototype.exitXRAsync = function () {
  19149. return this._xrSession.end();
  19150. };
  19151. /**
  19152. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  19153. * @param ray ray to cast into the environment
  19154. * @returns Promise which resolves with a collision point in the environment if it exists
  19155. */
  19156. WebXRSessionManager.prototype.environmentPointHitTestAsync = function (ray) {
  19157. var _this = this;
  19158. return new Promise(function (res) {
  19159. // Compute left handed inputs to request hit test
  19160. var origin = new Float32Array([ray.origin.x, ray.origin.y, ray.origin.z]);
  19161. var direction = new Float32Array([ray.direction.x, ray.direction.y, ray.direction.z]);
  19162. if (!_this.scene.useRightHandedSystem) {
  19163. origin[2] *= -1;
  19164. direction[2] *= -1;
  19165. }
  19166. // Fire hittest
  19167. _this._xrSession.requestHitTest(origin, direction, _this._frameOfReference)
  19168. .then(function (hits) {
  19169. if (hits.length > 0) {
  19170. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromFloat32ArrayToRefScaled(hits[0].hitMatrix, 0, 1.0, _this._tmpMatrix);
  19171. var hitPoint = _this._tmpMatrix.getTranslation();
  19172. if (!_this.scene.useRightHandedSystem) {
  19173. hitPoint.z *= -1;
  19174. }
  19175. res(hitPoint);
  19176. }
  19177. else {
  19178. res(null);
  19179. }
  19180. }).catch(function () {
  19181. res(null);
  19182. });
  19183. });
  19184. };
  19185. /**
  19186. * Checks if a session would be supported for the creation options specified
  19187. * @param options creation options to check if they are supported
  19188. * @returns true if supported
  19189. */
  19190. WebXRSessionManager.prototype.supportsSessionAsync = function (options) {
  19191. return this._xrDevice.supportsSession(options).then(function () {
  19192. return true;
  19193. }).catch(function () {
  19194. return false;
  19195. });
  19196. };
  19197. /**
  19198. * @hidden
  19199. * Converts the render layer of xrSession to a render target
  19200. * @param session session to create render target for
  19201. * @param scene scene the new render target should be created for
  19202. */
  19203. WebXRSessionManager._CreateRenderTargetTextureFromSession = function (session, scene) {
  19204. // Create internal texture
  19205. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"](scene.getEngine(), _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_UNKNOWN, true);
  19206. internalTexture.width = session.baseLayer.framebufferWidth;
  19207. internalTexture.height = session.baseLayer.framebufferHeight;
  19208. internalTexture._framebuffer = session.baseLayer.framebuffer;
  19209. // Create render target texture from the internal texture
  19210. 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);
  19211. renderTargetTexture._texture = internalTexture;
  19212. return renderTargetTexture;
  19213. };
  19214. /**
  19215. * Disposes of the session manager
  19216. */
  19217. WebXRSessionManager.prototype.dispose = function () {
  19218. this.onXRFrameObservable.clear();
  19219. this.onXRSessionEnded.clear();
  19220. };
  19221. return WebXRSessionManager;
  19222. }());
  19223. /***/ }),
  19224. /***/ "./Cameras/arcRotateCamera.ts":
  19225. /*!************************************!*\
  19226. !*** ./Cameras/arcRotateCamera.ts ***!
  19227. \************************************/
  19228. /*! exports provided: ArcRotateCamera */
  19229. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19230. "use strict";
  19231. __webpack_require__.r(__webpack_exports__);
  19232. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return ArcRotateCamera; });
  19233. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  19234. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  19235. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  19236. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  19237. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../node */ "./node.ts");
  19238. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  19239. /* harmony import */ var _Behaviors_Cameras_autoRotationBehavior__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Behaviors/Cameras/autoRotationBehavior */ "./Behaviors/Cameras/autoRotationBehavior.ts");
  19240. /* harmony import */ var _Behaviors_Cameras_bouncingBehavior__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Behaviors/Cameras/bouncingBehavior */ "./Behaviors/Cameras/bouncingBehavior.ts");
  19241. /* harmony import */ var _Behaviors_Cameras_framingBehavior__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Behaviors/Cameras/framingBehavior */ "./Behaviors/Cameras/framingBehavior.ts");
  19242. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  19243. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  19244. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  19245. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("ArcRotateCamera", function (name, scene) {
  19246. return function () { return new ArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  19247. });
  19248. /**
  19249. * This represents an orbital type of camera.
  19250. *
  19251. * 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.
  19252. * 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.
  19253. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  19254. */
  19255. var ArcRotateCamera = /** @class */ (function (_super) {
  19256. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCamera, _super);
  19257. /**
  19258. * Instantiates a new ArcRotateCamera in a given scene
  19259. * @param name Defines the name of the camera
  19260. * @param alpha Defines the camera rotation along the logitudinal axis
  19261. * @param beta Defines the camera rotation along the latitudinal axis
  19262. * @param radius Defines the camera distance from its target
  19263. * @param target Defines the camera target
  19264. * @param scene Defines the scene the camera belongs to
  19265. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19266. */
  19267. function ArcRotateCamera(name, alpha, beta, radius, target, scene, setActiveOnSceneIfNoneActive) {
  19268. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  19269. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene, setActiveOnSceneIfNoneActive) || this;
  19270. /**
  19271. * Current inertia value on the longitudinal axis.
  19272. * The bigger this number the longer it will take for the camera to stop.
  19273. */
  19274. _this.inertialAlphaOffset = 0;
  19275. /**
  19276. * Current inertia value on the latitudinal axis.
  19277. * The bigger this number the longer it will take for the camera to stop.
  19278. */
  19279. _this.inertialBetaOffset = 0;
  19280. /**
  19281. * Current inertia value on the radius axis.
  19282. * The bigger this number the longer it will take for the camera to stop.
  19283. */
  19284. _this.inertialRadiusOffset = 0;
  19285. /**
  19286. * Minimum allowed angle on the longitudinal axis.
  19287. * This can help limiting how the Camera is able to move in the scene.
  19288. */
  19289. _this.lowerAlphaLimit = null;
  19290. /**
  19291. * Maximum allowed angle on the longitudinal axis.
  19292. * This can help limiting how the Camera is able to move in the scene.
  19293. */
  19294. _this.upperAlphaLimit = null;
  19295. /**
  19296. * Minimum allowed angle on the latitudinal axis.
  19297. * This can help limiting how the Camera is able to move in the scene.
  19298. */
  19299. _this.lowerBetaLimit = 0.01;
  19300. /**
  19301. * Maximum allowed angle on the latitudinal axis.
  19302. * This can help limiting how the Camera is able to move in the scene.
  19303. */
  19304. _this.upperBetaLimit = Math.PI - 0.01;
  19305. /**
  19306. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  19307. * This can help limiting how the Camera is able to move in the scene.
  19308. */
  19309. _this.lowerRadiusLimit = null;
  19310. /**
  19311. * Maximum allowed distance of the camera to the target (The camera can not get further).
  19312. * This can help limiting how the Camera is able to move in the scene.
  19313. */
  19314. _this.upperRadiusLimit = null;
  19315. /**
  19316. * Defines the current inertia value used during panning of the camera along the X axis.
  19317. */
  19318. _this.inertialPanningX = 0;
  19319. /**
  19320. * Defines the current inertia value used during panning of the camera along the Y axis.
  19321. */
  19322. _this.inertialPanningY = 0;
  19323. /**
  19324. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  19325. * Basically if your fingers moves away from more than this distance you will be considered
  19326. * in pinch mode.
  19327. */
  19328. _this.pinchToPanMaxDistance = 20;
  19329. /**
  19330. * Defines the maximum distance the camera can pan.
  19331. * This could help keeping the cammera always in your scene.
  19332. */
  19333. _this.panningDistanceLimit = null;
  19334. /**
  19335. * Defines the target of the camera before paning.
  19336. */
  19337. _this.panningOriginTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19338. /**
  19339. * Defines the value of the inertia used during panning.
  19340. * 0 would mean stop inertia and one would mean no decelleration at all.
  19341. */
  19342. _this.panningInertia = 0.9;
  19343. //-- end properties for backward compatibility for inputs
  19344. /**
  19345. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  19346. */
  19347. _this.zoomOnFactor = 1;
  19348. /**
  19349. * Defines a screen offset for the camera position.
  19350. */
  19351. _this.targetScreenOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  19352. /**
  19353. * Allows the camera to be completely reversed.
  19354. * If false the camera can not arrive upside down.
  19355. */
  19356. _this.allowUpsideDown = true;
  19357. /**
  19358. * Define if double tap/click is used to restore the previously saved state of the camera.
  19359. */
  19360. _this.useInputToRestoreState = true;
  19361. /** @hidden */
  19362. _this._viewMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  19363. /**
  19364. * Defines the allowed panning axis.
  19365. */
  19366. _this.panningAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 1, 0);
  19367. /**
  19368. * Observable triggered when the mesh target has been changed on the camera.
  19369. */
  19370. _this.onMeshTargetChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  19371. /**
  19372. * Defines whether the camera should check collision with the objects oh the scene.
  19373. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  19374. */
  19375. _this.checkCollisions = false;
  19376. /**
  19377. * Defines the collision radius of the camera.
  19378. * This simulates a sphere around the camera.
  19379. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19380. */
  19381. _this.collisionRadius = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0.5, 0.5, 0.5);
  19382. _this._previousPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19383. _this._collisionVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19384. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19385. _this._computationVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19386. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  19387. if (collidedMesh === void 0) { collidedMesh = null; }
  19388. if (!collidedMesh) {
  19389. _this._previousPosition.copyFrom(_this._position);
  19390. }
  19391. else {
  19392. _this.setPosition(newPosition);
  19393. if (_this.onCollide) {
  19394. _this.onCollide(collidedMesh);
  19395. }
  19396. }
  19397. // Recompute because of constraints
  19398. var cosa = Math.cos(_this.alpha);
  19399. var sina = Math.sin(_this.alpha);
  19400. var cosb = Math.cos(_this.beta);
  19401. var sinb = Math.sin(_this.beta);
  19402. if (sinb === 0) {
  19403. sinb = 0.0001;
  19404. }
  19405. var target = _this._getTargetPosition();
  19406. _this._computationVector.copyFromFloats(_this.radius * cosa * sinb, _this.radius * cosb, _this.radius * sina * sinb);
  19407. target.addToRef(_this._computationVector, _this._newPosition);
  19408. _this._position.copyFrom(_this._newPosition);
  19409. var up = _this.upVector;
  19410. if (_this.allowUpsideDown && _this.beta < 0) {
  19411. up = up.clone();
  19412. up = up.negate();
  19413. }
  19414. _this._computeViewMatrix(_this._position, target, up);
  19415. _this._viewMatrix.addAtIndex(12, _this.targetScreenOffset.x);
  19416. _this._viewMatrix.addAtIndex(13, _this.targetScreenOffset.y);
  19417. _this._collisionTriggered = false;
  19418. };
  19419. _this._target = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19420. if (target) {
  19421. _this.setTarget(target);
  19422. }
  19423. _this.alpha = alpha;
  19424. _this.beta = beta;
  19425. _this.radius = radius;
  19426. _this.getViewMatrix();
  19427. _this.inputs = new _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__["ArcRotateCameraInputsManager"](_this);
  19428. _this.inputs.addKeyboard().addMouseWheel().addPointers();
  19429. return _this;
  19430. }
  19431. Object.defineProperty(ArcRotateCamera.prototype, "target", {
  19432. /**
  19433. * Defines the target point of the camera.
  19434. * The camera looks towards it form the radius distance.
  19435. */
  19436. get: function () {
  19437. return this._target;
  19438. },
  19439. set: function (value) {
  19440. this.setTarget(value);
  19441. },
  19442. enumerable: true,
  19443. configurable: true
  19444. });
  19445. Object.defineProperty(ArcRotateCamera.prototype, "position", {
  19446. /**
  19447. * Define the current local position of the camera in the scene
  19448. */
  19449. get: function () {
  19450. return this._position;
  19451. },
  19452. set: function (newPosition) {
  19453. this.setPosition(newPosition);
  19454. },
  19455. enumerable: true,
  19456. configurable: true
  19457. });
  19458. Object.defineProperty(ArcRotateCamera.prototype, "angularSensibilityX", {
  19459. //-- begin properties for backward compatibility for inputs
  19460. /**
  19461. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  19462. */
  19463. get: function () {
  19464. var pointers = this.inputs.attached["pointers"];
  19465. if (pointers) {
  19466. return pointers.angularSensibilityX;
  19467. }
  19468. return 0;
  19469. },
  19470. set: function (value) {
  19471. var pointers = this.inputs.attached["pointers"];
  19472. if (pointers) {
  19473. pointers.angularSensibilityX = value;
  19474. }
  19475. },
  19476. enumerable: true,
  19477. configurable: true
  19478. });
  19479. Object.defineProperty(ArcRotateCamera.prototype, "angularSensibilityY", {
  19480. /**
  19481. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  19482. */
  19483. get: function () {
  19484. var pointers = this.inputs.attached["pointers"];
  19485. if (pointers) {
  19486. return pointers.angularSensibilityY;
  19487. }
  19488. return 0;
  19489. },
  19490. set: function (value) {
  19491. var pointers = this.inputs.attached["pointers"];
  19492. if (pointers) {
  19493. pointers.angularSensibilityY = value;
  19494. }
  19495. },
  19496. enumerable: true,
  19497. configurable: true
  19498. });
  19499. Object.defineProperty(ArcRotateCamera.prototype, "pinchPrecision", {
  19500. /**
  19501. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  19502. */
  19503. get: function () {
  19504. var pointers = this.inputs.attached["pointers"];
  19505. if (pointers) {
  19506. return pointers.pinchPrecision;
  19507. }
  19508. return 0;
  19509. },
  19510. set: function (value) {
  19511. var pointers = this.inputs.attached["pointers"];
  19512. if (pointers) {
  19513. pointers.pinchPrecision = value;
  19514. }
  19515. },
  19516. enumerable: true,
  19517. configurable: true
  19518. });
  19519. Object.defineProperty(ArcRotateCamera.prototype, "pinchDeltaPercentage", {
  19520. /**
  19521. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  19522. * It will be used instead of pinchDeltaPrecision if different from 0.
  19523. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  19524. */
  19525. get: function () {
  19526. var pointers = this.inputs.attached["pointers"];
  19527. if (pointers) {
  19528. return pointers.pinchDeltaPercentage;
  19529. }
  19530. return 0;
  19531. },
  19532. set: function (value) {
  19533. var pointers = this.inputs.attached["pointers"];
  19534. if (pointers) {
  19535. pointers.pinchDeltaPercentage = value;
  19536. }
  19537. },
  19538. enumerable: true,
  19539. configurable: true
  19540. });
  19541. Object.defineProperty(ArcRotateCamera.prototype, "panningSensibility", {
  19542. /**
  19543. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  19544. */
  19545. get: function () {
  19546. var pointers = this.inputs.attached["pointers"];
  19547. if (pointers) {
  19548. return pointers.panningSensibility;
  19549. }
  19550. return 0;
  19551. },
  19552. set: function (value) {
  19553. var pointers = this.inputs.attached["pointers"];
  19554. if (pointers) {
  19555. pointers.panningSensibility = value;
  19556. }
  19557. },
  19558. enumerable: true,
  19559. configurable: true
  19560. });
  19561. Object.defineProperty(ArcRotateCamera.prototype, "keysUp", {
  19562. /**
  19563. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  19564. */
  19565. get: function () {
  19566. var keyboard = this.inputs.attached["keyboard"];
  19567. if (keyboard) {
  19568. return keyboard.keysUp;
  19569. }
  19570. return [];
  19571. },
  19572. set: function (value) {
  19573. var keyboard = this.inputs.attached["keyboard"];
  19574. if (keyboard) {
  19575. keyboard.keysUp = value;
  19576. }
  19577. },
  19578. enumerable: true,
  19579. configurable: true
  19580. });
  19581. Object.defineProperty(ArcRotateCamera.prototype, "keysDown", {
  19582. /**
  19583. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  19584. */
  19585. get: function () {
  19586. var keyboard = this.inputs.attached["keyboard"];
  19587. if (keyboard) {
  19588. return keyboard.keysDown;
  19589. }
  19590. return [];
  19591. },
  19592. set: function (value) {
  19593. var keyboard = this.inputs.attached["keyboard"];
  19594. if (keyboard) {
  19595. keyboard.keysDown = value;
  19596. }
  19597. },
  19598. enumerable: true,
  19599. configurable: true
  19600. });
  19601. Object.defineProperty(ArcRotateCamera.prototype, "keysLeft", {
  19602. /**
  19603. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  19604. */
  19605. get: function () {
  19606. var keyboard = this.inputs.attached["keyboard"];
  19607. if (keyboard) {
  19608. return keyboard.keysLeft;
  19609. }
  19610. return [];
  19611. },
  19612. set: function (value) {
  19613. var keyboard = this.inputs.attached["keyboard"];
  19614. if (keyboard) {
  19615. keyboard.keysLeft = value;
  19616. }
  19617. },
  19618. enumerable: true,
  19619. configurable: true
  19620. });
  19621. Object.defineProperty(ArcRotateCamera.prototype, "keysRight", {
  19622. /**
  19623. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  19624. */
  19625. get: function () {
  19626. var keyboard = this.inputs.attached["keyboard"];
  19627. if (keyboard) {
  19628. return keyboard.keysRight;
  19629. }
  19630. return [];
  19631. },
  19632. set: function (value) {
  19633. var keyboard = this.inputs.attached["keyboard"];
  19634. if (keyboard) {
  19635. keyboard.keysRight = value;
  19636. }
  19637. },
  19638. enumerable: true,
  19639. configurable: true
  19640. });
  19641. Object.defineProperty(ArcRotateCamera.prototype, "wheelPrecision", {
  19642. /**
  19643. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  19644. */
  19645. get: function () {
  19646. var mousewheel = this.inputs.attached["mousewheel"];
  19647. if (mousewheel) {
  19648. return mousewheel.wheelPrecision;
  19649. }
  19650. return 0;
  19651. },
  19652. set: function (value) {
  19653. var mousewheel = this.inputs.attached["mousewheel"];
  19654. if (mousewheel) {
  19655. mousewheel.wheelPrecision = value;
  19656. }
  19657. },
  19658. enumerable: true,
  19659. configurable: true
  19660. });
  19661. Object.defineProperty(ArcRotateCamera.prototype, "wheelDeltaPercentage", {
  19662. /**
  19663. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  19664. * It will be used instead of pinchDeltaPrecision if different from 0.
  19665. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  19666. */
  19667. get: function () {
  19668. var mousewheel = this.inputs.attached["mousewheel"];
  19669. if (mousewheel) {
  19670. return mousewheel.wheelDeltaPercentage;
  19671. }
  19672. return 0;
  19673. },
  19674. set: function (value) {
  19675. var mousewheel = this.inputs.attached["mousewheel"];
  19676. if (mousewheel) {
  19677. mousewheel.wheelDeltaPercentage = value;
  19678. }
  19679. },
  19680. enumerable: true,
  19681. configurable: true
  19682. });
  19683. Object.defineProperty(ArcRotateCamera.prototype, "bouncingBehavior", {
  19684. /**
  19685. * Gets the bouncing behavior of the camera if it has been enabled.
  19686. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  19687. */
  19688. get: function () {
  19689. return this._bouncingBehavior;
  19690. },
  19691. enumerable: true,
  19692. configurable: true
  19693. });
  19694. Object.defineProperty(ArcRotateCamera.prototype, "useBouncingBehavior", {
  19695. /**
  19696. * Defines if the bouncing behavior of the camera is enabled on the camera.
  19697. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  19698. */
  19699. get: function () {
  19700. return this._bouncingBehavior != null;
  19701. },
  19702. set: function (value) {
  19703. if (value === this.useBouncingBehavior) {
  19704. return;
  19705. }
  19706. if (value) {
  19707. this._bouncingBehavior = new _Behaviors_Cameras_bouncingBehavior__WEBPACK_IMPORTED_MODULE_7__["BouncingBehavior"]();
  19708. this.addBehavior(this._bouncingBehavior);
  19709. }
  19710. else if (this._bouncingBehavior) {
  19711. this.removeBehavior(this._bouncingBehavior);
  19712. this._bouncingBehavior = null;
  19713. }
  19714. },
  19715. enumerable: true,
  19716. configurable: true
  19717. });
  19718. Object.defineProperty(ArcRotateCamera.prototype, "framingBehavior", {
  19719. /**
  19720. * Gets the framing behavior of the camera if it has been enabled.
  19721. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  19722. */
  19723. get: function () {
  19724. return this._framingBehavior;
  19725. },
  19726. enumerable: true,
  19727. configurable: true
  19728. });
  19729. Object.defineProperty(ArcRotateCamera.prototype, "useFramingBehavior", {
  19730. /**
  19731. * Defines if the framing behavior of the camera is enabled on the camera.
  19732. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  19733. */
  19734. get: function () {
  19735. return this._framingBehavior != null;
  19736. },
  19737. set: function (value) {
  19738. if (value === this.useFramingBehavior) {
  19739. return;
  19740. }
  19741. if (value) {
  19742. this._framingBehavior = new _Behaviors_Cameras_framingBehavior__WEBPACK_IMPORTED_MODULE_8__["FramingBehavior"]();
  19743. this.addBehavior(this._framingBehavior);
  19744. }
  19745. else if (this._framingBehavior) {
  19746. this.removeBehavior(this._framingBehavior);
  19747. this._framingBehavior = null;
  19748. }
  19749. },
  19750. enumerable: true,
  19751. configurable: true
  19752. });
  19753. Object.defineProperty(ArcRotateCamera.prototype, "autoRotationBehavior", {
  19754. /**
  19755. * Gets the auto rotation behavior of the camera if it has been enabled.
  19756. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  19757. */
  19758. get: function () {
  19759. return this._autoRotationBehavior;
  19760. },
  19761. enumerable: true,
  19762. configurable: true
  19763. });
  19764. Object.defineProperty(ArcRotateCamera.prototype, "useAutoRotationBehavior", {
  19765. /**
  19766. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  19767. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  19768. */
  19769. get: function () {
  19770. return this._autoRotationBehavior != null;
  19771. },
  19772. set: function (value) {
  19773. if (value === this.useAutoRotationBehavior) {
  19774. return;
  19775. }
  19776. if (value) {
  19777. this._autoRotationBehavior = new _Behaviors_Cameras_autoRotationBehavior__WEBPACK_IMPORTED_MODULE_6__["AutoRotationBehavior"]();
  19778. this.addBehavior(this._autoRotationBehavior);
  19779. }
  19780. else if (this._autoRotationBehavior) {
  19781. this.removeBehavior(this._autoRotationBehavior);
  19782. this._autoRotationBehavior = null;
  19783. }
  19784. },
  19785. enumerable: true,
  19786. configurable: true
  19787. });
  19788. // Cache
  19789. /** @hidden */
  19790. ArcRotateCamera.prototype._initCache = function () {
  19791. _super.prototype._initCache.call(this);
  19792. this._cache._target = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  19793. this._cache.alpha = undefined;
  19794. this._cache.beta = undefined;
  19795. this._cache.radius = undefined;
  19796. this._cache.targetScreenOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  19797. };
  19798. /** @hidden */
  19799. ArcRotateCamera.prototype._updateCache = function (ignoreParentClass) {
  19800. if (!ignoreParentClass) {
  19801. _super.prototype._updateCache.call(this);
  19802. }
  19803. this._cache._target.copyFrom(this._getTargetPosition());
  19804. this._cache.alpha = this.alpha;
  19805. this._cache.beta = this.beta;
  19806. this._cache.radius = this.radius;
  19807. this._cache.targetScreenOffset.copyFrom(this.targetScreenOffset);
  19808. };
  19809. ArcRotateCamera.prototype._getTargetPosition = function () {
  19810. if (this._targetHost && this._targetHost.getAbsolutePosition) {
  19811. var pos = this._targetHost.absolutePosition;
  19812. if (this._targetBoundingCenter) {
  19813. pos.addToRef(this._targetBoundingCenter, this._target);
  19814. }
  19815. else {
  19816. this._target.copyFrom(pos);
  19817. }
  19818. }
  19819. var lockedTargetPosition = this._getLockedTargetPosition();
  19820. if (lockedTargetPosition) {
  19821. return lockedTargetPosition;
  19822. }
  19823. return this._target;
  19824. };
  19825. /**
  19826. * Stores the current state of the camera (alpha, beta, radius and target)
  19827. * @returns the camera itself
  19828. */
  19829. ArcRotateCamera.prototype.storeState = function () {
  19830. this._storedAlpha = this.alpha;
  19831. this._storedBeta = this.beta;
  19832. this._storedRadius = this.radius;
  19833. this._storedTarget = this._getTargetPosition().clone();
  19834. return _super.prototype.storeState.call(this);
  19835. };
  19836. /**
  19837. * @hidden
  19838. * Restored camera state. You must call storeState() first
  19839. */
  19840. ArcRotateCamera.prototype._restoreStateValues = function () {
  19841. if (!_super.prototype._restoreStateValues.call(this)) {
  19842. return false;
  19843. }
  19844. this.alpha = this._storedAlpha;
  19845. this.beta = this._storedBeta;
  19846. this.radius = this._storedRadius;
  19847. this.setTarget(this._storedTarget.clone());
  19848. this.inertialAlphaOffset = 0;
  19849. this.inertialBetaOffset = 0;
  19850. this.inertialRadiusOffset = 0;
  19851. this.inertialPanningX = 0;
  19852. this.inertialPanningY = 0;
  19853. return true;
  19854. };
  19855. // Synchronized
  19856. /** @hidden */
  19857. ArcRotateCamera.prototype._isSynchronizedViewMatrix = function () {
  19858. if (!_super.prototype._isSynchronizedViewMatrix.call(this)) {
  19859. return false;
  19860. }
  19861. return this._cache._target.equals(this._getTargetPosition())
  19862. && this._cache.alpha === this.alpha
  19863. && this._cache.beta === this.beta
  19864. && this._cache.radius === this.radius
  19865. && this._cache.targetScreenOffset.equals(this.targetScreenOffset);
  19866. };
  19867. /**
  19868. * Attached controls to the current camera.
  19869. * @param element Defines the element the controls should be listened from
  19870. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19871. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  19872. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  19873. */
  19874. ArcRotateCamera.prototype.attachControl = function (element, noPreventDefault, useCtrlForPanning, panningMouseButton) {
  19875. var _this = this;
  19876. if (useCtrlForPanning === void 0) { useCtrlForPanning = true; }
  19877. if (panningMouseButton === void 0) { panningMouseButton = 2; }
  19878. this._useCtrlForPanning = useCtrlForPanning;
  19879. this._panningMouseButton = panningMouseButton;
  19880. this.inputs.attachElement(element, noPreventDefault);
  19881. this._reset = function () {
  19882. _this.inertialAlphaOffset = 0;
  19883. _this.inertialBetaOffset = 0;
  19884. _this.inertialRadiusOffset = 0;
  19885. _this.inertialPanningX = 0;
  19886. _this.inertialPanningY = 0;
  19887. };
  19888. };
  19889. /**
  19890. * Detach the current controls from the camera.
  19891. * The camera will stop reacting to inputs.
  19892. * @param element Defines the element to stop listening the inputs from
  19893. */
  19894. ArcRotateCamera.prototype.detachControl = function (element) {
  19895. this.inputs.detachElement(element);
  19896. if (this._reset) {
  19897. this._reset();
  19898. }
  19899. };
  19900. /** @hidden */
  19901. ArcRotateCamera.prototype._checkInputs = function () {
  19902. //if (async) collision inspection was triggered, don't update the camera's position - until the collision callback was called.
  19903. if (this._collisionTriggered) {
  19904. return;
  19905. }
  19906. this.inputs.checkInputs();
  19907. // Inertia
  19908. if (this.inertialAlphaOffset !== 0 || this.inertialBetaOffset !== 0 || this.inertialRadiusOffset !== 0) {
  19909. var inertialAlphaOffset = this.inertialAlphaOffset;
  19910. if (this.beta <= 0) {
  19911. inertialAlphaOffset *= -1;
  19912. }
  19913. if (this.getScene().useRightHandedSystem) {
  19914. inertialAlphaOffset *= -1;
  19915. }
  19916. if (this.parent && this.parent._getWorldMatrixDeterminant() < 0) {
  19917. inertialAlphaOffset *= -1;
  19918. }
  19919. this.alpha += inertialAlphaOffset;
  19920. this.beta += this.inertialBetaOffset;
  19921. this.radius -= this.inertialRadiusOffset;
  19922. this.inertialAlphaOffset *= this.inertia;
  19923. this.inertialBetaOffset *= this.inertia;
  19924. this.inertialRadiusOffset *= this.inertia;
  19925. if (Math.abs(this.inertialAlphaOffset) < _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19926. this.inertialAlphaOffset = 0;
  19927. }
  19928. if (Math.abs(this.inertialBetaOffset) < _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19929. this.inertialBetaOffset = 0;
  19930. }
  19931. if (Math.abs(this.inertialRadiusOffset) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19932. this.inertialRadiusOffset = 0;
  19933. }
  19934. }
  19935. // Panning inertia
  19936. if (this.inertialPanningX !== 0 || this.inertialPanningY !== 0) {
  19937. if (!this._localDirection) {
  19938. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19939. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19940. }
  19941. this._localDirection.copyFromFloats(this.inertialPanningX, this.inertialPanningY, this.inertialPanningY);
  19942. this._localDirection.multiplyInPlace(this.panningAxis);
  19943. this._viewMatrix.invertToRef(this._cameraTransformMatrix);
  19944. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(this._localDirection, this._cameraTransformMatrix, this._transformedDirection);
  19945. //Eliminate y if map panning is enabled (panningAxis == 1,0,1)
  19946. if (!this.panningAxis.y) {
  19947. this._transformedDirection.y = 0;
  19948. }
  19949. if (!this._targetHost) {
  19950. if (this.panningDistanceLimit) {
  19951. this._transformedDirection.addInPlace(this._target);
  19952. var distanceSquared = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].DistanceSquared(this._transformedDirection, this.panningOriginTarget);
  19953. if (distanceSquared <= (this.panningDistanceLimit * this.panningDistanceLimit)) {
  19954. this._target.copyFrom(this._transformedDirection);
  19955. }
  19956. }
  19957. else {
  19958. this._target.addInPlace(this._transformedDirection);
  19959. }
  19960. }
  19961. this.inertialPanningX *= this.panningInertia;
  19962. this.inertialPanningY *= this.panningInertia;
  19963. if (Math.abs(this.inertialPanningX) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19964. this.inertialPanningX = 0;
  19965. }
  19966. if (Math.abs(this.inertialPanningY) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19967. this.inertialPanningY = 0;
  19968. }
  19969. }
  19970. // Limits
  19971. this._checkLimits();
  19972. _super.prototype._checkInputs.call(this);
  19973. };
  19974. ArcRotateCamera.prototype._checkLimits = function () {
  19975. if (this.lowerBetaLimit === null || this.lowerBetaLimit === undefined) {
  19976. if (this.allowUpsideDown && this.beta > Math.PI) {
  19977. this.beta = this.beta - (2 * Math.PI);
  19978. }
  19979. }
  19980. else {
  19981. if (this.beta < this.lowerBetaLimit) {
  19982. this.beta = this.lowerBetaLimit;
  19983. }
  19984. }
  19985. if (this.upperBetaLimit === null || this.upperBetaLimit === undefined) {
  19986. if (this.allowUpsideDown && this.beta < -Math.PI) {
  19987. this.beta = this.beta + (2 * Math.PI);
  19988. }
  19989. }
  19990. else {
  19991. if (this.beta > this.upperBetaLimit) {
  19992. this.beta = this.upperBetaLimit;
  19993. }
  19994. }
  19995. if (this.lowerAlphaLimit !== null && this.alpha < this.lowerAlphaLimit) {
  19996. this.alpha = this.lowerAlphaLimit;
  19997. }
  19998. if (this.upperAlphaLimit !== null && this.alpha > this.upperAlphaLimit) {
  19999. this.alpha = this.upperAlphaLimit;
  20000. }
  20001. if (this.lowerRadiusLimit !== null && this.radius < this.lowerRadiusLimit) {
  20002. this.radius = this.lowerRadiusLimit;
  20003. this.inertialRadiusOffset = 0;
  20004. }
  20005. if (this.upperRadiusLimit !== null && this.radius > this.upperRadiusLimit) {
  20006. this.radius = this.upperRadiusLimit;
  20007. this.inertialRadiusOffset = 0;
  20008. }
  20009. };
  20010. /**
  20011. * Rebuilds angles (alpha, beta) and radius from the give position and target
  20012. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  20013. */
  20014. ArcRotateCamera.prototype.rebuildAnglesAndRadius = function (updateView) {
  20015. if (updateView === void 0) { updateView = true; }
  20016. if (updateView) {
  20017. this.getViewMatrix(); // Force position update
  20018. }
  20019. this._position.subtractToRef(this._getTargetPosition(), this._computationVector);
  20020. this.radius = this._computationVector.length();
  20021. if (this.radius === 0) {
  20022. this.radius = 0.0001; // Just to avoid division by zero
  20023. }
  20024. // Alpha
  20025. this.alpha = Math.acos(this._computationVector.x / Math.sqrt(Math.pow(this._computationVector.x, 2) + Math.pow(this._computationVector.z, 2)));
  20026. if (this._computationVector.z < 0) {
  20027. this.alpha = 2 * Math.PI - this.alpha;
  20028. }
  20029. // Beta
  20030. this.beta = Math.acos(this._computationVector.y / this.radius);
  20031. this._checkLimits();
  20032. };
  20033. /**
  20034. * Use a position to define the current camera related information like aplha, beta and radius
  20035. * @param position Defines the position to set the camera at
  20036. */
  20037. ArcRotateCamera.prototype.setPosition = function (position) {
  20038. if (this._position.equals(position)) {
  20039. return;
  20040. }
  20041. this._position.copyFrom(position);
  20042. this.rebuildAnglesAndRadius(false);
  20043. };
  20044. /**
  20045. * Defines the target the camera should look at.
  20046. * This will automatically adapt alpha beta and radius to fit within the new target.
  20047. * @param target Defines the new target as a Vector or a mesh
  20048. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  20049. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  20050. */
  20051. ArcRotateCamera.prototype.setTarget = function (target, toBoundingCenter, allowSamePosition) {
  20052. if (toBoundingCenter === void 0) { toBoundingCenter = false; }
  20053. if (allowSamePosition === void 0) { allowSamePosition = false; }
  20054. if (target.getBoundingInfo) {
  20055. if (toBoundingCenter) {
  20056. this._targetBoundingCenter = target.getBoundingInfo().boundingBox.centerWorld.clone();
  20057. }
  20058. else {
  20059. this._targetBoundingCenter = null;
  20060. }
  20061. this._targetHost = target;
  20062. this._target = this._getTargetPosition();
  20063. this.onMeshTargetChangedObservable.notifyObservers(this._targetHost);
  20064. }
  20065. else {
  20066. var newTarget = target;
  20067. var currentTarget = this._getTargetPosition();
  20068. if (currentTarget && !allowSamePosition && currentTarget.equals(newTarget)) {
  20069. return;
  20070. }
  20071. this._targetHost = null;
  20072. this._target = newTarget;
  20073. this._targetBoundingCenter = null;
  20074. this.onMeshTargetChangedObservable.notifyObservers(null);
  20075. }
  20076. this.rebuildAnglesAndRadius();
  20077. };
  20078. /** @hidden */
  20079. ArcRotateCamera.prototype._getViewMatrix = function () {
  20080. // Compute
  20081. var cosa = Math.cos(this.alpha);
  20082. var sina = Math.sin(this.alpha);
  20083. var cosb = Math.cos(this.beta);
  20084. var sinb = Math.sin(this.beta);
  20085. if (sinb === 0) {
  20086. sinb = 0.0001;
  20087. }
  20088. var target = this._getTargetPosition();
  20089. this._computationVector.copyFromFloats(this.radius * cosa * sinb, this.radius * cosb, this.radius * sina * sinb);
  20090. // Rotate according to up vector
  20091. if (this.upVector.x !== 0 || this.upVector.y !== 1.0 || this.upVector.z !== 0) {
  20092. if (!this._tempAxisVector) {
  20093. this._tempAxisVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  20094. this._tempAxisRotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  20095. }
  20096. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up(), this.upVector, this._tempAxisVector);
  20097. this._tempAxisVector.normalize();
  20098. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].UpReadOnly, this.upVector));
  20099. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationAxisToRef(this._tempAxisVector, angle, this._tempAxisRotationMatrix);
  20100. this._tempAxisVector.copyFrom(this._computationVector);
  20101. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._tempAxisVector, this._tempAxisRotationMatrix, this._computationVector);
  20102. }
  20103. target.addToRef(this._computationVector, this._newPosition);
  20104. if (this.getScene().collisionsEnabled && this.checkCollisions) {
  20105. var coordinator = this.getScene().collisionCoordinator;
  20106. if (!this._collider) {
  20107. this._collider = coordinator.createCollider();
  20108. }
  20109. this._collider._radius = this.collisionRadius;
  20110. this._newPosition.subtractToRef(this._position, this._collisionVelocity);
  20111. this._collisionTriggered = true;
  20112. coordinator.getNewPosition(this._position, this._collisionVelocity, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  20113. }
  20114. else {
  20115. this._position.copyFrom(this._newPosition);
  20116. var up = this.upVector;
  20117. if (this.allowUpsideDown && sinb < 0) {
  20118. up = up.clone();
  20119. up = up.negate();
  20120. }
  20121. this._computeViewMatrix(this._position, target, up);
  20122. this._viewMatrix.addAtIndex(12, this.targetScreenOffset.x);
  20123. this._viewMatrix.addAtIndex(13, this.targetScreenOffset.y);
  20124. }
  20125. this._currentTarget = target;
  20126. return this._viewMatrix;
  20127. };
  20128. /**
  20129. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  20130. * @param meshes Defines the mesh to zoom on
  20131. * @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)
  20132. */
  20133. ArcRotateCamera.prototype.zoomOn = function (meshes, doNotUpdateMaxZ) {
  20134. if (doNotUpdateMaxZ === void 0) { doNotUpdateMaxZ = false; }
  20135. meshes = meshes || this.getScene().meshes;
  20136. var minMaxVector = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].MinMax(meshes);
  20137. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(minMaxVector.min, minMaxVector.max);
  20138. this.radius = distance * this.zoomOnFactor;
  20139. this.focusOn({ min: minMaxVector.min, max: minMaxVector.max, distance: distance }, doNotUpdateMaxZ);
  20140. };
  20141. /**
  20142. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  20143. * The target will be changed but the radius
  20144. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  20145. * @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)
  20146. */
  20147. ArcRotateCamera.prototype.focusOn = function (meshesOrMinMaxVectorAndDistance, doNotUpdateMaxZ) {
  20148. if (doNotUpdateMaxZ === void 0) { doNotUpdateMaxZ = false; }
  20149. var meshesOrMinMaxVector;
  20150. var distance;
  20151. if (meshesOrMinMaxVectorAndDistance.min === undefined) { // meshes
  20152. var meshes = meshesOrMinMaxVectorAndDistance || this.getScene().meshes;
  20153. meshesOrMinMaxVector = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].MinMax(meshes);
  20154. distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(meshesOrMinMaxVector.min, meshesOrMinMaxVector.max);
  20155. }
  20156. else { //minMaxVector and distance
  20157. var minMaxVectorAndDistance = meshesOrMinMaxVectorAndDistance;
  20158. meshesOrMinMaxVector = minMaxVectorAndDistance;
  20159. distance = minMaxVectorAndDistance.distance;
  20160. }
  20161. this._target = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].Center(meshesOrMinMaxVector);
  20162. if (!doNotUpdateMaxZ) {
  20163. this.maxZ = distance * 2;
  20164. }
  20165. };
  20166. /**
  20167. * @override
  20168. * Override Camera.createRigCamera
  20169. */
  20170. ArcRotateCamera.prototype.createRigCamera = function (name, cameraIndex) {
  20171. var alphaShift = 0;
  20172. switch (this.cameraRigMode) {
  20173. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  20174. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  20175. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  20176. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_VR:
  20177. alphaShift = this._cameraRigParams.stereoHalfAngle * (cameraIndex === 0 ? 1 : -1);
  20178. break;
  20179. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  20180. alphaShift = this._cameraRigParams.stereoHalfAngle * (cameraIndex === 0 ? -1 : 1);
  20181. break;
  20182. }
  20183. var rigCam = new ArcRotateCamera(name, this.alpha + alphaShift, this.beta, this.radius, this._target, this.getScene());
  20184. rigCam._cameraRigParams = {};
  20185. return rigCam;
  20186. };
  20187. /**
  20188. * @hidden
  20189. * @override
  20190. * Override Camera._updateRigCameras
  20191. */
  20192. ArcRotateCamera.prototype._updateRigCameras = function () {
  20193. var camLeft = this._rigCameras[0];
  20194. var camRight = this._rigCameras[1];
  20195. camLeft.beta = camRight.beta = this.beta;
  20196. switch (this.cameraRigMode) {
  20197. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  20198. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  20199. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  20200. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_VR:
  20201. camLeft.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
  20202. camRight.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
  20203. break;
  20204. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  20205. camLeft.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
  20206. camRight.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
  20207. break;
  20208. }
  20209. _super.prototype._updateRigCameras.call(this);
  20210. };
  20211. /**
  20212. * Destroy the camera and release the current resources hold by it.
  20213. */
  20214. ArcRotateCamera.prototype.dispose = function () {
  20215. this.inputs.clear();
  20216. _super.prototype.dispose.call(this);
  20217. };
  20218. /**
  20219. * Gets the current object class name.
  20220. * @return the class name
  20221. */
  20222. ArcRotateCamera.prototype.getClassName = function () {
  20223. return "ArcRotateCamera";
  20224. };
  20225. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20226. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20227. ], ArcRotateCamera.prototype, "alpha", void 0);
  20228. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20229. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20230. ], ArcRotateCamera.prototype, "beta", void 0);
  20231. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20232. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20233. ], ArcRotateCamera.prototype, "radius", void 0);
  20234. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20235. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("target")
  20236. ], ArcRotateCamera.prototype, "_target", void 0);
  20237. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20238. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20239. ], ArcRotateCamera.prototype, "inertialAlphaOffset", void 0);
  20240. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20241. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20242. ], ArcRotateCamera.prototype, "inertialBetaOffset", void 0);
  20243. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20244. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20245. ], ArcRotateCamera.prototype, "inertialRadiusOffset", void 0);
  20246. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20247. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20248. ], ArcRotateCamera.prototype, "lowerAlphaLimit", void 0);
  20249. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20250. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20251. ], ArcRotateCamera.prototype, "upperAlphaLimit", void 0);
  20252. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20253. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20254. ], ArcRotateCamera.prototype, "lowerBetaLimit", void 0);
  20255. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20256. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20257. ], ArcRotateCamera.prototype, "upperBetaLimit", void 0);
  20258. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20259. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20260. ], ArcRotateCamera.prototype, "lowerRadiusLimit", void 0);
  20261. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20262. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20263. ], ArcRotateCamera.prototype, "upperRadiusLimit", void 0);
  20264. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20265. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20266. ], ArcRotateCamera.prototype, "inertialPanningX", void 0);
  20267. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20268. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20269. ], ArcRotateCamera.prototype, "inertialPanningY", void 0);
  20270. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20271. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20272. ], ArcRotateCamera.prototype, "pinchToPanMaxDistance", void 0);
  20273. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20274. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20275. ], ArcRotateCamera.prototype, "panningDistanceLimit", void 0);
  20276. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20277. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  20278. ], ArcRotateCamera.prototype, "panningOriginTarget", void 0);
  20279. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20280. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20281. ], ArcRotateCamera.prototype, "panningInertia", void 0);
  20282. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20283. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20284. ], ArcRotateCamera.prototype, "zoomOnFactor", void 0);
  20285. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20286. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20287. ], ArcRotateCamera.prototype, "targetScreenOffset", void 0);
  20288. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20289. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20290. ], ArcRotateCamera.prototype, "allowUpsideDown", void 0);
  20291. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20292. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20293. ], ArcRotateCamera.prototype, "useInputToRestoreState", void 0);
  20294. return ArcRotateCamera;
  20295. }(_targetCamera__WEBPACK_IMPORTED_MODULE_10__["TargetCamera"]));
  20296. /***/ }),
  20297. /***/ "./Cameras/arcRotateCameraInputsManager.ts":
  20298. /*!*************************************************!*\
  20299. !*** ./Cameras/arcRotateCameraInputsManager.ts ***!
  20300. \*************************************************/
  20301. /*! exports provided: ArcRotateCameraInputsManager */
  20302. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  20303. "use strict";
  20304. __webpack_require__.r(__webpack_exports__);
  20305. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return ArcRotateCameraInputsManager; });
  20306. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  20307. /* harmony import */ var _Cameras_Inputs_arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraPointersInput */ "./Cameras/Inputs/arcRotateCameraPointersInput.ts");
  20308. /* harmony import */ var _Cameras_Inputs_arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraKeyboardMoveInput */ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts");
  20309. /* harmony import */ var _Cameras_Inputs_arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraMouseWheelInput */ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts");
  20310. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  20311. /**
  20312. * Default Inputs manager for the ArcRotateCamera.
  20313. * It groups all the default supported inputs for ease of use.
  20314. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  20315. */
  20316. var ArcRotateCameraInputsManager = /** @class */ (function (_super) {
  20317. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCameraInputsManager, _super);
  20318. /**
  20319. * Instantiates a new ArcRotateCameraInputsManager.
  20320. * @param camera Defines the camera the inputs belong to
  20321. */
  20322. function ArcRotateCameraInputsManager(camera) {
  20323. return _super.call(this, camera) || this;
  20324. }
  20325. /**
  20326. * Add mouse wheel input support to the input manager.
  20327. * @returns the current input manager
  20328. */
  20329. ArcRotateCameraInputsManager.prototype.addMouseWheel = function () {
  20330. this.add(new _Cameras_Inputs_arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__["ArcRotateCameraMouseWheelInput"]());
  20331. return this;
  20332. };
  20333. /**
  20334. * Add pointers input support to the input manager.
  20335. * @returns the current input manager
  20336. */
  20337. ArcRotateCameraInputsManager.prototype.addPointers = function () {
  20338. this.add(new _Cameras_Inputs_arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraPointersInput"]());
  20339. return this;
  20340. };
  20341. /**
  20342. * Add keyboard input support to the input manager.
  20343. * @returns the current input manager
  20344. */
  20345. ArcRotateCameraInputsManager.prototype.addKeyboard = function () {
  20346. this.add(new _Cameras_Inputs_arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCameraKeyboardMoveInput"]());
  20347. return this;
  20348. };
  20349. return ArcRotateCameraInputsManager;
  20350. }(_Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_4__["CameraInputsManager"]));
  20351. /***/ }),
  20352. /***/ "./Cameras/camera.ts":
  20353. /*!***************************!*\
  20354. !*** ./Cameras/camera.ts ***!
  20355. \***************************/
  20356. /*! exports provided: Camera */
  20357. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  20358. "use strict";
  20359. __webpack_require__.r(__webpack_exports__);
  20360. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return Camera; });
  20361. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  20362. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  20363. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  20364. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  20365. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  20366. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  20367. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  20368. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  20369. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  20370. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  20371. /**
  20372. * This is the base class of all the camera used in the application.
  20373. * @see http://doc.babylonjs.com/features/cameras
  20374. */
  20375. var Camera = /** @class */ (function (_super) {
  20376. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Camera, _super);
  20377. /**
  20378. * Instantiates a new camera object.
  20379. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  20380. * @see http://doc.babylonjs.com/features/cameras
  20381. * @param name Defines the name of the camera in the scene
  20382. * @param position Defines the position of the camera
  20383. * @param scene Defines the scene the camera belongs too
  20384. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  20385. */
  20386. function Camera(name, position, scene, setActiveOnSceneIfNoneActive) {
  20387. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  20388. var _this = _super.call(this, name, scene) || this;
  20389. /** @hidden */
  20390. _this._position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  20391. /**
  20392. * The vector the camera should consider as up.
  20393. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  20394. */
  20395. _this.upVector = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Up();
  20396. /**
  20397. * Define the current limit on the left side for an orthographic camera
  20398. * In scene unit
  20399. */
  20400. _this.orthoLeft = null;
  20401. /**
  20402. * Define the current limit on the right side for an orthographic camera
  20403. * In scene unit
  20404. */
  20405. _this.orthoRight = null;
  20406. /**
  20407. * Define the current limit on the bottom side for an orthographic camera
  20408. * In scene unit
  20409. */
  20410. _this.orthoBottom = null;
  20411. /**
  20412. * Define the current limit on the top side for an orthographic camera
  20413. * In scene unit
  20414. */
  20415. _this.orthoTop = null;
  20416. /**
  20417. * Field Of View is set in Radians. (default is 0.8)
  20418. */
  20419. _this.fov = 0.8;
  20420. /**
  20421. * Define the minimum distance the camera can see from.
  20422. * This is important to note that the depth buffer are not infinite and the closer it starts
  20423. * the more your scene might encounter depth fighting issue.
  20424. */
  20425. _this.minZ = 1;
  20426. /**
  20427. * Define the maximum distance the camera can see to.
  20428. * This is important to note that the depth buffer are not infinite and the further it end
  20429. * the more your scene might encounter depth fighting issue.
  20430. */
  20431. _this.maxZ = 10000.0;
  20432. /**
  20433. * Define the default inertia of the camera.
  20434. * This helps giving a smooth feeling to the camera movement.
  20435. */
  20436. _this.inertia = 0.9;
  20437. /**
  20438. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  20439. */
  20440. _this.mode = Camera.PERSPECTIVE_CAMERA;
  20441. /**
  20442. * Define wether the camera is intermediate.
  20443. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  20444. */
  20445. _this.isIntermediate = false;
  20446. /**
  20447. * Define the viewport of the camera.
  20448. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  20449. */
  20450. _this.viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Viewport"](0, 0, 1.0, 1.0);
  20451. /**
  20452. * Restricts the camera to viewing objects with the same layerMask.
  20453. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  20454. */
  20455. _this.layerMask = 0x0FFFFFFF;
  20456. /**
  20457. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  20458. */
  20459. _this.fovMode = Camera.FOVMODE_VERTICAL_FIXED;
  20460. /**
  20461. * Rig mode of the camera.
  20462. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  20463. * This is normally controlled byt the camera themselves as internal use.
  20464. */
  20465. _this.cameraRigMode = Camera.RIG_MODE_NONE;
  20466. /**
  20467. * 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
  20468. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  20469. * else in the scene.
  20470. */
  20471. _this.customRenderTargets = new Array();
  20472. /**
  20473. * When set, the camera will render to this render target instead of the default canvas
  20474. */
  20475. _this.outputRenderTarget = null;
  20476. /**
  20477. * Observable triggered when the camera view matrix has changed.
  20478. */
  20479. _this.onViewMatrixChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20480. /**
  20481. * Observable triggered when the camera Projection matrix has changed.
  20482. */
  20483. _this.onProjectionMatrixChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20484. /**
  20485. * Observable triggered when the inputs have been processed.
  20486. */
  20487. _this.onAfterCheckInputsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20488. /**
  20489. * Observable triggered when reset has been called and applied to the camera.
  20490. */
  20491. _this.onRestoreStateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20492. /** @hidden */
  20493. _this._rigCameras = new Array();
  20494. _this._webvrViewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20495. /** @hidden */
  20496. _this._skipRendering = false;
  20497. /** @hidden */
  20498. _this._projectionMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  20499. /** @hidden */
  20500. _this._postProcesses = new Array();
  20501. /** @hidden */
  20502. _this._activeMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](256);
  20503. _this._globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  20504. /** hidden */
  20505. _this._computedViewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20506. _this._doNotComputeProjectionMatrix = false;
  20507. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Zero();
  20508. _this._refreshFrustumPlanes = true;
  20509. /** @hidden */
  20510. _this._isCamera = true;
  20511. /** @hidden */
  20512. _this._isLeftCamera = false;
  20513. /** @hidden */
  20514. _this._isRightCamera = true;
  20515. _this.getScene().addCamera(_this);
  20516. if (setActiveOnSceneIfNoneActive && !_this.getScene().activeCamera) {
  20517. _this.getScene().activeCamera = _this;
  20518. }
  20519. _this.position = position;
  20520. return _this;
  20521. }
  20522. Object.defineProperty(Camera.prototype, "position", {
  20523. /**
  20524. * Define the current local position of the camera in the scene
  20525. */
  20526. get: function () {
  20527. return this._position;
  20528. },
  20529. set: function (newPosition) {
  20530. this._position = newPosition;
  20531. },
  20532. enumerable: true,
  20533. configurable: true
  20534. });
  20535. /**
  20536. * Store current camera state (fov, position, etc..)
  20537. * @returns the camera
  20538. */
  20539. Camera.prototype.storeState = function () {
  20540. this._stateStored = true;
  20541. this._storedFov = this.fov;
  20542. return this;
  20543. };
  20544. /**
  20545. * Restores the camera state values if it has been stored. You must call storeState() first
  20546. */
  20547. Camera.prototype._restoreStateValues = function () {
  20548. if (!this._stateStored) {
  20549. return false;
  20550. }
  20551. this.fov = this._storedFov;
  20552. return true;
  20553. };
  20554. /**
  20555. * Restored camera state. You must call storeState() first.
  20556. * @returns true if restored and false otherwise
  20557. */
  20558. Camera.prototype.restoreState = function () {
  20559. if (this._restoreStateValues()) {
  20560. this.onRestoreStateObservable.notifyObservers(this);
  20561. return true;
  20562. }
  20563. return false;
  20564. };
  20565. /**
  20566. * Gets the class name of the camera.
  20567. * @returns the class name
  20568. */
  20569. Camera.prototype.getClassName = function () {
  20570. return "Camera";
  20571. };
  20572. /**
  20573. * Gets a string representation of the camera useful for debug purpose.
  20574. * @param fullDetails Defines that a more verboe level of logging is required
  20575. * @returns the string representation
  20576. */
  20577. Camera.prototype.toString = function (fullDetails) {
  20578. var ret = "Name: " + this.name;
  20579. ret += ", type: " + this.getClassName();
  20580. if (this.animations) {
  20581. for (var i = 0; i < this.animations.length; i++) {
  20582. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  20583. }
  20584. }
  20585. if (fullDetails) {
  20586. }
  20587. return ret;
  20588. };
  20589. Object.defineProperty(Camera.prototype, "globalPosition", {
  20590. /**
  20591. * Gets the current world space position of the camera.
  20592. */
  20593. get: function () {
  20594. return this._globalPosition;
  20595. },
  20596. enumerable: true,
  20597. configurable: true
  20598. });
  20599. /**
  20600. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  20601. * @returns the active meshe list
  20602. */
  20603. Camera.prototype.getActiveMeshes = function () {
  20604. return this._activeMeshes;
  20605. };
  20606. /**
  20607. * Check wether a mesh is part of the current active mesh list of the camera
  20608. * @param mesh Defines the mesh to check
  20609. * @returns true if active, false otherwise
  20610. */
  20611. Camera.prototype.isActiveMesh = function (mesh) {
  20612. return (this._activeMeshes.indexOf(mesh) !== -1);
  20613. };
  20614. /**
  20615. * Is this camera ready to be used/rendered
  20616. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  20617. * @return true if the camera is ready
  20618. */
  20619. Camera.prototype.isReady = function (completeCheck) {
  20620. if (completeCheck === void 0) { completeCheck = false; }
  20621. if (completeCheck) {
  20622. for (var _i = 0, _a = this._postProcesses; _i < _a.length; _i++) {
  20623. var pp = _a[_i];
  20624. if (pp && !pp.isReady()) {
  20625. return false;
  20626. }
  20627. }
  20628. }
  20629. return _super.prototype.isReady.call(this, completeCheck);
  20630. };
  20631. /** @hidden */
  20632. Camera.prototype._initCache = function () {
  20633. _super.prototype._initCache.call(this);
  20634. this._cache.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  20635. this._cache.upVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  20636. this._cache.mode = undefined;
  20637. this._cache.minZ = undefined;
  20638. this._cache.maxZ = undefined;
  20639. this._cache.fov = undefined;
  20640. this._cache.fovMode = undefined;
  20641. this._cache.aspectRatio = undefined;
  20642. this._cache.orthoLeft = undefined;
  20643. this._cache.orthoRight = undefined;
  20644. this._cache.orthoBottom = undefined;
  20645. this._cache.orthoTop = undefined;
  20646. this._cache.renderWidth = undefined;
  20647. this._cache.renderHeight = undefined;
  20648. };
  20649. /** @hidden */
  20650. Camera.prototype._updateCache = function (ignoreParentClass) {
  20651. if (!ignoreParentClass) {
  20652. _super.prototype._updateCache.call(this);
  20653. }
  20654. this._cache.position.copyFrom(this.position);
  20655. this._cache.upVector.copyFrom(this.upVector);
  20656. };
  20657. /** @hidden */
  20658. Camera.prototype._isSynchronized = function () {
  20659. return this._isSynchronizedViewMatrix() && this._isSynchronizedProjectionMatrix();
  20660. };
  20661. /** @hidden */
  20662. Camera.prototype._isSynchronizedViewMatrix = function () {
  20663. if (!_super.prototype._isSynchronized.call(this)) {
  20664. return false;
  20665. }
  20666. return this._cache.position.equals(this.position)
  20667. && this._cache.upVector.equals(this.upVector)
  20668. && this.isSynchronizedWithParent();
  20669. };
  20670. /** @hidden */
  20671. Camera.prototype._isSynchronizedProjectionMatrix = function () {
  20672. var check = this._cache.mode === this.mode
  20673. && this._cache.minZ === this.minZ
  20674. && this._cache.maxZ === this.maxZ;
  20675. if (!check) {
  20676. return false;
  20677. }
  20678. var engine = this.getEngine();
  20679. if (this.mode === Camera.PERSPECTIVE_CAMERA) {
  20680. check = this._cache.fov === this.fov
  20681. && this._cache.fovMode === this.fovMode
  20682. && this._cache.aspectRatio === engine.getAspectRatio(this);
  20683. }
  20684. else {
  20685. check = this._cache.orthoLeft === this.orthoLeft
  20686. && this._cache.orthoRight === this.orthoRight
  20687. && this._cache.orthoBottom === this.orthoBottom
  20688. && this._cache.orthoTop === this.orthoTop
  20689. && this._cache.renderWidth === engine.getRenderWidth()
  20690. && this._cache.renderHeight === engine.getRenderHeight();
  20691. }
  20692. return check;
  20693. };
  20694. /**
  20695. * Attach the input controls to a specific dom element to get the input from.
  20696. * @param element Defines the element the controls should be listened from
  20697. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  20698. */
  20699. Camera.prototype.attachControl = function (element, noPreventDefault) {
  20700. };
  20701. /**
  20702. * Detach the current controls from the specified dom element.
  20703. * @param element Defines the element to stop listening the inputs from
  20704. */
  20705. Camera.prototype.detachControl = function (element) {
  20706. };
  20707. /**
  20708. * Update the camera state according to the different inputs gathered during the frame.
  20709. */
  20710. Camera.prototype.update = function () {
  20711. this._checkInputs();
  20712. if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  20713. this._updateRigCameras();
  20714. }
  20715. };
  20716. /** @hidden */
  20717. Camera.prototype._checkInputs = function () {
  20718. this.onAfterCheckInputsObservable.notifyObservers(this);
  20719. };
  20720. Object.defineProperty(Camera.prototype, "rigCameras", {
  20721. /** @hidden */
  20722. get: function () {
  20723. return this._rigCameras;
  20724. },
  20725. enumerable: true,
  20726. configurable: true
  20727. });
  20728. Object.defineProperty(Camera.prototype, "rigPostProcess", {
  20729. /**
  20730. * Gets the post process used by the rig cameras
  20731. */
  20732. get: function () {
  20733. return this._rigPostProcess;
  20734. },
  20735. enumerable: true,
  20736. configurable: true
  20737. });
  20738. /**
  20739. * Internal, gets the first post proces.
  20740. * @returns the first post process to be run on this camera.
  20741. */
  20742. Camera.prototype._getFirstPostProcess = function () {
  20743. for (var ppIndex = 0; ppIndex < this._postProcesses.length; ppIndex++) {
  20744. if (this._postProcesses[ppIndex] !== null) {
  20745. return this._postProcesses[ppIndex];
  20746. }
  20747. }
  20748. return null;
  20749. };
  20750. Camera.prototype._cascadePostProcessesToRigCams = function () {
  20751. // invalidate framebuffer
  20752. var firstPostProcess = this._getFirstPostProcess();
  20753. if (firstPostProcess) {
  20754. firstPostProcess.markTextureDirty();
  20755. }
  20756. // glue the rigPostProcess to the end of the user postprocesses & assign to each sub-camera
  20757. for (var i = 0, len = this._rigCameras.length; i < len; i++) {
  20758. var cam = this._rigCameras[i];
  20759. var rigPostProcess = cam._rigPostProcess;
  20760. // for VR rig, there does not have to be a post process
  20761. if (rigPostProcess) {
  20762. var isPass = rigPostProcess.getEffectName() === "pass";
  20763. if (isPass) {
  20764. // any rig which has a PassPostProcess for rig[0], cannot be isIntermediate when there are also user postProcesses
  20765. cam.isIntermediate = this._postProcesses.length === 0;
  20766. }
  20767. cam._postProcesses = this._postProcesses.slice(0).concat(rigPostProcess);
  20768. rigPostProcess.markTextureDirty();
  20769. }
  20770. else {
  20771. cam._postProcesses = this._postProcesses.slice(0);
  20772. }
  20773. }
  20774. };
  20775. /**
  20776. * Attach a post process to the camera.
  20777. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  20778. * @param postProcess The post process to attach to the camera
  20779. * @param insertAt The position of the post process in case several of them are in use in the scene
  20780. * @returns the position the post process has been inserted at
  20781. */
  20782. Camera.prototype.attachPostProcess = function (postProcess, insertAt) {
  20783. if (insertAt === void 0) { insertAt = null; }
  20784. if (!postProcess.isReusable() && this._postProcesses.indexOf(postProcess) > -1) {
  20785. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("You're trying to reuse a post process not defined as reusable.");
  20786. return 0;
  20787. }
  20788. if (insertAt == null || insertAt < 0) {
  20789. this._postProcesses.push(postProcess);
  20790. }
  20791. else if (this._postProcesses[insertAt] === null) {
  20792. this._postProcesses[insertAt] = postProcess;
  20793. }
  20794. else {
  20795. this._postProcesses.splice(insertAt, 0, postProcess);
  20796. }
  20797. this._cascadePostProcessesToRigCams(); // also ensures framebuffer invalidated
  20798. return this._postProcesses.indexOf(postProcess);
  20799. };
  20800. /**
  20801. * Detach a post process to the camera.
  20802. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  20803. * @param postProcess The post process to detach from the camera
  20804. */
  20805. Camera.prototype.detachPostProcess = function (postProcess) {
  20806. var idx = this._postProcesses.indexOf(postProcess);
  20807. if (idx !== -1) {
  20808. this._postProcesses[idx] = null;
  20809. }
  20810. this._cascadePostProcessesToRigCams(); // also ensures framebuffer invalidated
  20811. };
  20812. /**
  20813. * Gets the current world matrix of the camera
  20814. */
  20815. Camera.prototype.getWorldMatrix = function () {
  20816. if (this._isSynchronizedViewMatrix()) {
  20817. return this._worldMatrix;
  20818. }
  20819. // Getting the the view matrix will also compute the world matrix.
  20820. this.getViewMatrix();
  20821. return this._worldMatrix;
  20822. };
  20823. /** @hidden */
  20824. Camera.prototype._getViewMatrix = function () {
  20825. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20826. };
  20827. /**
  20828. * Gets the current view matrix of the camera.
  20829. * @param force forces the camera to recompute the matrix without looking at the cached state
  20830. * @returns the view matrix
  20831. */
  20832. Camera.prototype.getViewMatrix = function (force) {
  20833. if (!force && this._isSynchronizedViewMatrix()) {
  20834. return this._computedViewMatrix;
  20835. }
  20836. this.updateCache();
  20837. this._computedViewMatrix = this._getViewMatrix();
  20838. this._currentRenderId = this.getScene().getRenderId();
  20839. this._childRenderId = this._currentRenderId;
  20840. this._refreshFrustumPlanes = true;
  20841. if (this._cameraRigParams && this._cameraRigParams.vrPreViewMatrix) {
  20842. this._computedViewMatrix.multiplyToRef(this._cameraRigParams.vrPreViewMatrix, this._computedViewMatrix);
  20843. }
  20844. this.onViewMatrixChangedObservable.notifyObservers(this);
  20845. this._computedViewMatrix.invertToRef(this._worldMatrix);
  20846. return this._computedViewMatrix;
  20847. };
  20848. /**
  20849. * Freeze the projection matrix.
  20850. * It will prevent the cache check of the camera projection compute and can speed up perf
  20851. * if no parameter of the camera are meant to change
  20852. * @param projection Defines manually a projection if necessary
  20853. */
  20854. Camera.prototype.freezeProjectionMatrix = function (projection) {
  20855. this._doNotComputeProjectionMatrix = true;
  20856. if (projection !== undefined) {
  20857. this._projectionMatrix = projection;
  20858. }
  20859. };
  20860. /**
  20861. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  20862. */
  20863. Camera.prototype.unfreezeProjectionMatrix = function () {
  20864. this._doNotComputeProjectionMatrix = false;
  20865. };
  20866. /**
  20867. * Gets the current projection matrix of the camera.
  20868. * @param force forces the camera to recompute the matrix without looking at the cached state
  20869. * @returns the projection matrix
  20870. */
  20871. Camera.prototype.getProjectionMatrix = function (force) {
  20872. if (this._doNotComputeProjectionMatrix || (!force && this._isSynchronizedProjectionMatrix())) {
  20873. return this._projectionMatrix;
  20874. }
  20875. // Cache
  20876. this._cache.mode = this.mode;
  20877. this._cache.minZ = this.minZ;
  20878. this._cache.maxZ = this.maxZ;
  20879. // Matrix
  20880. this._refreshFrustumPlanes = true;
  20881. var engine = this.getEngine();
  20882. var scene = this.getScene();
  20883. if (this.mode === Camera.PERSPECTIVE_CAMERA) {
  20884. this._cache.fov = this.fov;
  20885. this._cache.fovMode = this.fovMode;
  20886. this._cache.aspectRatio = engine.getAspectRatio(this);
  20887. if (this.minZ <= 0) {
  20888. this.minZ = 0.1;
  20889. }
  20890. if (scene.useRightHandedSystem) {
  20891. _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);
  20892. }
  20893. else {
  20894. _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);
  20895. }
  20896. }
  20897. else {
  20898. var halfWidth = engine.getRenderWidth() / 2.0;
  20899. var halfHeight = engine.getRenderHeight() / 2.0;
  20900. if (scene.useRightHandedSystem) {
  20901. _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);
  20902. }
  20903. else {
  20904. _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);
  20905. }
  20906. this._cache.orthoLeft = this.orthoLeft;
  20907. this._cache.orthoRight = this.orthoRight;
  20908. this._cache.orthoBottom = this.orthoBottom;
  20909. this._cache.orthoTop = this.orthoTop;
  20910. this._cache.renderWidth = engine.getRenderWidth();
  20911. this._cache.renderHeight = engine.getRenderHeight();
  20912. }
  20913. this.onProjectionMatrixChangedObservable.notifyObservers(this);
  20914. return this._projectionMatrix;
  20915. };
  20916. /**
  20917. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  20918. * @returns a Matrix
  20919. */
  20920. Camera.prototype.getTransformationMatrix = function () {
  20921. this._computedViewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  20922. return this._transformMatrix;
  20923. };
  20924. Camera.prototype._updateFrustumPlanes = function () {
  20925. if (!this._refreshFrustumPlanes) {
  20926. return;
  20927. }
  20928. this.getTransformationMatrix();
  20929. if (!this._frustumPlanes) {
  20930. this._frustumPlanes = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Frustum"].GetPlanes(this._transformMatrix);
  20931. }
  20932. else {
  20933. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Frustum"].GetPlanesToRef(this._transformMatrix, this._frustumPlanes);
  20934. }
  20935. this._refreshFrustumPlanes = false;
  20936. };
  20937. /**
  20938. * Checks if a cullable object (mesh...) is in the camera frustum
  20939. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  20940. * @param target The object to check
  20941. * @returns true if the object is in frustum otherwise false
  20942. */
  20943. Camera.prototype.isInFrustum = function (target) {
  20944. this._updateFrustumPlanes();
  20945. return target.isInFrustum(this._frustumPlanes);
  20946. };
  20947. /**
  20948. * Checks if a cullable object (mesh...) is in the camera frustum
  20949. * Unlike isInFrustum this cheks the full bounding box
  20950. * @param target The object to check
  20951. * @returns true if the object is in frustum otherwise false
  20952. */
  20953. Camera.prototype.isCompletelyInFrustum = function (target) {
  20954. this._updateFrustumPlanes();
  20955. return target.isCompletelyInFrustum(this._frustumPlanes);
  20956. };
  20957. /**
  20958. * Gets a ray in the forward direction from the camera.
  20959. * @param length Defines the length of the ray to create
  20960. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  20961. * @param origin Defines the start point of the ray which defaults to the camera position
  20962. * @returns the forward ray
  20963. */
  20964. Camera.prototype.getForwardRay = function (length, transform, origin) {
  20965. if (length === void 0) { length = 100; }
  20966. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__["_DevTools"].WarnImport("Ray");
  20967. };
  20968. /**
  20969. * Releases resources associated with this node.
  20970. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20971. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20972. */
  20973. Camera.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  20974. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  20975. // Observables
  20976. this.onViewMatrixChangedObservable.clear();
  20977. this.onProjectionMatrixChangedObservable.clear();
  20978. this.onAfterCheckInputsObservable.clear();
  20979. this.onRestoreStateObservable.clear();
  20980. // Inputs
  20981. if (this.inputs) {
  20982. this.inputs.clear();
  20983. }
  20984. // Animations
  20985. this.getScene().stopAnimation(this);
  20986. // Remove from scene
  20987. this.getScene().removeCamera(this);
  20988. while (this._rigCameras.length > 0) {
  20989. var camera = this._rigCameras.pop();
  20990. if (camera) {
  20991. camera.dispose();
  20992. }
  20993. }
  20994. // Postprocesses
  20995. if (this._rigPostProcess) {
  20996. this._rigPostProcess.dispose(this);
  20997. this._rigPostProcess = null;
  20998. this._postProcesses = [];
  20999. }
  21000. else if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  21001. this._rigPostProcess = null;
  21002. this._postProcesses = [];
  21003. }
  21004. else {
  21005. var i = this._postProcesses.length;
  21006. while (--i >= 0) {
  21007. var postProcess = this._postProcesses[i];
  21008. if (postProcess) {
  21009. postProcess.dispose(this);
  21010. }
  21011. }
  21012. }
  21013. // Render targets
  21014. var i = this.customRenderTargets.length;
  21015. while (--i >= 0) {
  21016. this.customRenderTargets[i].dispose();
  21017. }
  21018. this.customRenderTargets = [];
  21019. // Active Meshes
  21020. this._activeMeshes.dispose();
  21021. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  21022. };
  21023. Object.defineProperty(Camera.prototype, "isLeftCamera", {
  21024. /**
  21025. * Gets the left camera of a rig setup in case of Rigged Camera
  21026. */
  21027. get: function () {
  21028. return this._isLeftCamera;
  21029. },
  21030. enumerable: true,
  21031. configurable: true
  21032. });
  21033. Object.defineProperty(Camera.prototype, "isRightCamera", {
  21034. /**
  21035. * Gets the right camera of a rig setup in case of Rigged Camera
  21036. */
  21037. get: function () {
  21038. return this._isRightCamera;
  21039. },
  21040. enumerable: true,
  21041. configurable: true
  21042. });
  21043. Object.defineProperty(Camera.prototype, "leftCamera", {
  21044. /**
  21045. * Gets the left camera of a rig setup in case of Rigged Camera
  21046. */
  21047. get: function () {
  21048. if (this._rigCameras.length < 1) {
  21049. return null;
  21050. }
  21051. return this._rigCameras[0];
  21052. },
  21053. enumerable: true,
  21054. configurable: true
  21055. });
  21056. Object.defineProperty(Camera.prototype, "rightCamera", {
  21057. /**
  21058. * Gets the right camera of a rig setup in case of Rigged Camera
  21059. */
  21060. get: function () {
  21061. if (this._rigCameras.length < 2) {
  21062. return null;
  21063. }
  21064. return this._rigCameras[1];
  21065. },
  21066. enumerable: true,
  21067. configurable: true
  21068. });
  21069. /**
  21070. * Gets the left camera target of a rig setup in case of Rigged Camera
  21071. * @returns the target position
  21072. */
  21073. Camera.prototype.getLeftTarget = function () {
  21074. if (this._rigCameras.length < 1) {
  21075. return null;
  21076. }
  21077. return this._rigCameras[0].getTarget();
  21078. };
  21079. /**
  21080. * Gets the right camera target of a rig setup in case of Rigged Camera
  21081. * @returns the target position
  21082. */
  21083. Camera.prototype.getRightTarget = function () {
  21084. if (this._rigCameras.length < 2) {
  21085. return null;
  21086. }
  21087. return this._rigCameras[1].getTarget();
  21088. };
  21089. /**
  21090. * @hidden
  21091. */
  21092. Camera.prototype.setCameraRigMode = function (mode, rigParams) {
  21093. if (this.cameraRigMode === mode) {
  21094. return;
  21095. }
  21096. while (this._rigCameras.length > 0) {
  21097. var camera = this._rigCameras.pop();
  21098. if (camera) {
  21099. camera.dispose();
  21100. }
  21101. }
  21102. this.cameraRigMode = mode;
  21103. this._cameraRigParams = {};
  21104. //we have to implement stereo camera calcultating left and right viewpoints from interaxialDistance and target,
  21105. //not from a given angle as it is now, but until that complete code rewriting provisional stereoHalfAngle value is introduced
  21106. this._cameraRigParams.interaxialDistance = rigParams.interaxialDistance || 0.0637;
  21107. this._cameraRigParams.stereoHalfAngle = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].ToRadians(this._cameraRigParams.interaxialDistance / 0.0637);
  21108. // create the rig cameras, unless none
  21109. if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  21110. var leftCamera = this.createRigCamera(this.name + "_L", 0);
  21111. if (leftCamera) {
  21112. leftCamera._isLeftCamera = true;
  21113. }
  21114. var rightCamera = this.createRigCamera(this.name + "_R", 1);
  21115. if (rightCamera) {
  21116. rightCamera._isRightCamera = true;
  21117. }
  21118. if (leftCamera && rightCamera) {
  21119. this._rigCameras.push(leftCamera);
  21120. this._rigCameras.push(rightCamera);
  21121. }
  21122. }
  21123. switch (this.cameraRigMode) {
  21124. case Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  21125. Camera._setStereoscopicAnaglyphRigMode(this);
  21126. break;
  21127. case Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  21128. case Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  21129. case Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:
  21130. Camera._setStereoscopicRigMode(this);
  21131. break;
  21132. case Camera.RIG_MODE_VR:
  21133. Camera._setVRRigMode(this, rigParams);
  21134. break;
  21135. case Camera.RIG_MODE_WEBVR:
  21136. Camera._setWebVRRigMode(this, rigParams);
  21137. break;
  21138. }
  21139. this._cascadePostProcessesToRigCams();
  21140. this.update();
  21141. };
  21142. /** @hidden */
  21143. Camera._setStereoscopicRigMode = function (camera) {
  21144. throw "Import Cameras/RigModes/stereoscopicRigMode before using stereoscopic rig mode";
  21145. };
  21146. /** @hidden */
  21147. Camera._setStereoscopicAnaglyphRigMode = function (camera) {
  21148. throw "Import Cameras/RigModes/stereoscopicAnaglyphRigMode before using stereoscopic anaglyph rig mode";
  21149. };
  21150. /** @hidden */
  21151. Camera._setVRRigMode = function (camera, rigParams) {
  21152. throw "Import Cameras/RigModes/vrRigMode before using VR rig mode";
  21153. };
  21154. /** @hidden */
  21155. Camera._setWebVRRigMode = function (camera, rigParams) {
  21156. throw "Import Cameras/RigModes/WebVRRigMode before using Web VR rig mode";
  21157. };
  21158. /** @hidden */
  21159. Camera.prototype._getVRProjectionMatrix = function () {
  21160. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov, this._cameraRigParams.vrMetrics.aspectRatio, this.minZ, this.maxZ, this._cameraRigParams.vrWorkMatrix);
  21161. this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix, this._projectionMatrix);
  21162. return this._projectionMatrix;
  21163. };
  21164. Camera.prototype._updateCameraRotationMatrix = function () {
  21165. //Here for WebVR
  21166. };
  21167. Camera.prototype._updateWebVRCameraRotationMatrix = function () {
  21168. //Here for WebVR
  21169. };
  21170. /**
  21171. * This function MUST be overwritten by the different WebVR cameras available.
  21172. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  21173. * @hidden
  21174. */
  21175. Camera.prototype._getWebVRProjectionMatrix = function () {
  21176. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  21177. };
  21178. /**
  21179. * This function MUST be overwritten by the different WebVR cameras available.
  21180. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  21181. * @hidden
  21182. */
  21183. Camera.prototype._getWebVRViewMatrix = function () {
  21184. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  21185. };
  21186. /** @hidden */
  21187. Camera.prototype.setCameraRigParameter = function (name, value) {
  21188. if (!this._cameraRigParams) {
  21189. this._cameraRigParams = {};
  21190. }
  21191. this._cameraRigParams[name] = value;
  21192. //provisionnally:
  21193. if (name === "interaxialDistance") {
  21194. this._cameraRigParams.stereoHalfAngle = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].ToRadians(value / 0.0637);
  21195. }
  21196. };
  21197. /**
  21198. * needs to be overridden by children so sub has required properties to be copied
  21199. * @hidden
  21200. */
  21201. Camera.prototype.createRigCamera = function (name, cameraIndex) {
  21202. return null;
  21203. };
  21204. /**
  21205. * May need to be overridden by children
  21206. * @hidden
  21207. */
  21208. Camera.prototype._updateRigCameras = function () {
  21209. for (var i = 0; i < this._rigCameras.length; i++) {
  21210. this._rigCameras[i].minZ = this.minZ;
  21211. this._rigCameras[i].maxZ = this.maxZ;
  21212. this._rigCameras[i].fov = this.fov;
  21213. this._rigCameras[i].upVector.copyFrom(this.upVector);
  21214. }
  21215. // only update viewport when ANAGLYPH
  21216. if (this.cameraRigMode === Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH) {
  21217. this._rigCameras[0].viewport = this._rigCameras[1].viewport = this.viewport;
  21218. }
  21219. };
  21220. /** @hidden */
  21221. Camera.prototype._setupInputs = function () {
  21222. };
  21223. /**
  21224. * Serialiaze the camera setup to a json represention
  21225. * @returns the JSON representation
  21226. */
  21227. Camera.prototype.serialize = function () {
  21228. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  21229. // Type
  21230. serializationObject.type = this.getClassName();
  21231. // Parent
  21232. if (this.parent) {
  21233. serializationObject.parentId = this.parent.id;
  21234. }
  21235. if (this.inputs) {
  21236. this.inputs.serialize(serializationObject);
  21237. }
  21238. // Animations
  21239. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  21240. serializationObject.ranges = this.serializeAnimationRanges();
  21241. return serializationObject;
  21242. };
  21243. /**
  21244. * Clones the current camera.
  21245. * @param name The cloned camera name
  21246. * @returns the cloned camera
  21247. */
  21248. Camera.prototype.clone = function (name) {
  21249. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(Camera.GetConstructorFromName(this.getClassName(), name, this.getScene(), this.interaxialDistance, this.isStereoscopicSideBySide), this);
  21250. };
  21251. /**
  21252. * Gets the direction of the camera relative to a given local axis.
  21253. * @param localAxis Defines the reference axis to provide a relative direction.
  21254. * @return the direction
  21255. */
  21256. Camera.prototype.getDirection = function (localAxis) {
  21257. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  21258. this.getDirectionToRef(localAxis, result);
  21259. return result;
  21260. };
  21261. /**
  21262. * Gets the direction of the camera relative to a given local axis into a passed vector.
  21263. * @param localAxis Defines the reference axis to provide a relative direction.
  21264. * @param result Defines the vector to store the result in
  21265. */
  21266. Camera.prototype.getDirectionToRef = function (localAxis, result) {
  21267. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
  21268. };
  21269. /**
  21270. * Gets a camera constructor for a given camera type
  21271. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  21272. * @param name The name of the camera the result will be able to instantiate
  21273. * @param scene The scene the result will construct the camera in
  21274. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  21275. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  21276. * @returns a factory method to construc the camera
  21277. */
  21278. Camera.GetConstructorFromName = function (type, name, scene, interaxial_distance, isStereoscopicSideBySide) {
  21279. if (interaxial_distance === void 0) { interaxial_distance = 0; }
  21280. if (isStereoscopicSideBySide === void 0) { isStereoscopicSideBySide = true; }
  21281. var constructorFunc = _node__WEBPACK_IMPORTED_MODULE_6__["Node"].Construct(type, name, scene, {
  21282. interaxial_distance: interaxial_distance,
  21283. isStereoscopicSideBySide: isStereoscopicSideBySide
  21284. });
  21285. if (constructorFunc) {
  21286. return constructorFunc;
  21287. }
  21288. // Default to universal camera
  21289. return function () { return Camera._createDefaultParsedCamera(name, scene); };
  21290. };
  21291. /**
  21292. * Compute the world matrix of the camera.
  21293. * @returns the camera workd matrix
  21294. */
  21295. Camera.prototype.computeWorldMatrix = function () {
  21296. return this.getWorldMatrix();
  21297. };
  21298. /**
  21299. * Parse a JSON and creates the camera from the parsed information
  21300. * @param parsedCamera The JSON to parse
  21301. * @param scene The scene to instantiate the camera in
  21302. * @returns the newly constructed camera
  21303. */
  21304. Camera.Parse = function (parsedCamera, scene) {
  21305. var type = parsedCamera.type;
  21306. var construct = Camera.GetConstructorFromName(type, parsedCamera.name, scene, parsedCamera.interaxial_distance, parsedCamera.isStereoscopicSideBySide);
  21307. var camera = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(construct, parsedCamera, scene);
  21308. // Parent
  21309. if (parsedCamera.parentId) {
  21310. camera._waitingParentId = parsedCamera.parentId;
  21311. }
  21312. //If camera has an input manager, let it parse inputs settings
  21313. if (camera.inputs) {
  21314. camera.inputs.parse(parsedCamera);
  21315. camera._setupInputs();
  21316. }
  21317. if (camera.setPosition) { // need to force position
  21318. camera.position.copyFromFloats(0, 0, 0);
  21319. camera.setPosition(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedCamera.position));
  21320. }
  21321. // Target
  21322. if (parsedCamera.target) {
  21323. if (camera.setTarget) {
  21324. camera.setTarget(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedCamera.target));
  21325. }
  21326. }
  21327. // Apply 3d rig, when found
  21328. if (parsedCamera.cameraRigMode) {
  21329. var rigParams = (parsedCamera.interaxial_distance) ? { interaxialDistance: parsedCamera.interaxial_distance } : {};
  21330. camera.setCameraRigMode(parsedCamera.cameraRigMode, rigParams);
  21331. }
  21332. // Animations
  21333. if (parsedCamera.animations) {
  21334. for (var animationIndex = 0; animationIndex < parsedCamera.animations.length; animationIndex++) {
  21335. var parsedAnimation = parsedCamera.animations[animationIndex];
  21336. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass("BABYLON.Animation");
  21337. if (internalClass) {
  21338. camera.animations.push(internalClass.Parse(parsedAnimation));
  21339. }
  21340. }
  21341. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(camera, parsedCamera, scene);
  21342. }
  21343. if (parsedCamera.autoAnimate) {
  21344. scene.beginAnimation(camera, parsedCamera.autoAnimateFrom, parsedCamera.autoAnimateTo, parsedCamera.autoAnimateLoop, parsedCamera.autoAnimateSpeed || 1.0);
  21345. }
  21346. return camera;
  21347. };
  21348. /** @hidden */
  21349. Camera._createDefaultParsedCamera = function (name, scene) {
  21350. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__["_DevTools"].WarnImport("UniversalCamera");
  21351. };
  21352. /**
  21353. * This is the default projection mode used by the cameras.
  21354. * It helps recreating a feeling of perspective and better appreciate depth.
  21355. * This is the best way to simulate real life cameras.
  21356. */
  21357. Camera.PERSPECTIVE_CAMERA = 0;
  21358. /**
  21359. * This helps creating camera with an orthographic mode.
  21360. * 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.
  21361. */
  21362. Camera.ORTHOGRAPHIC_CAMERA = 1;
  21363. /**
  21364. * This is the default FOV mode for perspective cameras.
  21365. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  21366. */
  21367. Camera.FOVMODE_VERTICAL_FIXED = 0;
  21368. /**
  21369. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  21370. */
  21371. Camera.FOVMODE_HORIZONTAL_FIXED = 1;
  21372. /**
  21373. * This specifies ther is no need for a camera rig.
  21374. * Basically only one eye is rendered corresponding to the camera.
  21375. */
  21376. Camera.RIG_MODE_NONE = 0;
  21377. /**
  21378. * Simulates a camera Rig with one blue eye and one red eye.
  21379. * This can be use with 3d blue and red glasses.
  21380. */
  21381. Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH = 10;
  21382. /**
  21383. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  21384. */
  21385. Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL = 11;
  21386. /**
  21387. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  21388. */
  21389. Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED = 12;
  21390. /**
  21391. * Defines that both eyes of the camera will be rendered over under each other.
  21392. */
  21393. Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER = 13;
  21394. /**
  21395. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  21396. */
  21397. Camera.RIG_MODE_VR = 20;
  21398. /**
  21399. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  21400. */
  21401. Camera.RIG_MODE_WEBVR = 21;
  21402. /**
  21403. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  21404. */
  21405. Camera.RIG_MODE_CUSTOM = 22;
  21406. /**
  21407. * Defines if by default attaching controls should prevent the default javascript event to continue.
  21408. */
  21409. Camera.ForceAttachControlToAlwaysPreventDefault = false;
  21410. /**
  21411. * @hidden
  21412. * Might be removed once multiview will be a thing
  21413. */
  21414. Camera.UseAlternateWebVRRendering = false;
  21415. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21416. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("position")
  21417. ], Camera.prototype, "_position", void 0);
  21418. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21419. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  21420. ], Camera.prototype, "upVector", void 0);
  21421. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21422. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21423. ], Camera.prototype, "orthoLeft", void 0);
  21424. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21425. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21426. ], Camera.prototype, "orthoRight", void 0);
  21427. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21428. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21429. ], Camera.prototype, "orthoBottom", void 0);
  21430. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21431. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21432. ], Camera.prototype, "orthoTop", void 0);
  21433. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21434. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21435. ], Camera.prototype, "fov", void 0);
  21436. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21437. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21438. ], Camera.prototype, "minZ", void 0);
  21439. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21440. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21441. ], Camera.prototype, "maxZ", void 0);
  21442. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21443. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21444. ], Camera.prototype, "inertia", void 0);
  21445. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21446. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21447. ], Camera.prototype, "mode", void 0);
  21448. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21449. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21450. ], Camera.prototype, "layerMask", void 0);
  21451. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21452. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21453. ], Camera.prototype, "fovMode", void 0);
  21454. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21455. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21456. ], Camera.prototype, "cameraRigMode", void 0);
  21457. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21458. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21459. ], Camera.prototype, "interaxialDistance", void 0);
  21460. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21461. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21462. ], Camera.prototype, "isStereoscopicSideBySide", void 0);
  21463. return Camera;
  21464. }(_node__WEBPACK_IMPORTED_MODULE_6__["Node"]));
  21465. /***/ }),
  21466. /***/ "./Cameras/cameraInputsManager.ts":
  21467. /*!****************************************!*\
  21468. !*** ./Cameras/cameraInputsManager.ts ***!
  21469. \****************************************/
  21470. /*! exports provided: CameraInputTypes, CameraInputsManager */
  21471. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21472. "use strict";
  21473. __webpack_require__.r(__webpack_exports__);
  21474. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return CameraInputTypes; });
  21475. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return CameraInputsManager; });
  21476. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  21477. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  21478. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  21479. /**
  21480. * @ignore
  21481. * This is a list of all the different input types that are available in the application.
  21482. * Fo instance: ArcRotateCameraGamepadInput...
  21483. */
  21484. var CameraInputTypes = {};
  21485. /**
  21486. * This represents the input manager used within a camera.
  21487. * It helps dealing with all the different kind of input attached to a camera.
  21488. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21489. */
  21490. var CameraInputsManager = /** @class */ (function () {
  21491. /**
  21492. * Instantiate a new Camera Input Manager.
  21493. * @param camera Defines the camera the input manager blongs to
  21494. */
  21495. function CameraInputsManager(camera) {
  21496. this.attached = {};
  21497. this.camera = camera;
  21498. this.checkInputs = function () { };
  21499. }
  21500. /**
  21501. * Add an input method to a camera
  21502. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21503. * @param input camera input method
  21504. */
  21505. CameraInputsManager.prototype.add = function (input) {
  21506. var type = input.getSimpleName();
  21507. if (this.attached[type]) {
  21508. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("camera input of type " + type + " already exists on camera");
  21509. return;
  21510. }
  21511. this.attached[type] = input;
  21512. input.camera = this.camera;
  21513. //for checkInputs, we are dynamically creating a function
  21514. //the goal is to avoid the performance penalty of looping for inputs in the render loop
  21515. if (input.checkInputs) {
  21516. this.checkInputs = this._addCheckInputs(input.checkInputs.bind(input));
  21517. }
  21518. if (this.attachedElement) {
  21519. input.attachControl(this.attachedElement);
  21520. }
  21521. };
  21522. /**
  21523. * Remove a specific input method from a camera
  21524. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  21525. * @param inputToRemove camera input method
  21526. */
  21527. CameraInputsManager.prototype.remove = function (inputToRemove) {
  21528. for (var cam in this.attached) {
  21529. var input = this.attached[cam];
  21530. if (input === inputToRemove) {
  21531. input.detachControl(this.attachedElement);
  21532. input.camera = null;
  21533. delete this.attached[cam];
  21534. this.rebuildInputCheck();
  21535. }
  21536. }
  21537. };
  21538. /**
  21539. * Remove a specific input type from a camera
  21540. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  21541. * @param inputType the type of the input to remove
  21542. */
  21543. CameraInputsManager.prototype.removeByType = function (inputType) {
  21544. for (var cam in this.attached) {
  21545. var input = this.attached[cam];
  21546. if (input.getClassName() === inputType) {
  21547. input.detachControl(this.attachedElement);
  21548. input.camera = null;
  21549. delete this.attached[cam];
  21550. this.rebuildInputCheck();
  21551. }
  21552. }
  21553. };
  21554. CameraInputsManager.prototype._addCheckInputs = function (fn) {
  21555. var current = this.checkInputs;
  21556. return function () {
  21557. current();
  21558. fn();
  21559. };
  21560. };
  21561. /**
  21562. * Attach the input controls to the currently attached dom element to listen the events from.
  21563. * @param input Defines the input to attach
  21564. */
  21565. CameraInputsManager.prototype.attachInput = function (input) {
  21566. if (this.attachedElement) {
  21567. input.attachControl(this.attachedElement, this.noPreventDefault);
  21568. }
  21569. };
  21570. /**
  21571. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  21572. * @param element Defines the dom element to collect the events from
  21573. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  21574. */
  21575. CameraInputsManager.prototype.attachElement = function (element, noPreventDefault) {
  21576. if (noPreventDefault === void 0) { noPreventDefault = false; }
  21577. if (this.attachedElement) {
  21578. return;
  21579. }
  21580. noPreventDefault = _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;
  21581. this.attachedElement = element;
  21582. this.noPreventDefault = noPreventDefault;
  21583. for (var cam in this.attached) {
  21584. this.attached[cam].attachControl(element, noPreventDefault);
  21585. }
  21586. };
  21587. /**
  21588. * Detach the current manager inputs controls from a specific dom element.
  21589. * @param element Defines the dom element to collect the events from
  21590. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  21591. */
  21592. CameraInputsManager.prototype.detachElement = function (element, disconnect) {
  21593. if (disconnect === void 0) { disconnect = false; }
  21594. if (this.attachedElement !== element) {
  21595. return;
  21596. }
  21597. for (var cam in this.attached) {
  21598. this.attached[cam].detachControl(element);
  21599. if (disconnect) {
  21600. this.attached[cam].camera = null;
  21601. }
  21602. }
  21603. this.attachedElement = null;
  21604. };
  21605. /**
  21606. * Rebuild the dynamic inputCheck function from the current list of
  21607. * defined inputs in the manager.
  21608. */
  21609. CameraInputsManager.prototype.rebuildInputCheck = function () {
  21610. this.checkInputs = function () { };
  21611. for (var cam in this.attached) {
  21612. var input = this.attached[cam];
  21613. if (input.checkInputs) {
  21614. this.checkInputs = this._addCheckInputs(input.checkInputs.bind(input));
  21615. }
  21616. }
  21617. };
  21618. /**
  21619. * Remove all attached input methods from a camera
  21620. */
  21621. CameraInputsManager.prototype.clear = function () {
  21622. if (this.attachedElement) {
  21623. this.detachElement(this.attachedElement, true);
  21624. }
  21625. this.attached = {};
  21626. this.attachedElement = null;
  21627. this.checkInputs = function () { };
  21628. };
  21629. /**
  21630. * Serialize the current input manager attached to a camera.
  21631. * This ensures than once parsed,
  21632. * the input associated to the camera will be identical to the current ones
  21633. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  21634. */
  21635. CameraInputsManager.prototype.serialize = function (serializedCamera) {
  21636. var inputs = {};
  21637. for (var cam in this.attached) {
  21638. var input = this.attached[cam];
  21639. var res = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(input);
  21640. inputs[input.getClassName()] = res;
  21641. }
  21642. serializedCamera.inputsmgr = inputs;
  21643. };
  21644. /**
  21645. * Parses an input manager serialized JSON to restore the previous list of inputs
  21646. * and states associated to a camera.
  21647. * @param parsedCamera Defines the JSON to parse
  21648. */
  21649. CameraInputsManager.prototype.parse = function (parsedCamera) {
  21650. var parsedInputs = parsedCamera.inputsmgr;
  21651. if (parsedInputs) {
  21652. this.clear();
  21653. for (var n in parsedInputs) {
  21654. var construct = CameraInputTypes[n];
  21655. if (construct) {
  21656. var parsedinput = parsedInputs[n];
  21657. var input = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new construct(); }, parsedinput, null);
  21658. this.add(input);
  21659. }
  21660. }
  21661. }
  21662. else {
  21663. //2016-03-08 this part is for managing backward compatibility
  21664. for (var n in this.attached) {
  21665. var construct = CameraInputTypes[this.attached[n].getClassName()];
  21666. if (construct) {
  21667. var input = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new construct(); }, parsedCamera, null);
  21668. this.remove(this.attached[n]);
  21669. this.add(input);
  21670. }
  21671. }
  21672. }
  21673. };
  21674. return CameraInputsManager;
  21675. }());
  21676. /***/ }),
  21677. /***/ "./Cameras/deviceOrientationCamera.ts":
  21678. /*!********************************************!*\
  21679. !*** ./Cameras/deviceOrientationCamera.ts ***!
  21680. \********************************************/
  21681. /*! exports provided: DeviceOrientationCamera */
  21682. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21683. "use strict";
  21684. __webpack_require__.r(__webpack_exports__);
  21685. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return DeviceOrientationCamera; });
  21686. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21687. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  21688. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  21689. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  21690. /* harmony import */ var _Inputs_freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/freeCameraDeviceOrientationInput */ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts");
  21691. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("DeviceOrientationCamera", function (name, scene) {
  21692. return function () { return new DeviceOrientationCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  21693. });
  21694. // We're mainly based on the logic defined into the FreeCamera code
  21695. /**
  21696. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  21697. * being tilted forward or back and left or right.
  21698. */
  21699. var DeviceOrientationCamera = /** @class */ (function (_super) {
  21700. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DeviceOrientationCamera, _super);
  21701. /**
  21702. * Creates a new device orientation camera
  21703. * @param name The name of the camera
  21704. * @param position The start position camera
  21705. * @param scene The scene the camera belongs to
  21706. */
  21707. function DeviceOrientationCamera(name, position, scene) {
  21708. var _this = _super.call(this, name, position, scene) || this;
  21709. _this._quaternionCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  21710. _this.inputs.addDeviceOrientation();
  21711. return _this;
  21712. }
  21713. /**
  21714. * Gets the current instance class name ("DeviceOrientationCamera").
  21715. * This helps avoiding instanceof at run time.
  21716. * @returns the class name
  21717. */
  21718. DeviceOrientationCamera.prototype.getClassName = function () {
  21719. return "DeviceOrientationCamera";
  21720. };
  21721. /**
  21722. * @hidden
  21723. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  21724. */
  21725. DeviceOrientationCamera.prototype._checkInputs = function () {
  21726. _super.prototype._checkInputs.call(this);
  21727. this._quaternionCache.copyFrom(this.rotationQuaternion);
  21728. if (this._initialQuaternion) {
  21729. this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  21730. }
  21731. };
  21732. /**
  21733. * Reset the camera to its default orientation on the specified axis only.
  21734. * @param axis The axis to reset
  21735. */
  21736. DeviceOrientationCamera.prototype.resetToCurrentRotation = function (axis) {
  21737. var _this = this;
  21738. if (axis === void 0) { axis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y; }
  21739. //can only work if this camera has a rotation quaternion already.
  21740. if (!this.rotationQuaternion) {
  21741. return;
  21742. }
  21743. if (!this._initialQuaternion) {
  21744. this._initialQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  21745. }
  21746. this._initialQuaternion.copyFrom(this._quaternionCache || this.rotationQuaternion);
  21747. ['x', 'y', 'z'].forEach(function (axisName) {
  21748. if (!axis[axisName]) {
  21749. _this._initialQuaternion[axisName] = 0;
  21750. }
  21751. else {
  21752. _this._initialQuaternion[axisName] *= -1;
  21753. }
  21754. });
  21755. this._initialQuaternion.normalize();
  21756. //force rotation update
  21757. this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  21758. };
  21759. return DeviceOrientationCamera;
  21760. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  21761. /***/ }),
  21762. /***/ "./Cameras/flyCamera.ts":
  21763. /*!******************************!*\
  21764. !*** ./Cameras/flyCamera.ts ***!
  21765. \******************************/
  21766. /*! exports provided: FlyCamera */
  21767. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21768. "use strict";
  21769. __webpack_require__.r(__webpack_exports__);
  21770. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return FlyCamera; });
  21771. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21772. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  21773. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  21774. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  21775. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  21776. /* harmony import */ var _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./flyCameraInputsManager */ "./Cameras/flyCameraInputsManager.ts");
  21777. /**
  21778. * This is a flying camera, designed for 3D movement and rotation in all directions,
  21779. * such as in a 3D Space Shooter or a Flight Simulator.
  21780. */
  21781. var FlyCamera = /** @class */ (function (_super) {
  21782. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FlyCamera, _super);
  21783. /**
  21784. * Instantiates a FlyCamera.
  21785. * This is a flying camera, designed for 3D movement and rotation in all directions,
  21786. * such as in a 3D Space Shooter or a Flight Simulator.
  21787. * @param name Define the name of the camera in the scene.
  21788. * @param position Define the starting position of the camera in the scene.
  21789. * @param scene Define the scene the camera belongs to.
  21790. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  21791. */
  21792. function FlyCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  21793. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  21794. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  21795. /**
  21796. * Define the collision ellipsoid of the camera.
  21797. * This is helpful for simulating a camera body, like a player's body.
  21798. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  21799. */
  21800. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 1, 1);
  21801. /**
  21802. * Define an offset for the position of the ellipsoid around the camera.
  21803. * This can be helpful if the camera is attached away from the player's body center,
  21804. * such as at its head.
  21805. */
  21806. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  21807. /**
  21808. * Enable or disable collisions of the camera with the rest of the scene objects.
  21809. */
  21810. _this.checkCollisions = false;
  21811. /**
  21812. * Enable or disable gravity on the camera.
  21813. */
  21814. _this.applyGravity = false;
  21815. /**
  21816. * Define the current direction the camera is moving to.
  21817. */
  21818. _this.cameraDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21819. /**
  21820. * Track Roll to maintain the wanted Rolling when looking around.
  21821. */
  21822. _this._trackRoll = 0;
  21823. /**
  21824. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  21825. */
  21826. _this.rollCorrect = 100;
  21827. /**
  21828. * Mimic a banked turn, Rolling the camera when Yawing.
  21829. * It's recommended to use rollCorrect = 10 for faster banking correction.
  21830. */
  21831. _this.bankedTurn = false;
  21832. /**
  21833. * Limit in radians for how much Roll banking will add. (Default: 90°)
  21834. */
  21835. _this.bankedTurnLimit = Math.PI / 2;
  21836. /**
  21837. * Value of 0 disables the banked Roll.
  21838. * Value of 1 is equal to the Yaw angle in radians.
  21839. */
  21840. _this.bankedTurnMultiplier = 1;
  21841. _this._needMoveForGravity = false;
  21842. _this._oldPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21843. _this._diffPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21844. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21845. // Collisions.
  21846. _this._collisionMask = -1;
  21847. /** @hidden */
  21848. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  21849. if (collidedMesh === void 0) { collidedMesh = null; }
  21850. var updatePosition = function (newPos) {
  21851. _this._newPosition.copyFrom(newPos);
  21852. _this._newPosition.subtractToRef(_this._oldPosition, _this._diffPosition);
  21853. if (_this._diffPosition.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].CollisionsEpsilon) {
  21854. _this.position.addInPlace(_this._diffPosition);
  21855. if (_this.onCollide && collidedMesh) {
  21856. _this.onCollide(collidedMesh);
  21857. }
  21858. }
  21859. };
  21860. updatePosition(newPosition);
  21861. };
  21862. _this.inputs = new _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FlyCameraInputsManager"](_this);
  21863. _this.inputs.addKeyboard().addMouse();
  21864. return _this;
  21865. }
  21866. Object.defineProperty(FlyCamera.prototype, "angularSensibility", {
  21867. /**
  21868. * Gets the input sensibility for mouse input.
  21869. * Higher values reduce sensitivity.
  21870. */
  21871. get: function () {
  21872. var mouse = this.inputs.attached["mouse"];
  21873. if (mouse) {
  21874. return mouse.angularSensibility;
  21875. }
  21876. return 0;
  21877. },
  21878. /**
  21879. * Sets the input sensibility for a mouse input.
  21880. * Higher values reduce sensitivity.
  21881. */
  21882. set: function (value) {
  21883. var mouse = this.inputs.attached["mouse"];
  21884. if (mouse) {
  21885. mouse.angularSensibility = value;
  21886. }
  21887. },
  21888. enumerable: true,
  21889. configurable: true
  21890. });
  21891. Object.defineProperty(FlyCamera.prototype, "keysForward", {
  21892. /**
  21893. * Get the keys for camera movement forward.
  21894. */
  21895. get: function () {
  21896. var keyboard = this.inputs.attached["keyboard"];
  21897. if (keyboard) {
  21898. return keyboard.keysForward;
  21899. }
  21900. return [];
  21901. },
  21902. /**
  21903. * Set the keys for camera movement forward.
  21904. */
  21905. set: function (value) {
  21906. var keyboard = this.inputs.attached["keyboard"];
  21907. if (keyboard) {
  21908. keyboard.keysForward = value;
  21909. }
  21910. },
  21911. enumerable: true,
  21912. configurable: true
  21913. });
  21914. Object.defineProperty(FlyCamera.prototype, "keysBackward", {
  21915. /**
  21916. * Get the keys for camera movement backward.
  21917. */
  21918. get: function () {
  21919. var keyboard = this.inputs.attached["keyboard"];
  21920. if (keyboard) {
  21921. return keyboard.keysBackward;
  21922. }
  21923. return [];
  21924. },
  21925. set: function (value) {
  21926. var keyboard = this.inputs.attached["keyboard"];
  21927. if (keyboard) {
  21928. keyboard.keysBackward = value;
  21929. }
  21930. },
  21931. enumerable: true,
  21932. configurable: true
  21933. });
  21934. Object.defineProperty(FlyCamera.prototype, "keysUp", {
  21935. /**
  21936. * Get the keys for camera movement up.
  21937. */
  21938. get: function () {
  21939. var keyboard = this.inputs.attached["keyboard"];
  21940. if (keyboard) {
  21941. return keyboard.keysUp;
  21942. }
  21943. return [];
  21944. },
  21945. /**
  21946. * Set the keys for camera movement up.
  21947. */
  21948. set: function (value) {
  21949. var keyboard = this.inputs.attached["keyboard"];
  21950. if (keyboard) {
  21951. keyboard.keysUp = value;
  21952. }
  21953. },
  21954. enumerable: true,
  21955. configurable: true
  21956. });
  21957. Object.defineProperty(FlyCamera.prototype, "keysDown", {
  21958. /**
  21959. * Get the keys for camera movement down.
  21960. */
  21961. get: function () {
  21962. var keyboard = this.inputs.attached["keyboard"];
  21963. if (keyboard) {
  21964. return keyboard.keysDown;
  21965. }
  21966. return [];
  21967. },
  21968. /**
  21969. * Set the keys for camera movement down.
  21970. */
  21971. set: function (value) {
  21972. var keyboard = this.inputs.attached["keyboard"];
  21973. if (keyboard) {
  21974. keyboard.keysDown = value;
  21975. }
  21976. },
  21977. enumerable: true,
  21978. configurable: true
  21979. });
  21980. Object.defineProperty(FlyCamera.prototype, "keysLeft", {
  21981. /**
  21982. * Get the keys for camera movement left.
  21983. */
  21984. get: function () {
  21985. var keyboard = this.inputs.attached["keyboard"];
  21986. if (keyboard) {
  21987. return keyboard.keysLeft;
  21988. }
  21989. return [];
  21990. },
  21991. /**
  21992. * Set the keys for camera movement left.
  21993. */
  21994. set: function (value) {
  21995. var keyboard = this.inputs.attached["keyboard"];
  21996. if (keyboard) {
  21997. keyboard.keysLeft = value;
  21998. }
  21999. },
  22000. enumerable: true,
  22001. configurable: true
  22002. });
  22003. Object.defineProperty(FlyCamera.prototype, "keysRight", {
  22004. /**
  22005. * Set the keys for camera movement right.
  22006. */
  22007. get: function () {
  22008. var keyboard = this.inputs.attached["keyboard"];
  22009. if (keyboard) {
  22010. return keyboard.keysRight;
  22011. }
  22012. return [];
  22013. },
  22014. /**
  22015. * Set the keys for camera movement right.
  22016. */
  22017. set: function (value) {
  22018. var keyboard = this.inputs.attached["keyboard"];
  22019. if (keyboard) {
  22020. keyboard.keysRight = value;
  22021. }
  22022. },
  22023. enumerable: true,
  22024. configurable: true
  22025. });
  22026. /**
  22027. * Attach a control to the HTML DOM element.
  22028. * @param element Defines the element that listens to the input events.
  22029. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  22030. */
  22031. FlyCamera.prototype.attachControl = function (element, noPreventDefault) {
  22032. this.inputs.attachElement(element, noPreventDefault);
  22033. };
  22034. /**
  22035. * Detach a control from the HTML DOM element.
  22036. * The camera will stop reacting to that input.
  22037. * @param element Defines the element that listens to the input events.
  22038. */
  22039. FlyCamera.prototype.detachControl = function (element) {
  22040. this.inputs.detachElement(element);
  22041. this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  22042. };
  22043. Object.defineProperty(FlyCamera.prototype, "collisionMask", {
  22044. /**
  22045. * Get the mask that the camera ignores in collision events.
  22046. */
  22047. get: function () {
  22048. return this._collisionMask;
  22049. },
  22050. /**
  22051. * Set the mask that the camera ignores in collision events.
  22052. */
  22053. set: function (mask) {
  22054. this._collisionMask = !isNaN(mask) ? mask : -1;
  22055. },
  22056. enumerable: true,
  22057. configurable: true
  22058. });
  22059. /** @hidden */
  22060. FlyCamera.prototype._collideWithWorld = function (displacement) {
  22061. var globalPosition;
  22062. if (this.parent) {
  22063. globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this.position, this.parent.getWorldMatrix());
  22064. }
  22065. else {
  22066. globalPosition = this.position;
  22067. }
  22068. globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition);
  22069. this._oldPosition.addInPlace(this.ellipsoidOffset);
  22070. var coordinator = this.getScene().collisionCoordinator;
  22071. if (!this._collider) {
  22072. this._collider = coordinator.createCollider();
  22073. }
  22074. this._collider._radius = this.ellipsoid;
  22075. this._collider.collisionMask = this._collisionMask;
  22076. // No need for clone, as long as gravity is not on.
  22077. var actualDisplacement = displacement;
  22078. // Add gravity to direction to prevent dual-collision checking.
  22079. if (this.applyGravity) {
  22080. // This prevents mending with cameraDirection, a global variable of the fly camera class.
  22081. actualDisplacement = displacement.add(this.getScene().gravity);
  22082. }
  22083. coordinator.getNewPosition(this._oldPosition, actualDisplacement, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  22084. };
  22085. /** @hidden */
  22086. FlyCamera.prototype._checkInputs = function () {
  22087. if (!this._localDirection) {
  22088. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22089. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22090. }
  22091. this.inputs.checkInputs();
  22092. _super.prototype._checkInputs.call(this);
  22093. };
  22094. /** @hidden */
  22095. FlyCamera.prototype._decideIfNeedsToMove = function () {
  22096. return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  22097. };
  22098. /** @hidden */
  22099. FlyCamera.prototype._updatePosition = function () {
  22100. if (this.checkCollisions && this.getScene().collisionsEnabled) {
  22101. this._collideWithWorld(this.cameraDirection);
  22102. }
  22103. else {
  22104. _super.prototype._updatePosition.call(this);
  22105. }
  22106. };
  22107. /**
  22108. * Restore the Roll to its target value at the rate specified.
  22109. * @param rate - Higher means slower restoring.
  22110. * @hidden
  22111. */
  22112. FlyCamera.prototype.restoreRoll = function (rate) {
  22113. var limit = this._trackRoll; // Target Roll.
  22114. var z = this.rotation.z; // Current Roll.
  22115. var delta = limit - z; // Difference in Roll.
  22116. var minRad = 0.001; // Tenth of a radian is a barely noticable difference.
  22117. // If the difference is noticable, restore the Roll.
  22118. if (Math.abs(delta) >= minRad) {
  22119. // Change Z rotation towards the target Roll.
  22120. this.rotation.z += delta / rate;
  22121. // Match when near enough.
  22122. if (Math.abs(limit - this.rotation.z) <= minRad) {
  22123. this.rotation.z = limit;
  22124. }
  22125. }
  22126. };
  22127. /**
  22128. * Destroy the camera and release the current resources held by it.
  22129. */
  22130. FlyCamera.prototype.dispose = function () {
  22131. this.inputs.clear();
  22132. _super.prototype.dispose.call(this);
  22133. };
  22134. /**
  22135. * Get the current object class name.
  22136. * @returns the class name.
  22137. */
  22138. FlyCamera.prototype.getClassName = function () {
  22139. return "FlyCamera";
  22140. };
  22141. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22142. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  22143. ], FlyCamera.prototype, "ellipsoid", void 0);
  22144. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22145. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  22146. ], FlyCamera.prototype, "ellipsoidOffset", void 0);
  22147. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22148. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22149. ], FlyCamera.prototype, "checkCollisions", void 0);
  22150. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22151. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22152. ], FlyCamera.prototype, "applyGravity", void 0);
  22153. return FlyCamera;
  22154. }(_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]));
  22155. /***/ }),
  22156. /***/ "./Cameras/flyCameraInputsManager.ts":
  22157. /*!*******************************************!*\
  22158. !*** ./Cameras/flyCameraInputsManager.ts ***!
  22159. \*******************************************/
  22160. /*! exports provided: FlyCameraInputsManager */
  22161. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22162. "use strict";
  22163. __webpack_require__.r(__webpack_exports__);
  22164. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return FlyCameraInputsManager; });
  22165. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22166. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  22167. /* harmony import */ var _Cameras_Inputs_flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/flyCameraMouseInput */ "./Cameras/Inputs/flyCameraMouseInput.ts");
  22168. /* harmony import */ var _Cameras_Inputs_flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/flyCameraKeyboardInput */ "./Cameras/Inputs/flyCameraKeyboardInput.ts");
  22169. /**
  22170. * Default Inputs manager for the FlyCamera.
  22171. * It groups all the default supported inputs for ease of use.
  22172. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  22173. */
  22174. var FlyCameraInputsManager = /** @class */ (function (_super) {
  22175. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FlyCameraInputsManager, _super);
  22176. /**
  22177. * Instantiates a new FlyCameraInputsManager.
  22178. * @param camera Defines the camera the inputs belong to.
  22179. */
  22180. function FlyCameraInputsManager(camera) {
  22181. return _super.call(this, camera) || this;
  22182. }
  22183. /**
  22184. * Add keyboard input support to the input manager.
  22185. * @returns the new FlyCameraKeyboardMoveInput().
  22186. */
  22187. FlyCameraInputsManager.prototype.addKeyboard = function () {
  22188. this.add(new _Cameras_Inputs_flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_3__["FlyCameraKeyboardInput"]());
  22189. return this;
  22190. };
  22191. /**
  22192. * Add mouse input support to the input manager.
  22193. * @param touchEnabled Enable touch screen support.
  22194. * @returns the new FlyCameraMouseInput().
  22195. */
  22196. FlyCameraInputsManager.prototype.addMouse = function (touchEnabled) {
  22197. if (touchEnabled === void 0) { touchEnabled = true; }
  22198. this.add(new _Cameras_Inputs_flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_2__["FlyCameraMouseInput"](touchEnabled));
  22199. return this;
  22200. };
  22201. return FlyCameraInputsManager;
  22202. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  22203. /***/ }),
  22204. /***/ "./Cameras/followCamera.ts":
  22205. /*!*********************************!*\
  22206. !*** ./Cameras/followCamera.ts ***!
  22207. \*********************************/
  22208. /*! exports provided: FollowCamera, ArcFollowCamera */
  22209. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22210. "use strict";
  22211. __webpack_require__.r(__webpack_exports__);
  22212. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return FollowCamera; });
  22213. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return ArcFollowCamera; });
  22214. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22215. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  22216. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  22217. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  22218. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22219. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../node */ "./node.ts");
  22220. /* harmony import */ var _followCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./followCameraInputsManager */ "./Cameras/followCameraInputsManager.ts");
  22221. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("FollowCamera", function (name, scene) {
  22222. return function () { return new FollowCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  22223. });
  22224. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("ArcFollowCamera", function (name, scene) {
  22225. return function () { return new ArcFollowCamera(name, 0, 0, 1.0, null, scene); };
  22226. });
  22227. /**
  22228. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  22229. * an arc rotate version arcFollowCamera are available.
  22230. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  22231. */
  22232. var FollowCamera = /** @class */ (function (_super) {
  22233. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCamera, _super);
  22234. /**
  22235. * Instantiates the follow camera.
  22236. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  22237. * @param name Define the name of the camera in the scene
  22238. * @param position Define the position of the camera
  22239. * @param scene Define the scene the camera belong to
  22240. * @param lockedTarget Define the target of the camera
  22241. */
  22242. function FollowCamera(name, position, scene, lockedTarget) {
  22243. if (lockedTarget === void 0) { lockedTarget = null; }
  22244. var _this = _super.call(this, name, position, scene) || this;
  22245. /**
  22246. * Distance the follow camera should follow an object at
  22247. */
  22248. _this.radius = 12;
  22249. /**
  22250. * Minimum allowed distance of the camera to the axis of rotation
  22251. * (The camera can not get closer).
  22252. * This can help limiting how the Camera is able to move in the scene.
  22253. */
  22254. _this.lowerRadiusLimit = null;
  22255. /**
  22256. * Maximum allowed distance of the camera to the axis of rotation
  22257. * (The camera can not get further).
  22258. * This can help limiting how the Camera is able to move in the scene.
  22259. */
  22260. _this.upperRadiusLimit = null;
  22261. /**
  22262. * Define a rotation offset between the camera and the object it follows
  22263. */
  22264. _this.rotationOffset = 0;
  22265. /**
  22266. * Minimum allowed angle to camera position relative to target object.
  22267. * This can help limiting how the Camera is able to move in the scene.
  22268. */
  22269. _this.lowerRotationOffsetLimit = null;
  22270. /**
  22271. * Maximum allowed angle to camera position relative to target object.
  22272. * This can help limiting how the Camera is able to move in the scene.
  22273. */
  22274. _this.upperRotationOffsetLimit = null;
  22275. /**
  22276. * Define a height offset between the camera and the object it follows.
  22277. * It can help following an object from the top (like a car chaing a plane)
  22278. */
  22279. _this.heightOffset = 4;
  22280. /**
  22281. * Minimum allowed height of camera position relative to target object.
  22282. * This can help limiting how the Camera is able to move in the scene.
  22283. */
  22284. _this.lowerHeightOffsetLimit = null;
  22285. /**
  22286. * Maximum allowed height of camera position relative to target object.
  22287. * This can help limiting how the Camera is able to move in the scene.
  22288. */
  22289. _this.upperHeightOffsetLimit = null;
  22290. /**
  22291. * Define how fast the camera can accelerate to follow it s target.
  22292. */
  22293. _this.cameraAcceleration = 0.05;
  22294. /**
  22295. * Define the speed limit of the camera following an object.
  22296. */
  22297. _this.maxCameraSpeed = 20;
  22298. _this.lockedTarget = lockedTarget;
  22299. _this.inputs = new _followCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__["FollowCameraInputsManager"](_this);
  22300. _this.inputs.addKeyboard().addMouseWheel().addPointers();
  22301. return _this;
  22302. // Uncomment the following line when the relevant handlers have been implemented.
  22303. // this.inputs.addKeyboard().addMouseWheel().addPointers().addVRDeviceOrientation();
  22304. }
  22305. FollowCamera.prototype._follow = function (cameraTarget) {
  22306. if (!cameraTarget) {
  22307. return;
  22308. }
  22309. var yRotation;
  22310. if (cameraTarget.rotationQuaternion) {
  22311. var rotMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  22312. cameraTarget.rotationQuaternion.toRotationMatrix(rotMatrix);
  22313. yRotation = Math.atan2(rotMatrix.m[8], rotMatrix.m[10]);
  22314. }
  22315. else {
  22316. yRotation = cameraTarget.rotation.y;
  22317. }
  22318. var radians = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(this.rotationOffset) + yRotation;
  22319. var targetPosition = cameraTarget.getAbsolutePosition();
  22320. var targetX = targetPosition.x + Math.sin(radians) * this.radius;
  22321. var targetZ = targetPosition.z + Math.cos(radians) * this.radius;
  22322. var dx = targetX - this.position.x;
  22323. var dy = (targetPosition.y + this.heightOffset) - this.position.y;
  22324. var dz = (targetZ) - this.position.z;
  22325. var vx = dx * this.cameraAcceleration * 2; //this is set to .05
  22326. var vy = dy * this.cameraAcceleration;
  22327. var vz = dz * this.cameraAcceleration * 2;
  22328. if (vx > this.maxCameraSpeed || vx < -this.maxCameraSpeed) {
  22329. vx = vx < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  22330. }
  22331. if (vy > this.maxCameraSpeed || vy < -this.maxCameraSpeed) {
  22332. vy = vy < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  22333. }
  22334. if (vz > this.maxCameraSpeed || vz < -this.maxCameraSpeed) {
  22335. vz = vz < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  22336. }
  22337. this.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](this.position.x + vx, this.position.y + vy, this.position.z + vz);
  22338. this.setTarget(targetPosition);
  22339. };
  22340. /**
  22341. * Attached controls to the current camera.
  22342. * @param element Defines the element the controls should be listened from
  22343. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  22344. */
  22345. FollowCamera.prototype.attachControl = function (element, noPreventDefault) {
  22346. this.inputs.attachElement(element, noPreventDefault);
  22347. this._reset = function () {
  22348. };
  22349. };
  22350. /**
  22351. * Detach the current controls from the camera.
  22352. * The camera will stop reacting to inputs.
  22353. * @param element Defines the element to stop listening the inputs from
  22354. */
  22355. FollowCamera.prototype.detachControl = function (element) {
  22356. this.inputs.detachElement(element);
  22357. if (this._reset) {
  22358. this._reset();
  22359. }
  22360. };
  22361. /** @hidden */
  22362. FollowCamera.prototype._checkInputs = function () {
  22363. this.inputs.checkInputs();
  22364. this._checkLimits();
  22365. _super.prototype._checkInputs.call(this);
  22366. if (this.lockedTarget) {
  22367. this._follow(this.lockedTarget);
  22368. }
  22369. };
  22370. FollowCamera.prototype._checkLimits = function () {
  22371. if (this.lowerRadiusLimit !== null && this.radius < this.lowerRadiusLimit) {
  22372. this.radius = this.lowerRadiusLimit;
  22373. }
  22374. if (this.upperRadiusLimit !== null && this.radius > this.upperRadiusLimit) {
  22375. this.radius = this.upperRadiusLimit;
  22376. }
  22377. if (this.lowerHeightOffsetLimit !== null &&
  22378. this.heightOffset < this.lowerHeightOffsetLimit) {
  22379. this.heightOffset = this.lowerHeightOffsetLimit;
  22380. }
  22381. if (this.upperHeightOffsetLimit !== null &&
  22382. this.heightOffset > this.upperHeightOffsetLimit) {
  22383. this.heightOffset = this.upperHeightOffsetLimit;
  22384. }
  22385. if (this.lowerRotationOffsetLimit !== null &&
  22386. this.rotationOffset < this.lowerRotationOffsetLimit) {
  22387. this.rotationOffset = this.lowerRotationOffsetLimit;
  22388. }
  22389. if (this.upperRotationOffsetLimit !== null &&
  22390. this.rotationOffset > this.upperRotationOffsetLimit) {
  22391. this.rotationOffset = this.upperRotationOffsetLimit;
  22392. }
  22393. };
  22394. /**
  22395. * Gets the camera class name.
  22396. * @returns the class name
  22397. */
  22398. FollowCamera.prototype.getClassName = function () {
  22399. return "FollowCamera";
  22400. };
  22401. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22402. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22403. ], FollowCamera.prototype, "radius", void 0);
  22404. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22405. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22406. ], FollowCamera.prototype, "lowerRadiusLimit", void 0);
  22407. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22408. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22409. ], FollowCamera.prototype, "upperRadiusLimit", void 0);
  22410. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22411. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22412. ], FollowCamera.prototype, "rotationOffset", void 0);
  22413. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22414. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22415. ], FollowCamera.prototype, "lowerRotationOffsetLimit", void 0);
  22416. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22417. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22418. ], FollowCamera.prototype, "upperRotationOffsetLimit", void 0);
  22419. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22420. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22421. ], FollowCamera.prototype, "heightOffset", void 0);
  22422. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22423. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22424. ], FollowCamera.prototype, "lowerHeightOffsetLimit", void 0);
  22425. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22426. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22427. ], FollowCamera.prototype, "upperHeightOffsetLimit", void 0);
  22428. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22429. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22430. ], FollowCamera.prototype, "cameraAcceleration", void 0);
  22431. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22432. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22433. ], FollowCamera.prototype, "maxCameraSpeed", void 0);
  22434. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22435. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])("lockedTargetId")
  22436. ], FollowCamera.prototype, "lockedTarget", void 0);
  22437. return FollowCamera;
  22438. }(_targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]));
  22439. /**
  22440. * Arc Rotate version of the follow camera.
  22441. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  22442. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  22443. */
  22444. var ArcFollowCamera = /** @class */ (function (_super) {
  22445. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcFollowCamera, _super);
  22446. /**
  22447. * Instantiates a new ArcFollowCamera
  22448. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  22449. * @param name Define the name of the camera
  22450. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  22451. * @param beta Define the rotation angle of the camera around the elevation axis
  22452. * @param radius Define the radius of the camera from its target point
  22453. * @param target Define the target of the camera
  22454. * @param scene Define the scene the camera belongs to
  22455. */
  22456. function ArcFollowCamera(name,
  22457. /** The longitudinal angle of the camera */
  22458. alpha,
  22459. /** The latitudinal angle of the camera */
  22460. beta,
  22461. /** The radius of the camera from its target */
  22462. radius,
  22463. /** Define the camera target (the messh it should follow) */
  22464. target, scene) {
  22465. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene) || this;
  22466. _this.alpha = alpha;
  22467. _this.beta = beta;
  22468. _this.radius = radius;
  22469. _this.target = target;
  22470. _this._cartesianCoordinates = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  22471. _this._follow();
  22472. return _this;
  22473. }
  22474. ArcFollowCamera.prototype._follow = function () {
  22475. if (!this.target) {
  22476. return;
  22477. }
  22478. this._cartesianCoordinates.x = this.radius * Math.cos(this.alpha) * Math.cos(this.beta);
  22479. this._cartesianCoordinates.y = this.radius * Math.sin(this.beta);
  22480. this._cartesianCoordinates.z = this.radius * Math.sin(this.alpha) * Math.cos(this.beta);
  22481. var targetPosition = this.target.getAbsolutePosition();
  22482. this.position = targetPosition.add(this._cartesianCoordinates);
  22483. this.setTarget(targetPosition);
  22484. };
  22485. /** @hidden */
  22486. ArcFollowCamera.prototype._checkInputs = function () {
  22487. _super.prototype._checkInputs.call(this);
  22488. this._follow();
  22489. };
  22490. /**
  22491. * Returns the class name of the object.
  22492. * It is mostly used internally for serialization purposes.
  22493. */
  22494. ArcFollowCamera.prototype.getClassName = function () {
  22495. return "ArcFollowCamera";
  22496. };
  22497. return ArcFollowCamera;
  22498. }(_targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]));
  22499. /***/ }),
  22500. /***/ "./Cameras/followCameraInputsManager.ts":
  22501. /*!**********************************************!*\
  22502. !*** ./Cameras/followCameraInputsManager.ts ***!
  22503. \**********************************************/
  22504. /*! exports provided: FollowCameraInputsManager */
  22505. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22506. "use strict";
  22507. __webpack_require__.r(__webpack_exports__);
  22508. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraInputsManager", function() { return FollowCameraInputsManager; });
  22509. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22510. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  22511. /* harmony import */ var _Inputs_followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Inputs/followCameraKeyboardMoveInput */ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts");
  22512. /* harmony import */ var _Inputs_followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Inputs/followCameraMouseWheelInput */ "./Cameras/Inputs/followCameraMouseWheelInput.ts");
  22513. /* harmony import */ var _Inputs_followCameraPointersInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/followCameraPointersInput */ "./Cameras/Inputs/followCameraPointersInput.ts");
  22514. /**
  22515. * Default Inputs manager for the FollowCamera.
  22516. * It groups all the default supported inputs for ease of use.
  22517. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  22518. */
  22519. var FollowCameraInputsManager = /** @class */ (function (_super) {
  22520. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCameraInputsManager, _super);
  22521. /**
  22522. * Instantiates a new FollowCameraInputsManager.
  22523. * @param camera Defines the camera the inputs belong to
  22524. */
  22525. function FollowCameraInputsManager(camera) {
  22526. return _super.call(this, camera) || this;
  22527. }
  22528. /**
  22529. * Add keyboard input support to the input manager.
  22530. * @returns the current input manager
  22531. */
  22532. FollowCameraInputsManager.prototype.addKeyboard = function () {
  22533. this.add(new _Inputs_followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["FollowCameraKeyboardMoveInput"]());
  22534. return this;
  22535. };
  22536. /**
  22537. * Add mouse wheel input support to the input manager.
  22538. * @returns the current input manager
  22539. */
  22540. FollowCameraInputsManager.prototype.addMouseWheel = function () {
  22541. this.add(new _Inputs_followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__["FollowCameraMouseWheelInput"]());
  22542. return this;
  22543. };
  22544. /**
  22545. * Add pointers input support to the input manager.
  22546. * @returns the current input manager
  22547. */
  22548. FollowCameraInputsManager.prototype.addPointers = function () {
  22549. this.add(new _Inputs_followCameraPointersInput__WEBPACK_IMPORTED_MODULE_4__["FollowCameraPointersInput"]());
  22550. return this;
  22551. };
  22552. /**
  22553. * Add orientation input support to the input manager.
  22554. * @returns the current input manager
  22555. */
  22556. FollowCameraInputsManager.prototype.addVRDeviceOrientation = function () {
  22557. console.warn("DeviceOrientation support not yet implemented for FollowCamera.");
  22558. return this;
  22559. };
  22560. return FollowCameraInputsManager;
  22561. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  22562. /***/ }),
  22563. /***/ "./Cameras/freeCamera.ts":
  22564. /*!*******************************!*\
  22565. !*** ./Cameras/freeCamera.ts ***!
  22566. \*******************************/
  22567. /*! exports provided: FreeCamera */
  22568. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22569. "use strict";
  22570. __webpack_require__.r(__webpack_exports__);
  22571. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return FreeCamera; });
  22572. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22573. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  22574. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22575. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  22576. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  22577. /* harmony import */ var _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  22578. /**
  22579. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  22580. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  22581. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22582. */
  22583. var FreeCamera = /** @class */ (function (_super) {
  22584. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FreeCamera, _super);
  22585. /**
  22586. * Instantiates a Free Camera.
  22587. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  22588. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  22589. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22590. * @param name Define the name of the camera in the scene
  22591. * @param position Define the start position of the camera in the scene
  22592. * @param scene Define the scene the camera belongs to
  22593. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  22594. */
  22595. function FreeCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  22596. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  22597. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  22598. /**
  22599. * Define the collision ellipsoid of the camera.
  22600. * This is helpful to simulate a camera body like the player body around the camera
  22601. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  22602. */
  22603. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.5, 1, 0.5);
  22604. /**
  22605. * Define an offset for the position of the ellipsoid around the camera.
  22606. * This can be helpful to determine the center of the body near the gravity center of the body
  22607. * instead of its head.
  22608. */
  22609. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  22610. /**
  22611. * Enable or disable collisions of the camera with the rest of the scene objects.
  22612. */
  22613. _this.checkCollisions = false;
  22614. /**
  22615. * Enable or disable gravity on the camera.
  22616. */
  22617. _this.applyGravity = false;
  22618. _this._needMoveForGravity = false;
  22619. _this._oldPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22620. _this._diffPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22621. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22622. // Collisions
  22623. _this._collisionMask = -1;
  22624. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  22625. if (collidedMesh === void 0) { collidedMesh = null; }
  22626. var updatePosition = function (newPos) {
  22627. _this._newPosition.copyFrom(newPos);
  22628. _this._newPosition.subtractToRef(_this._oldPosition, _this._diffPosition);
  22629. if (_this._diffPosition.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].CollisionsEpsilon) {
  22630. _this.position.addInPlace(_this._diffPosition);
  22631. if (_this.onCollide && collidedMesh) {
  22632. _this.onCollide(collidedMesh);
  22633. }
  22634. }
  22635. };
  22636. updatePosition(newPosition);
  22637. };
  22638. _this.inputs = new _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FreeCameraInputsManager"](_this);
  22639. _this.inputs.addKeyboard().addMouse();
  22640. return _this;
  22641. }
  22642. Object.defineProperty(FreeCamera.prototype, "angularSensibility", {
  22643. /**
  22644. * Gets the input sensibility for a mouse input. (default is 2000.0)
  22645. * Higher values reduce sensitivity.
  22646. */
  22647. get: function () {
  22648. var mouse = this.inputs.attached["mouse"];
  22649. if (mouse) {
  22650. return mouse.angularSensibility;
  22651. }
  22652. return 0;
  22653. },
  22654. /**
  22655. * Sets the input sensibility for a mouse input. (default is 2000.0)
  22656. * Higher values reduce sensitivity.
  22657. */
  22658. set: function (value) {
  22659. var mouse = this.inputs.attached["mouse"];
  22660. if (mouse) {
  22661. mouse.angularSensibility = value;
  22662. }
  22663. },
  22664. enumerable: true,
  22665. configurable: true
  22666. });
  22667. Object.defineProperty(FreeCamera.prototype, "keysUp", {
  22668. /**
  22669. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  22670. */
  22671. get: function () {
  22672. var keyboard = this.inputs.attached["keyboard"];
  22673. if (keyboard) {
  22674. return keyboard.keysUp;
  22675. }
  22676. return [];
  22677. },
  22678. set: function (value) {
  22679. var keyboard = this.inputs.attached["keyboard"];
  22680. if (keyboard) {
  22681. keyboard.keysUp = value;
  22682. }
  22683. },
  22684. enumerable: true,
  22685. configurable: true
  22686. });
  22687. Object.defineProperty(FreeCamera.prototype, "keysDown", {
  22688. /**
  22689. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  22690. */
  22691. get: function () {
  22692. var keyboard = this.inputs.attached["keyboard"];
  22693. if (keyboard) {
  22694. return keyboard.keysDown;
  22695. }
  22696. return [];
  22697. },
  22698. set: function (value) {
  22699. var keyboard = this.inputs.attached["keyboard"];
  22700. if (keyboard) {
  22701. keyboard.keysDown = value;
  22702. }
  22703. },
  22704. enumerable: true,
  22705. configurable: true
  22706. });
  22707. Object.defineProperty(FreeCamera.prototype, "keysLeft", {
  22708. /**
  22709. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  22710. */
  22711. get: function () {
  22712. var keyboard = this.inputs.attached["keyboard"];
  22713. if (keyboard) {
  22714. return keyboard.keysLeft;
  22715. }
  22716. return [];
  22717. },
  22718. set: function (value) {
  22719. var keyboard = this.inputs.attached["keyboard"];
  22720. if (keyboard) {
  22721. keyboard.keysLeft = value;
  22722. }
  22723. },
  22724. enumerable: true,
  22725. configurable: true
  22726. });
  22727. Object.defineProperty(FreeCamera.prototype, "keysRight", {
  22728. /**
  22729. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  22730. */
  22731. get: function () {
  22732. var keyboard = this.inputs.attached["keyboard"];
  22733. if (keyboard) {
  22734. return keyboard.keysRight;
  22735. }
  22736. return [];
  22737. },
  22738. set: function (value) {
  22739. var keyboard = this.inputs.attached["keyboard"];
  22740. if (keyboard) {
  22741. keyboard.keysRight = value;
  22742. }
  22743. },
  22744. enumerable: true,
  22745. configurable: true
  22746. });
  22747. /**
  22748. * Attached controls to the current camera.
  22749. * @param element Defines the element the controls should be listened from
  22750. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  22751. */
  22752. FreeCamera.prototype.attachControl = function (element, noPreventDefault) {
  22753. this.inputs.attachElement(element, noPreventDefault);
  22754. };
  22755. /**
  22756. * Detach the current controls from the camera.
  22757. * The camera will stop reacting to inputs.
  22758. * @param element Defines the element to stop listening the inputs from
  22759. */
  22760. FreeCamera.prototype.detachControl = function (element) {
  22761. this.inputs.detachElement(element);
  22762. this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  22763. this.cameraRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](0, 0);
  22764. };
  22765. Object.defineProperty(FreeCamera.prototype, "collisionMask", {
  22766. /**
  22767. * Define a collision mask to limit the list of object the camera can collide with
  22768. */
  22769. get: function () {
  22770. return this._collisionMask;
  22771. },
  22772. set: function (mask) {
  22773. this._collisionMask = !isNaN(mask) ? mask : -1;
  22774. },
  22775. enumerable: true,
  22776. configurable: true
  22777. });
  22778. /** @hidden */
  22779. FreeCamera.prototype._collideWithWorld = function (displacement) {
  22780. var globalPosition;
  22781. if (this.parent) {
  22782. globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this.position, this.parent.getWorldMatrix());
  22783. }
  22784. else {
  22785. globalPosition = this.position;
  22786. }
  22787. globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition);
  22788. this._oldPosition.addInPlace(this.ellipsoidOffset);
  22789. var coordinator = this.getScene().collisionCoordinator;
  22790. if (!this._collider) {
  22791. this._collider = coordinator.createCollider();
  22792. }
  22793. this._collider._radius = this.ellipsoid;
  22794. this._collider.collisionMask = this._collisionMask;
  22795. //no need for clone, as long as gravity is not on.
  22796. var actualDisplacement = displacement;
  22797. //add gravity to the direction to prevent the dual-collision checking
  22798. if (this.applyGravity) {
  22799. //this prevents mending with cameraDirection, a global variable of the free camera class.
  22800. actualDisplacement = displacement.add(this.getScene().gravity);
  22801. }
  22802. coordinator.getNewPosition(this._oldPosition, actualDisplacement, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  22803. };
  22804. /** @hidden */
  22805. FreeCamera.prototype._checkInputs = function () {
  22806. if (!this._localDirection) {
  22807. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22808. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22809. }
  22810. this.inputs.checkInputs();
  22811. _super.prototype._checkInputs.call(this);
  22812. };
  22813. /** @hidden */
  22814. FreeCamera.prototype._decideIfNeedsToMove = function () {
  22815. return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  22816. };
  22817. /** @hidden */
  22818. FreeCamera.prototype._updatePosition = function () {
  22819. if (this.checkCollisions && this.getScene().collisionsEnabled) {
  22820. this._collideWithWorld(this.cameraDirection);
  22821. }
  22822. else {
  22823. _super.prototype._updatePosition.call(this);
  22824. }
  22825. };
  22826. /**
  22827. * Destroy the camera and release the current resources hold by it.
  22828. */
  22829. FreeCamera.prototype.dispose = function () {
  22830. this.inputs.clear();
  22831. _super.prototype.dispose.call(this);
  22832. };
  22833. /**
  22834. * Gets the current object class name.
  22835. * @return the class name
  22836. */
  22837. FreeCamera.prototype.getClassName = function () {
  22838. return "FreeCamera";
  22839. };
  22840. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22841. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  22842. ], FreeCamera.prototype, "ellipsoid", void 0);
  22843. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22844. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  22845. ], FreeCamera.prototype, "ellipsoidOffset", void 0);
  22846. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22847. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22848. ], FreeCamera.prototype, "checkCollisions", void 0);
  22849. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22850. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22851. ], FreeCamera.prototype, "applyGravity", void 0);
  22852. return FreeCamera;
  22853. }(_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]));
  22854. /***/ }),
  22855. /***/ "./Cameras/freeCameraInputsManager.ts":
  22856. /*!********************************************!*\
  22857. !*** ./Cameras/freeCameraInputsManager.ts ***!
  22858. \********************************************/
  22859. /*! exports provided: FreeCameraInputsManager */
  22860. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22861. "use strict";
  22862. __webpack_require__.r(__webpack_exports__);
  22863. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return FreeCameraInputsManager; });
  22864. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22865. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  22866. /* harmony import */ var _Cameras_Inputs_freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraKeyboardMoveInput */ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts");
  22867. /* harmony import */ var _Cameras_Inputs_freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraMouseInput */ "./Cameras/Inputs/freeCameraMouseInput.ts");
  22868. /* harmony import */ var _Cameras_Inputs_freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraTouchInput */ "./Cameras/Inputs/freeCameraTouchInput.ts");
  22869. /**
  22870. * Default Inputs manager for the FreeCamera.
  22871. * It groups all the default supported inputs for ease of use.
  22872. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  22873. */
  22874. var FreeCameraInputsManager = /** @class */ (function (_super) {
  22875. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FreeCameraInputsManager, _super);
  22876. /**
  22877. * Instantiates a new FreeCameraInputsManager.
  22878. * @param camera Defines the camera the inputs belong to
  22879. */
  22880. function FreeCameraInputsManager(camera) {
  22881. return _super.call(this, camera) || this;
  22882. }
  22883. /**
  22884. * Add keyboard input support to the input manager.
  22885. * @returns the current input manager
  22886. */
  22887. FreeCameraInputsManager.prototype.addKeyboard = function () {
  22888. this.add(new _Cameras_Inputs_freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["FreeCameraKeyboardMoveInput"]());
  22889. return this;
  22890. };
  22891. /**
  22892. * Add mouse input support to the input manager.
  22893. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  22894. * @returns the current input manager
  22895. */
  22896. FreeCameraInputsManager.prototype.addMouse = function (touchEnabled) {
  22897. if (touchEnabled === void 0) { touchEnabled = true; }
  22898. this.add(new _Cameras_Inputs_freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_3__["FreeCameraMouseInput"](touchEnabled));
  22899. return this;
  22900. };
  22901. /**
  22902. * Add touch input support to the input manager.
  22903. * @returns the current input manager
  22904. */
  22905. FreeCameraInputsManager.prototype.addTouch = function () {
  22906. this.add(new _Cameras_Inputs_freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_4__["FreeCameraTouchInput"]());
  22907. return this;
  22908. };
  22909. return FreeCameraInputsManager;
  22910. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  22911. /***/ }),
  22912. /***/ "./Cameras/gamepadCamera.ts":
  22913. /*!**********************************!*\
  22914. !*** ./Cameras/gamepadCamera.ts ***!
  22915. \**********************************/
  22916. /*! exports provided: GamepadCamera */
  22917. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22918. "use strict";
  22919. __webpack_require__.r(__webpack_exports__);
  22920. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return GamepadCamera; });
  22921. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22922. /* harmony import */ var _universalCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./universalCamera */ "./Cameras/universalCamera.ts");
  22923. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22924. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  22925. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("GamepadCamera", function (name, scene) {
  22926. return function () { return new GamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  22927. });
  22928. /**
  22929. * This represents a FPS type of camera. This is only here for back compat purpose.
  22930. * Please use the UniversalCamera instead as both are identical.
  22931. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22932. */
  22933. var GamepadCamera = /** @class */ (function (_super) {
  22934. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GamepadCamera, _super);
  22935. /**
  22936. * Instantiates a new Gamepad Camera
  22937. * This represents a FPS type of camera. This is only here for back compat purpose.
  22938. * Please use the UniversalCamera instead as both are identical.
  22939. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22940. * @param name Define the name of the camera in the scene
  22941. * @param position Define the start position of the camera in the scene
  22942. * @param scene Define the scene the camera belongs to
  22943. */
  22944. function GamepadCamera(name, position, scene) {
  22945. return _super.call(this, name, position, scene) || this;
  22946. }
  22947. /**
  22948. * Gets the current object class name.
  22949. * @return the class name
  22950. */
  22951. GamepadCamera.prototype.getClassName = function () {
  22952. return "GamepadCamera";
  22953. };
  22954. return GamepadCamera;
  22955. }(_universalCamera__WEBPACK_IMPORTED_MODULE_1__["UniversalCamera"]));
  22956. /***/ }),
  22957. /***/ "./Cameras/index.ts":
  22958. /*!**************************!*\
  22959. !*** ./Cameras/index.ts ***!
  22960. \**************************/
  22961. /*! exports provided: CameraInputTypes, CameraInputsManager, Camera, TargetCamera, FreeCamera, FreeCameraInputsManager, TouchCamera, ArcRotateCamera, ArcRotateCameraInputsManager, DeviceOrientationCamera, FlyCamera, FlyCameraInputsManager, FollowCamera, ArcFollowCamera, GamepadCamera, UniversalCamera, VirtualJoysticksCamera, ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FollowCameraKeyboardMoveInput, FollowCameraMouseWheelInput, FollowCameraPointersInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput, AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera, VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, OnAfterEnteringVRObservableEvent, VRExperienceHelper, WebVRFreeCamera, WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager */
  22962. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22963. "use strict";
  22964. __webpack_require__.r(__webpack_exports__);
  22965. /* harmony import */ var _Inputs_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Inputs/index */ "./Cameras/Inputs/index.ts");
  22966. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  22967. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraKeyboardMoveInput"]; });
  22968. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraMouseWheelInput"]; });
  22969. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraPointersInput"]; });
  22970. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraVRDeviceOrientationInput"]; });
  22971. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraKeyboardInput"]; });
  22972. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraMouseInput"]; });
  22973. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraKeyboardMoveInput"]; });
  22974. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraMouseWheelInput"]; });
  22975. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraPointersInput"]; });
  22976. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraDeviceOrientationInput"]; });
  22977. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraGamepadInput"]; });
  22978. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraKeyboardMoveInput"]; });
  22979. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraMouseInput"]; });
  22980. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraTouchInput"]; });
  22981. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraVirtualJoystickInput"]; });
  22982. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  22983. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]; });
  22984. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]; });
  22985. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  22986. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"]; });
  22987. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  22988. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]; });
  22989. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  22990. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _freeCamera__WEBPACK_IMPORTED_MODULE_4__["FreeCamera"]; });
  22991. /* harmony import */ var _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  22992. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FreeCameraInputsManager"]; });
  22993. /* harmony import */ var _touchCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./touchCamera */ "./Cameras/touchCamera.ts");
  22994. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _touchCamera__WEBPACK_IMPORTED_MODULE_6__["TouchCamera"]; });
  22995. /* harmony import */ var _arcRotateCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  22996. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _arcRotateCamera__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCamera"]; });
  22997. /* harmony import */ var _arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  22998. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_8__["ArcRotateCameraInputsManager"]; });
  22999. /* harmony import */ var _deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  23000. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_9__["DeviceOrientationCamera"]; });
  23001. /* harmony import */ var _flyCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./flyCamera */ "./Cameras/flyCamera.ts");
  23002. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _flyCamera__WEBPACK_IMPORTED_MODULE_10__["FlyCamera"]; });
  23003. /* harmony import */ var _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./flyCameraInputsManager */ "./Cameras/flyCameraInputsManager.ts");
  23004. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__["FlyCameraInputsManager"]; });
  23005. /* harmony import */ var _followCamera__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./followCamera */ "./Cameras/followCamera.ts");
  23006. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _followCamera__WEBPACK_IMPORTED_MODULE_12__["FollowCamera"]; });
  23007. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _followCamera__WEBPACK_IMPORTED_MODULE_12__["ArcFollowCamera"]; });
  23008. /* harmony import */ var _gamepadCamera__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./gamepadCamera */ "./Cameras/gamepadCamera.ts");
  23009. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _gamepadCamera__WEBPACK_IMPORTED_MODULE_13__["GamepadCamera"]; });
  23010. /* harmony import */ var _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Stereoscopic/index */ "./Cameras/Stereoscopic/index.ts");
  23011. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphArcRotateCamera"]; });
  23012. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphFreeCamera"]; });
  23013. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphGamepadCamera"]; });
  23014. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphUniversalCamera"]; });
  23015. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicArcRotateCamera"]; });
  23016. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicFreeCamera"]; });
  23017. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicGamepadCamera"]; });
  23018. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicUniversalCamera"]; });
  23019. /* harmony import */ var _universalCamera__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./universalCamera */ "./Cameras/universalCamera.ts");
  23020. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _universalCamera__WEBPACK_IMPORTED_MODULE_15__["UniversalCamera"]; });
  23021. /* harmony import */ var _virtualJoysticksCamera__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./virtualJoysticksCamera */ "./Cameras/virtualJoysticksCamera.ts");
  23022. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _virtualJoysticksCamera__WEBPACK_IMPORTED_MODULE_16__["VirtualJoysticksCamera"]; });
  23023. /* harmony import */ var _VR_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./VR/index */ "./Cameras/VR/index.ts");
  23024. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRCameraMetrics"]; });
  23025. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationArcRotateCamera"]; });
  23026. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationFreeCamera"]; });
  23027. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationGamepadCamera"]; });
  23028. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["OnAfterEnteringVRObservableEvent"]; });
  23029. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRExperienceHelper"]; });
  23030. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["WebVRFreeCamera"]; });
  23031. /* harmony import */ var _XR_index__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./XR/index */ "./Cameras/XR/index.ts");
  23032. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRCamera"]; });
  23033. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUIButton"]; });
  23034. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUIOptions"]; });
  23035. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUI"]; });
  23036. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRState"]; });
  23037. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRExperienceHelper"]; });
  23038. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRController"]; });
  23039. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRInput"]; });
  23040. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRManagedOutputCanvas"]; });
  23041. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRSessionManager"]; });
  23042. /***/ }),
  23043. /***/ "./Cameras/targetCamera.ts":
  23044. /*!*********************************!*\
  23045. !*** ./Cameras/targetCamera.ts ***!
  23046. \*********************************/
  23047. /*! exports provided: TargetCamera */
  23048. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23049. "use strict";
  23050. __webpack_require__.r(__webpack_exports__);
  23051. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return TargetCamera; });
  23052. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23053. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  23054. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  23055. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23056. /**
  23057. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  23058. * This is the base of the follow, arc rotate cameras and Free camera
  23059. * @see http://doc.babylonjs.com/features/cameras
  23060. */
  23061. var TargetCamera = /** @class */ (function (_super) {
  23062. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TargetCamera, _super);
  23063. /**
  23064. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  23065. * This is the base of the follow, arc rotate cameras and Free camera
  23066. * @see http://doc.babylonjs.com/features/cameras
  23067. * @param name Defines the name of the camera in the scene
  23068. * @param position Defines the start position of the camera in the scene
  23069. * @param scene Defines the scene the camera belongs to
  23070. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  23071. */
  23072. function TargetCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  23073. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  23074. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  23075. /**
  23076. * Define the current direction the camera is moving to
  23077. */
  23078. _this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  23079. /**
  23080. * Define the current rotation the camera is rotating to
  23081. */
  23082. _this.cameraRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 0);
  23083. /**
  23084. * When set, the up vector of the camera will be updated by the rotation of the camera
  23085. */
  23086. _this.updateUpVectorFromRotation = false;
  23087. _this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  23088. /**
  23089. * Define the current rotation of the camera
  23090. */
  23091. _this.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  23092. /**
  23093. * Define the current speed of the camera
  23094. */
  23095. _this.speed = 2.0;
  23096. /**
  23097. * Add cconstraint to the camera to prevent it to move freely in all directions and
  23098. * around all axis.
  23099. */
  23100. _this.noRotationConstraint = false;
  23101. /**
  23102. * Define the current target of the camera as an object or a position.
  23103. */
  23104. _this.lockedTarget = null;
  23105. /** @hidden */
  23106. _this._currentTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  23107. /** @hidden */
  23108. _this._initialFocalDistance = 1;
  23109. /** @hidden */
  23110. _this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  23111. /** @hidden */
  23112. _this._camMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  23113. /** @hidden */
  23114. _this._cameraTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  23115. /** @hidden */
  23116. _this._cameraRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  23117. /** @hidden */
  23118. _this._referencePoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 1);
  23119. /** @hidden */
  23120. _this._transformedReferencePoint = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  23121. _this._globalCurrentTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  23122. _this._globalCurrentUpVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  23123. _this._defaultUp = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up();
  23124. _this._cachedRotationZ = 0;
  23125. _this._cachedQuaternionRotationZ = 0;
  23126. return _this;
  23127. }
  23128. /**
  23129. * Gets the position in front of the camera at a given distance.
  23130. * @param distance The distance from the camera we want the position to be
  23131. * @returns the position
  23132. */
  23133. TargetCamera.prototype.getFrontPosition = function (distance) {
  23134. this.getWorldMatrix();
  23135. var direction = this.getTarget().subtract(this.position);
  23136. direction.normalize();
  23137. direction.scaleInPlace(distance);
  23138. return this.globalPosition.add(direction);
  23139. };
  23140. /** @hidden */
  23141. TargetCamera.prototype._getLockedTargetPosition = function () {
  23142. if (!this.lockedTarget) {
  23143. return null;
  23144. }
  23145. if (this.lockedTarget.absolutePosition) {
  23146. this.lockedTarget.computeWorldMatrix();
  23147. }
  23148. return this.lockedTarget.absolutePosition || this.lockedTarget;
  23149. };
  23150. /**
  23151. * Store current camera state of the camera (fov, position, rotation, etc..)
  23152. * @returns the camera
  23153. */
  23154. TargetCamera.prototype.storeState = function () {
  23155. this._storedPosition = this.position.clone();
  23156. this._storedRotation = this.rotation.clone();
  23157. if (this.rotationQuaternion) {
  23158. this._storedRotationQuaternion = this.rotationQuaternion.clone();
  23159. }
  23160. return _super.prototype.storeState.call(this);
  23161. };
  23162. /**
  23163. * Restored camera state. You must call storeState() first
  23164. * @returns whether it was successful or not
  23165. * @hidden
  23166. */
  23167. TargetCamera.prototype._restoreStateValues = function () {
  23168. if (!_super.prototype._restoreStateValues.call(this)) {
  23169. return false;
  23170. }
  23171. this.position = this._storedPosition.clone();
  23172. this.rotation = this._storedRotation.clone();
  23173. if (this.rotationQuaternion) {
  23174. this.rotationQuaternion = this._storedRotationQuaternion.clone();
  23175. }
  23176. this.cameraDirection.copyFromFloats(0, 0, 0);
  23177. this.cameraRotation.copyFromFloats(0, 0);
  23178. return true;
  23179. };
  23180. /** @hidden */
  23181. TargetCamera.prototype._initCache = function () {
  23182. _super.prototype._initCache.call(this);
  23183. this._cache.lockedTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  23184. this._cache.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  23185. this._cache.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  23186. };
  23187. /** @hidden */
  23188. TargetCamera.prototype._updateCache = function (ignoreParentClass) {
  23189. if (!ignoreParentClass) {
  23190. _super.prototype._updateCache.call(this);
  23191. }
  23192. var lockedTargetPosition = this._getLockedTargetPosition();
  23193. if (!lockedTargetPosition) {
  23194. this._cache.lockedTarget = null;
  23195. }
  23196. else {
  23197. if (!this._cache.lockedTarget) {
  23198. this._cache.lockedTarget = lockedTargetPosition.clone();
  23199. }
  23200. else {
  23201. this._cache.lockedTarget.copyFrom(lockedTargetPosition);
  23202. }
  23203. }
  23204. this._cache.rotation.copyFrom(this.rotation);
  23205. if (this.rotationQuaternion) {
  23206. this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion);
  23207. }
  23208. };
  23209. // Synchronized
  23210. /** @hidden */
  23211. TargetCamera.prototype._isSynchronizedViewMatrix = function () {
  23212. if (!_super.prototype._isSynchronizedViewMatrix.call(this)) {
  23213. return false;
  23214. }
  23215. var lockedTargetPosition = this._getLockedTargetPosition();
  23216. return (this._cache.lockedTarget ? this._cache.lockedTarget.equals(lockedTargetPosition) : !lockedTargetPosition)
  23217. && (this.rotationQuaternion ? this.rotationQuaternion.equals(this._cache.rotationQuaternion) : this._cache.rotation.equals(this.rotation));
  23218. };
  23219. // Methods
  23220. /** @hidden */
  23221. TargetCamera.prototype._computeLocalCameraSpeed = function () {
  23222. var engine = this.getEngine();
  23223. return this.speed * Math.sqrt((engine.getDeltaTime() / (engine.getFps() * 100.0)));
  23224. };
  23225. // Target
  23226. /**
  23227. * Defines the target the camera should look at.
  23228. * This will automatically adapt alpha beta and radius to fit within the new target.
  23229. * @param target Defines the new target as a Vector or a mesh
  23230. */
  23231. TargetCamera.prototype.setTarget = function (target) {
  23232. this.upVector.normalize();
  23233. this._initialFocalDistance = target.subtract(this.position).length();
  23234. if (this.position.z === target.z) {
  23235. this.position.z += _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  23236. }
  23237. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(this.position, target, this._defaultUp, this._camMatrix);
  23238. this._camMatrix.invert();
  23239. this.rotation.x = Math.atan(this._camMatrix.m[6] / this._camMatrix.m[10]);
  23240. var vDir = target.subtract(this.position);
  23241. if (vDir.x >= 0.0) {
  23242. this.rotation.y = (-Math.atan(vDir.z / vDir.x) + Math.PI / 2.0);
  23243. }
  23244. else {
  23245. this.rotation.y = (-Math.atan(vDir.z / vDir.x) - Math.PI / 2.0);
  23246. }
  23247. this.rotation.z = 0;
  23248. if (isNaN(this.rotation.x)) {
  23249. this.rotation.x = 0;
  23250. }
  23251. if (isNaN(this.rotation.y)) {
  23252. this.rotation.y = 0;
  23253. }
  23254. if (isNaN(this.rotation.z)) {
  23255. this.rotation.z = 0;
  23256. }
  23257. if (this.rotationQuaternion) {
  23258. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion);
  23259. }
  23260. };
  23261. /**
  23262. * Return the current target position of the camera. This value is expressed in local space.
  23263. * @returns the target position
  23264. */
  23265. TargetCamera.prototype.getTarget = function () {
  23266. return this._currentTarget;
  23267. };
  23268. /** @hidden */
  23269. TargetCamera.prototype._decideIfNeedsToMove = function () {
  23270. return Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  23271. };
  23272. /** @hidden */
  23273. TargetCamera.prototype._updatePosition = function () {
  23274. if (this.parent) {
  23275. this.parent.getWorldMatrix().invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  23276. _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]);
  23277. this.position.addInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0]);
  23278. return;
  23279. }
  23280. this.position.addInPlace(this.cameraDirection);
  23281. };
  23282. /** @hidden */
  23283. TargetCamera.prototype._checkInputs = function () {
  23284. var needToMove = this._decideIfNeedsToMove();
  23285. var needToRotate = Math.abs(this.cameraRotation.x) > 0 || Math.abs(this.cameraRotation.y) > 0;
  23286. // Move
  23287. if (needToMove) {
  23288. this._updatePosition();
  23289. }
  23290. // Rotate
  23291. if (needToRotate) {
  23292. this.rotation.x += this.cameraRotation.x;
  23293. this.rotation.y += this.cameraRotation.y;
  23294. //rotate, if quaternion is set and rotation was used
  23295. if (this.rotationQuaternion) {
  23296. var len = this.rotation.lengthSquared();
  23297. if (len) {
  23298. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion);
  23299. }
  23300. }
  23301. if (!this.noRotationConstraint) {
  23302. var limit = (Math.PI / 2) * 0.95;
  23303. if (this.rotation.x > limit) {
  23304. this.rotation.x = limit;
  23305. }
  23306. if (this.rotation.x < -limit) {
  23307. this.rotation.x = -limit;
  23308. }
  23309. }
  23310. }
  23311. // Inertia
  23312. if (needToMove) {
  23313. if (Math.abs(this.cameraDirection.x) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  23314. this.cameraDirection.x = 0;
  23315. }
  23316. if (Math.abs(this.cameraDirection.y) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  23317. this.cameraDirection.y = 0;
  23318. }
  23319. if (Math.abs(this.cameraDirection.z) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  23320. this.cameraDirection.z = 0;
  23321. }
  23322. this.cameraDirection.scaleInPlace(this.inertia);
  23323. }
  23324. if (needToRotate) {
  23325. if (Math.abs(this.cameraRotation.x) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  23326. this.cameraRotation.x = 0;
  23327. }
  23328. if (Math.abs(this.cameraRotation.y) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  23329. this.cameraRotation.y = 0;
  23330. }
  23331. this.cameraRotation.scaleInPlace(this.inertia);
  23332. }
  23333. _super.prototype._checkInputs.call(this);
  23334. };
  23335. TargetCamera.prototype._updateCameraRotationMatrix = function () {
  23336. if (this.rotationQuaternion) {
  23337. this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix);
  23338. }
  23339. else {
  23340. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this._cameraRotationMatrix);
  23341. }
  23342. };
  23343. /**
  23344. * 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)
  23345. * @returns the current camera
  23346. */
  23347. TargetCamera.prototype._rotateUpVectorWithCameraRotationMatrix = function () {
  23348. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(this._defaultUp, this._cameraRotationMatrix, this.upVector);
  23349. return this;
  23350. };
  23351. /** @hidden */
  23352. TargetCamera.prototype._getViewMatrix = function () {
  23353. if (this.lockedTarget) {
  23354. this.setTarget(this._getLockedTargetPosition());
  23355. }
  23356. // Compute
  23357. this._updateCameraRotationMatrix();
  23358. // Apply the changed rotation to the upVector
  23359. if (this.rotationQuaternion && this._cachedQuaternionRotationZ != this.rotationQuaternion.z) {
  23360. this._rotateUpVectorWithCameraRotationMatrix();
  23361. this._cachedQuaternionRotationZ = this.rotationQuaternion.z;
  23362. }
  23363. else if (this._cachedRotationZ != this.rotation.z) {
  23364. this._rotateUpVectorWithCameraRotationMatrix();
  23365. this._cachedRotationZ = this.rotation.z;
  23366. }
  23367. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
  23368. // Computing target and final matrix
  23369. this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
  23370. if (this.updateUpVectorFromRotation) {
  23371. if (this.rotationQuaternion) {
  23372. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y.rotateByQuaternionToRef(this.rotationQuaternion, this.upVector);
  23373. }
  23374. else {
  23375. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].FromEulerVectorToRef(this.rotation, this._tmpQuaternion);
  23376. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y.rotateByQuaternionToRef(this._tmpQuaternion, this.upVector);
  23377. }
  23378. }
  23379. this._computeViewMatrix(this.position, this._currentTarget, this.upVector);
  23380. return this._viewMatrix;
  23381. };
  23382. TargetCamera.prototype._computeViewMatrix = function (position, target, up) {
  23383. if (this.parent) {
  23384. var parentWorldMatrix = this.parent.getWorldMatrix();
  23385. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(position, parentWorldMatrix, this._globalPosition);
  23386. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(target, parentWorldMatrix, this._globalCurrentTarget);
  23387. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(up, parentWorldMatrix, this._globalCurrentUpVector);
  23388. this._markSyncedWithParent();
  23389. }
  23390. else {
  23391. this._globalPosition.copyFrom(position);
  23392. this._globalCurrentTarget.copyFrom(target);
  23393. this._globalCurrentUpVector.copyFrom(up);
  23394. }
  23395. if (this.getScene().useRightHandedSystem) {
  23396. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtRHToRef(this._globalPosition, this._globalCurrentTarget, this._globalCurrentUpVector, this._viewMatrix);
  23397. }
  23398. else {
  23399. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(this._globalPosition, this._globalCurrentTarget, this._globalCurrentUpVector, this._viewMatrix);
  23400. }
  23401. };
  23402. /**
  23403. * @hidden
  23404. */
  23405. TargetCamera.prototype.createRigCamera = function (name, cameraIndex) {
  23406. if (this.cameraRigMode !== _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_NONE) {
  23407. var rigCamera = new TargetCamera(name, this.position.clone(), this.getScene());
  23408. if (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_VR || this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_WEBVR) {
  23409. if (!this.rotationQuaternion) {
  23410. this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  23411. }
  23412. rigCamera._cameraRigParams = {};
  23413. rigCamera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  23414. }
  23415. return rigCamera;
  23416. }
  23417. return null;
  23418. };
  23419. /**
  23420. * @hidden
  23421. */
  23422. TargetCamera.prototype._updateRigCameras = function () {
  23423. var camLeft = this._rigCameras[0];
  23424. var camRight = this._rigCameras[1];
  23425. this.computeWorldMatrix();
  23426. switch (this.cameraRigMode) {
  23427. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  23428. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  23429. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  23430. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  23431. //provisionnaly using _cameraRigParams.stereoHalfAngle instead of calculations based on _cameraRigParams.interaxialDistance:
  23432. var leftSign = (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED) ? 1 : -1;
  23433. var rightSign = (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED) ? -1 : 1;
  23434. this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * leftSign, camLeft);
  23435. this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * rightSign, camRight);
  23436. break;
  23437. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_VR:
  23438. if (camLeft.rotationQuaternion) {
  23439. camLeft.rotationQuaternion.copyFrom(this.rotationQuaternion);
  23440. camRight.rotationQuaternion.copyFrom(this.rotationQuaternion);
  23441. }
  23442. else {
  23443. camLeft.rotation.copyFrom(this.rotation);
  23444. camRight.rotation.copyFrom(this.rotation);
  23445. }
  23446. camLeft.position.copyFrom(this.position);
  23447. camRight.position.copyFrom(this.position);
  23448. break;
  23449. }
  23450. _super.prototype._updateRigCameras.call(this);
  23451. };
  23452. TargetCamera.prototype._getRigCamPositionAndTarget = function (halfSpace, rigCamera) {
  23453. var target = this.getTarget();
  23454. target.subtractToRef(this.position, TargetCamera._TargetFocalPoint);
  23455. TargetCamera._TargetFocalPoint.normalize().scaleInPlace(this._initialFocalDistance);
  23456. var newFocalTarget = TargetCamera._TargetFocalPoint.addInPlace(this.position);
  23457. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(-newFocalTarget.x, -newFocalTarget.y, -newFocalTarget.z, TargetCamera._TargetTransformMatrix);
  23458. TargetCamera._TargetTransformMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationY(halfSpace), TargetCamera._RigCamTransformMatrix);
  23459. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(newFocalTarget.x, newFocalTarget.y, newFocalTarget.z, TargetCamera._TargetTransformMatrix);
  23460. TargetCamera._RigCamTransformMatrix.multiplyToRef(TargetCamera._TargetTransformMatrix, TargetCamera._RigCamTransformMatrix);
  23461. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this.position, TargetCamera._RigCamTransformMatrix, rigCamera.position);
  23462. rigCamera.setTarget(newFocalTarget);
  23463. };
  23464. /**
  23465. * Gets the current object class name.
  23466. * @return the class name
  23467. */
  23468. TargetCamera.prototype.getClassName = function () {
  23469. return "TargetCamera";
  23470. };
  23471. TargetCamera._RigCamTransformMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  23472. TargetCamera._TargetTransformMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  23473. TargetCamera._TargetFocalPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  23474. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23475. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  23476. ], TargetCamera.prototype, "rotation", void 0);
  23477. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23478. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  23479. ], TargetCamera.prototype, "speed", void 0);
  23480. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23481. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])("lockedTargetId")
  23482. ], TargetCamera.prototype, "lockedTarget", void 0);
  23483. return TargetCamera;
  23484. }(_camera__WEBPACK_IMPORTED_MODULE_2__["Camera"]));
  23485. /***/ }),
  23486. /***/ "./Cameras/touchCamera.ts":
  23487. /*!********************************!*\
  23488. !*** ./Cameras/touchCamera.ts ***!
  23489. \********************************/
  23490. /*! exports provided: TouchCamera */
  23491. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23492. "use strict";
  23493. __webpack_require__.r(__webpack_exports__);
  23494. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return TouchCamera; });
  23495. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23496. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  23497. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23498. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  23499. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("TouchCamera", function (name, scene) {
  23500. return function () { return new TouchCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  23501. });
  23502. /**
  23503. * This represents a FPS type of camera controlled by touch.
  23504. * This is like a universal camera minus the Gamepad controls.
  23505. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23506. */
  23507. var TouchCamera = /** @class */ (function (_super) {
  23508. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TouchCamera, _super);
  23509. /**
  23510. * Instantiates a new touch camera.
  23511. * This represents a FPS type of camera controlled by touch.
  23512. * This is like a universal camera minus the Gamepad controls.
  23513. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23514. * @param name Define the name of the camera in the scene
  23515. * @param position Define the start position of the camera in the scene
  23516. * @param scene Define the scene the camera belongs to
  23517. */
  23518. function TouchCamera(name, position, scene) {
  23519. var _this = _super.call(this, name, position, scene) || this;
  23520. _this.inputs.addTouch();
  23521. _this._setupInputs();
  23522. return _this;
  23523. }
  23524. Object.defineProperty(TouchCamera.prototype, "touchAngularSensibility", {
  23525. /**
  23526. * Defines the touch sensibility for rotation.
  23527. * The higher the faster.
  23528. */
  23529. get: function () {
  23530. var touch = this.inputs.attached["touch"];
  23531. if (touch) {
  23532. return touch.touchAngularSensibility;
  23533. }
  23534. return 0;
  23535. },
  23536. set: function (value) {
  23537. var touch = this.inputs.attached["touch"];
  23538. if (touch) {
  23539. touch.touchAngularSensibility = value;
  23540. }
  23541. },
  23542. enumerable: true,
  23543. configurable: true
  23544. });
  23545. Object.defineProperty(TouchCamera.prototype, "touchMoveSensibility", {
  23546. /**
  23547. * Defines the touch sensibility for move.
  23548. * The higher the faster.
  23549. */
  23550. get: function () {
  23551. var touch = this.inputs.attached["touch"];
  23552. if (touch) {
  23553. return touch.touchMoveSensibility;
  23554. }
  23555. return 0;
  23556. },
  23557. set: function (value) {
  23558. var touch = this.inputs.attached["touch"];
  23559. if (touch) {
  23560. touch.touchMoveSensibility = value;
  23561. }
  23562. },
  23563. enumerable: true,
  23564. configurable: true
  23565. });
  23566. /**
  23567. * Gets the current object class name.
  23568. * @return the class name
  23569. */
  23570. TouchCamera.prototype.getClassName = function () {
  23571. return "TouchCamera";
  23572. };
  23573. /** @hidden */
  23574. TouchCamera.prototype._setupInputs = function () {
  23575. var mouse = this.inputs.attached["mouse"];
  23576. if (mouse) {
  23577. mouse.touchEnabled = false;
  23578. }
  23579. };
  23580. return TouchCamera;
  23581. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  23582. /***/ }),
  23583. /***/ "./Cameras/universalCamera.ts":
  23584. /*!************************************!*\
  23585. !*** ./Cameras/universalCamera.ts ***!
  23586. \************************************/
  23587. /*! exports provided: UniversalCamera */
  23588. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23589. "use strict";
  23590. __webpack_require__.r(__webpack_exports__);
  23591. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return UniversalCamera; });
  23592. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23593. /* harmony import */ var _touchCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./touchCamera */ "./Cameras/touchCamera.ts");
  23594. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../node */ "./node.ts");
  23595. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23596. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  23597. _node__WEBPACK_IMPORTED_MODULE_2__["Node"].AddNodeConstructor("FreeCamera", function (name, scene) {
  23598. // Forcing to use the Universal camera
  23599. return function () { return new UniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  23600. });
  23601. /**
  23602. * 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,
  23603. * which still works and will still be found in many Playgrounds.
  23604. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23605. */
  23606. var UniversalCamera = /** @class */ (function (_super) {
  23607. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](UniversalCamera, _super);
  23608. /**
  23609. * 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,
  23610. * which still works and will still be found in many Playgrounds.
  23611. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23612. * @param name Define the name of the camera in the scene
  23613. * @param position Define the start position of the camera in the scene
  23614. * @param scene Define the scene the camera belongs to
  23615. */
  23616. function UniversalCamera(name, position, scene) {
  23617. var _this = _super.call(this, name, position, scene) || this;
  23618. _this.inputs.addGamepad();
  23619. return _this;
  23620. }
  23621. Object.defineProperty(UniversalCamera.prototype, "gamepadAngularSensibility", {
  23622. /**
  23623. * Defines the gamepad rotation sensiblity.
  23624. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  23625. */
  23626. get: function () {
  23627. var gamepad = this.inputs.attached["gamepad"];
  23628. if (gamepad) {
  23629. return gamepad.gamepadAngularSensibility;
  23630. }
  23631. return 0;
  23632. },
  23633. set: function (value) {
  23634. var gamepad = this.inputs.attached["gamepad"];
  23635. if (gamepad) {
  23636. gamepad.gamepadAngularSensibility = value;
  23637. }
  23638. },
  23639. enumerable: true,
  23640. configurable: true
  23641. });
  23642. Object.defineProperty(UniversalCamera.prototype, "gamepadMoveSensibility", {
  23643. /**
  23644. * Defines the gamepad move sensiblity.
  23645. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  23646. */
  23647. get: function () {
  23648. var gamepad = this.inputs.attached["gamepad"];
  23649. if (gamepad) {
  23650. return gamepad.gamepadMoveSensibility;
  23651. }
  23652. return 0;
  23653. },
  23654. set: function (value) {
  23655. var gamepad = this.inputs.attached["gamepad"];
  23656. if (gamepad) {
  23657. gamepad.gamepadMoveSensibility = value;
  23658. }
  23659. },
  23660. enumerable: true,
  23661. configurable: true
  23662. });
  23663. /**
  23664. * Gets the current object class name.
  23665. * @return the class name
  23666. */
  23667. UniversalCamera.prototype.getClassName = function () {
  23668. return "UniversalCamera";
  23669. };
  23670. return UniversalCamera;
  23671. }(_touchCamera__WEBPACK_IMPORTED_MODULE_1__["TouchCamera"]));
  23672. _camera__WEBPACK_IMPORTED_MODULE_4__["Camera"]._createDefaultParsedCamera = function (name, scene) {
  23673. return new UniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene);
  23674. };
  23675. /***/ }),
  23676. /***/ "./Cameras/virtualJoysticksCamera.ts":
  23677. /*!*******************************************!*\
  23678. !*** ./Cameras/virtualJoysticksCamera.ts ***!
  23679. \*******************************************/
  23680. /*! exports provided: VirtualJoysticksCamera */
  23681. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23682. "use strict";
  23683. __webpack_require__.r(__webpack_exports__);
  23684. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return VirtualJoysticksCamera; });
  23685. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23686. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  23687. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23688. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  23689. /* harmony import */ var _Inputs_freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/freeCameraVirtualJoystickInput */ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts");
  23690. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("VirtualJoysticksCamera", function (name, scene) {
  23691. return function () { return new VirtualJoysticksCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  23692. });
  23693. /**
  23694. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  23695. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  23696. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  23697. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  23698. */
  23699. var VirtualJoysticksCamera = /** @class */ (function (_super) {
  23700. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VirtualJoysticksCamera, _super);
  23701. /**
  23702. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  23703. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  23704. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  23705. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  23706. * @param name Define the name of the camera in the scene
  23707. * @param position Define the start position of the camera in the scene
  23708. * @param scene Define the scene the camera belongs to
  23709. */
  23710. function VirtualJoysticksCamera(name, position, scene) {
  23711. var _this = _super.call(this, name, position, scene) || this;
  23712. _this.inputs.addVirtualJoystick();
  23713. return _this;
  23714. }
  23715. /**
  23716. * Gets the current object class name.
  23717. * @return the class name
  23718. */
  23719. VirtualJoysticksCamera.prototype.getClassName = function () {
  23720. return "VirtualJoysticksCamera";
  23721. };
  23722. return VirtualJoysticksCamera;
  23723. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  23724. /***/ }),
  23725. /***/ "./Collisions/collider.ts":
  23726. /*!********************************!*\
  23727. !*** ./Collisions/collider.ts ***!
  23728. \********************************/
  23729. /*! exports provided: Collider */
  23730. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23731. "use strict";
  23732. __webpack_require__.r(__webpack_exports__);
  23733. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return Collider; });
  23734. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23735. var intersectBoxAASphere = function (boxMin, boxMax, sphereCenter, sphereRadius) {
  23736. if (boxMin.x > sphereCenter.x + sphereRadius) {
  23737. return false;
  23738. }
  23739. if (sphereCenter.x - sphereRadius > boxMax.x) {
  23740. return false;
  23741. }
  23742. if (boxMin.y > sphereCenter.y + sphereRadius) {
  23743. return false;
  23744. }
  23745. if (sphereCenter.y - sphereRadius > boxMax.y) {
  23746. return false;
  23747. }
  23748. if (boxMin.z > sphereCenter.z + sphereRadius) {
  23749. return false;
  23750. }
  23751. if (sphereCenter.z - sphereRadius > boxMax.z) {
  23752. return false;
  23753. }
  23754. return true;
  23755. };
  23756. var getLowestRoot = (function () {
  23757. var result = { root: 0, found: false };
  23758. return function (a, b, c, maxR) {
  23759. result.root = 0;
  23760. result.found = false;
  23761. var determinant = b * b - 4.0 * a * c;
  23762. if (determinant < 0) {
  23763. return result;
  23764. }
  23765. var sqrtD = Math.sqrt(determinant);
  23766. var r1 = (-b - sqrtD) / (2.0 * a);
  23767. var r2 = (-b + sqrtD) / (2.0 * a);
  23768. if (r1 > r2) {
  23769. var temp = r2;
  23770. r2 = r1;
  23771. r1 = temp;
  23772. }
  23773. if (r1 > 0 && r1 < maxR) {
  23774. result.root = r1;
  23775. result.found = true;
  23776. return result;
  23777. }
  23778. if (r2 > 0 && r2 < maxR) {
  23779. result.root = r2;
  23780. result.found = true;
  23781. return result;
  23782. }
  23783. return result;
  23784. };
  23785. })();
  23786. /** @hidden */
  23787. var Collider = /** @class */ (function () {
  23788. function Collider() {
  23789. this._collisionPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23790. this._planeIntersectionPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23791. this._tempVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23792. this._tempVector2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23793. this._tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23794. this._tempVector4 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23795. this._edge = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23796. this._baseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23797. this._destinationPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23798. this._slidePlaneNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23799. this._displacementVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23800. /** @hidden */
  23801. this._radius = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  23802. /** @hidden */
  23803. this._retry = 0;
  23804. /** @hidden */
  23805. this._basePointWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23806. this._velocityWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23807. this._normalizedVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23808. this._collisionMask = -1;
  23809. }
  23810. Object.defineProperty(Collider.prototype, "collisionMask", {
  23811. get: function () {
  23812. return this._collisionMask;
  23813. },
  23814. set: function (mask) {
  23815. this._collisionMask = !isNaN(mask) ? mask : -1;
  23816. },
  23817. enumerable: true,
  23818. configurable: true
  23819. });
  23820. Object.defineProperty(Collider.prototype, "slidePlaneNormal", {
  23821. /**
  23822. * Gets the plane normal used to compute the sliding response (in local space)
  23823. */
  23824. get: function () {
  23825. return this._slidePlaneNormal;
  23826. },
  23827. enumerable: true,
  23828. configurable: true
  23829. });
  23830. // Methods
  23831. /** @hidden */
  23832. Collider.prototype._initialize = function (source, dir, e) {
  23833. this._velocity = dir;
  23834. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].NormalizeToRef(dir, this._normalizedVelocity);
  23835. this._basePoint = source;
  23836. source.multiplyToRef(this._radius, this._basePointWorld);
  23837. dir.multiplyToRef(this._radius, this._velocityWorld);
  23838. this._velocityWorldLength = this._velocityWorld.length();
  23839. this._epsilon = e;
  23840. this.collisionFound = false;
  23841. };
  23842. /** @hidden */
  23843. Collider.prototype._checkPointInTriangle = function (point, pa, pb, pc, n) {
  23844. pa.subtractToRef(point, this._tempVector);
  23845. pb.subtractToRef(point, this._tempVector2);
  23846. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector, this._tempVector2, this._tempVector4);
  23847. var d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  23848. if (d < 0) {
  23849. return false;
  23850. }
  23851. pc.subtractToRef(point, this._tempVector3);
  23852. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector2, this._tempVector3, this._tempVector4);
  23853. d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  23854. if (d < 0) {
  23855. return false;
  23856. }
  23857. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector3, this._tempVector, this._tempVector4);
  23858. d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  23859. return d >= 0;
  23860. };
  23861. /** @hidden */
  23862. Collider.prototype._canDoCollision = function (sphereCenter, sphereRadius, vecMin, vecMax) {
  23863. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(this._basePointWorld, sphereCenter);
  23864. var max = Math.max(this._radius.x, this._radius.y, this._radius.z);
  23865. if (distance > this._velocityWorldLength + max + sphereRadius) {
  23866. return false;
  23867. }
  23868. if (!intersectBoxAASphere(vecMin, vecMax, this._basePointWorld, this._velocityWorldLength + max)) {
  23869. return false;
  23870. }
  23871. return true;
  23872. };
  23873. /** @hidden */
  23874. Collider.prototype._testTriangle = function (faceIndex, trianglePlaneArray, p1, p2, p3, hasMaterial) {
  23875. var t0;
  23876. var embeddedInPlane = false;
  23877. //defensive programming, actually not needed.
  23878. if (!trianglePlaneArray) {
  23879. trianglePlaneArray = [];
  23880. }
  23881. if (!trianglePlaneArray[faceIndex]) {
  23882. trianglePlaneArray[faceIndex] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Plane"](0, 0, 0, 0);
  23883. trianglePlaneArray[faceIndex].copyFromPoints(p1, p2, p3);
  23884. }
  23885. var trianglePlane = trianglePlaneArray[faceIndex];
  23886. if ((!hasMaterial) && !trianglePlane.isFrontFacingTo(this._normalizedVelocity, 0)) {
  23887. return;
  23888. }
  23889. var signedDistToTrianglePlane = trianglePlane.signedDistanceTo(this._basePoint);
  23890. var normalDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(trianglePlane.normal, this._velocity);
  23891. if (normalDotVelocity == 0) {
  23892. if (Math.abs(signedDistToTrianglePlane) >= 1.0) {
  23893. return;
  23894. }
  23895. embeddedInPlane = true;
  23896. t0 = 0;
  23897. }
  23898. else {
  23899. t0 = (-1.0 - signedDistToTrianglePlane) / normalDotVelocity;
  23900. var t1 = (1.0 - signedDistToTrianglePlane) / normalDotVelocity;
  23901. if (t0 > t1) {
  23902. var temp = t1;
  23903. t1 = t0;
  23904. t0 = temp;
  23905. }
  23906. if (t0 > 1.0 || t1 < 0.0) {
  23907. return;
  23908. }
  23909. if (t0 < 0) {
  23910. t0 = 0;
  23911. }
  23912. if (t0 > 1.0) {
  23913. t0 = 1.0;
  23914. }
  23915. }
  23916. this._collisionPoint.copyFromFloats(0, 0, 0);
  23917. var found = false;
  23918. var t = 1.0;
  23919. if (!embeddedInPlane) {
  23920. this._basePoint.subtractToRef(trianglePlane.normal, this._planeIntersectionPoint);
  23921. this._velocity.scaleToRef(t0, this._tempVector);
  23922. this._planeIntersectionPoint.addInPlace(this._tempVector);
  23923. if (this._checkPointInTriangle(this._planeIntersectionPoint, p1, p2, p3, trianglePlane.normal)) {
  23924. found = true;
  23925. t = t0;
  23926. this._collisionPoint.copyFrom(this._planeIntersectionPoint);
  23927. }
  23928. }
  23929. if (!found) {
  23930. var velocitySquaredLength = this._velocity.lengthSquared();
  23931. var a = velocitySquaredLength;
  23932. this._basePoint.subtractToRef(p1, this._tempVector);
  23933. var b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  23934. var c = this._tempVector.lengthSquared() - 1.0;
  23935. var lowestRoot = getLowestRoot(a, b, c, t);
  23936. if (lowestRoot.found) {
  23937. t = lowestRoot.root;
  23938. found = true;
  23939. this._collisionPoint.copyFrom(p1);
  23940. }
  23941. this._basePoint.subtractToRef(p2, this._tempVector);
  23942. b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  23943. c = this._tempVector.lengthSquared() - 1.0;
  23944. lowestRoot = getLowestRoot(a, b, c, t);
  23945. if (lowestRoot.found) {
  23946. t = lowestRoot.root;
  23947. found = true;
  23948. this._collisionPoint.copyFrom(p2);
  23949. }
  23950. this._basePoint.subtractToRef(p3, this._tempVector);
  23951. b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  23952. c = this._tempVector.lengthSquared() - 1.0;
  23953. lowestRoot = getLowestRoot(a, b, c, t);
  23954. if (lowestRoot.found) {
  23955. t = lowestRoot.root;
  23956. found = true;
  23957. this._collisionPoint.copyFrom(p3);
  23958. }
  23959. p2.subtractToRef(p1, this._edge);
  23960. p1.subtractToRef(this._basePoint, this._baseToVertex);
  23961. var edgeSquaredLength = this._edge.lengthSquared();
  23962. var edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  23963. var edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  23964. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  23965. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  23966. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  23967. lowestRoot = getLowestRoot(a, b, c, t);
  23968. if (lowestRoot.found) {
  23969. var f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  23970. if (f >= 0.0 && f <= 1.0) {
  23971. t = lowestRoot.root;
  23972. found = true;
  23973. this._edge.scaleInPlace(f);
  23974. p1.addToRef(this._edge, this._collisionPoint);
  23975. }
  23976. }
  23977. p3.subtractToRef(p2, this._edge);
  23978. p2.subtractToRef(this._basePoint, this._baseToVertex);
  23979. edgeSquaredLength = this._edge.lengthSquared();
  23980. edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  23981. edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  23982. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  23983. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  23984. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  23985. lowestRoot = getLowestRoot(a, b, c, t);
  23986. if (lowestRoot.found) {
  23987. f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  23988. if (f >= 0.0 && f <= 1.0) {
  23989. t = lowestRoot.root;
  23990. found = true;
  23991. this._edge.scaleInPlace(f);
  23992. p2.addToRef(this._edge, this._collisionPoint);
  23993. }
  23994. }
  23995. p1.subtractToRef(p3, this._edge);
  23996. p3.subtractToRef(this._basePoint, this._baseToVertex);
  23997. edgeSquaredLength = this._edge.lengthSquared();
  23998. edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  23999. edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  24000. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  24001. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  24002. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  24003. lowestRoot = getLowestRoot(a, b, c, t);
  24004. if (lowestRoot.found) {
  24005. f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  24006. if (f >= 0.0 && f <= 1.0) {
  24007. t = lowestRoot.root;
  24008. found = true;
  24009. this._edge.scaleInPlace(f);
  24010. p3.addToRef(this._edge, this._collisionPoint);
  24011. }
  24012. }
  24013. }
  24014. if (found) {
  24015. var distToCollision = t * this._velocity.length();
  24016. if (!this.collisionFound || distToCollision < this._nearestDistance) {
  24017. if (!this.intersectionPoint) {
  24018. this.intersectionPoint = this._collisionPoint.clone();
  24019. }
  24020. else {
  24021. this.intersectionPoint.copyFrom(this._collisionPoint);
  24022. }
  24023. this._nearestDistance = distToCollision;
  24024. this.collisionFound = true;
  24025. }
  24026. }
  24027. };
  24028. /** @hidden */
  24029. Collider.prototype._collide = function (trianglePlaneArray, pts, indices, indexStart, indexEnd, decal, hasMaterial) {
  24030. for (var i = indexStart; i < indexEnd; i += 3) {
  24031. var p1 = pts[indices[i] - decal];
  24032. var p2 = pts[indices[i + 1] - decal];
  24033. var p3 = pts[indices[i + 2] - decal];
  24034. this._testTriangle(i, trianglePlaneArray, p3, p2, p1, hasMaterial);
  24035. }
  24036. };
  24037. /** @hidden */
  24038. Collider.prototype._getResponse = function (pos, vel) {
  24039. pos.addToRef(vel, this._destinationPoint);
  24040. vel.scaleInPlace((this._nearestDistance / vel.length()));
  24041. this._basePoint.addToRef(vel, pos);
  24042. pos.subtractToRef(this.intersectionPoint, this._slidePlaneNormal);
  24043. this._slidePlaneNormal.normalize();
  24044. this._slidePlaneNormal.scaleToRef(this._epsilon, this._displacementVector);
  24045. pos.addInPlace(this._displacementVector);
  24046. this.intersectionPoint.addInPlace(this._displacementVector);
  24047. this._slidePlaneNormal.scaleInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Plane"].SignedDistanceToPlaneFromPositionAndNormal(this.intersectionPoint, this._slidePlaneNormal, this._destinationPoint));
  24048. this._destinationPoint.subtractInPlace(this._slidePlaneNormal);
  24049. this._destinationPoint.subtractToRef(this.intersectionPoint, vel);
  24050. };
  24051. return Collider;
  24052. }());
  24053. /***/ }),
  24054. /***/ "./Collisions/collisionCoordinator.ts":
  24055. /*!********************************************!*\
  24056. !*** ./Collisions/collisionCoordinator.ts ***!
  24057. \********************************************/
  24058. /*! exports provided: DefaultCollisionCoordinator */
  24059. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24060. "use strict";
  24061. __webpack_require__.r(__webpack_exports__);
  24062. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return DefaultCollisionCoordinator; });
  24063. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  24064. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24065. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  24066. /* harmony import */ var _collider__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./collider */ "./Collisions/collider.ts");
  24067. /** @hidden */
  24068. var DefaultCollisionCoordinator = /** @class */ (function () {
  24069. function DefaultCollisionCoordinator() {
  24070. this._scaledPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24071. this._scaledVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24072. this._finalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24073. }
  24074. DefaultCollisionCoordinator.prototype.getNewPosition = function (position, displacement, collider, maximumRetry, excludedMesh, onNewPosition, collisionIndex) {
  24075. position.divideToRef(collider._radius, this._scaledPosition);
  24076. displacement.divideToRef(collider._radius, this._scaledVelocity);
  24077. collider.collidedMesh = null;
  24078. collider._retry = 0;
  24079. collider._initialVelocity = this._scaledVelocity;
  24080. collider._initialPosition = this._scaledPosition;
  24081. this._collideWithWorld(this._scaledPosition, this._scaledVelocity, collider, maximumRetry, this._finalPosition, excludedMesh);
  24082. this._finalPosition.multiplyInPlace(collider._radius);
  24083. //run the callback
  24084. onNewPosition(collisionIndex, this._finalPosition, collider.collidedMesh);
  24085. };
  24086. DefaultCollisionCoordinator.prototype.createCollider = function () {
  24087. return new _collider__WEBPACK_IMPORTED_MODULE_3__["Collider"]();
  24088. };
  24089. DefaultCollisionCoordinator.prototype.init = function (scene) {
  24090. this._scene = scene;
  24091. };
  24092. DefaultCollisionCoordinator.prototype._collideWithWorld = function (position, velocity, collider, maximumRetry, finalPosition, excludedMesh) {
  24093. if (excludedMesh === void 0) { excludedMesh = null; }
  24094. var closeDistance = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].CollisionsEpsilon * 10.0;
  24095. if (collider._retry >= maximumRetry) {
  24096. finalPosition.copyFrom(position);
  24097. return;
  24098. }
  24099. // Check if this is a mesh else camera or -1
  24100. var collisionMask = (excludedMesh ? excludedMesh.collisionMask : collider.collisionMask);
  24101. collider._initialize(position, velocity, closeDistance);
  24102. // Check all meshes
  24103. for (var index = 0; index < this._scene.meshes.length; index++) {
  24104. var mesh = this._scene.meshes[index];
  24105. if (mesh.isEnabled() && mesh.checkCollisions && mesh.subMeshes && mesh !== excludedMesh && ((collisionMask & mesh.collisionGroup) !== 0)) {
  24106. mesh._checkCollision(collider);
  24107. }
  24108. }
  24109. if (!collider.collisionFound) {
  24110. position.addToRef(velocity, finalPosition);
  24111. return;
  24112. }
  24113. if (velocity.x !== 0 || velocity.y !== 0 || velocity.z !== 0) {
  24114. collider._getResponse(position, velocity);
  24115. }
  24116. if (velocity.length() <= closeDistance) {
  24117. finalPosition.copyFrom(position);
  24118. return;
  24119. }
  24120. collider._retry++;
  24121. this._collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh);
  24122. };
  24123. return DefaultCollisionCoordinator;
  24124. }());
  24125. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].CollisionCoordinatorFactory = function () {
  24126. return new DefaultCollisionCoordinator();
  24127. };
  24128. /***/ }),
  24129. /***/ "./Collisions/index.ts":
  24130. /*!*****************************!*\
  24131. !*** ./Collisions/index.ts ***!
  24132. \*****************************/
  24133. /*! exports provided: Collider, DefaultCollisionCoordinator, PickingInfo, IntersectionInfo */
  24134. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24135. "use strict";
  24136. __webpack_require__.r(__webpack_exports__);
  24137. /* harmony import */ var _collider__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./collider */ "./Collisions/collider.ts");
  24138. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _collider__WEBPACK_IMPORTED_MODULE_0__["Collider"]; });
  24139. /* harmony import */ var _collisionCoordinator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./collisionCoordinator */ "./Collisions/collisionCoordinator.ts");
  24140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _collisionCoordinator__WEBPACK_IMPORTED_MODULE_1__["DefaultCollisionCoordinator"]; });
  24141. /* harmony import */ var _pickingInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pickingInfo */ "./Collisions/pickingInfo.ts");
  24142. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]; });
  24143. /* harmony import */ var _intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./intersectionInfo */ "./Collisions/intersectionInfo.ts");
  24144. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"]; });
  24145. /***/ }),
  24146. /***/ "./Collisions/intersectionInfo.ts":
  24147. /*!****************************************!*\
  24148. !*** ./Collisions/intersectionInfo.ts ***!
  24149. \****************************************/
  24150. /*! exports provided: IntersectionInfo */
  24151. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24152. "use strict";
  24153. __webpack_require__.r(__webpack_exports__);
  24154. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return IntersectionInfo; });
  24155. /**
  24156. * @hidden
  24157. */
  24158. var IntersectionInfo = /** @class */ (function () {
  24159. function IntersectionInfo(bu, bv, distance) {
  24160. this.bu = bu;
  24161. this.bv = bv;
  24162. this.distance = distance;
  24163. this.faceId = 0;
  24164. this.subMeshId = 0;
  24165. }
  24166. return IntersectionInfo;
  24167. }());
  24168. /***/ }),
  24169. /***/ "./Collisions/pickingInfo.ts":
  24170. /*!***********************************!*\
  24171. !*** ./Collisions/pickingInfo.ts ***!
  24172. \***********************************/
  24173. /*! exports provided: PickingInfo */
  24174. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24175. "use strict";
  24176. __webpack_require__.r(__webpack_exports__);
  24177. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return PickingInfo; });
  24178. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24179. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  24180. /**
  24181. * Information about the result of picking within a scene
  24182. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  24183. */
  24184. var PickingInfo = /** @class */ (function () {
  24185. function PickingInfo() {
  24186. /** @hidden */
  24187. this._pickingUnavailable = false;
  24188. /**
  24189. * If the pick collided with an object
  24190. */
  24191. this.hit = false;
  24192. /**
  24193. * Distance away where the pick collided
  24194. */
  24195. this.distance = 0;
  24196. /**
  24197. * The location of pick collision
  24198. */
  24199. this.pickedPoint = null;
  24200. /**
  24201. * The mesh corresponding the the pick collision
  24202. */
  24203. this.pickedMesh = null;
  24204. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  24205. this.bu = 0;
  24206. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  24207. this.bv = 0;
  24208. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24209. this.faceId = -1;
  24210. /** Id of the the submesh that was picked */
  24211. this.subMeshId = 0;
  24212. /** If a sprite was picked, this will be the sprite the pick collided with */
  24213. this.pickedSprite = null;
  24214. /**
  24215. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  24216. */
  24217. this.originMesh = null;
  24218. /**
  24219. * The ray that was used to perform the picking.
  24220. */
  24221. this.ray = null;
  24222. }
  24223. /**
  24224. * Gets the normal correspodning to the face the pick collided with
  24225. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  24226. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  24227. * @returns The normal correspodning to the face the pick collided with
  24228. */
  24229. PickingInfo.prototype.getNormal = function (useWorldCoordinates, useVerticesNormals) {
  24230. if (useWorldCoordinates === void 0) { useWorldCoordinates = false; }
  24231. if (useVerticesNormals === void 0) { useVerticesNormals = true; }
  24232. if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind)) {
  24233. return null;
  24234. }
  24235. var indices = this.pickedMesh.getIndices();
  24236. if (!indices) {
  24237. return null;
  24238. }
  24239. var result;
  24240. if (useVerticesNormals) {
  24241. var normals = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  24242. var normal0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3] * 3);
  24243. var normal1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3 + 1] * 3);
  24244. var normal2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3 + 2] * 3);
  24245. normal0 = normal0.scale(this.bu);
  24246. normal1 = normal1.scale(this.bv);
  24247. normal2 = normal2.scale(1.0 - this.bu - this.bv);
  24248. 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);
  24249. }
  24250. else {
  24251. var positions = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  24252. var vertex1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3] * 3);
  24253. var vertex2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3 + 1] * 3);
  24254. var vertex3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3 + 2] * 3);
  24255. var p1p2 = vertex1.subtract(vertex2);
  24256. var p3p2 = vertex3.subtract(vertex2);
  24257. result = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(p1p2, p3p2);
  24258. }
  24259. if (useWorldCoordinates) {
  24260. var wm = this.pickedMesh.getWorldMatrix();
  24261. if (this.pickedMesh.nonUniformScaling) {
  24262. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0].copyFrom(wm);
  24263. wm = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  24264. wm.setTranslationFromFloats(0, 0, 0);
  24265. wm.invert();
  24266. wm.transposeToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1]);
  24267. wm = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  24268. }
  24269. result = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(result, wm);
  24270. }
  24271. result.normalize();
  24272. return result;
  24273. };
  24274. /**
  24275. * Gets the texture coordinates of where the pick occured
  24276. * @returns the vector containing the coordnates of the texture
  24277. */
  24278. PickingInfo.prototype.getTextureCoordinates = function () {
  24279. if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  24280. return null;
  24281. }
  24282. var indices = this.pickedMesh.getIndices();
  24283. if (!indices) {
  24284. return null;
  24285. }
  24286. var uvs = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  24287. if (!uvs) {
  24288. return null;
  24289. }
  24290. var uv0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3] * 2);
  24291. var uv1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3 + 1] * 2);
  24292. var uv2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3 + 2] * 2);
  24293. uv0 = uv0.scale(1.0 - this.bu - this.bv);
  24294. uv1 = uv1.scale(this.bu);
  24295. uv2 = uv2.scale(this.bv);
  24296. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](uv0.x + uv1.x + uv2.x, uv0.y + uv1.y + uv2.y);
  24297. };
  24298. return PickingInfo;
  24299. }());
  24300. /***/ }),
  24301. /***/ "./Culling/Octrees/index.ts":
  24302. /*!**********************************!*\
  24303. !*** ./Culling/Octrees/index.ts ***!
  24304. \**********************************/
  24305. /*! exports provided: Octree, OctreeBlock, OctreeSceneComponent */
  24306. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24307. "use strict";
  24308. __webpack_require__.r(__webpack_exports__);
  24309. /* harmony import */ var _octree__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./octree */ "./Culling/Octrees/octree.ts");
  24310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _octree__WEBPACK_IMPORTED_MODULE_0__["Octree"]; });
  24311. /* harmony import */ var _octreeBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./octreeBlock */ "./Culling/Octrees/octreeBlock.ts");
  24312. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _octreeBlock__WEBPACK_IMPORTED_MODULE_1__["OctreeBlock"]; });
  24313. /* harmony import */ var _octreeSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./octreeSceneComponent */ "./Culling/Octrees/octreeSceneComponent.ts");
  24314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _octreeSceneComponent__WEBPACK_IMPORTED_MODULE_2__["OctreeSceneComponent"]; });
  24315. /***/ }),
  24316. /***/ "./Culling/Octrees/octree.ts":
  24317. /*!***********************************!*\
  24318. !*** ./Culling/Octrees/octree.ts ***!
  24319. \***********************************/
  24320. /*! exports provided: Octree */
  24321. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24322. "use strict";
  24323. __webpack_require__.r(__webpack_exports__);
  24324. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return Octree; });
  24325. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  24326. /* harmony import */ var _octreeBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./octreeBlock */ "./Culling/Octrees/octreeBlock.ts");
  24327. /**
  24328. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  24329. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  24330. */
  24331. var Octree = /** @class */ (function () {
  24332. /**
  24333. * Creates a octree
  24334. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  24335. * @param creationFunc function to be used to instatiate the octree
  24336. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  24337. * @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.)
  24338. */
  24339. function Octree(creationFunc, maxBlockCapacity,
  24340. /** 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.) */
  24341. maxDepth) {
  24342. if (maxDepth === void 0) { maxDepth = 2; }
  24343. this.maxDepth = maxDepth;
  24344. /**
  24345. * Content stored in the octree
  24346. */
  24347. this.dynamicContent = new Array();
  24348. this._maxBlockCapacity = maxBlockCapacity || 64;
  24349. this._selectionContent = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArrayNoDuplicate"](1024);
  24350. this._creationFunc = creationFunc;
  24351. }
  24352. // Methods
  24353. /**
  24354. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  24355. * @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);
  24356. * @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);
  24357. * @param entries meshes to be added to the octree blocks
  24358. */
  24359. Octree.prototype.update = function (worldMin, worldMax, entries) {
  24360. _octreeBlock__WEBPACK_IMPORTED_MODULE_1__["OctreeBlock"]._CreateBlocks(worldMin, worldMax, entries, this._maxBlockCapacity, 0, this.maxDepth, this, this._creationFunc);
  24361. };
  24362. /**
  24363. * Adds a mesh to the octree
  24364. * @param entry Mesh to add to the octree
  24365. */
  24366. Octree.prototype.addMesh = function (entry) {
  24367. for (var index = 0; index < this.blocks.length; index++) {
  24368. var block = this.blocks[index];
  24369. block.addEntry(entry);
  24370. }
  24371. };
  24372. /**
  24373. * Remove an element from the octree
  24374. * @param entry defines the element to remove
  24375. */
  24376. Octree.prototype.removeMesh = function (entry) {
  24377. for (var index = 0; index < this.blocks.length; index++) {
  24378. var block = this.blocks[index];
  24379. block.removeEntry(entry);
  24380. }
  24381. };
  24382. /**
  24383. * Selects an array of meshes within the frustum
  24384. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  24385. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  24386. * @returns array of meshes within the frustum
  24387. */
  24388. Octree.prototype.select = function (frustumPlanes, allowDuplicate) {
  24389. this._selectionContent.reset();
  24390. for (var index = 0; index < this.blocks.length; index++) {
  24391. var block = this.blocks[index];
  24392. block.select(frustumPlanes, this._selectionContent, allowDuplicate);
  24393. }
  24394. if (allowDuplicate) {
  24395. this._selectionContent.concat(this.dynamicContent);
  24396. }
  24397. else {
  24398. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  24399. }
  24400. return this._selectionContent;
  24401. };
  24402. /**
  24403. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  24404. * @param sphereCenter defines the bounding sphere center
  24405. * @param sphereRadius defines the bounding sphere radius
  24406. * @param allowDuplicate defines if the selection array can contains duplicated entries
  24407. * @returns an array of objects that intersect the sphere
  24408. */
  24409. Octree.prototype.intersects = function (sphereCenter, sphereRadius, allowDuplicate) {
  24410. this._selectionContent.reset();
  24411. for (var index = 0; index < this.blocks.length; index++) {
  24412. var block = this.blocks[index];
  24413. block.intersects(sphereCenter, sphereRadius, this._selectionContent, allowDuplicate);
  24414. }
  24415. if (allowDuplicate) {
  24416. this._selectionContent.concat(this.dynamicContent);
  24417. }
  24418. else {
  24419. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  24420. }
  24421. return this._selectionContent;
  24422. };
  24423. /**
  24424. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  24425. * @param ray defines the ray to test with
  24426. * @returns array of intersected objects
  24427. */
  24428. Octree.prototype.intersectsRay = function (ray) {
  24429. this._selectionContent.reset();
  24430. for (var index = 0; index < this.blocks.length; index++) {
  24431. var block = this.blocks[index];
  24432. block.intersectsRay(ray, this._selectionContent);
  24433. }
  24434. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  24435. return this._selectionContent;
  24436. };
  24437. /**
  24438. * Adds a mesh into the octree block if it intersects the block
  24439. */
  24440. Octree.CreationFuncForMeshes = function (entry, block) {
  24441. var boundingInfo = entry.getBoundingInfo();
  24442. if (!entry.isBlocked && boundingInfo.boundingBox.intersectsMinMax(block.minPoint, block.maxPoint)) {
  24443. block.entries.push(entry);
  24444. }
  24445. };
  24446. /**
  24447. * Adds a submesh into the octree block if it intersects the block
  24448. */
  24449. Octree.CreationFuncForSubMeshes = function (entry, block) {
  24450. var boundingInfo = entry.getBoundingInfo();
  24451. if (boundingInfo.boundingBox.intersectsMinMax(block.minPoint, block.maxPoint)) {
  24452. block.entries.push(entry);
  24453. }
  24454. };
  24455. return Octree;
  24456. }());
  24457. /***/ }),
  24458. /***/ "./Culling/Octrees/octreeBlock.ts":
  24459. /*!****************************************!*\
  24460. !*** ./Culling/Octrees/octreeBlock.ts ***!
  24461. \****************************************/
  24462. /*! exports provided: OctreeBlock */
  24463. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24464. "use strict";
  24465. __webpack_require__.r(__webpack_exports__);
  24466. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return OctreeBlock; });
  24467. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  24468. /* harmony import */ var _Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Culling/boundingBox */ "./Culling/boundingBox.ts");
  24469. /**
  24470. * Class used to store a cell in an octree
  24471. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  24472. */
  24473. var OctreeBlock = /** @class */ (function () {
  24474. /**
  24475. * Creates a new block
  24476. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  24477. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  24478. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  24479. * @param depth defines the current depth of this block in the octree
  24480. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  24481. * @param creationFunc defines a callback to call when an element is added to the block
  24482. */
  24483. function OctreeBlock(minPoint, maxPoint, capacity, depth, maxDepth, creationFunc) {
  24484. /**
  24485. * Gets the content of the current block
  24486. */
  24487. this.entries = new Array();
  24488. this._boundingVectors = new Array();
  24489. this._capacity = capacity;
  24490. this._depth = depth;
  24491. this._maxDepth = maxDepth;
  24492. this._creationFunc = creationFunc;
  24493. this._minPoint = minPoint;
  24494. this._maxPoint = maxPoint;
  24495. this._boundingVectors.push(minPoint.clone());
  24496. this._boundingVectors.push(maxPoint.clone());
  24497. this._boundingVectors.push(minPoint.clone());
  24498. this._boundingVectors[2].x = maxPoint.x;
  24499. this._boundingVectors.push(minPoint.clone());
  24500. this._boundingVectors[3].y = maxPoint.y;
  24501. this._boundingVectors.push(minPoint.clone());
  24502. this._boundingVectors[4].z = maxPoint.z;
  24503. this._boundingVectors.push(maxPoint.clone());
  24504. this._boundingVectors[5].z = minPoint.z;
  24505. this._boundingVectors.push(maxPoint.clone());
  24506. this._boundingVectors[6].x = minPoint.x;
  24507. this._boundingVectors.push(maxPoint.clone());
  24508. this._boundingVectors[7].y = minPoint.y;
  24509. }
  24510. Object.defineProperty(OctreeBlock.prototype, "capacity", {
  24511. // Property
  24512. /**
  24513. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  24514. */
  24515. get: function () {
  24516. return this._capacity;
  24517. },
  24518. enumerable: true,
  24519. configurable: true
  24520. });
  24521. Object.defineProperty(OctreeBlock.prototype, "minPoint", {
  24522. /**
  24523. * Gets the minimum vector (in world space) of the block's bounding box
  24524. */
  24525. get: function () {
  24526. return this._minPoint;
  24527. },
  24528. enumerable: true,
  24529. configurable: true
  24530. });
  24531. Object.defineProperty(OctreeBlock.prototype, "maxPoint", {
  24532. /**
  24533. * Gets the maximum vector (in world space) of the block's bounding box
  24534. */
  24535. get: function () {
  24536. return this._maxPoint;
  24537. },
  24538. enumerable: true,
  24539. configurable: true
  24540. });
  24541. // Methods
  24542. /**
  24543. * Add a new element to this block
  24544. * @param entry defines the element to add
  24545. */
  24546. OctreeBlock.prototype.addEntry = function (entry) {
  24547. if (this.blocks) {
  24548. for (var index = 0; index < this.blocks.length; index++) {
  24549. var block = this.blocks[index];
  24550. block.addEntry(entry);
  24551. }
  24552. return;
  24553. }
  24554. this._creationFunc(entry, this);
  24555. if (this.entries.length > this.capacity && this._depth < this._maxDepth) {
  24556. this.createInnerBlocks();
  24557. }
  24558. };
  24559. /**
  24560. * Remove an element from this block
  24561. * @param entry defines the element to remove
  24562. */
  24563. OctreeBlock.prototype.removeEntry = function (entry) {
  24564. if (this.blocks) {
  24565. for (var index = 0; index < this.blocks.length; index++) {
  24566. var block = this.blocks[index];
  24567. block.removeEntry(entry);
  24568. }
  24569. return;
  24570. }
  24571. var entryIndex = this.entries.indexOf(entry);
  24572. if (entryIndex > -1) {
  24573. this.entries.splice(entryIndex, 1);
  24574. }
  24575. };
  24576. /**
  24577. * Add an array of elements to this block
  24578. * @param entries defines the array of elements to add
  24579. */
  24580. OctreeBlock.prototype.addEntries = function (entries) {
  24581. for (var index = 0; index < entries.length; index++) {
  24582. var mesh = entries[index];
  24583. this.addEntry(mesh);
  24584. }
  24585. };
  24586. /**
  24587. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  24588. * @param frustumPlanes defines the frustum planes to test
  24589. * @param selection defines the array to store current content if selection is positive
  24590. * @param allowDuplicate defines if the selection array can contains duplicated entries
  24591. */
  24592. OctreeBlock.prototype.select = function (frustumPlanes, selection, allowDuplicate) {
  24593. if (_Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__["BoundingBox"].IsInFrustum(this._boundingVectors, frustumPlanes)) {
  24594. if (this.blocks) {
  24595. for (var index = 0; index < this.blocks.length; index++) {
  24596. var block = this.blocks[index];
  24597. block.select(frustumPlanes, selection, allowDuplicate);
  24598. }
  24599. return;
  24600. }
  24601. if (allowDuplicate) {
  24602. selection.concat(this.entries);
  24603. }
  24604. else {
  24605. selection.concatWithNoDuplicate(this.entries);
  24606. }
  24607. }
  24608. };
  24609. /**
  24610. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  24611. * @param sphereCenter defines the bounding sphere center
  24612. * @param sphereRadius defines the bounding sphere radius
  24613. * @param selection defines the array to store current content if selection is positive
  24614. * @param allowDuplicate defines if the selection array can contains duplicated entries
  24615. */
  24616. OctreeBlock.prototype.intersects = function (sphereCenter, sphereRadius, selection, allowDuplicate) {
  24617. if (_Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__["BoundingBox"].IntersectsSphere(this._minPoint, this._maxPoint, sphereCenter, sphereRadius)) {
  24618. if (this.blocks) {
  24619. for (var index = 0; index < this.blocks.length; index++) {
  24620. var block = this.blocks[index];
  24621. block.intersects(sphereCenter, sphereRadius, selection, allowDuplicate);
  24622. }
  24623. return;
  24624. }
  24625. if (allowDuplicate) {
  24626. selection.concat(this.entries);
  24627. }
  24628. else {
  24629. selection.concatWithNoDuplicate(this.entries);
  24630. }
  24631. }
  24632. };
  24633. /**
  24634. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  24635. * @param ray defines the ray to test with
  24636. * @param selection defines the array to store current content if selection is positive
  24637. */
  24638. OctreeBlock.prototype.intersectsRay = function (ray, selection) {
  24639. if (ray.intersectsBoxMinMax(this._minPoint, this._maxPoint)) {
  24640. if (this.blocks) {
  24641. for (var index = 0; index < this.blocks.length; index++) {
  24642. var block = this.blocks[index];
  24643. block.intersectsRay(ray, selection);
  24644. }
  24645. return;
  24646. }
  24647. selection.concatWithNoDuplicate(this.entries);
  24648. }
  24649. };
  24650. /**
  24651. * Subdivide the content into child blocks (this block will then be empty)
  24652. */
  24653. OctreeBlock.prototype.createInnerBlocks = function () {
  24654. OctreeBlock._CreateBlocks(this._minPoint, this._maxPoint, this.entries, this._capacity, this._depth, this._maxDepth, this, this._creationFunc);
  24655. };
  24656. /**
  24657. * @hidden
  24658. */
  24659. OctreeBlock._CreateBlocks = function (worldMin, worldMax, entries, maxBlockCapacity, currentDepth, maxDepth, target, creationFunc) {
  24660. target.blocks = new Array();
  24661. 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);
  24662. // Segmenting space
  24663. for (var x = 0; x < 2; x++) {
  24664. for (var y = 0; y < 2; y++) {
  24665. for (var z = 0; z < 2; z++) {
  24666. var localMin = worldMin.add(blockSize.multiplyByFloats(x, y, z));
  24667. var localMax = worldMin.add(blockSize.multiplyByFloats(x + 1, y + 1, z + 1));
  24668. var block = new OctreeBlock(localMin, localMax, maxBlockCapacity, currentDepth + 1, maxDepth, creationFunc);
  24669. block.addEntries(entries);
  24670. target.blocks.push(block);
  24671. }
  24672. }
  24673. }
  24674. };
  24675. return OctreeBlock;
  24676. }());
  24677. /***/ }),
  24678. /***/ "./Culling/Octrees/octreeSceneComponent.ts":
  24679. /*!*************************************************!*\
  24680. !*** ./Culling/Octrees/octreeSceneComponent.ts ***!
  24681. \*************************************************/
  24682. /*! exports provided: OctreeSceneComponent */
  24683. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24684. "use strict";
  24685. __webpack_require__.r(__webpack_exports__);
  24686. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return OctreeSceneComponent; });
  24687. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  24688. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  24689. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  24690. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  24691. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  24692. /* harmony import */ var _octree__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./octree */ "./Culling/Octrees/octree.ts");
  24693. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.createOrUpdateSelectionOctree = function (maxCapacity, maxDepth) {
  24694. if (maxCapacity === void 0) { maxCapacity = 64; }
  24695. if (maxDepth === void 0) { maxDepth = 2; }
  24696. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE);
  24697. if (!component) {
  24698. component = new OctreeSceneComponent(this);
  24699. this._addComponent(component);
  24700. }
  24701. if (!this._selectionOctree) {
  24702. this._selectionOctree = new _octree__WEBPACK_IMPORTED_MODULE_5__["Octree"](_octree__WEBPACK_IMPORTED_MODULE_5__["Octree"].CreationFuncForMeshes, maxCapacity, maxDepth);
  24703. }
  24704. var worldExtends = this.getWorldExtends();
  24705. // Update octree
  24706. this._selectionOctree.update(worldExtends.min, worldExtends.max, this.meshes);
  24707. return this._selectionOctree;
  24708. };
  24709. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "selectionOctree", {
  24710. get: function () {
  24711. return this._selectionOctree;
  24712. },
  24713. enumerable: true,
  24714. configurable: true
  24715. });
  24716. /**
  24717. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  24718. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  24719. * @param maxCapacity defines the maximum size of each block (64 by default)
  24720. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  24721. * @returns the new octree
  24722. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  24723. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  24724. */
  24725. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.createOrUpdateSubmeshesOctree = function (maxCapacity, maxDepth) {
  24726. if (maxCapacity === void 0) { maxCapacity = 64; }
  24727. if (maxDepth === void 0) { maxDepth = 2; }
  24728. var scene = this.getScene();
  24729. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE);
  24730. if (!component) {
  24731. component = new OctreeSceneComponent(scene);
  24732. scene._addComponent(component);
  24733. }
  24734. if (!this._submeshesOctree) {
  24735. this._submeshesOctree = new _octree__WEBPACK_IMPORTED_MODULE_5__["Octree"](_octree__WEBPACK_IMPORTED_MODULE_5__["Octree"].CreationFuncForSubMeshes, maxCapacity, maxDepth);
  24736. }
  24737. this.computeWorldMatrix(true);
  24738. var boundingInfo = this.getBoundingInfo();
  24739. // Update octree
  24740. var bbox = boundingInfo.boundingBox;
  24741. this._submeshesOctree.update(bbox.minimumWorld, bbox.maximumWorld, this.subMeshes);
  24742. return this._submeshesOctree;
  24743. };
  24744. /**
  24745. * Defines the octree scene component responsible to manage any octrees
  24746. * in a given scene.
  24747. */
  24748. var OctreeSceneComponent = /** @class */ (function () {
  24749. /**
  24750. * Creates a new instance of the component for the given scene
  24751. * @param scene Defines the scene to register the component in
  24752. */
  24753. function OctreeSceneComponent(scene) {
  24754. /**
  24755. * The component name helpfull to identify the component in the list of scene components.
  24756. */
  24757. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE;
  24758. /**
  24759. * Indicates if the meshes have been checked to make sure they are isEnabled()
  24760. */
  24761. this.checksIsEnabled = true;
  24762. 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));
  24763. this.scene = scene;
  24764. this.scene.getActiveMeshCandidates = this.getActiveMeshCandidates.bind(this);
  24765. this.scene.getActiveSubMeshCandidates = this.getActiveSubMeshCandidates.bind(this);
  24766. this.scene.getCollidingSubMeshCandidates = this.getCollidingSubMeshCandidates.bind(this);
  24767. this.scene.getIntersectingSubMeshCandidates = this.getIntersectingSubMeshCandidates.bind(this);
  24768. }
  24769. /**
  24770. * Registers the component in a given scene
  24771. */
  24772. OctreeSceneComponent.prototype.register = function () {
  24773. var _this = this;
  24774. this.scene.onMeshRemovedObservable.add(function (mesh) {
  24775. var sceneOctree = _this.scene.selectionOctree;
  24776. if (sceneOctree !== undefined && sceneOctree !== null) {
  24777. var index = sceneOctree.dynamicContent.indexOf(mesh);
  24778. if (index !== -1) {
  24779. sceneOctree.dynamicContent.splice(index, 1);
  24780. }
  24781. }
  24782. });
  24783. this.scene.onMeshImportedObservable.add(function (mesh) {
  24784. var sceneOctree = _this.scene.selectionOctree;
  24785. if (sceneOctree !== undefined && sceneOctree !== null) {
  24786. sceneOctree.addMesh(mesh);
  24787. }
  24788. });
  24789. };
  24790. /**
  24791. * Return the list of active meshes
  24792. * @returns the list of active meshes
  24793. */
  24794. OctreeSceneComponent.prototype.getActiveMeshCandidates = function () {
  24795. if (this.scene._selectionOctree) {
  24796. var selection = this.scene._selectionOctree.select(this.scene.frustumPlanes);
  24797. return selection;
  24798. }
  24799. return this.scene._getDefaultMeshCandidates();
  24800. };
  24801. /**
  24802. * Return the list of active sub meshes
  24803. * @param mesh The mesh to get the candidates sub meshes from
  24804. * @returns the list of active sub meshes
  24805. */
  24806. OctreeSceneComponent.prototype.getActiveSubMeshCandidates = function (mesh) {
  24807. if (mesh._submeshesOctree && mesh.useOctreeForRenderingSelection) {
  24808. var intersections = mesh._submeshesOctree.select(this.scene.frustumPlanes);
  24809. return intersections;
  24810. }
  24811. return this.scene._getDefaultSubMeshCandidates(mesh);
  24812. };
  24813. /**
  24814. * Return the list of sub meshes intersecting with a given local ray
  24815. * @param mesh defines the mesh to find the submesh for
  24816. * @param localRay defines the ray in local space
  24817. * @returns the list of intersecting sub meshes
  24818. */
  24819. OctreeSceneComponent.prototype.getIntersectingSubMeshCandidates = function (mesh, localRay) {
  24820. if (mesh._submeshesOctree && mesh.useOctreeForPicking) {
  24821. _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"].TransformToRef(localRay, mesh.getWorldMatrix(), this._tempRay);
  24822. var intersections = mesh._submeshesOctree.intersectsRay(this._tempRay);
  24823. return intersections;
  24824. }
  24825. return this.scene._getDefaultSubMeshCandidates(mesh);
  24826. };
  24827. /**
  24828. * Return the list of sub meshes colliding with a collider
  24829. * @param mesh defines the mesh to find the submesh for
  24830. * @param collider defines the collider to evaluate the collision against
  24831. * @returns the list of colliding sub meshes
  24832. */
  24833. OctreeSceneComponent.prototype.getCollidingSubMeshCandidates = function (mesh, collider) {
  24834. if (mesh._submeshesOctree && mesh.useOctreeForCollisions) {
  24835. var radius = collider._velocityWorldLength + Math.max(collider._radius.x, collider._radius.y, collider._radius.z);
  24836. var intersections = mesh._submeshesOctree.intersects(collider._basePointWorld, radius);
  24837. return intersections;
  24838. }
  24839. return this.scene._getDefaultSubMeshCandidates(mesh);
  24840. };
  24841. /**
  24842. * Rebuilds the elements related to this component in case of
  24843. * context lost for instance.
  24844. */
  24845. OctreeSceneComponent.prototype.rebuild = function () {
  24846. // Nothing to do here.
  24847. };
  24848. /**
  24849. * Disposes the component and the associated ressources.
  24850. */
  24851. OctreeSceneComponent.prototype.dispose = function () {
  24852. // Nothing to do here.
  24853. };
  24854. return OctreeSceneComponent;
  24855. }());
  24856. /***/ }),
  24857. /***/ "./Culling/boundingBox.ts":
  24858. /*!********************************!*\
  24859. !*** ./Culling/boundingBox.ts ***!
  24860. \********************************/
  24861. /*! exports provided: BoundingBox */
  24862. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24863. "use strict";
  24864. __webpack_require__.r(__webpack_exports__);
  24865. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return BoundingBox; });
  24866. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  24867. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24868. /**
  24869. * Class used to store bounding box information
  24870. */
  24871. var BoundingBox = /** @class */ (function () {
  24872. /**
  24873. * Creates a new bounding box
  24874. * @param min defines the minimum vector (in local space)
  24875. * @param max defines the maximum vector (in local space)
  24876. * @param worldMatrix defines the new world matrix
  24877. */
  24878. function BoundingBox(min, max, worldMatrix) {
  24879. /**
  24880. * Gets the 8 vectors representing the bounding box in local space
  24881. */
  24882. this.vectors = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24883. /**
  24884. * Gets the center of the bounding box in local space
  24885. */
  24886. this.center = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24887. /**
  24888. * Gets the center of the bounding box in world space
  24889. */
  24890. this.centerWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24891. /**
  24892. * Gets the extend size in local space
  24893. */
  24894. this.extendSize = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24895. /**
  24896. * Gets the extend size in world space
  24897. */
  24898. this.extendSizeWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24899. /**
  24900. * Gets the OBB (object bounding box) directions
  24901. */
  24902. this.directions = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24903. /**
  24904. * Gets the 8 vectors representing the bounding box in world space
  24905. */
  24906. this.vectorsWorld = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24907. /**
  24908. * Gets the minimum vector in world space
  24909. */
  24910. this.minimumWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24911. /**
  24912. * Gets the maximum vector in world space
  24913. */
  24914. this.maximumWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24915. /**
  24916. * Gets the minimum vector in local space
  24917. */
  24918. this.minimum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24919. /**
  24920. * Gets the maximum vector in local space
  24921. */
  24922. this.maximum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24923. this.reConstruct(min, max, worldMatrix);
  24924. }
  24925. // Methods
  24926. /**
  24927. * Recreates the entire bounding box from scratch as if we call the constructor in place
  24928. * @param min defines the new minimum vector (in local space)
  24929. * @param max defines the new maximum vector (in local space)
  24930. * @param worldMatrix defines the new world matrix
  24931. */
  24932. BoundingBox.prototype.reConstruct = function (min, max, worldMatrix) {
  24933. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  24934. var vectors = this.vectors;
  24935. this.minimum.copyFromFloats(minX, minY, minZ);
  24936. this.maximum.copyFromFloats(maxX, maxY, maxZ);
  24937. vectors[0].copyFromFloats(minX, minY, minZ);
  24938. vectors[1].copyFromFloats(maxX, maxY, maxZ);
  24939. vectors[2].copyFromFloats(maxX, minY, minZ);
  24940. vectors[3].copyFromFloats(minX, maxY, minZ);
  24941. vectors[4].copyFromFloats(minX, minY, maxZ);
  24942. vectors[5].copyFromFloats(maxX, maxY, minZ);
  24943. vectors[6].copyFromFloats(minX, maxY, maxZ);
  24944. vectors[7].copyFromFloats(maxX, minY, maxZ);
  24945. // OBB
  24946. max.addToRef(min, this.center).scaleInPlace(0.5);
  24947. max.subtractToRef(min, this.extendSize).scaleInPlace(0.5);
  24948. this._update(worldMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly);
  24949. };
  24950. /**
  24951. * Scale the current bounding box by applying a scale factor
  24952. * @param factor defines the scale factor to apply
  24953. * @returns the current bounding box
  24954. */
  24955. BoundingBox.prototype.scale = function (factor) {
  24956. var tmpVectors = BoundingBox.TmpVector3;
  24957. var diff = this.maximum.subtractToRef(this.minimum, tmpVectors[0]);
  24958. var len = diff.length();
  24959. diff.normalizeFromLength(len);
  24960. var distance = len * factor;
  24961. var newRadius = diff.scaleInPlace(distance * 0.5);
  24962. var min = this.center.subtractToRef(newRadius, tmpVectors[1]);
  24963. var max = this.center.addToRef(newRadius, tmpVectors[2]);
  24964. this.reConstruct(min, max, this._worldMatrix);
  24965. return this;
  24966. };
  24967. /**
  24968. * Gets the world matrix of the bounding box
  24969. * @returns a matrix
  24970. */
  24971. BoundingBox.prototype.getWorldMatrix = function () {
  24972. return this._worldMatrix;
  24973. };
  24974. /** @hidden */
  24975. BoundingBox.prototype._update = function (world) {
  24976. var minWorld = this.minimumWorld;
  24977. var maxWorld = this.maximumWorld;
  24978. var directions = this.directions;
  24979. var vectorsWorld = this.vectorsWorld;
  24980. var vectors = this.vectors;
  24981. if (!world.isIdentity()) {
  24982. minWorld.setAll(Number.MAX_VALUE);
  24983. maxWorld.setAll(-Number.MAX_VALUE);
  24984. for (var index = 0; index < 8; ++index) {
  24985. var v = vectorsWorld[index];
  24986. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(vectors[index], world, v);
  24987. minWorld.minimizeInPlace(v);
  24988. maxWorld.maximizeInPlace(v);
  24989. }
  24990. // Extend
  24991. maxWorld.subtractToRef(minWorld, this.extendSizeWorld).scaleInPlace(0.5);
  24992. maxWorld.addToRef(minWorld, this.centerWorld).scaleInPlace(0.5);
  24993. }
  24994. else {
  24995. minWorld.copyFrom(this.minimum);
  24996. maxWorld.copyFrom(this.maximum);
  24997. for (var index = 0; index < 8; ++index) {
  24998. vectorsWorld[index].copyFrom(vectors[index]);
  24999. }
  25000. // Extend
  25001. this.extendSizeWorld.copyFrom(this.extendSize);
  25002. this.centerWorld.copyFrom(this.center);
  25003. }
  25004. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 0, directions[0]);
  25005. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 4, directions[1]);
  25006. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 8, directions[2]);
  25007. this._worldMatrix = world;
  25008. };
  25009. /**
  25010. * Tests if the bounding box is intersecting the frustum planes
  25011. * @param frustumPlanes defines the frustum planes to test
  25012. * @returns true if there is an intersection
  25013. */
  25014. BoundingBox.prototype.isInFrustum = function (frustumPlanes) {
  25015. return BoundingBox.IsInFrustum(this.vectorsWorld, frustumPlanes);
  25016. };
  25017. /**
  25018. * Tests if the bounding box is entirely inside the frustum planes
  25019. * @param frustumPlanes defines the frustum planes to test
  25020. * @returns true if there is an inclusion
  25021. */
  25022. BoundingBox.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  25023. return BoundingBox.IsCompletelyInFrustum(this.vectorsWorld, frustumPlanes);
  25024. };
  25025. /**
  25026. * Tests if a point is inside the bounding box
  25027. * @param point defines the point to test
  25028. * @returns true if the point is inside the bounding box
  25029. */
  25030. BoundingBox.prototype.intersectsPoint = function (point) {
  25031. var min = this.minimumWorld;
  25032. var max = this.maximumWorld;
  25033. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  25034. var pointX = point.x, pointY = point.y, pointZ = point.z;
  25035. var delta = -_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"];
  25036. if (maxX - pointX < delta || delta > pointX - minX) {
  25037. return false;
  25038. }
  25039. if (maxY - pointY < delta || delta > pointY - minY) {
  25040. return false;
  25041. }
  25042. if (maxZ - pointZ < delta || delta > pointZ - minZ) {
  25043. return false;
  25044. }
  25045. return true;
  25046. };
  25047. /**
  25048. * Tests if the bounding box intersects with a bounding sphere
  25049. * @param sphere defines the sphere to test
  25050. * @returns true if there is an intersection
  25051. */
  25052. BoundingBox.prototype.intersectsSphere = function (sphere) {
  25053. return BoundingBox.IntersectsSphere(this.minimumWorld, this.maximumWorld, sphere.centerWorld, sphere.radiusWorld);
  25054. };
  25055. /**
  25056. * Tests if the bounding box intersects with a box defined by a min and max vectors
  25057. * @param min defines the min vector to use
  25058. * @param max defines the max vector to use
  25059. * @returns true if there is an intersection
  25060. */
  25061. BoundingBox.prototype.intersectsMinMax = function (min, max) {
  25062. var myMin = this.minimumWorld;
  25063. var myMax = this.maximumWorld;
  25064. var myMinX = myMin.x, myMinY = myMin.y, myMinZ = myMin.z, myMaxX = myMax.x, myMaxY = myMax.y, myMaxZ = myMax.z;
  25065. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  25066. if (myMaxX < minX || myMinX > maxX) {
  25067. return false;
  25068. }
  25069. if (myMaxY < minY || myMinY > maxY) {
  25070. return false;
  25071. }
  25072. if (myMaxZ < minZ || myMinZ > maxZ) {
  25073. return false;
  25074. }
  25075. return true;
  25076. };
  25077. // Statics
  25078. /**
  25079. * Tests if two bounding boxes are intersections
  25080. * @param box0 defines the first box to test
  25081. * @param box1 defines the second box to test
  25082. * @returns true if there is an intersection
  25083. */
  25084. BoundingBox.Intersects = function (box0, box1) {
  25085. return box0.intersectsMinMax(box1.minimumWorld, box1.maximumWorld);
  25086. };
  25087. /**
  25088. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  25089. * @param minPoint defines the minimum vector of the bounding box
  25090. * @param maxPoint defines the maximum vector of the bounding box
  25091. * @param sphereCenter defines the sphere center
  25092. * @param sphereRadius defines the sphere radius
  25093. * @returns true if there is an intersection
  25094. */
  25095. BoundingBox.IntersectsSphere = function (minPoint, maxPoint, sphereCenter, sphereRadius) {
  25096. var vector = BoundingBox.TmpVector3[0];
  25097. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ClampToRef(sphereCenter, minPoint, maxPoint, vector);
  25098. var num = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(sphereCenter, vector);
  25099. return (num <= (sphereRadius * sphereRadius));
  25100. };
  25101. /**
  25102. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  25103. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  25104. * @param frustumPlanes defines the frustum planes to test
  25105. * @return true if there is an inclusion
  25106. */
  25107. BoundingBox.IsCompletelyInFrustum = function (boundingVectors, frustumPlanes) {
  25108. for (var p = 0; p < 6; ++p) {
  25109. var frustumPlane = frustumPlanes[p];
  25110. for (var i = 0; i < 8; ++i) {
  25111. if (frustumPlane.dotCoordinate(boundingVectors[i]) < 0) {
  25112. return false;
  25113. }
  25114. }
  25115. }
  25116. return true;
  25117. };
  25118. /**
  25119. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  25120. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  25121. * @param frustumPlanes defines the frustum planes to test
  25122. * @return true if there is an intersection
  25123. */
  25124. BoundingBox.IsInFrustum = function (boundingVectors, frustumPlanes) {
  25125. for (var p = 0; p < 6; ++p) {
  25126. var canReturnFalse = true;
  25127. var frustumPlane = frustumPlanes[p];
  25128. for (var i = 0; i < 8; ++i) {
  25129. if (frustumPlane.dotCoordinate(boundingVectors[i]) >= 0) {
  25130. canReturnFalse = false;
  25131. break;
  25132. }
  25133. }
  25134. if (canReturnFalse) {
  25135. return false;
  25136. }
  25137. }
  25138. return true;
  25139. };
  25140. BoundingBox.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25141. return BoundingBox;
  25142. }());
  25143. /***/ }),
  25144. /***/ "./Culling/boundingInfo.ts":
  25145. /*!*********************************!*\
  25146. !*** ./Culling/boundingInfo.ts ***!
  25147. \*********************************/
  25148. /*! exports provided: BoundingInfo */
  25149. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25150. "use strict";
  25151. __webpack_require__.r(__webpack_exports__);
  25152. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return BoundingInfo; });
  25153. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  25154. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25155. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  25156. /* harmony import */ var _boundingBox__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./boundingBox */ "./Culling/boundingBox.ts");
  25157. /* harmony import */ var _boundingSphere__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./boundingSphere */ "./Culling/boundingSphere.ts");
  25158. var _result0 = { min: 0, max: 0 };
  25159. var _result1 = { min: 0, max: 0 };
  25160. var computeBoxExtents = function (axis, box, result) {
  25161. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.centerWorld, axis);
  25162. var r0 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[0], axis)) * box.extendSize.x;
  25163. var r1 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[1], axis)) * box.extendSize.y;
  25164. var r2 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[2], axis)) * box.extendSize.z;
  25165. var r = r0 + r1 + r2;
  25166. result.min = p - r;
  25167. result.max = p + r;
  25168. };
  25169. var axisOverlap = function (axis, box0, box1) {
  25170. computeBoxExtents(axis, box0, _result0);
  25171. computeBoxExtents(axis, box1, _result1);
  25172. return !(_result0.min > _result1.max || _result1.min > _result0.max);
  25173. };
  25174. /**
  25175. * Info for a bounding data of a mesh
  25176. */
  25177. var BoundingInfo = /** @class */ (function () {
  25178. /**
  25179. * Constructs bounding info
  25180. * @param minimum min vector of the bounding box/sphere
  25181. * @param maximum max vector of the bounding box/sphere
  25182. * @param worldMatrix defines the new world matrix
  25183. */
  25184. function BoundingInfo(minimum, maximum, worldMatrix) {
  25185. this._isLocked = false;
  25186. this.boundingBox = new _boundingBox__WEBPACK_IMPORTED_MODULE_3__["BoundingBox"](minimum, maximum, worldMatrix);
  25187. this.boundingSphere = new _boundingSphere__WEBPACK_IMPORTED_MODULE_4__["BoundingSphere"](minimum, maximum, worldMatrix);
  25188. }
  25189. /**
  25190. * Recreates the entire bounding info from scratch as if we call the constructor in place
  25191. * @param min defines the new minimum vector (in local space)
  25192. * @param max defines the new maximum vector (in local space)
  25193. * @param worldMatrix defines the new world matrix
  25194. */
  25195. BoundingInfo.prototype.reConstruct = function (min, max, worldMatrix) {
  25196. this.boundingBox.reConstruct(min, max, worldMatrix);
  25197. this.boundingSphere.reConstruct(min, max, worldMatrix);
  25198. };
  25199. Object.defineProperty(BoundingInfo.prototype, "minimum", {
  25200. /**
  25201. * min vector of the bounding box/sphere
  25202. */
  25203. get: function () {
  25204. return this.boundingBox.minimum;
  25205. },
  25206. enumerable: true,
  25207. configurable: true
  25208. });
  25209. Object.defineProperty(BoundingInfo.prototype, "maximum", {
  25210. /**
  25211. * max vector of the bounding box/sphere
  25212. */
  25213. get: function () {
  25214. return this.boundingBox.maximum;
  25215. },
  25216. enumerable: true,
  25217. configurable: true
  25218. });
  25219. Object.defineProperty(BoundingInfo.prototype, "isLocked", {
  25220. /**
  25221. * If the info is locked and won't be updated to avoid perf overhead
  25222. */
  25223. get: function () {
  25224. return this._isLocked;
  25225. },
  25226. set: function (value) {
  25227. this._isLocked = value;
  25228. },
  25229. enumerable: true,
  25230. configurable: true
  25231. });
  25232. // Methods
  25233. /**
  25234. * Updates the bounding sphere and box
  25235. * @param world world matrix to be used to update
  25236. */
  25237. BoundingInfo.prototype.update = function (world) {
  25238. if (this._isLocked) {
  25239. return;
  25240. }
  25241. this.boundingBox._update(world);
  25242. this.boundingSphere._update(world);
  25243. };
  25244. /**
  25245. * Recreate the bounding info to be centered around a specific point given a specific extend.
  25246. * @param center New center of the bounding info
  25247. * @param extend New extend of the bounding info
  25248. * @returns the current bounding info
  25249. */
  25250. BoundingInfo.prototype.centerOn = function (center, extend) {
  25251. var minimum = BoundingInfo.TmpVector3[0].copyFrom(center).subtractInPlace(extend);
  25252. var maximum = BoundingInfo.TmpVector3[1].copyFrom(center).addInPlace(extend);
  25253. this.boundingBox.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());
  25254. this.boundingSphere.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());
  25255. return this;
  25256. };
  25257. /**
  25258. * Scale the current bounding info by applying a scale factor
  25259. * @param factor defines the scale factor to apply
  25260. * @returns the current bounding info
  25261. */
  25262. BoundingInfo.prototype.scale = function (factor) {
  25263. this.boundingBox.scale(factor);
  25264. this.boundingSphere.scale(factor);
  25265. return this;
  25266. };
  25267. /**
  25268. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  25269. * @param frustumPlanes defines the frustum to test
  25270. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  25271. * @returns true if the bounding info is in the frustum planes
  25272. */
  25273. BoundingInfo.prototype.isInFrustum = function (frustumPlanes, strategy) {
  25274. if (strategy === void 0) { strategy = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].MESHES_CULLINGSTRATEGY_STANDARD; }
  25275. 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);
  25276. if (inclusionTest) {
  25277. if (this.boundingSphere.isCenterInFrustum(frustumPlanes)) {
  25278. return true;
  25279. }
  25280. }
  25281. if (!this.boundingSphere.isInFrustum(frustumPlanes)) {
  25282. return false;
  25283. }
  25284. 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);
  25285. if (bSphereOnlyTest) {
  25286. return true;
  25287. }
  25288. return this.boundingBox.isInFrustum(frustumPlanes);
  25289. };
  25290. Object.defineProperty(BoundingInfo.prototype, "diagonalLength", {
  25291. /**
  25292. * Gets the world distance between the min and max points of the bounding box
  25293. */
  25294. get: function () {
  25295. var boundingBox = this.boundingBox;
  25296. var diag = boundingBox.maximumWorld.subtractToRef(boundingBox.minimumWorld, BoundingInfo.TmpVector3[0]);
  25297. return diag.length();
  25298. },
  25299. enumerable: true,
  25300. configurable: true
  25301. });
  25302. /**
  25303. * Checks if a cullable object (mesh...) is in the camera frustum
  25304. * Unlike isInFrustum this cheks the full bounding box
  25305. * @param frustumPlanes Camera near/planes
  25306. * @returns true if the object is in frustum otherwise false
  25307. */
  25308. BoundingInfo.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  25309. return this.boundingBox.isCompletelyInFrustum(frustumPlanes);
  25310. };
  25311. /** @hidden */
  25312. BoundingInfo.prototype._checkCollision = function (collider) {
  25313. return collider._canDoCollision(this.boundingSphere.centerWorld, this.boundingSphere.radiusWorld, this.boundingBox.minimumWorld, this.boundingBox.maximumWorld);
  25314. };
  25315. /**
  25316. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  25317. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25318. * @param point the point to check intersection with
  25319. * @returns if the point intersects
  25320. */
  25321. BoundingInfo.prototype.intersectsPoint = function (point) {
  25322. if (!this.boundingSphere.centerWorld) {
  25323. return false;
  25324. }
  25325. if (!this.boundingSphere.intersectsPoint(point)) {
  25326. return false;
  25327. }
  25328. if (!this.boundingBox.intersectsPoint(point)) {
  25329. return false;
  25330. }
  25331. return true;
  25332. };
  25333. /**
  25334. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  25335. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25336. * @param boundingInfo the bounding info to check intersection with
  25337. * @param precise if the intersection should be done using OBB
  25338. * @returns if the bounding info intersects
  25339. */
  25340. BoundingInfo.prototype.intersects = function (boundingInfo, precise) {
  25341. if (!_boundingSphere__WEBPACK_IMPORTED_MODULE_4__["BoundingSphere"].Intersects(this.boundingSphere, boundingInfo.boundingSphere)) {
  25342. return false;
  25343. }
  25344. if (!_boundingBox__WEBPACK_IMPORTED_MODULE_3__["BoundingBox"].Intersects(this.boundingBox, boundingInfo.boundingBox)) {
  25345. return false;
  25346. }
  25347. if (!precise) {
  25348. return true;
  25349. }
  25350. var box0 = this.boundingBox;
  25351. var box1 = boundingInfo.boundingBox;
  25352. if (!axisOverlap(box0.directions[0], box0, box1)) {
  25353. return false;
  25354. }
  25355. if (!axisOverlap(box0.directions[1], box0, box1)) {
  25356. return false;
  25357. }
  25358. if (!axisOverlap(box0.directions[2], box0, box1)) {
  25359. return false;
  25360. }
  25361. if (!axisOverlap(box1.directions[0], box0, box1)) {
  25362. return false;
  25363. }
  25364. if (!axisOverlap(box1.directions[1], box0, box1)) {
  25365. return false;
  25366. }
  25367. if (!axisOverlap(box1.directions[2], box0, box1)) {
  25368. return false;
  25369. }
  25370. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[0]), box0, box1)) {
  25371. return false;
  25372. }
  25373. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[1]), box0, box1)) {
  25374. return false;
  25375. }
  25376. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[2]), box0, box1)) {
  25377. return false;
  25378. }
  25379. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[0]), box0, box1)) {
  25380. return false;
  25381. }
  25382. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[1]), box0, box1)) {
  25383. return false;
  25384. }
  25385. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[2]), box0, box1)) {
  25386. return false;
  25387. }
  25388. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[0]), box0, box1)) {
  25389. return false;
  25390. }
  25391. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[1]), box0, box1)) {
  25392. return false;
  25393. }
  25394. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[2]), box0, box1)) {
  25395. return false;
  25396. }
  25397. return true;
  25398. };
  25399. BoundingInfo.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25400. return BoundingInfo;
  25401. }());
  25402. /***/ }),
  25403. /***/ "./Culling/boundingSphere.ts":
  25404. /*!***********************************!*\
  25405. !*** ./Culling/boundingSphere.ts ***!
  25406. \***********************************/
  25407. /*! exports provided: BoundingSphere */
  25408. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25409. "use strict";
  25410. __webpack_require__.r(__webpack_exports__);
  25411. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return BoundingSphere; });
  25412. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  25413. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25414. /**
  25415. * Class used to store bounding sphere information
  25416. */
  25417. var BoundingSphere = /** @class */ (function () {
  25418. /**
  25419. * Creates a new bounding sphere
  25420. * @param min defines the minimum vector (in local space)
  25421. * @param max defines the maximum vector (in local space)
  25422. * @param worldMatrix defines the new world matrix
  25423. */
  25424. function BoundingSphere(min, max, worldMatrix) {
  25425. /**
  25426. * Gets the center of the bounding sphere in local space
  25427. */
  25428. this.center = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25429. /**
  25430. * Gets the center of the bounding sphere in world space
  25431. */
  25432. this.centerWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25433. /**
  25434. * Gets the minimum vector in local space
  25435. */
  25436. this.minimum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25437. /**
  25438. * Gets the maximum vector in local space
  25439. */
  25440. this.maximum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25441. this.reConstruct(min, max, worldMatrix);
  25442. }
  25443. /**
  25444. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  25445. * @param min defines the new minimum vector (in local space)
  25446. * @param max defines the new maximum vector (in local space)
  25447. * @param worldMatrix defines the new world matrix
  25448. */
  25449. BoundingSphere.prototype.reConstruct = function (min, max, worldMatrix) {
  25450. this.minimum.copyFrom(min);
  25451. this.maximum.copyFrom(max);
  25452. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Distance(min, max);
  25453. max.addToRef(min, this.center).scaleInPlace(0.5);
  25454. this.radius = distance * 0.5;
  25455. this._update(worldMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly);
  25456. };
  25457. /**
  25458. * Scale the current bounding sphere by applying a scale factor
  25459. * @param factor defines the scale factor to apply
  25460. * @returns the current bounding box
  25461. */
  25462. BoundingSphere.prototype.scale = function (factor) {
  25463. var newRadius = this.radius * factor;
  25464. var tmpVectors = BoundingSphere.TmpVector3;
  25465. var tempRadiusVector = tmpVectors[0].setAll(newRadius);
  25466. var min = this.center.subtractToRef(tempRadiusVector, tmpVectors[1]);
  25467. var max = this.center.addToRef(tempRadiusVector, tmpVectors[2]);
  25468. this.reConstruct(min, max, this._worldMatrix);
  25469. return this;
  25470. };
  25471. /**
  25472. * Gets the world matrix of the bounding box
  25473. * @returns a matrix
  25474. */
  25475. BoundingSphere.prototype.getWorldMatrix = function () {
  25476. return this._worldMatrix;
  25477. };
  25478. // Methods
  25479. /** @hidden */
  25480. BoundingSphere.prototype._update = function (worldMatrix) {
  25481. if (!worldMatrix.isIdentity()) {
  25482. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(this.center, worldMatrix, this.centerWorld);
  25483. var tempVector = BoundingSphere.TmpVector3[0];
  25484. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(1.0, 1.0, 1.0, worldMatrix, tempVector);
  25485. this.radiusWorld = Math.max(Math.abs(tempVector.x), Math.abs(tempVector.y), Math.abs(tempVector.z)) * this.radius;
  25486. }
  25487. else {
  25488. this.centerWorld.copyFrom(this.center);
  25489. this.radiusWorld = this.radius;
  25490. }
  25491. };
  25492. /**
  25493. * Tests if the bounding sphere is intersecting the frustum planes
  25494. * @param frustumPlanes defines the frustum planes to test
  25495. * @returns true if there is an intersection
  25496. */
  25497. BoundingSphere.prototype.isInFrustum = function (frustumPlanes) {
  25498. var center = this.centerWorld;
  25499. var radius = this.radiusWorld;
  25500. for (var i = 0; i < 6; i++) {
  25501. if (frustumPlanes[i].dotCoordinate(center) <= -radius) {
  25502. return false;
  25503. }
  25504. }
  25505. return true;
  25506. };
  25507. /**
  25508. * Tests if the bounding sphere center is in between the frustum planes.
  25509. * Used for optimistic fast inclusion.
  25510. * @param frustumPlanes defines the frustum planes to test
  25511. * @returns true if the sphere center is in between the frustum planes
  25512. */
  25513. BoundingSphere.prototype.isCenterInFrustum = function (frustumPlanes) {
  25514. var center = this.centerWorld;
  25515. for (var i = 0; i < 6; i++) {
  25516. if (frustumPlanes[i].dotCoordinate(center) < 0) {
  25517. return false;
  25518. }
  25519. }
  25520. return true;
  25521. };
  25522. /**
  25523. * Tests if a point is inside the bounding sphere
  25524. * @param point defines the point to test
  25525. * @returns true if the point is inside the bounding sphere
  25526. */
  25527. BoundingSphere.prototype.intersectsPoint = function (point) {
  25528. var squareDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(this.centerWorld, point);
  25529. if (this.radiusWorld * this.radiusWorld < squareDistance) {
  25530. return false;
  25531. }
  25532. return true;
  25533. };
  25534. // Statics
  25535. /**
  25536. * Checks if two sphere intersct
  25537. * @param sphere0 sphere 0
  25538. * @param sphere1 sphere 1
  25539. * @returns true if the speres intersect
  25540. */
  25541. BoundingSphere.Intersects = function (sphere0, sphere1) {
  25542. var squareDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(sphere0.centerWorld, sphere1.centerWorld);
  25543. var radiusSum = sphere0.radiusWorld + sphere1.radiusWorld;
  25544. if (radiusSum * radiusSum < squareDistance) {
  25545. return false;
  25546. }
  25547. return true;
  25548. };
  25549. BoundingSphere.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25550. return BoundingSphere;
  25551. }());
  25552. /***/ }),
  25553. /***/ "./Culling/index.ts":
  25554. /*!**************************!*\
  25555. !*** ./Culling/index.ts ***!
  25556. \**************************/
  25557. /*! exports provided: BoundingBox, BoundingInfo, BoundingSphere, Ray, Octree, OctreeBlock, OctreeSceneComponent */
  25558. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25559. "use strict";
  25560. __webpack_require__.r(__webpack_exports__);
  25561. /* harmony import */ var _boundingBox__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boundingBox */ "./Culling/boundingBox.ts");
  25562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _boundingBox__WEBPACK_IMPORTED_MODULE_0__["BoundingBox"]; });
  25563. /* harmony import */ var _boundingInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boundingInfo */ "./Culling/boundingInfo.ts");
  25564. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _boundingInfo__WEBPACK_IMPORTED_MODULE_1__["BoundingInfo"]; });
  25565. /* harmony import */ var _boundingSphere__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boundingSphere */ "./Culling/boundingSphere.ts");
  25566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _boundingSphere__WEBPACK_IMPORTED_MODULE_2__["BoundingSphere"]; });
  25567. /* harmony import */ var _Octrees_index__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Octrees/index */ "./Culling/Octrees/index.ts");
  25568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["Octree"]; });
  25569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["OctreeBlock"]; });
  25570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["OctreeSceneComponent"]; });
  25571. /* harmony import */ var _ray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ray */ "./Culling/ray.ts");
  25572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _ray__WEBPACK_IMPORTED_MODULE_4__["Ray"]; });
  25573. /***/ }),
  25574. /***/ "./Culling/ray.ts":
  25575. /*!************************!*\
  25576. !*** ./Culling/ray.ts ***!
  25577. \************************/
  25578. /*! exports provided: Ray */
  25579. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25580. "use strict";
  25581. __webpack_require__.r(__webpack_exports__);
  25582. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return Ray; });
  25583. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  25584. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25585. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  25586. /* harmony import */ var _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/intersectionInfo */ "./Collisions/intersectionInfo.ts");
  25587. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  25588. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  25589. /**
  25590. * Class representing a ray with position and direction
  25591. */
  25592. var Ray = /** @class */ (function () {
  25593. /**
  25594. * Creates a new ray
  25595. * @param origin origin point
  25596. * @param direction direction
  25597. * @param length length of the ray
  25598. */
  25599. function Ray(
  25600. /** origin point */
  25601. origin,
  25602. /** direction */
  25603. direction,
  25604. /** length of the ray */
  25605. length) {
  25606. if (length === void 0) { length = Number.MAX_VALUE; }
  25607. this.origin = origin;
  25608. this.direction = direction;
  25609. this.length = length;
  25610. }
  25611. // Methods
  25612. /**
  25613. * Checks if the ray intersects a box
  25614. * @param minimum bound of the box
  25615. * @param maximum bound of the box
  25616. * @param intersectionTreshold extra extend to be added to the box in all direction
  25617. * @returns if the box was hit
  25618. */
  25619. Ray.prototype.intersectsBoxMinMax = function (minimum, maximum, intersectionTreshold) {
  25620. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  25621. var newMinimum = Ray.TmpVector3[0].copyFromFloats(minimum.x - intersectionTreshold, minimum.y - intersectionTreshold, minimum.z - intersectionTreshold);
  25622. var newMaximum = Ray.TmpVector3[1].copyFromFloats(maximum.x + intersectionTreshold, maximum.y + intersectionTreshold, maximum.z + intersectionTreshold);
  25623. var d = 0.0;
  25624. var maxValue = Number.MAX_VALUE;
  25625. var inv;
  25626. var min;
  25627. var max;
  25628. var temp;
  25629. if (Math.abs(this.direction.x) < 0.0000001) {
  25630. if (this.origin.x < newMinimum.x || this.origin.x > newMaximum.x) {
  25631. return false;
  25632. }
  25633. }
  25634. else {
  25635. inv = 1.0 / this.direction.x;
  25636. min = (newMinimum.x - this.origin.x) * inv;
  25637. max = (newMaximum.x - this.origin.x) * inv;
  25638. if (max === -Infinity) {
  25639. max = Infinity;
  25640. }
  25641. if (min > max) {
  25642. temp = min;
  25643. min = max;
  25644. max = temp;
  25645. }
  25646. d = Math.max(min, d);
  25647. maxValue = Math.min(max, maxValue);
  25648. if (d > maxValue) {
  25649. return false;
  25650. }
  25651. }
  25652. if (Math.abs(this.direction.y) < 0.0000001) {
  25653. if (this.origin.y < newMinimum.y || this.origin.y > newMaximum.y) {
  25654. return false;
  25655. }
  25656. }
  25657. else {
  25658. inv = 1.0 / this.direction.y;
  25659. min = (newMinimum.y - this.origin.y) * inv;
  25660. max = (newMaximum.y - this.origin.y) * inv;
  25661. if (max === -Infinity) {
  25662. max = Infinity;
  25663. }
  25664. if (min > max) {
  25665. temp = min;
  25666. min = max;
  25667. max = temp;
  25668. }
  25669. d = Math.max(min, d);
  25670. maxValue = Math.min(max, maxValue);
  25671. if (d > maxValue) {
  25672. return false;
  25673. }
  25674. }
  25675. if (Math.abs(this.direction.z) < 0.0000001) {
  25676. if (this.origin.z < newMinimum.z || this.origin.z > newMaximum.z) {
  25677. return false;
  25678. }
  25679. }
  25680. else {
  25681. inv = 1.0 / this.direction.z;
  25682. min = (newMinimum.z - this.origin.z) * inv;
  25683. max = (newMaximum.z - this.origin.z) * inv;
  25684. if (max === -Infinity) {
  25685. max = Infinity;
  25686. }
  25687. if (min > max) {
  25688. temp = min;
  25689. min = max;
  25690. max = temp;
  25691. }
  25692. d = Math.max(min, d);
  25693. maxValue = Math.min(max, maxValue);
  25694. if (d > maxValue) {
  25695. return false;
  25696. }
  25697. }
  25698. return true;
  25699. };
  25700. /**
  25701. * Checks if the ray intersects a box
  25702. * @param box the bounding box to check
  25703. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  25704. * @returns if the box was hit
  25705. */
  25706. Ray.prototype.intersectsBox = function (box, intersectionTreshold) {
  25707. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  25708. return this.intersectsBoxMinMax(box.minimum, box.maximum, intersectionTreshold);
  25709. };
  25710. /**
  25711. * If the ray hits a sphere
  25712. * @param sphere the bounding sphere to check
  25713. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  25714. * @returns true if it hits the sphere
  25715. */
  25716. Ray.prototype.intersectsSphere = function (sphere, intersectionTreshold) {
  25717. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  25718. var x = sphere.center.x - this.origin.x;
  25719. var y = sphere.center.y - this.origin.y;
  25720. var z = sphere.center.z - this.origin.z;
  25721. var pyth = (x * x) + (y * y) + (z * z);
  25722. var radius = sphere.radius + intersectionTreshold;
  25723. var rr = radius * radius;
  25724. if (pyth <= rr) {
  25725. return true;
  25726. }
  25727. var dot = (x * this.direction.x) + (y * this.direction.y) + (z * this.direction.z);
  25728. if (dot < 0.0) {
  25729. return false;
  25730. }
  25731. var temp = pyth - (dot * dot);
  25732. return temp <= rr;
  25733. };
  25734. /**
  25735. * If the ray hits a triange
  25736. * @param vertex0 triangle vertex
  25737. * @param vertex1 triangle vertex
  25738. * @param vertex2 triangle vertex
  25739. * @returns intersection information if hit
  25740. */
  25741. Ray.prototype.intersectsTriangle = function (vertex0, vertex1, vertex2) {
  25742. var edge1 = Ray.TmpVector3[0];
  25743. var edge2 = Ray.TmpVector3[1];
  25744. var pvec = Ray.TmpVector3[2];
  25745. var tvec = Ray.TmpVector3[3];
  25746. var qvec = Ray.TmpVector3[4];
  25747. vertex1.subtractToRef(vertex0, edge1);
  25748. vertex2.subtractToRef(vertex0, edge2);
  25749. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(this.direction, edge2, pvec);
  25750. var det = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(edge1, pvec);
  25751. if (det === 0) {
  25752. return null;
  25753. }
  25754. var invdet = 1 / det;
  25755. this.origin.subtractToRef(vertex0, tvec);
  25756. var bu = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(tvec, pvec) * invdet;
  25757. if (bu < 0 || bu > 1.0) {
  25758. return null;
  25759. }
  25760. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(tvec, edge1, qvec);
  25761. var bv = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(this.direction, qvec) * invdet;
  25762. if (bv < 0 || bu + bv > 1.0) {
  25763. return null;
  25764. }
  25765. //check if the distance is longer than the predefined length.
  25766. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(edge2, qvec) * invdet;
  25767. if (distance > this.length) {
  25768. return null;
  25769. }
  25770. return new _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"](bu, bv, distance);
  25771. };
  25772. /**
  25773. * Checks if ray intersects a plane
  25774. * @param plane the plane to check
  25775. * @returns the distance away it was hit
  25776. */
  25777. Ray.prototype.intersectsPlane = function (plane) {
  25778. var distance;
  25779. var result1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(plane.normal, this.direction);
  25780. if (Math.abs(result1) < 9.99999997475243E-07) {
  25781. return null;
  25782. }
  25783. else {
  25784. var result2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(plane.normal, this.origin);
  25785. distance = (-plane.d - result2) / result1;
  25786. if (distance < 0.0) {
  25787. if (distance < -9.99999997475243E-07) {
  25788. return null;
  25789. }
  25790. else {
  25791. return 0;
  25792. }
  25793. }
  25794. return distance;
  25795. }
  25796. };
  25797. /**
  25798. * Checks if ray intersects a mesh
  25799. * @param mesh the mesh to check
  25800. * @param fastCheck if only the bounding box should checked
  25801. * @returns picking info of the intersecton
  25802. */
  25803. Ray.prototype.intersectsMesh = function (mesh, fastCheck) {
  25804. var tm = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0];
  25805. mesh.getWorldMatrix().invertToRef(tm);
  25806. if (this._tmpRay) {
  25807. Ray.TransformToRef(this, tm, this._tmpRay);
  25808. }
  25809. else {
  25810. this._tmpRay = Ray.Transform(this, tm);
  25811. }
  25812. return mesh.intersects(this._tmpRay, fastCheck);
  25813. };
  25814. /**
  25815. * Checks if ray intersects a mesh
  25816. * @param meshes the meshes to check
  25817. * @param fastCheck if only the bounding box should checked
  25818. * @param results array to store result in
  25819. * @returns Array of picking infos
  25820. */
  25821. Ray.prototype.intersectsMeshes = function (meshes, fastCheck, results) {
  25822. if (results) {
  25823. results.length = 0;
  25824. }
  25825. else {
  25826. results = [];
  25827. }
  25828. for (var i = 0; i < meshes.length; i++) {
  25829. var pickInfo = this.intersectsMesh(meshes[i], fastCheck);
  25830. if (pickInfo.hit) {
  25831. results.push(pickInfo);
  25832. }
  25833. }
  25834. results.sort(this._comparePickingInfo);
  25835. return results;
  25836. };
  25837. Ray.prototype._comparePickingInfo = function (pickingInfoA, pickingInfoB) {
  25838. if (pickingInfoA.distance < pickingInfoB.distance) {
  25839. return -1;
  25840. }
  25841. else if (pickingInfoA.distance > pickingInfoB.distance) {
  25842. return 1;
  25843. }
  25844. else {
  25845. return 0;
  25846. }
  25847. };
  25848. /**
  25849. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  25850. * @param sega the first point of the segment to test the intersection against
  25851. * @param segb the second point of the segment to test the intersection against
  25852. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  25853. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  25854. */
  25855. Ray.prototype.intersectionSegment = function (sega, segb, threshold) {
  25856. var o = this.origin;
  25857. var u = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  25858. var rsegb = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  25859. var v = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  25860. var w = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  25861. segb.subtractToRef(sega, u);
  25862. this.direction.scaleToRef(Ray.rayl, v);
  25863. o.addToRef(v, rsegb);
  25864. sega.subtractToRef(o, w);
  25865. var a = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, u); // always >= 0
  25866. var b = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, v);
  25867. var c = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(v, v); // always >= 0
  25868. var d = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, w);
  25869. var e = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(v, w);
  25870. var D = a * c - b * b; // always >= 0
  25871. var sc, sN, sD = D; // sc = sN / sD, default sD = D >= 0
  25872. var tc, tN, tD = D; // tc = tN / tD, default tD = D >= 0
  25873. // compute the line parameters of the two closest points
  25874. if (D < Ray.smallnum) { // the lines are almost parallel
  25875. sN = 0.0; // force using point P0 on segment S1
  25876. sD = 1.0; // to prevent possible division by 0.0 later
  25877. tN = e;
  25878. tD = c;
  25879. }
  25880. else { // get the closest points on the infinite lines
  25881. sN = (b * e - c * d);
  25882. tN = (a * e - b * d);
  25883. if (sN < 0.0) { // sc < 0 => the s=0 edge is visible
  25884. sN = 0.0;
  25885. tN = e;
  25886. tD = c;
  25887. }
  25888. else if (sN > sD) { // sc > 1 => the s=1 edge is visible
  25889. sN = sD;
  25890. tN = e + b;
  25891. tD = c;
  25892. }
  25893. }
  25894. if (tN < 0.0) { // tc < 0 => the t=0 edge is visible
  25895. tN = 0.0;
  25896. // recompute sc for this edge
  25897. if (-d < 0.0) {
  25898. sN = 0.0;
  25899. }
  25900. else if (-d > a) {
  25901. sN = sD;
  25902. }
  25903. else {
  25904. sN = -d;
  25905. sD = a;
  25906. }
  25907. }
  25908. else if (tN > tD) { // tc > 1 => the t=1 edge is visible
  25909. tN = tD;
  25910. // recompute sc for this edge
  25911. if ((-d + b) < 0.0) {
  25912. sN = 0;
  25913. }
  25914. else if ((-d + b) > a) {
  25915. sN = sD;
  25916. }
  25917. else {
  25918. sN = (-d + b);
  25919. sD = a;
  25920. }
  25921. }
  25922. // finally do the division to get sc and tc
  25923. sc = (Math.abs(sN) < Ray.smallnum ? 0.0 : sN / sD);
  25924. tc = (Math.abs(tN) < Ray.smallnum ? 0.0 : tN / tD);
  25925. // get the difference of the two closest points
  25926. var qtc = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[4];
  25927. v.scaleToRef(tc, qtc);
  25928. var qsc = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[5];
  25929. u.scaleToRef(sc, qsc);
  25930. qsc.addInPlace(w);
  25931. var dP = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[6];
  25932. qsc.subtractToRef(qtc, dP); // = S1(sc) - S2(tc)
  25933. var isIntersected = (tc > 0) && (tc <= this.length) && (dP.lengthSquared() < (threshold * threshold)); // return intersection result
  25934. if (isIntersected) {
  25935. return qsc.length();
  25936. }
  25937. return -1;
  25938. };
  25939. /**
  25940. * Update the ray from viewport position
  25941. * @param x position
  25942. * @param y y position
  25943. * @param viewportWidth viewport width
  25944. * @param viewportHeight viewport height
  25945. * @param world world matrix
  25946. * @param view view matrix
  25947. * @param projection projection matrix
  25948. * @returns this ray updated
  25949. */
  25950. Ray.prototype.update = function (x, y, viewportWidth, viewportHeight, world, view, projection) {
  25951. this.unprojectRayToRef(x, y, viewportWidth, viewportHeight, world, view, projection);
  25952. return this;
  25953. };
  25954. // Statics
  25955. /**
  25956. * Creates a ray with origin and direction of 0,0,0
  25957. * @returns the new ray
  25958. */
  25959. Ray.Zero = function () {
  25960. return new Ray(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero());
  25961. };
  25962. /**
  25963. * Creates a new ray from screen space and viewport
  25964. * @param x position
  25965. * @param y y position
  25966. * @param viewportWidth viewport width
  25967. * @param viewportHeight viewport height
  25968. * @param world world matrix
  25969. * @param view view matrix
  25970. * @param projection projection matrix
  25971. * @returns new ray
  25972. */
  25973. Ray.CreateNew = function (x, y, viewportWidth, viewportHeight, world, view, projection) {
  25974. var result = Ray.Zero();
  25975. return result.update(x, y, viewportWidth, viewportHeight, world, view, projection);
  25976. };
  25977. /**
  25978. * 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
  25979. * transformed to the given world matrix.
  25980. * @param origin The origin point
  25981. * @param end The end point
  25982. * @param world a matrix to transform the ray to. Default is the identity matrix.
  25983. * @returns the new ray
  25984. */
  25985. Ray.CreateNewFromTo = function (origin, end, world) {
  25986. if (world === void 0) { world = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly; }
  25987. var direction = end.subtract(origin);
  25988. var length = Math.sqrt((direction.x * direction.x) + (direction.y * direction.y) + (direction.z * direction.z));
  25989. direction.normalize();
  25990. return Ray.Transform(new Ray(origin, direction, length), world);
  25991. };
  25992. /**
  25993. * Transforms a ray by a matrix
  25994. * @param ray ray to transform
  25995. * @param matrix matrix to apply
  25996. * @returns the resulting new ray
  25997. */
  25998. Ray.Transform = function (ray, matrix) {
  25999. 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));
  26000. Ray.TransformToRef(ray, matrix, result);
  26001. return result;
  26002. };
  26003. /**
  26004. * Transforms a ray by a matrix
  26005. * @param ray ray to transform
  26006. * @param matrix matrix to apply
  26007. * @param result ray to store result in
  26008. */
  26009. Ray.TransformToRef = function (ray, matrix, result) {
  26010. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(ray.origin, matrix, result.origin);
  26011. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(ray.direction, matrix, result.direction);
  26012. result.length = ray.length;
  26013. var dir = result.direction;
  26014. var len = dir.length();
  26015. if (!(len === 0 || len === 1)) {
  26016. var num = 1.0 / len;
  26017. dir.x *= num;
  26018. dir.y *= num;
  26019. dir.z *= num;
  26020. result.length *= len;
  26021. }
  26022. };
  26023. /**
  26024. * Unproject a ray from screen space to object space
  26025. * @param sourceX defines the screen space x coordinate to use
  26026. * @param sourceY defines the screen space y coordinate to use
  26027. * @param viewportWidth defines the current width of the viewport
  26028. * @param viewportHeight defines the current height of the viewport
  26029. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  26030. * @param view defines the view matrix to use
  26031. * @param projection defines the projection matrix to use
  26032. */
  26033. Ray.prototype.unprojectRayToRef = function (sourceX, sourceY, viewportWidth, viewportHeight, world, view, projection) {
  26034. var matrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0];
  26035. world.multiplyToRef(view, matrix);
  26036. matrix.multiplyToRef(projection, matrix);
  26037. matrix.invert();
  26038. var nearScreenSource = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  26039. nearScreenSource.x = sourceX / viewportWidth * 2 - 1;
  26040. nearScreenSource.y = -(sourceY / viewportHeight * 2 - 1);
  26041. nearScreenSource.z = -1.0;
  26042. var farScreenSource = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1].copyFromFloats(nearScreenSource.x, nearScreenSource.y, 1.0);
  26043. var nearVec3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  26044. var farVec3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  26045. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]._UnprojectFromInvertedMatrixToRef(nearScreenSource, matrix, nearVec3);
  26046. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]._UnprojectFromInvertedMatrixToRef(farScreenSource, matrix, farVec3);
  26047. this.origin.copyFrom(nearVec3);
  26048. farVec3.subtractToRef(nearVec3, this.direction);
  26049. this.direction.normalize();
  26050. };
  26051. Ray.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(6, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  26052. Ray.smallnum = 0.00000001;
  26053. Ray.rayl = 10e8;
  26054. return Ray;
  26055. }());
  26056. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRay = function (x, y, world, camera, cameraViewSpace) {
  26057. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  26058. var result = Ray.Zero();
  26059. this.createPickingRayToRef(x, y, world, result, camera, cameraViewSpace);
  26060. return result;
  26061. };
  26062. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayToRef = function (x, y, world, result, camera, cameraViewSpace) {
  26063. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  26064. var engine = this.getEngine();
  26065. if (!camera) {
  26066. if (!this.activeCamera) {
  26067. throw new Error("Active camera not set");
  26068. }
  26069. camera = this.activeCamera;
  26070. }
  26071. var cameraViewport = camera.viewport;
  26072. var viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  26073. // Moving coordinates to local viewport world
  26074. x = x / engine.getHardwareScalingLevel() - viewport.x;
  26075. y = y / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - viewport.y - viewport.height);
  26076. 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());
  26077. return this;
  26078. };
  26079. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayInCameraSpace = function (x, y, camera) {
  26080. var result = Ray.Zero();
  26081. this.createPickingRayInCameraSpaceToRef(x, y, result, camera);
  26082. return result;
  26083. };
  26084. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayInCameraSpaceToRef = function (x, y, result, camera) {
  26085. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  26086. return this;
  26087. }
  26088. var engine = this.getEngine();
  26089. if (!camera) {
  26090. if (!this.activeCamera) {
  26091. throw new Error("Active camera not set");
  26092. }
  26093. camera = this.activeCamera;
  26094. }
  26095. var cameraViewport = camera.viewport;
  26096. var viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  26097. var identity = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  26098. // Moving coordinates to local viewport world
  26099. x = x / engine.getHardwareScalingLevel() - viewport.x;
  26100. y = y / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - viewport.y - viewport.height);
  26101. result.update(x, y, viewport.width, viewport.height, identity, identity, camera.getProjectionMatrix());
  26102. return this;
  26103. };
  26104. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._internalPick = function (rayFunction, predicate, fastCheck, trianglePredicate) {
  26105. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  26106. return null;
  26107. }
  26108. var pickingInfo = null;
  26109. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  26110. var mesh = this.meshes[meshIndex];
  26111. if (predicate) {
  26112. if (!predicate(mesh)) {
  26113. continue;
  26114. }
  26115. }
  26116. else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
  26117. continue;
  26118. }
  26119. var world = mesh.getWorldMatrix();
  26120. var ray = rayFunction(world);
  26121. var result = mesh.intersects(ray, fastCheck, trianglePredicate);
  26122. if (!result || !result.hit) {
  26123. continue;
  26124. }
  26125. if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) {
  26126. continue;
  26127. }
  26128. pickingInfo = result;
  26129. if (fastCheck) {
  26130. break;
  26131. }
  26132. }
  26133. return pickingInfo || new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]();
  26134. };
  26135. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._internalMultiPick = function (rayFunction, predicate, trianglePredicate) {
  26136. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  26137. return null;
  26138. }
  26139. var pickingInfos = new Array();
  26140. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  26141. var mesh = this.meshes[meshIndex];
  26142. if (predicate) {
  26143. if (!predicate(mesh)) {
  26144. continue;
  26145. }
  26146. }
  26147. else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
  26148. continue;
  26149. }
  26150. var world = mesh.getWorldMatrix();
  26151. var ray = rayFunction(world);
  26152. var result = mesh.intersects(ray, false, trianglePredicate);
  26153. if (!result || !result.hit) {
  26154. continue;
  26155. }
  26156. pickingInfos.push(result);
  26157. }
  26158. return pickingInfos;
  26159. };
  26160. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.pick = function (x, y, predicate, fastCheck, camera, trianglePredicate) {
  26161. var _this = this;
  26162. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  26163. return null;
  26164. }
  26165. var result = this._internalPick(function (world) {
  26166. if (!_this._tempPickingRay) {
  26167. _this._tempPickingRay = Ray.Zero();
  26168. }
  26169. _this.createPickingRayToRef(x, y, world, _this._tempPickingRay, camera || null);
  26170. return _this._tempPickingRay;
  26171. }, predicate, fastCheck, trianglePredicate);
  26172. if (result) {
  26173. result.ray = this.createPickingRay(x, y, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), camera || null);
  26174. }
  26175. return result;
  26176. };
  26177. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.pickWithRay = function (ray, predicate, fastCheck, trianglePredicate) {
  26178. var _this = this;
  26179. var result = this._internalPick(function (world) {
  26180. if (!_this._pickWithRayInverseMatrix) {
  26181. _this._pickWithRayInverseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  26182. }
  26183. world.invertToRef(_this._pickWithRayInverseMatrix);
  26184. if (!_this._cachedRayForTransform) {
  26185. _this._cachedRayForTransform = Ray.Zero();
  26186. }
  26187. Ray.TransformToRef(ray, _this._pickWithRayInverseMatrix, _this._cachedRayForTransform);
  26188. return _this._cachedRayForTransform;
  26189. }, predicate, fastCheck, trianglePredicate);
  26190. if (result) {
  26191. result.ray = ray;
  26192. }
  26193. return result;
  26194. };
  26195. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.multiPick = function (x, y, predicate, camera, trianglePredicate) {
  26196. var _this = this;
  26197. return this._internalMultiPick(function (world) { return _this.createPickingRay(x, y, world, camera || null); }, predicate, trianglePredicate);
  26198. };
  26199. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.multiPickWithRay = function (ray, predicate, trianglePredicate) {
  26200. var _this = this;
  26201. return this._internalMultiPick(function (world) {
  26202. if (!_this._pickWithRayInverseMatrix) {
  26203. _this._pickWithRayInverseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  26204. }
  26205. world.invertToRef(_this._pickWithRayInverseMatrix);
  26206. if (!_this._cachedRayForTransform) {
  26207. _this._cachedRayForTransform = Ray.Zero();
  26208. }
  26209. Ray.TransformToRef(ray, _this._pickWithRayInverseMatrix, _this._cachedRayForTransform);
  26210. return _this._cachedRayForTransform;
  26211. }, predicate, trianglePredicate);
  26212. };
  26213. _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].prototype.getForwardRay = function (length, transform, origin) {
  26214. if (length === void 0) { length = 100; }
  26215. if (!transform) {
  26216. transform = this.getWorldMatrix();
  26217. }
  26218. if (!origin) {
  26219. origin = this.position;
  26220. }
  26221. 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);
  26222. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(forward, transform);
  26223. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Normalize(forwardWorld);
  26224. return new Ray(origin, direction, length);
  26225. };
  26226. /***/ }),
  26227. /***/ "./Debug/axesViewer.ts":
  26228. /*!*****************************!*\
  26229. !*** ./Debug/axesViewer.ts ***!
  26230. \*****************************/
  26231. /*! exports provided: AxesViewer */
  26232. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26233. "use strict";
  26234. __webpack_require__.r(__webpack_exports__);
  26235. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return AxesViewer; });
  26236. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26237. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  26238. /* harmony import */ var _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Gizmos/axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  26239. /**
  26240. * The Axes viewer will show 3 axes in a specific point in space
  26241. */
  26242. var AxesViewer = /** @class */ (function () {
  26243. /**
  26244. * Creates a new AxesViewer
  26245. * @param scene defines the hosting scene
  26246. * @param scaleLines defines a number used to scale line length (1 by default)
  26247. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  26248. * @param xAxis defines the node hierarchy used to render the x-axis
  26249. * @param yAxis defines the node hierarchy used to render the y-axis
  26250. * @param zAxis defines the node hierarchy used to render the z-axis
  26251. */
  26252. function AxesViewer(scene, scaleLines, renderingGroupId, xAxis, yAxis, zAxis) {
  26253. if (scaleLines === void 0) { scaleLines = 1; }
  26254. if (renderingGroupId === void 0) { renderingGroupId = 2; }
  26255. this._scaleLinesFactor = 4;
  26256. this._instanced = false;
  26257. /**
  26258. * Gets or sets a number used to scale line length
  26259. */
  26260. this.scaleLines = 1;
  26261. this.scaleLines = scaleLines;
  26262. if (!xAxis) {
  26263. var redColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  26264. redColoredMaterial.disableLighting = true;
  26265. redColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Red().scale(0.5);
  26266. xAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, redColoredMaterial);
  26267. }
  26268. if (!yAxis) {
  26269. var greenColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  26270. greenColoredMaterial.disableLighting = true;
  26271. greenColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Green().scale(0.5);
  26272. yAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, greenColoredMaterial);
  26273. }
  26274. if (!zAxis) {
  26275. var blueColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  26276. blueColoredMaterial.disableLighting = true;
  26277. blueColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Blue().scale(0.5);
  26278. zAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, blueColoredMaterial);
  26279. }
  26280. this._xAxis = xAxis;
  26281. this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26282. this._yAxis = yAxis;
  26283. this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26284. this._zAxis = zAxis;
  26285. this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26286. if (renderingGroupId != null) {
  26287. AxesViewer._SetRenderingGroupId(this._xAxis, renderingGroupId);
  26288. AxesViewer._SetRenderingGroupId(this._yAxis, renderingGroupId);
  26289. AxesViewer._SetRenderingGroupId(this._zAxis, renderingGroupId);
  26290. }
  26291. this.scene = scene;
  26292. 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());
  26293. }
  26294. Object.defineProperty(AxesViewer.prototype, "xAxis", {
  26295. /** Gets the node hierarchy used to render x-axis */
  26296. get: function () {
  26297. return this._xAxis;
  26298. },
  26299. enumerable: true,
  26300. configurable: true
  26301. });
  26302. Object.defineProperty(AxesViewer.prototype, "yAxis", {
  26303. /** Gets the node hierarchy used to render y-axis */
  26304. get: function () {
  26305. return this._yAxis;
  26306. },
  26307. enumerable: true,
  26308. configurable: true
  26309. });
  26310. Object.defineProperty(AxesViewer.prototype, "zAxis", {
  26311. /** Gets the node hierarchy used to render z-axis */
  26312. get: function () {
  26313. return this._zAxis;
  26314. },
  26315. enumerable: true,
  26316. configurable: true
  26317. });
  26318. /**
  26319. * Force the viewer to update
  26320. * @param position defines the position of the viewer
  26321. * @param xaxis defines the x axis of the viewer
  26322. * @param yaxis defines the y axis of the viewer
  26323. * @param zaxis defines the z axis of the viewer
  26324. */
  26325. AxesViewer.prototype.update = function (position, xaxis, yaxis, zaxis) {
  26326. this._xAxis.position.copyFrom(position);
  26327. this._xAxis.setDirection(xaxis);
  26328. this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26329. this._yAxis.position.copyFrom(position);
  26330. this._yAxis.setDirection(yaxis);
  26331. this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26332. this._zAxis.position.copyFrom(position);
  26333. this._zAxis.setDirection(zaxis);
  26334. this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26335. };
  26336. /**
  26337. * Creates an instance of this axes viewer.
  26338. * @returns a new axes viewer with instanced meshes
  26339. */
  26340. AxesViewer.prototype.createInstance = function () {
  26341. var xAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._xAxis);
  26342. var yAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._yAxis);
  26343. var zAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._zAxis);
  26344. var axesViewer = new AxesViewer(this.scene, this.scaleLines, null, xAxis, yAxis, zAxis);
  26345. axesViewer._instanced = true;
  26346. return axesViewer;
  26347. };
  26348. /** Releases resources */
  26349. AxesViewer.prototype.dispose = function () {
  26350. if (this._xAxis) {
  26351. this._xAxis.dispose(false, !this._instanced);
  26352. delete this._xAxis;
  26353. }
  26354. if (this._yAxis) {
  26355. this._yAxis.dispose(false, !this._instanced);
  26356. delete this._yAxis;
  26357. }
  26358. if (this._zAxis) {
  26359. this._zAxis.dispose(false, !this._instanced);
  26360. delete this._zAxis;
  26361. }
  26362. delete this.scene;
  26363. };
  26364. AxesViewer._SetRenderingGroupId = function (node, id) {
  26365. node.getChildMeshes().forEach(function (mesh) {
  26366. mesh.renderingGroupId = id;
  26367. });
  26368. };
  26369. return AxesViewer;
  26370. }());
  26371. /***/ }),
  26372. /***/ "./Debug/boneAxesViewer.ts":
  26373. /*!*********************************!*\
  26374. !*** ./Debug/boneAxesViewer.ts ***!
  26375. \*********************************/
  26376. /*! exports provided: BoneAxesViewer */
  26377. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26378. "use strict";
  26379. __webpack_require__.r(__webpack_exports__);
  26380. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return BoneAxesViewer; });
  26381. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  26382. /* harmony import */ var _Debug_axesViewer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Debug/axesViewer */ "./Debug/axesViewer.ts");
  26383. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26384. /**
  26385. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  26386. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  26387. */
  26388. var BoneAxesViewer = /** @class */ (function (_super) {
  26389. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BoneAxesViewer, _super);
  26390. /**
  26391. * Creates a new BoneAxesViewer
  26392. * @param scene defines the hosting scene
  26393. * @param bone defines the target bone
  26394. * @param mesh defines the target mesh
  26395. * @param scaleLines defines a scaling factor for line length (1 by default)
  26396. */
  26397. function BoneAxesViewer(scene, bone, mesh, scaleLines) {
  26398. if (scaleLines === void 0) { scaleLines = 1; }
  26399. var _this = _super.call(this, scene, scaleLines) || this;
  26400. /** Gets current position */
  26401. _this.pos = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  26402. /** Gets direction of X axis */
  26403. _this.xaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  26404. /** Gets direction of Y axis */
  26405. _this.yaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  26406. /** Gets direction of Z axis */
  26407. _this.zaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  26408. _this.mesh = mesh;
  26409. _this.bone = bone;
  26410. return _this;
  26411. }
  26412. /**
  26413. * Force the viewer to update
  26414. */
  26415. BoneAxesViewer.prototype.update = function () {
  26416. if (!this.mesh || !this.bone) {
  26417. return;
  26418. }
  26419. var bone = this.bone;
  26420. bone.getAbsolutePositionToRef(this.mesh, this.pos);
  26421. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].X, this.mesh, this.xaxis);
  26422. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y, this.mesh, this.yaxis);
  26423. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Z, this.mesh, this.zaxis);
  26424. _super.prototype.update.call(this, this.pos, this.xaxis, this.yaxis, this.zaxis);
  26425. };
  26426. /** Releases resources */
  26427. BoneAxesViewer.prototype.dispose = function () {
  26428. if (this.mesh) {
  26429. this.mesh = null;
  26430. this.bone = null;
  26431. _super.prototype.dispose.call(this);
  26432. }
  26433. };
  26434. return BoneAxesViewer;
  26435. }(_Debug_axesViewer__WEBPACK_IMPORTED_MODULE_1__["AxesViewer"]));
  26436. /***/ }),
  26437. /***/ "./Debug/debugLayer.ts":
  26438. /*!*****************************!*\
  26439. !*** ./Debug/debugLayer.ts ***!
  26440. \*****************************/
  26441. /*! exports provided: DebugLayer */
  26442. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26443. "use strict";
  26444. __webpack_require__.r(__webpack_exports__);
  26445. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return DebugLayer; });
  26446. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  26447. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  26448. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  26449. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  26450. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  26451. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype, "debugLayer", {
  26452. get: function () {
  26453. if (!this._debugLayer) {
  26454. this._debugLayer = new DebugLayer(this);
  26455. }
  26456. return this._debugLayer;
  26457. },
  26458. enumerable: true,
  26459. configurable: true
  26460. });
  26461. /**
  26462. * The debug layer (aka Inspector) is the go to tool in order to better understand
  26463. * what is happening in your scene
  26464. * @see http://doc.babylonjs.com/features/playground_debuglayer
  26465. */
  26466. var DebugLayer = /** @class */ (function () {
  26467. /**
  26468. * Instantiates a new debug layer.
  26469. * The debug layer (aka Inspector) is the go to tool in order to better understand
  26470. * what is happening in your scene
  26471. * @see http://doc.babylonjs.com/features/playground_debuglayer
  26472. * @param scene Defines the scene to inspect
  26473. */
  26474. function DebugLayer(scene) {
  26475. var _this = this;
  26476. this.BJSINSPECTOR = this._getGlobalInspector();
  26477. /**
  26478. * Observable triggered when a property is changed through the inspector.
  26479. */
  26480. this.onPropertyChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  26481. this._scene = scene;
  26482. this._scene.onDisposeObservable.add(function () {
  26483. // Debug layer
  26484. if (_this._scene._debugLayer) {
  26485. _this._scene._debugLayer.hide();
  26486. }
  26487. });
  26488. }
  26489. /** Creates the inspector window. */
  26490. DebugLayer.prototype._createInspector = function (config) {
  26491. if (this.isVisible()) {
  26492. return;
  26493. }
  26494. var userOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ overlay: false, showExplorer: true, showInspector: true, embedMode: false, handleResize: true, enablePopup: true }, config);
  26495. this.BJSINSPECTOR = this.BJSINSPECTOR || this._getGlobalInspector();
  26496. this.BJSINSPECTOR.Inspector.Show(this._scene, userOptions);
  26497. };
  26498. /**
  26499. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  26500. * @param entity defines the entity to select
  26501. * @param lineContainerTitle defines the specific block to highlight
  26502. */
  26503. DebugLayer.prototype.select = function (entity, lineContainerTitle) {
  26504. if (this.BJSINSPECTOR) {
  26505. this.BJSINSPECTOR.Inspector.MarkLineContainerTitleForHighlighting(lineContainerTitle);
  26506. this.BJSINSPECTOR.Inspector.OnSelectionChangeObservable.notifyObservers(entity);
  26507. }
  26508. };
  26509. /** Get the inspector from bundle or global */
  26510. DebugLayer.prototype._getGlobalInspector = function () {
  26511. // UMD Global name detection from Webpack Bundle UMD Name.
  26512. if (typeof INSPECTOR !== 'undefined') {
  26513. return INSPECTOR;
  26514. }
  26515. // In case of module let s check the global emitted from the Inspector entry point.
  26516. if (typeof BABYLON !== 'undefined' && typeof BABYLON.Inspector !== 'undefined') {
  26517. return BABYLON;
  26518. }
  26519. return undefined;
  26520. };
  26521. /**
  26522. * Get if the inspector is visible or not.
  26523. * @returns true if visible otherwise, false
  26524. */
  26525. DebugLayer.prototype.isVisible = function () {
  26526. return this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector.IsVisible;
  26527. };
  26528. /**
  26529. * Hide the inspector and close its window.
  26530. */
  26531. DebugLayer.prototype.hide = function () {
  26532. if (this.BJSINSPECTOR) {
  26533. this.BJSINSPECTOR.Inspector.Hide();
  26534. }
  26535. };
  26536. /**
  26537. * Launch the debugLayer.
  26538. * @param config Define the configuration of the inspector
  26539. * @return a promise fulfilled when the debug layer is visible
  26540. */
  26541. DebugLayer.prototype.show = function (config) {
  26542. var _this = this;
  26543. return new Promise(function (resolve, reject) {
  26544. if (typeof _this.BJSINSPECTOR == 'undefined') {
  26545. var inspectorUrl = config && config.inspectorURL ? config.inspectorURL : DebugLayer.InspectorURL;
  26546. // Load inspector and add it to the DOM
  26547. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].LoadScript(inspectorUrl, function () {
  26548. _this._createInspector(config);
  26549. resolve(_this);
  26550. });
  26551. }
  26552. else {
  26553. // Otherwise creates the inspector
  26554. _this._createInspector(config);
  26555. resolve(_this);
  26556. }
  26557. });
  26558. };
  26559. /**
  26560. * Define the url to get the inspector script from.
  26561. * By default it uses the babylonjs CDN.
  26562. * @ignoreNaming
  26563. */
  26564. DebugLayer.InspectorURL = "https://unpkg.com/babylonjs-inspector@" + _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].Version + "/babylon.inspector.bundle.js";
  26565. return DebugLayer;
  26566. }());
  26567. /***/ }),
  26568. /***/ "./Debug/index.ts":
  26569. /*!************************!*\
  26570. !*** ./Debug/index.ts ***!
  26571. \************************/
  26572. /*! exports provided: AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer */
  26573. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26574. "use strict";
  26575. __webpack_require__.r(__webpack_exports__);
  26576. /* harmony import */ var _axesViewer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./axesViewer */ "./Debug/axesViewer.ts");
  26577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _axesViewer__WEBPACK_IMPORTED_MODULE_0__["AxesViewer"]; });
  26578. /* harmony import */ var _boneAxesViewer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boneAxesViewer */ "./Debug/boneAxesViewer.ts");
  26579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _boneAxesViewer__WEBPACK_IMPORTED_MODULE_1__["BoneAxesViewer"]; });
  26580. /* harmony import */ var _debugLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./debugLayer */ "./Debug/debugLayer.ts");
  26581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _debugLayer__WEBPACK_IMPORTED_MODULE_2__["DebugLayer"]; });
  26582. /* harmony import */ var _physicsViewer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./physicsViewer */ "./Debug/physicsViewer.ts");
  26583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _physicsViewer__WEBPACK_IMPORTED_MODULE_3__["PhysicsViewer"]; });
  26584. /* harmony import */ var _rayHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rayHelper */ "./Debug/rayHelper.ts");
  26585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _rayHelper__WEBPACK_IMPORTED_MODULE_4__["RayHelper"]; });
  26586. /* harmony import */ var _skeletonViewer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./skeletonViewer */ "./Debug/skeletonViewer.ts");
  26587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _skeletonViewer__WEBPACK_IMPORTED_MODULE_5__["SkeletonViewer"]; });
  26588. /***/ }),
  26589. /***/ "./Debug/physicsViewer.ts":
  26590. /*!********************************!*\
  26591. !*** ./Debug/physicsViewer.ts ***!
  26592. \********************************/
  26593. /*! exports provided: PhysicsViewer */
  26594. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26595. "use strict";
  26596. __webpack_require__.r(__webpack_exports__);
  26597. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return PhysicsViewer; });
  26598. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  26599. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  26600. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26601. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  26602. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  26603. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  26604. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  26605. /**
  26606. * Used to show the physics impostor around the specific mesh
  26607. */
  26608. var PhysicsViewer = /** @class */ (function () {
  26609. /**
  26610. * Creates a new PhysicsViewer
  26611. * @param scene defines the hosting scene
  26612. */
  26613. function PhysicsViewer(scene) {
  26614. /** @hidden */
  26615. this._impostors = [];
  26616. /** @hidden */
  26617. this._meshes = [];
  26618. /** @hidden */
  26619. this._numMeshes = 0;
  26620. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  26621. var physicEngine = this._scene.getPhysicsEngine();
  26622. if (physicEngine) {
  26623. this._physicsEnginePlugin = physicEngine.getPhysicsPlugin();
  26624. }
  26625. this._utilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__["UtilityLayerRenderer"](this._scene, false);
  26626. this._utilityLayer.pickUtilitySceneFirst = false;
  26627. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;
  26628. }
  26629. /** @hidden */
  26630. PhysicsViewer.prototype._updateDebugMeshes = function () {
  26631. var plugin = this._physicsEnginePlugin;
  26632. for (var i = 0; i < this._numMeshes; i++) {
  26633. var impostor = this._impostors[i];
  26634. if (!impostor) {
  26635. continue;
  26636. }
  26637. if (impostor.isDisposed) {
  26638. this.hideImpostor(this._impostors[i--]);
  26639. }
  26640. else {
  26641. var mesh = this._meshes[i];
  26642. if (mesh && plugin) {
  26643. plugin.syncMeshWithImpostor(mesh, impostor);
  26644. }
  26645. }
  26646. }
  26647. };
  26648. /**
  26649. * Renders a specified physic impostor
  26650. * @param impostor defines the impostor to render
  26651. * @returns the new debug mesh used to render the impostor
  26652. */
  26653. PhysicsViewer.prototype.showImpostor = function (impostor) {
  26654. if (!this._scene) {
  26655. return null;
  26656. }
  26657. for (var i = 0; i < this._numMeshes; i++) {
  26658. if (this._impostors[i] == impostor) {
  26659. return null;
  26660. }
  26661. }
  26662. var debugMesh = this._getDebugMesh(impostor);
  26663. if (debugMesh) {
  26664. this._impostors[this._numMeshes] = impostor;
  26665. this._meshes[this._numMeshes] = debugMesh;
  26666. if (this._numMeshes === 0) {
  26667. this._renderFunction = this._updateDebugMeshes.bind(this);
  26668. this._scene.registerBeforeRender(this._renderFunction);
  26669. }
  26670. this._numMeshes++;
  26671. }
  26672. return debugMesh;
  26673. };
  26674. /**
  26675. * Hides a specified physic impostor
  26676. * @param impostor defines the impostor to hide
  26677. */
  26678. PhysicsViewer.prototype.hideImpostor = function (impostor) {
  26679. if (!impostor || !this._scene || !this._utilityLayer) {
  26680. return;
  26681. }
  26682. var removed = false;
  26683. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  26684. for (var i = 0; i < this._numMeshes; i++) {
  26685. if (this._impostors[i] == impostor) {
  26686. var mesh = this._meshes[i];
  26687. if (!mesh) {
  26688. continue;
  26689. }
  26690. utilityLayerScene.removeMesh(mesh);
  26691. mesh.dispose();
  26692. this._numMeshes--;
  26693. if (this._numMeshes > 0) {
  26694. this._meshes[i] = this._meshes[this._numMeshes];
  26695. this._impostors[i] = this._impostors[this._numMeshes];
  26696. this._meshes[this._numMeshes] = null;
  26697. this._impostors[this._numMeshes] = null;
  26698. }
  26699. else {
  26700. this._meshes[0] = null;
  26701. this._impostors[0] = null;
  26702. }
  26703. removed = true;
  26704. break;
  26705. }
  26706. }
  26707. if (removed && this._numMeshes === 0) {
  26708. this._scene.unregisterBeforeRender(this._renderFunction);
  26709. }
  26710. };
  26711. PhysicsViewer.prototype._getDebugMaterial = function (scene) {
  26712. if (!this._debugMaterial) {
  26713. this._debugMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_4__["StandardMaterial"]('', scene);
  26714. this._debugMaterial.wireframe = true;
  26715. this._debugMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].White();
  26716. this._debugMaterial.disableLighting = true;
  26717. }
  26718. return this._debugMaterial;
  26719. };
  26720. PhysicsViewer.prototype._getDebugBoxMesh = function (scene) {
  26721. if (!this._debugBoxMesh) {
  26722. this._debugBoxMesh = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_0__["BoxBuilder"].CreateBox('physicsBodyBoxViewMesh', { size: 1 }, scene);
  26723. this._debugBoxMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  26724. this._debugBoxMesh.material = this._getDebugMaterial(scene);
  26725. }
  26726. return this._debugBoxMesh.createInstance('physicsBodyBoxViewInstance');
  26727. };
  26728. PhysicsViewer.prototype._getDebugSphereMesh = function (scene) {
  26729. if (!this._debugSphereMesh) {
  26730. this._debugSphereMesh = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__["SphereBuilder"].CreateSphere('physicsBodySphereViewMesh', { diameter: 1 }, scene);
  26731. this._debugSphereMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  26732. this._debugSphereMesh.material = this._getDebugMaterial(scene);
  26733. }
  26734. return this._debugSphereMesh.createInstance('physicsBodyBoxViewInstance');
  26735. };
  26736. PhysicsViewer.prototype._getDebugMesh = function (impostor) {
  26737. if (!this._utilityLayer) {
  26738. return null;
  26739. }
  26740. var mesh = null;
  26741. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  26742. if (impostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_5__["PhysicsImpostor"].BoxImpostor) {
  26743. mesh = this._getDebugBoxMesh(utilityLayerScene);
  26744. impostor.getBoxSizeToRef(mesh.scaling);
  26745. }
  26746. else if (impostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_5__["PhysicsImpostor"].SphereImpostor) {
  26747. mesh = this._getDebugSphereMesh(utilityLayerScene);
  26748. var radius = impostor.getRadius();
  26749. mesh.scaling.x = radius * 2;
  26750. mesh.scaling.y = radius * 2;
  26751. mesh.scaling.z = radius * 2;
  26752. }
  26753. return mesh;
  26754. };
  26755. /** Releases all resources */
  26756. PhysicsViewer.prototype.dispose = function () {
  26757. for (var i = 0; i < this._numMeshes; i++) {
  26758. this.hideImpostor(this._impostors[i]);
  26759. }
  26760. if (this._debugBoxMesh) {
  26761. this._debugBoxMesh.dispose();
  26762. }
  26763. if (this._debugSphereMesh) {
  26764. this._debugSphereMesh.dispose();
  26765. }
  26766. if (this._debugMaterial) {
  26767. this._debugMaterial.dispose();
  26768. }
  26769. this._impostors.length = 0;
  26770. this._scene = null;
  26771. this._physicsEnginePlugin = null;
  26772. if (this._utilityLayer) {
  26773. this._utilityLayer.dispose();
  26774. this._utilityLayer = null;
  26775. }
  26776. };
  26777. return PhysicsViewer;
  26778. }());
  26779. /***/ }),
  26780. /***/ "./Debug/rayHelper.ts":
  26781. /*!****************************!*\
  26782. !*** ./Debug/rayHelper.ts ***!
  26783. \****************************/
  26784. /*! exports provided: RayHelper */
  26785. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26786. "use strict";
  26787. __webpack_require__.r(__webpack_exports__);
  26788. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return RayHelper; });
  26789. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26790. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  26791. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  26792. /**
  26793. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  26794. * in order to better appreciate the issue one might have.
  26795. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  26796. */
  26797. var RayHelper = /** @class */ (function () {
  26798. /**
  26799. * Instantiate a new ray helper.
  26800. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  26801. * in order to better appreciate the issue one might have.
  26802. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  26803. * @param ray Defines the ray we are currently tryin to visualize
  26804. */
  26805. function RayHelper(ray) {
  26806. this.ray = ray;
  26807. }
  26808. /**
  26809. * Helper function to create a colored helper in a scene in one line.
  26810. * @param ray Defines the ray we are currently tryin to visualize
  26811. * @param scene Defines the scene the ray is used in
  26812. * @param color Defines the color we want to see the ray in
  26813. * @returns The newly created ray helper.
  26814. */
  26815. RayHelper.CreateAndShow = function (ray, scene, color) {
  26816. var helper = new RayHelper(ray);
  26817. helper.show(scene, color);
  26818. return helper;
  26819. };
  26820. /**
  26821. * Shows the ray we are willing to debug.
  26822. * @param scene Defines the scene the ray needs to be rendered in
  26823. * @param color Defines the color the ray needs to be rendered in
  26824. */
  26825. RayHelper.prototype.show = function (scene, color) {
  26826. if (!this._renderFunction && this.ray) {
  26827. var ray = this.ray;
  26828. this._renderFunction = this._render.bind(this);
  26829. this._scene = scene;
  26830. this._renderPoints = [ray.origin, ray.origin.add(ray.direction.scale(ray.length))];
  26831. this._renderLine = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines("ray", this._renderPoints, scene, true);
  26832. if (this._renderFunction) {
  26833. this._scene.registerBeforeRender(this._renderFunction);
  26834. }
  26835. }
  26836. if (color && this._renderLine) {
  26837. this._renderLine.color.copyFrom(color);
  26838. }
  26839. };
  26840. /**
  26841. * Hides the ray we are debugging.
  26842. */
  26843. RayHelper.prototype.hide = function () {
  26844. if (this._renderFunction && this._scene) {
  26845. this._scene.unregisterBeforeRender(this._renderFunction);
  26846. this._scene = null;
  26847. this._renderFunction = null;
  26848. if (this._renderLine) {
  26849. this._renderLine.dispose();
  26850. this._renderLine = null;
  26851. }
  26852. this._renderPoints = [];
  26853. }
  26854. };
  26855. RayHelper.prototype._render = function () {
  26856. var ray = this.ray;
  26857. if (!ray) {
  26858. return;
  26859. }
  26860. var point = this._renderPoints[1];
  26861. var len = Math.min(ray.length, 1000000);
  26862. point.copyFrom(ray.direction);
  26863. point.scaleInPlace(len);
  26864. point.addInPlace(ray.origin);
  26865. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines("ray", this._renderPoints, this._scene, true, this._renderLine);
  26866. };
  26867. /**
  26868. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  26869. * @param mesh Defines the mesh we want the helper attached to
  26870. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  26871. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  26872. * @param length Defines the length of the ray
  26873. */
  26874. RayHelper.prototype.attachToMesh = function (mesh, meshSpaceDirection, meshSpaceOrigin, length) {
  26875. this._attachedToMesh = mesh;
  26876. var ray = this.ray;
  26877. if (!ray) {
  26878. return;
  26879. }
  26880. if (!ray.direction) {
  26881. ray.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  26882. }
  26883. if (!ray.origin) {
  26884. ray.origin = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  26885. }
  26886. if (length) {
  26887. ray.length = length;
  26888. }
  26889. if (!meshSpaceOrigin) {
  26890. meshSpaceOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  26891. }
  26892. if (!meshSpaceDirection) {
  26893. // -1 so that this will work with Mesh.lookAt
  26894. meshSpaceDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1);
  26895. }
  26896. if (!this._meshSpaceDirection) {
  26897. this._meshSpaceDirection = meshSpaceDirection.clone();
  26898. this._meshSpaceOrigin = meshSpaceOrigin.clone();
  26899. }
  26900. else {
  26901. this._meshSpaceDirection.copyFrom(meshSpaceDirection);
  26902. this._meshSpaceOrigin.copyFrom(meshSpaceOrigin);
  26903. }
  26904. if (!this._updateToMeshFunction) {
  26905. this._updateToMeshFunction = this._updateToMesh.bind(this);
  26906. this._attachedToMesh.getScene().registerBeforeRender(this._updateToMeshFunction);
  26907. }
  26908. this._updateToMesh();
  26909. };
  26910. /**
  26911. * Detach the ray helper from the mesh it has previously been attached to.
  26912. */
  26913. RayHelper.prototype.detachFromMesh = function () {
  26914. if (this._attachedToMesh) {
  26915. if (this._updateToMeshFunction) {
  26916. this._attachedToMesh.getScene().unregisterBeforeRender(this._updateToMeshFunction);
  26917. }
  26918. this._attachedToMesh = null;
  26919. this._updateToMeshFunction = null;
  26920. }
  26921. };
  26922. RayHelper.prototype._updateToMesh = function () {
  26923. var ray = this.ray;
  26924. if (!this._attachedToMesh || !ray) {
  26925. return;
  26926. }
  26927. if (this._attachedToMesh._isDisposed) {
  26928. this.detachFromMesh();
  26929. return;
  26930. }
  26931. this._attachedToMesh.getDirectionToRef(this._meshSpaceDirection, ray.direction);
  26932. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this._meshSpaceOrigin, this._attachedToMesh.getWorldMatrix(), ray.origin);
  26933. };
  26934. /**
  26935. * Dispose the helper and release its associated resources.
  26936. */
  26937. RayHelper.prototype.dispose = function () {
  26938. this.hide();
  26939. this.detachFromMesh();
  26940. this.ray = null;
  26941. };
  26942. return RayHelper;
  26943. }());
  26944. /***/ }),
  26945. /***/ "./Debug/skeletonViewer.ts":
  26946. /*!*********************************!*\
  26947. !*** ./Debug/skeletonViewer.ts ***!
  26948. \*********************************/
  26949. /*! exports provided: SkeletonViewer */
  26950. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26951. "use strict";
  26952. __webpack_require__.r(__webpack_exports__);
  26953. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return SkeletonViewer; });
  26954. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26955. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  26956. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  26957. /**
  26958. * Class used to render a debug view of a given skeleton
  26959. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  26960. */
  26961. var SkeletonViewer = /** @class */ (function () {
  26962. /**
  26963. * Creates a new SkeletonViewer
  26964. * @param skeleton defines the skeleton to render
  26965. * @param mesh defines the mesh attached to the skeleton
  26966. * @param scene defines the hosting scene
  26967. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  26968. * @param renderingGroupId defines the rendering group id to use with the viewer
  26969. */
  26970. function SkeletonViewer(
  26971. /** defines the skeleton to render */
  26972. skeleton,
  26973. /** defines the mesh attached to the skeleton */
  26974. mesh, scene,
  26975. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  26976. autoUpdateBonesMatrices,
  26977. /** defines the rendering group id to use with the viewer */
  26978. renderingGroupId) {
  26979. if (autoUpdateBonesMatrices === void 0) { autoUpdateBonesMatrices = true; }
  26980. if (renderingGroupId === void 0) { renderingGroupId = 1; }
  26981. this.skeleton = skeleton;
  26982. this.mesh = mesh;
  26983. this.autoUpdateBonesMatrices = autoUpdateBonesMatrices;
  26984. this.renderingGroupId = renderingGroupId;
  26985. /** Gets or sets the color used to render the skeleton */
  26986. this.color = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].White();
  26987. this._debugLines = new Array();
  26988. this._isEnabled = false;
  26989. this._scene = scene;
  26990. this._utilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__["UtilityLayerRenderer"](this._scene, false);
  26991. this._utilityLayer.pickUtilitySceneFirst = false;
  26992. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;
  26993. this.update();
  26994. this._renderFunction = this.update.bind(this);
  26995. }
  26996. Object.defineProperty(SkeletonViewer.prototype, "debugMesh", {
  26997. /**
  26998. * Returns the mesh used to render the bones
  26999. */
  27000. get: function () {
  27001. return this._debugMesh;
  27002. },
  27003. enumerable: true,
  27004. configurable: true
  27005. });
  27006. Object.defineProperty(SkeletonViewer.prototype, "isEnabled", {
  27007. get: function () {
  27008. return this._isEnabled;
  27009. },
  27010. /** Gets or sets a boolean indicating if the viewer is enabled */
  27011. set: function (value) {
  27012. if (this._isEnabled === value) {
  27013. return;
  27014. }
  27015. this._isEnabled = value;
  27016. if (value) {
  27017. this._scene.registerBeforeRender(this._renderFunction);
  27018. }
  27019. else {
  27020. this._scene.unregisterBeforeRender(this._renderFunction);
  27021. }
  27022. },
  27023. enumerable: true,
  27024. configurable: true
  27025. });
  27026. SkeletonViewer.prototype._getBonePosition = function (position, bone, meshMat, x, y, z) {
  27027. if (x === void 0) { x = 0; }
  27028. if (y === void 0) { y = 0; }
  27029. if (z === void 0) { z = 0; }
  27030. var tmat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  27031. var parentBone = bone.getParent();
  27032. tmat.copyFrom(bone.getLocalMatrix());
  27033. if (x !== 0 || y !== 0 || z !== 0) {
  27034. var tmat2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  27035. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityToRef(tmat2);
  27036. tmat2.setTranslationFromFloats(x, y, z);
  27037. tmat2.multiplyToRef(tmat, tmat);
  27038. }
  27039. if (parentBone) {
  27040. tmat.multiplyToRef(parentBone.getAbsoluteTransform(), tmat);
  27041. }
  27042. tmat.multiplyToRef(meshMat, tmat);
  27043. position.x = tmat.m[12];
  27044. position.y = tmat.m[13];
  27045. position.z = tmat.m[14];
  27046. };
  27047. SkeletonViewer.prototype._getLinesForBonesWithLength = function (bones, meshMat) {
  27048. var len = bones.length;
  27049. var meshPos = this.mesh.position;
  27050. for (var i = 0; i < len; i++) {
  27051. var bone = bones[i];
  27052. var points = this._debugLines[i];
  27053. if (!points) {
  27054. points = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero()];
  27055. this._debugLines[i] = points;
  27056. }
  27057. this._getBonePosition(points[0], bone, meshMat);
  27058. this._getBonePosition(points[1], bone, meshMat, 0, bone.length, 0);
  27059. points[0].subtractInPlace(meshPos);
  27060. points[1].subtractInPlace(meshPos);
  27061. }
  27062. };
  27063. SkeletonViewer.prototype._getLinesForBonesNoLength = function (bones, meshMat) {
  27064. var len = bones.length;
  27065. var boneNum = 0;
  27066. var meshPos = this.mesh.position;
  27067. for (var i = len - 1; i >= 0; i--) {
  27068. var childBone = bones[i];
  27069. var parentBone = childBone.getParent();
  27070. if (!parentBone) {
  27071. continue;
  27072. }
  27073. var points = this._debugLines[boneNum];
  27074. if (!points) {
  27075. points = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero()];
  27076. this._debugLines[boneNum] = points;
  27077. }
  27078. childBone.getAbsolutePositionToRef(this.mesh, points[0]);
  27079. parentBone.getAbsolutePositionToRef(this.mesh, points[1]);
  27080. points[0].subtractInPlace(meshPos);
  27081. points[1].subtractInPlace(meshPos);
  27082. boneNum++;
  27083. }
  27084. };
  27085. /** Update the viewer to sync with current skeleton state */
  27086. SkeletonViewer.prototype.update = function () {
  27087. if (!this._utilityLayer) {
  27088. return;
  27089. }
  27090. if (this.autoUpdateBonesMatrices) {
  27091. this.skeleton.computeAbsoluteTransforms();
  27092. }
  27093. if (this.skeleton.bones[0].length === undefined) {
  27094. this._getLinesForBonesNoLength(this.skeleton.bones, this.mesh.getWorldMatrix());
  27095. }
  27096. else {
  27097. this._getLinesForBonesWithLength(this.skeleton.bones, this.mesh.getWorldMatrix());
  27098. }
  27099. var targetScene = this._utilityLayer.utilityLayerScene;
  27100. if (!this._debugMesh) {
  27101. this._debugMesh = _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_1__["LinesBuilder"].CreateLineSystem("", { lines: this._debugLines, updatable: true, instance: null }, targetScene);
  27102. this._debugMesh.renderingGroupId = this.renderingGroupId;
  27103. }
  27104. else {
  27105. _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_1__["LinesBuilder"].CreateLineSystem("", { lines: this._debugLines, updatable: true, instance: this._debugMesh }, targetScene);
  27106. }
  27107. this._debugMesh.position.copyFrom(this.mesh.position);
  27108. this._debugMesh.color = this.color;
  27109. };
  27110. /** Release associated resources */
  27111. SkeletonViewer.prototype.dispose = function () {
  27112. this.isEnabled = false;
  27113. if (this._debugMesh) {
  27114. this.isEnabled = false;
  27115. this._debugMesh.dispose();
  27116. this._debugMesh = null;
  27117. }
  27118. if (this._utilityLayer) {
  27119. this._utilityLayer.dispose();
  27120. this._utilityLayer = null;
  27121. }
  27122. };
  27123. return SkeletonViewer;
  27124. }());
  27125. /***/ }),
  27126. /***/ "./Engines/Extensions/engine.occlusionQuery.ts":
  27127. /*!*****************************************************!*\
  27128. !*** ./Engines/Extensions/engine.occlusionQuery.ts ***!
  27129. \*****************************************************/
  27130. /*! exports provided: _OcclusionDataStorage */
  27131. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27132. "use strict";
  27133. __webpack_require__.r(__webpack_exports__);
  27134. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _OcclusionDataStorage; });
  27135. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  27136. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  27137. /* harmony import */ var _Instrumentation_timeToken__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Instrumentation/timeToken */ "./Instrumentation/timeToken.ts");
  27138. /** @hidden */
  27139. var _OcclusionDataStorage = /** @class */ (function () {
  27140. function _OcclusionDataStorage() {
  27141. /** @hidden */
  27142. this.occlusionInternalRetryCounter = 0;
  27143. /** @hidden */
  27144. this.isOcclusionQueryInProgress = false;
  27145. /** @hidden */
  27146. this.isOccluded = false;
  27147. /** @hidden */
  27148. this.occlusionRetryCount = -1;
  27149. /** @hidden */
  27150. this.occlusionType = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_NONE;
  27151. /** @hidden */
  27152. this.occlusionQueryAlgorithmType = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE;
  27153. }
  27154. return _OcclusionDataStorage;
  27155. }());
  27156. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createQuery = function () {
  27157. return this._gl.createQuery();
  27158. };
  27159. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.deleteQuery = function (query) {
  27160. this._gl.deleteQuery(query);
  27161. return this;
  27162. };
  27163. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.isQueryResultAvailable = function (query) {
  27164. return this._gl.getQueryParameter(query, this._gl.QUERY_RESULT_AVAILABLE);
  27165. };
  27166. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.getQueryResult = function (query) {
  27167. return this._gl.getQueryParameter(query, this._gl.QUERY_RESULT);
  27168. };
  27169. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.beginOcclusionQuery = function (algorithmType, query) {
  27170. var glAlgorithm = this._getGlAlgorithmType(algorithmType);
  27171. this._gl.beginQuery(glAlgorithm, query);
  27172. return this;
  27173. };
  27174. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endOcclusionQuery = function (algorithmType) {
  27175. var glAlgorithm = this._getGlAlgorithmType(algorithmType);
  27176. this._gl.endQuery(glAlgorithm);
  27177. return this;
  27178. };
  27179. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._createTimeQuery = function () {
  27180. var timerQuery = this.getCaps().timerQuery;
  27181. if (timerQuery.createQueryEXT) {
  27182. return timerQuery.createQueryEXT();
  27183. }
  27184. return this.createQuery();
  27185. };
  27186. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._deleteTimeQuery = function (query) {
  27187. var timerQuery = this.getCaps().timerQuery;
  27188. if (timerQuery.deleteQueryEXT) {
  27189. timerQuery.deleteQueryEXT(query);
  27190. return;
  27191. }
  27192. this.deleteQuery(query);
  27193. };
  27194. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getTimeQueryResult = function (query) {
  27195. var timerQuery = this.getCaps().timerQuery;
  27196. if (timerQuery.getQueryObjectEXT) {
  27197. return timerQuery.getQueryObjectEXT(query, timerQuery.QUERY_RESULT_EXT);
  27198. }
  27199. return this.getQueryResult(query);
  27200. };
  27201. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getTimeQueryAvailability = function (query) {
  27202. var timerQuery = this.getCaps().timerQuery;
  27203. if (timerQuery.getQueryObjectEXT) {
  27204. return timerQuery.getQueryObjectEXT(query, timerQuery.QUERY_RESULT_AVAILABLE_EXT);
  27205. }
  27206. return this.isQueryResultAvailable(query);
  27207. };
  27208. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.startTimeQuery = function () {
  27209. var caps = this.getCaps();
  27210. var timerQuery = caps.timerQuery;
  27211. if (!timerQuery) {
  27212. return null;
  27213. }
  27214. var token = new _Instrumentation_timeToken__WEBPACK_IMPORTED_MODULE_2__["_TimeToken"]();
  27215. this._gl.getParameter(timerQuery.GPU_DISJOINT_EXT);
  27216. if (caps.canUseTimestampForTimerQuery) {
  27217. token._startTimeQuery = this._createTimeQuery();
  27218. timerQuery.queryCounterEXT(token._startTimeQuery, timerQuery.TIMESTAMP_EXT);
  27219. }
  27220. else {
  27221. if (this._currentNonTimestampToken) {
  27222. return this._currentNonTimestampToken;
  27223. }
  27224. token._timeElapsedQuery = this._createTimeQuery();
  27225. if (timerQuery.beginQueryEXT) {
  27226. timerQuery.beginQueryEXT(timerQuery.TIME_ELAPSED_EXT, token._timeElapsedQuery);
  27227. }
  27228. else {
  27229. this._gl.beginQuery(timerQuery.TIME_ELAPSED_EXT, token._timeElapsedQuery);
  27230. }
  27231. this._currentNonTimestampToken = token;
  27232. }
  27233. return token;
  27234. };
  27235. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endTimeQuery = function (token) {
  27236. var caps = this.getCaps();
  27237. var timerQuery = caps.timerQuery;
  27238. if (!timerQuery || !token) {
  27239. return -1;
  27240. }
  27241. if (caps.canUseTimestampForTimerQuery) {
  27242. if (!token._startTimeQuery) {
  27243. return -1;
  27244. }
  27245. if (!token._endTimeQuery) {
  27246. token._endTimeQuery = this._createTimeQuery();
  27247. timerQuery.queryCounterEXT(token._endTimeQuery, timerQuery.TIMESTAMP_EXT);
  27248. }
  27249. }
  27250. else if (!token._timeElapsedQueryEnded) {
  27251. if (!token._timeElapsedQuery) {
  27252. return -1;
  27253. }
  27254. if (timerQuery.endQueryEXT) {
  27255. timerQuery.endQueryEXT(timerQuery.TIME_ELAPSED_EXT);
  27256. }
  27257. else {
  27258. this._gl.endQuery(timerQuery.TIME_ELAPSED_EXT);
  27259. }
  27260. token._timeElapsedQueryEnded = true;
  27261. }
  27262. var disjoint = this._gl.getParameter(timerQuery.GPU_DISJOINT_EXT);
  27263. var available = false;
  27264. if (token._endTimeQuery) {
  27265. available = this._getTimeQueryAvailability(token._endTimeQuery);
  27266. }
  27267. else if (token._timeElapsedQuery) {
  27268. available = this._getTimeQueryAvailability(token._timeElapsedQuery);
  27269. }
  27270. if (available && !disjoint) {
  27271. var result = 0;
  27272. if (caps.canUseTimestampForTimerQuery) {
  27273. if (!token._startTimeQuery || !token._endTimeQuery) {
  27274. return -1;
  27275. }
  27276. var timeStart = this._getTimeQueryResult(token._startTimeQuery);
  27277. var timeEnd = this._getTimeQueryResult(token._endTimeQuery);
  27278. result = timeEnd - timeStart;
  27279. this._deleteTimeQuery(token._startTimeQuery);
  27280. this._deleteTimeQuery(token._endTimeQuery);
  27281. token._startTimeQuery = null;
  27282. token._endTimeQuery = null;
  27283. }
  27284. else {
  27285. if (!token._timeElapsedQuery) {
  27286. return -1;
  27287. }
  27288. result = this._getTimeQueryResult(token._timeElapsedQuery);
  27289. this._deleteTimeQuery(token._timeElapsedQuery);
  27290. token._timeElapsedQuery = null;
  27291. token._timeElapsedQueryEnded = false;
  27292. this._currentNonTimestampToken = null;
  27293. }
  27294. return result;
  27295. }
  27296. return -1;
  27297. };
  27298. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getGlAlgorithmType = function (algorithmType) {
  27299. return algorithmType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE ? this._gl.ANY_SAMPLES_PASSED_CONSERVATIVE : this._gl.ANY_SAMPLES_PASSED;
  27300. };
  27301. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "isOcclusionQueryInProgress", {
  27302. get: function () {
  27303. return this._occlusionDataStorage.isOcclusionQueryInProgress;
  27304. },
  27305. enumerable: false,
  27306. configurable: true
  27307. });
  27308. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "_occlusionDataStorage", {
  27309. get: function () {
  27310. if (!this.__occlusionDataStorage) {
  27311. this.__occlusionDataStorage = new _OcclusionDataStorage();
  27312. }
  27313. return this.__occlusionDataStorage;
  27314. },
  27315. enumerable: false,
  27316. configurable: true
  27317. });
  27318. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "isOccluded", {
  27319. get: function () {
  27320. return this._occlusionDataStorage.isOccluded;
  27321. },
  27322. set: function (value) {
  27323. this._occlusionDataStorage.isOccluded = value;
  27324. },
  27325. enumerable: true,
  27326. configurable: true
  27327. });
  27328. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionQueryAlgorithmType", {
  27329. get: function () {
  27330. return this._occlusionDataStorage.occlusionQueryAlgorithmType;
  27331. },
  27332. set: function (value) {
  27333. this._occlusionDataStorage.occlusionQueryAlgorithmType = value;
  27334. },
  27335. enumerable: true,
  27336. configurable: true
  27337. });
  27338. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionType", {
  27339. get: function () {
  27340. return this._occlusionDataStorage.occlusionType;
  27341. },
  27342. set: function (value) {
  27343. this._occlusionDataStorage.occlusionType = value;
  27344. },
  27345. enumerable: true,
  27346. configurable: true
  27347. });
  27348. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionRetryCount", {
  27349. get: function () {
  27350. return this._occlusionDataStorage.occlusionRetryCount;
  27351. },
  27352. set: function (value) {
  27353. this._occlusionDataStorage.occlusionRetryCount = value;
  27354. },
  27355. enumerable: true,
  27356. configurable: true
  27357. });
  27358. // We also need to update AbstractMesh as there is a portion of the code there
  27359. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype._checkOcclusionQuery = function () {
  27360. var dataStorage = this._occlusionDataStorage;
  27361. if (dataStorage.occlusionType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_NONE) {
  27362. dataStorage.isOccluded = false;
  27363. return false;
  27364. }
  27365. var engine = this.getEngine();
  27366. if (engine.webGLVersion < 2) {
  27367. dataStorage.isOccluded = false;
  27368. return false;
  27369. }
  27370. if (!engine.isQueryResultAvailable) { // Occlusion query where not referenced
  27371. dataStorage.isOccluded = false;
  27372. return false;
  27373. }
  27374. if (this.isOcclusionQueryInProgress && this._occlusionQuery) {
  27375. var isOcclusionQueryAvailable = engine.isQueryResultAvailable(this._occlusionQuery);
  27376. if (isOcclusionQueryAvailable) {
  27377. var occlusionQueryResult = engine.getQueryResult(this._occlusionQuery);
  27378. dataStorage.isOcclusionQueryInProgress = false;
  27379. dataStorage.occlusionInternalRetryCounter = 0;
  27380. dataStorage.isOccluded = occlusionQueryResult === 1 ? false : true;
  27381. }
  27382. else {
  27383. dataStorage.occlusionInternalRetryCounter++;
  27384. if (dataStorage.occlusionRetryCount !== -1 && dataStorage.occlusionInternalRetryCounter > dataStorage.occlusionRetryCount) {
  27385. dataStorage.isOcclusionQueryInProgress = false;
  27386. dataStorage.occlusionInternalRetryCounter = 0;
  27387. // if optimistic set isOccluded to false regardless of the status of isOccluded. (Render in the current render loop)
  27388. // if strict continue the last state of the object.
  27389. dataStorage.isOccluded = dataStorage.occlusionType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_OPTIMISTIC ? false : dataStorage.isOccluded;
  27390. }
  27391. else {
  27392. return false;
  27393. }
  27394. }
  27395. }
  27396. var scene = this.getScene();
  27397. if (scene.getBoundingBoxRenderer) {
  27398. var occlusionBoundingBoxRenderer = scene.getBoundingBoxRenderer();
  27399. if (!this._occlusionQuery) {
  27400. this._occlusionQuery = engine.createQuery();
  27401. }
  27402. engine.beginOcclusionQuery(dataStorage.occlusionQueryAlgorithmType, this._occlusionQuery);
  27403. occlusionBoundingBoxRenderer.renderOcclusionBoundingBox(this);
  27404. engine.endOcclusionQuery(dataStorage.occlusionQueryAlgorithmType);
  27405. this._occlusionDataStorage.isOcclusionQueryInProgress = true;
  27406. }
  27407. return dataStorage.isOccluded;
  27408. };
  27409. /***/ }),
  27410. /***/ "./Engines/Extensions/engine.transformFeedback.ts":
  27411. /*!********************************************************!*\
  27412. !*** ./Engines/Extensions/engine.transformFeedback.ts ***!
  27413. \********************************************************/
  27414. /*! exports provided: _forceTransformFeedbackToBundle */
  27415. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27416. "use strict";
  27417. __webpack_require__.r(__webpack_exports__);
  27418. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _forceTransformFeedbackToBundle; });
  27419. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  27420. /** @hidden */
  27421. var _forceTransformFeedbackToBundle = true;
  27422. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createTransformFeedback = function () {
  27423. return this._gl.createTransformFeedback();
  27424. };
  27425. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.deleteTransformFeedback = function (value) {
  27426. this._gl.deleteTransformFeedback(value);
  27427. };
  27428. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.bindTransformFeedback = function (value) {
  27429. this._gl.bindTransformFeedback(this._gl.TRANSFORM_FEEDBACK, value);
  27430. };
  27431. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.beginTransformFeedback = function (usePoints) {
  27432. if (usePoints === void 0) { usePoints = true; }
  27433. this._gl.beginTransformFeedback(usePoints ? this._gl.POINTS : this._gl.TRIANGLES);
  27434. };
  27435. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endTransformFeedback = function () {
  27436. this._gl.endTransformFeedback();
  27437. };
  27438. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.setTranformFeedbackVaryings = function (program, value) {
  27439. this._gl.transformFeedbackVaryings(program, value, this._gl.INTERLEAVED_ATTRIBS);
  27440. };
  27441. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.bindTransformFeedbackBuffer = function (value) {
  27442. this._gl.bindBufferBase(this._gl.TRANSFORM_FEEDBACK_BUFFER, 0, value);
  27443. };
  27444. /***/ }),
  27445. /***/ "./Engines/Extensions/index.ts":
  27446. /*!*************************************!*\
  27447. !*** ./Engines/Extensions/index.ts ***!
  27448. \*************************************/
  27449. /*! exports provided: _OcclusionDataStorage, _forceTransformFeedbackToBundle */
  27450. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27451. "use strict";
  27452. __webpack_require__.r(__webpack_exports__);
  27453. /* harmony import */ var _engine_occlusionQuery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engine.occlusionQuery */ "./Engines/Extensions/engine.occlusionQuery.ts");
  27454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _engine_occlusionQuery__WEBPACK_IMPORTED_MODULE_0__["_OcclusionDataStorage"]; });
  27455. /* harmony import */ var _engine_transformFeedback__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine.transformFeedback */ "./Engines/Extensions/engine.transformFeedback.ts");
  27456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _engine_transformFeedback__WEBPACK_IMPORTED_MODULE_1__["_forceTransformFeedbackToBundle"]; });
  27457. /***/ }),
  27458. /***/ "./Engines/constants.ts":
  27459. /*!******************************!*\
  27460. !*** ./Engines/constants.ts ***!
  27461. \******************************/
  27462. /*! exports provided: Constants */
  27463. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27464. "use strict";
  27465. __webpack_require__.r(__webpack_exports__);
  27466. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return Constants; });
  27467. /** Defines the cross module used constants to avoid circular dependncies */
  27468. var Constants = /** @class */ (function () {
  27469. function Constants() {
  27470. }
  27471. /** Defines that alpha blending is disabled */
  27472. Constants.ALPHA_DISABLE = 0;
  27473. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27474. Constants.ALPHA_ADD = 1;
  27475. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27476. Constants.ALPHA_COMBINE = 2;
  27477. /** Defines that alpha blending to DEST - SRC * DEST */
  27478. Constants.ALPHA_SUBTRACT = 3;
  27479. /** Defines that alpha blending to SRC * DEST */
  27480. Constants.ALPHA_MULTIPLY = 4;
  27481. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27482. Constants.ALPHA_MAXIMIZED = 5;
  27483. /** Defines that alpha blending to SRC + DEST */
  27484. Constants.ALPHA_ONEONE = 6;
  27485. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27486. Constants.ALPHA_PREMULTIPLIED = 7;
  27487. /**
  27488. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27489. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27490. */
  27491. Constants.ALPHA_PREMULTIPLIED_PORTERDUFF = 8;
  27492. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27493. Constants.ALPHA_INTERPOLATE = 9;
  27494. /**
  27495. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27496. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27497. */
  27498. Constants.ALPHA_SCREENMODE = 10;
  27499. /** Defines that the ressource is not delayed*/
  27500. Constants.DELAYLOADSTATE_NONE = 0;
  27501. /** Defines that the ressource was successfully delay loaded */
  27502. Constants.DELAYLOADSTATE_LOADED = 1;
  27503. /** Defines that the ressource is currently delay loading */
  27504. Constants.DELAYLOADSTATE_LOADING = 2;
  27505. /** Defines that the ressource is delayed and has not started loading */
  27506. Constants.DELAYLOADSTATE_NOTLOADED = 4;
  27507. // Depht or Stencil test Constants.
  27508. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27509. Constants.NEVER = 0x0200;
  27510. /** 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 */
  27511. Constants.ALWAYS = 0x0207;
  27512. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27513. Constants.LESS = 0x0201;
  27514. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27515. Constants.EQUAL = 0x0202;
  27516. /** 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 */
  27517. Constants.LEQUAL = 0x0203;
  27518. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27519. Constants.GREATER = 0x0204;
  27520. /** 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 */
  27521. Constants.GEQUAL = 0x0206;
  27522. /** 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 */
  27523. Constants.NOTEQUAL = 0x0205;
  27524. // Stencil Actions Constants.
  27525. /** Passed to stencilOperation to specify that stencil value must be kept */
  27526. Constants.KEEP = 0x1E00;
  27527. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27528. Constants.REPLACE = 0x1E01;
  27529. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27530. Constants.INCR = 0x1E02;
  27531. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27532. Constants.DECR = 0x1E03;
  27533. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27534. Constants.INVERT = 0x150A;
  27535. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27536. Constants.INCR_WRAP = 0x8507;
  27537. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27538. Constants.DECR_WRAP = 0x8508;
  27539. /** Texture is not repeating outside of 0..1 UVs */
  27540. Constants.TEXTURE_CLAMP_ADDRESSMODE = 0;
  27541. /** Texture is repeating outside of 0..1 UVs */
  27542. Constants.TEXTURE_WRAP_ADDRESSMODE = 1;
  27543. /** Texture is repeating and mirrored */
  27544. Constants.TEXTURE_MIRROR_ADDRESSMODE = 2;
  27545. /** ALPHA */
  27546. Constants.TEXTUREFORMAT_ALPHA = 0;
  27547. /** LUMINANCE */
  27548. Constants.TEXTUREFORMAT_LUMINANCE = 1;
  27549. /** LUMINANCE_ALPHA */
  27550. Constants.TEXTUREFORMAT_LUMINANCE_ALPHA = 2;
  27551. /** RGB */
  27552. Constants.TEXTUREFORMAT_RGB = 4;
  27553. /** RGBA */
  27554. Constants.TEXTUREFORMAT_RGBA = 5;
  27555. /** RED */
  27556. Constants.TEXTUREFORMAT_RED = 6;
  27557. /** RED (2nd reference) */
  27558. Constants.TEXTUREFORMAT_R = 6;
  27559. /** RG */
  27560. Constants.TEXTUREFORMAT_RG = 7;
  27561. /** RED_INTEGER */
  27562. Constants.TEXTUREFORMAT_RED_INTEGER = 8;
  27563. /** RED_INTEGER (2nd reference) */
  27564. Constants.TEXTUREFORMAT_R_INTEGER = 8;
  27565. /** RG_INTEGER */
  27566. Constants.TEXTUREFORMAT_RG_INTEGER = 9;
  27567. /** RGB_INTEGER */
  27568. Constants.TEXTUREFORMAT_RGB_INTEGER = 10;
  27569. /** RGBA_INTEGER */
  27570. Constants.TEXTUREFORMAT_RGBA_INTEGER = 11;
  27571. /** UNSIGNED_BYTE */
  27572. Constants.TEXTURETYPE_UNSIGNED_BYTE = 0;
  27573. /** UNSIGNED_BYTE (2nd reference) */
  27574. Constants.TEXTURETYPE_UNSIGNED_INT = 0;
  27575. /** FLOAT */
  27576. Constants.TEXTURETYPE_FLOAT = 1;
  27577. /** HALF_FLOAT */
  27578. Constants.TEXTURETYPE_HALF_FLOAT = 2;
  27579. /** BYTE */
  27580. Constants.TEXTURETYPE_BYTE = 3;
  27581. /** SHORT */
  27582. Constants.TEXTURETYPE_SHORT = 4;
  27583. /** UNSIGNED_SHORT */
  27584. Constants.TEXTURETYPE_UNSIGNED_SHORT = 5;
  27585. /** INT */
  27586. Constants.TEXTURETYPE_INT = 6;
  27587. /** UNSIGNED_INT */
  27588. Constants.TEXTURETYPE_UNSIGNED_INTEGER = 7;
  27589. /** UNSIGNED_SHORT_4_4_4_4 */
  27590. Constants.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = 8;
  27591. /** UNSIGNED_SHORT_5_5_5_1 */
  27592. Constants.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = 9;
  27593. /** UNSIGNED_SHORT_5_6_5 */
  27594. Constants.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = 10;
  27595. /** UNSIGNED_INT_2_10_10_10_REV */
  27596. Constants.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = 11;
  27597. /** UNSIGNED_INT_24_8 */
  27598. Constants.TEXTURETYPE_UNSIGNED_INT_24_8 = 12;
  27599. /** UNSIGNED_INT_10F_11F_11F_REV */
  27600. Constants.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = 13;
  27601. /** UNSIGNED_INT_5_9_9_9_REV */
  27602. Constants.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = 14;
  27603. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27604. Constants.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = 15;
  27605. /** nearest is mag = nearest and min = nearest and mip = linear */
  27606. Constants.TEXTURE_NEAREST_SAMPLINGMODE = 1;
  27607. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27608. Constants.TEXTURE_BILINEAR_SAMPLINGMODE = 2;
  27609. /** Trilinear is mag = linear and min = linear and mip = linear */
  27610. Constants.TEXTURE_TRILINEAR_SAMPLINGMODE = 3;
  27611. /** nearest is mag = nearest and min = nearest and mip = linear */
  27612. Constants.TEXTURE_NEAREST_NEAREST_MIPLINEAR = 1;
  27613. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27614. Constants.TEXTURE_LINEAR_LINEAR_MIPNEAREST = 2;
  27615. /** Trilinear is mag = linear and min = linear and mip = linear */
  27616. Constants.TEXTURE_LINEAR_LINEAR_MIPLINEAR = 3;
  27617. /** mag = nearest and min = nearest and mip = nearest */
  27618. Constants.TEXTURE_NEAREST_NEAREST_MIPNEAREST = 4;
  27619. /** mag = nearest and min = linear and mip = nearest */
  27620. Constants.TEXTURE_NEAREST_LINEAR_MIPNEAREST = 5;
  27621. /** mag = nearest and min = linear and mip = linear */
  27622. Constants.TEXTURE_NEAREST_LINEAR_MIPLINEAR = 6;
  27623. /** mag = nearest and min = linear and mip = none */
  27624. Constants.TEXTURE_NEAREST_LINEAR = 7;
  27625. /** mag = nearest and min = nearest and mip = none */
  27626. Constants.TEXTURE_NEAREST_NEAREST = 8;
  27627. /** mag = linear and min = nearest and mip = nearest */
  27628. Constants.TEXTURE_LINEAR_NEAREST_MIPNEAREST = 9;
  27629. /** mag = linear and min = nearest and mip = linear */
  27630. Constants.TEXTURE_LINEAR_NEAREST_MIPLINEAR = 10;
  27631. /** mag = linear and min = linear and mip = none */
  27632. Constants.TEXTURE_LINEAR_LINEAR = 11;
  27633. /** mag = linear and min = nearest and mip = none */
  27634. Constants.TEXTURE_LINEAR_NEAREST = 12;
  27635. /** Explicit coordinates mode */
  27636. Constants.TEXTURE_EXPLICIT_MODE = 0;
  27637. /** Spherical coordinates mode */
  27638. Constants.TEXTURE_SPHERICAL_MODE = 1;
  27639. /** Planar coordinates mode */
  27640. Constants.TEXTURE_PLANAR_MODE = 2;
  27641. /** Cubic coordinates mode */
  27642. Constants.TEXTURE_CUBIC_MODE = 3;
  27643. /** Projection coordinates mode */
  27644. Constants.TEXTURE_PROJECTION_MODE = 4;
  27645. /** Skybox coordinates mode */
  27646. Constants.TEXTURE_SKYBOX_MODE = 5;
  27647. /** Inverse Cubic coordinates mode */
  27648. Constants.TEXTURE_INVCUBIC_MODE = 6;
  27649. /** Equirectangular coordinates mode */
  27650. Constants.TEXTURE_EQUIRECTANGULAR_MODE = 7;
  27651. /** Equirectangular Fixed coordinates mode */
  27652. Constants.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = 8;
  27653. /** Equirectangular Fixed Mirrored coordinates mode */
  27654. Constants.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = 9;
  27655. // Texture rescaling mode
  27656. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27657. Constants.SCALEMODE_FLOOR = 1;
  27658. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27659. Constants.SCALEMODE_NEAREST = 2;
  27660. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27661. Constants.SCALEMODE_CEILING = 3;
  27662. /**
  27663. * The dirty texture flag value
  27664. */
  27665. Constants.MATERIAL_TextureDirtyFlag = 1;
  27666. /**
  27667. * The dirty light flag value
  27668. */
  27669. Constants.MATERIAL_LightDirtyFlag = 2;
  27670. /**
  27671. * The dirty fresnel flag value
  27672. */
  27673. Constants.MATERIAL_FresnelDirtyFlag = 4;
  27674. /**
  27675. * The dirty attribute flag value
  27676. */
  27677. Constants.MATERIAL_AttributesDirtyFlag = 8;
  27678. /**
  27679. * The dirty misc flag value
  27680. */
  27681. Constants.MATERIAL_MiscDirtyFlag = 16;
  27682. /**
  27683. * The all dirty flag value
  27684. */
  27685. Constants.MATERIAL_AllDirtyFlag = 31;
  27686. /**
  27687. * Returns the triangle fill mode
  27688. */
  27689. Constants.MATERIAL_TriangleFillMode = 0;
  27690. /**
  27691. * Returns the wireframe mode
  27692. */
  27693. Constants.MATERIAL_WireFrameFillMode = 1;
  27694. /**
  27695. * Returns the point fill mode
  27696. */
  27697. Constants.MATERIAL_PointFillMode = 2;
  27698. /**
  27699. * Returns the point list draw mode
  27700. */
  27701. Constants.MATERIAL_PointListDrawMode = 3;
  27702. /**
  27703. * Returns the line list draw mode
  27704. */
  27705. Constants.MATERIAL_LineListDrawMode = 4;
  27706. /**
  27707. * Returns the line loop draw mode
  27708. */
  27709. Constants.MATERIAL_LineLoopDrawMode = 5;
  27710. /**
  27711. * Returns the line strip draw mode
  27712. */
  27713. Constants.MATERIAL_LineStripDrawMode = 6;
  27714. /**
  27715. * Returns the triangle strip draw mode
  27716. */
  27717. Constants.MATERIAL_TriangleStripDrawMode = 7;
  27718. /**
  27719. * Returns the triangle fan draw mode
  27720. */
  27721. Constants.MATERIAL_TriangleFanDrawMode = 8;
  27722. /**
  27723. * Stores the clock-wise side orientation
  27724. */
  27725. Constants.MATERIAL_ClockWiseSideOrientation = 0;
  27726. /**
  27727. * Stores the counter clock-wise side orientation
  27728. */
  27729. Constants.MATERIAL_CounterClockWiseSideOrientation = 1;
  27730. /**
  27731. * Nothing
  27732. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27733. */
  27734. Constants.ACTION_NothingTrigger = 0;
  27735. /**
  27736. * On pick
  27737. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27738. */
  27739. Constants.ACTION_OnPickTrigger = 1;
  27740. /**
  27741. * On left pick
  27742. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27743. */
  27744. Constants.ACTION_OnLeftPickTrigger = 2;
  27745. /**
  27746. * On right pick
  27747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27748. */
  27749. Constants.ACTION_OnRightPickTrigger = 3;
  27750. /**
  27751. * On center pick
  27752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27753. */
  27754. Constants.ACTION_OnCenterPickTrigger = 4;
  27755. /**
  27756. * On pick down
  27757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27758. */
  27759. Constants.ACTION_OnPickDownTrigger = 5;
  27760. /**
  27761. * On double pick
  27762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27763. */
  27764. Constants.ACTION_OnDoublePickTrigger = 6;
  27765. /**
  27766. * On pick up
  27767. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27768. */
  27769. Constants.ACTION_OnPickUpTrigger = 7;
  27770. /**
  27771. * On pick out.
  27772. * This trigger will only be raised if you also declared a OnPickDown
  27773. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27774. */
  27775. Constants.ACTION_OnPickOutTrigger = 16;
  27776. /**
  27777. * On long press
  27778. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27779. */
  27780. Constants.ACTION_OnLongPressTrigger = 8;
  27781. /**
  27782. * On pointer over
  27783. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27784. */
  27785. Constants.ACTION_OnPointerOverTrigger = 9;
  27786. /**
  27787. * On pointer out
  27788. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27789. */
  27790. Constants.ACTION_OnPointerOutTrigger = 10;
  27791. /**
  27792. * On every frame
  27793. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27794. */
  27795. Constants.ACTION_OnEveryFrameTrigger = 11;
  27796. /**
  27797. * On intersection enter
  27798. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27799. */
  27800. Constants.ACTION_OnIntersectionEnterTrigger = 12;
  27801. /**
  27802. * On intersection exit
  27803. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27804. */
  27805. Constants.ACTION_OnIntersectionExitTrigger = 13;
  27806. /**
  27807. * On key down
  27808. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27809. */
  27810. Constants.ACTION_OnKeyDownTrigger = 14;
  27811. /**
  27812. * On key up
  27813. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27814. */
  27815. Constants.ACTION_OnKeyUpTrigger = 15;
  27816. /**
  27817. * Billboard mode will only apply to Y axis
  27818. */
  27819. Constants.PARTICLES_BILLBOARDMODE_Y = 2;
  27820. /**
  27821. * Billboard mode will apply to all axes
  27822. */
  27823. Constants.PARTICLES_BILLBOARDMODE_ALL = 7;
  27824. /**
  27825. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  27826. */
  27827. Constants.PARTICLES_BILLBOARDMODE_STRETCHED = 8;
  27828. /**
  27829. * Gets or sets base Assets URL
  27830. */
  27831. Constants.PARTICLES_BaseAssetsUrl = "https://assets.babylonjs.com/particles";
  27832. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27833. * Test order :
  27834. * Is the bounding sphere outside the frustum ?
  27835. * If not, are the bounding box vertices outside the frustum ?
  27836. * It not, then the cullable object is in the frustum.
  27837. */
  27838. Constants.MESHES_CULLINGSTRATEGY_STANDARD = 0;
  27839. /** Culling strategy : Bounding Sphere Only.
  27840. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27841. * It's also less accurate than the standard because some not visible objects can still be selected.
  27842. * Test : is the bounding sphere outside the frustum ?
  27843. * If not, then the cullable object is in the frustum.
  27844. */
  27845. Constants.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = 1;
  27846. /** Culling strategy : Optimistic Inclusion.
  27847. * This in an inclusion test first, then the standard exclusion test.
  27848. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27849. * 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.
  27850. * Anyway, it's as accurate as the standard strategy.
  27851. * Test :
  27852. * Is the cullable object bounding sphere center in the frustum ?
  27853. * If not, apply the default culling strategy.
  27854. */
  27855. Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = 2;
  27856. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27857. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27858. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27859. * 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.
  27860. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27861. * Test :
  27862. * Is the cullable object bounding sphere center in the frustum ?
  27863. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27864. */
  27865. Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = 3;
  27866. /**
  27867. * No logging while loading
  27868. */
  27869. Constants.SCENELOADER_NO_LOGGING = 0;
  27870. /**
  27871. * Minimal logging while loading
  27872. */
  27873. Constants.SCENELOADER_MINIMAL_LOGGING = 1;
  27874. /**
  27875. * Summary logging while loading
  27876. */
  27877. Constants.SCENELOADER_SUMMARY_LOGGING = 2;
  27878. /**
  27879. * Detailled logging while loading
  27880. */
  27881. Constants.SCENELOADER_DETAILED_LOGGING = 3;
  27882. return Constants;
  27883. }());
  27884. /***/ }),
  27885. /***/ "./Engines/engine.ts":
  27886. /*!***************************!*\
  27887. !*** ./Engines/engine.ts ***!
  27888. \***************************/
  27889. /*! exports provided: InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine */
  27890. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27891. "use strict";
  27892. __webpack_require__.r(__webpack_exports__);
  27893. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return InstancingAttributeInfo; });
  27894. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return DepthTextureCreationOptions; });
  27895. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return EngineCapabilities; });
  27896. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return Engine; });
  27897. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  27898. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  27899. /* harmony import */ var _Misc_performanceMonitor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/performanceMonitor */ "./Misc/performanceMonitor.ts");
  27900. /* harmony import */ var _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/stringDictionary */ "./Misc/stringDictionary.ts");
  27901. /* harmony import */ var _Misc_promise__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/promise */ "./Misc/promise.ts");
  27902. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  27903. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  27904. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  27905. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  27906. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  27907. /* harmony import */ var _Materials_Textures_internalTextureTracker__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/internalTextureTracker */ "./Materials/Textures/internalTextureTracker.ts");
  27908. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  27909. /* harmony import */ var _States_index__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../States/index */ "./States/index.ts");
  27910. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  27911. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  27912. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  27913. /* harmony import */ var _engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./engineStore */ "./Engines/engineStore.ts");
  27914. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  27915. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  27916. /**
  27917. * Keeps track of all the buffer info used in engine.
  27918. */
  27919. var BufferPointer = /** @class */ (function () {
  27920. function BufferPointer() {
  27921. }
  27922. return BufferPointer;
  27923. }());
  27924. /**
  27925. * Interface for attribute information associated with buffer instanciation
  27926. */
  27927. var InstancingAttributeInfo = /** @class */ (function () {
  27928. function InstancingAttributeInfo() {
  27929. }
  27930. return InstancingAttributeInfo;
  27931. }());
  27932. /**
  27933. * Define options used to create a depth texture
  27934. */
  27935. var DepthTextureCreationOptions = /** @class */ (function () {
  27936. function DepthTextureCreationOptions() {
  27937. }
  27938. return DepthTextureCreationOptions;
  27939. }());
  27940. /**
  27941. * Class used to describe the capabilities of the engine relatively to the current browser
  27942. */
  27943. var EngineCapabilities = /** @class */ (function () {
  27944. function EngineCapabilities() {
  27945. }
  27946. return EngineCapabilities;
  27947. }());
  27948. /**
  27949. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27950. */
  27951. var Engine = /** @class */ (function () {
  27952. /**
  27953. * Creates a new engine
  27954. * @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
  27955. * @param antialias defines enable antialiasing (default: false)
  27956. * @param options defines further options to be sent to the getContext() function
  27957. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27958. */
  27959. function Engine(canvasOrContext, antialias, options, adaptToDeviceRatio) {
  27960. if (adaptToDeviceRatio === void 0) { adaptToDeviceRatio = false; }
  27961. var _this = this;
  27962. // Public members
  27963. /**
  27964. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27965. */
  27966. this.forcePOTTextures = false;
  27967. /**
  27968. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27969. */
  27970. this.isFullscreen = false;
  27971. /**
  27972. * Gets a boolean indicating if the pointer is currently locked
  27973. */
  27974. this.isPointerLock = false;
  27975. /**
  27976. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27977. */
  27978. this.cullBackFaces = true;
  27979. /**
  27980. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27981. */
  27982. this.renderEvenInBackground = true;
  27983. /**
  27984. * Gets or sets a boolean indicating that cache can be kept between frames
  27985. */
  27986. this.preventCacheWipeBetweenFrames = false;
  27987. /**
  27988. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27989. **/
  27990. this.enableOfflineSupport = false;
  27991. /**
  27992. * 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)
  27993. **/
  27994. this.disableManifestCheck = false;
  27995. /**
  27996. * Gets the list of created scenes
  27997. */
  27998. this.scenes = new Array();
  27999. /**
  28000. * Event raised when a new scene is created
  28001. */
  28002. this.onNewSceneAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28003. /**
  28004. * Gets the list of created postprocesses
  28005. */
  28006. this.postProcesses = new Array();
  28007. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28008. this.validateShaderPrograms = false;
  28009. // Observables
  28010. /**
  28011. * Observable event triggered each time the rendering canvas is resized
  28012. */
  28013. this.onResizeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28014. /**
  28015. * Observable event triggered each time the canvas loses focus
  28016. */
  28017. this.onCanvasBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28018. /**
  28019. * Observable event triggered each time the canvas gains focus
  28020. */
  28021. this.onCanvasFocusObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28022. /**
  28023. * Observable event triggered each time the canvas receives pointerout event
  28024. */
  28025. this.onCanvasPointerOutObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28026. /**
  28027. * Observable event triggered before each texture is initialized
  28028. */
  28029. this.onBeforeTextureInitObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28030. //WebVR
  28031. this._vrDisplay = undefined;
  28032. this._vrSupported = false;
  28033. this._vrExclusivePointerMode = false;
  28034. // Uniform buffers list
  28035. /**
  28036. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28037. */
  28038. this.disableUniformBuffers = false;
  28039. /** @hidden */
  28040. this._uniformBuffers = new Array();
  28041. // Observables
  28042. /**
  28043. * Observable raised when the engine begins a new frame
  28044. */
  28045. this.onBeginFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28046. /**
  28047. * If set, will be used to request the next animation frame for the render loop
  28048. */
  28049. this.customAnimationFrameRequester = null;
  28050. /**
  28051. * Observable raised when the engine ends the current frame
  28052. */
  28053. this.onEndFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28054. /**
  28055. * Observable raised when the engine is about to compile a shader
  28056. */
  28057. this.onBeforeShaderCompilationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28058. /**
  28059. * Observable raised when the engine has jsut compiled a shader
  28060. */
  28061. this.onAfterShaderCompilationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28062. this._windowIsBackground = false;
  28063. this._webGLVersion = 1.0;
  28064. /** @hidden */
  28065. this._badOS = false;
  28066. /** @hidden */
  28067. this._badDesktopOS = false;
  28068. /**
  28069. * Gets or sets a value indicating if we want to disable texture binding optimization.
  28070. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  28071. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  28072. */
  28073. this.disableTextureBindingOptimization = false;
  28074. /**
  28075. * Observable signaled when VR display mode changes
  28076. */
  28077. this.onVRDisplayChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28078. /**
  28079. * Observable signaled when VR request present is complete
  28080. */
  28081. this.onVRRequestPresentComplete = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28082. /**
  28083. * Observable signaled when VR request present starts
  28084. */
  28085. this.onVRRequestPresentStart = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28086. this._colorWrite = true;
  28087. /** @hidden */
  28088. this._drawCalls = new _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["PerfCounter"]();
  28089. /** @hidden */
  28090. this._textureCollisions = new _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["PerfCounter"]();
  28091. this._renderingQueueLaunched = false;
  28092. this._activeRenderLoops = new Array();
  28093. // Deterministic lockstepMaxSteps
  28094. this._deterministicLockstep = false;
  28095. this._lockstepMaxSteps = 4;
  28096. // Lost context
  28097. /**
  28098. * Observable signaled when a context lost event is raised
  28099. */
  28100. this.onContextLostObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28101. /**
  28102. * Observable signaled when a context restored event is raised
  28103. */
  28104. this.onContextRestoredObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28105. this._contextWasLost = false;
  28106. this._doNotHandleContextLost = false;
  28107. // FPS
  28108. this._performanceMonitor = new _Misc_performanceMonitor__WEBPACK_IMPORTED_MODULE_2__["PerformanceMonitor"]();
  28109. this._fps = 60;
  28110. this._deltaTime = 0;
  28111. /**
  28112. * Turn this value on if you want to pause FPS computation when in background
  28113. */
  28114. this.disablePerformanceMonitorInBackground = false;
  28115. // States
  28116. /** @hidden */
  28117. this._depthCullingState = new _States_index__WEBPACK_IMPORTED_MODULE_12__["_DepthCullingState"]();
  28118. /** @hidden */
  28119. this._stencilState = new _States_index__WEBPACK_IMPORTED_MODULE_12__["_StencilState"]();
  28120. /** @hidden */
  28121. this._alphaState = new _States_index__WEBPACK_IMPORTED_MODULE_12__["_AlphaState"]();
  28122. /** @hidden */
  28123. this._alphaMode = Engine.ALPHA_DISABLE;
  28124. // Cache
  28125. this._internalTexturesCache = new Array();
  28126. /** @hidden */
  28127. this._activeChannel = 0;
  28128. this._currentTextureChannel = -1;
  28129. /** @hidden */
  28130. this._boundTexturesCache = {};
  28131. this._compiledEffects = {};
  28132. this._vertexAttribArraysEnabled = [];
  28133. this._uintIndicesCurrentlySet = false;
  28134. this._currentBoundBuffer = new Array();
  28135. /** @hidden */
  28136. this._currentFramebuffer = null;
  28137. this._currentBufferPointers = new Array();
  28138. this._currentInstanceLocations = new Array();
  28139. this._currentInstanceBuffers = new Array();
  28140. this._firstBoundInternalTextureTracker = new _Materials_Textures_internalTextureTracker__WEBPACK_IMPORTED_MODULE_10__["DummyInternalTextureTracker"]();
  28141. this._lastBoundInternalTextureTracker = new _Materials_Textures_internalTextureTracker__WEBPACK_IMPORTED_MODULE_10__["DummyInternalTextureTracker"]();
  28142. this._vaoRecordInProgress = false;
  28143. this._mustWipeVertexAttributes = false;
  28144. this._nextFreeTextureSlots = new Array();
  28145. this._maxSimultaneousTextures = 0;
  28146. this._activeRequests = new Array();
  28147. // Hardware supported Compressed Textures
  28148. this._texturesSupported = new Array();
  28149. /**
  28150. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28151. */
  28152. this.premultipliedAlpha = true;
  28153. this._viewportCached = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Vector4"](0, 0, 0, 0);
  28154. this._onVRFullScreenTriggered = function () {
  28155. if (_this._vrDisplay && _this._vrDisplay.isPresenting) {
  28156. //get the old size before we change
  28157. _this._oldSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Size"](_this.getRenderWidth(), _this.getRenderHeight());
  28158. _this._oldHardwareScaleFactor = _this.getHardwareScalingLevel();
  28159. //get the width and height, change the render size
  28160. var leftEye = _this._vrDisplay.getEyeParameters('left');
  28161. _this.setHardwareScalingLevel(1);
  28162. _this.setSize(leftEye.renderWidth * 2, leftEye.renderHeight);
  28163. }
  28164. else {
  28165. _this.setHardwareScalingLevel(_this._oldHardwareScaleFactor);
  28166. _this.setSize(_this._oldSize.width, _this._oldSize.height);
  28167. }
  28168. };
  28169. this._unpackFlipYCached = null;
  28170. /**
  28171. * In case you are sharing the context with other applications, it might
  28172. * be interested to not cache the unpack flip y state to ensure a consistent
  28173. * value would be set.
  28174. */
  28175. this.enableUnpackFlipYCached = true;
  28176. this._boundUniforms = {};
  28177. // Register promises
  28178. _Misc_promise__WEBPACK_IMPORTED_MODULE_4__["PromisePolyfill"].Apply();
  28179. var canvas = null;
  28180. Engine.Instances.push(this);
  28181. if (!canvasOrContext) {
  28182. return;
  28183. }
  28184. options = options || {};
  28185. if (canvasOrContext.getContext) {
  28186. canvas = canvasOrContext;
  28187. this._renderingCanvas = canvas;
  28188. if (antialias != null) {
  28189. options.antialias = antialias;
  28190. }
  28191. if (options.deterministicLockstep === undefined) {
  28192. options.deterministicLockstep = false;
  28193. }
  28194. if (options.lockstepMaxSteps === undefined) {
  28195. options.lockstepMaxSteps = 4;
  28196. }
  28197. if (options.preserveDrawingBuffer === undefined) {
  28198. options.preserveDrawingBuffer = false;
  28199. }
  28200. if (options.audioEngine === undefined) {
  28201. options.audioEngine = true;
  28202. }
  28203. if (options.stencil === undefined) {
  28204. options.stencil = true;
  28205. }
  28206. if (options.premultipliedAlpha === false) {
  28207. this.premultipliedAlpha = false;
  28208. }
  28209. this._deterministicLockstep = options.deterministicLockstep;
  28210. this._lockstepMaxSteps = options.lockstepMaxSteps;
  28211. this._doNotHandleContextLost = options.doNotHandleContextLost ? true : false;
  28212. // Exceptions
  28213. if (navigator && navigator.userAgent) {
  28214. var ua = navigator.userAgent;
  28215. for (var _i = 0, _a = Engine.ExceptionList; _i < _a.length; _i++) {
  28216. var exception = _a[_i];
  28217. var key = exception.key;
  28218. var targets = exception.targets;
  28219. if (ua.indexOf(key) > -1) {
  28220. if (exception.capture && exception.captureConstraint) {
  28221. var capture = exception.capture;
  28222. var constraint = exception.captureConstraint;
  28223. var regex = new RegExp(capture);
  28224. var matches = regex.exec(ua);
  28225. if (matches && matches.length > 0) {
  28226. var capturedValue = parseInt(matches[matches.length - 1]);
  28227. if (capturedValue >= constraint) {
  28228. continue;
  28229. }
  28230. }
  28231. }
  28232. for (var _b = 0, targets_1 = targets; _b < targets_1.length; _b++) {
  28233. var target = targets_1[_b];
  28234. switch (target) {
  28235. case "uniformBuffer":
  28236. this.disableUniformBuffers = true;
  28237. break;
  28238. case "textureBindingOptimization":
  28239. this.disableTextureBindingOptimization = true;
  28240. break;
  28241. }
  28242. }
  28243. }
  28244. }
  28245. }
  28246. // GL
  28247. if (!options.disableWebGL2Support) {
  28248. try {
  28249. this._gl = (canvas.getContext("webgl2", options) || canvas.getContext("experimental-webgl2", options));
  28250. if (this._gl) {
  28251. this._webGLVersion = 2.0;
  28252. // Prevent weird browsers to lie :-)
  28253. if (!this._gl.deleteQuery) {
  28254. this._webGLVersion = 1.0;
  28255. }
  28256. }
  28257. }
  28258. catch (e) {
  28259. // Do nothing
  28260. }
  28261. }
  28262. if (!this._gl) {
  28263. if (!canvas) {
  28264. throw new Error("The provided canvas is null or undefined.");
  28265. }
  28266. try {
  28267. this._gl = (canvas.getContext("webgl", options) || canvas.getContext("experimental-webgl", options));
  28268. }
  28269. catch (e) {
  28270. throw new Error("WebGL not supported");
  28271. }
  28272. }
  28273. if (!this._gl) {
  28274. throw new Error("WebGL not supported");
  28275. }
  28276. // Ensures a consistent color space unpacking of textures cross browser.
  28277. this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, this._gl.NONE);
  28278. this._onCanvasFocus = function () {
  28279. _this.onCanvasFocusObservable.notifyObservers(_this);
  28280. };
  28281. this._onCanvasBlur = function () {
  28282. _this.onCanvasBlurObservable.notifyObservers(_this);
  28283. };
  28284. canvas.addEventListener("focus", this._onCanvasFocus);
  28285. canvas.addEventListener("blur", this._onCanvasBlur);
  28286. this._onBlur = function () {
  28287. if (_this.disablePerformanceMonitorInBackground) {
  28288. _this._performanceMonitor.disable();
  28289. }
  28290. _this._windowIsBackground = true;
  28291. };
  28292. this._onFocus = function () {
  28293. if (_this.disablePerformanceMonitorInBackground) {
  28294. _this._performanceMonitor.enable();
  28295. }
  28296. _this._windowIsBackground = false;
  28297. };
  28298. this._onCanvasPointerOut = function (ev) {
  28299. _this.onCanvasPointerOutObservable.notifyObservers(ev);
  28300. };
  28301. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  28302. window.addEventListener("blur", this._onBlur);
  28303. window.addEventListener("focus", this._onFocus);
  28304. }
  28305. canvas.addEventListener("pointerout", this._onCanvasPointerOut);
  28306. // Context lost
  28307. if (!this._doNotHandleContextLost) {
  28308. this._onContextLost = function (evt) {
  28309. evt.preventDefault();
  28310. _this._contextWasLost = true;
  28311. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("WebGL context lost.");
  28312. _this.onContextLostObservable.notifyObservers(_this);
  28313. };
  28314. this._onContextRestored = function () {
  28315. // Adding a timeout to avoid race condition at browser level
  28316. setTimeout(function () {
  28317. // Rebuild gl context
  28318. _this._initGLContext();
  28319. // Rebuild effects
  28320. _this._rebuildEffects();
  28321. // Rebuild textures
  28322. _this._rebuildInternalTextures();
  28323. // Rebuild buffers
  28324. _this._rebuildBuffers();
  28325. // Cache
  28326. _this.wipeCaches(true);
  28327. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("WebGL context successfully restored.");
  28328. _this.onContextRestoredObservable.notifyObservers(_this);
  28329. _this._contextWasLost = false;
  28330. }, 0);
  28331. };
  28332. canvas.addEventListener("webglcontextlost", this._onContextLost, false);
  28333. canvas.addEventListener("webglcontextrestored", this._onContextRestored, false);
  28334. }
  28335. if (!options.doNotHandleTouchAction) {
  28336. this._disableTouchAction();
  28337. }
  28338. }
  28339. else {
  28340. this._gl = canvasOrContext;
  28341. this._renderingCanvas = this._gl.canvas;
  28342. if (this._gl.renderbufferStorageMultisample) {
  28343. this._webGLVersion = 2.0;
  28344. }
  28345. var attributes = this._gl.getContextAttributes();
  28346. if (attributes) {
  28347. options.stencil = attributes.stencil;
  28348. }
  28349. }
  28350. // Viewport
  28351. var devicePixelRatio = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist() ? (window.devicePixelRatio || 1.0) : 1.0;
  28352. var limitDeviceRatio = options.limitDeviceRatio || devicePixelRatio;
  28353. this._hardwareScalingLevel = adaptToDeviceRatio ? 1.0 / Math.min(limitDeviceRatio, devicePixelRatio) : 1.0;
  28354. this.resize();
  28355. this._isStencilEnable = options.stencil ? true : false;
  28356. this._initGLContext();
  28357. if (canvas) {
  28358. // Fullscreen
  28359. this._onFullscreenChange = function () {
  28360. if (document.fullscreen !== undefined) {
  28361. _this.isFullscreen = document.fullscreen;
  28362. }
  28363. else if (document.mozFullScreen !== undefined) {
  28364. _this.isFullscreen = document.mozFullScreen;
  28365. }
  28366. else if (document.webkitIsFullScreen !== undefined) {
  28367. _this.isFullscreen = document.webkitIsFullScreen;
  28368. }
  28369. else if (document.msIsFullScreen !== undefined) {
  28370. _this.isFullscreen = document.msIsFullScreen;
  28371. }
  28372. // Pointer lock
  28373. if (_this.isFullscreen && _this._pointerLockRequested && canvas) {
  28374. canvas.requestPointerLock = canvas.requestPointerLock ||
  28375. canvas.msRequestPointerLock ||
  28376. canvas.mozRequestPointerLock ||
  28377. canvas.webkitRequestPointerLock;
  28378. if (canvas.requestPointerLock) {
  28379. canvas.requestPointerLock();
  28380. }
  28381. }
  28382. };
  28383. document.addEventListener("fullscreenchange", this._onFullscreenChange, false);
  28384. document.addEventListener("mozfullscreenchange", this._onFullscreenChange, false);
  28385. document.addEventListener("webkitfullscreenchange", this._onFullscreenChange, false);
  28386. document.addEventListener("msfullscreenchange", this._onFullscreenChange, false);
  28387. // Pointer lock
  28388. this._onPointerLockChange = function () {
  28389. _this.isPointerLock = (document.mozPointerLockElement === canvas ||
  28390. document.webkitPointerLockElement === canvas ||
  28391. document.msPointerLockElement === canvas ||
  28392. document.pointerLockElement === canvas);
  28393. };
  28394. document.addEventListener("pointerlockchange", this._onPointerLockChange, false);
  28395. document.addEventListener("mspointerlockchange", this._onPointerLockChange, false);
  28396. document.addEventListener("mozpointerlockchange", this._onPointerLockChange, false);
  28397. document.addEventListener("webkitpointerlockchange", this._onPointerLockChange, false);
  28398. this._onVRDisplayPointerRestricted = function () {
  28399. if (canvas) {
  28400. canvas.requestPointerLock();
  28401. }
  28402. };
  28403. this._onVRDisplayPointerUnrestricted = function () {
  28404. document.exitPointerLock();
  28405. };
  28406. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  28407. window.addEventListener('vrdisplaypointerrestricted', this._onVRDisplayPointerRestricted, false);
  28408. window.addEventListener('vrdisplaypointerunrestricted', this._onVRDisplayPointerUnrestricted, false);
  28409. }
  28410. }
  28411. // Create Audio Engine if needed.
  28412. if (!Engine.audioEngine && options.audioEngine && Engine.AudioEngineFactory) {
  28413. Engine.audioEngine = Engine.AudioEngineFactory(this.getRenderingCanvas());
  28414. }
  28415. // Prepare buffer pointers
  28416. for (var i = 0; i < this._caps.maxVertexAttribs; i++) {
  28417. this._currentBufferPointers[i] = new BufferPointer();
  28418. }
  28419. this._linkTrackers(this._firstBoundInternalTextureTracker, this._lastBoundInternalTextureTracker);
  28420. // Load WebVR Devices
  28421. if (options.autoEnableWebVR) {
  28422. this.initWebVR();
  28423. }
  28424. // Detect if we are running on a faulty buggy OS.
  28425. this._badOS = /iPad/i.test(navigator.userAgent) || /iPhone/i.test(navigator.userAgent);
  28426. // Detect if we are running on a faulty buggy desktop OS.
  28427. this._badDesktopOS = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
  28428. console.log("Babylon.js v" + Engine.Version + " - " + this.description);
  28429. this.enableOfflineSupport = Engine.OfflineProviderFactory !== undefined;
  28430. }
  28431. Object.defineProperty(Engine, "Instances", {
  28432. /** Gets the list of created engines */
  28433. get: function () {
  28434. return _engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].Instances;
  28435. },
  28436. enumerable: true,
  28437. configurable: true
  28438. });
  28439. Object.defineProperty(Engine, "LastCreatedEngine", {
  28440. /**
  28441. * Gets the latest created engine
  28442. */
  28443. get: function () {
  28444. return _engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine;
  28445. },
  28446. enumerable: true,
  28447. configurable: true
  28448. });
  28449. Object.defineProperty(Engine, "LastCreatedScene", {
  28450. /**
  28451. * Gets the latest created scene
  28452. */
  28453. get: function () {
  28454. return _engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene;
  28455. },
  28456. enumerable: true,
  28457. configurable: true
  28458. });
  28459. /**
  28460. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  28461. * @param flag defines which part of the materials must be marked as dirty
  28462. * @param predicate defines a predicate used to filter which materials should be affected
  28463. */
  28464. Engine.MarkAllMaterialsAsDirty = function (flag, predicate) {
  28465. for (var engineIndex = 0; engineIndex < Engine.Instances.length; engineIndex++) {
  28466. var engine = Engine.Instances[engineIndex];
  28467. for (var sceneIndex = 0; sceneIndex < engine.scenes.length; sceneIndex++) {
  28468. engine.scenes[sceneIndex].markAllMaterialsAsDirty(flag, predicate);
  28469. }
  28470. }
  28471. };
  28472. Object.defineProperty(Engine, "Version", {
  28473. /**
  28474. * Returns the current version of the framework
  28475. */
  28476. get: function () {
  28477. return "4.0.0-alpha.26";
  28478. },
  28479. enumerable: true,
  28480. configurable: true
  28481. });
  28482. Object.defineProperty(Engine.prototype, "description", {
  28483. /**
  28484. * Returns a string describing the current engine
  28485. */
  28486. get: function () {
  28487. var description = "WebGL" + this.webGLVersion;
  28488. if (this._caps.parallelShaderCompile) {
  28489. description += " - Parallel shader compilation";
  28490. }
  28491. return description;
  28492. },
  28493. enumerable: true,
  28494. configurable: true
  28495. });
  28496. Object.defineProperty(Engine, "ShadersRepository", {
  28497. /**
  28498. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28499. */
  28500. get: function () {
  28501. return _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ShadersRepository;
  28502. },
  28503. set: function (value) {
  28504. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ShadersRepository = value;
  28505. },
  28506. enumerable: true,
  28507. configurable: true
  28508. });
  28509. /**
  28510. * Method called to create the default loading screen.
  28511. * This can be overriden in your own app.
  28512. * @param canvas The rendering canvas element
  28513. * @returns The loading screen
  28514. */
  28515. Engine.DefaultLoadingScreenFactory = function (canvas) {
  28516. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_18__["_DevTools"].WarnImport("LoadingScreen");
  28517. };
  28518. Object.defineProperty(Engine.prototype, "isInVRExclusivePointerMode", {
  28519. /**
  28520. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  28521. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  28522. */
  28523. get: function () {
  28524. return this._vrExclusivePointerMode;
  28525. },
  28526. enumerable: true,
  28527. configurable: true
  28528. });
  28529. Object.defineProperty(Engine.prototype, "supportsUniformBuffers", {
  28530. /**
  28531. * Gets a boolean indicating that the engine supports uniform buffers
  28532. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28533. */
  28534. get: function () {
  28535. return this.webGLVersion > 1 && !this.disableUniformBuffers;
  28536. },
  28537. enumerable: true,
  28538. configurable: true
  28539. });
  28540. Object.defineProperty(Engine.prototype, "needPOTTextures", {
  28541. /**
  28542. * Gets a boolean indicating that only power of 2 textures are supported
  28543. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28544. */
  28545. get: function () {
  28546. return this._webGLVersion < 2 || this.forcePOTTextures;
  28547. },
  28548. enumerable: true,
  28549. configurable: true
  28550. });
  28551. Object.defineProperty(Engine.prototype, "doNotHandleContextLost", {
  28552. /**
  28553. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28554. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28555. */
  28556. get: function () {
  28557. return this._doNotHandleContextLost;
  28558. },
  28559. set: function (value) {
  28560. this._doNotHandleContextLost = value;
  28561. },
  28562. enumerable: true,
  28563. configurable: true
  28564. });
  28565. Object.defineProperty(Engine.prototype, "performanceMonitor", {
  28566. /**
  28567. * Gets the performance monitor attached to this engine
  28568. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28569. */
  28570. get: function () {
  28571. return this._performanceMonitor;
  28572. },
  28573. enumerable: true,
  28574. configurable: true
  28575. });
  28576. Object.defineProperty(Engine.prototype, "texturesSupported", {
  28577. /**
  28578. * Gets the list of texture formats supported
  28579. */
  28580. get: function () {
  28581. return this._texturesSupported;
  28582. },
  28583. enumerable: true,
  28584. configurable: true
  28585. });
  28586. Object.defineProperty(Engine.prototype, "textureFormatInUse", {
  28587. /**
  28588. * Gets the list of texture formats in use
  28589. */
  28590. get: function () {
  28591. return this._textureFormatInUse;
  28592. },
  28593. enumerable: true,
  28594. configurable: true
  28595. });
  28596. Object.defineProperty(Engine.prototype, "currentViewport", {
  28597. /**
  28598. * Gets the current viewport
  28599. */
  28600. get: function () {
  28601. return this._cachedViewport;
  28602. },
  28603. enumerable: true,
  28604. configurable: true
  28605. });
  28606. Object.defineProperty(Engine.prototype, "emptyTexture", {
  28607. /**
  28608. * Gets the default empty texture
  28609. */
  28610. get: function () {
  28611. if (!this._emptyTexture) {
  28612. this._emptyTexture = this.createRawTexture(new Uint8Array(4), 1, 1, Engine.TEXTUREFORMAT_RGBA, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  28613. }
  28614. return this._emptyTexture;
  28615. },
  28616. enumerable: true,
  28617. configurable: true
  28618. });
  28619. Object.defineProperty(Engine.prototype, "emptyTexture3D", {
  28620. /**
  28621. * Gets the default empty 3D texture
  28622. */
  28623. get: function () {
  28624. if (!this._emptyTexture3D) {
  28625. this._emptyTexture3D = this.createRawTexture3D(new Uint8Array(4), 1, 1, 1, Engine.TEXTUREFORMAT_RGBA, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  28626. }
  28627. return this._emptyTexture3D;
  28628. },
  28629. enumerable: true,
  28630. configurable: true
  28631. });
  28632. Object.defineProperty(Engine.prototype, "emptyCubeTexture", {
  28633. /**
  28634. * Gets the default empty cube texture
  28635. */
  28636. get: function () {
  28637. if (!this._emptyCubeTexture) {
  28638. var faceData = new Uint8Array(4);
  28639. var cubeData = [faceData, faceData, faceData, faceData, faceData, faceData];
  28640. this._emptyCubeTexture = this.createRawCubeTexture(cubeData, 1, Engine.TEXTUREFORMAT_RGBA, Engine.TEXTURETYPE_UNSIGNED_INT, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  28641. }
  28642. return this._emptyCubeTexture;
  28643. },
  28644. enumerable: true,
  28645. configurable: true
  28646. });
  28647. Engine.prototype._disableTouchAction = function () {
  28648. if (!this._renderingCanvas) {
  28649. return;
  28650. }
  28651. this._renderingCanvas.setAttribute("touch-action", "none");
  28652. this._renderingCanvas.style.touchAction = "none";
  28653. this._renderingCanvas.style.msTouchAction = "none";
  28654. };
  28655. Engine.prototype._rebuildInternalTextures = function () {
  28656. var currentState = this._internalTexturesCache.slice(); // Do a copy because the rebuild will add proxies
  28657. for (var _i = 0, currentState_1 = currentState; _i < currentState_1.length; _i++) {
  28658. var internalTexture = currentState_1[_i];
  28659. internalTexture._rebuild();
  28660. }
  28661. };
  28662. Engine.prototype._rebuildEffects = function () {
  28663. for (var key in this._compiledEffects) {
  28664. var effect = this._compiledEffects[key];
  28665. effect._prepareEffect();
  28666. }
  28667. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ResetCache();
  28668. };
  28669. /**
  28670. * Gets a boolean indicating if all created effects are ready
  28671. * @returns true if all effects are ready
  28672. */
  28673. Engine.prototype.areAllEffectsReady = function () {
  28674. for (var key in this._compiledEffects) {
  28675. var effect = this._compiledEffects[key];
  28676. if (!effect.isReady()) {
  28677. return false;
  28678. }
  28679. }
  28680. return true;
  28681. };
  28682. Engine.prototype._rebuildBuffers = function () {
  28683. // Index / Vertex
  28684. for (var _i = 0, _a = this.scenes; _i < _a.length; _i++) {
  28685. var scene = _a[_i];
  28686. scene.resetCachedMaterial();
  28687. scene._rebuildGeometries();
  28688. scene._rebuildTextures();
  28689. }
  28690. // Uniforms
  28691. for (var _b = 0, _c = this._uniformBuffers; _b < _c.length; _b++) {
  28692. var uniformBuffer = _c[_b];
  28693. uniformBuffer._rebuild();
  28694. }
  28695. };
  28696. Engine.prototype._initGLContext = function () {
  28697. // Caps
  28698. this._caps = new EngineCapabilities();
  28699. this._caps.maxTexturesImageUnits = this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS);
  28700. this._caps.maxCombinedTexturesImageUnits = this._gl.getParameter(this._gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS);
  28701. this._caps.maxVertexTextureImageUnits = this._gl.getParameter(this._gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS);
  28702. this._caps.maxTextureSize = this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE);
  28703. this._caps.maxCubemapTextureSize = this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE);
  28704. this._caps.maxRenderTextureSize = this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE);
  28705. this._caps.maxVertexAttribs = this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS);
  28706. this._caps.maxVaryingVectors = this._gl.getParameter(this._gl.MAX_VARYING_VECTORS);
  28707. this._caps.maxFragmentUniformVectors = this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS);
  28708. this._caps.maxVertexUniformVectors = this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS);
  28709. // Infos
  28710. this._glVersion = this._gl.getParameter(this._gl.VERSION);
  28711. var rendererInfo = this._gl.getExtension("WEBGL_debug_renderer_info");
  28712. if (rendererInfo != null) {
  28713. this._glRenderer = this._gl.getParameter(rendererInfo.UNMASKED_RENDERER_WEBGL);
  28714. this._glVendor = this._gl.getParameter(rendererInfo.UNMASKED_VENDOR_WEBGL);
  28715. }
  28716. if (!this._glVendor) {
  28717. this._glVendor = "Unknown vendor";
  28718. }
  28719. if (!this._glRenderer) {
  28720. this._glRenderer = "Unknown renderer";
  28721. }
  28722. // Constants
  28723. this._gl.HALF_FLOAT_OES = 0x8D61; // Half floating-point type (16-bit).
  28724. if (this._gl.RGBA16F !== 0x881A) {
  28725. this._gl.RGBA16F = 0x881A; // RGBA 16-bit floating-point color-renderable internal sized format.
  28726. }
  28727. if (this._gl.RGBA32F !== 0x8814) {
  28728. this._gl.RGBA32F = 0x8814; // RGBA 32-bit floating-point color-renderable internal sized format.
  28729. }
  28730. if (this._gl.DEPTH24_STENCIL8 !== 35056) {
  28731. this._gl.DEPTH24_STENCIL8 = 35056;
  28732. }
  28733. // Extensions
  28734. this._caps.standardDerivatives = this._webGLVersion > 1 || (this._gl.getExtension('OES_standard_derivatives') !== null);
  28735. this._caps.astc = this._gl.getExtension('WEBGL_compressed_texture_astc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_astc');
  28736. this._caps.s3tc = this._gl.getExtension('WEBGL_compressed_texture_s3tc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_s3tc');
  28737. this._caps.pvrtc = this._gl.getExtension('WEBGL_compressed_texture_pvrtc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_pvrtc');
  28738. this._caps.etc1 = this._gl.getExtension('WEBGL_compressed_texture_etc1') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_etc1');
  28739. this._caps.etc2 = this._gl.getExtension('WEBGL_compressed_texture_etc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_etc') ||
  28740. this._gl.getExtension('WEBGL_compressed_texture_es3_0'); // also a requirement of OpenGL ES 3
  28741. 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');
  28742. this._caps.maxAnisotropy = this._caps.textureAnisotropicFilterExtension ? this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT) : 0;
  28743. this._caps.uintIndices = this._webGLVersion > 1 || this._gl.getExtension('OES_element_index_uint') !== null;
  28744. this._caps.fragmentDepthSupported = this._webGLVersion > 1 || this._gl.getExtension('EXT_frag_depth') !== null;
  28745. this._caps.highPrecisionShaderSupported = false;
  28746. this._caps.timerQuery = this._gl.getExtension('EXT_disjoint_timer_query_webgl2') || this._gl.getExtension("EXT_disjoint_timer_query");
  28747. if (this._caps.timerQuery) {
  28748. if (this._webGLVersion === 1) {
  28749. this._gl.getQuery = this._caps.timerQuery.getQueryEXT.bind(this._caps.timerQuery);
  28750. }
  28751. this._caps.canUseTimestampForTimerQuery = this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT, this._caps.timerQuery.QUERY_COUNTER_BITS_EXT) > 0;
  28752. }
  28753. // Checks if some of the format renders first to allow the use of webgl inspector.
  28754. this._caps.colorBufferFloat = this._webGLVersion > 1 && this._gl.getExtension('EXT_color_buffer_float');
  28755. this._caps.textureFloat = (this._webGLVersion > 1 || this._gl.getExtension('OES_texture_float')) ? true : false;
  28756. this._caps.textureFloatLinearFiltering = this._caps.textureFloat && this._gl.getExtension('OES_texture_float_linear') ? true : false;
  28757. this._caps.textureFloatRender = this._caps.textureFloat && this._canRenderToFloatFramebuffer() ? true : false;
  28758. this._caps.textureHalfFloat = (this._webGLVersion > 1 || this._gl.getExtension('OES_texture_half_float')) ? true : false;
  28759. this._caps.textureHalfFloatLinearFiltering = (this._webGLVersion > 1 || (this._caps.textureHalfFloat && this._gl.getExtension('OES_texture_half_float_linear'))) ? true : false;
  28760. if (this._webGLVersion > 1) {
  28761. this._gl.HALF_FLOAT_OES = 0x140B;
  28762. }
  28763. this._caps.textureHalfFloatRender = this._caps.textureHalfFloat && this._canRenderToHalfFloatFramebuffer();
  28764. this._caps.textureLOD = (this._webGLVersion > 1 || this._gl.getExtension('EXT_shader_texture_lod')) ? true : false;
  28765. // Draw buffers
  28766. if (this._webGLVersion > 1) {
  28767. this._caps.drawBuffersExtension = true;
  28768. }
  28769. else {
  28770. var drawBuffersExtension = this._gl.getExtension('WEBGL_draw_buffers');
  28771. if (drawBuffersExtension !== null) {
  28772. this._caps.drawBuffersExtension = true;
  28773. this._gl.drawBuffers = drawBuffersExtension.drawBuffersWEBGL.bind(drawBuffersExtension);
  28774. this._gl.DRAW_FRAMEBUFFER = this._gl.FRAMEBUFFER;
  28775. for (var i = 0; i < 16; i++) {
  28776. this._gl["COLOR_ATTACHMENT" + i + "_WEBGL"] = drawBuffersExtension["COLOR_ATTACHMENT" + i + "_WEBGL"];
  28777. }
  28778. }
  28779. else {
  28780. this._caps.drawBuffersExtension = false;
  28781. }
  28782. }
  28783. // Shader compiler threads
  28784. this._caps.parallelShaderCompile = this._gl.getExtension('KHR_parallel_shader_compile');
  28785. if (this._caps.parallelShaderCompile) {
  28786. var threads = this._gl.getParameter(this._caps.parallelShaderCompile.MAX_SHADER_COMPILER_THREADS_KHR);
  28787. this._caps.parallelShaderCompile.maxShaderCompilerThreadsKHR(threads);
  28788. }
  28789. // Depth Texture
  28790. if (this._webGLVersion > 1) {
  28791. this._caps.depthTextureExtension = true;
  28792. }
  28793. else {
  28794. var depthTextureExtension = this._gl.getExtension('WEBGL_depth_texture');
  28795. if (depthTextureExtension != null) {
  28796. this._caps.depthTextureExtension = true;
  28797. this._gl.UNSIGNED_INT_24_8 = depthTextureExtension.UNSIGNED_INT_24_8_WEBGL;
  28798. }
  28799. }
  28800. // Vertex array object
  28801. if (this._webGLVersion > 1) {
  28802. this._caps.vertexArrayObject = true;
  28803. }
  28804. else {
  28805. var vertexArrayObjectExtension = this._gl.getExtension('OES_vertex_array_object');
  28806. if (vertexArrayObjectExtension != null) {
  28807. this._caps.vertexArrayObject = true;
  28808. this._gl.createVertexArray = vertexArrayObjectExtension.createVertexArrayOES.bind(vertexArrayObjectExtension);
  28809. this._gl.bindVertexArray = vertexArrayObjectExtension.bindVertexArrayOES.bind(vertexArrayObjectExtension);
  28810. this._gl.deleteVertexArray = vertexArrayObjectExtension.deleteVertexArrayOES.bind(vertexArrayObjectExtension);
  28811. }
  28812. else {
  28813. this._caps.vertexArrayObject = false;
  28814. }
  28815. }
  28816. // Instances count
  28817. if (this._webGLVersion > 1) {
  28818. this._caps.instancedArrays = true;
  28819. }
  28820. else {
  28821. var instanceExtension = this._gl.getExtension('ANGLE_instanced_arrays');
  28822. if (instanceExtension != null) {
  28823. this._caps.instancedArrays = true;
  28824. this._gl.drawArraysInstanced = instanceExtension.drawArraysInstancedANGLE.bind(instanceExtension);
  28825. this._gl.drawElementsInstanced = instanceExtension.drawElementsInstancedANGLE.bind(instanceExtension);
  28826. this._gl.vertexAttribDivisor = instanceExtension.vertexAttribDivisorANGLE.bind(instanceExtension);
  28827. }
  28828. else {
  28829. this._caps.instancedArrays = false;
  28830. }
  28831. }
  28832. // Intelligently add supported compressed formats in order to check for.
  28833. // Check for ASTC support first as it is most powerful and to be very cross platform.
  28834. // Next PVRTC & DXT, which are probably superior to ETC1/2.
  28835. // Likely no hardware which supports both PVR & DXT, so order matters little.
  28836. // ETC2 is newer and handles ETC1 (no alpha capability), so check for first.
  28837. if (this._caps.astc) {
  28838. this.texturesSupported.push('-astc.ktx');
  28839. }
  28840. if (this._caps.s3tc) {
  28841. this.texturesSupported.push('-dxt.ktx');
  28842. }
  28843. if (this._caps.pvrtc) {
  28844. this.texturesSupported.push('-pvrtc.ktx');
  28845. }
  28846. if (this._caps.etc2) {
  28847. this.texturesSupported.push('-etc2.ktx');
  28848. }
  28849. if (this._caps.etc1) {
  28850. this.texturesSupported.push('-etc1.ktx');
  28851. }
  28852. if (this._gl.getShaderPrecisionFormat) {
  28853. var vertex_highp = this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER, this._gl.HIGH_FLOAT);
  28854. var fragment_highp = this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER, this._gl.HIGH_FLOAT);
  28855. if (vertex_highp && fragment_highp) {
  28856. this._caps.highPrecisionShaderSupported = vertex_highp.precision !== 0 && fragment_highp.precision !== 0;
  28857. }
  28858. }
  28859. // Depth buffer
  28860. this.setDepthBuffer(true);
  28861. this.setDepthFunctionToLessOrEqual();
  28862. this.setDepthWrite(true);
  28863. // Texture maps
  28864. this._maxSimultaneousTextures = this._caps.maxCombinedTexturesImageUnits;
  28865. for (var slot = 0; slot < this._maxSimultaneousTextures; slot++) {
  28866. this._nextFreeTextureSlots.push(slot);
  28867. }
  28868. };
  28869. Object.defineProperty(Engine.prototype, "webGLVersion", {
  28870. /**
  28871. * Gets version of the current webGL context
  28872. */
  28873. get: function () {
  28874. return this._webGLVersion;
  28875. },
  28876. enumerable: true,
  28877. configurable: true
  28878. });
  28879. Object.defineProperty(Engine.prototype, "isStencilEnable", {
  28880. /**
  28881. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28882. */
  28883. get: function () {
  28884. return this._isStencilEnable;
  28885. },
  28886. enumerable: true,
  28887. configurable: true
  28888. });
  28889. Engine.prototype._prepareWorkingCanvas = function () {
  28890. if (this._workingCanvas) {
  28891. return;
  28892. }
  28893. this._workingCanvas = document.createElement("canvas");
  28894. var context = this._workingCanvas.getContext("2d");
  28895. if (context) {
  28896. this._workingContext = context;
  28897. }
  28898. };
  28899. /**
  28900. * Reset the texture cache to empty state
  28901. */
  28902. Engine.prototype.resetTextureCache = function () {
  28903. for (var key in this._boundTexturesCache) {
  28904. if (!this._boundTexturesCache.hasOwnProperty(key)) {
  28905. continue;
  28906. }
  28907. var boundTexture = this._boundTexturesCache[key];
  28908. if (boundTexture) {
  28909. this._removeDesignatedSlot(boundTexture);
  28910. }
  28911. this._boundTexturesCache[key] = null;
  28912. }
  28913. if (!this.disableTextureBindingOptimization) {
  28914. this._nextFreeTextureSlots = [];
  28915. for (var slot = 0; slot < this._maxSimultaneousTextures; slot++) {
  28916. this._nextFreeTextureSlots.push(slot);
  28917. }
  28918. }
  28919. this._currentTextureChannel = -1;
  28920. };
  28921. /**
  28922. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28923. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28924. * @returns true if engine is in deterministic lock step mode
  28925. */
  28926. Engine.prototype.isDeterministicLockStep = function () {
  28927. return this._deterministicLockstep;
  28928. };
  28929. /**
  28930. * Gets the max steps when engine is running in deterministic lock step
  28931. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28932. * @returns the max steps
  28933. */
  28934. Engine.prototype.getLockstepMaxSteps = function () {
  28935. return this._lockstepMaxSteps;
  28936. };
  28937. /**
  28938. * Gets an object containing information about the current webGL context
  28939. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28940. */
  28941. Engine.prototype.getGlInfo = function () {
  28942. return {
  28943. vendor: this._glVendor,
  28944. renderer: this._glRenderer,
  28945. version: this._glVersion
  28946. };
  28947. };
  28948. /**
  28949. * Gets current aspect ratio
  28950. * @param camera defines the camera to use to get the aspect ratio
  28951. * @param useScreen defines if screen size must be used (or the current render target if any)
  28952. * @returns a number defining the aspect ratio
  28953. */
  28954. Engine.prototype.getAspectRatio = function (camera, useScreen) {
  28955. if (useScreen === void 0) { useScreen = false; }
  28956. var viewport = camera.viewport;
  28957. return (this.getRenderWidth(useScreen) * viewport.width) / (this.getRenderHeight(useScreen) * viewport.height);
  28958. };
  28959. /**
  28960. * Gets current screen aspect ratio
  28961. * @returns a number defining the aspect ratio
  28962. */
  28963. Engine.prototype.getScreenAspectRatio = function () {
  28964. return (this.getRenderWidth(true)) / (this.getRenderHeight(true));
  28965. };
  28966. /**
  28967. * Gets the current render width
  28968. * @param useScreen defines if screen size must be used (or the current render target if any)
  28969. * @returns a number defining the current render width
  28970. */
  28971. Engine.prototype.getRenderWidth = function (useScreen) {
  28972. if (useScreen === void 0) { useScreen = false; }
  28973. if (!useScreen && this._currentRenderTarget) {
  28974. return this._currentRenderTarget.width;
  28975. }
  28976. return this._gl.drawingBufferWidth;
  28977. };
  28978. /**
  28979. * Gets the current render height
  28980. * @param useScreen defines if screen size must be used (or the current render target if any)
  28981. * @returns a number defining the current render height
  28982. */
  28983. Engine.prototype.getRenderHeight = function (useScreen) {
  28984. if (useScreen === void 0) { useScreen = false; }
  28985. if (!useScreen && this._currentRenderTarget) {
  28986. return this._currentRenderTarget.height;
  28987. }
  28988. return this._gl.drawingBufferHeight;
  28989. };
  28990. /**
  28991. * Gets the HTML canvas attached with the current webGL context
  28992. * @returns a HTML canvas
  28993. */
  28994. Engine.prototype.getRenderingCanvas = function () {
  28995. return this._renderingCanvas;
  28996. };
  28997. /**
  28998. * Gets the client rect of the HTML canvas attached with the current webGL context
  28999. * @returns a client rectanglee
  29000. */
  29001. Engine.prototype.getRenderingCanvasClientRect = function () {
  29002. if (!this._renderingCanvas) {
  29003. return null;
  29004. }
  29005. return this._renderingCanvas.getBoundingClientRect();
  29006. };
  29007. /**
  29008. * Defines the hardware scaling level.
  29009. * By default the hardware scaling level is computed from the window device ratio.
  29010. * 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.
  29011. * @param level defines the level to use
  29012. */
  29013. Engine.prototype.setHardwareScalingLevel = function (level) {
  29014. this._hardwareScalingLevel = level;
  29015. this.resize();
  29016. };
  29017. /**
  29018. * Gets the current hardware scaling level.
  29019. * By default the hardware scaling level is computed from the window device ratio.
  29020. * 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.
  29021. * @returns a number indicating the current hardware scaling level
  29022. */
  29023. Engine.prototype.getHardwareScalingLevel = function () {
  29024. return this._hardwareScalingLevel;
  29025. };
  29026. /**
  29027. * Gets the list of loaded textures
  29028. * @returns an array containing all loaded textures
  29029. */
  29030. Engine.prototype.getLoadedTexturesCache = function () {
  29031. return this._internalTexturesCache;
  29032. };
  29033. /**
  29034. * Gets the object containing all engine capabilities
  29035. * @returns the EngineCapabilities object
  29036. */
  29037. Engine.prototype.getCaps = function () {
  29038. return this._caps;
  29039. };
  29040. /**
  29041. * Gets the current depth function
  29042. * @returns a number defining the depth function
  29043. */
  29044. Engine.prototype.getDepthFunction = function () {
  29045. return this._depthCullingState.depthFunc;
  29046. };
  29047. /**
  29048. * Sets the current depth function
  29049. * @param depthFunc defines the function to use
  29050. */
  29051. Engine.prototype.setDepthFunction = function (depthFunc) {
  29052. this._depthCullingState.depthFunc = depthFunc;
  29053. };
  29054. /**
  29055. * Sets the current depth function to GREATER
  29056. */
  29057. Engine.prototype.setDepthFunctionToGreater = function () {
  29058. this._depthCullingState.depthFunc = this._gl.GREATER;
  29059. };
  29060. /**
  29061. * Sets the current depth function to GEQUAL
  29062. */
  29063. Engine.prototype.setDepthFunctionToGreaterOrEqual = function () {
  29064. this._depthCullingState.depthFunc = this._gl.GEQUAL;
  29065. };
  29066. /**
  29067. * Sets the current depth function to LESS
  29068. */
  29069. Engine.prototype.setDepthFunctionToLess = function () {
  29070. this._depthCullingState.depthFunc = this._gl.LESS;
  29071. };
  29072. /**
  29073. * Sets the current depth function to LEQUAL
  29074. */
  29075. Engine.prototype.setDepthFunctionToLessOrEqual = function () {
  29076. this._depthCullingState.depthFunc = this._gl.LEQUAL;
  29077. };
  29078. /**
  29079. * Gets a boolean indicating if stencil buffer is enabled
  29080. * @returns the current stencil buffer state
  29081. */
  29082. Engine.prototype.getStencilBuffer = function () {
  29083. return this._stencilState.stencilTest;
  29084. };
  29085. /**
  29086. * Enable or disable the stencil buffer
  29087. * @param enable defines if the stencil buffer must be enabled or disabled
  29088. */
  29089. Engine.prototype.setStencilBuffer = function (enable) {
  29090. this._stencilState.stencilTest = enable;
  29091. };
  29092. /**
  29093. * Gets the current stencil mask
  29094. * @returns a number defining the new stencil mask to use
  29095. */
  29096. Engine.prototype.getStencilMask = function () {
  29097. return this._stencilState.stencilMask;
  29098. };
  29099. /**
  29100. * Sets the current stencil mask
  29101. * @param mask defines the new stencil mask to use
  29102. */
  29103. Engine.prototype.setStencilMask = function (mask) {
  29104. this._stencilState.stencilMask = mask;
  29105. };
  29106. /**
  29107. * Gets the current stencil function
  29108. * @returns a number defining the stencil function to use
  29109. */
  29110. Engine.prototype.getStencilFunction = function () {
  29111. return this._stencilState.stencilFunc;
  29112. };
  29113. /**
  29114. * Gets the current stencil reference value
  29115. * @returns a number defining the stencil reference value to use
  29116. */
  29117. Engine.prototype.getStencilFunctionReference = function () {
  29118. return this._stencilState.stencilFuncRef;
  29119. };
  29120. /**
  29121. * Gets the current stencil mask
  29122. * @returns a number defining the stencil mask to use
  29123. */
  29124. Engine.prototype.getStencilFunctionMask = function () {
  29125. return this._stencilState.stencilFuncMask;
  29126. };
  29127. /**
  29128. * Sets the current stencil function
  29129. * @param stencilFunc defines the new stencil function to use
  29130. */
  29131. Engine.prototype.setStencilFunction = function (stencilFunc) {
  29132. this._stencilState.stencilFunc = stencilFunc;
  29133. };
  29134. /**
  29135. * Sets the current stencil reference
  29136. * @param reference defines the new stencil reference to use
  29137. */
  29138. Engine.prototype.setStencilFunctionReference = function (reference) {
  29139. this._stencilState.stencilFuncRef = reference;
  29140. };
  29141. /**
  29142. * Sets the current stencil mask
  29143. * @param mask defines the new stencil mask to use
  29144. */
  29145. Engine.prototype.setStencilFunctionMask = function (mask) {
  29146. this._stencilState.stencilFuncMask = mask;
  29147. };
  29148. /**
  29149. * Gets the current stencil operation when stencil fails
  29150. * @returns a number defining stencil operation to use when stencil fails
  29151. */
  29152. Engine.prototype.getStencilOperationFail = function () {
  29153. return this._stencilState.stencilOpStencilFail;
  29154. };
  29155. /**
  29156. * Gets the current stencil operation when depth fails
  29157. * @returns a number defining stencil operation to use when depth fails
  29158. */
  29159. Engine.prototype.getStencilOperationDepthFail = function () {
  29160. return this._stencilState.stencilOpDepthFail;
  29161. };
  29162. /**
  29163. * Gets the current stencil operation when stencil passes
  29164. * @returns a number defining stencil operation to use when stencil passes
  29165. */
  29166. Engine.prototype.getStencilOperationPass = function () {
  29167. return this._stencilState.stencilOpStencilDepthPass;
  29168. };
  29169. /**
  29170. * Sets the stencil operation to use when stencil fails
  29171. * @param operation defines the stencil operation to use when stencil fails
  29172. */
  29173. Engine.prototype.setStencilOperationFail = function (operation) {
  29174. this._stencilState.stencilOpStencilFail = operation;
  29175. };
  29176. /**
  29177. * Sets the stencil operation to use when depth fails
  29178. * @param operation defines the stencil operation to use when depth fails
  29179. */
  29180. Engine.prototype.setStencilOperationDepthFail = function (operation) {
  29181. this._stencilState.stencilOpDepthFail = operation;
  29182. };
  29183. /**
  29184. * Sets the stencil operation to use when stencil passes
  29185. * @param operation defines the stencil operation to use when stencil passes
  29186. */
  29187. Engine.prototype.setStencilOperationPass = function (operation) {
  29188. this._stencilState.stencilOpStencilDepthPass = operation;
  29189. };
  29190. /**
  29191. * Sets a boolean indicating if the dithering state is enabled or disabled
  29192. * @param value defines the dithering state
  29193. */
  29194. Engine.prototype.setDitheringState = function (value) {
  29195. if (value) {
  29196. this._gl.enable(this._gl.DITHER);
  29197. }
  29198. else {
  29199. this._gl.disable(this._gl.DITHER);
  29200. }
  29201. };
  29202. /**
  29203. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  29204. * @param value defines the rasterizer state
  29205. */
  29206. Engine.prototype.setRasterizerState = function (value) {
  29207. if (value) {
  29208. this._gl.disable(this._gl.RASTERIZER_DISCARD);
  29209. }
  29210. else {
  29211. this._gl.enable(this._gl.RASTERIZER_DISCARD);
  29212. }
  29213. };
  29214. /**
  29215. * stop executing a render loop function and remove it from the execution array
  29216. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  29217. */
  29218. Engine.prototype.stopRenderLoop = function (renderFunction) {
  29219. if (!renderFunction) {
  29220. this._activeRenderLoops = [];
  29221. return;
  29222. }
  29223. var index = this._activeRenderLoops.indexOf(renderFunction);
  29224. if (index >= 0) {
  29225. this._activeRenderLoops.splice(index, 1);
  29226. }
  29227. };
  29228. /** @hidden */
  29229. Engine.prototype._renderLoop = function () {
  29230. if (!this._contextWasLost) {
  29231. var shouldRender = true;
  29232. if (!this.renderEvenInBackground && this._windowIsBackground) {
  29233. shouldRender = false;
  29234. }
  29235. if (shouldRender) {
  29236. // Start new frame
  29237. this.beginFrame();
  29238. for (var index = 0; index < this._activeRenderLoops.length; index++) {
  29239. var renderFunction = this._activeRenderLoops[index];
  29240. renderFunction();
  29241. }
  29242. // Present
  29243. this.endFrame();
  29244. }
  29245. }
  29246. if (this._activeRenderLoops.length > 0) {
  29247. // Register new frame
  29248. if (this.customAnimationFrameRequester) {
  29249. this.customAnimationFrameRequester.requestID = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this.customAnimationFrameRequester.renderFunction || this._bindedRenderFunction, this.customAnimationFrameRequester);
  29250. this._frameHandler = this.customAnimationFrameRequester.requestID;
  29251. }
  29252. else if (this._vrDisplay && this._vrDisplay.isPresenting) {
  29253. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction, this._vrDisplay);
  29254. }
  29255. else {
  29256. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction);
  29257. }
  29258. }
  29259. else {
  29260. this._renderingQueueLaunched = false;
  29261. }
  29262. };
  29263. /**
  29264. * Register and execute a render loop. The engine can have more than one render function
  29265. * @param renderFunction defines the function to continuously execute
  29266. */
  29267. Engine.prototype.runRenderLoop = function (renderFunction) {
  29268. if (this._activeRenderLoops.indexOf(renderFunction) !== -1) {
  29269. return;
  29270. }
  29271. this._activeRenderLoops.push(renderFunction);
  29272. if (!this._renderingQueueLaunched) {
  29273. this._renderingQueueLaunched = true;
  29274. this._bindedRenderFunction = this._renderLoop.bind(this);
  29275. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction);
  29276. }
  29277. };
  29278. /**
  29279. * Toggle full screen mode
  29280. * @param requestPointerLock defines if a pointer lock should be requested from the user
  29281. */
  29282. Engine.prototype.switchFullscreen = function (requestPointerLock) {
  29283. if (this.isFullscreen) {
  29284. this.exitFullscreen();
  29285. }
  29286. else {
  29287. this.enterFullscreen(requestPointerLock);
  29288. }
  29289. };
  29290. /**
  29291. * Enters full screen mode
  29292. * @param requestPointerLock defines if a pointer lock should be requested from the user
  29293. */
  29294. Engine.prototype.enterFullscreen = function (requestPointerLock) {
  29295. if (!this.isFullscreen) {
  29296. this._pointerLockRequested = requestPointerLock;
  29297. if (this._renderingCanvas) {
  29298. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].RequestFullscreen(this._renderingCanvas);
  29299. }
  29300. }
  29301. };
  29302. /**
  29303. * Exits full screen mode
  29304. */
  29305. Engine.prototype.exitFullscreen = function () {
  29306. if (this.isFullscreen) {
  29307. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].ExitFullscreen();
  29308. }
  29309. };
  29310. /**
  29311. * Clear the current render buffer or the current render target (if any is set up)
  29312. * @param color defines the color to use
  29313. * @param backBuffer defines if the back buffer must be cleared
  29314. * @param depth defines if the depth buffer must be cleared
  29315. * @param stencil defines if the stencil buffer must be cleared
  29316. */
  29317. Engine.prototype.clear = function (color, backBuffer, depth, stencil) {
  29318. if (stencil === void 0) { stencil = false; }
  29319. this.applyStates();
  29320. var mode = 0;
  29321. if (backBuffer && color) {
  29322. this._gl.clearColor(color.r, color.g, color.b, color.a !== undefined ? color.a : 1.0);
  29323. mode |= this._gl.COLOR_BUFFER_BIT;
  29324. }
  29325. if (depth) {
  29326. this._gl.clearDepth(1.0);
  29327. mode |= this._gl.DEPTH_BUFFER_BIT;
  29328. }
  29329. if (stencil) {
  29330. this._gl.clearStencil(0);
  29331. mode |= this._gl.STENCIL_BUFFER_BIT;
  29332. }
  29333. this._gl.clear(mode);
  29334. };
  29335. /**
  29336. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  29337. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29338. * @param y defines the y-coordinate of the corner of the clear rectangle
  29339. * @param width defines the width of the clear rectangle
  29340. * @param height defines the height of the clear rectangle
  29341. * @param clearColor defines the clear color
  29342. */
  29343. Engine.prototype.scissorClear = function (x, y, width, height, clearColor) {
  29344. this.enableScissor(x, y, width, height);
  29345. this.clear(clearColor, true, true, true);
  29346. this.disableScissor();
  29347. };
  29348. /**
  29349. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  29350. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29351. * @param y defines the y-coordinate of the corner of the clear rectangle
  29352. * @param width defines the width of the clear rectangle
  29353. * @param height defines the height of the clear rectangle
  29354. */
  29355. Engine.prototype.enableScissor = function (x, y, width, height) {
  29356. var gl = this._gl;
  29357. // Change state
  29358. gl.enable(gl.SCISSOR_TEST);
  29359. gl.scissor(x, y, width, height);
  29360. };
  29361. /**
  29362. * Disable previously set scissor test rectangle
  29363. */
  29364. Engine.prototype.disableScissor = function () {
  29365. var gl = this._gl;
  29366. gl.disable(gl.SCISSOR_TEST);
  29367. };
  29368. /** @hidden */
  29369. Engine.prototype._viewport = function (x, y, width, height) {
  29370. if (x !== this._viewportCached.x ||
  29371. y !== this._viewportCached.y ||
  29372. width !== this._viewportCached.z ||
  29373. height !== this._viewportCached.w) {
  29374. this._viewportCached.x = x;
  29375. this._viewportCached.y = y;
  29376. this._viewportCached.z = width;
  29377. this._viewportCached.w = height;
  29378. this._gl.viewport(x, y, width, height);
  29379. }
  29380. };
  29381. /**
  29382. * Set the WebGL's viewport
  29383. * @param viewport defines the viewport element to be used
  29384. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29385. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29386. */
  29387. Engine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {
  29388. var width = requiredWidth || this.getRenderWidth();
  29389. var height = requiredHeight || this.getRenderHeight();
  29390. var x = viewport.x || 0;
  29391. var y = viewport.y || 0;
  29392. this._cachedViewport = viewport;
  29393. this._viewport(x * width, y * height, width * viewport.width, height * viewport.height);
  29394. };
  29395. /**
  29396. * Directly set the WebGL Viewport
  29397. * @param x defines the x coordinate of the viewport (in screen space)
  29398. * @param y defines the y coordinate of the viewport (in screen space)
  29399. * @param width defines the width of the viewport (in screen space)
  29400. * @param height defines the height of the viewport (in screen space)
  29401. * @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
  29402. */
  29403. Engine.prototype.setDirectViewport = function (x, y, width, height) {
  29404. var currentViewport = this._cachedViewport;
  29405. this._cachedViewport = null;
  29406. this._viewport(x, y, width, height);
  29407. return currentViewport;
  29408. };
  29409. /**
  29410. * Begin a new frame
  29411. */
  29412. Engine.prototype.beginFrame = function () {
  29413. this.onBeginFrameObservable.notifyObservers(this);
  29414. this._measureFps();
  29415. };
  29416. /**
  29417. * Enf the current frame
  29418. */
  29419. Engine.prototype.endFrame = function () {
  29420. // Force a flush in case we are using a bad OS.
  29421. if (this._badOS) {
  29422. this.flushFramebuffer();
  29423. }
  29424. // Submit frame to the vr device, if enabled
  29425. if (this._vrDisplay && this._vrDisplay.isPresenting) {
  29426. // TODO: We should only submit the frame if we read frameData successfully.
  29427. try {
  29428. this._vrDisplay.submitFrame();
  29429. }
  29430. catch (e) {
  29431. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].Warn("webVR submitFrame has had an unexpected failure: " + e);
  29432. }
  29433. }
  29434. this.onEndFrameObservable.notifyObservers(this);
  29435. };
  29436. /**
  29437. * Resize the view according to the canvas' size
  29438. */
  29439. Engine.prototype.resize = function () {
  29440. // We're not resizing the size of the canvas while in VR mode & presenting
  29441. if (!(this._vrDisplay && this._vrDisplay.isPresenting)) {
  29442. var width = this._renderingCanvas ? this._renderingCanvas.clientWidth : window.innerWidth;
  29443. var height = this._renderingCanvas ? this._renderingCanvas.clientHeight : window.innerHeight;
  29444. this.setSize(width / this._hardwareScalingLevel, height / this._hardwareScalingLevel);
  29445. }
  29446. };
  29447. /**
  29448. * Force a specific size of the canvas
  29449. * @param width defines the new canvas' width
  29450. * @param height defines the new canvas' height
  29451. */
  29452. Engine.prototype.setSize = function (width, height) {
  29453. if (!this._renderingCanvas) {
  29454. return;
  29455. }
  29456. if (this._renderingCanvas.width === width && this._renderingCanvas.height === height) {
  29457. return;
  29458. }
  29459. this._renderingCanvas.width = width;
  29460. this._renderingCanvas.height = height;
  29461. for (var index = 0; index < this.scenes.length; index++) {
  29462. var scene = this.scenes[index];
  29463. for (var camIndex = 0; camIndex < scene.cameras.length; camIndex++) {
  29464. var cam = scene.cameras[camIndex];
  29465. cam._currentRenderId = 0;
  29466. }
  29467. }
  29468. if (this.onResizeObservable.hasObservers) {
  29469. this.onResizeObservable.notifyObservers(this);
  29470. }
  29471. };
  29472. // WebVR functions
  29473. /**
  29474. * Gets a boolean indicating if a webVR device was detected
  29475. * @returns true if a webVR device was detected
  29476. */
  29477. Engine.prototype.isVRDevicePresent = function () {
  29478. return !!this._vrDisplay;
  29479. };
  29480. /**
  29481. * Gets the current webVR device
  29482. * @returns the current webVR device (or null)
  29483. */
  29484. Engine.prototype.getVRDevice = function () {
  29485. return this._vrDisplay;
  29486. };
  29487. /**
  29488. * Initializes a webVR display and starts listening to display change events
  29489. * The onVRDisplayChangedObservable will be notified upon these changes
  29490. * @returns The onVRDisplayChangedObservable
  29491. */
  29492. Engine.prototype.initWebVR = function () {
  29493. this.initWebVRAsync();
  29494. return this.onVRDisplayChangedObservable;
  29495. };
  29496. /**
  29497. * Initializes a webVR display and starts listening to display change events
  29498. * The onVRDisplayChangedObservable will be notified upon these changes
  29499. * @returns A promise containing a VRDisplay and if vr is supported
  29500. */
  29501. Engine.prototype.initWebVRAsync = function () {
  29502. var _this = this;
  29503. var notifyObservers = function () {
  29504. var eventArgs = {
  29505. vrDisplay: _this._vrDisplay,
  29506. vrSupported: _this._vrSupported
  29507. };
  29508. _this.onVRDisplayChangedObservable.notifyObservers(eventArgs);
  29509. _this._webVRInitPromise = new Promise(function (res) { res(eventArgs); });
  29510. };
  29511. if (!this._onVrDisplayConnect) {
  29512. this._onVrDisplayConnect = function (event) {
  29513. _this._vrDisplay = event.display;
  29514. notifyObservers();
  29515. };
  29516. this._onVrDisplayDisconnect = function () {
  29517. _this._vrDisplay.cancelAnimationFrame(_this._frameHandler);
  29518. _this._vrDisplay = undefined;
  29519. _this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(_this._bindedRenderFunction);
  29520. notifyObservers();
  29521. };
  29522. this._onVrDisplayPresentChange = function () {
  29523. _this._vrExclusivePointerMode = _this._vrDisplay && _this._vrDisplay.isPresenting;
  29524. };
  29525. window.addEventListener('vrdisplayconnect', this._onVrDisplayConnect);
  29526. window.addEventListener('vrdisplaydisconnect', this._onVrDisplayDisconnect);
  29527. window.addEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  29528. }
  29529. this._webVRInitPromise = this._webVRInitPromise || this._getVRDisplaysAsync();
  29530. this._webVRInitPromise.then(notifyObservers);
  29531. return this._webVRInitPromise;
  29532. };
  29533. /**
  29534. * Call this function to switch to webVR mode
  29535. * Will do nothing if webVR is not supported or if there is no webVR device
  29536. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29537. */
  29538. Engine.prototype.enableVR = function () {
  29539. var _this = this;
  29540. if (this._vrDisplay && !this._vrDisplay.isPresenting) {
  29541. var onResolved = function () {
  29542. _this.onVRRequestPresentComplete.notifyObservers(true);
  29543. _this._onVRFullScreenTriggered();
  29544. };
  29545. var onRejected = function () {
  29546. _this.onVRRequestPresentComplete.notifyObservers(false);
  29547. };
  29548. this.onVRRequestPresentStart.notifyObservers(this);
  29549. this._vrDisplay.requestPresent([{ source: this.getRenderingCanvas() }]).then(onResolved).catch(onRejected);
  29550. }
  29551. };
  29552. /**
  29553. * Call this function to leave webVR mode
  29554. * Will do nothing if webVR is not supported or if there is no webVR device
  29555. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29556. */
  29557. Engine.prototype.disableVR = function () {
  29558. if (this._vrDisplay && this._vrDisplay.isPresenting) {
  29559. this._vrDisplay.exitPresent().then(this._onVRFullScreenTriggered).catch(this._onVRFullScreenTriggered);
  29560. }
  29561. };
  29562. Engine.prototype._getVRDisplaysAsync = function () {
  29563. var _this = this;
  29564. return new Promise(function (res) {
  29565. if (navigator.getVRDisplays) {
  29566. navigator.getVRDisplays().then(function (devices) {
  29567. _this._vrSupported = true;
  29568. // note that devices may actually be an empty array. This is fine;
  29569. // we expect this._vrDisplay to be undefined in this case.
  29570. _this._vrDisplay = devices[0];
  29571. res({
  29572. vrDisplay: _this._vrDisplay,
  29573. vrSupported: _this._vrSupported
  29574. });
  29575. });
  29576. }
  29577. else {
  29578. _this._vrDisplay = undefined;
  29579. _this._vrSupported = false;
  29580. res({
  29581. vrDisplay: _this._vrDisplay,
  29582. vrSupported: _this._vrSupported
  29583. });
  29584. }
  29585. });
  29586. };
  29587. /**
  29588. * Binds the frame buffer to the specified texture.
  29589. * @param texture The texture to render to or null for the default canvas
  29590. * @param faceIndex The face of the texture to render to in case of cube texture
  29591. * @param requiredWidth The width of the target to render to
  29592. * @param requiredHeight The height of the target to render to
  29593. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29594. * @param depthStencilTexture The depth stencil texture to use to render
  29595. * @param lodLevel defines le lod level to bind to the frame buffer
  29596. */
  29597. Engine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport, depthStencilTexture, lodLevel) {
  29598. if (lodLevel === void 0) { lodLevel = 0; }
  29599. if (this._currentRenderTarget) {
  29600. this.unBindFramebuffer(this._currentRenderTarget);
  29601. }
  29602. this._currentRenderTarget = texture;
  29603. this.bindUnboundFramebuffer(texture._MSAAFramebuffer ? texture._MSAAFramebuffer : texture._framebuffer);
  29604. var gl = this._gl;
  29605. if (texture.isCube) {
  29606. if (faceIndex === undefined) {
  29607. faceIndex = 0;
  29608. }
  29609. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture._webGLTexture, lodLevel);
  29610. if (depthStencilTexture) {
  29611. if (depthStencilTexture._generateStencilBuffer) {
  29612. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, depthStencilTexture._webGLTexture, lodLevel);
  29613. }
  29614. else {
  29615. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, depthStencilTexture._webGLTexture, lodLevel);
  29616. }
  29617. }
  29618. }
  29619. if (this._cachedViewport && !forceFullscreenViewport) {
  29620. this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);
  29621. }
  29622. else {
  29623. if (!requiredWidth) {
  29624. requiredWidth = texture.width;
  29625. if (lodLevel) {
  29626. requiredWidth = requiredWidth / Math.pow(2, lodLevel);
  29627. }
  29628. }
  29629. if (!requiredHeight) {
  29630. requiredHeight = texture.height;
  29631. if (lodLevel) {
  29632. requiredHeight = requiredHeight / Math.pow(2, lodLevel);
  29633. }
  29634. }
  29635. this._viewport(0, 0, requiredWidth, requiredHeight);
  29636. }
  29637. this.wipeCaches();
  29638. };
  29639. Engine.prototype.bindUnboundFramebuffer = function (framebuffer) {
  29640. if (this._currentFramebuffer !== framebuffer) {
  29641. this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, framebuffer);
  29642. this._currentFramebuffer = framebuffer;
  29643. }
  29644. };
  29645. /**
  29646. * Unbind the current render target texture from the webGL context
  29647. * @param texture defines the render target texture to unbind
  29648. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29649. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29650. */
  29651. Engine.prototype.unBindFramebuffer = function (texture, disableGenerateMipMaps, onBeforeUnbind) {
  29652. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  29653. this._currentRenderTarget = null;
  29654. // If MSAA, we need to bitblt back to main texture
  29655. var gl = this._gl;
  29656. if (texture._MSAAFramebuffer) {
  29657. gl.bindFramebuffer(gl.READ_FRAMEBUFFER, texture._MSAAFramebuffer);
  29658. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, texture._framebuffer);
  29659. gl.blitFramebuffer(0, 0, texture.width, texture.height, 0, 0, texture.width, texture.height, gl.COLOR_BUFFER_BIT, gl.NEAREST);
  29660. }
  29661. if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {
  29662. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  29663. gl.generateMipmap(gl.TEXTURE_2D);
  29664. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  29665. }
  29666. if (onBeforeUnbind) {
  29667. if (texture._MSAAFramebuffer) {
  29668. // Bind the correct framebuffer
  29669. this.bindUnboundFramebuffer(texture._framebuffer);
  29670. }
  29671. onBeforeUnbind();
  29672. }
  29673. this.bindUnboundFramebuffer(null);
  29674. };
  29675. /**
  29676. * Unbind a list of render target textures from the webGL context
  29677. * This is used only when drawBuffer extension or webGL2 are active
  29678. * @param textures defines the render target textures to unbind
  29679. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29680. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29681. */
  29682. Engine.prototype.unBindMultiColorAttachmentFramebuffer = function (textures, disableGenerateMipMaps, onBeforeUnbind) {
  29683. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  29684. this._currentRenderTarget = null;
  29685. // If MSAA, we need to bitblt back to main texture
  29686. var gl = this._gl;
  29687. if (textures[0]._MSAAFramebuffer) {
  29688. gl.bindFramebuffer(gl.READ_FRAMEBUFFER, textures[0]._MSAAFramebuffer);
  29689. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, textures[0]._framebuffer);
  29690. var attachments = textures[0]._attachments;
  29691. if (!attachments) {
  29692. attachments = new Array(textures.length);
  29693. textures[0]._attachments = attachments;
  29694. }
  29695. for (var i = 0; i < textures.length; i++) {
  29696. var texture = textures[i];
  29697. for (var j = 0; j < attachments.length; j++) {
  29698. attachments[j] = gl.NONE;
  29699. }
  29700. attachments[i] = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  29701. gl.readBuffer(attachments[i]);
  29702. gl.drawBuffers(attachments);
  29703. gl.blitFramebuffer(0, 0, texture.width, texture.height, 0, 0, texture.width, texture.height, gl.COLOR_BUFFER_BIT, gl.NEAREST);
  29704. }
  29705. for (var i = 0; i < attachments.length; i++) {
  29706. attachments[i] = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  29707. }
  29708. gl.drawBuffers(attachments);
  29709. }
  29710. for (var i = 0; i < textures.length; i++) {
  29711. var texture = textures[i];
  29712. if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {
  29713. this._bindTextureDirectly(gl.TEXTURE_2D, texture);
  29714. gl.generateMipmap(gl.TEXTURE_2D);
  29715. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  29716. }
  29717. }
  29718. if (onBeforeUnbind) {
  29719. if (textures[0]._MSAAFramebuffer) {
  29720. // Bind the correct framebuffer
  29721. this.bindUnboundFramebuffer(textures[0]._framebuffer);
  29722. }
  29723. onBeforeUnbind();
  29724. }
  29725. this.bindUnboundFramebuffer(null);
  29726. };
  29727. /**
  29728. * Force the mipmap generation for the given render target texture
  29729. * @param texture defines the render target texture to use
  29730. */
  29731. Engine.prototype.generateMipMapsForCubemap = function (texture) {
  29732. if (texture.generateMipMaps) {
  29733. var gl = this._gl;
  29734. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  29735. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  29736. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  29737. }
  29738. };
  29739. /**
  29740. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29741. */
  29742. Engine.prototype.flushFramebuffer = function () {
  29743. this._gl.flush();
  29744. };
  29745. /**
  29746. * Unbind the current render target and bind the default framebuffer
  29747. */
  29748. Engine.prototype.restoreDefaultFramebuffer = function () {
  29749. if (this._currentRenderTarget) {
  29750. this.unBindFramebuffer(this._currentRenderTarget);
  29751. }
  29752. else {
  29753. this.bindUnboundFramebuffer(null);
  29754. }
  29755. if (this._cachedViewport) {
  29756. this.setViewport(this._cachedViewport);
  29757. }
  29758. this.wipeCaches();
  29759. };
  29760. // UBOs
  29761. /**
  29762. * Create an uniform buffer
  29763. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29764. * @param elements defines the content of the uniform buffer
  29765. * @returns the webGL uniform buffer
  29766. */
  29767. Engine.prototype.createUniformBuffer = function (elements) {
  29768. var ubo = this._gl.createBuffer();
  29769. if (!ubo) {
  29770. throw new Error("Unable to create uniform buffer");
  29771. }
  29772. this.bindUniformBuffer(ubo);
  29773. if (elements instanceof Float32Array) {
  29774. this._gl.bufferData(this._gl.UNIFORM_BUFFER, elements, this._gl.STATIC_DRAW);
  29775. }
  29776. else {
  29777. this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(elements), this._gl.STATIC_DRAW);
  29778. }
  29779. this.bindUniformBuffer(null);
  29780. ubo.references = 1;
  29781. return ubo;
  29782. };
  29783. /**
  29784. * Create a dynamic uniform buffer
  29785. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29786. * @param elements defines the content of the uniform buffer
  29787. * @returns the webGL uniform buffer
  29788. */
  29789. Engine.prototype.createDynamicUniformBuffer = function (elements) {
  29790. var ubo = this._gl.createBuffer();
  29791. if (!ubo) {
  29792. throw new Error("Unable to create dynamic uniform buffer");
  29793. }
  29794. this.bindUniformBuffer(ubo);
  29795. if (elements instanceof Float32Array) {
  29796. this._gl.bufferData(this._gl.UNIFORM_BUFFER, elements, this._gl.DYNAMIC_DRAW);
  29797. }
  29798. else {
  29799. this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(elements), this._gl.DYNAMIC_DRAW);
  29800. }
  29801. this.bindUniformBuffer(null);
  29802. ubo.references = 1;
  29803. return ubo;
  29804. };
  29805. /**
  29806. * Update an existing uniform buffer
  29807. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29808. * @param uniformBuffer defines the target uniform buffer
  29809. * @param elements defines the content to update
  29810. * @param offset defines the offset in the uniform buffer where update should start
  29811. * @param count defines the size of the data to update
  29812. */
  29813. Engine.prototype.updateUniformBuffer = function (uniformBuffer, elements, offset, count) {
  29814. this.bindUniformBuffer(uniformBuffer);
  29815. if (offset === undefined) {
  29816. offset = 0;
  29817. }
  29818. if (count === undefined) {
  29819. if (elements instanceof Float32Array) {
  29820. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, offset, elements);
  29821. }
  29822. else {
  29823. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, offset, new Float32Array(elements));
  29824. }
  29825. }
  29826. else {
  29827. if (elements instanceof Float32Array) {
  29828. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, elements.subarray(offset, offset + count));
  29829. }
  29830. else {
  29831. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, new Float32Array(elements).subarray(offset, offset + count));
  29832. }
  29833. }
  29834. this.bindUniformBuffer(null);
  29835. };
  29836. // VBOs
  29837. Engine.prototype._resetVertexBufferBinding = function () {
  29838. this.bindArrayBuffer(null);
  29839. this._cachedVertexBuffers = null;
  29840. };
  29841. /**
  29842. * Creates a vertex buffer
  29843. * @param data the data for the vertex buffer
  29844. * @returns the new WebGL static buffer
  29845. */
  29846. Engine.prototype.createVertexBuffer = function (data) {
  29847. var vbo = this._gl.createBuffer();
  29848. if (!vbo) {
  29849. throw new Error("Unable to create vertex buffer");
  29850. }
  29851. this.bindArrayBuffer(vbo);
  29852. if (data instanceof Array) {
  29853. this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), this._gl.STATIC_DRAW);
  29854. }
  29855. else {
  29856. this._gl.bufferData(this._gl.ARRAY_BUFFER, data, this._gl.STATIC_DRAW);
  29857. }
  29858. this._resetVertexBufferBinding();
  29859. vbo.references = 1;
  29860. return vbo;
  29861. };
  29862. /**
  29863. * Creates a dynamic vertex buffer
  29864. * @param data the data for the dynamic vertex buffer
  29865. * @returns the new WebGL dynamic buffer
  29866. */
  29867. Engine.prototype.createDynamicVertexBuffer = function (data) {
  29868. var vbo = this._gl.createBuffer();
  29869. if (!vbo) {
  29870. throw new Error("Unable to create dynamic vertex buffer");
  29871. }
  29872. this.bindArrayBuffer(vbo);
  29873. if (data instanceof Array) {
  29874. this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), this._gl.DYNAMIC_DRAW);
  29875. }
  29876. else {
  29877. this._gl.bufferData(this._gl.ARRAY_BUFFER, data, this._gl.DYNAMIC_DRAW);
  29878. }
  29879. this._resetVertexBufferBinding();
  29880. vbo.references = 1;
  29881. return vbo;
  29882. };
  29883. /**
  29884. * Update a dynamic index buffer
  29885. * @param indexBuffer defines the target index buffer
  29886. * @param indices defines the data to update
  29887. * @param offset defines the offset in the target index buffer where update should start
  29888. */
  29889. Engine.prototype.updateDynamicIndexBuffer = function (indexBuffer, indices, offset) {
  29890. if (offset === void 0) { offset = 0; }
  29891. // Force cache update
  29892. this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER] = null;
  29893. this.bindIndexBuffer(indexBuffer);
  29894. var arrayBuffer;
  29895. if (indices instanceof Uint16Array || indices instanceof Uint32Array) {
  29896. arrayBuffer = indices;
  29897. }
  29898. else {
  29899. arrayBuffer = indexBuffer.is32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
  29900. }
  29901. this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, this._gl.DYNAMIC_DRAW);
  29902. this._resetIndexBufferBinding();
  29903. };
  29904. /**
  29905. * Updates a dynamic vertex buffer.
  29906. * @param vertexBuffer the vertex buffer to update
  29907. * @param data the data used to update the vertex buffer
  29908. * @param byteOffset the byte offset of the data
  29909. * @param byteLength the byte length of the data
  29910. */
  29911. Engine.prototype.updateDynamicVertexBuffer = function (vertexBuffer, data, byteOffset, byteLength) {
  29912. this.bindArrayBuffer(vertexBuffer);
  29913. if (byteOffset === undefined) {
  29914. byteOffset = 0;
  29915. }
  29916. if (byteLength === undefined) {
  29917. if (data instanceof Array) {
  29918. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, new Float32Array(data));
  29919. }
  29920. else {
  29921. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, data);
  29922. }
  29923. }
  29924. else {
  29925. if (data instanceof Array) {
  29926. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, new Float32Array(data).subarray(byteOffset, byteOffset + byteLength));
  29927. }
  29928. else {
  29929. if (data instanceof ArrayBuffer) {
  29930. data = new Uint8Array(data, byteOffset, byteLength);
  29931. }
  29932. else {
  29933. data = new Uint8Array(data.buffer, data.byteOffset + byteOffset, byteLength);
  29934. }
  29935. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  29936. }
  29937. }
  29938. this._resetVertexBufferBinding();
  29939. };
  29940. Engine.prototype._resetIndexBufferBinding = function () {
  29941. this.bindIndexBuffer(null);
  29942. this._cachedIndexBuffer = null;
  29943. };
  29944. /**
  29945. * Creates a new index buffer
  29946. * @param indices defines the content of the index buffer
  29947. * @param updatable defines if the index buffer must be updatable
  29948. * @returns a new webGL buffer
  29949. */
  29950. Engine.prototype.createIndexBuffer = function (indices, updatable) {
  29951. var vbo = this._gl.createBuffer();
  29952. if (!vbo) {
  29953. throw new Error("Unable to create index buffer");
  29954. }
  29955. this.bindIndexBuffer(vbo);
  29956. // Check for 32 bits indices
  29957. var arrayBuffer;
  29958. var need32Bits = false;
  29959. if (indices instanceof Uint16Array) {
  29960. arrayBuffer = indices;
  29961. }
  29962. else {
  29963. //check 32 bit support
  29964. if (this._caps.uintIndices) {
  29965. if (indices instanceof Uint32Array) {
  29966. arrayBuffer = indices;
  29967. need32Bits = true;
  29968. }
  29969. else {
  29970. //number[] or Int32Array, check if 32 bit is necessary
  29971. for (var index = 0; index < indices.length; index++) {
  29972. if (indices[index] > 65535) {
  29973. need32Bits = true;
  29974. break;
  29975. }
  29976. }
  29977. arrayBuffer = need32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
  29978. }
  29979. }
  29980. else {
  29981. //no 32 bit support, force conversion to 16 bit (values greater 16 bit are lost)
  29982. arrayBuffer = new Uint16Array(indices);
  29983. }
  29984. }
  29985. this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, updatable ? this._gl.DYNAMIC_DRAW : this._gl.STATIC_DRAW);
  29986. this._resetIndexBufferBinding();
  29987. vbo.references = 1;
  29988. vbo.is32Bits = need32Bits;
  29989. return vbo;
  29990. };
  29991. /**
  29992. * Bind a webGL buffer to the webGL context
  29993. * @param buffer defines the buffer to bind
  29994. */
  29995. Engine.prototype.bindArrayBuffer = function (buffer) {
  29996. if (!this._vaoRecordInProgress) {
  29997. this._unbindVertexArrayObject();
  29998. }
  29999. this.bindBuffer(buffer, this._gl.ARRAY_BUFFER);
  30000. };
  30001. /**
  30002. * Bind an uniform buffer to the current webGL context
  30003. * @param buffer defines the buffer to bind
  30004. */
  30005. Engine.prototype.bindUniformBuffer = function (buffer) {
  30006. this._gl.bindBuffer(this._gl.UNIFORM_BUFFER, buffer);
  30007. };
  30008. /**
  30009. * Bind a buffer to the current webGL context at a given location
  30010. * @param buffer defines the buffer to bind
  30011. * @param location defines the index where to bind the buffer
  30012. */
  30013. Engine.prototype.bindUniformBufferBase = function (buffer, location) {
  30014. this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER, location, buffer);
  30015. };
  30016. /**
  30017. * Bind a specific block at a given index in a specific shader program
  30018. * @param shaderProgram defines the shader program
  30019. * @param blockName defines the block name
  30020. * @param index defines the index where to bind the block
  30021. */
  30022. Engine.prototype.bindUniformBlock = function (shaderProgram, blockName, index) {
  30023. var uniformLocation = this._gl.getUniformBlockIndex(shaderProgram, blockName);
  30024. this._gl.uniformBlockBinding(shaderProgram, uniformLocation, index);
  30025. };
  30026. Engine.prototype.bindIndexBuffer = function (buffer) {
  30027. if (!this._vaoRecordInProgress) {
  30028. this._unbindVertexArrayObject();
  30029. }
  30030. this.bindBuffer(buffer, this._gl.ELEMENT_ARRAY_BUFFER);
  30031. };
  30032. Engine.prototype.bindBuffer = function (buffer, target) {
  30033. if (this._vaoRecordInProgress || this._currentBoundBuffer[target] !== buffer) {
  30034. this._gl.bindBuffer(target, buffer);
  30035. this._currentBoundBuffer[target] = buffer;
  30036. }
  30037. };
  30038. /**
  30039. * update the bound buffer with the given data
  30040. * @param data defines the data to update
  30041. */
  30042. Engine.prototype.updateArrayBuffer = function (data) {
  30043. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  30044. };
  30045. Engine.prototype._vertexAttribPointer = function (buffer, indx, size, type, normalized, stride, offset) {
  30046. var pointer = this._currentBufferPointers[indx];
  30047. var changed = false;
  30048. if (!pointer.active) {
  30049. changed = true;
  30050. pointer.active = true;
  30051. pointer.index = indx;
  30052. pointer.size = size;
  30053. pointer.type = type;
  30054. pointer.normalized = normalized;
  30055. pointer.stride = stride;
  30056. pointer.offset = offset;
  30057. pointer.buffer = buffer;
  30058. }
  30059. else {
  30060. if (pointer.buffer !== buffer) {
  30061. pointer.buffer = buffer;
  30062. changed = true;
  30063. }
  30064. if (pointer.size !== size) {
  30065. pointer.size = size;
  30066. changed = true;
  30067. }
  30068. if (pointer.type !== type) {
  30069. pointer.type = type;
  30070. changed = true;
  30071. }
  30072. if (pointer.normalized !== normalized) {
  30073. pointer.normalized = normalized;
  30074. changed = true;
  30075. }
  30076. if (pointer.stride !== stride) {
  30077. pointer.stride = stride;
  30078. changed = true;
  30079. }
  30080. if (pointer.offset !== offset) {
  30081. pointer.offset = offset;
  30082. changed = true;
  30083. }
  30084. }
  30085. if (changed || this._vaoRecordInProgress) {
  30086. this.bindArrayBuffer(buffer);
  30087. this._gl.vertexAttribPointer(indx, size, type, normalized, stride, offset);
  30088. }
  30089. };
  30090. Engine.prototype._bindIndexBufferWithCache = function (indexBuffer) {
  30091. if (indexBuffer == null) {
  30092. return;
  30093. }
  30094. if (this._cachedIndexBuffer !== indexBuffer) {
  30095. this._cachedIndexBuffer = indexBuffer;
  30096. this.bindIndexBuffer(indexBuffer);
  30097. this._uintIndicesCurrentlySet = indexBuffer.is32Bits;
  30098. }
  30099. };
  30100. Engine.prototype._bindVertexBuffersAttributes = function (vertexBuffers, effect) {
  30101. var attributes = effect.getAttributesNames();
  30102. if (!this._vaoRecordInProgress) {
  30103. this._unbindVertexArrayObject();
  30104. }
  30105. this.unbindAllAttributes();
  30106. for (var index = 0; index < attributes.length; index++) {
  30107. var order = effect.getAttributeLocation(index);
  30108. if (order >= 0) {
  30109. var vertexBuffer = vertexBuffers[attributes[index]];
  30110. if (!vertexBuffer) {
  30111. continue;
  30112. }
  30113. this._gl.enableVertexAttribArray(order);
  30114. if (!this._vaoRecordInProgress) {
  30115. this._vertexAttribArraysEnabled[order] = true;
  30116. }
  30117. var buffer = vertexBuffer.getBuffer();
  30118. if (buffer) {
  30119. this._vertexAttribPointer(buffer, order, vertexBuffer.getSize(), vertexBuffer.type, vertexBuffer.normalized, vertexBuffer.byteStride, vertexBuffer.byteOffset);
  30120. if (vertexBuffer.getIsInstanced()) {
  30121. this._gl.vertexAttribDivisor(order, vertexBuffer.getInstanceDivisor());
  30122. if (!this._vaoRecordInProgress) {
  30123. this._currentInstanceLocations.push(order);
  30124. this._currentInstanceBuffers.push(buffer);
  30125. }
  30126. }
  30127. }
  30128. }
  30129. }
  30130. };
  30131. /**
  30132. * Records a vertex array object
  30133. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30134. * @param vertexBuffers defines the list of vertex buffers to store
  30135. * @param indexBuffer defines the index buffer to store
  30136. * @param effect defines the effect to store
  30137. * @returns the new vertex array object
  30138. */
  30139. Engine.prototype.recordVertexArrayObject = function (vertexBuffers, indexBuffer, effect) {
  30140. var vao = this._gl.createVertexArray();
  30141. this._vaoRecordInProgress = true;
  30142. this._gl.bindVertexArray(vao);
  30143. this._mustWipeVertexAttributes = true;
  30144. this._bindVertexBuffersAttributes(vertexBuffers, effect);
  30145. this.bindIndexBuffer(indexBuffer);
  30146. this._vaoRecordInProgress = false;
  30147. this._gl.bindVertexArray(null);
  30148. return vao;
  30149. };
  30150. /**
  30151. * Bind a specific vertex array object
  30152. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30153. * @param vertexArrayObject defines the vertex array object to bind
  30154. * @param indexBuffer defines the index buffer to bind
  30155. */
  30156. Engine.prototype.bindVertexArrayObject = function (vertexArrayObject, indexBuffer) {
  30157. if (this._cachedVertexArrayObject !== vertexArrayObject) {
  30158. this._cachedVertexArrayObject = vertexArrayObject;
  30159. this._gl.bindVertexArray(vertexArrayObject);
  30160. this._cachedVertexBuffers = null;
  30161. this._cachedIndexBuffer = null;
  30162. this._uintIndicesCurrentlySet = indexBuffer != null && indexBuffer.is32Bits;
  30163. this._mustWipeVertexAttributes = true;
  30164. }
  30165. };
  30166. /**
  30167. * Bind webGl buffers directly to the webGL context
  30168. * @param vertexBuffer defines the vertex buffer to bind
  30169. * @param indexBuffer defines the index buffer to bind
  30170. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30171. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30172. * @param effect defines the effect associated with the vertex buffer
  30173. */
  30174. Engine.prototype.bindBuffersDirectly = function (vertexBuffer, indexBuffer, vertexDeclaration, vertexStrideSize, effect) {
  30175. if (this._cachedVertexBuffers !== vertexBuffer || this._cachedEffectForVertexBuffers !== effect) {
  30176. this._cachedVertexBuffers = vertexBuffer;
  30177. this._cachedEffectForVertexBuffers = effect;
  30178. var attributesCount = effect.getAttributesCount();
  30179. this._unbindVertexArrayObject();
  30180. this.unbindAllAttributes();
  30181. var offset = 0;
  30182. for (var index = 0; index < attributesCount; index++) {
  30183. if (index < vertexDeclaration.length) {
  30184. var order = effect.getAttributeLocation(index);
  30185. if (order >= 0) {
  30186. this._gl.enableVertexAttribArray(order);
  30187. this._vertexAttribArraysEnabled[order] = true;
  30188. this._vertexAttribPointer(vertexBuffer, order, vertexDeclaration[index], this._gl.FLOAT, false, vertexStrideSize, offset);
  30189. }
  30190. offset += vertexDeclaration[index] * 4;
  30191. }
  30192. }
  30193. }
  30194. this._bindIndexBufferWithCache(indexBuffer);
  30195. };
  30196. Engine.prototype._unbindVertexArrayObject = function () {
  30197. if (!this._cachedVertexArrayObject) {
  30198. return;
  30199. }
  30200. this._cachedVertexArrayObject = null;
  30201. this._gl.bindVertexArray(null);
  30202. };
  30203. /**
  30204. * Bind a list of vertex buffers to the webGL context
  30205. * @param vertexBuffers defines the list of vertex buffers to bind
  30206. * @param indexBuffer defines the index buffer to bind
  30207. * @param effect defines the effect associated with the vertex buffers
  30208. */
  30209. Engine.prototype.bindBuffers = function (vertexBuffers, indexBuffer, effect) {
  30210. if (this._cachedVertexBuffers !== vertexBuffers || this._cachedEffectForVertexBuffers !== effect) {
  30211. this._cachedVertexBuffers = vertexBuffers;
  30212. this._cachedEffectForVertexBuffers = effect;
  30213. this._bindVertexBuffersAttributes(vertexBuffers, effect);
  30214. }
  30215. this._bindIndexBufferWithCache(indexBuffer);
  30216. };
  30217. /**
  30218. * Unbind all instance attributes
  30219. */
  30220. Engine.prototype.unbindInstanceAttributes = function () {
  30221. var boundBuffer;
  30222. for (var i = 0, ul = this._currentInstanceLocations.length; i < ul; i++) {
  30223. var instancesBuffer = this._currentInstanceBuffers[i];
  30224. if (boundBuffer != instancesBuffer && instancesBuffer.references) {
  30225. boundBuffer = instancesBuffer;
  30226. this.bindArrayBuffer(instancesBuffer);
  30227. }
  30228. var offsetLocation = this._currentInstanceLocations[i];
  30229. this._gl.vertexAttribDivisor(offsetLocation, 0);
  30230. }
  30231. this._currentInstanceBuffers.length = 0;
  30232. this._currentInstanceLocations.length = 0;
  30233. };
  30234. /**
  30235. * Release and free the memory of a vertex array object
  30236. * @param vao defines the vertex array object to delete
  30237. */
  30238. Engine.prototype.releaseVertexArrayObject = function (vao) {
  30239. this._gl.deleteVertexArray(vao);
  30240. };
  30241. /** @hidden */
  30242. Engine.prototype._releaseBuffer = function (buffer) {
  30243. buffer.references--;
  30244. if (buffer.references === 0) {
  30245. this._gl.deleteBuffer(buffer);
  30246. return true;
  30247. }
  30248. return false;
  30249. };
  30250. /**
  30251. * Creates a webGL buffer to use with instanciation
  30252. * @param capacity defines the size of the buffer
  30253. * @returns the webGL buffer
  30254. */
  30255. Engine.prototype.createInstancesBuffer = function (capacity) {
  30256. var buffer = this._gl.createBuffer();
  30257. if (!buffer) {
  30258. throw new Error("Unable to create instance buffer");
  30259. }
  30260. buffer.capacity = capacity;
  30261. this.bindArrayBuffer(buffer);
  30262. this._gl.bufferData(this._gl.ARRAY_BUFFER, capacity, this._gl.DYNAMIC_DRAW);
  30263. return buffer;
  30264. };
  30265. /**
  30266. * Delete a webGL buffer used with instanciation
  30267. * @param buffer defines the webGL buffer to delete
  30268. */
  30269. Engine.prototype.deleteInstancesBuffer = function (buffer) {
  30270. this._gl.deleteBuffer(buffer);
  30271. };
  30272. /**
  30273. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30274. * @param instancesBuffer defines the webGL buffer to update and bind
  30275. * @param data defines the data to store in the buffer
  30276. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30277. */
  30278. Engine.prototype.updateAndBindInstancesBuffer = function (instancesBuffer, data, offsetLocations) {
  30279. this.bindArrayBuffer(instancesBuffer);
  30280. if (data) {
  30281. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  30282. }
  30283. if (offsetLocations[0].index !== undefined) {
  30284. var stride = 0;
  30285. for (var i = 0; i < offsetLocations.length; i++) {
  30286. var ai = offsetLocations[i];
  30287. stride += ai.attributeSize * 4;
  30288. }
  30289. for (var i = 0; i < offsetLocations.length; i++) {
  30290. var ai = offsetLocations[i];
  30291. if (!this._vertexAttribArraysEnabled[ai.index]) {
  30292. this._gl.enableVertexAttribArray(ai.index);
  30293. this._vertexAttribArraysEnabled[ai.index] = true;
  30294. }
  30295. this._vertexAttribPointer(instancesBuffer, ai.index, ai.attributeSize, ai.attribyteType || this._gl.FLOAT, ai.normalized || false, stride, ai.offset);
  30296. this._gl.vertexAttribDivisor(ai.index, 1);
  30297. this._currentInstanceLocations.push(ai.index);
  30298. this._currentInstanceBuffers.push(instancesBuffer);
  30299. }
  30300. }
  30301. else {
  30302. for (var index = 0; index < 4; index++) {
  30303. var offsetLocation = offsetLocations[index];
  30304. if (!this._vertexAttribArraysEnabled[offsetLocation]) {
  30305. this._gl.enableVertexAttribArray(offsetLocation);
  30306. this._vertexAttribArraysEnabled[offsetLocation] = true;
  30307. }
  30308. this._vertexAttribPointer(instancesBuffer, offsetLocation, 4, this._gl.FLOAT, false, 64, index * 16);
  30309. this._gl.vertexAttribDivisor(offsetLocation, 1);
  30310. this._currentInstanceLocations.push(offsetLocation);
  30311. this._currentInstanceBuffers.push(instancesBuffer);
  30312. }
  30313. }
  30314. };
  30315. /**
  30316. * Apply all cached states (depth, culling, stencil and alpha)
  30317. */
  30318. Engine.prototype.applyStates = function () {
  30319. this._depthCullingState.apply(this._gl);
  30320. this._stencilState.apply(this._gl);
  30321. this._alphaState.apply(this._gl);
  30322. };
  30323. /**
  30324. * Send a draw order
  30325. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30326. * @param indexStart defines the starting index
  30327. * @param indexCount defines the number of index to draw
  30328. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30329. */
  30330. Engine.prototype.draw = function (useTriangles, indexStart, indexCount, instancesCount) {
  30331. this.drawElementsType(useTriangles ? _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode : _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode, indexStart, indexCount, instancesCount);
  30332. };
  30333. /**
  30334. * Draw a list of points
  30335. * @param verticesStart defines the index of first vertex to draw
  30336. * @param verticesCount defines the count of vertices to draw
  30337. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30338. */
  30339. Engine.prototype.drawPointClouds = function (verticesStart, verticesCount, instancesCount) {
  30340. this.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointFillMode, verticesStart, verticesCount, instancesCount);
  30341. };
  30342. /**
  30343. * Draw a list of unindexed primitives
  30344. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30345. * @param verticesStart defines the index of first vertex to draw
  30346. * @param verticesCount defines the count of vertices to draw
  30347. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30348. */
  30349. Engine.prototype.drawUnIndexed = function (useTriangles, verticesStart, verticesCount, instancesCount) {
  30350. this.drawArraysType(useTriangles ? _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode : _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode, verticesStart, verticesCount, instancesCount);
  30351. };
  30352. /**
  30353. * Draw a list of indexed primitives
  30354. * @param fillMode defines the primitive to use
  30355. * @param indexStart defines the starting index
  30356. * @param indexCount defines the number of index to draw
  30357. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30358. */
  30359. Engine.prototype.drawElementsType = function (fillMode, indexStart, indexCount, instancesCount) {
  30360. // Apply states
  30361. this.applyStates();
  30362. this._drawCalls.addCount(1, false);
  30363. // Render
  30364. var drawMode = this._drawMode(fillMode);
  30365. var indexFormat = this._uintIndicesCurrentlySet ? this._gl.UNSIGNED_INT : this._gl.UNSIGNED_SHORT;
  30366. var mult = this._uintIndicesCurrentlySet ? 4 : 2;
  30367. if (instancesCount) {
  30368. this._gl.drawElementsInstanced(drawMode, indexCount, indexFormat, indexStart * mult, instancesCount);
  30369. }
  30370. else {
  30371. this._gl.drawElements(drawMode, indexCount, indexFormat, indexStart * mult);
  30372. }
  30373. };
  30374. /**
  30375. * Draw a list of unindexed primitives
  30376. * @param fillMode defines the primitive to use
  30377. * @param verticesStart defines the index of first vertex to draw
  30378. * @param verticesCount defines the count of vertices to draw
  30379. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30380. */
  30381. Engine.prototype.drawArraysType = function (fillMode, verticesStart, verticesCount, instancesCount) {
  30382. // Apply states
  30383. this.applyStates();
  30384. this._drawCalls.addCount(1, false);
  30385. var drawMode = this._drawMode(fillMode);
  30386. if (instancesCount) {
  30387. this._gl.drawArraysInstanced(drawMode, verticesStart, verticesCount, instancesCount);
  30388. }
  30389. else {
  30390. this._gl.drawArrays(drawMode, verticesStart, verticesCount);
  30391. }
  30392. };
  30393. Engine.prototype._drawMode = function (fillMode) {
  30394. switch (fillMode) {
  30395. // Triangle views
  30396. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode:
  30397. return this._gl.TRIANGLES;
  30398. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointFillMode:
  30399. return this._gl.POINTS;
  30400. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode:
  30401. return this._gl.LINES;
  30402. // Draw modes
  30403. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointListDrawMode:
  30404. return this._gl.POINTS;
  30405. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineListDrawMode:
  30406. return this._gl.LINES;
  30407. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineLoopDrawMode:
  30408. return this._gl.LINE_LOOP;
  30409. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineStripDrawMode:
  30410. return this._gl.LINE_STRIP;
  30411. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleStripDrawMode:
  30412. return this._gl.TRIANGLE_STRIP;
  30413. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFanDrawMode:
  30414. return this._gl.TRIANGLE_FAN;
  30415. default:
  30416. return this._gl.TRIANGLES;
  30417. }
  30418. };
  30419. // Shaders
  30420. /** @hidden */
  30421. Engine.prototype._releaseEffect = function (effect) {
  30422. if (this._compiledEffects[effect._key]) {
  30423. delete this._compiledEffects[effect._key];
  30424. this._deleteProgram(effect.getProgram());
  30425. }
  30426. };
  30427. /** @hidden */
  30428. Engine.prototype._deleteProgram = function (program) {
  30429. if (program) {
  30430. program.__SPECTOR_rebuildProgram = null;
  30431. if (program.transformFeedback) {
  30432. this.deleteTransformFeedback(program.transformFeedback);
  30433. program.transformFeedback = null;
  30434. }
  30435. this._gl.deleteProgram(program);
  30436. }
  30437. };
  30438. /**
  30439. * Create a new effect (used to store vertex/fragment shaders)
  30440. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30441. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  30442. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30443. * @param samplers defines an array of string used to represent textures
  30444. * @param defines defines the string containing the defines to use to compile the shaders
  30445. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30446. * @param onCompiled defines a function to call when the effect creation is successful
  30447. * @param onError defines a function to call when the effect creation has failed
  30448. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30449. * @returns the new Effect
  30450. */
  30451. Engine.prototype.createEffect = function (baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, defines, fallbacks, onCompiled, onError, indexParameters) {
  30452. var vertex = baseName.vertexElement || baseName.vertex || baseName;
  30453. var fragment = baseName.fragmentElement || baseName.fragment || baseName;
  30454. var name = vertex + "+" + fragment + "@" + (defines ? defines : attributesNamesOrOptions.defines);
  30455. if (this._compiledEffects[name]) {
  30456. var compiledEffect = this._compiledEffects[name];
  30457. if (onCompiled && compiledEffect.isReady()) {
  30458. onCompiled(compiledEffect);
  30459. }
  30460. return compiledEffect;
  30461. }
  30462. var effect = new _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"](baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, this, defines, fallbacks, onCompiled, onError, indexParameters);
  30463. effect._key = name;
  30464. this._compiledEffects[name] = effect;
  30465. return effect;
  30466. };
  30467. Engine.prototype._compileShader = function (source, type, defines, shaderVersion) {
  30468. return this._compileRawShader(shaderVersion + (defines ? defines + "\n" : "") + source, type);
  30469. };
  30470. Engine.prototype._compileRawShader = function (source, type) {
  30471. var gl = this._gl;
  30472. var shader = gl.createShader(type === "vertex" ? gl.VERTEX_SHADER : gl.FRAGMENT_SHADER);
  30473. if (!shader) {
  30474. throw new Error("Something went wrong while compile the shader.");
  30475. }
  30476. gl.shaderSource(shader, source);
  30477. gl.compileShader(shader);
  30478. if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
  30479. var log = gl.getShaderInfoLog(shader);
  30480. if (log) {
  30481. throw new Error(log);
  30482. }
  30483. }
  30484. return shader;
  30485. };
  30486. /**
  30487. * Directly creates a webGL program
  30488. * @param vertexCode defines the vertex shader code to use
  30489. * @param fragmentCode defines the fragment shader code to use
  30490. * @param context defines the webGL context to use (if not set, the current one will be used)
  30491. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30492. * @returns the new webGL program
  30493. */
  30494. Engine.prototype.createRawShaderProgram = function (vertexCode, fragmentCode, context, transformFeedbackVaryings) {
  30495. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  30496. context = context || this._gl;
  30497. var vertexShader = this._compileRawShader(vertexCode, "vertex");
  30498. var fragmentShader = this._compileRawShader(fragmentCode, "fragment");
  30499. return this._createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings);
  30500. };
  30501. /**
  30502. * Creates a webGL program
  30503. * @param vertexCode defines the vertex shader code to use
  30504. * @param fragmentCode defines the fragment shader code to use
  30505. * @param defines defines the string containing the defines to use to compile the shaders
  30506. * @param context defines the webGL context to use (if not set, the current one will be used)
  30507. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30508. * @returns the new webGL program
  30509. */
  30510. Engine.prototype.createShaderProgram = function (vertexCode, fragmentCode, defines, context, transformFeedbackVaryings) {
  30511. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  30512. context = context || this._gl;
  30513. this.onBeforeShaderCompilationObservable.notifyObservers(this);
  30514. var shaderVersion = (this._webGLVersion > 1) ? "#version 300 es\n#define WEBGL2 \n" : "";
  30515. var vertexShader = this._compileShader(vertexCode, "vertex", defines, shaderVersion);
  30516. var fragmentShader = this._compileShader(fragmentCode, "fragment", defines, shaderVersion);
  30517. var program = this._createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings);
  30518. this.onAfterShaderCompilationObservable.notifyObservers(this);
  30519. return program;
  30520. };
  30521. Engine.prototype._createShaderProgram = function (vertexShader, fragmentShader, context, transformFeedbackVaryings) {
  30522. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  30523. var shaderProgram = context.createProgram();
  30524. if (!shaderProgram) {
  30525. throw new Error("Unable to create program");
  30526. }
  30527. context.attachShader(shaderProgram, vertexShader);
  30528. context.attachShader(shaderProgram, fragmentShader);
  30529. if (this.webGLVersion > 1 && transformFeedbackVaryings) {
  30530. var transformFeedback = this.createTransformFeedback();
  30531. this.bindTransformFeedback(transformFeedback);
  30532. this.setTranformFeedbackVaryings(shaderProgram, transformFeedbackVaryings);
  30533. shaderProgram.transformFeedback = transformFeedback;
  30534. }
  30535. context.linkProgram(shaderProgram);
  30536. if (this.webGLVersion > 1 && transformFeedbackVaryings) {
  30537. this.bindTransformFeedback(null);
  30538. }
  30539. shaderProgram.context = context;
  30540. shaderProgram.vertexShader = vertexShader;
  30541. shaderProgram.fragmentShader = fragmentShader;
  30542. if (!this._caps.parallelShaderCompile) {
  30543. this._finalizeProgram(shaderProgram);
  30544. }
  30545. else {
  30546. shaderProgram.isParallelCompiled = true;
  30547. }
  30548. return shaderProgram;
  30549. };
  30550. Engine.prototype._finalizeProgram = function (shaderProgram) {
  30551. var context = shaderProgram.context;
  30552. var vertexShader = shaderProgram.vertexShader;
  30553. var fragmentShader = shaderProgram.fragmentShader;
  30554. var linked = context.getProgramParameter(shaderProgram, context.LINK_STATUS);
  30555. if (!linked) {
  30556. var error = context.getProgramInfoLog(shaderProgram);
  30557. if (error) {
  30558. throw new Error(error);
  30559. }
  30560. }
  30561. if (this.validateShaderPrograms) {
  30562. context.validateProgram(shaderProgram);
  30563. var validated = context.getProgramParameter(shaderProgram, context.VALIDATE_STATUS);
  30564. if (!validated) {
  30565. var error = context.getProgramInfoLog(shaderProgram);
  30566. if (error) {
  30567. throw new Error(error);
  30568. }
  30569. }
  30570. }
  30571. context.deleteShader(vertexShader);
  30572. context.deleteShader(fragmentShader);
  30573. shaderProgram.context = undefined;
  30574. shaderProgram.vertexShader = undefined;
  30575. shaderProgram.fragmentShader = undefined;
  30576. if (shaderProgram.onCompiled) {
  30577. shaderProgram.onCompiled();
  30578. shaderProgram.onCompiled = undefined;
  30579. }
  30580. };
  30581. /** @hidden */
  30582. Engine.prototype._isProgramCompiled = function (shaderProgram) {
  30583. if (!shaderProgram.isParallelCompiled) {
  30584. return true;
  30585. }
  30586. if (this._gl.getProgramParameter(shaderProgram, this._caps.parallelShaderCompile.COMPLETION_STATUS_KHR)) {
  30587. this._finalizeProgram(shaderProgram);
  30588. return true;
  30589. }
  30590. return false;
  30591. };
  30592. /** @hidden */
  30593. Engine.prototype._executeWhenProgramIsCompiled = function (shaderProgram, action) {
  30594. if (!shaderProgram.isParallelCompiled) {
  30595. action();
  30596. return;
  30597. }
  30598. shaderProgram.onCompiled = action;
  30599. };
  30600. /**
  30601. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30602. * @param shaderProgram defines the webGL program to use
  30603. * @param uniformsNames defines the list of uniform names
  30604. * @returns an array of webGL uniform locations
  30605. */
  30606. Engine.prototype.getUniforms = function (shaderProgram, uniformsNames) {
  30607. var results = new Array();
  30608. for (var index = 0; index < uniformsNames.length; index++) {
  30609. results.push(this._gl.getUniformLocation(shaderProgram, uniformsNames[index]));
  30610. }
  30611. return results;
  30612. };
  30613. /**
  30614. * Gets the lsit of active attributes for a given webGL program
  30615. * @param shaderProgram defines the webGL program to use
  30616. * @param attributesNames defines the list of attribute names to get
  30617. * @returns an array of indices indicating the offset of each attribute
  30618. */
  30619. Engine.prototype.getAttributes = function (shaderProgram, attributesNames) {
  30620. var results = [];
  30621. for (var index = 0; index < attributesNames.length; index++) {
  30622. try {
  30623. results.push(this._gl.getAttribLocation(shaderProgram, attributesNames[index]));
  30624. }
  30625. catch (e) {
  30626. results.push(-1);
  30627. }
  30628. }
  30629. return results;
  30630. };
  30631. /**
  30632. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30633. * @param effect defines the effect to activate
  30634. */
  30635. Engine.prototype.enableEffect = function (effect) {
  30636. if (!effect || effect === this._currentEffect) {
  30637. return;
  30638. }
  30639. // Use program
  30640. this.bindSamplers(effect);
  30641. this._currentEffect = effect;
  30642. if (effect.onBind) {
  30643. effect.onBind(effect);
  30644. }
  30645. if (effect._onBindObservable) {
  30646. effect._onBindObservable.notifyObservers(effect);
  30647. }
  30648. };
  30649. /**
  30650. * Set the value of an uniform to an array of int32
  30651. * @param uniform defines the webGL uniform location where to store the value
  30652. * @param array defines the array of int32 to store
  30653. */
  30654. Engine.prototype.setIntArray = function (uniform, array) {
  30655. if (!uniform) {
  30656. return;
  30657. }
  30658. this._gl.uniform1iv(uniform, array);
  30659. };
  30660. /**
  30661. * Set the value of an uniform to an array of int32 (stored as vec2)
  30662. * @param uniform defines the webGL uniform location where to store the value
  30663. * @param array defines the array of int32 to store
  30664. */
  30665. Engine.prototype.setIntArray2 = function (uniform, array) {
  30666. if (!uniform || array.length % 2 !== 0) {
  30667. return;
  30668. }
  30669. this._gl.uniform2iv(uniform, array);
  30670. };
  30671. /**
  30672. * Set the value of an uniform to an array of int32 (stored as vec3)
  30673. * @param uniform defines the webGL uniform location where to store the value
  30674. * @param array defines the array of int32 to store
  30675. */
  30676. Engine.prototype.setIntArray3 = function (uniform, array) {
  30677. if (!uniform || array.length % 3 !== 0) {
  30678. return;
  30679. }
  30680. this._gl.uniform3iv(uniform, array);
  30681. };
  30682. /**
  30683. * Set the value of an uniform to an array of int32 (stored as vec4)
  30684. * @param uniform defines the webGL uniform location where to store the value
  30685. * @param array defines the array of int32 to store
  30686. */
  30687. Engine.prototype.setIntArray4 = function (uniform, array) {
  30688. if (!uniform || array.length % 4 !== 0) {
  30689. return;
  30690. }
  30691. this._gl.uniform4iv(uniform, array);
  30692. };
  30693. /**
  30694. * Set the value of an uniform to an array of float32
  30695. * @param uniform defines the webGL uniform location where to store the value
  30696. * @param array defines the array of float32 to store
  30697. */
  30698. Engine.prototype.setFloatArray = function (uniform, array) {
  30699. if (!uniform) {
  30700. return;
  30701. }
  30702. this._gl.uniform1fv(uniform, array);
  30703. };
  30704. /**
  30705. * Set the value of an uniform to an array of float32 (stored as vec2)
  30706. * @param uniform defines the webGL uniform location where to store the value
  30707. * @param array defines the array of float32 to store
  30708. */
  30709. Engine.prototype.setFloatArray2 = function (uniform, array) {
  30710. if (!uniform || array.length % 2 !== 0) {
  30711. return;
  30712. }
  30713. this._gl.uniform2fv(uniform, array);
  30714. };
  30715. /**
  30716. * Set the value of an uniform to an array of float32 (stored as vec3)
  30717. * @param uniform defines the webGL uniform location where to store the value
  30718. * @param array defines the array of float32 to store
  30719. */
  30720. Engine.prototype.setFloatArray3 = function (uniform, array) {
  30721. if (!uniform || array.length % 3 !== 0) {
  30722. return;
  30723. }
  30724. this._gl.uniform3fv(uniform, array);
  30725. };
  30726. /**
  30727. * Set the value of an uniform to an array of float32 (stored as vec4)
  30728. * @param uniform defines the webGL uniform location where to store the value
  30729. * @param array defines the array of float32 to store
  30730. */
  30731. Engine.prototype.setFloatArray4 = function (uniform, array) {
  30732. if (!uniform || array.length % 4 !== 0) {
  30733. return;
  30734. }
  30735. this._gl.uniform4fv(uniform, array);
  30736. };
  30737. /**
  30738. * Set the value of an uniform to an array of number
  30739. * @param uniform defines the webGL uniform location where to store the value
  30740. * @param array defines the array of number to store
  30741. */
  30742. Engine.prototype.setArray = function (uniform, array) {
  30743. if (!uniform) {
  30744. return;
  30745. }
  30746. this._gl.uniform1fv(uniform, array);
  30747. };
  30748. /**
  30749. * Set the value of an uniform to an array of number (stored as vec2)
  30750. * @param uniform defines the webGL uniform location where to store the value
  30751. * @param array defines the array of number to store
  30752. */
  30753. Engine.prototype.setArray2 = function (uniform, array) {
  30754. if (!uniform || array.length % 2 !== 0) {
  30755. return;
  30756. }
  30757. this._gl.uniform2fv(uniform, array);
  30758. };
  30759. /**
  30760. * Set the value of an uniform to an array of number (stored as vec3)
  30761. * @param uniform defines the webGL uniform location where to store the value
  30762. * @param array defines the array of number to store
  30763. */
  30764. Engine.prototype.setArray3 = function (uniform, array) {
  30765. if (!uniform || array.length % 3 !== 0) {
  30766. return;
  30767. }
  30768. this._gl.uniform3fv(uniform, array);
  30769. };
  30770. /**
  30771. * Set the value of an uniform to an array of number (stored as vec4)
  30772. * @param uniform defines the webGL uniform location where to store the value
  30773. * @param array defines the array of number to store
  30774. */
  30775. Engine.prototype.setArray4 = function (uniform, array) {
  30776. if (!uniform || array.length % 4 !== 0) {
  30777. return;
  30778. }
  30779. this._gl.uniform4fv(uniform, array);
  30780. };
  30781. /**
  30782. * Set the value of an uniform to an array of float32 (stored as matrices)
  30783. * @param uniform defines the webGL uniform location where to store the value
  30784. * @param matrices defines the array of float32 to store
  30785. */
  30786. Engine.prototype.setMatrices = function (uniform, matrices) {
  30787. if (!uniform) {
  30788. return;
  30789. }
  30790. this._gl.uniformMatrix4fv(uniform, false, matrices);
  30791. };
  30792. /**
  30793. * Set the value of an uniform to a matrix
  30794. * @param uniform defines the webGL uniform location where to store the value
  30795. * @param matrix defines the matrix to store
  30796. */
  30797. Engine.prototype.setMatrix = function (uniform, matrix) {
  30798. if (!uniform) {
  30799. return;
  30800. }
  30801. this._gl.uniformMatrix4fv(uniform, false, matrix.toArray());
  30802. };
  30803. /**
  30804. * Set the value of an uniform to a matrix (3x3)
  30805. * @param uniform defines the webGL uniform location where to store the value
  30806. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30807. */
  30808. Engine.prototype.setMatrix3x3 = function (uniform, matrix) {
  30809. if (!uniform) {
  30810. return;
  30811. }
  30812. this._gl.uniformMatrix3fv(uniform, false, matrix);
  30813. };
  30814. /**
  30815. * Set the value of an uniform to a matrix (2x2)
  30816. * @param uniform defines the webGL uniform location where to store the value
  30817. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30818. */
  30819. Engine.prototype.setMatrix2x2 = function (uniform, matrix) {
  30820. if (!uniform) {
  30821. return;
  30822. }
  30823. this._gl.uniformMatrix2fv(uniform, false, matrix);
  30824. };
  30825. /**
  30826. * Set the value of an uniform to a number (int)
  30827. * @param uniform defines the webGL uniform location where to store the value
  30828. * @param value defines the int number to store
  30829. */
  30830. Engine.prototype.setInt = function (uniform, value) {
  30831. if (!uniform) {
  30832. return;
  30833. }
  30834. this._gl.uniform1i(uniform, value);
  30835. };
  30836. /**
  30837. * Set the value of an uniform to a number (float)
  30838. * @param uniform defines the webGL uniform location where to store the value
  30839. * @param value defines the float number to store
  30840. */
  30841. Engine.prototype.setFloat = function (uniform, value) {
  30842. if (!uniform) {
  30843. return;
  30844. }
  30845. this._gl.uniform1f(uniform, value);
  30846. };
  30847. /**
  30848. * Set the value of an uniform to a vec2
  30849. * @param uniform defines the webGL uniform location where to store the value
  30850. * @param x defines the 1st component of the value
  30851. * @param y defines the 2nd component of the value
  30852. */
  30853. Engine.prototype.setFloat2 = function (uniform, x, y) {
  30854. if (!uniform) {
  30855. return;
  30856. }
  30857. this._gl.uniform2f(uniform, x, y);
  30858. };
  30859. /**
  30860. * Set the value of an uniform to a vec3
  30861. * @param uniform defines the webGL uniform location where to store the value
  30862. * @param x defines the 1st component of the value
  30863. * @param y defines the 2nd component of the value
  30864. * @param z defines the 3rd component of the value
  30865. */
  30866. Engine.prototype.setFloat3 = function (uniform, x, y, z) {
  30867. if (!uniform) {
  30868. return;
  30869. }
  30870. this._gl.uniform3f(uniform, x, y, z);
  30871. };
  30872. /**
  30873. * Set the value of an uniform to a boolean
  30874. * @param uniform defines the webGL uniform location where to store the value
  30875. * @param bool defines the boolean to store
  30876. */
  30877. Engine.prototype.setBool = function (uniform, bool) {
  30878. if (!uniform) {
  30879. return;
  30880. }
  30881. this._gl.uniform1i(uniform, bool);
  30882. };
  30883. /**
  30884. * Set the value of an uniform to a vec4
  30885. * @param uniform defines the webGL uniform location where to store the value
  30886. * @param x defines the 1st component of the value
  30887. * @param y defines the 2nd component of the value
  30888. * @param z defines the 3rd component of the value
  30889. * @param w defines the 4th component of the value
  30890. */
  30891. Engine.prototype.setFloat4 = function (uniform, x, y, z, w) {
  30892. if (!uniform) {
  30893. return;
  30894. }
  30895. this._gl.uniform4f(uniform, x, y, z, w);
  30896. };
  30897. /**
  30898. * Set the value of an uniform to a Color3
  30899. * @param uniform defines the webGL uniform location where to store the value
  30900. * @param color3 defines the color to store
  30901. */
  30902. Engine.prototype.setColor3 = function (uniform, color3) {
  30903. if (!uniform) {
  30904. return;
  30905. }
  30906. this._gl.uniform3f(uniform, color3.r, color3.g, color3.b);
  30907. };
  30908. /**
  30909. * Set the value of an uniform to a Color3 and an alpha value
  30910. * @param uniform defines the webGL uniform location where to store the value
  30911. * @param color3 defines the color to store
  30912. * @param alpha defines the alpha component to store
  30913. */
  30914. Engine.prototype.setColor4 = function (uniform, color3, alpha) {
  30915. if (!uniform) {
  30916. return;
  30917. }
  30918. this._gl.uniform4f(uniform, color3.r, color3.g, color3.b, alpha);
  30919. };
  30920. /**
  30921. * Sets a Color4 on a uniform variable
  30922. * @param uniform defines the uniform location
  30923. * @param color4 defines the value to be set
  30924. */
  30925. Engine.prototype.setDirectColor4 = function (uniform, color4) {
  30926. if (!uniform) {
  30927. return;
  30928. }
  30929. this._gl.uniform4f(uniform, color4.r, color4.g, color4.b, color4.a);
  30930. };
  30931. // States
  30932. /**
  30933. * Set various states to the webGL context
  30934. * @param culling defines backface culling state
  30935. * @param zOffset defines the value to apply to zOffset (0 by default)
  30936. * @param force defines if states must be applied even if cache is up to date
  30937. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  30938. */
  30939. Engine.prototype.setState = function (culling, zOffset, force, reverseSide) {
  30940. if (zOffset === void 0) { zOffset = 0; }
  30941. if (reverseSide === void 0) { reverseSide = false; }
  30942. // Culling
  30943. if (this._depthCullingState.cull !== culling || force) {
  30944. this._depthCullingState.cull = culling;
  30945. }
  30946. // Cull face
  30947. var cullFace = this.cullBackFaces ? this._gl.BACK : this._gl.FRONT;
  30948. if (this._depthCullingState.cullFace !== cullFace || force) {
  30949. this._depthCullingState.cullFace = cullFace;
  30950. }
  30951. // Z offset
  30952. this.setZOffset(zOffset);
  30953. // Front face
  30954. var frontFace = reverseSide ? this._gl.CW : this._gl.CCW;
  30955. if (this._depthCullingState.frontFace !== frontFace || force) {
  30956. this._depthCullingState.frontFace = frontFace;
  30957. }
  30958. };
  30959. /**
  30960. * Set the z offset to apply to current rendering
  30961. * @param value defines the offset to apply
  30962. */
  30963. Engine.prototype.setZOffset = function (value) {
  30964. this._depthCullingState.zOffset = value;
  30965. };
  30966. /**
  30967. * Gets the current value of the zOffset
  30968. * @returns the current zOffset state
  30969. */
  30970. Engine.prototype.getZOffset = function () {
  30971. return this._depthCullingState.zOffset;
  30972. };
  30973. /**
  30974. * Enable or disable depth buffering
  30975. * @param enable defines the state to set
  30976. */
  30977. Engine.prototype.setDepthBuffer = function (enable) {
  30978. this._depthCullingState.depthTest = enable;
  30979. };
  30980. /**
  30981. * Gets a boolean indicating if depth writing is enabled
  30982. * @returns the current depth writing state
  30983. */
  30984. Engine.prototype.getDepthWrite = function () {
  30985. return this._depthCullingState.depthMask;
  30986. };
  30987. /**
  30988. * Enable or disable depth writing
  30989. * @param enable defines the state to set
  30990. */
  30991. Engine.prototype.setDepthWrite = function (enable) {
  30992. this._depthCullingState.depthMask = enable;
  30993. };
  30994. /**
  30995. * Enable or disable color writing
  30996. * @param enable defines the state to set
  30997. */
  30998. Engine.prototype.setColorWrite = function (enable) {
  30999. this._gl.colorMask(enable, enable, enable, enable);
  31000. this._colorWrite = enable;
  31001. };
  31002. /**
  31003. * Gets a boolean indicating if color writing is enabled
  31004. * @returns the current color writing state
  31005. */
  31006. Engine.prototype.getColorWrite = function () {
  31007. return this._colorWrite;
  31008. };
  31009. /**
  31010. * Sets alpha constants used by some alpha blending modes
  31011. * @param r defines the red component
  31012. * @param g defines the green component
  31013. * @param b defines the blue component
  31014. * @param a defines the alpha component
  31015. */
  31016. Engine.prototype.setAlphaConstants = function (r, g, b, a) {
  31017. this._alphaState.setAlphaBlendConstants(r, g, b, a);
  31018. };
  31019. /**
  31020. * Sets the current alpha mode
  31021. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31022. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31023. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31024. */
  31025. Engine.prototype.setAlphaMode = function (mode, noDepthWriteChange) {
  31026. if (noDepthWriteChange === void 0) { noDepthWriteChange = false; }
  31027. if (this._alphaMode === mode) {
  31028. return;
  31029. }
  31030. switch (mode) {
  31031. case Engine.ALPHA_DISABLE:
  31032. this._alphaState.alphaBlend = false;
  31033. break;
  31034. case Engine.ALPHA_PREMULTIPLIED:
  31035. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE);
  31036. this._alphaState.alphaBlend = true;
  31037. break;
  31038. case Engine.ALPHA_PREMULTIPLIED_PORTERDUFF:
  31039. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA);
  31040. this._alphaState.alphaBlend = true;
  31041. break;
  31042. case Engine.ALPHA_COMBINE:
  31043. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE);
  31044. this._alphaState.alphaBlend = true;
  31045. break;
  31046. case Engine.ALPHA_ONEONE:
  31047. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ZERO, this._gl.ONE);
  31048. this._alphaState.alphaBlend = true;
  31049. break;
  31050. case Engine.ALPHA_ADD:
  31051. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE, this._gl.ZERO, this._gl.ONE);
  31052. this._alphaState.alphaBlend = true;
  31053. break;
  31054. case Engine.ALPHA_SUBTRACT:
  31055. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ZERO, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE);
  31056. this._alphaState.alphaBlend = true;
  31057. break;
  31058. case Engine.ALPHA_MULTIPLY:
  31059. this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR, this._gl.ZERO, this._gl.ONE, this._gl.ONE);
  31060. this._alphaState.alphaBlend = true;
  31061. break;
  31062. case Engine.ALPHA_MAXIMIZED:
  31063. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE);
  31064. this._alphaState.alphaBlend = true;
  31065. break;
  31066. case Engine.ALPHA_INTERPOLATE:
  31067. this._alphaState.setAlphaBlendFunctionParameters(this._gl.CONSTANT_COLOR, this._gl.ONE_MINUS_CONSTANT_COLOR, this._gl.CONSTANT_ALPHA, this._gl.ONE_MINUS_CONSTANT_ALPHA);
  31068. this._alphaState.alphaBlend = true;
  31069. break;
  31070. case Engine.ALPHA_SCREENMODE:
  31071. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA);
  31072. this._alphaState.alphaBlend = true;
  31073. break;
  31074. }
  31075. if (!noDepthWriteChange) {
  31076. this.setDepthWrite(mode === Engine.ALPHA_DISABLE);
  31077. }
  31078. this._alphaMode = mode;
  31079. };
  31080. /**
  31081. * Gets the current alpha mode
  31082. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31083. * @returns the current alpha mode
  31084. */
  31085. Engine.prototype.getAlphaMode = function () {
  31086. return this._alphaMode;
  31087. };
  31088. // Textures
  31089. /**
  31090. * Clears the list of texture accessible through engine.
  31091. * This can help preventing texture load conflict due to name collision.
  31092. */
  31093. Engine.prototype.clearInternalTexturesCache = function () {
  31094. this._internalTexturesCache = [];
  31095. };
  31096. /**
  31097. * Force the entire cache to be cleared
  31098. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31099. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31100. */
  31101. Engine.prototype.wipeCaches = function (bruteForce) {
  31102. if (this.preventCacheWipeBetweenFrames && !bruteForce) {
  31103. return;
  31104. }
  31105. this._currentEffect = null;
  31106. this._viewportCached.x = 0;
  31107. this._viewportCached.y = 0;
  31108. this._viewportCached.z = 0;
  31109. this._viewportCached.w = 0;
  31110. if (bruteForce) {
  31111. this.resetTextureCache();
  31112. this._currentProgram = null;
  31113. this._stencilState.reset();
  31114. this._depthCullingState.reset();
  31115. this.setDepthFunctionToLessOrEqual();
  31116. this._alphaState.reset();
  31117. this._unpackFlipYCached = null;
  31118. }
  31119. this._resetVertexBufferBinding();
  31120. this._cachedIndexBuffer = null;
  31121. this._cachedEffectForVertexBuffers = null;
  31122. this._unbindVertexArrayObject();
  31123. this.bindIndexBuffer(null);
  31124. };
  31125. /**
  31126. * Set the compressed texture format to use, based on the formats you have, and the formats
  31127. * supported by the hardware / browser.
  31128. *
  31129. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31130. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31131. * to API arguments needed to compressed textures. This puts the burden on the container
  31132. * generator to house the arcane code for determining these for current & future formats.
  31133. *
  31134. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31135. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31136. *
  31137. * Note: The result of this call is not taken into account when a texture is base64.
  31138. *
  31139. * @param formatsAvailable defines the list of those format families you have created
  31140. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31141. *
  31142. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31143. * @returns The extension selected.
  31144. */
  31145. Engine.prototype.setTextureFormatToUse = function (formatsAvailable) {
  31146. for (var i = 0, len1 = this.texturesSupported.length; i < len1; i++) {
  31147. for (var j = 0, len2 = formatsAvailable.length; j < len2; j++) {
  31148. if (this._texturesSupported[i] === formatsAvailable[j].toLowerCase()) {
  31149. return this._textureFormatInUse = this._texturesSupported[i];
  31150. }
  31151. }
  31152. }
  31153. // actively set format to nothing, to allow this to be called more than once
  31154. // and possibly fail the 2nd time
  31155. this._textureFormatInUse = null;
  31156. return null;
  31157. };
  31158. Engine.prototype._getSamplingParameters = function (samplingMode, generateMipMaps) {
  31159. var gl = this._gl;
  31160. var magFilter = gl.NEAREST;
  31161. var minFilter = gl.NEAREST;
  31162. switch (samplingMode) {
  31163. case Engine.TEXTURE_BILINEAR_SAMPLINGMODE:
  31164. magFilter = gl.LINEAR;
  31165. if (generateMipMaps) {
  31166. minFilter = gl.LINEAR_MIPMAP_NEAREST;
  31167. }
  31168. else {
  31169. minFilter = gl.LINEAR;
  31170. }
  31171. break;
  31172. case Engine.TEXTURE_TRILINEAR_SAMPLINGMODE:
  31173. magFilter = gl.LINEAR;
  31174. if (generateMipMaps) {
  31175. minFilter = gl.LINEAR_MIPMAP_LINEAR;
  31176. }
  31177. else {
  31178. minFilter = gl.LINEAR;
  31179. }
  31180. break;
  31181. case Engine.TEXTURE_NEAREST_SAMPLINGMODE:
  31182. magFilter = gl.NEAREST;
  31183. if (generateMipMaps) {
  31184. minFilter = gl.NEAREST_MIPMAP_LINEAR;
  31185. }
  31186. else {
  31187. minFilter = gl.NEAREST;
  31188. }
  31189. break;
  31190. case Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST:
  31191. magFilter = gl.NEAREST;
  31192. if (generateMipMaps) {
  31193. minFilter = gl.NEAREST_MIPMAP_NEAREST;
  31194. }
  31195. else {
  31196. minFilter = gl.NEAREST;
  31197. }
  31198. break;
  31199. case Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST:
  31200. magFilter = gl.NEAREST;
  31201. if (generateMipMaps) {
  31202. minFilter = gl.LINEAR_MIPMAP_NEAREST;
  31203. }
  31204. else {
  31205. minFilter = gl.LINEAR;
  31206. }
  31207. break;
  31208. case Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR:
  31209. magFilter = gl.NEAREST;
  31210. if (generateMipMaps) {
  31211. minFilter = gl.LINEAR_MIPMAP_LINEAR;
  31212. }
  31213. else {
  31214. minFilter = gl.LINEAR;
  31215. }
  31216. break;
  31217. case Engine.TEXTURE_NEAREST_LINEAR:
  31218. magFilter = gl.NEAREST;
  31219. minFilter = gl.LINEAR;
  31220. break;
  31221. case Engine.TEXTURE_NEAREST_NEAREST:
  31222. magFilter = gl.NEAREST;
  31223. minFilter = gl.NEAREST;
  31224. break;
  31225. case Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST:
  31226. magFilter = gl.LINEAR;
  31227. if (generateMipMaps) {
  31228. minFilter = gl.NEAREST_MIPMAP_NEAREST;
  31229. }
  31230. else {
  31231. minFilter = gl.NEAREST;
  31232. }
  31233. break;
  31234. case Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR:
  31235. magFilter = gl.LINEAR;
  31236. if (generateMipMaps) {
  31237. minFilter = gl.NEAREST_MIPMAP_LINEAR;
  31238. }
  31239. else {
  31240. minFilter = gl.NEAREST;
  31241. }
  31242. break;
  31243. case Engine.TEXTURE_LINEAR_LINEAR:
  31244. magFilter = gl.LINEAR;
  31245. minFilter = gl.LINEAR;
  31246. break;
  31247. case Engine.TEXTURE_LINEAR_NEAREST:
  31248. magFilter = gl.LINEAR;
  31249. minFilter = gl.NEAREST;
  31250. break;
  31251. }
  31252. return {
  31253. min: minFilter,
  31254. mag: magFilter
  31255. };
  31256. };
  31257. Engine.prototype._partialLoadImg = function (url, index, loadedImages, scene, onfinish, onErrorCallBack) {
  31258. if (onErrorCallBack === void 0) { onErrorCallBack = null; }
  31259. var img;
  31260. var onload = function () {
  31261. loadedImages[index] = img;
  31262. loadedImages._internalCount++;
  31263. if (scene) {
  31264. scene._removePendingData(img);
  31265. }
  31266. if (loadedImages._internalCount === 6) {
  31267. onfinish(loadedImages);
  31268. }
  31269. };
  31270. var onerror = function (message, exception) {
  31271. if (scene) {
  31272. scene._removePendingData(img);
  31273. }
  31274. if (onErrorCallBack) {
  31275. onErrorCallBack(message, exception);
  31276. }
  31277. };
  31278. img = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(url, onload, onerror, scene ? scene.offlineProvider : null);
  31279. if (scene) {
  31280. scene._addPendingData(img);
  31281. }
  31282. };
  31283. Engine.prototype._cascadeLoadImgs = function (scene, onfinish, files, onError) {
  31284. if (onError === void 0) { onError = null; }
  31285. var loadedImages = [];
  31286. loadedImages._internalCount = 0;
  31287. for (var index = 0; index < 6; index++) {
  31288. this._partialLoadImg(files[index], index, loadedImages, scene, onfinish, onError);
  31289. }
  31290. };
  31291. /** @hidden */
  31292. Engine.prototype._createTexture = function () {
  31293. var texture = this._gl.createTexture();
  31294. if (!texture) {
  31295. throw new Error("Unable to create texture");
  31296. }
  31297. return texture;
  31298. };
  31299. /**
  31300. * Usually called from Texture.ts.
  31301. * Passed information to create a WebGLTexture
  31302. * @param urlArg defines a value which contains one of the following:
  31303. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31304. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31305. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31306. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31307. * @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)
  31308. * @param scene needed for loading to the correct scene
  31309. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31310. * @param onLoad optional callback to be called upon successful completion
  31311. * @param onError optional callback to be called upon failure
  31312. * @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
  31313. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31314. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31315. * @param forcedExtension defines the extension to use to pick the right loader
  31316. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31317. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31318. */
  31319. Engine.prototype.createTexture = function (urlArg, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallback, format, forcedExtension, excludeLoaders) {
  31320. var _this = this;
  31321. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  31322. if (onLoad === void 0) { onLoad = null; }
  31323. if (onError === void 0) { onError = null; }
  31324. if (buffer === void 0) { buffer = null; }
  31325. if (fallback === void 0) { fallback = null; }
  31326. if (format === void 0) { format = null; }
  31327. if (forcedExtension === void 0) { forcedExtension = null; }
  31328. if (excludeLoaders === void 0) { excludeLoaders = []; }
  31329. var url = String(urlArg); // assign a new string, so that the original is still available in case of fallback
  31330. var fromData = url.substr(0, 5) === "data:";
  31331. var fromBlob = url.substr(0, 5) === "blob:";
  31332. var isBase64 = fromData && url.indexOf(";base64,") !== -1;
  31333. var texture = fallback ? fallback : new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_URL);
  31334. // establish the file extension, if possible
  31335. var lastDot = url.lastIndexOf('.');
  31336. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? url.substring(lastDot).toLowerCase() : "");
  31337. var loader = null;
  31338. for (var _i = 0, _a = Engine._TextureLoaders; _i < _a.length; _i++) {
  31339. var availableLoader = _a[_i];
  31340. if (excludeLoaders.indexOf(availableLoader) === -1 && availableLoader.canLoad(extension, this._textureFormatInUse, fallback, isBase64, buffer ? true : false)) {
  31341. loader = availableLoader;
  31342. break;
  31343. }
  31344. }
  31345. if (loader) {
  31346. url = loader.transformUrl(url, this._textureFormatInUse);
  31347. }
  31348. if (scene) {
  31349. scene._addPendingData(texture);
  31350. }
  31351. texture.url = url;
  31352. texture.generateMipMaps = !noMipmap;
  31353. texture.samplingMode = samplingMode;
  31354. texture.invertY = invertY;
  31355. if (!this._doNotHandleContextLost) {
  31356. // Keep a link to the buffer only if we plan to handle context lost
  31357. texture._buffer = buffer;
  31358. }
  31359. var onLoadObserver = null;
  31360. if (onLoad && !fallback) {
  31361. onLoadObserver = texture.onLoadedObservable.add(onLoad);
  31362. }
  31363. if (!fallback) {
  31364. this._internalTexturesCache.push(texture);
  31365. }
  31366. var onInternalError = function (message, exception) {
  31367. if (scene) {
  31368. scene._removePendingData(texture);
  31369. }
  31370. var customFallback = false;
  31371. if (loader) {
  31372. var fallbackUrl = loader.getFallbackTextureUrl(url, _this._textureFormatInUse);
  31373. if (fallbackUrl) {
  31374. // Add Back
  31375. customFallback = true;
  31376. excludeLoaders.push(loader);
  31377. _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");
  31378. _this.createTexture(urlArg, noMipmap, texture.invertY, scene, samplingMode, null, null, buffer, texture, undefined, undefined, excludeLoaders);
  31379. }
  31380. }
  31381. if (!customFallback) {
  31382. if (onLoadObserver) {
  31383. texture.onLoadedObservable.remove(onLoadObserver);
  31384. }
  31385. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].UseFallbackTexture) {
  31386. _this.createTexture(_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].fallbackTexture, noMipmap, texture.invertY, scene, samplingMode, null, null, buffer, texture);
  31387. }
  31388. }
  31389. if (onError) {
  31390. onError(message || "Unknown error", exception);
  31391. }
  31392. };
  31393. // processing for non-image formats
  31394. if (loader) {
  31395. var callback = function (data) {
  31396. loader.loadData(data, texture, function (width, height, loadMipmap, isCompressed, done, loadFailed) {
  31397. if (loadFailed) {
  31398. onInternalError("TextureLoader failed to load data");
  31399. }
  31400. else {
  31401. _this._prepareWebGLTexture(texture, scene, width, height, texture.invertY, !loadMipmap, isCompressed, function () {
  31402. done();
  31403. return false;
  31404. }, samplingMode);
  31405. }
  31406. });
  31407. };
  31408. if (!buffer) {
  31409. this._loadFile(url, callback, undefined, scene ? scene.offlineProvider : undefined, true, function (request, exception) {
  31410. onInternalError("Unable to load " + (request ? request.responseURL : url, exception));
  31411. });
  31412. }
  31413. else {
  31414. callback(buffer);
  31415. }
  31416. }
  31417. else {
  31418. var onload = function (img) {
  31419. if (fromBlob && !_this._doNotHandleContextLost) {
  31420. // We need to store the image if we need to rebuild the texture
  31421. // in case of a webgl context lost
  31422. texture._buffer = img;
  31423. }
  31424. _this._prepareWebGLTexture(texture, scene, img.width, img.height, texture.invertY, noMipmap, false, function (potWidth, potHeight, continuationCallback) {
  31425. var gl = _this._gl;
  31426. var isPot = (img.width === potWidth && img.height === potHeight);
  31427. var internalFormat = format ? _this._getInternalFormat(format) : ((extension === ".jpg") ? gl.RGB : gl.RGBA);
  31428. if (isPot) {
  31429. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, img);
  31430. return false;
  31431. }
  31432. var maxTextureSize = _this._caps.maxTextureSize;
  31433. if (img.width > maxTextureSize || img.height > maxTextureSize || Engine._RescalePostProcessFactory === null) {
  31434. _this._prepareWorkingCanvas();
  31435. if (!_this._workingCanvas || !_this._workingContext) {
  31436. return false;
  31437. }
  31438. _this._workingCanvas.width = potWidth;
  31439. _this._workingCanvas.height = potHeight;
  31440. _this._workingContext.drawImage(img, 0, 0, img.width, img.height, 0, 0, potWidth, potHeight);
  31441. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, _this._workingCanvas);
  31442. texture.width = potWidth;
  31443. texture.height = potHeight;
  31444. return false;
  31445. }
  31446. else {
  31447. // Using shaders when possible to rescale because canvas.drawImage is lossy
  31448. var source_1 = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](_this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_TEMP);
  31449. _this._bindTextureDirectly(gl.TEXTURE_2D, source_1, true);
  31450. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, img);
  31451. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  31452. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
  31453. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31454. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31455. _this._rescaleTexture(source_1, texture, scene, internalFormat, function () {
  31456. _this._releaseTexture(source_1);
  31457. _this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  31458. continuationCallback();
  31459. });
  31460. }
  31461. return true;
  31462. }, samplingMode);
  31463. };
  31464. if (!fromData || isBase64) {
  31465. if (buffer instanceof HTMLImageElement) {
  31466. onload(buffer);
  31467. }
  31468. else {
  31469. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(url, onload, onInternalError, scene ? scene.offlineProvider : null);
  31470. }
  31471. }
  31472. else if (typeof buffer === "string" || buffer instanceof ArrayBuffer || buffer instanceof Blob) {
  31473. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(buffer, onload, onInternalError, scene ? scene.offlineProvider : null);
  31474. }
  31475. else {
  31476. onload(buffer);
  31477. }
  31478. }
  31479. return texture;
  31480. };
  31481. Engine.prototype._rescaleTexture = function (source, destination, scene, internalFormat, onComplete) {
  31482. var _this = this;
  31483. var rtt = this.createRenderTargetTexture({
  31484. width: destination.width,
  31485. height: destination.height,
  31486. }, {
  31487. generateMipMaps: false,
  31488. type: Engine.TEXTURETYPE_UNSIGNED_INT,
  31489. samplingMode: Engine.TEXTURE_BILINEAR_SAMPLINGMODE,
  31490. generateDepthBuffer: false,
  31491. generateStencilBuffer: false
  31492. });
  31493. if (!this._rescalePostProcess && Engine._RescalePostProcessFactory) {
  31494. this._rescalePostProcess = Engine._RescalePostProcessFactory(this);
  31495. }
  31496. this._rescalePostProcess.getEffect().executeWhenCompiled(function () {
  31497. _this._rescalePostProcess.onApply = function (effect) {
  31498. effect._bindTexture("textureSampler", source);
  31499. };
  31500. var hostingScene = scene;
  31501. if (!hostingScene) {
  31502. hostingScene = _this.scenes[_this.scenes.length - 1];
  31503. }
  31504. hostingScene.postProcessManager.directRender([_this._rescalePostProcess], rtt, true);
  31505. _this._bindTextureDirectly(_this._gl.TEXTURE_2D, destination, true);
  31506. _this._gl.copyTexImage2D(_this._gl.TEXTURE_2D, 0, internalFormat, 0, 0, destination.width, destination.height, 0);
  31507. _this.unBindFramebuffer(rtt);
  31508. _this._releaseTexture(rtt);
  31509. if (onComplete) {
  31510. onComplete();
  31511. }
  31512. });
  31513. };
  31514. /**
  31515. * Update a raw texture
  31516. * @param texture defines the texture to update
  31517. * @param data defines the data to store in the texture
  31518. * @param format defines the format of the data
  31519. * @param invertY defines if data must be stored with Y axis inverted
  31520. * @param compression defines the compression used (null by default)
  31521. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31522. */
  31523. Engine.prototype.updateRawTexture = function (texture, data, format, invertY, compression, type) {
  31524. if (compression === void 0) { compression = null; }
  31525. if (type === void 0) { type = Engine.TEXTURETYPE_UNSIGNED_INT; }
  31526. if (!texture) {
  31527. return;
  31528. }
  31529. // babylon's internalSizedFomat but gl's texImage2D internalFormat
  31530. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(type, format);
  31531. // babylon's internalFormat but gl's texImage2D format
  31532. var internalFormat = this._getInternalFormat(format);
  31533. var textureType = this._getWebGLTextureType(type);
  31534. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  31535. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  31536. if (!this._doNotHandleContextLost) {
  31537. texture._bufferView = data;
  31538. texture.format = format;
  31539. texture.type = type;
  31540. texture.invertY = invertY;
  31541. texture._compression = compression;
  31542. }
  31543. if (texture.width % 4 !== 0) {
  31544. this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);
  31545. }
  31546. if (compression && data) {
  31547. this._gl.compressedTexImage2D(this._gl.TEXTURE_2D, 0, this.getCaps().s3tc[compression], texture.width, texture.height, 0, data);
  31548. }
  31549. else {
  31550. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalSizedFomat, texture.width, texture.height, 0, internalFormat, textureType, data);
  31551. }
  31552. if (texture.generateMipMaps) {
  31553. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31554. }
  31555. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31556. // this.resetTextureCache();
  31557. texture.isReady = true;
  31558. };
  31559. /**
  31560. * Creates a raw texture
  31561. * @param data defines the data to store in the texture
  31562. * @param width defines the width of the texture
  31563. * @param height defines the height of the texture
  31564. * @param format defines the format of the data
  31565. * @param generateMipMaps defines if the engine should generate the mip levels
  31566. * @param invertY defines if data must be stored with Y axis inverted
  31567. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31568. * @param compression defines the compression used (null by default)
  31569. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31570. * @returns the raw texture inside an InternalTexture
  31571. */
  31572. Engine.prototype.createRawTexture = function (data, width, height, format, generateMipMaps, invertY, samplingMode, compression, type) {
  31573. if (compression === void 0) { compression = null; }
  31574. if (type === void 0) { type = Engine.TEXTURETYPE_UNSIGNED_INT; }
  31575. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RAW);
  31576. texture.baseWidth = width;
  31577. texture.baseHeight = height;
  31578. texture.width = width;
  31579. texture.height = height;
  31580. texture.format = format;
  31581. texture.generateMipMaps = generateMipMaps;
  31582. texture.samplingMode = samplingMode;
  31583. texture.invertY = invertY;
  31584. texture._compression = compression;
  31585. texture.type = type;
  31586. if (!this._doNotHandleContextLost) {
  31587. texture._bufferView = data;
  31588. }
  31589. this.updateRawTexture(texture, data, format, invertY, compression, type);
  31590. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  31591. // Filters
  31592. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  31593. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, filters.mag);
  31594. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  31595. if (generateMipMaps) {
  31596. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31597. }
  31598. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31599. this._internalTexturesCache.push(texture);
  31600. return texture;
  31601. };
  31602. /** @hidden */
  31603. Engine.prototype._unpackFlipY = function (value) {
  31604. if (this._unpackFlipYCached !== value) {
  31605. this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, value ? 1 : 0);
  31606. if (this.enableUnpackFlipYCached) {
  31607. this._unpackFlipYCached = value;
  31608. }
  31609. }
  31610. };
  31611. /** @hidden */
  31612. Engine.prototype._getUnpackAlignement = function () {
  31613. return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT);
  31614. };
  31615. /**
  31616. * Creates a dynamic texture
  31617. * @param width defines the width of the texture
  31618. * @param height defines the height of the texture
  31619. * @param generateMipMaps defines if the engine should generate the mip levels
  31620. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31621. * @returns the dynamic texture inside an InternalTexture
  31622. */
  31623. Engine.prototype.createDynamicTexture = function (width, height, generateMipMaps, samplingMode) {
  31624. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_DYNAMIC);
  31625. texture.baseWidth = width;
  31626. texture.baseHeight = height;
  31627. if (generateMipMaps) {
  31628. width = this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(width, this._caps.maxTextureSize) : width;
  31629. height = this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(height, this._caps.maxTextureSize) : height;
  31630. }
  31631. // this.resetTextureCache();
  31632. texture.width = width;
  31633. texture.height = height;
  31634. texture.isReady = false;
  31635. texture.generateMipMaps = generateMipMaps;
  31636. texture.samplingMode = samplingMode;
  31637. this.updateTextureSamplingMode(samplingMode, texture);
  31638. this._internalTexturesCache.push(texture);
  31639. return texture;
  31640. };
  31641. /**
  31642. * Update the sampling mode of a given texture
  31643. * @param samplingMode defines the required sampling mode
  31644. * @param texture defines the texture to update
  31645. */
  31646. Engine.prototype.updateTextureSamplingMode = function (samplingMode, texture) {
  31647. var filters = this._getSamplingParameters(samplingMode, texture.generateMipMaps);
  31648. if (texture.isCube) {
  31649. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  31650. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_MIN_FILTER, filters.min);
  31651. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  31652. }
  31653. else if (texture.is3D) {
  31654. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  31655. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  31656. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  31657. }
  31658. else {
  31659. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  31660. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  31661. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31662. }
  31663. texture.samplingMode = samplingMode;
  31664. };
  31665. /**
  31666. * Update the content of a dynamic texture
  31667. * @param texture defines the texture to update
  31668. * @param canvas defines the canvas containing the source
  31669. * @param invertY defines if data must be stored with Y axis inverted
  31670. * @param premulAlpha defines if alpha is stored as premultiplied
  31671. * @param format defines the format of the data
  31672. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  31673. */
  31674. Engine.prototype.updateDynamicTexture = function (texture, canvas, invertY, premulAlpha, format, forceBindTexture) {
  31675. if (premulAlpha === void 0) { premulAlpha = false; }
  31676. if (forceBindTexture === void 0) { forceBindTexture = false; }
  31677. if (!texture) {
  31678. return;
  31679. }
  31680. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true, forceBindTexture);
  31681. this._unpackFlipY(invertY);
  31682. if (premulAlpha) {
  31683. this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1);
  31684. }
  31685. var internalFormat = format ? this._getInternalFormat(format) : this._gl.RGBA;
  31686. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalFormat, internalFormat, this._gl.UNSIGNED_BYTE, canvas);
  31687. if (texture.generateMipMaps) {
  31688. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31689. }
  31690. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31691. if (premulAlpha) {
  31692. this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0);
  31693. }
  31694. texture.isReady = true;
  31695. };
  31696. /**
  31697. * Update a video texture
  31698. * @param texture defines the texture to update
  31699. * @param video defines the video element to use
  31700. * @param invertY defines if data must be stored with Y axis inverted
  31701. */
  31702. Engine.prototype.updateVideoTexture = function (texture, video, invertY) {
  31703. if (!texture || texture._isDisabled) {
  31704. return;
  31705. }
  31706. var wasPreviouslyBound = this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  31707. this._unpackFlipY(!invertY); // Video are upside down by default
  31708. try {
  31709. // Testing video texture support
  31710. if (this._videoTextureSupported === undefined) {
  31711. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, video);
  31712. if (this._gl.getError() !== 0) {
  31713. this._videoTextureSupported = false;
  31714. }
  31715. else {
  31716. this._videoTextureSupported = true;
  31717. }
  31718. }
  31719. // Copy video through the current working canvas if video texture is not supported
  31720. if (!this._videoTextureSupported) {
  31721. if (!texture._workingCanvas) {
  31722. texture._workingCanvas = document.createElement("canvas");
  31723. var context = texture._workingCanvas.getContext("2d");
  31724. if (!context) {
  31725. throw new Error("Unable to get 2d context");
  31726. }
  31727. texture._workingContext = context;
  31728. texture._workingCanvas.width = texture.width;
  31729. texture._workingCanvas.height = texture.height;
  31730. }
  31731. texture._workingContext.drawImage(video, 0, 0, video.videoWidth, video.videoHeight, 0, 0, texture.width, texture.height);
  31732. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, texture._workingCanvas);
  31733. }
  31734. else {
  31735. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, video);
  31736. }
  31737. if (texture.generateMipMaps) {
  31738. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31739. }
  31740. if (!wasPreviouslyBound) {
  31741. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31742. }
  31743. // this.resetTextureCache();
  31744. texture.isReady = true;
  31745. }
  31746. catch (ex) {
  31747. // Something unexpected
  31748. // Let's disable the texture
  31749. texture._isDisabled = true;
  31750. }
  31751. };
  31752. /**
  31753. * Updates a depth texture Comparison Mode and Function.
  31754. * If the comparison Function is equal to 0, the mode will be set to none.
  31755. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  31756. * @param texture The texture to set the comparison function for
  31757. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  31758. */
  31759. Engine.prototype.updateTextureComparisonFunction = function (texture, comparisonFunction) {
  31760. if (this.webGLVersion === 1) {
  31761. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Error("WebGL 1 does not support texture comparison.");
  31762. return;
  31763. }
  31764. var gl = this._gl;
  31765. if (texture.isCube) {
  31766. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, texture, true);
  31767. if (comparisonFunction === 0) {
  31768. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  31769. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  31770. }
  31771. else {
  31772. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  31773. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  31774. }
  31775. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  31776. }
  31777. else {
  31778. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  31779. if (comparisonFunction === 0) {
  31780. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  31781. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  31782. }
  31783. else {
  31784. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  31785. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  31786. }
  31787. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31788. }
  31789. texture._comparisonFunction = comparisonFunction;
  31790. };
  31791. Engine.prototype._setupDepthStencilTexture = function (internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction) {
  31792. var width = size.width || size;
  31793. var height = size.height || size;
  31794. internalTexture.baseWidth = width;
  31795. internalTexture.baseHeight = height;
  31796. internalTexture.width = width;
  31797. internalTexture.height = height;
  31798. internalTexture.isReady = true;
  31799. internalTexture.samples = 1;
  31800. internalTexture.generateMipMaps = false;
  31801. internalTexture._generateDepthBuffer = true;
  31802. internalTexture._generateStencilBuffer = generateStencil;
  31803. internalTexture.samplingMode = bilinearFiltering ? Engine.TEXTURE_BILINEAR_SAMPLINGMODE : Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31804. internalTexture.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  31805. internalTexture._comparisonFunction = comparisonFunction;
  31806. var gl = this._gl;
  31807. var target = internalTexture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  31808. var samplingParameters = this._getSamplingParameters(internalTexture.samplingMode, false);
  31809. gl.texParameteri(target, gl.TEXTURE_MAG_FILTER, samplingParameters.mag);
  31810. gl.texParameteri(target, gl.TEXTURE_MIN_FILTER, samplingParameters.min);
  31811. gl.texParameteri(target, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31812. gl.texParameteri(target, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31813. if (comparisonFunction === 0) {
  31814. gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  31815. gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  31816. }
  31817. else {
  31818. gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  31819. gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  31820. }
  31821. };
  31822. /**
  31823. * Creates a depth stencil texture.
  31824. * This is only available in WebGL 2 or with the depth texture extension available.
  31825. * @param size The size of face edge in the texture.
  31826. * @param options The options defining the texture.
  31827. * @returns The texture
  31828. */
  31829. Engine.prototype.createDepthStencilTexture = function (size, options) {
  31830. if (options.isCube) {
  31831. var width = size.width || size;
  31832. return this._createDepthStencilCubeTexture(width, options);
  31833. }
  31834. else {
  31835. return this._createDepthStencilTexture(size, options);
  31836. }
  31837. };
  31838. /**
  31839. * Creates a depth stencil texture.
  31840. * This is only available in WebGL 2 or with the depth texture extension available.
  31841. * @param size The size of face edge in the texture.
  31842. * @param options The options defining the texture.
  31843. * @returns The texture
  31844. */
  31845. Engine.prototype._createDepthStencilTexture = function (size, options) {
  31846. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_DEPTHTEXTURE);
  31847. if (!this._caps.depthTextureExtension) {
  31848. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Error("Depth texture is not supported by your browser or hardware.");
  31849. return internalTexture;
  31850. }
  31851. var internalOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ bilinearFiltering: false, comparisonFunction: 0, generateStencil: false }, options);
  31852. var gl = this._gl;
  31853. this._bindTextureDirectly(gl.TEXTURE_2D, internalTexture, true);
  31854. this._setupDepthStencilTexture(internalTexture, size, internalOptions.generateStencil, internalOptions.bilinearFiltering, internalOptions.comparisonFunction);
  31855. if (this.webGLVersion > 1) {
  31856. if (internalOptions.generateStencil) {
  31857. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH24_STENCIL8, internalTexture.width, internalTexture.height, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_INT_24_8, null);
  31858. }
  31859. else {
  31860. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT24, internalTexture.width, internalTexture.height, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  31861. }
  31862. }
  31863. else {
  31864. if (internalOptions.generateStencil) {
  31865. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_STENCIL, internalTexture.width, internalTexture.height, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_INT_24_8, null);
  31866. }
  31867. else {
  31868. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT, internalTexture.width, internalTexture.height, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  31869. }
  31870. }
  31871. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  31872. return internalTexture;
  31873. };
  31874. /**
  31875. * Creates a depth stencil cube texture.
  31876. * This is only available in WebGL 2.
  31877. * @param size The size of face edge in the cube texture.
  31878. * @param options The options defining the cube texture.
  31879. * @returns The cube texture
  31880. */
  31881. Engine.prototype._createDepthStencilCubeTexture = function (size, options) {
  31882. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_UNKNOWN);
  31883. internalTexture.isCube = true;
  31884. if (this.webGLVersion === 1) {
  31885. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Error("Depth cube texture is not supported by WebGL 1.");
  31886. return internalTexture;
  31887. }
  31888. var internalOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ bilinearFiltering: false, comparisonFunction: 0, generateStencil: false }, options);
  31889. var gl = this._gl;
  31890. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, internalTexture, true);
  31891. this._setupDepthStencilTexture(internalTexture, size, internalOptions.generateStencil, internalOptions.bilinearFiltering, internalOptions.comparisonFunction);
  31892. // Create the depth/stencil buffer
  31893. for (var face = 0; face < 6; face++) {
  31894. if (internalOptions.generateStencil) {
  31895. 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);
  31896. }
  31897. else {
  31898. gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + face, 0, gl.DEPTH_COMPONENT24, size, size, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  31899. }
  31900. }
  31901. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  31902. return internalTexture;
  31903. };
  31904. /**
  31905. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31906. * @param renderTarget The render target to set the frame buffer for
  31907. */
  31908. Engine.prototype.setFrameBufferDepthStencilTexture = function (renderTarget) {
  31909. // Create the framebuffer
  31910. var internalTexture = renderTarget.getInternalTexture();
  31911. if (!internalTexture || !internalTexture._framebuffer || !renderTarget.depthStencilTexture) {
  31912. return;
  31913. }
  31914. var gl = this._gl;
  31915. var depthStencilTexture = renderTarget.depthStencilTexture;
  31916. this.bindUnboundFramebuffer(internalTexture._framebuffer);
  31917. if (depthStencilTexture.isCube) {
  31918. if (depthStencilTexture._generateStencilBuffer) {
  31919. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X, depthStencilTexture._webGLTexture, 0);
  31920. }
  31921. else {
  31922. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X, depthStencilTexture._webGLTexture, 0);
  31923. }
  31924. }
  31925. else {
  31926. if (depthStencilTexture._generateStencilBuffer) {
  31927. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_2D, depthStencilTexture._webGLTexture, 0);
  31928. }
  31929. else {
  31930. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, depthStencilTexture._webGLTexture, 0);
  31931. }
  31932. }
  31933. this.bindUnboundFramebuffer(null);
  31934. };
  31935. /**
  31936. * Creates a new render target texture
  31937. * @param size defines the size of the texture
  31938. * @param options defines the options used to create the texture
  31939. * @returns a new render target texture stored in an InternalTexture
  31940. */
  31941. Engine.prototype.createRenderTargetTexture = function (size, options) {
  31942. var fullOptions = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_17__["RenderTargetCreationOptions"]();
  31943. if (options !== undefined && typeof options === "object") {
  31944. fullOptions.generateMipMaps = options.generateMipMaps;
  31945. fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  31946. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;
  31947. fullOptions.type = options.type === undefined ? Engine.TEXTURETYPE_UNSIGNED_INT : options.type;
  31948. fullOptions.samplingMode = options.samplingMode === undefined ? Engine.TEXTURE_TRILINEAR_SAMPLINGMODE : options.samplingMode;
  31949. fullOptions.format = options.format === undefined ? Engine.TEXTUREFORMAT_RGBA : options.format;
  31950. }
  31951. else {
  31952. fullOptions.generateMipMaps = options;
  31953. fullOptions.generateDepthBuffer = true;
  31954. fullOptions.generateStencilBuffer = false;
  31955. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  31956. fullOptions.samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE;
  31957. fullOptions.format = Engine.TEXTUREFORMAT_RGBA;
  31958. }
  31959. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  31960. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  31961. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31962. }
  31963. else if (fullOptions.type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  31964. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  31965. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31966. }
  31967. var gl = this._gl;
  31968. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RENDERTARGET);
  31969. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  31970. var width = size.width || size;
  31971. var height = size.height || size;
  31972. var filters = this._getSamplingParameters(fullOptions.samplingMode, fullOptions.generateMipMaps ? true : false);
  31973. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  31974. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  31975. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
  31976. }
  31977. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  31978. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  31979. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31980. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31981. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(fullOptions.type, fullOptions.format), width, height, 0, this._getInternalFormat(fullOptions.format), this._getWebGLTextureType(fullOptions.type), null);
  31982. // Create the framebuffer
  31983. var currentFrameBuffer = this._currentFramebuffer;
  31984. var framebuffer = gl.createFramebuffer();
  31985. this.bindUnboundFramebuffer(framebuffer);
  31986. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, 0);
  31987. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(fullOptions.generateStencilBuffer ? true : false, fullOptions.generateDepthBuffer, width, height);
  31988. if (fullOptions.generateMipMaps) {
  31989. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31990. }
  31991. // Unbind
  31992. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  31993. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  31994. this.bindUnboundFramebuffer(currentFrameBuffer);
  31995. texture._framebuffer = framebuffer;
  31996. texture.baseWidth = width;
  31997. texture.baseHeight = height;
  31998. texture.width = width;
  31999. texture.height = height;
  32000. texture.isReady = true;
  32001. texture.samples = 1;
  32002. texture.generateMipMaps = fullOptions.generateMipMaps ? true : false;
  32003. texture.samplingMode = fullOptions.samplingMode;
  32004. texture.type = fullOptions.type;
  32005. texture.format = fullOptions.format;
  32006. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  32007. texture._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;
  32008. // this.resetTextureCache();
  32009. this._internalTexturesCache.push(texture);
  32010. return texture;
  32011. };
  32012. /**
  32013. * Create a multi render target texture
  32014. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  32015. * @param size defines the size of the texture
  32016. * @param options defines the creation options
  32017. * @returns the cube texture as an InternalTexture
  32018. */
  32019. Engine.prototype.createMultipleRenderTarget = function (size, options) {
  32020. var generateMipMaps = false;
  32021. var generateDepthBuffer = true;
  32022. var generateStencilBuffer = false;
  32023. var generateDepthTexture = false;
  32024. var textureCount = 1;
  32025. var defaultType = Engine.TEXTURETYPE_UNSIGNED_INT;
  32026. var defaultSamplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE;
  32027. var types = new Array();
  32028. var samplingModes = new Array();
  32029. if (options !== undefined) {
  32030. generateMipMaps = options.generateMipMaps === undefined ? false : options.generateMipMaps;
  32031. generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  32032. generateStencilBuffer = options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;
  32033. generateDepthTexture = options.generateDepthTexture === undefined ? false : options.generateDepthTexture;
  32034. textureCount = options.textureCount || 1;
  32035. if (options.types) {
  32036. types = options.types;
  32037. }
  32038. if (options.samplingModes) {
  32039. samplingModes = options.samplingModes;
  32040. }
  32041. }
  32042. var gl = this._gl;
  32043. // Create the framebuffer
  32044. var framebuffer = gl.createFramebuffer();
  32045. this.bindUnboundFramebuffer(framebuffer);
  32046. var width = size.width || size;
  32047. var height = size.height || size;
  32048. var textures = [];
  32049. var attachments = [];
  32050. var depthStencilBuffer = this._setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height);
  32051. for (var i = 0; i < textureCount; i++) {
  32052. var samplingMode = samplingModes[i] || defaultSamplingMode;
  32053. var type = types[i] || defaultType;
  32054. if (type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  32055. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  32056. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32057. }
  32058. else if (type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  32059. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  32060. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32061. }
  32062. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  32063. if (type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  32064. type = Engine.TEXTURETYPE_UNSIGNED_INT;
  32065. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
  32066. }
  32067. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_MULTIRENDERTARGET);
  32068. var attachment = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  32069. textures.push(texture);
  32070. attachments.push(attachment);
  32071. gl.activeTexture(gl["TEXTURE" + i]);
  32072. gl.bindTexture(gl.TEXTURE_2D, texture._webGLTexture);
  32073. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  32074. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  32075. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32076. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32077. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(type), width, height, 0, gl.RGBA, this._getWebGLTextureType(type), null);
  32078. gl.framebufferTexture2D(gl.DRAW_FRAMEBUFFER, attachment, gl.TEXTURE_2D, texture._webGLTexture, 0);
  32079. if (generateMipMaps) {
  32080. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  32081. }
  32082. // Unbind
  32083. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  32084. texture._framebuffer = framebuffer;
  32085. texture._depthStencilBuffer = depthStencilBuffer;
  32086. texture.baseWidth = width;
  32087. texture.baseHeight = height;
  32088. texture.width = width;
  32089. texture.height = height;
  32090. texture.isReady = true;
  32091. texture.samples = 1;
  32092. texture.generateMipMaps = generateMipMaps;
  32093. texture.samplingMode = samplingMode;
  32094. texture.type = type;
  32095. texture._generateDepthBuffer = generateDepthBuffer;
  32096. texture._generateStencilBuffer = generateStencilBuffer;
  32097. texture._attachments = attachments;
  32098. this._internalTexturesCache.push(texture);
  32099. }
  32100. if (generateDepthTexture && this._caps.depthTextureExtension) {
  32101. // Depth texture
  32102. var depthTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_MULTIRENDERTARGET);
  32103. gl.activeTexture(gl.TEXTURE0);
  32104. gl.bindTexture(gl.TEXTURE_2D, depthTexture._webGLTexture);
  32105. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  32106. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  32107. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32108. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32109. 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);
  32110. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, depthTexture._webGLTexture, 0);
  32111. depthTexture._framebuffer = framebuffer;
  32112. depthTexture.baseWidth = width;
  32113. depthTexture.baseHeight = height;
  32114. depthTexture.width = width;
  32115. depthTexture.height = height;
  32116. depthTexture.isReady = true;
  32117. depthTexture.samples = 1;
  32118. depthTexture.generateMipMaps = generateMipMaps;
  32119. depthTexture.samplingMode = gl.NEAREST;
  32120. depthTexture._generateDepthBuffer = generateDepthBuffer;
  32121. depthTexture._generateStencilBuffer = generateStencilBuffer;
  32122. textures.push(depthTexture);
  32123. this._internalTexturesCache.push(depthTexture);
  32124. }
  32125. gl.drawBuffers(attachments);
  32126. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  32127. this.bindUnboundFramebuffer(null);
  32128. this.resetTextureCache();
  32129. return textures;
  32130. };
  32131. Engine.prototype._setupFramebufferDepthAttachments = function (generateStencilBuffer, generateDepthBuffer, width, height, samples) {
  32132. if (samples === void 0) { samples = 1; }
  32133. var depthStencilBuffer = null;
  32134. var gl = this._gl;
  32135. // Create the depth/stencil buffer
  32136. if (generateStencilBuffer) {
  32137. depthStencilBuffer = gl.createRenderbuffer();
  32138. gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
  32139. if (samples > 1) {
  32140. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, gl.DEPTH24_STENCIL8, width, height);
  32141. }
  32142. else {
  32143. gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, width, height);
  32144. }
  32145. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer);
  32146. }
  32147. else if (generateDepthBuffer) {
  32148. depthStencilBuffer = gl.createRenderbuffer();
  32149. gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
  32150. if (samples > 1) {
  32151. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, gl.DEPTH_COMPONENT16, width, height);
  32152. }
  32153. else {
  32154. gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, width, height);
  32155. }
  32156. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer);
  32157. }
  32158. return depthStencilBuffer;
  32159. };
  32160. /**
  32161. * Updates the sample count of a render target texture
  32162. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32163. * @param texture defines the texture to update
  32164. * @param samples defines the sample count to set
  32165. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32166. */
  32167. Engine.prototype.updateRenderTargetTextureSampleCount = function (texture, samples) {
  32168. if (this.webGLVersion < 2 || !texture) {
  32169. return 1;
  32170. }
  32171. if (texture.samples === samples) {
  32172. return samples;
  32173. }
  32174. var gl = this._gl;
  32175. samples = Math.min(samples, gl.getParameter(gl.MAX_SAMPLES));
  32176. // Dispose previous render buffers
  32177. if (texture._depthStencilBuffer) {
  32178. gl.deleteRenderbuffer(texture._depthStencilBuffer);
  32179. texture._depthStencilBuffer = null;
  32180. }
  32181. if (texture._MSAAFramebuffer) {
  32182. gl.deleteFramebuffer(texture._MSAAFramebuffer);
  32183. texture._MSAAFramebuffer = null;
  32184. }
  32185. if (texture._MSAARenderBuffer) {
  32186. gl.deleteRenderbuffer(texture._MSAARenderBuffer);
  32187. texture._MSAARenderBuffer = null;
  32188. }
  32189. if (samples > 1) {
  32190. var framebuffer = gl.createFramebuffer();
  32191. if (!framebuffer) {
  32192. throw new Error("Unable to create multi sampled framebuffer");
  32193. }
  32194. texture._MSAAFramebuffer = framebuffer;
  32195. this.bindUnboundFramebuffer(texture._MSAAFramebuffer);
  32196. var colorRenderbuffer = gl.createRenderbuffer();
  32197. if (!colorRenderbuffer) {
  32198. throw new Error("Unable to create multi sampled framebuffer");
  32199. }
  32200. gl.bindRenderbuffer(gl.RENDERBUFFER, colorRenderbuffer);
  32201. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, this._getRGBAMultiSampleBufferFormat(texture.type), texture.width, texture.height);
  32202. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, colorRenderbuffer);
  32203. texture._MSAARenderBuffer = colorRenderbuffer;
  32204. }
  32205. else {
  32206. this.bindUnboundFramebuffer(texture._framebuffer);
  32207. }
  32208. texture.samples = samples;
  32209. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(texture._generateStencilBuffer, texture._generateDepthBuffer, texture.width, texture.height, samples);
  32210. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  32211. this.bindUnboundFramebuffer(null);
  32212. return samples;
  32213. };
  32214. /**
  32215. * Update the sample count for a given multiple render target texture
  32216. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32217. * @param textures defines the textures to update
  32218. * @param samples defines the sample count to set
  32219. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32220. */
  32221. Engine.prototype.updateMultipleRenderTargetTextureSampleCount = function (textures, samples) {
  32222. if (this.webGLVersion < 2 || !textures || textures.length == 0) {
  32223. return 1;
  32224. }
  32225. if (textures[0].samples === samples) {
  32226. return samples;
  32227. }
  32228. var gl = this._gl;
  32229. samples = Math.min(samples, gl.getParameter(gl.MAX_SAMPLES));
  32230. // Dispose previous render buffers
  32231. if (textures[0]._depthStencilBuffer) {
  32232. gl.deleteRenderbuffer(textures[0]._depthStencilBuffer);
  32233. textures[0]._depthStencilBuffer = null;
  32234. }
  32235. if (textures[0]._MSAAFramebuffer) {
  32236. gl.deleteFramebuffer(textures[0]._MSAAFramebuffer);
  32237. textures[0]._MSAAFramebuffer = null;
  32238. }
  32239. for (var i = 0; i < textures.length; i++) {
  32240. if (textures[i]._MSAARenderBuffer) {
  32241. gl.deleteRenderbuffer(textures[i]._MSAARenderBuffer);
  32242. textures[i]._MSAARenderBuffer = null;
  32243. }
  32244. }
  32245. if (samples > 1) {
  32246. var framebuffer = gl.createFramebuffer();
  32247. if (!framebuffer) {
  32248. throw new Error("Unable to create multi sampled framebuffer");
  32249. }
  32250. this.bindUnboundFramebuffer(framebuffer);
  32251. var depthStencilBuffer = this._setupFramebufferDepthAttachments(textures[0]._generateStencilBuffer, textures[0]._generateDepthBuffer, textures[0].width, textures[0].height, samples);
  32252. var attachments = [];
  32253. for (var i = 0; i < textures.length; i++) {
  32254. var texture = textures[i];
  32255. var attachment = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  32256. var colorRenderbuffer = gl.createRenderbuffer();
  32257. if (!colorRenderbuffer) {
  32258. throw new Error("Unable to create multi sampled framebuffer");
  32259. }
  32260. gl.bindRenderbuffer(gl.RENDERBUFFER, colorRenderbuffer);
  32261. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, this._getRGBAMultiSampleBufferFormat(texture.type), texture.width, texture.height);
  32262. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, colorRenderbuffer);
  32263. texture._MSAAFramebuffer = framebuffer;
  32264. texture._MSAARenderBuffer = colorRenderbuffer;
  32265. texture.samples = samples;
  32266. texture._depthStencilBuffer = depthStencilBuffer;
  32267. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  32268. attachments.push(attachment);
  32269. }
  32270. gl.drawBuffers(attachments);
  32271. }
  32272. else {
  32273. this.bindUnboundFramebuffer(textures[0]._framebuffer);
  32274. }
  32275. this.bindUnboundFramebuffer(null);
  32276. return samples;
  32277. };
  32278. /** @hidden */
  32279. Engine.prototype._uploadCompressedDataToTextureDirectly = function (texture, internalFormat, width, height, data, faceIndex, lod) {
  32280. if (faceIndex === void 0) { faceIndex = 0; }
  32281. if (lod === void 0) { lod = 0; }
  32282. var gl = this._gl;
  32283. var target = gl.TEXTURE_2D;
  32284. if (texture.isCube) {
  32285. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  32286. }
  32287. this._gl.compressedTexImage2D(target, lod, internalFormat, width, height, 0, data);
  32288. };
  32289. /** @hidden */
  32290. Engine.prototype._uploadDataToTextureDirectly = function (texture, imageData, faceIndex, lod) {
  32291. if (faceIndex === void 0) { faceIndex = 0; }
  32292. if (lod === void 0) { lod = 0; }
  32293. var gl = this._gl;
  32294. var textureType = this._getWebGLTextureType(texture.type);
  32295. var format = this._getInternalFormat(texture.format);
  32296. var internalFormat = this._getRGBABufferInternalSizedFormat(texture.type, format);
  32297. this._unpackFlipY(texture.invertY);
  32298. var target = gl.TEXTURE_2D;
  32299. if (texture.isCube) {
  32300. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  32301. }
  32302. var lodMaxWidth = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__["Scalar"].Log2(texture.width));
  32303. var lodMaxHeight = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__["Scalar"].Log2(texture.height));
  32304. var width = Math.pow(2, Math.max(lodMaxWidth - lod, 0));
  32305. var height = Math.pow(2, Math.max(lodMaxHeight - lod, 0));
  32306. gl.texImage2D(target, lod, internalFormat, width, height, 0, format, textureType, imageData);
  32307. };
  32308. /** @hidden */
  32309. Engine.prototype._uploadArrayBufferViewToTexture = function (texture, imageData, faceIndex, lod) {
  32310. if (faceIndex === void 0) { faceIndex = 0; }
  32311. if (lod === void 0) { lod = 0; }
  32312. var gl = this._gl;
  32313. var bindTarget = texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  32314. this._bindTextureDirectly(bindTarget, texture, true);
  32315. this._uploadDataToTextureDirectly(texture, imageData, faceIndex, lod);
  32316. this._bindTextureDirectly(bindTarget, null, true);
  32317. };
  32318. /** @hidden */
  32319. Engine.prototype._uploadImageToTexture = function (texture, image, faceIndex, lod) {
  32320. if (faceIndex === void 0) { faceIndex = 0; }
  32321. if (lod === void 0) { lod = 0; }
  32322. var gl = this._gl;
  32323. var textureType = this._getWebGLTextureType(texture.type);
  32324. var format = this._getInternalFormat(texture.format);
  32325. var internalFormat = this._getRGBABufferInternalSizedFormat(texture.type, format);
  32326. var bindTarget = texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  32327. this._bindTextureDirectly(bindTarget, texture, true);
  32328. this._unpackFlipY(texture.invertY);
  32329. var target = gl.TEXTURE_2D;
  32330. if (texture.isCube) {
  32331. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  32332. }
  32333. gl.texImage2D(target, lod, internalFormat, format, textureType, image);
  32334. this._bindTextureDirectly(bindTarget, null, true);
  32335. };
  32336. /**
  32337. * Creates a new render target cube texture
  32338. * @param size defines the size of the texture
  32339. * @param options defines the options used to create the texture
  32340. * @returns a new render target cube texture stored in an InternalTexture
  32341. */
  32342. Engine.prototype.createRenderTargetCubeTexture = function (size, options) {
  32343. 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);
  32344. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && fullOptions.generateStencilBuffer;
  32345. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  32346. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  32347. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32348. }
  32349. else if (fullOptions.type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  32350. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  32351. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32352. }
  32353. var gl = this._gl;
  32354. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RENDERTARGET);
  32355. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32356. var filters = this._getSamplingParameters(fullOptions.samplingMode, fullOptions.generateMipMaps);
  32357. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  32358. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  32359. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type");
  32360. }
  32361. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, filters.mag);
  32362. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, filters.min);
  32363. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32364. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32365. for (var face = 0; face < 6; face++) {
  32366. 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);
  32367. }
  32368. // Create the framebuffer
  32369. var framebuffer = gl.createFramebuffer();
  32370. this.bindUnboundFramebuffer(framebuffer);
  32371. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(fullOptions.generateStencilBuffer, fullOptions.generateDepthBuffer, size, size);
  32372. // MipMaps
  32373. if (fullOptions.generateMipMaps) {
  32374. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  32375. }
  32376. // Unbind
  32377. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  32378. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  32379. this.bindUnboundFramebuffer(null);
  32380. texture._framebuffer = framebuffer;
  32381. texture.width = size;
  32382. texture.height = size;
  32383. texture.isReady = true;
  32384. texture.isCube = true;
  32385. texture.samples = 1;
  32386. texture.generateMipMaps = fullOptions.generateMipMaps;
  32387. texture.samplingMode = fullOptions.samplingMode;
  32388. texture.type = fullOptions.type;
  32389. texture.format = fullOptions.format;
  32390. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  32391. texture._generateStencilBuffer = fullOptions.generateStencilBuffer;
  32392. this._internalTexturesCache.push(texture);
  32393. return texture;
  32394. };
  32395. /**
  32396. * Creates a cube texture
  32397. * @param rootUrl defines the url where the files to load is located
  32398. * @param scene defines the current scene
  32399. * @param files defines the list of files to load (1 per face)
  32400. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  32401. * @param onLoad defines an optional callback raised when the texture is loaded
  32402. * @param onError defines an optional callback raised if there is an issue to load the texture
  32403. * @param format defines the format of the data
  32404. * @param forcedExtension defines the extension to use to pick the right loader
  32405. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  32406. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  32407. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  32408. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  32409. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  32410. * @returns the cube texture as an InternalTexture
  32411. */
  32412. Engine.prototype.createCubeTexture = function (rootUrl, scene, files, noMipmap, onLoad, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset, fallback, excludeLoaders) {
  32413. var _this = this;
  32414. if (onLoad === void 0) { onLoad = null; }
  32415. if (onError === void 0) { onError = null; }
  32416. if (forcedExtension === void 0) { forcedExtension = null; }
  32417. if (createPolynomials === void 0) { createPolynomials = false; }
  32418. if (lodScale === void 0) { lodScale = 0; }
  32419. if (lodOffset === void 0) { lodOffset = 0; }
  32420. if (fallback === void 0) { fallback = null; }
  32421. if (excludeLoaders === void 0) { excludeLoaders = []; }
  32422. var gl = this._gl;
  32423. var texture = fallback ? fallback : new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_CUBE);
  32424. texture.isCube = true;
  32425. texture.url = rootUrl;
  32426. texture.generateMipMaps = !noMipmap;
  32427. texture._lodGenerationScale = lodScale;
  32428. texture._lodGenerationOffset = lodOffset;
  32429. if (!this._doNotHandleContextLost) {
  32430. texture._extension = forcedExtension;
  32431. texture._files = files;
  32432. }
  32433. var lastDot = rootUrl.lastIndexOf('.');
  32434. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? rootUrl.substring(lastDot).toLowerCase() : "");
  32435. var loader = null;
  32436. for (var _i = 0, _a = Engine._TextureLoaders; _i < _a.length; _i++) {
  32437. var availableLoader = _a[_i];
  32438. if (excludeLoaders.indexOf(availableLoader) === -1 && availableLoader.canLoad(extension, this._textureFormatInUse, fallback, false, false)) {
  32439. loader = availableLoader;
  32440. break;
  32441. }
  32442. }
  32443. var onInternalError = function (request, exception) {
  32444. if (loader) {
  32445. var fallbackUrl = loader.getFallbackTextureUrl(texture.url, _this._textureFormatInUse);
  32446. _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");
  32447. if (fallbackUrl) {
  32448. excludeLoaders.push(loader);
  32449. _this.createCubeTexture(fallbackUrl, scene, files, noMipmap, onLoad, onError, format, extension, createPolynomials, lodScale, lodOffset, texture, excludeLoaders);
  32450. return;
  32451. }
  32452. }
  32453. if (onError && request) {
  32454. onError(request.status + " " + request.statusText, exception);
  32455. }
  32456. };
  32457. if (loader) {
  32458. rootUrl = loader.transformUrl(rootUrl, this._textureFormatInUse);
  32459. var onloaddata = function (data) {
  32460. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32461. loader.loadCubeData(data, texture, createPolynomials, onLoad, onError);
  32462. };
  32463. if (files && files.length === 6) {
  32464. if (loader.supportCascades) {
  32465. this._cascadeLoadFiles(scene, onloaddata, files, onError);
  32466. }
  32467. else if (onError) {
  32468. onError("Textures type does not support cascades.");
  32469. }
  32470. }
  32471. else {
  32472. this._loadFile(rootUrl, onloaddata, undefined, undefined, true, onInternalError);
  32473. }
  32474. }
  32475. else {
  32476. if (!files) {
  32477. throw new Error("Cannot load cubemap because files were not defined");
  32478. }
  32479. this._cascadeLoadImgs(scene, function (imgs) {
  32480. var width = _this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(imgs[0].width, _this._caps.maxCubemapTextureSize) : imgs[0].width;
  32481. var height = width;
  32482. _this._prepareWorkingCanvas();
  32483. if (!_this._workingCanvas || !_this._workingContext) {
  32484. return;
  32485. }
  32486. _this._workingCanvas.width = width;
  32487. _this._workingCanvas.height = height;
  32488. var faces = [
  32489. gl.TEXTURE_CUBE_MAP_POSITIVE_X, gl.TEXTURE_CUBE_MAP_POSITIVE_Y, gl.TEXTURE_CUBE_MAP_POSITIVE_Z,
  32490. gl.TEXTURE_CUBE_MAP_NEGATIVE_X, gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, gl.TEXTURE_CUBE_MAP_NEGATIVE_Z
  32491. ];
  32492. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32493. _this._unpackFlipY(false);
  32494. var internalFormat = format ? _this._getInternalFormat(format) : _this._gl.RGBA;
  32495. for (var index = 0; index < faces.length; index++) {
  32496. _this._workingContext.drawImage(imgs[index], 0, 0, imgs[index].width, imgs[index].height, 0, 0, width, height);
  32497. gl.texImage2D(faces[index], 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, _this._workingCanvas);
  32498. }
  32499. if (!noMipmap) {
  32500. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  32501. }
  32502. _this._setCubeMapTextureParams(!noMipmap);
  32503. texture.width = width;
  32504. texture.height = height;
  32505. texture.isReady = true;
  32506. if (format) {
  32507. texture.format = format;
  32508. }
  32509. texture.onLoadedObservable.notifyObservers(texture);
  32510. texture.onLoadedObservable.clear();
  32511. if (onLoad) {
  32512. onLoad();
  32513. }
  32514. }, files, onError);
  32515. }
  32516. this._internalTexturesCache.push(texture);
  32517. return texture;
  32518. };
  32519. /**
  32520. * @hidden
  32521. */
  32522. Engine.prototype._setCubeMapTextureParams = function (loadMipmap) {
  32523. var gl = this._gl;
  32524. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  32525. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, loadMipmap ? gl.LINEAR_MIPMAP_LINEAR : gl.LINEAR);
  32526. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32527. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32528. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  32529. // this.resetTextureCache();
  32530. };
  32531. /**
  32532. * Update a raw cube texture
  32533. * @param texture defines the texture to udpdate
  32534. * @param data defines the data to store
  32535. * @param format defines the data format
  32536. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32537. * @param invertY defines if data must be stored with Y axis inverted
  32538. * @param compression defines the compression used (null by default)
  32539. * @param level defines which level of the texture to update
  32540. */
  32541. Engine.prototype.updateRawCubeTexture = function (texture, data, format, type, invertY, compression, level) {
  32542. if (compression === void 0) { compression = null; }
  32543. if (level === void 0) { level = 0; }
  32544. texture._bufferViewArray = data;
  32545. texture.format = format;
  32546. texture.type = type;
  32547. texture.invertY = invertY;
  32548. texture._compression = compression;
  32549. var gl = this._gl;
  32550. var textureType = this._getWebGLTextureType(type);
  32551. var internalFormat = this._getInternalFormat(format);
  32552. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(type);
  32553. var needConversion = false;
  32554. if (internalFormat === gl.RGB) {
  32555. internalFormat = gl.RGBA;
  32556. needConversion = true;
  32557. }
  32558. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32559. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  32560. if (texture.width % 4 !== 0) {
  32561. gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);
  32562. }
  32563. // Data are known to be in +X +Y +Z -X -Y -Z
  32564. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  32565. var faceData = data[faceIndex];
  32566. if (compression) {
  32567. gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level, (this.getCaps().s3tc)[compression], texture.width, texture.height, 0, faceData);
  32568. }
  32569. else {
  32570. if (needConversion) {
  32571. faceData = this._convertRGBtoRGBATextureData(faceData, texture.width, texture.height, type);
  32572. }
  32573. gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level, internalSizedFomat, texture.width, texture.height, 0, internalFormat, textureType, faceData);
  32574. }
  32575. }
  32576. var isPot = !this.needPOTTextures || (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.width) && _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.height));
  32577. if (isPot && texture.generateMipMaps && level === 0) {
  32578. this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
  32579. }
  32580. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  32581. // this.resetTextureCache();
  32582. texture.isReady = true;
  32583. };
  32584. /**
  32585. * Creates a new raw cube texture
  32586. * @param data defines the array of data to use to create each face
  32587. * @param size defines the size of the textures
  32588. * @param format defines the format of the data
  32589. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32590. * @param generateMipMaps defines if the engine should generate the mip levels
  32591. * @param invertY defines if data must be stored with Y axis inverted
  32592. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32593. * @param compression defines the compression used (null by default)
  32594. * @returns the cube texture as an InternalTexture
  32595. */
  32596. Engine.prototype.createRawCubeTexture = function (data, size, format, type, generateMipMaps, invertY, samplingMode, compression) {
  32597. if (compression === void 0) { compression = null; }
  32598. var gl = this._gl;
  32599. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_CUBERAW);
  32600. texture.isCube = true;
  32601. texture.format = format;
  32602. texture.type = type;
  32603. if (!this._doNotHandleContextLost) {
  32604. texture._bufferViewArray = data;
  32605. }
  32606. var textureType = this._getWebGLTextureType(type);
  32607. var internalFormat = this._getInternalFormat(format);
  32608. if (internalFormat === gl.RGB) {
  32609. internalFormat = gl.RGBA;
  32610. }
  32611. // Mipmap generation needs a sized internal format that is both color-renderable and texture-filterable
  32612. if (textureType === gl.FLOAT && !this._caps.textureFloatLinearFiltering) {
  32613. generateMipMaps = false;
  32614. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32615. _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.");
  32616. }
  32617. else if (textureType === this._gl.HALF_FLOAT_OES && !this._caps.textureHalfFloatLinearFiltering) {
  32618. generateMipMaps = false;
  32619. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32620. _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.");
  32621. }
  32622. else if (textureType === gl.FLOAT && !this._caps.textureFloatRender) {
  32623. generateMipMaps = false;
  32624. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Render to float textures is not supported. Mipmap generation forced to false.");
  32625. }
  32626. else if (textureType === gl.HALF_FLOAT && !this._caps.colorBufferFloat) {
  32627. generateMipMaps = false;
  32628. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Render to half float textures is not supported. Mipmap generation forced to false.");
  32629. }
  32630. var width = size;
  32631. var height = width;
  32632. texture.width = width;
  32633. texture.height = height;
  32634. // Double check on POT to generate Mips.
  32635. var isPot = !this.needPOTTextures || (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.width) && _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.height));
  32636. if (!isPot) {
  32637. generateMipMaps = false;
  32638. }
  32639. // Upload data if needed. The texture won't be ready until then.
  32640. if (data) {
  32641. this.updateRawCubeTexture(texture, data, format, type, invertY, compression);
  32642. }
  32643. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, texture, true);
  32644. // Filters
  32645. if (data && generateMipMaps) {
  32646. this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
  32647. }
  32648. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  32649. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, filters.mag);
  32650. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, filters.min);
  32651. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32652. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32653. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  32654. texture.generateMipMaps = generateMipMaps;
  32655. return texture;
  32656. };
  32657. /**
  32658. * Creates a new raw cube texture from a specified url
  32659. * @param url defines the url where the data is located
  32660. * @param scene defines the current scene
  32661. * @param size defines the size of the textures
  32662. * @param format defines the format of the data
  32663. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32664. * @param noMipmap defines if the engine should avoid generating the mip levels
  32665. * @param callback defines a callback used to extract texture data from loaded data
  32666. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  32667. * @param onLoad defines a callback called when texture is loaded
  32668. * @param onError defines a callback called if there is an error
  32669. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32670. * @param invertY defines if data must be stored with Y axis inverted
  32671. * @returns the cube texture as an InternalTexture
  32672. */
  32673. Engine.prototype.createRawCubeTextureFromUrl = function (url, scene, size, format, type, noMipmap, callback, mipmapGenerator, onLoad, onError, samplingMode, invertY) {
  32674. var _this = this;
  32675. if (onLoad === void 0) { onLoad = null; }
  32676. if (onError === void 0) { onError = null; }
  32677. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  32678. if (invertY === void 0) { invertY = false; }
  32679. var gl = this._gl;
  32680. var texture = this.createRawCubeTexture(null, size, format, type, !noMipmap, invertY, samplingMode);
  32681. scene._addPendingData(texture);
  32682. texture.url = url;
  32683. this._internalTexturesCache.push(texture);
  32684. var onerror = function (request, exception) {
  32685. scene._removePendingData(texture);
  32686. if (onError && request) {
  32687. onError(request.status + " " + request.statusText, exception);
  32688. }
  32689. };
  32690. var internalCallback = function (data) {
  32691. var width = texture.width;
  32692. var faceDataArrays = callback(data);
  32693. if (!faceDataArrays) {
  32694. return;
  32695. }
  32696. if (mipmapGenerator) {
  32697. var textureType = _this._getWebGLTextureType(type);
  32698. var internalFormat = _this._getInternalFormat(format);
  32699. var internalSizedFomat = _this._getRGBABufferInternalSizedFormat(type);
  32700. var needConversion = false;
  32701. if (internalFormat === gl.RGB) {
  32702. internalFormat = gl.RGBA;
  32703. needConversion = true;
  32704. }
  32705. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32706. _this._unpackFlipY(false);
  32707. var mipData = mipmapGenerator(faceDataArrays);
  32708. for (var level = 0; level < mipData.length; level++) {
  32709. var mipSize = width >> level;
  32710. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  32711. var mipFaceData = mipData[level][faceIndex];
  32712. if (needConversion) {
  32713. mipFaceData = _this._convertRGBtoRGBATextureData(mipFaceData, mipSize, mipSize, type);
  32714. }
  32715. gl.texImage2D(faceIndex, level, internalSizedFomat, mipSize, mipSize, 0, internalFormat, textureType, mipFaceData);
  32716. }
  32717. }
  32718. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  32719. }
  32720. else {
  32721. _this.updateRawCubeTexture(texture, faceDataArrays, format, type, invertY);
  32722. }
  32723. texture.isReady = true;
  32724. // this.resetTextureCache();
  32725. scene._removePendingData(texture);
  32726. if (onLoad) {
  32727. onLoad();
  32728. }
  32729. };
  32730. this._loadFile(url, function (data) {
  32731. internalCallback(data);
  32732. }, undefined, scene.offlineProvider, true, onerror);
  32733. return texture;
  32734. };
  32735. /**
  32736. * Update a raw 3D texture
  32737. * @param texture defines the texture to update
  32738. * @param data defines the data to store
  32739. * @param format defines the data format
  32740. * @param invertY defines if data must be stored with Y axis inverted
  32741. * @param compression defines the used compression (can be null)
  32742. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  32743. */
  32744. Engine.prototype.updateRawTexture3D = function (texture, data, format, invertY, compression, textureType) {
  32745. if (compression === void 0) { compression = null; }
  32746. if (textureType === void 0) { textureType = Engine.TEXTURETYPE_UNSIGNED_INT; }
  32747. var internalType = this._getWebGLTextureType(textureType);
  32748. var internalFormat = this._getInternalFormat(format);
  32749. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(textureType, format);
  32750. this._bindTextureDirectly(this._gl.TEXTURE_3D, texture, true);
  32751. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  32752. if (!this._doNotHandleContextLost) {
  32753. texture._bufferView = data;
  32754. texture.format = format;
  32755. texture.invertY = invertY;
  32756. texture._compression = compression;
  32757. }
  32758. if (texture.width % 4 !== 0) {
  32759. this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);
  32760. }
  32761. if (compression && data) {
  32762. this._gl.compressedTexImage3D(this._gl.TEXTURE_3D, 0, this.getCaps().s3tc[compression], texture.width, texture.height, texture.depth, 0, data);
  32763. }
  32764. else {
  32765. this._gl.texImage3D(this._gl.TEXTURE_3D, 0, internalSizedFomat, texture.width, texture.height, texture.depth, 0, internalFormat, internalType, data);
  32766. }
  32767. if (texture.generateMipMaps) {
  32768. this._gl.generateMipmap(this._gl.TEXTURE_3D);
  32769. }
  32770. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  32771. // this.resetTextureCache();
  32772. texture.isReady = true;
  32773. };
  32774. /**
  32775. * Creates a new raw 3D texture
  32776. * @param data defines the data used to create the texture
  32777. * @param width defines the width of the texture
  32778. * @param height defines the height of the texture
  32779. * @param depth defines the depth of the texture
  32780. * @param format defines the format of the texture
  32781. * @param generateMipMaps defines if the engine must generate mip levels
  32782. * @param invertY defines if data must be stored with Y axis inverted
  32783. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32784. * @param compression defines the compressed used (can be null)
  32785. * @param textureType defines the compressed used (can be null)
  32786. * @returns a new raw 3D texture (stored in an InternalTexture)
  32787. */
  32788. Engine.prototype.createRawTexture3D = function (data, width, height, depth, format, generateMipMaps, invertY, samplingMode, compression, textureType) {
  32789. if (compression === void 0) { compression = null; }
  32790. if (textureType === void 0) { textureType = Engine.TEXTURETYPE_UNSIGNED_INT; }
  32791. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RAW3D);
  32792. texture.baseWidth = width;
  32793. texture.baseHeight = height;
  32794. texture.baseDepth = depth;
  32795. texture.width = width;
  32796. texture.height = height;
  32797. texture.depth = depth;
  32798. texture.format = format;
  32799. texture.type = textureType;
  32800. texture.generateMipMaps = generateMipMaps;
  32801. texture.samplingMode = samplingMode;
  32802. texture.is3D = true;
  32803. if (!this._doNotHandleContextLost) {
  32804. texture._bufferView = data;
  32805. }
  32806. this.updateRawTexture3D(texture, data, format, invertY, compression, textureType);
  32807. this._bindTextureDirectly(this._gl.TEXTURE_3D, texture, true);
  32808. // Filters
  32809. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  32810. this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_MAG_FILTER, filters.mag);
  32811. this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  32812. if (generateMipMaps) {
  32813. this._gl.generateMipmap(this._gl.TEXTURE_3D);
  32814. }
  32815. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  32816. this._internalTexturesCache.push(texture);
  32817. return texture;
  32818. };
  32819. Engine.prototype._prepareWebGLTextureContinuation = function (texture, scene, noMipmap, isCompressed, samplingMode) {
  32820. var gl = this._gl;
  32821. if (!gl) {
  32822. return;
  32823. }
  32824. var filters = this._getSamplingParameters(samplingMode, !noMipmap);
  32825. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  32826. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  32827. if (!noMipmap && !isCompressed) {
  32828. gl.generateMipmap(gl.TEXTURE_2D);
  32829. }
  32830. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  32831. // this.resetTextureCache();
  32832. if (scene) {
  32833. scene._removePendingData(texture);
  32834. }
  32835. texture.onLoadedObservable.notifyObservers(texture);
  32836. texture.onLoadedObservable.clear();
  32837. };
  32838. Engine.prototype._prepareWebGLTexture = function (texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode) {
  32839. var _this = this;
  32840. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  32841. var maxTextureSize = this.getCaps().maxTextureSize;
  32842. var potWidth = Math.min(maxTextureSize, this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(width, maxTextureSize) : width);
  32843. var potHeight = Math.min(maxTextureSize, this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(height, maxTextureSize) : height);
  32844. var gl = this._gl;
  32845. if (!gl) {
  32846. return;
  32847. }
  32848. if (!texture._webGLTexture) {
  32849. // this.resetTextureCache();
  32850. if (scene) {
  32851. scene._removePendingData(texture);
  32852. }
  32853. return;
  32854. }
  32855. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  32856. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  32857. texture.baseWidth = width;
  32858. texture.baseHeight = height;
  32859. texture.width = potWidth;
  32860. texture.height = potHeight;
  32861. texture.isReady = true;
  32862. if (processFunction(potWidth, potHeight, function () {
  32863. _this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  32864. })) {
  32865. // Returning as texture needs extra async steps
  32866. return;
  32867. }
  32868. this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  32869. };
  32870. Engine.prototype._convertRGBtoRGBATextureData = function (rgbData, width, height, textureType) {
  32871. // Create new RGBA data container.
  32872. var rgbaData;
  32873. if (textureType === Engine.TEXTURETYPE_FLOAT) {
  32874. rgbaData = new Float32Array(width * height * 4);
  32875. }
  32876. else {
  32877. rgbaData = new Uint32Array(width * height * 4);
  32878. }
  32879. // Convert each pixel.
  32880. for (var x = 0; x < width; x++) {
  32881. for (var y = 0; y < height; y++) {
  32882. var index = (y * width + x) * 3;
  32883. var newIndex = (y * width + x) * 4;
  32884. // Map Old Value to new value.
  32885. rgbaData[newIndex + 0] = rgbData[index + 0];
  32886. rgbaData[newIndex + 1] = rgbData[index + 1];
  32887. rgbaData[newIndex + 2] = rgbData[index + 2];
  32888. // Add fully opaque alpha channel.
  32889. rgbaData[newIndex + 3] = 1;
  32890. }
  32891. }
  32892. return rgbaData;
  32893. };
  32894. /** @hidden */
  32895. Engine.prototype._releaseFramebufferObjects = function (texture) {
  32896. var gl = this._gl;
  32897. if (texture._framebuffer) {
  32898. gl.deleteFramebuffer(texture._framebuffer);
  32899. texture._framebuffer = null;
  32900. }
  32901. if (texture._depthStencilBuffer) {
  32902. gl.deleteRenderbuffer(texture._depthStencilBuffer);
  32903. texture._depthStencilBuffer = null;
  32904. }
  32905. if (texture._MSAAFramebuffer) {
  32906. gl.deleteFramebuffer(texture._MSAAFramebuffer);
  32907. texture._MSAAFramebuffer = null;
  32908. }
  32909. if (texture._MSAARenderBuffer) {
  32910. gl.deleteRenderbuffer(texture._MSAARenderBuffer);
  32911. texture._MSAARenderBuffer = null;
  32912. }
  32913. };
  32914. /** @hidden */
  32915. Engine.prototype._releaseTexture = function (texture) {
  32916. var gl = this._gl;
  32917. this._releaseFramebufferObjects(texture);
  32918. gl.deleteTexture(texture._webGLTexture);
  32919. // Unbind channels
  32920. this.unbindAllTextures();
  32921. var index = this._internalTexturesCache.indexOf(texture);
  32922. if (index !== -1) {
  32923. this._internalTexturesCache.splice(index, 1);
  32924. }
  32925. // Integrated fixed lod samplers.
  32926. if (texture._lodTextureHigh) {
  32927. texture._lodTextureHigh.dispose();
  32928. }
  32929. if (texture._lodTextureMid) {
  32930. texture._lodTextureMid.dispose();
  32931. }
  32932. if (texture._lodTextureLow) {
  32933. texture._lodTextureLow.dispose();
  32934. }
  32935. // Set output texture of post process to null if the texture has been released/disposed
  32936. this.scenes.forEach(function (scene) {
  32937. scene.postProcesses.forEach(function (postProcess) {
  32938. if (postProcess._outputTexture == texture) {
  32939. postProcess._outputTexture = null;
  32940. }
  32941. });
  32942. scene.cameras.forEach(function (camera) {
  32943. camera._postProcesses.forEach(function (postProcess) {
  32944. if (postProcess) {
  32945. if (postProcess._outputTexture == texture) {
  32946. postProcess._outputTexture = null;
  32947. }
  32948. }
  32949. });
  32950. });
  32951. });
  32952. };
  32953. Engine.prototype.setProgram = function (program) {
  32954. if (this._currentProgram !== program) {
  32955. this._gl.useProgram(program);
  32956. this._currentProgram = program;
  32957. }
  32958. };
  32959. /**
  32960. * Binds an effect to the webGL context
  32961. * @param effect defines the effect to bind
  32962. */
  32963. Engine.prototype.bindSamplers = function (effect) {
  32964. this.setProgram(effect.getProgram());
  32965. var samplers = effect.getSamplers();
  32966. for (var index = 0; index < samplers.length; index++) {
  32967. var uniform = effect.getUniform(samplers[index]);
  32968. if (uniform) {
  32969. this._boundUniforms[index] = uniform;
  32970. }
  32971. }
  32972. this._currentEffect = null;
  32973. };
  32974. Engine.prototype._moveBoundTextureOnTop = function (internalTexture) {
  32975. if (this.disableTextureBindingOptimization || this._lastBoundInternalTextureTracker.previous === internalTexture) {
  32976. return;
  32977. }
  32978. // Remove
  32979. this._linkTrackers(internalTexture.previous, internalTexture.next);
  32980. // Bind last to it
  32981. this._linkTrackers(this._lastBoundInternalTextureTracker.previous, internalTexture);
  32982. // Bind to dummy
  32983. this._linkTrackers(internalTexture, this._lastBoundInternalTextureTracker);
  32984. };
  32985. Engine.prototype._getCorrectTextureChannel = function (channel, internalTexture) {
  32986. if (!internalTexture) {
  32987. return -1;
  32988. }
  32989. internalTexture._initialSlot = channel;
  32990. if (this.disableTextureBindingOptimization) { // We want texture sampler ID === texture channel
  32991. if (channel !== internalTexture._designatedSlot) {
  32992. this._textureCollisions.addCount(1, false);
  32993. }
  32994. }
  32995. else {
  32996. if (channel !== internalTexture._designatedSlot) {
  32997. if (internalTexture._designatedSlot > -1) { // Texture is already assigned to a slot
  32998. return internalTexture._designatedSlot;
  32999. }
  33000. else {
  33001. // No slot for this texture, let's pick a new one (if we find a free slot)
  33002. if (this._nextFreeTextureSlots.length) {
  33003. return this._nextFreeTextureSlots[0];
  33004. }
  33005. // We need to recycle the oldest bound texture, sorry.
  33006. this._textureCollisions.addCount(1, false);
  33007. return this._removeDesignatedSlot(this._firstBoundInternalTextureTracker.next);
  33008. }
  33009. }
  33010. }
  33011. return channel;
  33012. };
  33013. Engine.prototype._linkTrackers = function (previous, next) {
  33014. previous.next = next;
  33015. next.previous = previous;
  33016. };
  33017. Engine.prototype._removeDesignatedSlot = function (internalTexture) {
  33018. var currentSlot = internalTexture._designatedSlot;
  33019. if (currentSlot === -1) {
  33020. return -1;
  33021. }
  33022. internalTexture._designatedSlot = -1;
  33023. if (this.disableTextureBindingOptimization) {
  33024. return -1;
  33025. }
  33026. // Remove from bound list
  33027. this._linkTrackers(internalTexture.previous, internalTexture.next);
  33028. // Free the slot
  33029. this._boundTexturesCache[currentSlot] = null;
  33030. this._nextFreeTextureSlots.push(currentSlot);
  33031. return currentSlot;
  33032. };
  33033. Engine.prototype._activateCurrentTexture = function () {
  33034. if (this._currentTextureChannel !== this._activeChannel) {
  33035. this._gl.activeTexture(this._gl.TEXTURE0 + this._activeChannel);
  33036. this._currentTextureChannel = this._activeChannel;
  33037. }
  33038. };
  33039. /** @hidden */
  33040. Engine.prototype._bindTextureDirectly = function (target, texture, forTextureDataUpdate, force) {
  33041. if (forTextureDataUpdate === void 0) { forTextureDataUpdate = false; }
  33042. if (force === void 0) { force = false; }
  33043. var wasPreviouslyBound = false;
  33044. if (forTextureDataUpdate && texture && texture._designatedSlot > -1) {
  33045. this._activeChannel = texture._designatedSlot;
  33046. }
  33047. var currentTextureBound = this._boundTexturesCache[this._activeChannel];
  33048. var isTextureForRendering = texture && texture._initialSlot > -1;
  33049. if (currentTextureBound !== texture || force) {
  33050. if (currentTextureBound) {
  33051. this._removeDesignatedSlot(currentTextureBound);
  33052. }
  33053. this._activateCurrentTexture();
  33054. this._gl.bindTexture(target, texture ? texture._webGLTexture : null);
  33055. this._boundTexturesCache[this._activeChannel] = texture;
  33056. if (texture) {
  33057. if (!this.disableTextureBindingOptimization) {
  33058. var slotIndex = this._nextFreeTextureSlots.indexOf(this._activeChannel);
  33059. if (slotIndex > -1) {
  33060. this._nextFreeTextureSlots.splice(slotIndex, 1);
  33061. }
  33062. this._linkTrackers(this._lastBoundInternalTextureTracker.previous, texture);
  33063. this._linkTrackers(texture, this._lastBoundInternalTextureTracker);
  33064. }
  33065. texture._designatedSlot = this._activeChannel;
  33066. }
  33067. }
  33068. else if (forTextureDataUpdate) {
  33069. wasPreviouslyBound = true;
  33070. this._activateCurrentTexture();
  33071. }
  33072. if (isTextureForRendering && !forTextureDataUpdate) {
  33073. this._bindSamplerUniformToChannel(texture._initialSlot, this._activeChannel);
  33074. }
  33075. return wasPreviouslyBound;
  33076. };
  33077. /** @hidden */
  33078. Engine.prototype._bindTexture = function (channel, texture) {
  33079. if (channel < 0) {
  33080. return;
  33081. }
  33082. if (texture) {
  33083. channel = this._getCorrectTextureChannel(channel, texture);
  33084. }
  33085. this._activeChannel = channel;
  33086. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture);
  33087. };
  33088. /**
  33089. * Sets a texture to the webGL context from a postprocess
  33090. * @param channel defines the channel to use
  33091. * @param postProcess defines the source postprocess
  33092. */
  33093. Engine.prototype.setTextureFromPostProcess = function (channel, postProcess) {
  33094. this._bindTexture(channel, postProcess ? postProcess._textures.data[postProcess._currentRenderTextureInd] : null);
  33095. };
  33096. /**
  33097. * Binds the output of the passed in post process to the texture channel specified
  33098. * @param channel The channel the texture should be bound to
  33099. * @param postProcess The post process which's output should be bound
  33100. */
  33101. Engine.prototype.setTextureFromPostProcessOutput = function (channel, postProcess) {
  33102. this._bindTexture(channel, postProcess ? postProcess._outputTexture : null);
  33103. };
  33104. /**
  33105. * Unbind all textures from the webGL context
  33106. */
  33107. Engine.prototype.unbindAllTextures = function () {
  33108. for (var channel = 0; channel < this._maxSimultaneousTextures; channel++) {
  33109. this._activeChannel = channel;
  33110. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  33111. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  33112. if (this.webGLVersion > 1) {
  33113. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  33114. }
  33115. }
  33116. };
  33117. /**
  33118. * Sets a texture to the according uniform.
  33119. * @param channel The texture channel
  33120. * @param uniform The uniform to set
  33121. * @param texture The texture to apply
  33122. */
  33123. Engine.prototype.setTexture = function (channel, uniform, texture) {
  33124. if (channel < 0) {
  33125. return;
  33126. }
  33127. if (uniform) {
  33128. this._boundUniforms[channel] = uniform;
  33129. }
  33130. this._setTexture(channel, texture);
  33131. };
  33132. /**
  33133. * Sets a depth stencil texture from a render target to the according uniform.
  33134. * @param channel The texture channel
  33135. * @param uniform The uniform to set
  33136. * @param texture The render target texture containing the depth stencil texture to apply
  33137. */
  33138. Engine.prototype.setDepthStencilTexture = function (channel, uniform, texture) {
  33139. if (channel < 0) {
  33140. return;
  33141. }
  33142. if (uniform) {
  33143. this._boundUniforms[channel] = uniform;
  33144. }
  33145. if (!texture || !texture.depthStencilTexture) {
  33146. this._setTexture(channel, null);
  33147. }
  33148. else {
  33149. this._setTexture(channel, texture, false, true);
  33150. }
  33151. };
  33152. Engine.prototype._bindSamplerUniformToChannel = function (sourceSlot, destination) {
  33153. var uniform = this._boundUniforms[sourceSlot];
  33154. if (uniform._currentState === destination) {
  33155. return;
  33156. }
  33157. this._gl.uniform1i(uniform, destination);
  33158. uniform._currentState = destination;
  33159. };
  33160. Engine.prototype._getTextureWrapMode = function (mode) {
  33161. switch (mode) {
  33162. case Engine.TEXTURE_WRAP_ADDRESSMODE:
  33163. return this._gl.REPEAT;
  33164. case Engine.TEXTURE_CLAMP_ADDRESSMODE:
  33165. return this._gl.CLAMP_TO_EDGE;
  33166. case Engine.TEXTURE_MIRROR_ADDRESSMODE:
  33167. return this._gl.MIRRORED_REPEAT;
  33168. }
  33169. return this._gl.REPEAT;
  33170. };
  33171. Engine.prototype._setTexture = function (channel, texture, isPartOfTextureArray, depthStencilTexture) {
  33172. if (isPartOfTextureArray === void 0) { isPartOfTextureArray = false; }
  33173. if (depthStencilTexture === void 0) { depthStencilTexture = false; }
  33174. // Not ready?
  33175. if (!texture) {
  33176. if (this._boundTexturesCache[channel] != null) {
  33177. this._activeChannel = channel;
  33178. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  33179. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  33180. if (this.webGLVersion > 1) {
  33181. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  33182. }
  33183. }
  33184. return false;
  33185. }
  33186. // Video
  33187. if (texture.video) {
  33188. this._activeChannel = channel;
  33189. texture.update();
  33190. }
  33191. else if (texture.delayLoadState === Engine.DELAYLOADSTATE_NOTLOADED) { // Delay loading
  33192. texture.delayLoad();
  33193. return false;
  33194. }
  33195. var internalTexture;
  33196. if (depthStencilTexture) {
  33197. internalTexture = texture.depthStencilTexture;
  33198. }
  33199. else if (texture.isReady()) {
  33200. internalTexture = texture.getInternalTexture();
  33201. }
  33202. else if (texture.isCube) {
  33203. internalTexture = this.emptyCubeTexture;
  33204. }
  33205. else if (texture.is3D) {
  33206. internalTexture = this.emptyTexture3D;
  33207. }
  33208. else {
  33209. internalTexture = this.emptyTexture;
  33210. }
  33211. if (!isPartOfTextureArray) {
  33212. channel = this._getCorrectTextureChannel(channel, internalTexture);
  33213. }
  33214. var needToBind = true;
  33215. if (this._boundTexturesCache[channel] === internalTexture) {
  33216. this._moveBoundTextureOnTop(internalTexture);
  33217. if (!isPartOfTextureArray) {
  33218. this._bindSamplerUniformToChannel(internalTexture._initialSlot, channel);
  33219. }
  33220. needToBind = false;
  33221. }
  33222. this._activeChannel = channel;
  33223. if (internalTexture && internalTexture.is3D) {
  33224. if (needToBind) {
  33225. this._bindTextureDirectly(this._gl.TEXTURE_3D, internalTexture, isPartOfTextureArray);
  33226. }
  33227. if (internalTexture && internalTexture._cachedWrapU !== texture.wrapU) {
  33228. internalTexture._cachedWrapU = texture.wrapU;
  33229. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(texture.wrapU), internalTexture);
  33230. }
  33231. if (internalTexture && internalTexture._cachedWrapV !== texture.wrapV) {
  33232. internalTexture._cachedWrapV = texture.wrapV;
  33233. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(texture.wrapV), internalTexture);
  33234. }
  33235. if (internalTexture && internalTexture._cachedWrapR !== texture.wrapR) {
  33236. internalTexture._cachedWrapR = texture.wrapR;
  33237. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_R, this._getTextureWrapMode(texture.wrapR), internalTexture);
  33238. }
  33239. this._setAnisotropicLevel(this._gl.TEXTURE_3D, texture);
  33240. }
  33241. else if (internalTexture && internalTexture.isCube) {
  33242. if (needToBind) {
  33243. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, internalTexture, isPartOfTextureArray);
  33244. }
  33245. if (internalTexture._cachedCoordinatesMode !== texture.coordinatesMode) {
  33246. internalTexture._cachedCoordinatesMode = texture.coordinatesMode;
  33247. // CUBIC_MODE and SKYBOX_MODE both require CLAMP_TO_EDGE. All other modes use REPEAT.
  33248. var textureWrapMode = (texture.coordinatesMode !== Engine.TEXTURE_CUBIC_MODE && texture.coordinatesMode !== Engine.TEXTURE_SKYBOX_MODE) ? this._gl.REPEAT : this._gl.CLAMP_TO_EDGE;
  33249. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_WRAP_S, textureWrapMode, internalTexture);
  33250. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_WRAP_T, textureWrapMode);
  33251. }
  33252. this._setAnisotropicLevel(this._gl.TEXTURE_CUBE_MAP, texture);
  33253. }
  33254. else {
  33255. if (needToBind) {
  33256. this._bindTextureDirectly(this._gl.TEXTURE_2D, internalTexture, isPartOfTextureArray);
  33257. }
  33258. if (internalTexture && internalTexture._cachedWrapU !== texture.wrapU) {
  33259. internalTexture._cachedWrapU = texture.wrapU;
  33260. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(texture.wrapU), internalTexture);
  33261. }
  33262. if (internalTexture && internalTexture._cachedWrapV !== texture.wrapV) {
  33263. internalTexture._cachedWrapV = texture.wrapV;
  33264. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(texture.wrapV), internalTexture);
  33265. }
  33266. this._setAnisotropicLevel(this._gl.TEXTURE_2D, texture);
  33267. }
  33268. return true;
  33269. };
  33270. /**
  33271. * Sets an array of texture to the webGL context
  33272. * @param channel defines the channel where the texture array must be set
  33273. * @param uniform defines the associated uniform location
  33274. * @param textures defines the array of textures to bind
  33275. */
  33276. Engine.prototype.setTextureArray = function (channel, uniform, textures) {
  33277. if (channel < 0 || !uniform) {
  33278. return;
  33279. }
  33280. if (!this._textureUnits || this._textureUnits.length !== textures.length) {
  33281. this._textureUnits = new Int32Array(textures.length);
  33282. }
  33283. for (var i = 0; i < textures.length; i++) {
  33284. this._textureUnits[i] = this._getCorrectTextureChannel(channel + i, textures[i].getInternalTexture());
  33285. }
  33286. this._gl.uniform1iv(uniform, this._textureUnits);
  33287. for (var index = 0; index < textures.length; index++) {
  33288. this._setTexture(this._textureUnits[index], textures[index], true);
  33289. }
  33290. };
  33291. /** @hidden */
  33292. Engine.prototype._setAnisotropicLevel = function (target, texture) {
  33293. var internalTexture = texture.getInternalTexture();
  33294. if (!internalTexture) {
  33295. return;
  33296. }
  33297. var anisotropicFilterExtension = this._caps.textureAnisotropicFilterExtension;
  33298. var value = texture.anisotropicFilteringLevel;
  33299. if (internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST
  33300. && internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR
  33301. && internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR) {
  33302. value = 1; // Forcing the anisotropic to 1 because else webgl will force filters to linear
  33303. }
  33304. if (anisotropicFilterExtension && internalTexture._cachedAnisotropicFilteringLevel !== value) {
  33305. this._setTextureParameterFloat(target, anisotropicFilterExtension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(value, this._caps.maxAnisotropy), internalTexture);
  33306. internalTexture._cachedAnisotropicFilteringLevel = value;
  33307. }
  33308. };
  33309. Engine.prototype._setTextureParameterFloat = function (target, parameter, value, texture) {
  33310. this._bindTextureDirectly(target, texture, true, true);
  33311. this._gl.texParameterf(target, parameter, value);
  33312. };
  33313. Engine.prototype._setTextureParameterInteger = function (target, parameter, value, texture) {
  33314. if (texture) {
  33315. this._bindTextureDirectly(target, texture, true, true);
  33316. }
  33317. this._gl.texParameteri(target, parameter, value);
  33318. };
  33319. /**
  33320. * Reads pixels from the current frame buffer. Please note that this function can be slow
  33321. * @param x defines the x coordinate of the rectangle where pixels must be read
  33322. * @param y defines the y coordinate of the rectangle where pixels must be read
  33323. * @param width defines the width of the rectangle where pixels must be read
  33324. * @param height defines the height of the rectangle where pixels must be read
  33325. * @returns a Uint8Array containing RGBA colors
  33326. */
  33327. Engine.prototype.readPixels = function (x, y, width, height) {
  33328. var data = new Uint8Array(height * width * 4);
  33329. this._gl.readPixels(x, y, width, height, this._gl.RGBA, this._gl.UNSIGNED_BYTE, data);
  33330. return data;
  33331. };
  33332. /**
  33333. * Add an externaly attached data from its key.
  33334. * This method call will fail and return false, if such key already exists.
  33335. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33336. * @param key the unique key that identifies the data
  33337. * @param data the data object to associate to the key for this Engine instance
  33338. * @return true if no such key were already present and the data was added successfully, false otherwise
  33339. */
  33340. Engine.prototype.addExternalData = function (key, data) {
  33341. if (!this._externalData) {
  33342. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  33343. }
  33344. return this._externalData.add(key, data);
  33345. };
  33346. /**
  33347. * Get an externaly attached data from its key
  33348. * @param key the unique key that identifies the data
  33349. * @return the associated data, if present (can be null), or undefined if not present
  33350. */
  33351. Engine.prototype.getExternalData = function (key) {
  33352. if (!this._externalData) {
  33353. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  33354. }
  33355. return this._externalData.get(key);
  33356. };
  33357. /**
  33358. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33359. * @param key the unique key that identifies the data
  33360. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33361. * @return the associated data, can be null if the factory returned null.
  33362. */
  33363. Engine.prototype.getOrAddExternalDataWithFactory = function (key, factory) {
  33364. if (!this._externalData) {
  33365. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  33366. }
  33367. return this._externalData.getOrAddWithFactory(key, factory);
  33368. };
  33369. /**
  33370. * Remove an externaly attached data from the Engine instance
  33371. * @param key the unique key that identifies the data
  33372. * @return true if the data was successfully removed, false if it doesn't exist
  33373. */
  33374. Engine.prototype.removeExternalData = function (key) {
  33375. if (!this._externalData) {
  33376. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  33377. }
  33378. return this._externalData.remove(key);
  33379. };
  33380. /**
  33381. * Unbind all vertex attributes from the webGL context
  33382. */
  33383. Engine.prototype.unbindAllAttributes = function () {
  33384. if (this._mustWipeVertexAttributes) {
  33385. this._mustWipeVertexAttributes = false;
  33386. for (var i = 0; i < this._caps.maxVertexAttribs; i++) {
  33387. this._gl.disableVertexAttribArray(i);
  33388. this._vertexAttribArraysEnabled[i] = false;
  33389. this._currentBufferPointers[i].active = false;
  33390. }
  33391. return;
  33392. }
  33393. for (var i = 0, ul = this._vertexAttribArraysEnabled.length; i < ul; i++) {
  33394. if (i >= this._caps.maxVertexAttribs || !this._vertexAttribArraysEnabled[i]) {
  33395. continue;
  33396. }
  33397. this._gl.disableVertexAttribArray(i);
  33398. this._vertexAttribArraysEnabled[i] = false;
  33399. this._currentBufferPointers[i].active = false;
  33400. }
  33401. };
  33402. /**
  33403. * 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
  33404. */
  33405. Engine.prototype.releaseEffects = function () {
  33406. for (var name in this._compiledEffects) {
  33407. this._deleteProgram(this._compiledEffects[name]._program);
  33408. }
  33409. this._compiledEffects = {};
  33410. };
  33411. /**
  33412. * Dispose and release all associated resources
  33413. */
  33414. Engine.prototype.dispose = function () {
  33415. this.hideLoadingUI();
  33416. this.stopRenderLoop();
  33417. this.onNewSceneAddedObservable.clear();
  33418. // Release postProcesses
  33419. while (this.postProcesses.length) {
  33420. this.postProcesses[0].dispose();
  33421. }
  33422. // Empty texture
  33423. if (this._emptyTexture) {
  33424. this._releaseTexture(this._emptyTexture);
  33425. this._emptyTexture = null;
  33426. }
  33427. if (this._emptyCubeTexture) {
  33428. this._releaseTexture(this._emptyCubeTexture);
  33429. this._emptyCubeTexture = null;
  33430. }
  33431. // Rescale PP
  33432. if (this._rescalePostProcess) {
  33433. this._rescalePostProcess.dispose();
  33434. }
  33435. // Release scenes
  33436. while (this.scenes.length) {
  33437. this.scenes[0].dispose();
  33438. }
  33439. // Release audio engine
  33440. if (Engine.Instances.length === 1 && Engine.audioEngine) {
  33441. Engine.audioEngine.dispose();
  33442. }
  33443. // Release effects
  33444. this.releaseEffects();
  33445. // Unbind
  33446. this.unbindAllAttributes();
  33447. this._boundUniforms = [];
  33448. if (this._dummyFramebuffer) {
  33449. this._gl.deleteFramebuffer(this._dummyFramebuffer);
  33450. }
  33451. //WebVR
  33452. this.disableVR();
  33453. // Events
  33454. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  33455. window.removeEventListener("blur", this._onBlur);
  33456. window.removeEventListener("focus", this._onFocus);
  33457. window.removeEventListener('vrdisplaypointerrestricted', this._onVRDisplayPointerRestricted);
  33458. window.removeEventListener('vrdisplaypointerunrestricted', this._onVRDisplayPointerUnrestricted);
  33459. if (this._renderingCanvas) {
  33460. this._renderingCanvas.removeEventListener("focus", this._onCanvasFocus);
  33461. this._renderingCanvas.removeEventListener("blur", this._onCanvasBlur);
  33462. this._renderingCanvas.removeEventListener("pointerout", this._onCanvasPointerOut);
  33463. if (!this._doNotHandleContextLost) {
  33464. this._renderingCanvas.removeEventListener("webglcontextlost", this._onContextLost);
  33465. this._renderingCanvas.removeEventListener("webglcontextrestored", this._onContextRestored);
  33466. }
  33467. }
  33468. document.removeEventListener("fullscreenchange", this._onFullscreenChange);
  33469. document.removeEventListener("mozfullscreenchange", this._onFullscreenChange);
  33470. document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange);
  33471. document.removeEventListener("msfullscreenchange", this._onFullscreenChange);
  33472. document.removeEventListener("pointerlockchange", this._onPointerLockChange);
  33473. document.removeEventListener("mspointerlockchange", this._onPointerLockChange);
  33474. document.removeEventListener("mozpointerlockchange", this._onPointerLockChange);
  33475. document.removeEventListener("webkitpointerlockchange", this._onPointerLockChange);
  33476. if (this._onVrDisplayConnect) {
  33477. window.removeEventListener('vrdisplayconnect', this._onVrDisplayConnect);
  33478. if (this._onVrDisplayDisconnect) {
  33479. window.removeEventListener('vrdisplaydisconnect', this._onVrDisplayDisconnect);
  33480. }
  33481. if (this._onVrDisplayPresentChange) {
  33482. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  33483. }
  33484. this._onVrDisplayConnect = null;
  33485. this._onVrDisplayDisconnect = null;
  33486. }
  33487. }
  33488. // Remove from Instances
  33489. var index = Engine.Instances.indexOf(this);
  33490. if (index >= 0) {
  33491. Engine.Instances.splice(index, 1);
  33492. }
  33493. this._workingCanvas = null;
  33494. this._workingContext = null;
  33495. this._currentBufferPointers = [];
  33496. this._renderingCanvas = null;
  33497. this._currentProgram = null;
  33498. this._bindedRenderFunction = null;
  33499. this.onResizeObservable.clear();
  33500. this.onCanvasBlurObservable.clear();
  33501. this.onCanvasFocusObservable.clear();
  33502. this.onCanvasPointerOutObservable.clear();
  33503. this.onBeginFrameObservable.clear();
  33504. this.onEndFrameObservable.clear();
  33505. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ResetCache();
  33506. // Abort active requests
  33507. for (var _i = 0, _a = this._activeRequests; _i < _a.length; _i++) {
  33508. var request = _a[_i];
  33509. request.abort();
  33510. }
  33511. };
  33512. // Loading screen
  33513. /**
  33514. * Display the loading screen
  33515. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33516. */
  33517. Engine.prototype.displayLoadingUI = function () {
  33518. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  33519. return;
  33520. }
  33521. var loadingScreen = this.loadingScreen;
  33522. if (loadingScreen) {
  33523. loadingScreen.displayLoadingUI();
  33524. }
  33525. };
  33526. /**
  33527. * Hide the loading screen
  33528. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33529. */
  33530. Engine.prototype.hideLoadingUI = function () {
  33531. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  33532. return;
  33533. }
  33534. var loadingScreen = this.loadingScreen;
  33535. if (loadingScreen) {
  33536. loadingScreen.hideLoadingUI();
  33537. }
  33538. };
  33539. Object.defineProperty(Engine.prototype, "loadingScreen", {
  33540. /**
  33541. * Gets the current loading screen object
  33542. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33543. */
  33544. get: function () {
  33545. if (!this._loadingScreen && this._renderingCanvas) {
  33546. this._loadingScreen = Engine.DefaultLoadingScreenFactory(this._renderingCanvas);
  33547. }
  33548. return this._loadingScreen;
  33549. },
  33550. /**
  33551. * Sets the current loading screen object
  33552. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33553. */
  33554. set: function (loadingScreen) {
  33555. this._loadingScreen = loadingScreen;
  33556. },
  33557. enumerable: true,
  33558. configurable: true
  33559. });
  33560. Object.defineProperty(Engine.prototype, "loadingUIText", {
  33561. /**
  33562. * Sets the current loading screen text
  33563. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33564. */
  33565. set: function (text) {
  33566. this.loadingScreen.loadingUIText = text;
  33567. },
  33568. enumerable: true,
  33569. configurable: true
  33570. });
  33571. Object.defineProperty(Engine.prototype, "loadingUIBackgroundColor", {
  33572. /**
  33573. * Sets the current loading screen background color
  33574. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33575. */
  33576. set: function (color) {
  33577. this.loadingScreen.loadingUIBackgroundColor = color;
  33578. },
  33579. enumerable: true,
  33580. configurable: true
  33581. });
  33582. /**
  33583. * Attach a new callback raised when context lost event is fired
  33584. * @param callback defines the callback to call
  33585. */
  33586. Engine.prototype.attachContextLostEvent = function (callback) {
  33587. if (this._renderingCanvas) {
  33588. this._renderingCanvas.addEventListener("webglcontextlost", callback, false);
  33589. }
  33590. };
  33591. /**
  33592. * Attach a new callback raised when context restored event is fired
  33593. * @param callback defines the callback to call
  33594. */
  33595. Engine.prototype.attachContextRestoredEvent = function (callback) {
  33596. if (this._renderingCanvas) {
  33597. this._renderingCanvas.addEventListener("webglcontextrestored", callback, false);
  33598. }
  33599. };
  33600. /**
  33601. * Gets the source code of the vertex shader associated with a specific webGL program
  33602. * @param program defines the program to use
  33603. * @returns a string containing the source code of the vertex shader associated with the program
  33604. */
  33605. Engine.prototype.getVertexShaderSource = function (program) {
  33606. var shaders = this._gl.getAttachedShaders(program);
  33607. if (!shaders) {
  33608. return null;
  33609. }
  33610. return this._gl.getShaderSource(shaders[0]);
  33611. };
  33612. /**
  33613. * Gets the source code of the fragment shader associated with a specific webGL program
  33614. * @param program defines the program to use
  33615. * @returns a string containing the source code of the fragment shader associated with the program
  33616. */
  33617. Engine.prototype.getFragmentShaderSource = function (program) {
  33618. var shaders = this._gl.getAttachedShaders(program);
  33619. if (!shaders) {
  33620. return null;
  33621. }
  33622. return this._gl.getShaderSource(shaders[1]);
  33623. };
  33624. /**
  33625. * Get the current error code of the webGL context
  33626. * @returns the error code
  33627. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  33628. */
  33629. Engine.prototype.getError = function () {
  33630. return this._gl.getError();
  33631. };
  33632. // FPS
  33633. /**
  33634. * Gets the current framerate
  33635. * @returns a number representing the framerate
  33636. */
  33637. Engine.prototype.getFps = function () {
  33638. return this._fps;
  33639. };
  33640. /**
  33641. * Gets the time spent between current and previous frame
  33642. * @returns a number representing the delta time in ms
  33643. */
  33644. Engine.prototype.getDeltaTime = function () {
  33645. return this._deltaTime;
  33646. };
  33647. Engine.prototype._measureFps = function () {
  33648. this._performanceMonitor.sampleFrame();
  33649. this._fps = this._performanceMonitor.averageFPS;
  33650. this._deltaTime = this._performanceMonitor.instantaneousFrameTime || 0;
  33651. };
  33652. /** @hidden */
  33653. Engine.prototype._readTexturePixels = function (texture, width, height, faceIndex, level, buffer) {
  33654. if (faceIndex === void 0) { faceIndex = -1; }
  33655. if (level === void 0) { level = 0; }
  33656. if (buffer === void 0) { buffer = null; }
  33657. var gl = this._gl;
  33658. if (!this._dummyFramebuffer) {
  33659. var dummy = gl.createFramebuffer();
  33660. if (!dummy) {
  33661. throw new Error("Unable to create dummy framebuffer");
  33662. }
  33663. this._dummyFramebuffer = dummy;
  33664. }
  33665. gl.bindFramebuffer(gl.FRAMEBUFFER, this._dummyFramebuffer);
  33666. if (faceIndex > -1) {
  33667. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture._webGLTexture, level);
  33668. }
  33669. else {
  33670. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, level);
  33671. }
  33672. var readType = (texture.type !== undefined) ? this._getWebGLTextureType(texture.type) : gl.UNSIGNED_BYTE;
  33673. switch (readType) {
  33674. case gl.UNSIGNED_BYTE:
  33675. if (!buffer) {
  33676. buffer = new Uint8Array(4 * width * height);
  33677. }
  33678. readType = gl.UNSIGNED_BYTE;
  33679. break;
  33680. default:
  33681. if (!buffer) {
  33682. buffer = new Float32Array(4 * width * height);
  33683. }
  33684. readType = gl.FLOAT;
  33685. break;
  33686. }
  33687. gl.readPixels(0, 0, width, height, gl.RGBA, readType, buffer);
  33688. gl.bindFramebuffer(gl.FRAMEBUFFER, this._currentFramebuffer);
  33689. return buffer;
  33690. };
  33691. Engine.prototype._canRenderToFloatFramebuffer = function () {
  33692. if (this._webGLVersion > 1) {
  33693. return this._caps.colorBufferFloat;
  33694. }
  33695. return this._canRenderToFramebuffer(Engine.TEXTURETYPE_FLOAT);
  33696. };
  33697. Engine.prototype._canRenderToHalfFloatFramebuffer = function () {
  33698. if (this._webGLVersion > 1) {
  33699. return this._caps.colorBufferFloat;
  33700. }
  33701. return this._canRenderToFramebuffer(Engine.TEXTURETYPE_HALF_FLOAT);
  33702. };
  33703. // Thank you : http://stackoverflow.com/questions/28827511/webgl-ios-render-to-floating-point-texture
  33704. Engine.prototype._canRenderToFramebuffer = function (type) {
  33705. var gl = this._gl;
  33706. //clear existing errors
  33707. while (gl.getError() !== gl.NO_ERROR) { }
  33708. var successful = true;
  33709. var texture = gl.createTexture();
  33710. gl.bindTexture(gl.TEXTURE_2D, texture);
  33711. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(type), 1, 1, 0, gl.RGBA, this._getWebGLTextureType(type), null);
  33712. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  33713. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  33714. var fb = gl.createFramebuffer();
  33715. gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
  33716. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
  33717. var status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
  33718. successful = successful && (status === gl.FRAMEBUFFER_COMPLETE);
  33719. successful = successful && (gl.getError() === gl.NO_ERROR);
  33720. //try render by clearing frame buffer's color buffer
  33721. if (successful) {
  33722. gl.clear(gl.COLOR_BUFFER_BIT);
  33723. successful = successful && (gl.getError() === gl.NO_ERROR);
  33724. }
  33725. //try reading from frame to ensure render occurs (just creating the FBO is not sufficient to determine if rendering is supported)
  33726. if (successful) {
  33727. //in practice it's sufficient to just read from the backbuffer rather than handle potentially issues reading from the texture
  33728. gl.bindFramebuffer(gl.FRAMEBUFFER, null);
  33729. var readFormat = gl.RGBA;
  33730. var readType = gl.UNSIGNED_BYTE;
  33731. var buffer = new Uint8Array(4);
  33732. gl.readPixels(0, 0, 1, 1, readFormat, readType, buffer);
  33733. successful = successful && (gl.getError() === gl.NO_ERROR);
  33734. }
  33735. //clean up
  33736. gl.deleteTexture(texture);
  33737. gl.deleteFramebuffer(fb);
  33738. gl.bindFramebuffer(gl.FRAMEBUFFER, null);
  33739. //clear accumulated errors
  33740. while (!successful && (gl.getError() !== gl.NO_ERROR)) { }
  33741. return successful;
  33742. };
  33743. /** @hidden */
  33744. Engine.prototype._getWebGLTextureType = function (type) {
  33745. if (this._webGLVersion === 1) {
  33746. switch (type) {
  33747. case Engine.TEXTURETYPE_FLOAT:
  33748. return this._gl.FLOAT;
  33749. case Engine.TEXTURETYPE_HALF_FLOAT:
  33750. return this._gl.HALF_FLOAT_OES;
  33751. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  33752. return this._gl.UNSIGNED_BYTE;
  33753. }
  33754. return this._gl.UNSIGNED_BYTE;
  33755. }
  33756. switch (type) {
  33757. case Engine.TEXTURETYPE_BYTE:
  33758. return this._gl.BYTE;
  33759. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  33760. return this._gl.UNSIGNED_BYTE;
  33761. case Engine.TEXTURETYPE_SHORT:
  33762. return this._gl.SHORT;
  33763. case Engine.TEXTURETYPE_UNSIGNED_SHORT:
  33764. return this._gl.UNSIGNED_SHORT;
  33765. case Engine.TEXTURETYPE_INT:
  33766. return this._gl.INT;
  33767. case Engine.TEXTURETYPE_UNSIGNED_INTEGER: // Refers to UNSIGNED_INT
  33768. return this._gl.UNSIGNED_INT;
  33769. case Engine.TEXTURETYPE_FLOAT:
  33770. return this._gl.FLOAT;
  33771. case Engine.TEXTURETYPE_HALF_FLOAT:
  33772. return this._gl.HALF_FLOAT;
  33773. case Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
  33774. return this._gl.UNSIGNED_SHORT_4_4_4_4;
  33775. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
  33776. return this._gl.UNSIGNED_SHORT_5_5_5_1;
  33777. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
  33778. return this._gl.UNSIGNED_SHORT_5_6_5;
  33779. case Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
  33780. return this._gl.UNSIGNED_INT_2_10_10_10_REV;
  33781. case Engine.TEXTURETYPE_UNSIGNED_INT_24_8:
  33782. return this._gl.UNSIGNED_INT_24_8;
  33783. case Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
  33784. return this._gl.UNSIGNED_INT_10F_11F_11F_REV;
  33785. case Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
  33786. return this._gl.UNSIGNED_INT_5_9_9_9_REV;
  33787. case Engine.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV:
  33788. return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV;
  33789. }
  33790. return this._gl.UNSIGNED_BYTE;
  33791. };
  33792. Engine.prototype._getInternalFormat = function (format) {
  33793. var internalFormat = this._gl.RGBA;
  33794. switch (format) {
  33795. case Engine.TEXTUREFORMAT_ALPHA:
  33796. internalFormat = this._gl.ALPHA;
  33797. break;
  33798. case Engine.TEXTUREFORMAT_LUMINANCE:
  33799. internalFormat = this._gl.LUMINANCE;
  33800. break;
  33801. case Engine.TEXTUREFORMAT_LUMINANCE_ALPHA:
  33802. internalFormat = this._gl.LUMINANCE_ALPHA;
  33803. break;
  33804. case Engine.TEXTUREFORMAT_RED:
  33805. internalFormat = this._gl.RED;
  33806. break;
  33807. case Engine.TEXTUREFORMAT_RG:
  33808. internalFormat = this._gl.RG;
  33809. break;
  33810. case Engine.TEXTUREFORMAT_RGB:
  33811. internalFormat = this._gl.RGB;
  33812. break;
  33813. case Engine.TEXTUREFORMAT_RGBA:
  33814. internalFormat = this._gl.RGBA;
  33815. break;
  33816. }
  33817. if (this._webGLVersion > 1) {
  33818. switch (format) {
  33819. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33820. internalFormat = this._gl.RED_INTEGER;
  33821. break;
  33822. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33823. internalFormat = this._gl.RG_INTEGER;
  33824. break;
  33825. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33826. internalFormat = this._gl.RGB_INTEGER;
  33827. break;
  33828. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33829. internalFormat = this._gl.RGBA_INTEGER;
  33830. break;
  33831. }
  33832. }
  33833. return internalFormat;
  33834. };
  33835. /** @hidden */
  33836. Engine.prototype._getRGBABufferInternalSizedFormat = function (type, format) {
  33837. if (this._webGLVersion === 1) {
  33838. if (format !== undefined) {
  33839. switch (format) {
  33840. case Engine.TEXTUREFORMAT_ALPHA:
  33841. return this._gl.ALPHA;
  33842. case Engine.TEXTUREFORMAT_LUMINANCE:
  33843. return this._gl.LUMINANCE;
  33844. case Engine.TEXTUREFORMAT_LUMINANCE_ALPHA:
  33845. return this._gl.LUMINANCE_ALPHA;
  33846. }
  33847. }
  33848. return this._gl.RGBA;
  33849. }
  33850. switch (type) {
  33851. case Engine.TEXTURETYPE_BYTE:
  33852. switch (format) {
  33853. case Engine.TEXTUREFORMAT_RED:
  33854. return this._gl.R8_SNORM;
  33855. case Engine.TEXTUREFORMAT_RG:
  33856. return this._gl.RG8_SNORM;
  33857. case Engine.TEXTUREFORMAT_RGB:
  33858. return this._gl.RGB8_SNORM;
  33859. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33860. return this._gl.R8I;
  33861. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33862. return this._gl.RG8I;
  33863. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33864. return this._gl.RGB8I;
  33865. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33866. return this._gl.RGBA8I;
  33867. default:
  33868. return this._gl.RGBA8_SNORM;
  33869. }
  33870. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  33871. switch (format) {
  33872. case Engine.TEXTUREFORMAT_RED:
  33873. return this._gl.R8;
  33874. case Engine.TEXTUREFORMAT_RG:
  33875. return this._gl.RG8;
  33876. case Engine.TEXTUREFORMAT_RGB:
  33877. return this._gl.RGB8; // By default. Other possibilities are RGB565, SRGB8.
  33878. case Engine.TEXTUREFORMAT_RGBA:
  33879. return this._gl.RGBA8; // By default. Other possibilities are RGB5_A1, RGBA4, SRGB8_ALPHA8.
  33880. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33881. return this._gl.R8UI;
  33882. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33883. return this._gl.RG8UI;
  33884. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33885. return this._gl.RGB8UI;
  33886. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33887. return this._gl.RGBA8UI;
  33888. default:
  33889. return this._gl.RGBA8;
  33890. }
  33891. case Engine.TEXTURETYPE_SHORT:
  33892. switch (format) {
  33893. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33894. return this._gl.R16I;
  33895. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33896. return this._gl.RG16I;
  33897. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33898. return this._gl.RGB16I;
  33899. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33900. return this._gl.RGBA16I;
  33901. default:
  33902. return this._gl.RGBA16I;
  33903. }
  33904. case Engine.TEXTURETYPE_UNSIGNED_SHORT:
  33905. switch (format) {
  33906. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33907. return this._gl.R16UI;
  33908. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33909. return this._gl.RG16UI;
  33910. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33911. return this._gl.RGB16UI;
  33912. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33913. return this._gl.RGBA16UI;
  33914. default:
  33915. return this._gl.RGBA16UI;
  33916. }
  33917. case Engine.TEXTURETYPE_INT:
  33918. switch (format) {
  33919. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33920. return this._gl.R32I;
  33921. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33922. return this._gl.RG32I;
  33923. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33924. return this._gl.RGB32I;
  33925. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33926. return this._gl.RGBA32I;
  33927. default:
  33928. return this._gl.RGBA32I;
  33929. }
  33930. case Engine.TEXTURETYPE_UNSIGNED_INTEGER: // Refers to UNSIGNED_INT
  33931. switch (format) {
  33932. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33933. return this._gl.R32UI;
  33934. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33935. return this._gl.RG32UI;
  33936. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33937. return this._gl.RGB32UI;
  33938. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33939. return this._gl.RGBA32UI;
  33940. default:
  33941. return this._gl.RGBA32UI;
  33942. }
  33943. case Engine.TEXTURETYPE_FLOAT:
  33944. switch (format) {
  33945. case Engine.TEXTUREFORMAT_RED:
  33946. return this._gl.R32F; // By default. Other possibility is R16F.
  33947. case Engine.TEXTUREFORMAT_RG:
  33948. return this._gl.RG32F; // By default. Other possibility is RG16F.
  33949. case Engine.TEXTUREFORMAT_RGB:
  33950. return this._gl.RGB32F; // By default. Other possibilities are RGB16F, R11F_G11F_B10F, RGB9_E5.
  33951. case Engine.TEXTUREFORMAT_RGBA:
  33952. return this._gl.RGBA32F; // By default. Other possibility is RGBA16F.
  33953. default:
  33954. return this._gl.RGBA32F;
  33955. }
  33956. case Engine.TEXTURETYPE_HALF_FLOAT:
  33957. switch (format) {
  33958. case Engine.TEXTUREFORMAT_RED:
  33959. return this._gl.R16F;
  33960. case Engine.TEXTUREFORMAT_RG:
  33961. return this._gl.RG16F;
  33962. case Engine.TEXTUREFORMAT_RGB:
  33963. return this._gl.RGB16F; // By default. Other possibilities are R11F_G11F_B10F, RGB9_E5.
  33964. case Engine.TEXTUREFORMAT_RGBA:
  33965. return this._gl.RGBA16F;
  33966. default:
  33967. return this._gl.RGBA16F;
  33968. }
  33969. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
  33970. return this._gl.RGB565;
  33971. case Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
  33972. return this._gl.R11F_G11F_B10F;
  33973. case Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
  33974. return this._gl.RGB9_E5;
  33975. case Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
  33976. return this._gl.RGBA4;
  33977. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
  33978. return this._gl.RGB5_A1;
  33979. case Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
  33980. switch (format) {
  33981. case Engine.TEXTUREFORMAT_RGBA:
  33982. return this._gl.RGB10_A2; // By default. Other possibility is RGB5_A1.
  33983. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33984. return this._gl.RGB10_A2UI;
  33985. default:
  33986. return this._gl.RGB10_A2;
  33987. }
  33988. }
  33989. return this._gl.RGBA8;
  33990. };
  33991. /** @hidden */
  33992. Engine.prototype._getRGBAMultiSampleBufferFormat = function (type) {
  33993. if (type === Engine.TEXTURETYPE_FLOAT) {
  33994. return this._gl.RGBA32F;
  33995. }
  33996. else if (type === Engine.TEXTURETYPE_HALF_FLOAT) {
  33997. return this._gl.RGBA16F;
  33998. }
  33999. return this._gl.RGBA8;
  34000. };
  34001. /** @hidden */
  34002. Engine.prototype._loadFile = function (url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {
  34003. var _this = this;
  34004. var request = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadFile(url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError);
  34005. this._activeRequests.push(request);
  34006. request.onCompleteObservable.add(function (request) {
  34007. _this._activeRequests.splice(_this._activeRequests.indexOf(request), 1);
  34008. });
  34009. return request;
  34010. };
  34011. /** @hidden */
  34012. Engine.prototype._loadFileAsync = function (url, offlineProvider, useArrayBuffer) {
  34013. var _this = this;
  34014. return new Promise(function (resolve, reject) {
  34015. _this._loadFile(url, function (data) {
  34016. resolve(data);
  34017. }, undefined, offlineProvider, useArrayBuffer, function (request, exception) {
  34018. reject(exception);
  34019. });
  34020. });
  34021. };
  34022. Engine.prototype._partialLoadFile = function (url, index, loadedFiles, onfinish, onErrorCallBack) {
  34023. if (onErrorCallBack === void 0) { onErrorCallBack = null; }
  34024. var onload = function (data) {
  34025. loadedFiles[index] = data;
  34026. loadedFiles._internalCount++;
  34027. if (loadedFiles._internalCount === 6) {
  34028. onfinish(loadedFiles);
  34029. }
  34030. };
  34031. var onerror = function (request, exception) {
  34032. if (onErrorCallBack && request) {
  34033. onErrorCallBack(request.status + " " + request.statusText, exception);
  34034. }
  34035. };
  34036. this._loadFile(url, onload, undefined, undefined, true, onerror);
  34037. };
  34038. Engine.prototype._cascadeLoadFiles = function (scene, onfinish, files, onError) {
  34039. if (onError === void 0) { onError = null; }
  34040. var loadedFiles = [];
  34041. loadedFiles._internalCount = 0;
  34042. for (var index = 0; index < 6; index++) {
  34043. this._partialLoadFile(files[index], index, loadedFiles, onfinish, onError);
  34044. }
  34045. };
  34046. // Statics
  34047. /**
  34048. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  34049. * @returns true if the engine can be created
  34050. * @ignorenaming
  34051. */
  34052. Engine.isSupported = function () {
  34053. try {
  34054. var tempcanvas = document.createElement("canvas");
  34055. var gl = tempcanvas.getContext("webgl") || tempcanvas.getContext("experimental-webgl");
  34056. return gl != null && !!window.WebGLRenderingContext;
  34057. }
  34058. catch (e) {
  34059. return false;
  34060. }
  34061. };
  34062. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  34063. Engine.ExceptionList = [
  34064. { key: "Chrome/63.0", capture: "63\\.0\\.3239\\.(\\d+)", captureConstraint: 108, targets: ["uniformBuffer"] },
  34065. { key: "Firefox/58", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
  34066. { key: "Firefox/59", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
  34067. { key: "Macintosh", capture: null, captureConstraint: null, targets: ["textureBindingOptimization"] },
  34068. { key: "iPhone", capture: null, captureConstraint: null, targets: ["textureBindingOptimization"] },
  34069. { key: "iPad", capture: null, captureConstraint: null, targets: ["textureBindingOptimization"] }
  34070. ];
  34071. /**
  34072. * Hidden
  34073. */
  34074. Engine._TextureLoaders = [];
  34075. // Const statics
  34076. /** Defines that alpha blending is disabled */
  34077. Engine.ALPHA_DISABLE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_DISABLE;
  34078. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  34079. Engine.ALPHA_ADD = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_ADD;
  34080. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  34081. Engine.ALPHA_COMBINE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_COMBINE;
  34082. /** Defines that alpha blending to DEST - SRC * DEST */
  34083. Engine.ALPHA_SUBTRACT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_SUBTRACT;
  34084. /** Defines that alpha blending to SRC * DEST */
  34085. Engine.ALPHA_MULTIPLY = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_MULTIPLY;
  34086. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  34087. Engine.ALPHA_MAXIMIZED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_MAXIMIZED;
  34088. /** Defines that alpha blending to SRC + DEST */
  34089. Engine.ALPHA_ONEONE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_ONEONE;
  34090. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  34091. Engine.ALPHA_PREMULTIPLIED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_PREMULTIPLIED;
  34092. /**
  34093. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  34094. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  34095. */
  34096. Engine.ALPHA_PREMULTIPLIED_PORTERDUFF = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF;
  34097. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  34098. Engine.ALPHA_INTERPOLATE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_INTERPOLATE;
  34099. /**
  34100. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  34101. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  34102. */
  34103. Engine.ALPHA_SCREENMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_SCREENMODE;
  34104. /** Defines that the ressource is not delayed*/
  34105. Engine.DELAYLOADSTATE_NONE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_NONE;
  34106. /** Defines that the ressource was successfully delay loaded */
  34107. Engine.DELAYLOADSTATE_LOADED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_LOADED;
  34108. /** Defines that the ressource is currently delay loading */
  34109. Engine.DELAYLOADSTATE_LOADING = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_LOADING;
  34110. /** Defines that the ressource is delayed and has not started loading */
  34111. Engine.DELAYLOADSTATE_NOTLOADED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_NOTLOADED;
  34112. // Depht or Stencil test Constants.
  34113. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34114. Engine.NEVER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].NEVER;
  34115. /** 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 */
  34116. Engine.ALWAYS = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALWAYS;
  34117. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34118. Engine.LESS = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].LESS;
  34119. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34120. Engine.EQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].EQUAL;
  34121. /** 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 */
  34122. Engine.LEQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].LEQUAL;
  34123. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34124. Engine.GREATER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].GREATER;
  34125. /** 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 */
  34126. Engine.GEQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].GEQUAL;
  34127. /** 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 */
  34128. Engine.NOTEQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].NOTEQUAL;
  34129. // Stencil Actions Constants.
  34130. /** Passed to stencilOperation to specify that stencil value must be kept */
  34131. Engine.KEEP = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].KEEP;
  34132. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34133. Engine.REPLACE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].REPLACE;
  34134. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34135. Engine.INCR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].INCR;
  34136. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34137. Engine.DECR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DECR;
  34138. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34139. Engine.INVERT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].INVERT;
  34140. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34141. Engine.INCR_WRAP = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].INCR_WRAP;
  34142. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34143. Engine.DECR_WRAP = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DECR_WRAP;
  34144. /** Texture is not repeating outside of 0..1 UVs */
  34145. Engine.TEXTURE_CLAMP_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  34146. /** Texture is repeating outside of 0..1 UVs */
  34147. Engine.TEXTURE_WRAP_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  34148. /** Texture is repeating and mirrored */
  34149. Engine.TEXTURE_MIRROR_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_MIRROR_ADDRESSMODE;
  34150. /** ALPHA */
  34151. Engine.TEXTUREFORMAT_ALPHA = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_ALPHA;
  34152. /** LUMINANCE */
  34153. Engine.TEXTUREFORMAT_LUMINANCE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_LUMINANCE;
  34154. /** LUMINANCE_ALPHA */
  34155. Engine.TEXTUREFORMAT_LUMINANCE_ALPHA = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_LUMINANCE_ALPHA;
  34156. /** RGB */
  34157. Engine.TEXTUREFORMAT_RGB = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGB;
  34158. /** RGBA */
  34159. Engine.TEXTUREFORMAT_RGBA = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGBA;
  34160. /** RED */
  34161. Engine.TEXTUREFORMAT_RED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RED;
  34162. /** RED (2nd reference) */
  34163. Engine.TEXTUREFORMAT_R = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_R;
  34164. /** RG */
  34165. Engine.TEXTUREFORMAT_RG = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RG;
  34166. /** RED_INTEGER */
  34167. Engine.TEXTUREFORMAT_RED_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RED_INTEGER;
  34168. /** RED_INTEGER (2nd reference) */
  34169. Engine.TEXTUREFORMAT_R_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_R_INTEGER;
  34170. /** RG_INTEGER */
  34171. Engine.TEXTUREFORMAT_RG_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RG_INTEGER;
  34172. /** RGB_INTEGER */
  34173. Engine.TEXTUREFORMAT_RGB_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGB_INTEGER;
  34174. /** RGBA_INTEGER */
  34175. Engine.TEXTUREFORMAT_RGBA_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGBA_INTEGER;
  34176. /** UNSIGNED_BYTE */
  34177. Engine.TEXTURETYPE_UNSIGNED_BYTE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_BYTE;
  34178. /** UNSIGNED_BYTE (2nd reference) */
  34179. Engine.TEXTURETYPE_UNSIGNED_INT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  34180. /** FLOAT */
  34181. Engine.TEXTURETYPE_FLOAT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_FLOAT;
  34182. /** HALF_FLOAT */
  34183. Engine.TEXTURETYPE_HALF_FLOAT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_HALF_FLOAT;
  34184. /** BYTE */
  34185. Engine.TEXTURETYPE_BYTE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_BYTE;
  34186. /** SHORT */
  34187. Engine.TEXTURETYPE_SHORT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_SHORT;
  34188. /** UNSIGNED_SHORT */
  34189. Engine.TEXTURETYPE_UNSIGNED_SHORT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT;
  34190. /** INT */
  34191. Engine.TEXTURETYPE_INT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_INT;
  34192. /** UNSIGNED_INT */
  34193. Engine.TEXTURETYPE_UNSIGNED_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INTEGER;
  34194. /** UNSIGNED_SHORT_4_4_4_4 */
  34195. Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4;
  34196. /** UNSIGNED_SHORT_5_5_5_1 */
  34197. Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1;
  34198. /** UNSIGNED_SHORT_5_6_5 */
  34199. Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_5_6_5;
  34200. /** UNSIGNED_INT_2_10_10_10_REV */
  34201. Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV;
  34202. /** UNSIGNED_INT_24_8 */
  34203. Engine.TEXTURETYPE_UNSIGNED_INT_24_8 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_24_8;
  34204. /** UNSIGNED_INT_10F_11F_11F_REV */
  34205. Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV;
  34206. /** UNSIGNED_INT_5_9_9_9_REV */
  34207. Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV;
  34208. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34209. Engine.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV;
  34210. /** nearest is mag = nearest and min = nearest and mip = linear */
  34211. Engine.TEXTURE_NEAREST_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  34212. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34213. Engine.TEXTURE_BILINEAR_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE;
  34214. /** Trilinear is mag = linear and min = linear and mip = linear */
  34215. Engine.TEXTURE_TRILINEAR_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  34216. /** nearest is mag = nearest and min = nearest and mip = linear */
  34217. Engine.TEXTURE_NEAREST_NEAREST_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_NEAREST_MIPLINEAR;
  34218. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34219. Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_LINEAR_MIPNEAREST;
  34220. /** Trilinear is mag = linear and min = linear and mip = linear */
  34221. Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_LINEAR_MIPLINEAR;
  34222. /** mag = nearest and min = nearest and mip = nearest */
  34223. Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_NEAREST_MIPNEAREST;
  34224. /** mag = nearest and min = linear and mip = nearest */
  34225. Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_LINEAR_MIPNEAREST;
  34226. /** mag = nearest and min = linear and mip = linear */
  34227. Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_LINEAR_MIPLINEAR;
  34228. /** mag = nearest and min = linear and mip = none */
  34229. Engine.TEXTURE_NEAREST_LINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_LINEAR;
  34230. /** mag = nearest and min = nearest and mip = none */
  34231. Engine.TEXTURE_NEAREST_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_NEAREST;
  34232. /** mag = linear and min = nearest and mip = nearest */
  34233. Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_NEAREST_MIPNEAREST;
  34234. /** mag = linear and min = nearest and mip = linear */
  34235. Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_NEAREST_MIPLINEAR;
  34236. /** mag = linear and min = linear and mip = none */
  34237. Engine.TEXTURE_LINEAR_LINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_LINEAR;
  34238. /** mag = linear and min = nearest and mip = none */
  34239. Engine.TEXTURE_LINEAR_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_NEAREST;
  34240. /** Explicit coordinates mode */
  34241. Engine.TEXTURE_EXPLICIT_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_EXPLICIT_MODE;
  34242. /** Spherical coordinates mode */
  34243. Engine.TEXTURE_SPHERICAL_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_SPHERICAL_MODE;
  34244. /** Planar coordinates mode */
  34245. Engine.TEXTURE_PLANAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_PLANAR_MODE;
  34246. /** Cubic coordinates mode */
  34247. Engine.TEXTURE_CUBIC_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_CUBIC_MODE;
  34248. /** Projection coordinates mode */
  34249. Engine.TEXTURE_PROJECTION_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_PROJECTION_MODE;
  34250. /** Skybox coordinates mode */
  34251. Engine.TEXTURE_SKYBOX_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_SKYBOX_MODE;
  34252. /** Inverse Cubic coordinates mode */
  34253. Engine.TEXTURE_INVCUBIC_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_INVCUBIC_MODE;
  34254. /** Equirectangular coordinates mode */
  34255. Engine.TEXTURE_EQUIRECTANGULAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_EQUIRECTANGULAR_MODE;
  34256. /** Equirectangular Fixed coordinates mode */
  34257. Engine.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MODE;
  34258. /** Equirectangular Fixed Mirrored coordinates mode */
  34259. Engine.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE;
  34260. // Texture rescaling mode
  34261. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34262. Engine.SCALEMODE_FLOOR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].SCALEMODE_FLOOR;
  34263. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34264. Engine.SCALEMODE_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].SCALEMODE_NEAREST;
  34265. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34266. Engine.SCALEMODE_CEILING = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].SCALEMODE_CEILING;
  34267. // Updatable statics so stick with vars here
  34268. /**
  34269. * Gets or sets the epsilon value used by collision engine
  34270. */
  34271. Engine.CollisionsEpsilon = 0.001;
  34272. /**
  34273. * Method called to create the default rescale post process on each engine.
  34274. */
  34275. Engine._RescalePostProcessFactory = null;
  34276. return Engine;
  34277. }());
  34278. /***/ }),
  34279. /***/ "./Engines/engineStore.ts":
  34280. /*!********************************!*\
  34281. !*** ./Engines/engineStore.ts ***!
  34282. \********************************/
  34283. /*! exports provided: EngineStore */
  34284. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34285. "use strict";
  34286. __webpack_require__.r(__webpack_exports__);
  34287. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return EngineStore; });
  34288. /**
  34289. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34290. * during the life time of the application.
  34291. */
  34292. var EngineStore = /** @class */ (function () {
  34293. function EngineStore() {
  34294. }
  34295. Object.defineProperty(EngineStore, "LastCreatedEngine", {
  34296. /**
  34297. * Gets the latest created engine
  34298. */
  34299. get: function () {
  34300. if (this.Instances.length === 0) {
  34301. return null;
  34302. }
  34303. return this.Instances[this.Instances.length - 1];
  34304. },
  34305. enumerable: true,
  34306. configurable: true
  34307. });
  34308. Object.defineProperty(EngineStore, "LastCreatedScene", {
  34309. /**
  34310. * Gets the latest created scene
  34311. */
  34312. get: function () {
  34313. var lastCreatedEngine = this.LastCreatedEngine;
  34314. if (!lastCreatedEngine) {
  34315. return null;
  34316. }
  34317. if (lastCreatedEngine.scenes.length === 0) {
  34318. return null;
  34319. }
  34320. return lastCreatedEngine.scenes[lastCreatedEngine.scenes.length - 1];
  34321. },
  34322. enumerable: true,
  34323. configurable: true
  34324. });
  34325. /** Gets the list of created engines */
  34326. EngineStore.Instances = new Array();
  34327. return EngineStore;
  34328. }());
  34329. /***/ }),
  34330. /***/ "./Engines/index.ts":
  34331. /*!**************************!*\
  34332. !*** ./Engines/index.ts ***!
  34333. \**************************/
  34334. /*! exports provided: Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, _OcclusionDataStorage, _forceTransformFeedbackToBundle */
  34335. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34336. "use strict";
  34337. __webpack_require__.r(__webpack_exports__);
  34338. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  34339. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _constants__WEBPACK_IMPORTED_MODULE_0__["Constants"]; });
  34340. /* harmony import */ var _engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine */ "./Engines/engine.ts");
  34341. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["InstancingAttributeInfo"]; });
  34342. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["DepthTextureCreationOptions"]; });
  34343. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["EngineCapabilities"]; });
  34344. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]; });
  34345. /* harmony import */ var _engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./engineStore */ "./Engines/engineStore.ts");
  34346. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"]; });
  34347. /* harmony import */ var _nullEngine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./nullEngine */ "./Engines/nullEngine.ts");
  34348. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _nullEngine__WEBPACK_IMPORTED_MODULE_3__["NullEngineOptions"]; });
  34349. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _nullEngine__WEBPACK_IMPORTED_MODULE_3__["NullEngine"]; });
  34350. /* harmony import */ var _Extensions_index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Extensions/index */ "./Engines/Extensions/index.ts");
  34351. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _Extensions_index__WEBPACK_IMPORTED_MODULE_4__["_OcclusionDataStorage"]; });
  34352. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _Extensions_index__WEBPACK_IMPORTED_MODULE_4__["_forceTransformFeedbackToBundle"]; });
  34353. /***/ }),
  34354. /***/ "./Engines/nullEngine.ts":
  34355. /*!*******************************!*\
  34356. !*** ./Engines/nullEngine.ts ***!
  34357. \*******************************/
  34358. /*! exports provided: NullEngineOptions, NullEngine */
  34359. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34360. "use strict";
  34361. __webpack_require__.r(__webpack_exports__);
  34362. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return NullEngineOptions; });
  34363. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return NullEngine; });
  34364. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34365. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  34366. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  34367. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  34368. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  34369. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  34370. /**
  34371. * Options to create the null engine
  34372. */
  34373. var NullEngineOptions = /** @class */ (function () {
  34374. function NullEngineOptions() {
  34375. /**
  34376. * Render width (Default: 512)
  34377. */
  34378. this.renderWidth = 512;
  34379. /**
  34380. * Render height (Default: 256)
  34381. */
  34382. this.renderHeight = 256;
  34383. /**
  34384. * Texture size (Default: 512)
  34385. */
  34386. this.textureSize = 512;
  34387. /**
  34388. * If delta time between frames should be constant
  34389. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34390. */
  34391. this.deterministicLockstep = false;
  34392. /**
  34393. * Maximum about of steps between frames (Default: 4)
  34394. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34395. */
  34396. this.lockstepMaxSteps = 4;
  34397. }
  34398. return NullEngineOptions;
  34399. }());
  34400. /**
  34401. * The null engine class provides support for headless version of babylon.js.
  34402. * This can be used in server side scenario or for testing purposes
  34403. */
  34404. var NullEngine = /** @class */ (function (_super) {
  34405. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](NullEngine, _super);
  34406. function NullEngine(options) {
  34407. if (options === void 0) { options = new NullEngineOptions(); }
  34408. var _this = _super.call(this, null) || this;
  34409. if (options.deterministicLockstep === undefined) {
  34410. options.deterministicLockstep = false;
  34411. }
  34412. if (options.lockstepMaxSteps === undefined) {
  34413. options.lockstepMaxSteps = 4;
  34414. }
  34415. _this._options = options;
  34416. // Init caps
  34417. // We consider we are on a webgl1 capable device
  34418. _this._caps = new _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["EngineCapabilities"]();
  34419. _this._caps.maxTexturesImageUnits = 16;
  34420. _this._caps.maxVertexTextureImageUnits = 16;
  34421. _this._caps.maxTextureSize = 512;
  34422. _this._caps.maxCubemapTextureSize = 512;
  34423. _this._caps.maxRenderTextureSize = 512;
  34424. _this._caps.maxVertexAttribs = 16;
  34425. _this._caps.maxVaryingVectors = 16;
  34426. _this._caps.maxFragmentUniformVectors = 16;
  34427. _this._caps.maxVertexUniformVectors = 16;
  34428. // Extensions
  34429. _this._caps.standardDerivatives = false;
  34430. _this._caps.astc = null;
  34431. _this._caps.s3tc = null;
  34432. _this._caps.pvrtc = null;
  34433. _this._caps.etc1 = null;
  34434. _this._caps.etc2 = null;
  34435. _this._caps.textureAnisotropicFilterExtension = null;
  34436. _this._caps.maxAnisotropy = 0;
  34437. _this._caps.uintIndices = false;
  34438. _this._caps.fragmentDepthSupported = false;
  34439. _this._caps.highPrecisionShaderSupported = true;
  34440. _this._caps.colorBufferFloat = false;
  34441. _this._caps.textureFloat = false;
  34442. _this._caps.textureFloatLinearFiltering = false;
  34443. _this._caps.textureFloatRender = false;
  34444. _this._caps.textureHalfFloat = false;
  34445. _this._caps.textureHalfFloatLinearFiltering = false;
  34446. _this._caps.textureHalfFloatRender = false;
  34447. _this._caps.textureLOD = false;
  34448. _this._caps.drawBuffersExtension = false;
  34449. _this._caps.depthTextureExtension = false;
  34450. _this._caps.vertexArrayObject = false;
  34451. _this._caps.instancedArrays = false;
  34452. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log("Babylon.js v" + _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].Version + " - Null engine");
  34453. // Wrappers
  34454. if (typeof URL === "undefined") {
  34455. URL = {
  34456. createObjectURL: function () { },
  34457. revokeObjectURL: function () { }
  34458. };
  34459. }
  34460. if (typeof Blob === "undefined") {
  34461. Blob = function () { };
  34462. }
  34463. return _this;
  34464. }
  34465. /**
  34466. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34467. */
  34468. NullEngine.prototype.isDeterministicLockStep = function () {
  34469. return this._options.deterministicLockstep;
  34470. };
  34471. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  34472. NullEngine.prototype.getLockstepMaxSteps = function () {
  34473. return this._options.lockstepMaxSteps;
  34474. };
  34475. /**
  34476. * Sets hardware scaling, used to save performance if needed
  34477. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  34478. */
  34479. NullEngine.prototype.getHardwareScalingLevel = function () {
  34480. return 1.0;
  34481. };
  34482. NullEngine.prototype.createVertexBuffer = function (vertices) {
  34483. return {
  34484. capacity: 0,
  34485. references: 1,
  34486. is32Bits: false
  34487. };
  34488. };
  34489. NullEngine.prototype.createIndexBuffer = function (indices) {
  34490. return {
  34491. capacity: 0,
  34492. references: 1,
  34493. is32Bits: false
  34494. };
  34495. };
  34496. NullEngine.prototype.clear = function (color, backBuffer, depth, stencil) {
  34497. if (stencil === void 0) { stencil = false; }
  34498. };
  34499. NullEngine.prototype.getRenderWidth = function (useScreen) {
  34500. if (useScreen === void 0) { useScreen = false; }
  34501. if (!useScreen && this._currentRenderTarget) {
  34502. return this._currentRenderTarget.width;
  34503. }
  34504. return this._options.renderWidth;
  34505. };
  34506. NullEngine.prototype.getRenderHeight = function (useScreen) {
  34507. if (useScreen === void 0) { useScreen = false; }
  34508. if (!useScreen && this._currentRenderTarget) {
  34509. return this._currentRenderTarget.height;
  34510. }
  34511. return this._options.renderHeight;
  34512. };
  34513. NullEngine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {
  34514. this._cachedViewport = viewport;
  34515. };
  34516. NullEngine.prototype.createShaderProgram = function (vertexCode, fragmentCode, defines, context) {
  34517. return {
  34518. transformFeedback: null,
  34519. __SPECTOR_rebuildProgram: null,
  34520. isParallelCompiled: false
  34521. };
  34522. };
  34523. NullEngine.prototype.getUniforms = function (shaderProgram, uniformsNames) {
  34524. return [];
  34525. };
  34526. NullEngine.prototype.getAttributes = function (shaderProgram, attributesNames) {
  34527. return [];
  34528. };
  34529. NullEngine.prototype.bindSamplers = function (effect) {
  34530. this._currentEffect = null;
  34531. };
  34532. NullEngine.prototype.enableEffect = function (effect) {
  34533. this._currentEffect = effect;
  34534. if (effect.onBind) {
  34535. effect.onBind(effect);
  34536. }
  34537. if (effect._onBindObservable) {
  34538. effect._onBindObservable.notifyObservers(effect);
  34539. }
  34540. };
  34541. NullEngine.prototype.setState = function (culling, zOffset, force, reverseSide) {
  34542. if (zOffset === void 0) { zOffset = 0; }
  34543. if (reverseSide === void 0) { reverseSide = false; }
  34544. };
  34545. NullEngine.prototype.setIntArray = function (uniform, array) {
  34546. };
  34547. NullEngine.prototype.setIntArray2 = function (uniform, array) {
  34548. };
  34549. NullEngine.prototype.setIntArray3 = function (uniform, array) {
  34550. };
  34551. NullEngine.prototype.setIntArray4 = function (uniform, array) {
  34552. };
  34553. NullEngine.prototype.setFloatArray = function (uniform, array) {
  34554. };
  34555. NullEngine.prototype.setFloatArray2 = function (uniform, array) {
  34556. };
  34557. NullEngine.prototype.setFloatArray3 = function (uniform, array) {
  34558. };
  34559. NullEngine.prototype.setFloatArray4 = function (uniform, array) {
  34560. };
  34561. NullEngine.prototype.setArray = function (uniform, array) {
  34562. };
  34563. NullEngine.prototype.setArray2 = function (uniform, array) {
  34564. };
  34565. NullEngine.prototype.setArray3 = function (uniform, array) {
  34566. };
  34567. NullEngine.prototype.setArray4 = function (uniform, array) {
  34568. };
  34569. NullEngine.prototype.setMatrices = function (uniform, matrices) {
  34570. };
  34571. NullEngine.prototype.setMatrix = function (uniform, matrix) {
  34572. };
  34573. NullEngine.prototype.setMatrix3x3 = function (uniform, matrix) {
  34574. };
  34575. NullEngine.prototype.setMatrix2x2 = function (uniform, matrix) {
  34576. };
  34577. NullEngine.prototype.setFloat = function (uniform, value) {
  34578. };
  34579. NullEngine.prototype.setFloat2 = function (uniform, x, y) {
  34580. };
  34581. NullEngine.prototype.setFloat3 = function (uniform, x, y, z) {
  34582. };
  34583. NullEngine.prototype.setBool = function (uniform, bool) {
  34584. };
  34585. NullEngine.prototype.setFloat4 = function (uniform, x, y, z, w) {
  34586. };
  34587. NullEngine.prototype.setColor3 = function (uniform, color3) {
  34588. };
  34589. NullEngine.prototype.setColor4 = function (uniform, color3, alpha) {
  34590. };
  34591. NullEngine.prototype.setAlphaMode = function (mode, noDepthWriteChange) {
  34592. if (noDepthWriteChange === void 0) { noDepthWriteChange = false; }
  34593. if (this._alphaMode === mode) {
  34594. return;
  34595. }
  34596. this._alphaState.alphaBlend = (mode !== _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].ALPHA_DISABLE);
  34597. if (!noDepthWriteChange) {
  34598. this.setDepthWrite(mode === _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].ALPHA_DISABLE);
  34599. }
  34600. this._alphaMode = mode;
  34601. };
  34602. NullEngine.prototype.bindBuffers = function (vertexBuffers, indexBuffer, effect) {
  34603. };
  34604. NullEngine.prototype.wipeCaches = function (bruteForce) {
  34605. if (this.preventCacheWipeBetweenFrames) {
  34606. return;
  34607. }
  34608. this.resetTextureCache();
  34609. this._currentEffect = null;
  34610. if (bruteForce) {
  34611. this._currentProgram = null;
  34612. this._stencilState.reset();
  34613. this._depthCullingState.reset();
  34614. this._alphaState.reset();
  34615. }
  34616. this._cachedVertexBuffers = null;
  34617. this._cachedIndexBuffer = null;
  34618. this._cachedEffectForVertexBuffers = null;
  34619. };
  34620. NullEngine.prototype.draw = function (useTriangles, indexStart, indexCount, instancesCount) {
  34621. };
  34622. NullEngine.prototype.drawElementsType = function (fillMode, indexStart, indexCount, instancesCount) {
  34623. };
  34624. NullEngine.prototype.drawArraysType = function (fillMode, verticesStart, verticesCount, instancesCount) {
  34625. };
  34626. /** @hidden */
  34627. NullEngine.prototype._createTexture = function () {
  34628. return {};
  34629. };
  34630. /** @hidden */
  34631. NullEngine.prototype._releaseTexture = function (texture) {
  34632. };
  34633. NullEngine.prototype.createTexture = function (urlArg, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallBack, format) {
  34634. if (samplingMode === void 0) { samplingMode = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  34635. if (onLoad === void 0) { onLoad = null; }
  34636. if (onError === void 0) { onError = null; }
  34637. if (buffer === void 0) { buffer = null; }
  34638. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_URL);
  34639. var url = String(urlArg);
  34640. texture.url = url;
  34641. texture.generateMipMaps = !noMipmap;
  34642. texture.samplingMode = samplingMode;
  34643. texture.invertY = invertY;
  34644. texture.baseWidth = this._options.textureSize;
  34645. texture.baseHeight = this._options.textureSize;
  34646. texture.width = this._options.textureSize;
  34647. texture.height = this._options.textureSize;
  34648. if (format) {
  34649. texture.format = format;
  34650. }
  34651. texture.isReady = true;
  34652. if (onLoad) {
  34653. onLoad();
  34654. }
  34655. this._internalTexturesCache.push(texture);
  34656. return texture;
  34657. };
  34658. NullEngine.prototype.createRenderTargetTexture = function (size, options) {
  34659. var fullOptions = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_3__["RenderTargetCreationOptions"]();
  34660. if (options !== undefined && typeof options === "object") {
  34661. fullOptions.generateMipMaps = options.generateMipMaps;
  34662. fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  34663. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;
  34664. fullOptions.type = options.type === undefined ? _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT : options.type;
  34665. fullOptions.samplingMode = options.samplingMode === undefined ? _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE : options.samplingMode;
  34666. }
  34667. else {
  34668. fullOptions.generateMipMaps = options;
  34669. fullOptions.generateDepthBuffer = true;
  34670. fullOptions.generateStencilBuffer = false;
  34671. fullOptions.type = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  34672. fullOptions.samplingMode = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  34673. }
  34674. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_RENDERTARGET);
  34675. var width = size.width || size;
  34676. var height = size.height || size;
  34677. texture._depthStencilBuffer = {};
  34678. texture._framebuffer = {};
  34679. texture.baseWidth = width;
  34680. texture.baseHeight = height;
  34681. texture.width = width;
  34682. texture.height = height;
  34683. texture.isReady = true;
  34684. texture.samples = 1;
  34685. texture.generateMipMaps = fullOptions.generateMipMaps ? true : false;
  34686. texture.samplingMode = fullOptions.samplingMode;
  34687. texture.type = fullOptions.type;
  34688. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  34689. texture._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;
  34690. this._internalTexturesCache.push(texture);
  34691. return texture;
  34692. };
  34693. NullEngine.prototype.updateTextureSamplingMode = function (samplingMode, texture) {
  34694. texture.samplingMode = samplingMode;
  34695. };
  34696. NullEngine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport) {
  34697. if (this._currentRenderTarget) {
  34698. this.unBindFramebuffer(this._currentRenderTarget);
  34699. }
  34700. this._currentRenderTarget = texture;
  34701. this._currentFramebuffer = texture._MSAAFramebuffer ? texture._MSAAFramebuffer : texture._framebuffer;
  34702. if (this._cachedViewport && !forceFullscreenViewport) {
  34703. this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);
  34704. }
  34705. };
  34706. NullEngine.prototype.unBindFramebuffer = function (texture, disableGenerateMipMaps, onBeforeUnbind) {
  34707. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  34708. this._currentRenderTarget = null;
  34709. if (onBeforeUnbind) {
  34710. if (texture._MSAAFramebuffer) {
  34711. this._currentFramebuffer = texture._framebuffer;
  34712. }
  34713. onBeforeUnbind();
  34714. }
  34715. this._currentFramebuffer = null;
  34716. };
  34717. NullEngine.prototype.createDynamicVertexBuffer = function (vertices) {
  34718. var vbo = {
  34719. capacity: 1,
  34720. references: 1,
  34721. is32Bits: false
  34722. };
  34723. return vbo;
  34724. };
  34725. NullEngine.prototype.updateDynamicTexture = function (texture, canvas, invertY, premulAlpha, format) {
  34726. if (premulAlpha === void 0) { premulAlpha = false; }
  34727. };
  34728. NullEngine.prototype.areAllEffectsReady = function () {
  34729. return true;
  34730. };
  34731. /**
  34732. * @hidden
  34733. * Get the current error code of the webGL context
  34734. * @returns the error code
  34735. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  34736. */
  34737. NullEngine.prototype.getError = function () {
  34738. return 0;
  34739. };
  34740. /** @hidden */
  34741. NullEngine.prototype._getUnpackAlignement = function () {
  34742. return 1;
  34743. };
  34744. /** @hidden */
  34745. NullEngine.prototype._unpackFlipY = function (value) {
  34746. };
  34747. NullEngine.prototype.updateDynamicIndexBuffer = function (indexBuffer, indices, offset) {
  34748. if (offset === void 0) { offset = 0; }
  34749. };
  34750. /**
  34751. * Updates a dynamic vertex buffer.
  34752. * @param vertexBuffer the vertex buffer to update
  34753. * @param data the data used to update the vertex buffer
  34754. * @param byteOffset the byte offset of the data (optional)
  34755. * @param byteLength the byte length of the data (optional)
  34756. */
  34757. NullEngine.prototype.updateDynamicVertexBuffer = function (vertexBuffer, vertices, byteOffset, byteLength) {
  34758. };
  34759. NullEngine.prototype._bindTextureDirectly = function (target, texture) {
  34760. if (this._boundTexturesCache[this._activeChannel] !== texture) {
  34761. this._boundTexturesCache[this._activeChannel] = texture;
  34762. return true;
  34763. }
  34764. return false;
  34765. };
  34766. /** @hidden */
  34767. NullEngine.prototype._bindTexture = function (channel, texture) {
  34768. if (channel < 0) {
  34769. return;
  34770. }
  34771. this._bindTextureDirectly(0, texture);
  34772. };
  34773. /** @hidden */
  34774. NullEngine.prototype._releaseBuffer = function (buffer) {
  34775. buffer.references--;
  34776. if (buffer.references === 0) {
  34777. return true;
  34778. }
  34779. return false;
  34780. };
  34781. NullEngine.prototype.releaseEffects = function () {
  34782. };
  34783. NullEngine.prototype.displayLoadingUI = function () {
  34784. };
  34785. NullEngine.prototype.hideLoadingUI = function () {
  34786. };
  34787. /** @hidden */
  34788. NullEngine.prototype._uploadCompressedDataToTextureDirectly = function (texture, internalFormat, width, height, data, faceIndex, lod) {
  34789. if (faceIndex === void 0) { faceIndex = 0; }
  34790. if (lod === void 0) { lod = 0; }
  34791. };
  34792. /** @hidden */
  34793. NullEngine.prototype._uploadDataToTextureDirectly = function (texture, imageData, faceIndex, lod) {
  34794. if (faceIndex === void 0) { faceIndex = 0; }
  34795. if (lod === void 0) { lod = 0; }
  34796. };
  34797. /** @hidden */
  34798. NullEngine.prototype._uploadArrayBufferViewToTexture = function (texture, imageData, faceIndex, lod) {
  34799. if (faceIndex === void 0) { faceIndex = 0; }
  34800. if (lod === void 0) { lod = 0; }
  34801. };
  34802. /** @hidden */
  34803. NullEngine.prototype._uploadImageToTexture = function (texture, image, faceIndex, lod) {
  34804. if (faceIndex === void 0) { faceIndex = 0; }
  34805. if (lod === void 0) { lod = 0; }
  34806. };
  34807. return NullEngine;
  34808. }(_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"]));
  34809. /***/ }),
  34810. /***/ "./Events/clipboardEvents.ts":
  34811. /*!***********************************!*\
  34812. !*** ./Events/clipboardEvents.ts ***!
  34813. \***********************************/
  34814. /*! exports provided: ClipboardEventTypes, ClipboardInfo */
  34815. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34816. "use strict";
  34817. __webpack_require__.r(__webpack_exports__);
  34818. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return ClipboardEventTypes; });
  34819. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return ClipboardInfo; });
  34820. /**
  34821. * Gather the list of clipboard event types as constants.
  34822. */
  34823. var ClipboardEventTypes = /** @class */ (function () {
  34824. function ClipboardEventTypes() {
  34825. }
  34826. /**
  34827. * The clipboard event is fired when a copy command is active (pressed).
  34828. */
  34829. ClipboardEventTypes.COPY = 0x01; //
  34830. /**
  34831. * The clipboard event is fired when a cut command is active (pressed).
  34832. */
  34833. ClipboardEventTypes.CUT = 0x02;
  34834. /**
  34835. * The clipboard event is fired when a paste command is active (pressed).
  34836. */
  34837. ClipboardEventTypes.PASTE = 0x03;
  34838. return ClipboardEventTypes;
  34839. }());
  34840. /**
  34841. * This class is used to store clipboard related info for the onClipboardObservable event.
  34842. */
  34843. var ClipboardInfo = /** @class */ (function () {
  34844. /**
  34845. *Creates an instance of ClipboardInfo.
  34846. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  34847. * @param event Defines the related dom event
  34848. */
  34849. function ClipboardInfo(
  34850. /**
  34851. * Defines the type of event (BABYLON.ClipboardEventTypes)
  34852. */
  34853. type,
  34854. /**
  34855. * Defines the related dom event
  34856. */
  34857. event) {
  34858. this.type = type;
  34859. this.event = event;
  34860. }
  34861. /**
  34862. * Get the clipboard event's type from the keycode.
  34863. * @param keyCode Defines the keyCode for the current keyboard event.
  34864. * @return {number}
  34865. */
  34866. ClipboardInfo.GetTypeFromCharacter = function (keyCode) {
  34867. var charCode = keyCode;
  34868. //TODO: add codes for extended ASCII
  34869. switch (charCode) {
  34870. case 67: return ClipboardEventTypes.COPY;
  34871. case 86: return ClipboardEventTypes.PASTE;
  34872. case 88: return ClipboardEventTypes.CUT;
  34873. default: return -1;
  34874. }
  34875. };
  34876. return ClipboardInfo;
  34877. }());
  34878. /***/ }),
  34879. /***/ "./Events/index.ts":
  34880. /*!*************************!*\
  34881. !*** ./Events/index.ts ***!
  34882. \*************************/
  34883. /*! exports provided: KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo */
  34884. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34885. "use strict";
  34886. __webpack_require__.r(__webpack_exports__);
  34887. /* harmony import */ var _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./keyboardEvents */ "./Events/keyboardEvents.ts");
  34888. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardEventTypes"]; });
  34889. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfo"]; });
  34890. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfoPre"]; });
  34891. /* harmony import */ var _pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pointerEvents */ "./Events/pointerEvents.ts");
  34892. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"]; });
  34893. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfoBase"]; });
  34894. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfoPre"]; });
  34895. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfo"]; });
  34896. /* harmony import */ var _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./clipboardEvents */ "./Events/clipboardEvents.ts");
  34897. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__["ClipboardEventTypes"]; });
  34898. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__["ClipboardInfo"]; });
  34899. /***/ }),
  34900. /***/ "./Events/keyboardEvents.ts":
  34901. /*!**********************************!*\
  34902. !*** ./Events/keyboardEvents.ts ***!
  34903. \**********************************/
  34904. /*! exports provided: KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre */
  34905. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34906. "use strict";
  34907. __webpack_require__.r(__webpack_exports__);
  34908. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return KeyboardEventTypes; });
  34909. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return KeyboardInfo; });
  34910. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return KeyboardInfoPre; });
  34911. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34912. /**
  34913. * Gather the list of keyboard event types as constants.
  34914. */
  34915. var KeyboardEventTypes = /** @class */ (function () {
  34916. function KeyboardEventTypes() {
  34917. }
  34918. /**
  34919. * The keydown event is fired when a key becomes active (pressed).
  34920. */
  34921. KeyboardEventTypes.KEYDOWN = 0x01;
  34922. /**
  34923. * The keyup event is fired when a key has been released.
  34924. */
  34925. KeyboardEventTypes.KEYUP = 0x02;
  34926. return KeyboardEventTypes;
  34927. }());
  34928. /**
  34929. * This class is used to store keyboard related info for the onKeyboardObservable event.
  34930. */
  34931. var KeyboardInfo = /** @class */ (function () {
  34932. /**
  34933. * Instantiates a new keyboard info.
  34934. * This class is used to store keyboard related info for the onKeyboardObservable event.
  34935. * @param type Defines the type of event (KeyboardEventTypes)
  34936. * @param event Defines the related dom event
  34937. */
  34938. function KeyboardInfo(
  34939. /**
  34940. * Defines the type of event (KeyboardEventTypes)
  34941. */
  34942. type,
  34943. /**
  34944. * Defines the related dom event
  34945. */
  34946. event) {
  34947. this.type = type;
  34948. this.event = event;
  34949. }
  34950. return KeyboardInfo;
  34951. }());
  34952. /**
  34953. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  34954. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  34955. */
  34956. var KeyboardInfoPre = /** @class */ (function (_super) {
  34957. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](KeyboardInfoPre, _super);
  34958. /**
  34959. * Instantiates a new keyboard pre info.
  34960. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  34961. * @param type Defines the type of event (KeyboardEventTypes)
  34962. * @param event Defines the related dom event
  34963. */
  34964. function KeyboardInfoPre(
  34965. /**
  34966. * Defines the type of event (KeyboardEventTypes)
  34967. */
  34968. type,
  34969. /**
  34970. * Defines the related dom event
  34971. */
  34972. event) {
  34973. var _this = _super.call(this, type, event) || this;
  34974. _this.type = type;
  34975. _this.event = event;
  34976. _this.skipOnPointerObservable = false;
  34977. return _this;
  34978. }
  34979. return KeyboardInfoPre;
  34980. }(KeyboardInfo));
  34981. /***/ }),
  34982. /***/ "./Events/pointerEvents.ts":
  34983. /*!*********************************!*\
  34984. !*** ./Events/pointerEvents.ts ***!
  34985. \*********************************/
  34986. /*! exports provided: PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo */
  34987. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34988. "use strict";
  34989. __webpack_require__.r(__webpack_exports__);
  34990. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return PointerEventTypes; });
  34991. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return PointerInfoBase; });
  34992. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return PointerInfoPre; });
  34993. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return PointerInfo; });
  34994. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34995. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  34996. /**
  34997. * Gather the list of pointer event types as constants.
  34998. */
  34999. var PointerEventTypes = /** @class */ (function () {
  35000. function PointerEventTypes() {
  35001. }
  35002. /**
  35003. * 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.
  35004. */
  35005. PointerEventTypes.POINTERDOWN = 0x01;
  35006. /**
  35007. * The pointerup event is fired when a pointer is no longer active.
  35008. */
  35009. PointerEventTypes.POINTERUP = 0x02;
  35010. /**
  35011. * The pointermove event is fired when a pointer changes coordinates.
  35012. */
  35013. PointerEventTypes.POINTERMOVE = 0x04;
  35014. /**
  35015. * The pointerwheel event is fired when a mouse wheel has been rotated.
  35016. */
  35017. PointerEventTypes.POINTERWHEEL = 0x08;
  35018. /**
  35019. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  35020. */
  35021. PointerEventTypes.POINTERPICK = 0x10;
  35022. /**
  35023. * The pointertap event is fired when a the object has been touched and released without drag.
  35024. */
  35025. PointerEventTypes.POINTERTAP = 0x20;
  35026. /**
  35027. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  35028. */
  35029. PointerEventTypes.POINTERDOUBLETAP = 0x40;
  35030. return PointerEventTypes;
  35031. }());
  35032. /**
  35033. * Base class of pointer info types.
  35034. */
  35035. var PointerInfoBase = /** @class */ (function () {
  35036. /**
  35037. * Instantiates the base class of pointers info.
  35038. * @param type Defines the type of event (PointerEventTypes)
  35039. * @param event Defines the related dom event
  35040. */
  35041. function PointerInfoBase(
  35042. /**
  35043. * Defines the type of event (PointerEventTypes)
  35044. */
  35045. type,
  35046. /**
  35047. * Defines the related dom event
  35048. */
  35049. event) {
  35050. this.type = type;
  35051. this.event = event;
  35052. }
  35053. return PointerInfoBase;
  35054. }());
  35055. /**
  35056. * This class is used to store pointer related info for the onPrePointerObservable event.
  35057. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  35058. */
  35059. var PointerInfoPre = /** @class */ (function (_super) {
  35060. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointerInfoPre, _super);
  35061. /**
  35062. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  35063. * @param type Defines the type of event (PointerEventTypes)
  35064. * @param event Defines the related dom event
  35065. * @param localX Defines the local x coordinates of the pointer when the event occured
  35066. * @param localY Defines the local y coordinates of the pointer when the event occured
  35067. */
  35068. function PointerInfoPre(type, event, localX, localY) {
  35069. var _this = _super.call(this, type, event) || this;
  35070. /**
  35071. * Ray from a pointer if availible (eg. 6dof controller)
  35072. */
  35073. _this.ray = null;
  35074. _this.skipOnPointerObservable = false;
  35075. _this.localPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](localX, localY);
  35076. return _this;
  35077. }
  35078. return PointerInfoPre;
  35079. }(PointerInfoBase));
  35080. /**
  35081. * This type contains all the data related to a pointer event in Babylon.js.
  35082. * 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.
  35083. */
  35084. var PointerInfo = /** @class */ (function (_super) {
  35085. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointerInfo, _super);
  35086. /**
  35087. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  35088. * @param type Defines the type of event (PointerEventTypes)
  35089. * @param event Defines the related dom event
  35090. * @param pickInfo Defines the picking info associated to the info (if any)\
  35091. */
  35092. function PointerInfo(type, event,
  35093. /**
  35094. * Defines the picking info associated to the info (if any)\
  35095. */
  35096. pickInfo) {
  35097. var _this = _super.call(this, type, event) || this;
  35098. _this.pickInfo = pickInfo;
  35099. return _this;
  35100. }
  35101. return PointerInfo;
  35102. }(PointerInfoBase));
  35103. /***/ }),
  35104. /***/ "./Gamepads/Controllers/daydreamController.ts":
  35105. /*!****************************************************!*\
  35106. !*** ./Gamepads/Controllers/daydreamController.ts ***!
  35107. \****************************************************/
  35108. /*! exports provided: DaydreamController */
  35109. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35110. "use strict";
  35111. __webpack_require__.r(__webpack_exports__);
  35112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return DaydreamController; });
  35113. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35114. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  35115. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35116. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35117. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35118. /**
  35119. * Google Daydream controller
  35120. */
  35121. var DaydreamController = /** @class */ (function (_super) {
  35122. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DaydreamController, _super);
  35123. /**
  35124. * Creates a new DaydreamController from a gamepad
  35125. * @param vrGamepad the gamepad that the controller should be created from
  35126. */
  35127. function DaydreamController(vrGamepad) {
  35128. var _this = _super.call(this, vrGamepad) || this;
  35129. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"].DAYDREAM;
  35130. return _this;
  35131. }
  35132. /**
  35133. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35134. * @param scene scene in which to add meshes
  35135. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35136. */
  35137. DaydreamController.prototype.initControllerMesh = function (scene, meshLoaded) {
  35138. var _this = this;
  35139. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"].ImportMesh("", DaydreamController.MODEL_BASE_URL, DaydreamController.MODEL_FILENAME, scene, function (newMeshes) {
  35140. _this._defaultModel = newMeshes[1];
  35141. _this.attachToMesh(_this._defaultModel);
  35142. if (meshLoaded) {
  35143. meshLoaded(_this._defaultModel);
  35144. }
  35145. });
  35146. };
  35147. /**
  35148. * Called once for each button that changed state since the last frame
  35149. * @param buttonIdx Which button index changed
  35150. * @param state New state of the button
  35151. * @param changes Which properties on the state changed since last frame
  35152. */
  35153. DaydreamController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35154. // Daydream controller only has 1 GamepadButton (on the trackpad).
  35155. if (buttonIdx === 0) {
  35156. var observable = this.onTriggerStateChangedObservable;
  35157. if (observable) {
  35158. observable.notifyObservers(state);
  35159. }
  35160. }
  35161. else {
  35162. // If the app or home buttons are ever made available
  35163. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Unrecognized Daydream button index: " + buttonIdx);
  35164. }
  35165. };
  35166. /**
  35167. * Base Url for the controller model.
  35168. */
  35169. DaydreamController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  35170. /**
  35171. * File name for the controller model.
  35172. */
  35173. DaydreamController.MODEL_FILENAME = 'generic.babylon';
  35174. /**
  35175. * Gamepad Id prefix used to identify Daydream Controller.
  35176. */
  35177. DaydreamController.GAMEPAD_ID_PREFIX = 'Daydream'; // id is 'Daydream Controller'
  35178. return DaydreamController;
  35179. }(_webVRController__WEBPACK_IMPORTED_MODULE_3__["WebVRController"]));
  35180. _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  35181. canCreate: function (gamepadInfo) {
  35182. return gamepadInfo.id.indexOf(DaydreamController.GAMEPAD_ID_PREFIX) === 0;
  35183. },
  35184. create: function (gamepadInfo) {
  35185. return new DaydreamController(gamepadInfo);
  35186. }
  35187. });
  35188. /***/ }),
  35189. /***/ "./Gamepads/Controllers/gearVRController.ts":
  35190. /*!**************************************************!*\
  35191. !*** ./Gamepads/Controllers/gearVRController.ts ***!
  35192. \**************************************************/
  35193. /*! exports provided: GearVRController */
  35194. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35195. "use strict";
  35196. __webpack_require__.r(__webpack_exports__);
  35197. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return GearVRController; });
  35198. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35199. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  35200. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  35201. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35202. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35203. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35204. /**
  35205. * Gear VR Controller
  35206. */
  35207. var GearVRController = /** @class */ (function (_super) {
  35208. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GearVRController, _super);
  35209. /**
  35210. * Creates a new GearVRController from a gamepad
  35211. * @param vrGamepad the gamepad that the controller should be created from
  35212. */
  35213. function GearVRController(vrGamepad) {
  35214. var _this = _super.call(this, vrGamepad) || this;
  35215. _this._buttonIndexToObservableNameMap = [
  35216. 'onTrackpadChangedObservable',
  35217. 'onTriggerStateChangedObservable' // Trigger
  35218. ];
  35219. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__["PoseEnabledControllerType"].GEAR_VR;
  35220. // Initial starting position defaults to where hand would be (incase of only 3dof controller)
  35221. _this._calculatedPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](_this.hand == "left" ? -0.15 : 0.15, -0.5, 0.25);
  35222. _this._disableTrackPosition(_this._calculatedPosition);
  35223. return _this;
  35224. }
  35225. /**
  35226. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35227. * @param scene scene in which to add meshes
  35228. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35229. */
  35230. GearVRController.prototype.initControllerMesh = function (scene, meshLoaded) {
  35231. var _this = this;
  35232. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_3__["SceneLoader"].ImportMesh("", GearVRController.MODEL_BASE_URL, GearVRController.MODEL_FILENAME, scene, function (newMeshes) {
  35233. // Offset the controller so it will rotate around the users wrist
  35234. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("", scene);
  35235. newMeshes[1].parent = mesh;
  35236. newMeshes[1].position.z = -0.15;
  35237. _this._defaultModel = mesh;
  35238. _this.attachToMesh(_this._defaultModel);
  35239. if (meshLoaded) {
  35240. meshLoaded(_this._defaultModel);
  35241. }
  35242. });
  35243. };
  35244. /**
  35245. * Called once for each button that changed state since the last frame
  35246. * @param buttonIdx Which button index changed
  35247. * @param state New state of the button
  35248. * @param changes Which properties on the state changed since last frame
  35249. */
  35250. GearVRController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35251. if (buttonIdx < this._buttonIndexToObservableNameMap.length) {
  35252. var observableName = this._buttonIndexToObservableNameMap[buttonIdx];
  35253. // Only emit events for buttons that we know how to map from index to observable
  35254. var observable = this[observableName];
  35255. if (observable) {
  35256. observable.notifyObservers(state);
  35257. }
  35258. }
  35259. };
  35260. /**
  35261. * Base Url for the controller model.
  35262. */
  35263. GearVRController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  35264. /**
  35265. * File name for the controller model.
  35266. */
  35267. GearVRController.MODEL_FILENAME = 'generic.babylon';
  35268. /**
  35269. * Gamepad Id prefix used to identify this controller.
  35270. */
  35271. GearVRController.GAMEPAD_ID_PREFIX = 'Gear VR'; // id is 'Gear VR Controller'
  35272. return GearVRController;
  35273. }(_webVRController__WEBPACK_IMPORTED_MODULE_4__["WebVRController"]));
  35274. _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  35275. canCreate: function (gamepadInfo) {
  35276. return gamepadInfo.id.indexOf(GearVRController.GAMEPAD_ID_PREFIX) === 0 ||
  35277. gamepadInfo.id.indexOf('Oculus Go') !== -1;
  35278. },
  35279. create: function (gamepadInfo) {
  35280. return new GearVRController(gamepadInfo);
  35281. }
  35282. });
  35283. /***/ }),
  35284. /***/ "./Gamepads/Controllers/genericController.ts":
  35285. /*!***************************************************!*\
  35286. !*** ./Gamepads/Controllers/genericController.ts ***!
  35287. \***************************************************/
  35288. /*! exports provided: GenericController */
  35289. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35290. "use strict";
  35291. __webpack_require__.r(__webpack_exports__);
  35292. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return GenericController; });
  35293. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35294. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35295. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35296. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35297. /**
  35298. * Generic Controller
  35299. */
  35300. var GenericController = /** @class */ (function (_super) {
  35301. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GenericController, _super);
  35302. /**
  35303. * Creates a new GenericController from a gamepad
  35304. * @param vrGamepad the gamepad that the controller should be created from
  35305. */
  35306. function GenericController(vrGamepad) {
  35307. return _super.call(this, vrGamepad) || this;
  35308. }
  35309. /**
  35310. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35311. * @param scene scene in which to add meshes
  35312. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35313. */
  35314. GenericController.prototype.initControllerMesh = function (scene, meshLoaded) {
  35315. var _this = this;
  35316. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh("", GenericController.MODEL_BASE_URL, GenericController.MODEL_FILENAME, scene, function (newMeshes) {
  35317. _this._defaultModel = newMeshes[1];
  35318. _this.attachToMesh(_this._defaultModel);
  35319. if (meshLoaded) {
  35320. meshLoaded(_this._defaultModel);
  35321. }
  35322. });
  35323. };
  35324. /**
  35325. * Called once for each button that changed state since the last frame
  35326. * @param buttonIdx Which button index changed
  35327. * @param state New state of the button
  35328. * @param changes Which properties on the state changed since last frame
  35329. */
  35330. GenericController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35331. console.log("Button id: " + buttonIdx + "state: ");
  35332. console.dir(state);
  35333. };
  35334. /**
  35335. * Base Url for the controller model.
  35336. */
  35337. GenericController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  35338. /**
  35339. * File name for the controller model.
  35340. */
  35341. GenericController.MODEL_FILENAME = 'generic.babylon';
  35342. return GenericController;
  35343. }(_webVRController__WEBPACK_IMPORTED_MODULE_2__["WebVRController"]));
  35344. _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"]._DefaultControllerFactory = function (gamepadInfo) { return new GenericController(gamepadInfo); };
  35345. /***/ }),
  35346. /***/ "./Gamepads/Controllers/index.ts":
  35347. /*!***************************************!*\
  35348. !*** ./Gamepads/Controllers/index.ts ***!
  35349. \***************************************/
  35350. /*! exports provided: DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController */
  35351. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35352. "use strict";
  35353. __webpack_require__.r(__webpack_exports__);
  35354. /* harmony import */ var _daydreamController__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./daydreamController */ "./Gamepads/Controllers/daydreamController.ts");
  35355. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _daydreamController__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  35356. /* harmony import */ var _gearVRController__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gearVRController */ "./Gamepads/Controllers/gearVRController.ts");
  35357. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _gearVRController__WEBPACK_IMPORTED_MODULE_1__["GearVRController"]; });
  35358. /* harmony import */ var _genericController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./genericController */ "./Gamepads/Controllers/genericController.ts");
  35359. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _genericController__WEBPACK_IMPORTED_MODULE_2__["GenericController"]; });
  35360. /* harmony import */ var _oculusTouchController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./oculusTouchController */ "./Gamepads/Controllers/oculusTouchController.ts");
  35361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _oculusTouchController__WEBPACK_IMPORTED_MODULE_3__["OculusTouchController"]; });
  35362. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"]; });
  35364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]; });
  35365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledController"]; });
  35366. /* harmony import */ var _viveController__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./viveController */ "./Gamepads/Controllers/viveController.ts");
  35367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _viveController__WEBPACK_IMPORTED_MODULE_5__["ViveController"]; });
  35368. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _webVRController__WEBPACK_IMPORTED_MODULE_6__["WebVRController"]; });
  35370. /* harmony import */ var _windowsMotionController__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./windowsMotionController */ "./Gamepads/Controllers/windowsMotionController.ts");
  35371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _windowsMotionController__WEBPACK_IMPORTED_MODULE_7__["WindowsMotionController"]; });
  35372. /***/ }),
  35373. /***/ "./Gamepads/Controllers/oculusTouchController.ts":
  35374. /*!*******************************************************!*\
  35375. !*** ./Gamepads/Controllers/oculusTouchController.ts ***!
  35376. \*******************************************************/
  35377. /*! exports provided: OculusTouchController */
  35378. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35379. "use strict";
  35380. __webpack_require__.r(__webpack_exports__);
  35381. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return OculusTouchController; });
  35382. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35383. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  35384. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35385. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35386. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35387. /**
  35388. * Oculus Touch Controller
  35389. */
  35390. var OculusTouchController = /** @class */ (function (_super) {
  35391. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](OculusTouchController, _super);
  35392. /**
  35393. * Creates a new OculusTouchController from a gamepad
  35394. * @param vrGamepad the gamepad that the controller should be created from
  35395. */
  35396. function OculusTouchController(vrGamepad) {
  35397. var _this = _super.call(this, vrGamepad) || this;
  35398. /**
  35399. * Fired when the secondary trigger on this controller is modified
  35400. */
  35401. _this.onSecondaryTriggerStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35402. /**
  35403. * Fired when the thumb rest on this controller is modified
  35404. */
  35405. _this.onThumbRestChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35406. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"].OCULUS;
  35407. return _this;
  35408. }
  35409. /**
  35410. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35411. * @param scene scene in which to add meshes
  35412. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35413. */
  35414. OculusTouchController.prototype.initControllerMesh = function (scene, meshLoaded) {
  35415. var _this = this;
  35416. var meshName;
  35417. // Hand
  35418. if (this.hand === 'left') {
  35419. meshName = OculusTouchController.MODEL_LEFT_FILENAME;
  35420. }
  35421. else { // Right is the default if no hand is specified
  35422. meshName = OculusTouchController.MODEL_RIGHT_FILENAME;
  35423. }
  35424. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"].ImportMesh("", OculusTouchController.MODEL_BASE_URL, meshName, scene, function (newMeshes) {
  35425. /*
  35426. Parent Mesh name: oculus_touch_left
  35427. - body
  35428. - trigger
  35429. - thumbstick
  35430. - grip
  35431. - button_y
  35432. - button_x
  35433. - button_enter
  35434. */
  35435. _this._defaultModel = newMeshes[1];
  35436. _this.attachToMesh(_this._defaultModel);
  35437. if (meshLoaded) {
  35438. meshLoaded(_this._defaultModel);
  35439. }
  35440. });
  35441. };
  35442. Object.defineProperty(OculusTouchController.prototype, "onAButtonStateChangedObservable", {
  35443. /**
  35444. * Fired when the A button on this controller is modified
  35445. */
  35446. get: function () {
  35447. if (this.hand === 'right') {
  35448. return this.onMainButtonStateChangedObservable;
  35449. }
  35450. else {
  35451. throw new Error('No A button on left hand');
  35452. }
  35453. },
  35454. enumerable: true,
  35455. configurable: true
  35456. });
  35457. Object.defineProperty(OculusTouchController.prototype, "onBButtonStateChangedObservable", {
  35458. /**
  35459. * Fired when the B button on this controller is modified
  35460. */
  35461. get: function () {
  35462. if (this.hand === 'right') {
  35463. return this.onSecondaryButtonStateChangedObservable;
  35464. }
  35465. else {
  35466. throw new Error('No B button on left hand');
  35467. }
  35468. },
  35469. enumerable: true,
  35470. configurable: true
  35471. });
  35472. Object.defineProperty(OculusTouchController.prototype, "onXButtonStateChangedObservable", {
  35473. /**
  35474. * Fired when the X button on this controller is modified
  35475. */
  35476. get: function () {
  35477. if (this.hand === 'left') {
  35478. return this.onMainButtonStateChangedObservable;
  35479. }
  35480. else {
  35481. throw new Error('No X button on right hand');
  35482. }
  35483. },
  35484. enumerable: true,
  35485. configurable: true
  35486. });
  35487. Object.defineProperty(OculusTouchController.prototype, "onYButtonStateChangedObservable", {
  35488. /**
  35489. * Fired when the Y button on this controller is modified
  35490. */
  35491. get: function () {
  35492. if (this.hand === 'left') {
  35493. return this.onSecondaryButtonStateChangedObservable;
  35494. }
  35495. else {
  35496. throw new Error('No Y button on right hand');
  35497. }
  35498. },
  35499. enumerable: true,
  35500. configurable: true
  35501. });
  35502. /**
  35503. * Called once for each button that changed state since the last frame
  35504. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  35505. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  35506. * 2) secondary trigger (same)
  35507. * 3) A (right) X (left), touch, pressed = value
  35508. * 4) B / Y
  35509. * 5) thumb rest
  35510. * @param buttonIdx Which button index changed
  35511. * @param state New state of the button
  35512. * @param changes Which properties on the state changed since last frame
  35513. */
  35514. OculusTouchController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35515. var notifyObject = state; //{ state: state, changes: changes };
  35516. var triggerDirection = this.hand === 'right' ? -1 : 1;
  35517. switch (buttonIdx) {
  35518. case 0:
  35519. this.onPadStateChangedObservable.notifyObservers(notifyObject);
  35520. return;
  35521. case 1: // index trigger
  35522. if (this._defaultModel) {
  35523. (this._defaultModel.getChildren()[3]).rotation.x = -notifyObject.value * 0.20;
  35524. (this._defaultModel.getChildren()[3]).position.y = -notifyObject.value * 0.005;
  35525. (this._defaultModel.getChildren()[3]).position.z = -notifyObject.value * 0.005;
  35526. }
  35527. this.onTriggerStateChangedObservable.notifyObservers(notifyObject);
  35528. return;
  35529. case 2: // secondary trigger
  35530. if (this._defaultModel) {
  35531. (this._defaultModel.getChildren()[4]).position.x = triggerDirection * notifyObject.value * 0.0035;
  35532. }
  35533. this.onSecondaryTriggerStateChangedObservable.notifyObservers(notifyObject);
  35534. return;
  35535. case 3:
  35536. if (this._defaultModel) {
  35537. if (notifyObject.pressed) {
  35538. (this._defaultModel.getChildren()[1]).position.y = -0.001;
  35539. }
  35540. else {
  35541. (this._defaultModel.getChildren()[1]).position.y = 0;
  35542. }
  35543. }
  35544. this.onMainButtonStateChangedObservable.notifyObservers(notifyObject);
  35545. return;
  35546. case 4:
  35547. if (this._defaultModel) {
  35548. if (notifyObject.pressed) {
  35549. (this._defaultModel.getChildren()[2]).position.y = -0.001;
  35550. }
  35551. else {
  35552. (this._defaultModel.getChildren()[2]).position.y = 0;
  35553. }
  35554. }
  35555. this.onSecondaryButtonStateChangedObservable.notifyObservers(notifyObject);
  35556. return;
  35557. case 5:
  35558. this.onThumbRestChangedObservable.notifyObservers(notifyObject);
  35559. return;
  35560. }
  35561. };
  35562. /**
  35563. * Base Url for the controller model.
  35564. */
  35565. OculusTouchController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/oculus/';
  35566. /**
  35567. * File name for the left controller model.
  35568. */
  35569. OculusTouchController.MODEL_LEFT_FILENAME = 'left.babylon';
  35570. /**
  35571. * File name for the right controller model.
  35572. */
  35573. OculusTouchController.MODEL_RIGHT_FILENAME = 'right.babylon';
  35574. return OculusTouchController;
  35575. }(_webVRController__WEBPACK_IMPORTED_MODULE_3__["WebVRController"]));
  35576. _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  35577. canCreate: function (gamepadInfo) {
  35578. return gamepadInfo.id.indexOf('Oculus Touch') !== -1;
  35579. },
  35580. create: function (gamepadInfo) {
  35581. return new OculusTouchController(gamepadInfo);
  35582. }
  35583. });
  35584. /***/ }),
  35585. /***/ "./Gamepads/Controllers/poseEnabledController.ts":
  35586. /*!*******************************************************!*\
  35587. !*** ./Gamepads/Controllers/poseEnabledController.ts ***!
  35588. \*******************************************************/
  35589. /*! exports provided: PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController */
  35590. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35591. "use strict";
  35592. __webpack_require__.r(__webpack_exports__);
  35593. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return PoseEnabledControllerType; });
  35594. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return PoseEnabledControllerHelper; });
  35595. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return PoseEnabledController; });
  35596. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35597. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  35598. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  35599. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  35600. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  35601. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  35602. /**
  35603. * Defines the types of pose enabled controllers that are supported
  35604. */
  35605. var PoseEnabledControllerType;
  35606. (function (PoseEnabledControllerType) {
  35607. /**
  35608. * HTC Vive
  35609. */
  35610. PoseEnabledControllerType[PoseEnabledControllerType["VIVE"] = 0] = "VIVE";
  35611. /**
  35612. * Oculus Rift
  35613. */
  35614. PoseEnabledControllerType[PoseEnabledControllerType["OCULUS"] = 1] = "OCULUS";
  35615. /**
  35616. * Windows mixed reality
  35617. */
  35618. PoseEnabledControllerType[PoseEnabledControllerType["WINDOWS"] = 2] = "WINDOWS";
  35619. /**
  35620. * Samsung gear VR
  35621. */
  35622. PoseEnabledControllerType[PoseEnabledControllerType["GEAR_VR"] = 3] = "GEAR_VR";
  35623. /**
  35624. * Google Daydream
  35625. */
  35626. PoseEnabledControllerType[PoseEnabledControllerType["DAYDREAM"] = 4] = "DAYDREAM";
  35627. /**
  35628. * Generic
  35629. */
  35630. PoseEnabledControllerType[PoseEnabledControllerType["GENERIC"] = 5] = "GENERIC";
  35631. })(PoseEnabledControllerType || (PoseEnabledControllerType = {}));
  35632. /**
  35633. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  35634. */
  35635. var PoseEnabledControllerHelper = /** @class */ (function () {
  35636. function PoseEnabledControllerHelper() {
  35637. }
  35638. /**
  35639. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  35640. * @param vrGamepad the gamepad to initialized
  35641. * @returns a vr controller of the type the gamepad identified as
  35642. */
  35643. PoseEnabledControllerHelper.InitiateController = function (vrGamepad) {
  35644. for (var _i = 0, _a = this._ControllerFactories; _i < _a.length; _i++) {
  35645. var factory = _a[_i];
  35646. if (factory.canCreate(vrGamepad)) {
  35647. return factory.create(vrGamepad);
  35648. }
  35649. }
  35650. if (this._DefaultControllerFactory) {
  35651. return this._DefaultControllerFactory(vrGamepad);
  35652. }
  35653. throw "The type of gamepad you are trying to load needs to be imported first or is not supported.";
  35654. };
  35655. /** @hidden */
  35656. PoseEnabledControllerHelper._ControllerFactories = [];
  35657. /** @hidden */
  35658. PoseEnabledControllerHelper._DefaultControllerFactory = null;
  35659. return PoseEnabledControllerHelper;
  35660. }());
  35661. /**
  35662. * Defines the PoseEnabledController object that contains state of a vr capable controller
  35663. */
  35664. var PoseEnabledController = /** @class */ (function (_super) {
  35665. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PoseEnabledController, _super);
  35666. /**
  35667. * Creates a new PoseEnabledController from a gamepad
  35668. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  35669. */
  35670. function PoseEnabledController(browserGamepad) {
  35671. var _this = _super.call(this, browserGamepad.id, browserGamepad.index, browserGamepad) || this;
  35672. // Represents device position and rotation in room space. Should only be used to help calculate babylon space values
  35673. _this._deviceRoomPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  35674. _this._deviceRoomRotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35675. /**
  35676. * The device position in babylon space
  35677. */
  35678. _this.devicePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  35679. /**
  35680. * The device rotation in babylon space
  35681. */
  35682. _this.deviceRotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35683. /**
  35684. * The scale factor of the device in babylon space
  35685. */
  35686. _this.deviceScaleFactor = 1;
  35687. // Used to convert 6dof controllers to 3dof
  35688. _this._trackPosition = true;
  35689. _this._maxRotationDistFromHeadset = Math.PI / 5;
  35690. _this._draggedRoomRotation = 0;
  35691. _this._leftHandSystemQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35692. /**
  35693. * Internal, matrix used to convert room space to babylon space
  35694. * @hidden
  35695. */
  35696. _this._deviceToWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  35697. /**
  35698. * Node to be used when casting a ray from the controller
  35699. * @hidden
  35700. */
  35701. _this._pointingPoseNode = null;
  35702. _this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  35703. /**
  35704. * @hidden
  35705. */
  35706. _this._meshAttachedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35707. _this.type = _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED;
  35708. _this.controllerType = PoseEnabledControllerType.GENERIC;
  35709. _this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  35710. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35711. _this._calculatedPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  35712. _this._calculatedRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35713. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(Math.PI, 0, 0, _this._leftHandSystemQuaternion);
  35714. return _this;
  35715. }
  35716. /**
  35717. * @hidden
  35718. */
  35719. PoseEnabledController.prototype._disableTrackPosition = function (fixedPosition) {
  35720. if (this._trackPosition) {
  35721. this._calculatedPosition.copyFrom(fixedPosition);
  35722. this._trackPosition = false;
  35723. }
  35724. };
  35725. /**
  35726. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  35727. */
  35728. PoseEnabledController.prototype.update = function () {
  35729. _super.prototype.update.call(this);
  35730. this._updatePoseAndMesh();
  35731. };
  35732. /**
  35733. * Updates only the pose device and mesh without doing any button event checking
  35734. */
  35735. PoseEnabledController.prototype._updatePoseAndMesh = function () {
  35736. var pose = this.browserGamepad.pose;
  35737. this.updateFromDevice(pose);
  35738. 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) {
  35739. var camera = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene.activeCamera;
  35740. camera._computeDevicePosition();
  35741. this._deviceToWorld.setTranslation(camera.devicePosition);
  35742. if (camera.deviceRotationQuaternion) {
  35743. var camera = camera;
  35744. camera._deviceRoomRotationQuaternion.toEulerAnglesToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Vector3[0]);
  35745. // Find the radian distance away that the headset is from the controllers rotation
  35746. 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));
  35747. if (Math.abs(distanceAway) > this._maxRotationDistFromHeadset) {
  35748. // Only rotate enouph to be within the _maxRotationDistFromHeadset
  35749. var rotationAmount = distanceAway - (distanceAway < 0 ? -this._maxRotationDistFromHeadset : this._maxRotationDistFromHeadset);
  35750. this._draggedRoomRotation += rotationAmount;
  35751. // Rotate controller around headset
  35752. var sin = Math.sin(-rotationAmount);
  35753. var cos = Math.cos(-rotationAmount);
  35754. this._calculatedPosition.x = this._calculatedPosition.x * cos - this._calculatedPosition.z * sin;
  35755. this._calculatedPosition.z = this._calculatedPosition.x * sin + this._calculatedPosition.z * cos;
  35756. }
  35757. }
  35758. }
  35759. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this._calculatedPosition, this._deviceToWorld, this.devicePosition);
  35760. this._deviceToWorld.getRotationMatrixToRef(this._workingMatrix);
  35761. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion);
  35762. this.deviceRotationQuaternion.multiplyInPlace(this._calculatedRotation);
  35763. if (this._mesh) {
  35764. this._mesh.position.copyFrom(this.devicePosition);
  35765. if (this._mesh.rotationQuaternion) {
  35766. this._mesh.rotationQuaternion.copyFrom(this.deviceRotationQuaternion);
  35767. }
  35768. }
  35769. };
  35770. /**
  35771. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  35772. * @param poseData raw pose fromthe device
  35773. */
  35774. PoseEnabledController.prototype.updateFromDevice = function (poseData) {
  35775. if (poseData) {
  35776. this.rawPose = poseData;
  35777. if (poseData.position) {
  35778. this._deviceRoomPosition.copyFromFloats(poseData.position[0], poseData.position[1], -poseData.position[2]);
  35779. if (this._mesh && this._mesh.getScene().useRightHandedSystem) {
  35780. this._deviceRoomPosition.z *= -1;
  35781. }
  35782. if (this._trackPosition) {
  35783. this._deviceRoomPosition.scaleToRef(this.deviceScaleFactor, this._calculatedPosition);
  35784. }
  35785. this._calculatedPosition.addInPlace(this.position);
  35786. }
  35787. var pose = this.rawPose;
  35788. if (poseData.orientation && pose.orientation) {
  35789. this._deviceRoomRotationQuaternion.copyFromFloats(pose.orientation[0], pose.orientation[1], -pose.orientation[2], -pose.orientation[3]);
  35790. if (this._mesh) {
  35791. if (this._mesh.getScene().useRightHandedSystem) {
  35792. this._deviceRoomRotationQuaternion.z *= -1;
  35793. this._deviceRoomRotationQuaternion.w *= -1;
  35794. }
  35795. else {
  35796. this._deviceRoomRotationQuaternion.multiplyToRef(this._leftHandSystemQuaternion, this._deviceRoomRotationQuaternion);
  35797. }
  35798. }
  35799. // if the camera is set, rotate to the camera's rotation
  35800. this._deviceRoomRotationQuaternion.multiplyToRef(this.rotationQuaternion, this._calculatedRotation);
  35801. }
  35802. }
  35803. };
  35804. /**
  35805. * Attaches a mesh to the controller
  35806. * @param mesh the mesh to be attached
  35807. */
  35808. PoseEnabledController.prototype.attachToMesh = function (mesh) {
  35809. if (this._mesh) {
  35810. this._mesh.parent = null;
  35811. }
  35812. this._mesh = mesh;
  35813. if (this._poseControlledCamera) {
  35814. this._mesh.parent = this._poseControlledCamera;
  35815. }
  35816. if (!this._mesh.rotationQuaternion) {
  35817. this._mesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35818. }
  35819. // 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
  35820. this._updatePoseAndMesh();
  35821. if (this._pointingPoseNode) {
  35822. var parents = [];
  35823. var obj = this._pointingPoseNode;
  35824. while (obj.parent) {
  35825. parents.push(obj.parent);
  35826. obj = obj.parent;
  35827. }
  35828. parents.reverse().forEach(function (p) { p.computeWorldMatrix(true); });
  35829. }
  35830. this._meshAttachedObservable.notifyObservers(mesh);
  35831. };
  35832. /**
  35833. * Attaches the controllers mesh to a camera
  35834. * @param camera the camera the mesh should be attached to
  35835. */
  35836. PoseEnabledController.prototype.attachToPoseControlledCamera = function (camera) {
  35837. this._poseControlledCamera = camera;
  35838. if (this._mesh) {
  35839. this._mesh.parent = this._poseControlledCamera;
  35840. }
  35841. };
  35842. /**
  35843. * Disposes of the controller
  35844. */
  35845. PoseEnabledController.prototype.dispose = function () {
  35846. if (this._mesh) {
  35847. this._mesh.dispose();
  35848. }
  35849. this._mesh = null;
  35850. _super.prototype.dispose.call(this);
  35851. };
  35852. Object.defineProperty(PoseEnabledController.prototype, "mesh", {
  35853. /**
  35854. * The mesh that is attached to the controller
  35855. */
  35856. get: function () {
  35857. return this._mesh;
  35858. },
  35859. enumerable: true,
  35860. configurable: true
  35861. });
  35862. /**
  35863. * Gets the ray of the controller in the direction the controller is pointing
  35864. * @param length the length the resulting ray should be
  35865. * @returns a ray in the direction the controller is pointing
  35866. */
  35867. PoseEnabledController.prototype.getForwardRay = function (length) {
  35868. if (length === void 0) { length = 100; }
  35869. if (!this.mesh) {
  35870. 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);
  35871. }
  35872. var m = this._pointingPoseNode ? this._pointingPoseNode.getWorldMatrix() : this.mesh.getWorldMatrix();
  35873. var origin = m.getTranslation();
  35874. var forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, -1);
  35875. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormal(forward, m);
  35876. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(forwardWorld);
  35877. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"](origin, direction, length);
  35878. };
  35879. /**
  35880. * Name of the child mesh that can be used to cast a ray from the controller
  35881. */
  35882. PoseEnabledController.POINTING_POSE = "POINTING_POSE";
  35883. return PoseEnabledController;
  35884. }(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"]));
  35885. /***/ }),
  35886. /***/ "./Gamepads/Controllers/viveController.ts":
  35887. /*!************************************************!*\
  35888. !*** ./Gamepads/Controllers/viveController.ts ***!
  35889. \************************************************/
  35890. /*! exports provided: ViveController */
  35891. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35892. "use strict";
  35893. __webpack_require__.r(__webpack_exports__);
  35894. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return ViveController; });
  35895. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35896. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35897. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35898. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35899. /**
  35900. * Vive Controller
  35901. */
  35902. var ViveController = /** @class */ (function (_super) {
  35903. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ViveController, _super);
  35904. /**
  35905. * Creates a new ViveController from a gamepad
  35906. * @param vrGamepad the gamepad that the controller should be created from
  35907. */
  35908. function ViveController(vrGamepad) {
  35909. var _this = _super.call(this, vrGamepad) || this;
  35910. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerType"].VIVE;
  35911. _this._invertLeftStickY = true;
  35912. return _this;
  35913. }
  35914. /**
  35915. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35916. * @param scene scene in which to add meshes
  35917. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35918. */
  35919. ViveController.prototype.initControllerMesh = function (scene, meshLoaded) {
  35920. var _this = this;
  35921. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh("", ViveController.MODEL_BASE_URL, ViveController.MODEL_FILENAME, scene, function (newMeshes) {
  35922. /*
  35923. Parent Mesh name: ViveWand
  35924. - body
  35925. - r_gripper
  35926. - l_gripper
  35927. - menu_button
  35928. - system_button
  35929. - trackpad
  35930. - trigger
  35931. - LED
  35932. */
  35933. _this._defaultModel = newMeshes[1];
  35934. _this.attachToMesh(_this._defaultModel);
  35935. if (meshLoaded) {
  35936. meshLoaded(_this._defaultModel);
  35937. }
  35938. });
  35939. };
  35940. Object.defineProperty(ViveController.prototype, "onLeftButtonStateChangedObservable", {
  35941. /**
  35942. * Fired when the left button on this controller is modified
  35943. */
  35944. get: function () {
  35945. return this.onMainButtonStateChangedObservable;
  35946. },
  35947. enumerable: true,
  35948. configurable: true
  35949. });
  35950. Object.defineProperty(ViveController.prototype, "onRightButtonStateChangedObservable", {
  35951. /**
  35952. * Fired when the right button on this controller is modified
  35953. */
  35954. get: function () {
  35955. return this.onMainButtonStateChangedObservable;
  35956. },
  35957. enumerable: true,
  35958. configurable: true
  35959. });
  35960. Object.defineProperty(ViveController.prototype, "onMenuButtonStateChangedObservable", {
  35961. /**
  35962. * Fired when the menu button on this controller is modified
  35963. */
  35964. get: function () {
  35965. return this.onSecondaryButtonStateChangedObservable;
  35966. },
  35967. enumerable: true,
  35968. configurable: true
  35969. });
  35970. /**
  35971. * Called once for each button that changed state since the last frame
  35972. * Vive mapping:
  35973. * 0: touchpad
  35974. * 1: trigger
  35975. * 2: left AND right buttons
  35976. * 3: menu button
  35977. * @param buttonIdx Which button index changed
  35978. * @param state New state of the button
  35979. * @param changes Which properties on the state changed since last frame
  35980. */
  35981. ViveController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35982. var notifyObject = state; //{ state: state, changes: changes };
  35983. switch (buttonIdx) {
  35984. case 0:
  35985. this.onPadStateChangedObservable.notifyObservers(notifyObject);
  35986. return;
  35987. case 1: // index trigger
  35988. if (this._defaultModel) {
  35989. (this._defaultModel.getChildren()[6]).rotation.x = -notifyObject.value * 0.15;
  35990. }
  35991. this.onTriggerStateChangedObservable.notifyObservers(notifyObject);
  35992. return;
  35993. case 2: // left AND right button
  35994. this.onMainButtonStateChangedObservable.notifyObservers(notifyObject);
  35995. return;
  35996. case 3:
  35997. if (this._defaultModel) {
  35998. if (notifyObject.pressed) {
  35999. (this._defaultModel.getChildren()[2]).position.y = -0.001;
  36000. }
  36001. else {
  36002. (this._defaultModel.getChildren()[2]).position.y = 0;
  36003. }
  36004. }
  36005. this.onSecondaryButtonStateChangedObservable.notifyObservers(notifyObject);
  36006. return;
  36007. }
  36008. };
  36009. /**
  36010. * Base Url for the controller model.
  36011. */
  36012. ViveController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/vive/';
  36013. /**
  36014. * File name for the controller model.
  36015. */
  36016. ViveController.MODEL_FILENAME = 'wand.babylon';
  36017. return ViveController;
  36018. }(_webVRController__WEBPACK_IMPORTED_MODULE_2__["WebVRController"]));
  36019. _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  36020. canCreate: function (gamepadInfo) {
  36021. return gamepadInfo.id.toLowerCase().indexOf('openvr') !== -1;
  36022. },
  36023. create: function (gamepadInfo) {
  36024. return new ViveController(gamepadInfo);
  36025. }
  36026. });
  36027. /***/ }),
  36028. /***/ "./Gamepads/Controllers/webVRController.ts":
  36029. /*!*************************************************!*\
  36030. !*** ./Gamepads/Controllers/webVRController.ts ***!
  36031. \*************************************************/
  36032. /*! exports provided: WebVRController */
  36033. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36034. "use strict";
  36035. __webpack_require__.r(__webpack_exports__);
  36036. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return WebVRController; });
  36037. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36038. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  36039. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  36040. /**
  36041. * Defines the WebVRController object that represents controllers tracked in 3D space
  36042. */
  36043. var WebVRController = /** @class */ (function (_super) {
  36044. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebVRController, _super);
  36045. /**
  36046. * Creates a new WebVRController from a gamepad
  36047. * @param vrGamepad the gamepad that the WebVRController should be created from
  36048. */
  36049. function WebVRController(vrGamepad) {
  36050. var _this = _super.call(this, vrGamepad) || this;
  36051. // Observables
  36052. /**
  36053. * Fired when the trigger state has changed
  36054. */
  36055. _this.onTriggerStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36056. /**
  36057. * Fired when the main button state has changed
  36058. */
  36059. _this.onMainButtonStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36060. /**
  36061. * Fired when the secondary button state has changed
  36062. */
  36063. _this.onSecondaryButtonStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36064. /**
  36065. * Fired when the pad state has changed
  36066. */
  36067. _this.onPadStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36068. /**
  36069. * Fired when controllers stick values have changed
  36070. */
  36071. _this.onPadValuesChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36072. /**
  36073. * X and Y axis corrisponding to the controllers joystick
  36074. */
  36075. _this.pad = { x: 0, y: 0 };
  36076. // avoid GC, store state in a tmp object
  36077. _this._changes = {
  36078. pressChanged: false,
  36079. touchChanged: false,
  36080. valueChanged: false,
  36081. changed: false
  36082. };
  36083. _this._buttons = new Array(vrGamepad.buttons.length);
  36084. _this.hand = vrGamepad.hand;
  36085. return _this;
  36086. }
  36087. /**
  36088. * Fired when a controller button's state has changed
  36089. * @param callback the callback containing the button that was modified
  36090. */
  36091. WebVRController.prototype.onButtonStateChange = function (callback) {
  36092. this._onButtonStateChange = callback;
  36093. };
  36094. Object.defineProperty(WebVRController.prototype, "defaultModel", {
  36095. /**
  36096. * The default controller model for the controller
  36097. */
  36098. get: function () {
  36099. return this._defaultModel;
  36100. },
  36101. enumerable: true,
  36102. configurable: true
  36103. });
  36104. /**
  36105. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  36106. */
  36107. WebVRController.prototype.update = function () {
  36108. _super.prototype.update.call(this);
  36109. for (var index = 0; index < this._buttons.length; index++) {
  36110. this._setButtonValue(this.browserGamepad.buttons[index], this._buttons[index], index);
  36111. }
  36112. if (this.leftStick.x !== this.pad.x || this.leftStick.y !== this.pad.y) {
  36113. this.pad.x = this.leftStick.x;
  36114. this.pad.y = this.leftStick.y;
  36115. this.onPadValuesChangedObservable.notifyObservers(this.pad);
  36116. }
  36117. };
  36118. WebVRController.prototype._setButtonValue = function (newState, currentState, buttonIndex) {
  36119. if (!newState) {
  36120. newState = {
  36121. pressed: false,
  36122. touched: false,
  36123. value: 0
  36124. };
  36125. }
  36126. if (!currentState) {
  36127. this._buttons[buttonIndex] = {
  36128. pressed: newState.pressed,
  36129. touched: newState.touched,
  36130. value: newState.value
  36131. };
  36132. return;
  36133. }
  36134. this._checkChanges(newState, currentState);
  36135. if (this._changes.changed) {
  36136. this._onButtonStateChange && this._onButtonStateChange(this.index, buttonIndex, newState);
  36137. this._handleButtonChange(buttonIndex, newState, this._changes);
  36138. }
  36139. this._buttons[buttonIndex].pressed = newState.pressed;
  36140. this._buttons[buttonIndex].touched = newState.touched;
  36141. // oculus triggers are never 0, thou not touched.
  36142. this._buttons[buttonIndex].value = newState.value < 0.00000001 ? 0 : newState.value;
  36143. };
  36144. WebVRController.prototype._checkChanges = function (newState, currentState) {
  36145. this._changes.pressChanged = newState.pressed !== currentState.pressed;
  36146. this._changes.touchChanged = newState.touched !== currentState.touched;
  36147. this._changes.valueChanged = newState.value !== currentState.value;
  36148. this._changes.changed = this._changes.pressChanged || this._changes.touchChanged || this._changes.valueChanged;
  36149. return this._changes;
  36150. };
  36151. /**
  36152. * Disposes of th webVRCOntroller
  36153. */
  36154. WebVRController.prototype.dispose = function () {
  36155. _super.prototype.dispose.call(this);
  36156. this.onTriggerStateChangedObservable.clear();
  36157. this.onMainButtonStateChangedObservable.clear();
  36158. this.onSecondaryButtonStateChangedObservable.clear();
  36159. this.onPadStateChangedObservable.clear();
  36160. this.onPadValuesChangedObservable.clear();
  36161. };
  36162. return WebVRController;
  36163. }(_poseEnabledController__WEBPACK_IMPORTED_MODULE_2__["PoseEnabledController"]));
  36164. /***/ }),
  36165. /***/ "./Gamepads/Controllers/windowsMotionController.ts":
  36166. /*!*********************************************************!*\
  36167. !*** ./Gamepads/Controllers/windowsMotionController.ts ***!
  36168. \*********************************************************/
  36169. /*! exports provided: WindowsMotionController */
  36170. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36171. "use strict";
  36172. __webpack_require__.r(__webpack_exports__);
  36173. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return WindowsMotionController; });
  36174. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36175. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  36176. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  36177. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  36178. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  36179. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  36180. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  36181. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  36182. /* harmony import */ var _genericController__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./genericController */ "./Gamepads/Controllers/genericController.ts");
  36183. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  36184. /**
  36185. * Defines the LoadedMeshInfo object that describes information about the loaded webVR controller mesh
  36186. */
  36187. var LoadedMeshInfo = /** @class */ (function () {
  36188. function LoadedMeshInfo() {
  36189. /**
  36190. * Map of the button meshes contained in the controller
  36191. */
  36192. this.buttonMeshes = {};
  36193. /**
  36194. * Map of the axis meshes contained in the controller
  36195. */
  36196. this.axisMeshes = {};
  36197. }
  36198. return LoadedMeshInfo;
  36199. }());
  36200. /**
  36201. * Defines the WindowsMotionController object that the state of the windows motion controller
  36202. */
  36203. var WindowsMotionController = /** @class */ (function (_super) {
  36204. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WindowsMotionController, _super);
  36205. /**
  36206. * Creates a new WindowsMotionController from a gamepad
  36207. * @param vrGamepad the gamepad that the controller should be created from
  36208. */
  36209. function WindowsMotionController(vrGamepad) {
  36210. var _this = _super.call(this, vrGamepad) || this;
  36211. _this._mapping = {
  36212. // Semantic button names
  36213. buttons: ['thumbstick', 'trigger', 'grip', 'menu', 'trackpad'],
  36214. // A mapping of the button name to glTF model node name
  36215. // that should be transformed by button value.
  36216. buttonMeshNames: {
  36217. 'trigger': 'SELECT',
  36218. 'menu': 'MENU',
  36219. 'grip': 'GRASP',
  36220. 'thumbstick': 'THUMBSTICK_PRESS',
  36221. 'trackpad': 'TOUCHPAD_PRESS'
  36222. },
  36223. // This mapping is used to translate from the Motion Controller to Babylon semantics
  36224. buttonObservableNames: {
  36225. 'trigger': 'onTriggerStateChangedObservable',
  36226. 'menu': 'onSecondaryButtonStateChangedObservable',
  36227. 'grip': 'onMainButtonStateChangedObservable',
  36228. 'thumbstick': 'onPadStateChangedObservable',
  36229. 'trackpad': 'onTrackpadChangedObservable'
  36230. },
  36231. // A mapping of the axis name to glTF model node name
  36232. // that should be transformed by axis value.
  36233. // This array mirrors the browserGamepad.axes array, such that
  36234. // the mesh corresponding to axis 0 is in this array index 0.
  36235. axisMeshNames: [
  36236. 'THUMBSTICK_X',
  36237. 'THUMBSTICK_Y',
  36238. 'TOUCHPAD_TOUCH_X',
  36239. 'TOUCHPAD_TOUCH_Y'
  36240. ],
  36241. pointingPoseMeshName: _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledController"].POINTING_POSE
  36242. };
  36243. /**
  36244. * Fired when the trackpad on this controller is clicked
  36245. */
  36246. _this.onTrackpadChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  36247. /**
  36248. * Fired when the trackpad on this controller is modified
  36249. */
  36250. _this.onTrackpadValuesChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  36251. /**
  36252. * The current x and y values of this controller's trackpad
  36253. */
  36254. _this.trackpad = { x: 0, y: 0 };
  36255. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledControllerType"].WINDOWS;
  36256. _this._loadedMeshInfo = null;
  36257. return _this;
  36258. }
  36259. Object.defineProperty(WindowsMotionController.prototype, "onTriggerButtonStateChangedObservable", {
  36260. /**
  36261. * Fired when the trigger on this controller is modified
  36262. */
  36263. get: function () {
  36264. return this.onTriggerStateChangedObservable;
  36265. },
  36266. enumerable: true,
  36267. configurable: true
  36268. });
  36269. Object.defineProperty(WindowsMotionController.prototype, "onMenuButtonStateChangedObservable", {
  36270. /**
  36271. * Fired when the menu button on this controller is modified
  36272. */
  36273. get: function () {
  36274. return this.onSecondaryButtonStateChangedObservable;
  36275. },
  36276. enumerable: true,
  36277. configurable: true
  36278. });
  36279. Object.defineProperty(WindowsMotionController.prototype, "onGripButtonStateChangedObservable", {
  36280. /**
  36281. * Fired when the grip button on this controller is modified
  36282. */
  36283. get: function () {
  36284. return this.onMainButtonStateChangedObservable;
  36285. },
  36286. enumerable: true,
  36287. configurable: true
  36288. });
  36289. Object.defineProperty(WindowsMotionController.prototype, "onThumbstickButtonStateChangedObservable", {
  36290. /**
  36291. * Fired when the thumbstick button on this controller is modified
  36292. */
  36293. get: function () {
  36294. return this.onPadStateChangedObservable;
  36295. },
  36296. enumerable: true,
  36297. configurable: true
  36298. });
  36299. Object.defineProperty(WindowsMotionController.prototype, "onTouchpadButtonStateChangedObservable", {
  36300. /**
  36301. * Fired when the touchpad button on this controller is modified
  36302. */
  36303. get: function () {
  36304. return this.onTrackpadChangedObservable;
  36305. },
  36306. enumerable: true,
  36307. configurable: true
  36308. });
  36309. Object.defineProperty(WindowsMotionController.prototype, "onTouchpadValuesChangedObservable", {
  36310. /**
  36311. * Fired when the touchpad values on this controller are modified
  36312. */
  36313. get: function () {
  36314. return this.onTrackpadValuesChangedObservable;
  36315. },
  36316. enumerable: true,
  36317. configurable: true
  36318. });
  36319. WindowsMotionController.prototype._updateTrackpad = function () {
  36320. if (this.browserGamepad.axes && (this.browserGamepad.axes[2] != this.trackpad.x || this.browserGamepad.axes[3] != this.trackpad.y)) {
  36321. this.trackpad.x = this.browserGamepad["axes"][2];
  36322. this.trackpad.y = this.browserGamepad["axes"][3];
  36323. this.onTrackpadValuesChangedObservable.notifyObservers(this.trackpad);
  36324. }
  36325. };
  36326. /**
  36327. * Called once per frame by the engine.
  36328. */
  36329. WindowsMotionController.prototype.update = function () {
  36330. _super.prototype.update.call(this);
  36331. if (this.browserGamepad.axes) {
  36332. this._updateTrackpad();
  36333. // Only need to animate axes if there is a loaded mesh
  36334. if (this._loadedMeshInfo) {
  36335. for (var axis = 0; axis < this._mapping.axisMeshNames.length; axis++) {
  36336. this._lerpAxisTransform(axis, this.browserGamepad.axes[axis]);
  36337. }
  36338. }
  36339. }
  36340. };
  36341. /**
  36342. * Called once for each button that changed state since the last frame
  36343. * @param buttonIdx Which button index changed
  36344. * @param state New state of the button
  36345. * @param changes Which properties on the state changed since last frame
  36346. */
  36347. WindowsMotionController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  36348. var buttonName = this._mapping.buttons[buttonIdx];
  36349. if (!buttonName) {
  36350. return;
  36351. }
  36352. // Update the trackpad to ensure trackpad.x/y are accurate during button events between frames
  36353. this._updateTrackpad();
  36354. // Only emit events for buttons that we know how to map from index to name
  36355. var observable = this[(this._mapping.buttonObservableNames)[buttonName]];
  36356. if (observable) {
  36357. observable.notifyObservers(state);
  36358. }
  36359. this._lerpButtonTransform(buttonName, state.value);
  36360. };
  36361. /**
  36362. * Moves the buttons on the controller mesh based on their current state
  36363. * @param buttonName the name of the button to move
  36364. * @param buttonValue the value of the button which determines the buttons new position
  36365. */
  36366. WindowsMotionController.prototype._lerpButtonTransform = function (buttonName, buttonValue) {
  36367. // If there is no loaded mesh, there is nothing to transform.
  36368. if (!this._loadedMeshInfo) {
  36369. return;
  36370. }
  36371. var meshInfo = this._loadedMeshInfo.buttonMeshes[buttonName];
  36372. if (!meshInfo.unpressed.rotationQuaternion || !meshInfo.pressed.rotationQuaternion || !meshInfo.value.rotationQuaternion) {
  36373. return;
  36374. }
  36375. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(meshInfo.unpressed.rotationQuaternion, meshInfo.pressed.rotationQuaternion, buttonValue, meshInfo.value.rotationQuaternion);
  36376. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].LerpToRef(meshInfo.unpressed.position, meshInfo.pressed.position, buttonValue, meshInfo.value.position);
  36377. };
  36378. /**
  36379. * Moves the axis on the controller mesh based on its current state
  36380. * @param axis the index of the axis
  36381. * @param axisValue the value of the axis which determines the meshes new position
  36382. * @hidden
  36383. */
  36384. WindowsMotionController.prototype._lerpAxisTransform = function (axis, axisValue) {
  36385. if (!this._loadedMeshInfo) {
  36386. return;
  36387. }
  36388. var meshInfo = this._loadedMeshInfo.axisMeshes[axis];
  36389. if (!meshInfo) {
  36390. return;
  36391. }
  36392. if (!meshInfo.min.rotationQuaternion || !meshInfo.max.rotationQuaternion || !meshInfo.value.rotationQuaternion) {
  36393. return;
  36394. }
  36395. // Convert from gamepad value range (-1 to +1) to lerp range (0 to 1)
  36396. var lerpValue = axisValue * 0.5 + 0.5;
  36397. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(meshInfo.min.rotationQuaternion, meshInfo.max.rotationQuaternion, lerpValue, meshInfo.value.rotationQuaternion);
  36398. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].LerpToRef(meshInfo.min.position, meshInfo.max.position, lerpValue, meshInfo.value.position);
  36399. };
  36400. /**
  36401. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  36402. * @param scene scene in which to add meshes
  36403. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  36404. */
  36405. WindowsMotionController.prototype.initControllerMesh = function (scene, meshLoaded, forceDefault) {
  36406. var _this = this;
  36407. if (forceDefault === void 0) { forceDefault = false; }
  36408. var path;
  36409. var filename;
  36410. // Checking if GLB loader is present
  36411. if (_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__["SceneLoader"].IsPluginForExtensionAvailable(".glb")) {
  36412. // Determine the device specific folder based on the ID suffix
  36413. var device = 'default';
  36414. if (this.id && !forceDefault) {
  36415. var match = this.id.match(WindowsMotionController.GAMEPAD_ID_PATTERN);
  36416. device = ((match && match[0]) || device);
  36417. }
  36418. // Hand
  36419. if (this.hand === 'left') {
  36420. filename = WindowsMotionController.MODEL_LEFT_FILENAME;
  36421. }
  36422. else { // Right is the default if no hand is specified
  36423. filename = WindowsMotionController.MODEL_RIGHT_FILENAME;
  36424. }
  36425. path = WindowsMotionController.MODEL_BASE_URL + device + '/';
  36426. }
  36427. else {
  36428. _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");
  36429. path = _genericController__WEBPACK_IMPORTED_MODULE_8__["GenericController"].MODEL_BASE_URL;
  36430. filename = _genericController__WEBPACK_IMPORTED_MODULE_8__["GenericController"].MODEL_FILENAME;
  36431. }
  36432. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__["SceneLoader"].ImportMesh("", path, filename, scene, function (meshes) {
  36433. // glTF files successfully loaded from the remote server, now process them to ensure they are in the right format.
  36434. _this._loadedMeshInfo = _this.processModel(scene, meshes);
  36435. if (!_this._loadedMeshInfo) {
  36436. return;
  36437. }
  36438. _this._defaultModel = _this._loadedMeshInfo.rootNode;
  36439. _this.attachToMesh(_this._defaultModel);
  36440. if (meshLoaded) {
  36441. meshLoaded(_this._defaultModel);
  36442. }
  36443. }, null, function (scene, message) {
  36444. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log(message);
  36445. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Failed to retrieve controller model from the remote server: ' + path + filename);
  36446. if (!forceDefault) {
  36447. _this.initControllerMesh(scene, meshLoaded, true);
  36448. }
  36449. });
  36450. };
  36451. /**
  36452. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  36453. * can be transformed by button presses and axes values, based on this._mapping.
  36454. *
  36455. * @param scene scene in which the meshes exist
  36456. * @param meshes list of meshes that make up the controller model to process
  36457. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  36458. */
  36459. WindowsMotionController.prototype.processModel = function (scene, meshes) {
  36460. var loadedMeshInfo = null;
  36461. // Create a new mesh to contain the glTF hierarchy
  36462. var parentMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"](this.id + " " + this.hand, scene);
  36463. // Find the root node in the loaded glTF scene, and attach it as a child of 'parentMesh'
  36464. var childMesh = null;
  36465. for (var i = 0; i < meshes.length; i++) {
  36466. var mesh = meshes[i];
  36467. if (!mesh.parent) {
  36468. // Exclude controller meshes from picking results
  36469. mesh.isPickable = false;
  36470. // Handle root node, attach to the new parentMesh
  36471. childMesh = mesh;
  36472. break;
  36473. }
  36474. }
  36475. if (childMesh) {
  36476. childMesh.setParent(parentMesh);
  36477. // Create our mesh info. Note that this method will always return non-null.
  36478. loadedMeshInfo = this.createMeshInfo(parentMesh);
  36479. }
  36480. else {
  36481. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Could not find root node in model file.');
  36482. }
  36483. return loadedMeshInfo;
  36484. };
  36485. WindowsMotionController.prototype.createMeshInfo = function (rootNode) {
  36486. var loadedMeshInfo = new LoadedMeshInfo();
  36487. var i;
  36488. loadedMeshInfo.rootNode = rootNode;
  36489. // Reset the caches
  36490. loadedMeshInfo.buttonMeshes = {};
  36491. loadedMeshInfo.axisMeshes = {};
  36492. // Button Meshes
  36493. for (i = 0; i < this._mapping.buttons.length; i++) {
  36494. var buttonMeshName = this._mapping.buttonMeshNames[this._mapping.buttons[i]];
  36495. if (!buttonMeshName) {
  36496. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log('Skipping unknown button at index: ' + i + ' with mapped name: ' + this._mapping.buttons[i]);
  36497. continue;
  36498. }
  36499. var buttonMesh = getChildByName(rootNode, buttonMeshName);
  36500. if (!buttonMesh) {
  36501. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing button mesh with name: ' + buttonMeshName);
  36502. continue;
  36503. }
  36504. var buttonMeshInfo = {
  36505. index: i,
  36506. value: getImmediateChildByName(buttonMesh, 'VALUE'),
  36507. pressed: getImmediateChildByName(buttonMesh, 'PRESSED'),
  36508. unpressed: getImmediateChildByName(buttonMesh, 'UNPRESSED')
  36509. };
  36510. if (buttonMeshInfo.value && buttonMeshInfo.pressed && buttonMeshInfo.unpressed) {
  36511. loadedMeshInfo.buttonMeshes[this._mapping.buttons[i]] = buttonMeshInfo;
  36512. }
  36513. else {
  36514. // If we didn't find the mesh, it simply means this button won't have transforms applied as mapped button value changes.
  36515. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing button submesh under mesh with name: ' + buttonMeshName +
  36516. '(VALUE: ' + !!buttonMeshInfo.value +
  36517. ', PRESSED: ' + !!buttonMeshInfo.pressed +
  36518. ', UNPRESSED:' + !!buttonMeshInfo.unpressed +
  36519. ')');
  36520. }
  36521. }
  36522. // Axis Meshes
  36523. for (i = 0; i < this._mapping.axisMeshNames.length; i++) {
  36524. var axisMeshName = this._mapping.axisMeshNames[i];
  36525. if (!axisMeshName) {
  36526. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log('Skipping unknown axis at index: ' + i);
  36527. continue;
  36528. }
  36529. var axisMesh = getChildByName(rootNode, axisMeshName);
  36530. if (!axisMesh) {
  36531. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing axis mesh with name: ' + axisMeshName);
  36532. continue;
  36533. }
  36534. var axisMeshInfo = {
  36535. index: i,
  36536. value: getImmediateChildByName(axisMesh, 'VALUE'),
  36537. min: getImmediateChildByName(axisMesh, 'MIN'),
  36538. max: getImmediateChildByName(axisMesh, 'MAX')
  36539. };
  36540. if (axisMeshInfo.value && axisMeshInfo.min && axisMeshInfo.max) {
  36541. loadedMeshInfo.axisMeshes[i] = axisMeshInfo;
  36542. }
  36543. else {
  36544. // If we didn't find the mesh, it simply means thit axis won't have transforms applied as mapped axis values change.
  36545. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing axis submesh under mesh with name: ' + axisMeshName +
  36546. '(VALUE: ' + !!axisMeshInfo.value +
  36547. ', MIN: ' + !!axisMeshInfo.min +
  36548. ', MAX:' + !!axisMeshInfo.max +
  36549. ')');
  36550. }
  36551. }
  36552. // Pointing Ray
  36553. loadedMeshInfo.pointingPoseNode = getChildByName(rootNode, this._mapping.pointingPoseMeshName);
  36554. if (!loadedMeshInfo.pointingPoseNode) {
  36555. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing pointing pose mesh with name: ' + this._mapping.pointingPoseMeshName);
  36556. }
  36557. else {
  36558. this._pointingPoseNode = loadedMeshInfo.pointingPoseNode;
  36559. }
  36560. return loadedMeshInfo;
  36561. // Look through all children recursively. This will return null if no mesh exists with the given name.
  36562. function getChildByName(node, name) {
  36563. return node.getChildren(function (n) { return n.name === name; }, false)[0];
  36564. }
  36565. // Look through only immediate children. This will return null if no mesh exists with the given name.
  36566. function getImmediateChildByName(node, name) {
  36567. return node.getChildren(function (n) { return n.name == name; }, true)[0];
  36568. }
  36569. };
  36570. /**
  36571. * Gets the ray of the controller in the direction the controller is pointing
  36572. * @param length the length the resulting ray should be
  36573. * @returns a ray in the direction the controller is pointing
  36574. */
  36575. WindowsMotionController.prototype.getForwardRay = function (length) {
  36576. if (length === void 0) { length = 100; }
  36577. if (!(this._loadedMeshInfo && this._loadedMeshInfo.pointingPoseNode)) {
  36578. return _super.prototype.getForwardRay.call(this, length);
  36579. }
  36580. var m = this._loadedMeshInfo.pointingPoseNode.getWorldMatrix();
  36581. var origin = m.getTranslation();
  36582. var forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1);
  36583. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(forward, m);
  36584. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Normalize(forwardWorld);
  36585. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](origin, direction, length);
  36586. };
  36587. /**
  36588. * Disposes of the controller
  36589. */
  36590. WindowsMotionController.prototype.dispose = function () {
  36591. _super.prototype.dispose.call(this);
  36592. this.onTrackpadChangedObservable.clear();
  36593. };
  36594. /**
  36595. * The base url used to load the left and right controller models
  36596. */
  36597. WindowsMotionController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/microsoft/';
  36598. /**
  36599. * The name of the left controller model file
  36600. */
  36601. WindowsMotionController.MODEL_LEFT_FILENAME = 'left.glb';
  36602. /**
  36603. * The name of the right controller model file
  36604. */
  36605. WindowsMotionController.MODEL_RIGHT_FILENAME = 'right.glb';
  36606. /**
  36607. * The controller name prefix for this controller type
  36608. */
  36609. WindowsMotionController.GAMEPAD_ID_PREFIX = 'Spatial Controller (Spatial Interaction Source) ';
  36610. /**
  36611. * The controller id pattern for this controller type
  36612. */
  36613. WindowsMotionController.GAMEPAD_ID_PATTERN = /([0-9a-zA-Z]+-[0-9a-zA-Z]+)$/;
  36614. return WindowsMotionController;
  36615. }(_webVRController__WEBPACK_IMPORTED_MODULE_7__["WebVRController"]));
  36616. _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  36617. canCreate: function (gamepadInfo) {
  36618. return gamepadInfo.id.indexOf(WindowsMotionController.GAMEPAD_ID_PREFIX) === 0;
  36619. },
  36620. create: function (gamepadInfo) {
  36621. return new WindowsMotionController(gamepadInfo);
  36622. }
  36623. });
  36624. /***/ }),
  36625. /***/ "./Gamepads/gamepad.ts":
  36626. /*!*****************************!*\
  36627. !*** ./Gamepads/gamepad.ts ***!
  36628. \*****************************/
  36629. /*! exports provided: StickValues, Gamepad, GenericPad */
  36630. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36631. "use strict";
  36632. __webpack_require__.r(__webpack_exports__);
  36633. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return StickValues; });
  36634. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return Gamepad; });
  36635. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return GenericPad; });
  36636. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36637. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  36638. /**
  36639. * Represents a gamepad control stick position
  36640. */
  36641. var StickValues = /** @class */ (function () {
  36642. /**
  36643. * Initializes the gamepad x and y control stick values
  36644. * @param x The x component of the gamepad control stick value
  36645. * @param y The y component of the gamepad control stick value
  36646. */
  36647. function StickValues(
  36648. /**
  36649. * The x component of the control stick
  36650. */
  36651. x,
  36652. /**
  36653. * The y component of the control stick
  36654. */
  36655. y) {
  36656. this.x = x;
  36657. this.y = y;
  36658. }
  36659. return StickValues;
  36660. }());
  36661. /**
  36662. * Represents a gamepad
  36663. */
  36664. var Gamepad = /** @class */ (function () {
  36665. /**
  36666. * Initializes the gamepad
  36667. * @param id The id of the gamepad
  36668. * @param index The index of the gamepad
  36669. * @param browserGamepad The browser gamepad
  36670. * @param leftStickX The x component of the left joystick
  36671. * @param leftStickY The y component of the left joystick
  36672. * @param rightStickX The x component of the right joystick
  36673. * @param rightStickY The y component of the right joystick
  36674. */
  36675. function Gamepad(
  36676. /**
  36677. * The id of the gamepad
  36678. */
  36679. id,
  36680. /**
  36681. * The index of the gamepad
  36682. */
  36683. index,
  36684. /**
  36685. * The browser gamepad
  36686. */
  36687. browserGamepad, leftStickX, leftStickY, rightStickX, rightStickY) {
  36688. if (leftStickX === void 0) { leftStickX = 0; }
  36689. if (leftStickY === void 0) { leftStickY = 1; }
  36690. if (rightStickX === void 0) { rightStickX = 2; }
  36691. if (rightStickY === void 0) { rightStickY = 3; }
  36692. this.id = id;
  36693. this.index = index;
  36694. this.browserGamepad = browserGamepad;
  36695. this._leftStick = { x: 0, y: 0 };
  36696. this._rightStick = { x: 0, y: 0 };
  36697. /** @hidden */
  36698. this._isConnected = true;
  36699. /**
  36700. * Specifies whether the left control stick should be Y-inverted
  36701. */
  36702. this._invertLeftStickY = false;
  36703. this.type = Gamepad.GAMEPAD;
  36704. this._leftStickAxisX = leftStickX;
  36705. this._leftStickAxisY = leftStickY;
  36706. this._rightStickAxisX = rightStickX;
  36707. this._rightStickAxisY = rightStickY;
  36708. if (this.browserGamepad.axes.length >= 2) {
  36709. this._leftStick = { x: this.browserGamepad.axes[this._leftStickAxisX], y: this.browserGamepad.axes[this._leftStickAxisY] };
  36710. }
  36711. if (this.browserGamepad.axes.length >= 4) {
  36712. this._rightStick = { x: this.browserGamepad.axes[this._rightStickAxisX], y: this.browserGamepad.axes[this._rightStickAxisY] };
  36713. }
  36714. }
  36715. Object.defineProperty(Gamepad.prototype, "isConnected", {
  36716. /**
  36717. * Specifies if the gamepad has been connected
  36718. */
  36719. get: function () {
  36720. return this._isConnected;
  36721. },
  36722. enumerable: true,
  36723. configurable: true
  36724. });
  36725. /**
  36726. * Callback triggered when the left joystick has changed
  36727. * @param callback
  36728. */
  36729. Gamepad.prototype.onleftstickchanged = function (callback) {
  36730. this._onleftstickchanged = callback;
  36731. };
  36732. /**
  36733. * Callback triggered when the right joystick has changed
  36734. * @param callback
  36735. */
  36736. Gamepad.prototype.onrightstickchanged = function (callback) {
  36737. this._onrightstickchanged = callback;
  36738. };
  36739. Object.defineProperty(Gamepad.prototype, "leftStick", {
  36740. /**
  36741. * Gets the left joystick
  36742. */
  36743. get: function () {
  36744. return this._leftStick;
  36745. },
  36746. /**
  36747. * Sets the left joystick values
  36748. */
  36749. set: function (newValues) {
  36750. if (this._onleftstickchanged && (this._leftStick.x !== newValues.x || this._leftStick.y !== newValues.y)) {
  36751. this._onleftstickchanged(newValues);
  36752. }
  36753. this._leftStick = newValues;
  36754. },
  36755. enumerable: true,
  36756. configurable: true
  36757. });
  36758. Object.defineProperty(Gamepad.prototype, "rightStick", {
  36759. /**
  36760. * Gets the right joystick
  36761. */
  36762. get: function () {
  36763. return this._rightStick;
  36764. },
  36765. /**
  36766. * Sets the right joystick value
  36767. */
  36768. set: function (newValues) {
  36769. if (this._onrightstickchanged && (this._rightStick.x !== newValues.x || this._rightStick.y !== newValues.y)) {
  36770. this._onrightstickchanged(newValues);
  36771. }
  36772. this._rightStick = newValues;
  36773. },
  36774. enumerable: true,
  36775. configurable: true
  36776. });
  36777. /**
  36778. * Updates the gamepad joystick positions
  36779. */
  36780. Gamepad.prototype.update = function () {
  36781. if (this._leftStick) {
  36782. this.leftStick = { x: this.browserGamepad.axes[this._leftStickAxisX], y: this.browserGamepad.axes[this._leftStickAxisY] };
  36783. if (this._invertLeftStickY) {
  36784. this.leftStick.y *= -1;
  36785. }
  36786. }
  36787. if (this._rightStick) {
  36788. this.rightStick = { x: this.browserGamepad.axes[this._rightStickAxisX], y: this.browserGamepad.axes[this._rightStickAxisY] };
  36789. }
  36790. };
  36791. /**
  36792. * Disposes the gamepad
  36793. */
  36794. Gamepad.prototype.dispose = function () {
  36795. };
  36796. /**
  36797. * Represents a gamepad controller
  36798. */
  36799. Gamepad.GAMEPAD = 0;
  36800. /**
  36801. * Represents a generic controller
  36802. */
  36803. Gamepad.GENERIC = 1;
  36804. /**
  36805. * Represents an XBox controller
  36806. */
  36807. Gamepad.XBOX = 2;
  36808. /**
  36809. * Represents a pose-enabled controller
  36810. */
  36811. Gamepad.POSE_ENABLED = 3;
  36812. return Gamepad;
  36813. }());
  36814. /**
  36815. * Represents a generic gamepad
  36816. */
  36817. var GenericPad = /** @class */ (function (_super) {
  36818. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GenericPad, _super);
  36819. /**
  36820. * Initializes the generic gamepad
  36821. * @param id The id of the generic gamepad
  36822. * @param index The index of the generic gamepad
  36823. * @param browserGamepad The browser gamepad
  36824. */
  36825. function GenericPad(id, index, browserGamepad) {
  36826. var _this = _super.call(this, id, index, browserGamepad) || this;
  36827. /**
  36828. * Observable triggered when a button has been pressed
  36829. */
  36830. _this.onButtonDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36831. /**
  36832. * Observable triggered when a button has been released
  36833. */
  36834. _this.onButtonUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36835. _this.type = Gamepad.GENERIC;
  36836. _this._buttons = new Array(browserGamepad.buttons.length);
  36837. return _this;
  36838. }
  36839. /**
  36840. * Callback triggered when a button has been pressed
  36841. * @param callback Called when a button has been pressed
  36842. */
  36843. GenericPad.prototype.onbuttondown = function (callback) {
  36844. this._onbuttondown = callback;
  36845. };
  36846. /**
  36847. * Callback triggered when a button has been released
  36848. * @param callback Called when a button has been released
  36849. */
  36850. GenericPad.prototype.onbuttonup = function (callback) {
  36851. this._onbuttonup = callback;
  36852. };
  36853. GenericPad.prototype._setButtonValue = function (newValue, currentValue, buttonIndex) {
  36854. if (newValue !== currentValue) {
  36855. if (newValue === 1) {
  36856. if (this._onbuttondown) {
  36857. this._onbuttondown(buttonIndex);
  36858. }
  36859. this.onButtonDownObservable.notifyObservers(buttonIndex);
  36860. }
  36861. if (newValue === 0) {
  36862. if (this._onbuttonup) {
  36863. this._onbuttonup(buttonIndex);
  36864. }
  36865. this.onButtonUpObservable.notifyObservers(buttonIndex);
  36866. }
  36867. }
  36868. return newValue;
  36869. };
  36870. /**
  36871. * Updates the generic gamepad
  36872. */
  36873. GenericPad.prototype.update = function () {
  36874. _super.prototype.update.call(this);
  36875. for (var index = 0; index < this._buttons.length; index++) {
  36876. this._buttons[index] = this._setButtonValue(this.browserGamepad.buttons[index].value, this._buttons[index], index);
  36877. }
  36878. };
  36879. /**
  36880. * Disposes the generic gamepad
  36881. */
  36882. GenericPad.prototype.dispose = function () {
  36883. _super.prototype.dispose.call(this);
  36884. this.onButtonDownObservable.clear();
  36885. this.onButtonUpObservable.clear();
  36886. };
  36887. return GenericPad;
  36888. }(Gamepad));
  36889. /***/ }),
  36890. /***/ "./Gamepads/gamepadManager.ts":
  36891. /*!************************************!*\
  36892. !*** ./Gamepads/gamepadManager.ts ***!
  36893. \************************************/
  36894. /*! exports provided: GamepadManager */
  36895. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36896. "use strict";
  36897. __webpack_require__.r(__webpack_exports__);
  36898. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return GamepadManager; });
  36899. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  36900. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  36901. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  36902. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  36903. /* harmony import */ var _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  36904. /* harmony import */ var _gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./gamepad */ "./Gamepads/gamepad.ts");
  36905. /**
  36906. * Manager for handling gamepads
  36907. */
  36908. var GamepadManager = /** @class */ (function () {
  36909. /**
  36910. * Initializes the gamepad manager
  36911. * @param _scene BabylonJS scene
  36912. */
  36913. function GamepadManager(_scene) {
  36914. var _this = this;
  36915. this._scene = _scene;
  36916. this._babylonGamepads = [];
  36917. this._oneGamepadConnected = false;
  36918. /** @hidden */
  36919. this._isMonitoring = false;
  36920. /**
  36921. * observable to be triggered when the gamepad controller has been disconnected
  36922. */
  36923. this.onGamepadDisconnectedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36924. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  36925. this._gamepadEventSupported = false;
  36926. }
  36927. else {
  36928. this._gamepadEventSupported = 'GamepadEvent' in window;
  36929. this._gamepadSupport = (navigator.getGamepads ||
  36930. navigator.webkitGetGamepads || navigator.msGetGamepads || navigator.webkitGamepads);
  36931. }
  36932. this.onGamepadConnectedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"](function (observer) {
  36933. // This will be used to raise the onGamepadConnected for all gamepads ALREADY connected
  36934. for (var i in _this._babylonGamepads) {
  36935. var gamepad = _this._babylonGamepads[i];
  36936. if (gamepad && gamepad._isConnected) {
  36937. _this.onGamepadConnectedObservable.notifyObserver(observer, gamepad);
  36938. }
  36939. }
  36940. });
  36941. this._onGamepadConnectedEvent = function (evt) {
  36942. var gamepad = evt.gamepad;
  36943. if (gamepad.index in _this._babylonGamepads) {
  36944. if (_this._babylonGamepads[gamepad.index].isConnected) {
  36945. return;
  36946. }
  36947. }
  36948. var newGamepad;
  36949. if (_this._babylonGamepads[gamepad.index]) {
  36950. newGamepad = _this._babylonGamepads[gamepad.index];
  36951. newGamepad.browserGamepad = gamepad;
  36952. newGamepad._isConnected = true;
  36953. }
  36954. else {
  36955. newGamepad = _this._addNewGamepad(gamepad);
  36956. }
  36957. _this.onGamepadConnectedObservable.notifyObservers(newGamepad);
  36958. _this._startMonitoringGamepads();
  36959. };
  36960. this._onGamepadDisconnectedEvent = function (evt) {
  36961. var gamepad = evt.gamepad;
  36962. // Remove the gamepad from the list of gamepads to monitor.
  36963. for (var i in _this._babylonGamepads) {
  36964. if (_this._babylonGamepads[i].index === gamepad.index) {
  36965. var disconnectedGamepad = _this._babylonGamepads[i];
  36966. disconnectedGamepad._isConnected = false;
  36967. _this.onGamepadDisconnectedObservable.notifyObservers(disconnectedGamepad);
  36968. break;
  36969. }
  36970. }
  36971. };
  36972. if (this._gamepadSupport) {
  36973. //first add already-connected gamepads
  36974. this._updateGamepadObjects();
  36975. if (this._babylonGamepads.length) {
  36976. this._startMonitoringGamepads();
  36977. }
  36978. // Checking if the gamepad connected event is supported (like in Firefox)
  36979. if (this._gamepadEventSupported) {
  36980. window.addEventListener('gamepadconnected', this._onGamepadConnectedEvent, false);
  36981. window.addEventListener('gamepaddisconnected', this._onGamepadDisconnectedEvent, false);
  36982. }
  36983. else {
  36984. this._startMonitoringGamepads();
  36985. }
  36986. }
  36987. }
  36988. Object.defineProperty(GamepadManager.prototype, "gamepads", {
  36989. /**
  36990. * The gamepads in the game pad manager
  36991. */
  36992. get: function () {
  36993. return this._babylonGamepads;
  36994. },
  36995. enumerable: true,
  36996. configurable: true
  36997. });
  36998. /**
  36999. * Get the gamepad controllers based on type
  37000. * @param type The type of gamepad controller
  37001. * @returns Nullable gamepad
  37002. */
  37003. GamepadManager.prototype.getGamepadByType = function (type) {
  37004. if (type === void 0) { type = _gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].XBOX; }
  37005. for (var _i = 0, _a = this._babylonGamepads; _i < _a.length; _i++) {
  37006. var gamepad = _a[_i];
  37007. if (gamepad && gamepad.type === type) {
  37008. return gamepad;
  37009. }
  37010. }
  37011. return null;
  37012. };
  37013. /**
  37014. * Disposes the gamepad manager
  37015. */
  37016. GamepadManager.prototype.dispose = function () {
  37017. if (this._gamepadEventSupported) {
  37018. if (this._onGamepadConnectedEvent) {
  37019. window.removeEventListener('gamepadconnected', this._onGamepadConnectedEvent);
  37020. }
  37021. if (this._onGamepadDisconnectedEvent) {
  37022. window.removeEventListener('gamepaddisconnected', this._onGamepadDisconnectedEvent);
  37023. }
  37024. this._onGamepadConnectedEvent = null;
  37025. this._onGamepadDisconnectedEvent = null;
  37026. }
  37027. this._babylonGamepads.forEach(function (gamepad) {
  37028. gamepad.dispose();
  37029. });
  37030. this.onGamepadConnectedObservable.clear();
  37031. this.onGamepadDisconnectedObservable.clear();
  37032. this._oneGamepadConnected = false;
  37033. this._stopMonitoringGamepads();
  37034. this._babylonGamepads = [];
  37035. };
  37036. GamepadManager.prototype._addNewGamepad = function (gamepad) {
  37037. if (!this._oneGamepadConnected) {
  37038. this._oneGamepadConnected = true;
  37039. }
  37040. var newGamepad;
  37041. var xboxOne = (gamepad.id.search("Xbox One") !== -1);
  37042. if (xboxOne || gamepad.id.search("Xbox 360") !== -1 || gamepad.id.search("xinput") !== -1) {
  37043. newGamepad = new _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Pad"](gamepad.id, gamepad.index, gamepad, xboxOne);
  37044. }
  37045. // if pose is supported, use the (WebVR) pose enabled controller
  37046. else if (gamepad.pose) {
  37047. newGamepad = _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"].InitiateController(gamepad);
  37048. }
  37049. else {
  37050. newGamepad = new _gamepad__WEBPACK_IMPORTED_MODULE_5__["GenericPad"](gamepad.id, gamepad.index, gamepad);
  37051. }
  37052. this._babylonGamepads[newGamepad.index] = newGamepad;
  37053. return newGamepad;
  37054. };
  37055. GamepadManager.prototype._startMonitoringGamepads = function () {
  37056. if (!this._isMonitoring) {
  37057. this._isMonitoring = true;
  37058. //back-comp
  37059. if (!this._scene) {
  37060. this._checkGamepadsStatus();
  37061. }
  37062. }
  37063. };
  37064. GamepadManager.prototype._stopMonitoringGamepads = function () {
  37065. this._isMonitoring = false;
  37066. };
  37067. /** @hidden */
  37068. GamepadManager.prototype._checkGamepadsStatus = function () {
  37069. var _this = this;
  37070. // Hack to be compatible Chrome
  37071. this._updateGamepadObjects();
  37072. for (var i in this._babylonGamepads) {
  37073. var gamepad = this._babylonGamepads[i];
  37074. if (!gamepad || !gamepad.isConnected) {
  37075. continue;
  37076. }
  37077. gamepad.update();
  37078. }
  37079. if (this._isMonitoring && !this._scene) {
  37080. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].QueueNewFrame(function () { _this._checkGamepadsStatus(); });
  37081. }
  37082. };
  37083. // This function is called only on Chrome, which does not properly support
  37084. // connection/disconnection events and forces you to recopy again the gamepad object
  37085. GamepadManager.prototype._updateGamepadObjects = function () {
  37086. var gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);
  37087. for (var i = 0; i < gamepads.length; i++) {
  37088. var gamepad = gamepads[i];
  37089. if (gamepad) {
  37090. if (!this._babylonGamepads[gamepad.index]) {
  37091. var newGamepad = this._addNewGamepad(gamepad);
  37092. this.onGamepadConnectedObservable.notifyObservers(newGamepad);
  37093. }
  37094. else {
  37095. // Forced to copy again this object for Chrome for unknown reason
  37096. this._babylonGamepads[i].browserGamepad = gamepad;
  37097. if (!this._babylonGamepads[i].isConnected) {
  37098. this._babylonGamepads[i]._isConnected = true;
  37099. this.onGamepadConnectedObservable.notifyObservers(this._babylonGamepads[i]);
  37100. }
  37101. }
  37102. }
  37103. }
  37104. };
  37105. return GamepadManager;
  37106. }());
  37107. /***/ }),
  37108. /***/ "./Gamepads/gamepadSceneComponent.ts":
  37109. /*!*******************************************!*\
  37110. !*** ./Gamepads/gamepadSceneComponent.ts ***!
  37111. \*******************************************/
  37112. /*! exports provided: GamepadSystemSceneComponent */
  37113. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37114. "use strict";
  37115. __webpack_require__.r(__webpack_exports__);
  37116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return GamepadSystemSceneComponent; });
  37117. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  37118. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  37119. /* harmony import */ var _gamepadManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gamepadManager */ "./Gamepads/gamepadManager.ts");
  37120. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  37121. /* harmony import */ var _Cameras_Inputs_freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraGamepadInput */ "./Cameras/Inputs/freeCameraGamepadInput.ts");
  37122. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  37123. /* harmony import */ var _Cameras_Inputs_arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraGamepadInput */ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts");
  37124. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "gamepadManager", {
  37125. get: function () {
  37126. if (!this._gamepadManager) {
  37127. this._gamepadManager = new _gamepadManager__WEBPACK_IMPORTED_MODULE_2__["GamepadManager"](this);
  37128. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GAMEPAD);
  37129. if (!component) {
  37130. component = new GamepadSystemSceneComponent(this);
  37131. this._addComponent(component);
  37132. }
  37133. }
  37134. return this._gamepadManager;
  37135. },
  37136. enumerable: true,
  37137. configurable: true
  37138. });
  37139. /**
  37140. * Adds a gamepad to the free camera inputs manager
  37141. */
  37142. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addGamepad = function () {
  37143. this.add(new _Cameras_Inputs_freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_4__["FreeCameraGamepadInput"]());
  37144. return this;
  37145. };
  37146. /**
  37147. * Adds a gamepad to the arc rotate camera inputs manager
  37148. */
  37149. _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["ArcRotateCameraInputsManager"].prototype.addGamepad = function () {
  37150. this.add(new _Cameras_Inputs_arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_6__["ArcRotateCameraGamepadInput"]());
  37151. return this;
  37152. };
  37153. /**
  37154. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  37155. */
  37156. var GamepadSystemSceneComponent = /** @class */ (function () {
  37157. /**
  37158. * Creates a new instance of the component for the given scene
  37159. * @param scene Defines the scene to register the component in
  37160. */
  37161. function GamepadSystemSceneComponent(scene) {
  37162. /**
  37163. * The component name helpfull to identify the component in the list of scene components.
  37164. */
  37165. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GAMEPAD;
  37166. this.scene = scene;
  37167. }
  37168. /**
  37169. * Registers the component in a given scene
  37170. */
  37171. GamepadSystemSceneComponent.prototype.register = function () {
  37172. this.scene._beforeCameraUpdateStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECAMERAUPDATE_GAMEPAD, this, this._beforeCameraUpdate);
  37173. };
  37174. /**
  37175. * Rebuilds the elements related to this component in case of
  37176. * context lost for instance.
  37177. */
  37178. GamepadSystemSceneComponent.prototype.rebuild = function () {
  37179. // Nothing to do for gamepads
  37180. };
  37181. /**
  37182. * Disposes the component and the associated ressources
  37183. */
  37184. GamepadSystemSceneComponent.prototype.dispose = function () {
  37185. var gamepadManager = this.scene._gamepadManager;
  37186. if (gamepadManager) {
  37187. gamepadManager.dispose();
  37188. this.scene._gamepadManager = null;
  37189. }
  37190. };
  37191. GamepadSystemSceneComponent.prototype._beforeCameraUpdate = function () {
  37192. var gamepadManager = this.scene._gamepadManager;
  37193. if (gamepadManager && gamepadManager._isMonitoring) {
  37194. gamepadManager._checkGamepadsStatus();
  37195. }
  37196. };
  37197. return GamepadSystemSceneComponent;
  37198. }());
  37199. /***/ }),
  37200. /***/ "./Gamepads/index.ts":
  37201. /*!***************************!*\
  37202. !*** ./Gamepads/index.ts ***!
  37203. \***************************/
  37204. /*! exports provided: StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad, DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController */
  37205. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37206. "use strict";
  37207. __webpack_require__.r(__webpack_exports__);
  37208. /* harmony import */ var _Controllers_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Controllers/index */ "./Gamepads/Controllers/index.ts");
  37209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  37210. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["GearVRController"]; });
  37211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["GenericController"]; });
  37212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["OculusTouchController"]; });
  37213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerType"]; });
  37214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerHelper"]; });
  37215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledController"]; });
  37216. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["ViveController"]; });
  37217. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["WebVRController"]; });
  37218. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["WindowsMotionController"]; });
  37219. /* harmony import */ var _gamepad__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gamepad */ "./Gamepads/gamepad.ts");
  37220. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["StickValues"]; });
  37221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["Gamepad"]; });
  37222. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["GenericPad"]; });
  37223. /* harmony import */ var _gamepadManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gamepadManager */ "./Gamepads/gamepadManager.ts");
  37224. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _gamepadManager__WEBPACK_IMPORTED_MODULE_2__["GamepadManager"]; });
  37225. /* harmony import */ var _gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./gamepadSceneComponent */ "./Gamepads/gamepadSceneComponent.ts");
  37226. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_3__["GamepadSystemSceneComponent"]; });
  37227. /* harmony import */ var _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  37228. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Button"]; });
  37229. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Dpad"]; });
  37230. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Pad"]; });
  37231. /***/ }),
  37232. /***/ "./Gamepads/xboxGamepad.ts":
  37233. /*!*********************************!*\
  37234. !*** ./Gamepads/xboxGamepad.ts ***!
  37235. \*********************************/
  37236. /*! exports provided: Xbox360Button, Xbox360Dpad, Xbox360Pad */
  37237. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37238. "use strict";
  37239. __webpack_require__.r(__webpack_exports__);
  37240. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return Xbox360Button; });
  37241. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return Xbox360Dpad; });
  37242. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return Xbox360Pad; });
  37243. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37244. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37245. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  37246. /**
  37247. * Defines supported buttons for XBox360 compatible gamepads
  37248. */
  37249. var Xbox360Button;
  37250. (function (Xbox360Button) {
  37251. /** A */
  37252. Xbox360Button[Xbox360Button["A"] = 0] = "A";
  37253. /** B */
  37254. Xbox360Button[Xbox360Button["B"] = 1] = "B";
  37255. /** X */
  37256. Xbox360Button[Xbox360Button["X"] = 2] = "X";
  37257. /** Y */
  37258. Xbox360Button[Xbox360Button["Y"] = 3] = "Y";
  37259. /** Start */
  37260. Xbox360Button[Xbox360Button["Start"] = 4] = "Start";
  37261. /** Back */
  37262. Xbox360Button[Xbox360Button["Back"] = 5] = "Back";
  37263. /** Left button */
  37264. Xbox360Button[Xbox360Button["LB"] = 6] = "LB";
  37265. /** Right button */
  37266. Xbox360Button[Xbox360Button["RB"] = 7] = "RB";
  37267. /** Left stick */
  37268. Xbox360Button[Xbox360Button["LeftStick"] = 8] = "LeftStick";
  37269. /** Right stick */
  37270. Xbox360Button[Xbox360Button["RightStick"] = 9] = "RightStick";
  37271. })(Xbox360Button || (Xbox360Button = {}));
  37272. /** Defines values for XBox360 DPad */
  37273. var Xbox360Dpad;
  37274. (function (Xbox360Dpad) {
  37275. /** Up */
  37276. Xbox360Dpad[Xbox360Dpad["Up"] = 0] = "Up";
  37277. /** Down */
  37278. Xbox360Dpad[Xbox360Dpad["Down"] = 1] = "Down";
  37279. /** Left */
  37280. Xbox360Dpad[Xbox360Dpad["Left"] = 2] = "Left";
  37281. /** Right */
  37282. Xbox360Dpad[Xbox360Dpad["Right"] = 3] = "Right";
  37283. })(Xbox360Dpad || (Xbox360Dpad = {}));
  37284. /**
  37285. * Defines a XBox360 gamepad
  37286. */
  37287. var Xbox360Pad = /** @class */ (function (_super) {
  37288. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Xbox360Pad, _super);
  37289. /**
  37290. * Creates a new XBox360 gamepad object
  37291. * @param id defines the id of this gamepad
  37292. * @param index defines its index
  37293. * @param gamepad defines the internal HTML gamepad object
  37294. * @param xboxOne defines if it is a XBox One gamepad
  37295. */
  37296. function Xbox360Pad(id, index, gamepad, xboxOne) {
  37297. if (xboxOne === void 0) { xboxOne = false; }
  37298. var _this = _super.call(this, id, index, gamepad, 0, 1, 2, 3) || this;
  37299. _this._leftTrigger = 0;
  37300. _this._rightTrigger = 0;
  37301. /** Observable raised when a button is pressed */
  37302. _this.onButtonDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37303. /** Observable raised when a button is released */
  37304. _this.onButtonUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37305. /** Observable raised when a pad is pressed */
  37306. _this.onPadDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37307. /** Observable raised when a pad is released */
  37308. _this.onPadUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37309. _this._buttonA = 0;
  37310. _this._buttonB = 0;
  37311. _this._buttonX = 0;
  37312. _this._buttonY = 0;
  37313. _this._buttonBack = 0;
  37314. _this._buttonStart = 0;
  37315. _this._buttonLB = 0;
  37316. _this._buttonRB = 0;
  37317. _this._buttonLeftStick = 0;
  37318. _this._buttonRightStick = 0;
  37319. _this._dPadUp = 0;
  37320. _this._dPadDown = 0;
  37321. _this._dPadLeft = 0;
  37322. _this._dPadRight = 0;
  37323. _this._isXboxOnePad = false;
  37324. _this.type = _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__["Gamepad"].XBOX;
  37325. _this._isXboxOnePad = xboxOne;
  37326. return _this;
  37327. }
  37328. /**
  37329. * Defines the callback to call when left trigger is pressed
  37330. * @param callback defines the callback to use
  37331. */
  37332. Xbox360Pad.prototype.onlefttriggerchanged = function (callback) {
  37333. this._onlefttriggerchanged = callback;
  37334. };
  37335. /**
  37336. * Defines the callback to call when right trigger is pressed
  37337. * @param callback defines the callback to use
  37338. */
  37339. Xbox360Pad.prototype.onrighttriggerchanged = function (callback) {
  37340. this._onrighttriggerchanged = callback;
  37341. };
  37342. Object.defineProperty(Xbox360Pad.prototype, "leftTrigger", {
  37343. /**
  37344. * Gets the left trigger value
  37345. */
  37346. get: function () {
  37347. return this._leftTrigger;
  37348. },
  37349. /**
  37350. * Sets the left trigger value
  37351. */
  37352. set: function (newValue) {
  37353. if (this._onlefttriggerchanged && this._leftTrigger !== newValue) {
  37354. this._onlefttriggerchanged(newValue);
  37355. }
  37356. this._leftTrigger = newValue;
  37357. },
  37358. enumerable: true,
  37359. configurable: true
  37360. });
  37361. Object.defineProperty(Xbox360Pad.prototype, "rightTrigger", {
  37362. /**
  37363. * Gets the right trigger value
  37364. */
  37365. get: function () {
  37366. return this._rightTrigger;
  37367. },
  37368. /**
  37369. * Sets the right trigger value
  37370. */
  37371. set: function (newValue) {
  37372. if (this._onrighttriggerchanged && this._rightTrigger !== newValue) {
  37373. this._onrighttriggerchanged(newValue);
  37374. }
  37375. this._rightTrigger = newValue;
  37376. },
  37377. enumerable: true,
  37378. configurable: true
  37379. });
  37380. /**
  37381. * Defines the callback to call when a button is pressed
  37382. * @param callback defines the callback to use
  37383. */
  37384. Xbox360Pad.prototype.onbuttondown = function (callback) {
  37385. this._onbuttondown = callback;
  37386. };
  37387. /**
  37388. * Defines the callback to call when a button is released
  37389. * @param callback defines the callback to use
  37390. */
  37391. Xbox360Pad.prototype.onbuttonup = function (callback) {
  37392. this._onbuttonup = callback;
  37393. };
  37394. /**
  37395. * Defines the callback to call when a pad is pressed
  37396. * @param callback defines the callback to use
  37397. */
  37398. Xbox360Pad.prototype.ondpaddown = function (callback) {
  37399. this._ondpaddown = callback;
  37400. };
  37401. /**
  37402. * Defines the callback to call when a pad is released
  37403. * @param callback defines the callback to use
  37404. */
  37405. Xbox360Pad.prototype.ondpadup = function (callback) {
  37406. this._ondpadup = callback;
  37407. };
  37408. Xbox360Pad.prototype._setButtonValue = function (newValue, currentValue, buttonType) {
  37409. if (newValue !== currentValue) {
  37410. if (newValue === 1) {
  37411. if (this._onbuttondown) {
  37412. this._onbuttondown(buttonType);
  37413. }
  37414. this.onButtonDownObservable.notifyObservers(buttonType);
  37415. }
  37416. if (newValue === 0) {
  37417. if (this._onbuttonup) {
  37418. this._onbuttonup(buttonType);
  37419. }
  37420. this.onButtonUpObservable.notifyObservers(buttonType);
  37421. }
  37422. }
  37423. return newValue;
  37424. };
  37425. Xbox360Pad.prototype._setDPadValue = function (newValue, currentValue, buttonType) {
  37426. if (newValue !== currentValue) {
  37427. if (newValue === 1) {
  37428. if (this._ondpaddown) {
  37429. this._ondpaddown(buttonType);
  37430. }
  37431. this.onPadDownObservable.notifyObservers(buttonType);
  37432. }
  37433. if (newValue === 0) {
  37434. if (this._ondpadup) {
  37435. this._ondpadup(buttonType);
  37436. }
  37437. this.onPadUpObservable.notifyObservers(buttonType);
  37438. }
  37439. }
  37440. return newValue;
  37441. };
  37442. Object.defineProperty(Xbox360Pad.prototype, "buttonA", {
  37443. /**
  37444. * Gets the value of the `A` button
  37445. */
  37446. get: function () {
  37447. return this._buttonA;
  37448. },
  37449. /**
  37450. * Sets the value of the `A` button
  37451. */
  37452. set: function (value) {
  37453. this._buttonA = this._setButtonValue(value, this._buttonA, Xbox360Button.A);
  37454. },
  37455. enumerable: true,
  37456. configurable: true
  37457. });
  37458. Object.defineProperty(Xbox360Pad.prototype, "buttonB", {
  37459. /**
  37460. * Gets the value of the `B` button
  37461. */
  37462. get: function () {
  37463. return this._buttonB;
  37464. },
  37465. /**
  37466. * Sets the value of the `B` button
  37467. */
  37468. set: function (value) {
  37469. this._buttonB = this._setButtonValue(value, this._buttonB, Xbox360Button.B);
  37470. },
  37471. enumerable: true,
  37472. configurable: true
  37473. });
  37474. Object.defineProperty(Xbox360Pad.prototype, "buttonX", {
  37475. /**
  37476. * Gets the value of the `X` button
  37477. */
  37478. get: function () {
  37479. return this._buttonX;
  37480. },
  37481. /**
  37482. * Sets the value of the `X` button
  37483. */
  37484. set: function (value) {
  37485. this._buttonX = this._setButtonValue(value, this._buttonX, Xbox360Button.X);
  37486. },
  37487. enumerable: true,
  37488. configurable: true
  37489. });
  37490. Object.defineProperty(Xbox360Pad.prototype, "buttonY", {
  37491. /**
  37492. * Gets the value of the `Y` button
  37493. */
  37494. get: function () {
  37495. return this._buttonY;
  37496. },
  37497. /**
  37498. * Sets the value of the `Y` button
  37499. */
  37500. set: function (value) {
  37501. this._buttonY = this._setButtonValue(value, this._buttonY, Xbox360Button.Y);
  37502. },
  37503. enumerable: true,
  37504. configurable: true
  37505. });
  37506. Object.defineProperty(Xbox360Pad.prototype, "buttonStart", {
  37507. /**
  37508. * Gets the value of the `Start` button
  37509. */
  37510. get: function () {
  37511. return this._buttonStart;
  37512. },
  37513. /**
  37514. * Sets the value of the `Start` button
  37515. */
  37516. set: function (value) {
  37517. this._buttonStart = this._setButtonValue(value, this._buttonStart, Xbox360Button.Start);
  37518. },
  37519. enumerable: true,
  37520. configurable: true
  37521. });
  37522. Object.defineProperty(Xbox360Pad.prototype, "buttonBack", {
  37523. /**
  37524. * Gets the value of the `Back` button
  37525. */
  37526. get: function () {
  37527. return this._buttonBack;
  37528. },
  37529. /**
  37530. * Sets the value of the `Back` button
  37531. */
  37532. set: function (value) {
  37533. this._buttonBack = this._setButtonValue(value, this._buttonBack, Xbox360Button.Back);
  37534. },
  37535. enumerable: true,
  37536. configurable: true
  37537. });
  37538. Object.defineProperty(Xbox360Pad.prototype, "buttonLB", {
  37539. /**
  37540. * Gets the value of the `Left` button
  37541. */
  37542. get: function () {
  37543. return this._buttonLB;
  37544. },
  37545. /**
  37546. * Sets the value of the `Left` button
  37547. */
  37548. set: function (value) {
  37549. this._buttonLB = this._setButtonValue(value, this._buttonLB, Xbox360Button.LB);
  37550. },
  37551. enumerable: true,
  37552. configurable: true
  37553. });
  37554. Object.defineProperty(Xbox360Pad.prototype, "buttonRB", {
  37555. /**
  37556. * Gets the value of the `Right` button
  37557. */
  37558. get: function () {
  37559. return this._buttonRB;
  37560. },
  37561. /**
  37562. * Sets the value of the `Right` button
  37563. */
  37564. set: function (value) {
  37565. this._buttonRB = this._setButtonValue(value, this._buttonRB, Xbox360Button.RB);
  37566. },
  37567. enumerable: true,
  37568. configurable: true
  37569. });
  37570. Object.defineProperty(Xbox360Pad.prototype, "buttonLeftStick", {
  37571. /**
  37572. * Gets the value of the Left joystick
  37573. */
  37574. get: function () {
  37575. return this._buttonLeftStick;
  37576. },
  37577. /**
  37578. * Sets the value of the Left joystick
  37579. */
  37580. set: function (value) {
  37581. this._buttonLeftStick = this._setButtonValue(value, this._buttonLeftStick, Xbox360Button.LeftStick);
  37582. },
  37583. enumerable: true,
  37584. configurable: true
  37585. });
  37586. Object.defineProperty(Xbox360Pad.prototype, "buttonRightStick", {
  37587. /**
  37588. * Gets the value of the Right joystick
  37589. */
  37590. get: function () {
  37591. return this._buttonRightStick;
  37592. },
  37593. /**
  37594. * Sets the value of the Right joystick
  37595. */
  37596. set: function (value) {
  37597. this._buttonRightStick = this._setButtonValue(value, this._buttonRightStick, Xbox360Button.RightStick);
  37598. },
  37599. enumerable: true,
  37600. configurable: true
  37601. });
  37602. Object.defineProperty(Xbox360Pad.prototype, "dPadUp", {
  37603. /**
  37604. * Gets the value of D-pad up
  37605. */
  37606. get: function () {
  37607. return this._dPadUp;
  37608. },
  37609. /**
  37610. * Sets the value of D-pad up
  37611. */
  37612. set: function (value) {
  37613. this._dPadUp = this._setDPadValue(value, this._dPadUp, Xbox360Dpad.Up);
  37614. },
  37615. enumerable: true,
  37616. configurable: true
  37617. });
  37618. Object.defineProperty(Xbox360Pad.prototype, "dPadDown", {
  37619. /**
  37620. * Gets the value of D-pad down
  37621. */
  37622. get: function () {
  37623. return this._dPadDown;
  37624. },
  37625. /**
  37626. * Sets the value of D-pad down
  37627. */
  37628. set: function (value) {
  37629. this._dPadDown = this._setDPadValue(value, this._dPadDown, Xbox360Dpad.Down);
  37630. },
  37631. enumerable: true,
  37632. configurable: true
  37633. });
  37634. Object.defineProperty(Xbox360Pad.prototype, "dPadLeft", {
  37635. /**
  37636. * Gets the value of D-pad left
  37637. */
  37638. get: function () {
  37639. return this._dPadLeft;
  37640. },
  37641. /**
  37642. * Sets the value of D-pad left
  37643. */
  37644. set: function (value) {
  37645. this._dPadLeft = this._setDPadValue(value, this._dPadLeft, Xbox360Dpad.Left);
  37646. },
  37647. enumerable: true,
  37648. configurable: true
  37649. });
  37650. Object.defineProperty(Xbox360Pad.prototype, "dPadRight", {
  37651. /**
  37652. * Gets the value of D-pad right
  37653. */
  37654. get: function () {
  37655. return this._dPadRight;
  37656. },
  37657. /**
  37658. * Sets the value of D-pad right
  37659. */
  37660. set: function (value) {
  37661. this._dPadRight = this._setDPadValue(value, this._dPadRight, Xbox360Dpad.Right);
  37662. },
  37663. enumerable: true,
  37664. configurable: true
  37665. });
  37666. /**
  37667. * Force the gamepad to synchronize with device values
  37668. */
  37669. Xbox360Pad.prototype.update = function () {
  37670. _super.prototype.update.call(this);
  37671. if (this._isXboxOnePad) {
  37672. this.buttonA = this.browserGamepad.buttons[0].value;
  37673. this.buttonB = this.browserGamepad.buttons[1].value;
  37674. this.buttonX = this.browserGamepad.buttons[2].value;
  37675. this.buttonY = this.browserGamepad.buttons[3].value;
  37676. this.buttonLB = this.browserGamepad.buttons[4].value;
  37677. this.buttonRB = this.browserGamepad.buttons[5].value;
  37678. this.leftTrigger = this.browserGamepad.axes[2];
  37679. this.rightTrigger = this.browserGamepad.axes[5];
  37680. this.buttonBack = this.browserGamepad.buttons[9].value;
  37681. this.buttonStart = this.browserGamepad.buttons[8].value;
  37682. this.buttonLeftStick = this.browserGamepad.buttons[6].value;
  37683. this.buttonRightStick = this.browserGamepad.buttons[7].value;
  37684. this.dPadUp = this.browserGamepad.buttons[11].value;
  37685. this.dPadDown = this.browserGamepad.buttons[12].value;
  37686. this.dPadLeft = this.browserGamepad.buttons[13].value;
  37687. this.dPadRight = this.browserGamepad.buttons[14].value;
  37688. }
  37689. else {
  37690. this.buttonA = this.browserGamepad.buttons[0].value;
  37691. this.buttonB = this.browserGamepad.buttons[1].value;
  37692. this.buttonX = this.browserGamepad.buttons[2].value;
  37693. this.buttonY = this.browserGamepad.buttons[3].value;
  37694. this.buttonLB = this.browserGamepad.buttons[4].value;
  37695. this.buttonRB = this.browserGamepad.buttons[5].value;
  37696. this.leftTrigger = this.browserGamepad.buttons[6].value;
  37697. this.rightTrigger = this.browserGamepad.buttons[7].value;
  37698. this.buttonBack = this.browserGamepad.buttons[8].value;
  37699. this.buttonStart = this.browserGamepad.buttons[9].value;
  37700. this.buttonLeftStick = this.browserGamepad.buttons[10].value;
  37701. this.buttonRightStick = this.browserGamepad.buttons[11].value;
  37702. this.dPadUp = this.browserGamepad.buttons[12].value;
  37703. this.dPadDown = this.browserGamepad.buttons[13].value;
  37704. this.dPadLeft = this.browserGamepad.buttons[14].value;
  37705. this.dPadRight = this.browserGamepad.buttons[15].value;
  37706. }
  37707. };
  37708. /**
  37709. * Disposes the gamepad
  37710. */
  37711. Xbox360Pad.prototype.dispose = function () {
  37712. _super.prototype.dispose.call(this);
  37713. this.onButtonDownObservable.clear();
  37714. this.onButtonUpObservable.clear();
  37715. this.onPadDownObservable.clear();
  37716. this.onPadUpObservable.clear();
  37717. };
  37718. return Xbox360Pad;
  37719. }(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__["Gamepad"]));
  37720. /***/ }),
  37721. /***/ "./Gizmos/axisDragGizmo.ts":
  37722. /*!*********************************!*\
  37723. !*** ./Gizmos/axisDragGizmo.ts ***!
  37724. \*********************************/
  37725. /*! exports provided: AxisDragGizmo */
  37726. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37727. "use strict";
  37728. __webpack_require__.r(__webpack_exports__);
  37729. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return AxisDragGizmo; });
  37730. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37731. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37732. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  37733. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  37734. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  37735. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  37736. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  37737. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  37738. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  37739. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  37740. /**
  37741. * Single axis drag gizmo
  37742. */
  37743. var AxisDragGizmo = /** @class */ (function (_super) {
  37744. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AxisDragGizmo, _super);
  37745. /**
  37746. * Creates an AxisDragGizmo
  37747. * @param gizmoLayer The utility layer the gizmo will be added to
  37748. * @param dragAxis The axis which the gizmo will be able to drag on
  37749. * @param color The color of the gizmo
  37750. */
  37751. function AxisDragGizmo(dragAxis, color, gizmoLayer) {
  37752. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  37753. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_8__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  37754. var _this = _super.call(this, gizmoLayer) || this;
  37755. _this._pointerObserver = null;
  37756. /**
  37757. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  37758. */
  37759. _this.snapDistance = 0;
  37760. /**
  37761. * Event that fires each time the gizmo snaps to a new location.
  37762. * * snapDistance is the the change in distance
  37763. */
  37764. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37765. // Create Material
  37766. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_9__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37767. coloredMaterial.disableLighting = true;
  37768. coloredMaterial.emissiveColor = color;
  37769. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_9__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37770. hoverMaterial.disableLighting = true;
  37771. hoverMaterial.emissiveColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  37772. // Build mesh on root node
  37773. var arrow = AxisDragGizmo._CreateArrow(gizmoLayer.utilityLayerScene, coloredMaterial);
  37774. arrow.lookAt(_this._rootMesh.position.add(dragAxis));
  37775. arrow.scaling.scaleInPlace(1 / 3);
  37776. arrow.parent = _this._rootMesh;
  37777. var currentSnapDragDistance = 0;
  37778. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  37779. var tmpSnapEvent = { snapDistance: 0 };
  37780. // Add drag behavior to handle events when the gizmo is dragged
  37781. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_6__["PointerDragBehavior"]({ dragAxis: dragAxis });
  37782. _this.dragBehavior.moveAttached = false;
  37783. _this._rootMesh.addBehavior(_this.dragBehavior);
  37784. var localDelta = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  37785. var tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  37786. _this.dragBehavior.onDragObservable.add(function (event) {
  37787. if (_this.attachedMesh) {
  37788. // Convert delta to local translation if it has a parent
  37789. if (_this.attachedMesh.parent) {
  37790. _this.attachedMesh.parent.computeWorldMatrix().invertToRef(tmpMatrix);
  37791. tmpMatrix.setTranslationFromFloats(0, 0, 0);
  37792. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(event.delta, tmpMatrix, localDelta);
  37793. }
  37794. else {
  37795. localDelta.copyFrom(event.delta);
  37796. }
  37797. // Snapping logic
  37798. if (_this.snapDistance == 0) {
  37799. _this.attachedMesh.position.addInPlace(localDelta);
  37800. }
  37801. else {
  37802. currentSnapDragDistance += event.dragDistance;
  37803. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  37804. var dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  37805. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  37806. localDelta.normalizeToRef(tmpVector);
  37807. tmpVector.scaleInPlace(_this.snapDistance * dragSteps);
  37808. _this.attachedMesh.position.addInPlace(tmpVector);
  37809. tmpSnapEvent.snapDistance = _this.snapDistance * dragSteps;
  37810. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  37811. }
  37812. }
  37813. }
  37814. });
  37815. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  37816. if (_this._customMeshSet) {
  37817. return;
  37818. }
  37819. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  37820. var material = isHovered ? hoverMaterial : coloredMaterial;
  37821. _this._rootMesh.getChildMeshes().forEach(function (m) {
  37822. m.material = material;
  37823. if (m.color) {
  37824. m.color = material.emissiveColor;
  37825. }
  37826. });
  37827. });
  37828. return _this;
  37829. }
  37830. /** @hidden */
  37831. AxisDragGizmo._CreateArrow = function (scene, material) {
  37832. var arrow = new _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__["TransformNode"]("arrow", scene);
  37833. var cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder("cylinder", { diameterTop: 0, height: 1.5, diameterBottom: 0.75, tessellation: 96 }, scene);
  37834. 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);
  37835. line.color = material.emissiveColor;
  37836. cylinder.parent = arrow;
  37837. line.parent = arrow;
  37838. // Position arrow pointing in its drag axis
  37839. cylinder.scaling.scaleInPlace(0.05);
  37840. cylinder.material = material;
  37841. cylinder.rotation.x = Math.PI / 2;
  37842. cylinder.position.z += 0.3;
  37843. line.scaling.scaleInPlace(0.26);
  37844. line.rotation.x = Math.PI / 2;
  37845. line.material = material;
  37846. return arrow;
  37847. };
  37848. /** @hidden */
  37849. AxisDragGizmo._CreateArrowInstance = function (scene, arrow) {
  37850. var instance = new _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__["TransformNode"]("arrow", scene);
  37851. for (var _i = 0, _a = arrow.getChildMeshes(); _i < _a.length; _i++) {
  37852. var mesh = _a[_i];
  37853. var childInstance = mesh.createInstance(mesh.name);
  37854. childInstance.parent = instance;
  37855. }
  37856. return instance;
  37857. };
  37858. AxisDragGizmo.prototype._attachedMeshChanged = function (value) {
  37859. if (this.dragBehavior) {
  37860. this.dragBehavior.enabled = value ? true : false;
  37861. }
  37862. };
  37863. /**
  37864. * Disposes of the gizmo
  37865. */
  37866. AxisDragGizmo.prototype.dispose = function () {
  37867. this.onSnapObservable.clear();
  37868. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  37869. this.dragBehavior.detach();
  37870. _super.prototype.dispose.call(this);
  37871. };
  37872. return AxisDragGizmo;
  37873. }(_gizmo__WEBPACK_IMPORTED_MODULE_7__["Gizmo"]));
  37874. /***/ }),
  37875. /***/ "./Gizmos/axisScaleGizmo.ts":
  37876. /*!**********************************!*\
  37877. !*** ./Gizmos/axisScaleGizmo.ts ***!
  37878. \**********************************/
  37879. /*! exports provided: AxisScaleGizmo */
  37880. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37881. "use strict";
  37882. __webpack_require__.r(__webpack_exports__);
  37883. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return AxisScaleGizmo; });
  37884. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37885. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37886. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  37887. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  37888. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  37889. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  37890. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  37891. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  37892. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  37893. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  37894. /**
  37895. * Single axis scale gizmo
  37896. */
  37897. var AxisScaleGizmo = /** @class */ (function (_super) {
  37898. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AxisScaleGizmo, _super);
  37899. /**
  37900. * Creates an AxisScaleGizmo
  37901. * @param gizmoLayer The utility layer the gizmo will be added to
  37902. * @param dragAxis The axis which the gizmo will be able to scale on
  37903. * @param color The color of the gizmo
  37904. */
  37905. function AxisScaleGizmo(dragAxis, color, gizmoLayer) {
  37906. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  37907. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  37908. var _this = _super.call(this, gizmoLayer) || this;
  37909. _this._pointerObserver = null;
  37910. /**
  37911. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  37912. */
  37913. _this.snapDistance = 0;
  37914. /**
  37915. * Event that fires each time the gizmo snaps to a new location.
  37916. * * snapDistance is the the change in distance
  37917. */
  37918. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37919. /**
  37920. * If the scaling operation should be done on all axis (default: false)
  37921. */
  37922. _this.uniformScaling = false;
  37923. // Create Material
  37924. _this._coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37925. _this._coloredMaterial.disableLighting = true;
  37926. _this._coloredMaterial.emissiveColor = color;
  37927. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37928. hoverMaterial.disableLighting = true;
  37929. hoverMaterial.emissiveColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  37930. // Build mesh on root node
  37931. var arrow = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  37932. var arrowMesh = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_4__["BoxBuilder"].CreateBox("yPosMesh", { size: 0.4 }, gizmoLayer.utilityLayerScene);
  37933. 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);
  37934. arrowTail.color = _this._coloredMaterial.emissiveColor;
  37935. arrow.addChild(arrowMesh);
  37936. arrow.addChild(arrowTail);
  37937. // Position arrow pointing in its drag axis
  37938. arrowMesh.scaling.scaleInPlace(0.1);
  37939. arrowMesh.material = _this._coloredMaterial;
  37940. arrowMesh.rotation.x = Math.PI / 2;
  37941. arrowMesh.position.z += 0.3;
  37942. arrowTail.scaling.scaleInPlace(0.26);
  37943. arrowTail.rotation.x = Math.PI / 2;
  37944. arrowTail.material = _this._coloredMaterial;
  37945. arrow.lookAt(_this._rootMesh.position.add(dragAxis));
  37946. _this._rootMesh.addChild(arrow);
  37947. arrow.scaling.scaleInPlace(1 / 3);
  37948. // Add drag behavior to handle events when the gizmo is dragged
  37949. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_7__["PointerDragBehavior"]({ dragAxis: dragAxis });
  37950. _this.dragBehavior.moveAttached = false;
  37951. _this._rootMesh.addBehavior(_this.dragBehavior);
  37952. var currentSnapDragDistance = 0;
  37953. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  37954. var tmpSnapEvent = { snapDistance: 0 };
  37955. _this.dragBehavior.onDragObservable.add(function (event) {
  37956. if (_this.attachedMesh) {
  37957. // Snapping logic
  37958. var snapped = false;
  37959. var dragSteps = 0;
  37960. if (_this.uniformScaling) {
  37961. _this.attachedMesh.scaling.normalizeToRef(tmpVector);
  37962. if (tmpVector.y < 0) {
  37963. tmpVector.scaleInPlace(-1);
  37964. }
  37965. }
  37966. else {
  37967. tmpVector.copyFrom(dragAxis);
  37968. }
  37969. if (_this.snapDistance == 0) {
  37970. tmpVector.scaleToRef(event.dragDistance, tmpVector);
  37971. }
  37972. else {
  37973. currentSnapDragDistance += event.dragDistance;
  37974. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  37975. dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  37976. if (currentSnapDragDistance < 0) {
  37977. dragSteps *= -1;
  37978. }
  37979. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  37980. tmpVector.scaleToRef(_this.snapDistance * dragSteps, tmpVector);
  37981. snapped = true;
  37982. }
  37983. else {
  37984. tmpVector.scaleInPlace(0);
  37985. }
  37986. }
  37987. _this.attachedMesh.scaling.addInPlace(tmpVector);
  37988. if (snapped) {
  37989. tmpSnapEvent.snapDistance = _this.snapDistance * dragSteps;
  37990. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  37991. }
  37992. }
  37993. });
  37994. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  37995. if (_this._customMeshSet) {
  37996. return;
  37997. }
  37998. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  37999. var material = isHovered ? hoverMaterial : _this._coloredMaterial;
  38000. _this._rootMesh.getChildMeshes().forEach(function (m) {
  38001. m.material = material;
  38002. if (m.color) {
  38003. m.color = material.emissiveColor;
  38004. }
  38005. });
  38006. });
  38007. return _this;
  38008. }
  38009. AxisScaleGizmo.prototype._attachedMeshChanged = function (value) {
  38010. if (this.dragBehavior) {
  38011. this.dragBehavior.enabled = value ? true : false;
  38012. }
  38013. };
  38014. /**
  38015. * Disposes of the gizmo
  38016. */
  38017. AxisScaleGizmo.prototype.dispose = function () {
  38018. this.onSnapObservable.clear();
  38019. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  38020. this.dragBehavior.detach();
  38021. _super.prototype.dispose.call(this);
  38022. };
  38023. /**
  38024. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  38025. * @param mesh The mesh to replace the default mesh of the gizmo
  38026. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  38027. */
  38028. AxisScaleGizmo.prototype.setCustomMesh = function (mesh, useGizmoMaterial) {
  38029. var _this = this;
  38030. if (useGizmoMaterial === void 0) { useGizmoMaterial = false; }
  38031. _super.prototype.setCustomMesh.call(this, mesh);
  38032. if (useGizmoMaterial) {
  38033. this._rootMesh.getChildMeshes().forEach(function (m) {
  38034. m.material = _this._coloredMaterial;
  38035. if (m.color) {
  38036. m.color = _this._coloredMaterial.emissiveColor;
  38037. }
  38038. });
  38039. this._customMeshSet = false;
  38040. }
  38041. };
  38042. return AxisScaleGizmo;
  38043. }(_gizmo__WEBPACK_IMPORTED_MODULE_8__["Gizmo"]));
  38044. /***/ }),
  38045. /***/ "./Gizmos/boundingBoxGizmo.ts":
  38046. /*!************************************!*\
  38047. !*** ./Gizmos/boundingBoxGizmo.ts ***!
  38048. \************************************/
  38049. /*! exports provided: BoundingBoxGizmo */
  38050. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38051. "use strict";
  38052. __webpack_require__.r(__webpack_exports__);
  38053. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return BoundingBoxGizmo; });
  38054. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38055. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38056. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  38057. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38058. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  38059. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  38060. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  38061. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  38062. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  38063. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  38064. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38065. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38066. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  38067. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Misc/pivotTools */ "./Misc/pivotTools.ts");
  38068. /**
  38069. * Bounding box gizmo
  38070. */
  38071. var BoundingBoxGizmo = /** @class */ (function (_super) {
  38072. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BoundingBoxGizmo, _super);
  38073. /**
  38074. * Creates an BoundingBoxGizmo
  38075. * @param gizmoLayer The utility layer the gizmo will be added to
  38076. * @param color The color of the gizmo
  38077. */
  38078. function BoundingBoxGizmo(color, gizmoLayer) {
  38079. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Gray(); }
  38080. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_11__["UtilityLayerRenderer"].DefaultKeepDepthUtilityLayer; }
  38081. var _this = _super.call(this, gizmoLayer) || this;
  38082. _this._boundingDimensions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 1, 1);
  38083. _this._renderObserver = null;
  38084. _this._pointerObserver = null;
  38085. _this._scaleDragSpeed = 0.2;
  38086. _this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38087. _this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  38088. _this._tmpRotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  38089. /**
  38090. * 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)
  38091. */
  38092. _this.ignoreChildren = false;
  38093. /**
  38094. * 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)
  38095. */
  38096. _this.includeChildPredicate = null;
  38097. /**
  38098. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  38099. */
  38100. _this.rotationSphereSize = 0.1;
  38101. /**
  38102. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  38103. */
  38104. _this.scaleBoxSize = 0.1;
  38105. /**
  38106. * 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)
  38107. */
  38108. _this.fixedDragMeshScreenSize = false;
  38109. /**
  38110. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  38111. */
  38112. _this.fixedDragMeshScreenSizeDistanceFactor = 10;
  38113. /**
  38114. * Fired when a rotation sphere or scale box is dragged
  38115. */
  38116. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38117. /**
  38118. * Fired when a scale box is dragged
  38119. */
  38120. _this.onScaleBoxDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38121. /**
  38122. * Fired when a scale box drag is ended
  38123. */
  38124. _this.onScaleBoxDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38125. /**
  38126. * Fired when a rotation sphere is dragged
  38127. */
  38128. _this.onRotationSphereDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38129. /**
  38130. * Fired when a rotation sphere drag is ended
  38131. */
  38132. _this.onRotationSphereDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38133. /**
  38134. * 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)
  38135. */
  38136. _this.scalePivot = null;
  38137. _this._existingMeshScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  38138. // Dragging
  38139. _this._dragMesh = null;
  38140. _this.pointerDragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]();
  38141. // Do not update the gizmo's scale so it has a fixed size to the object its attached to
  38142. _this._updateScale = false;
  38143. _this._anchorMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("anchor", gizmoLayer.utilityLayerScene);
  38144. // Create Materials
  38145. _this.coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38146. _this.coloredMaterial.disableLighting = true;
  38147. _this.hoverColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38148. _this.hoverColoredMaterial.disableLighting = true;
  38149. // Build bounding box out of lines
  38150. _this._lineBoundingBox = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  38151. _this._lineBoundingBox.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38152. var lines = [];
  38153. 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));
  38154. 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));
  38155. 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));
  38156. 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));
  38157. 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));
  38158. 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));
  38159. 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));
  38160. 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));
  38161. 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));
  38162. 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));
  38163. 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));
  38164. 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));
  38165. lines.forEach(function (l) {
  38166. l.color = color;
  38167. l.position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-_this._boundingDimensions.x / 2, -_this._boundingDimensions.y / 2, -_this._boundingDimensions.z / 2));
  38168. l.isPickable = false;
  38169. _this._lineBoundingBox.addChild(l);
  38170. });
  38171. _this._rootMesh.addChild(_this._lineBoundingBox);
  38172. _this.setColor(color);
  38173. // Create rotation spheres
  38174. _this._rotateSpheresParent = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  38175. _this._rotateSpheresParent.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38176. var _loop_1 = function (i_1) {
  38177. var sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__["SphereBuilder"].CreateSphere("", { diameter: 1 }, gizmoLayer.utilityLayerScene);
  38178. sphere.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38179. sphere.material = this_1.coloredMaterial;
  38180. // Drag behavior
  38181. _dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]({});
  38182. _dragBehavior.moveAttached = false;
  38183. _dragBehavior.updateDragPlane = false;
  38184. sphere.addBehavior(_dragBehavior);
  38185. var startingTurnDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 0, 0);
  38186. var totalTurnAmountOfDrag = 0;
  38187. _dragBehavior.onDragStartObservable.add(function () {
  38188. startingTurnDirection.copyFrom(sphere.forward);
  38189. totalTurnAmountOfDrag = 0;
  38190. });
  38191. _dragBehavior.onDragObservable.add(function (event) {
  38192. _this.onRotationSphereDragObservable.notifyObservers({});
  38193. if (_this.attachedMesh) {
  38194. var originalParent = _this.attachedMesh.parent;
  38195. if (originalParent && (originalParent.scaling && originalParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  38196. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
  38197. return;
  38198. }
  38199. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(_this.attachedMesh);
  38200. var worldDragDirection = startingTurnDirection;
  38201. // Project the world right on to the drag plane
  38202. var toSub = event.dragPlaneNormal.scale(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(event.dragPlaneNormal, worldDragDirection));
  38203. var dragAxis = worldDragDirection.subtract(toSub).normalizeToNew();
  38204. // project drag delta on to the resulting drag axis and rotate based on that
  38205. var projectDist = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(dragAxis, event.delta) < 0 ? Math.abs(event.delta.length()) : -Math.abs(event.delta.length());
  38206. // Make rotation relative to size of mesh.
  38207. projectDist = (projectDist / _this._boundingDimensions.length()) * _this._anchorMesh.scaling.length();
  38208. // Rotate based on axis
  38209. if (!_this.attachedMesh.rotationQuaternion) {
  38210. _this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(_this.attachedMesh.rotation.y, _this.attachedMesh.rotation.x, _this.attachedMesh.rotation.z);
  38211. }
  38212. if (!_this._anchorMesh.rotationQuaternion) {
  38213. _this._anchorMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(_this._anchorMesh.rotation.y, _this._anchorMesh.rotation.x, _this._anchorMesh.rotation.z);
  38214. }
  38215. // Do not allow the object to turn more than a full circle
  38216. totalTurnAmountOfDrag += projectDist;
  38217. if (Math.abs(totalTurnAmountOfDrag) <= 2 * Math.PI) {
  38218. if (i_1 >= 8) {
  38219. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(0, 0, projectDist, _this._tmpQuaternion);
  38220. }
  38221. else if (i_1 >= 4) {
  38222. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(projectDist, 0, 0, _this._tmpQuaternion);
  38223. }
  38224. else {
  38225. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(0, projectDist, 0, _this._tmpQuaternion);
  38226. }
  38227. // Rotate around center of bounding box
  38228. _this._anchorMesh.addChild(_this.attachedMesh);
  38229. _this._anchorMesh.rotationQuaternion.multiplyToRef(_this._tmpQuaternion, _this._anchorMesh.rotationQuaternion);
  38230. _this._anchorMesh.removeChild(_this.attachedMesh);
  38231. _this.attachedMesh.setParent(originalParent);
  38232. }
  38233. _this.updateBoundingBox();
  38234. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(_this.attachedMesh);
  38235. }
  38236. _this._updateDummy();
  38237. });
  38238. // Selection/deselection
  38239. _dragBehavior.onDragStartObservable.add(function () {
  38240. _this.onDragStartObservable.notifyObservers({});
  38241. _this._selectNode(sphere);
  38242. });
  38243. _dragBehavior.onDragEndObservable.add(function () {
  38244. _this.onRotationSphereDragEndObservable.notifyObservers({});
  38245. _this._selectNode(null);
  38246. _this._updateDummy();
  38247. });
  38248. this_1._rotateSpheresParent.addChild(sphere);
  38249. };
  38250. var this_1 = this, _dragBehavior;
  38251. for (var i_1 = 0; i_1 < 12; i_1++) {
  38252. _loop_1(i_1);
  38253. }
  38254. _this._rootMesh.addChild(_this._rotateSpheresParent);
  38255. // Create scale cubes
  38256. _this._scaleBoxesParent = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  38257. _this._scaleBoxesParent.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38258. for (var i = 0; i < 2; i++) {
  38259. for (var j = 0; j < 2; j++) {
  38260. var _loop_2 = function () {
  38261. var box = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__["BoxBuilder"].CreateBox("", { size: 1 }, gizmoLayer.utilityLayerScene);
  38262. box.material = this_2.coloredMaterial;
  38263. // Dragging logic
  38264. var dragAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](i == 0 ? -1 : 1, j == 0 ? -1 : 1, k == 0 ? -1 : 1);
  38265. _dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]({ dragAxis: dragAxis });
  38266. _dragBehavior.moveAttached = false;
  38267. box.addBehavior(_dragBehavior);
  38268. _dragBehavior.onDragObservable.add(function (event) {
  38269. _this.onScaleBoxDragObservable.notifyObservers({});
  38270. if (_this.attachedMesh) {
  38271. var originalParent = _this.attachedMesh.parent;
  38272. if (originalParent && (originalParent.scaling && originalParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  38273. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
  38274. return;
  38275. }
  38276. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(_this.attachedMesh);
  38277. var relativeDragDistance = (event.dragDistance / _this._boundingDimensions.length()) * _this._anchorMesh.scaling.length();
  38278. var deltaScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](relativeDragDistance, relativeDragDistance, relativeDragDistance);
  38279. deltaScale.scaleInPlace(_this._scaleDragSpeed);
  38280. _this.updateBoundingBox();
  38281. if (_this.scalePivot) {
  38282. _this.attachedMesh.getWorldMatrix().getRotationMatrixToRef(_this._tmpRotationMatrix);
  38283. // Move anchor to desired pivot point (Bottom left corner + dimension/2)
  38284. _this._boundingDimensions.scaleToRef(0.5, _this._tmpVector);
  38285. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._tmpVector, _this._tmpRotationMatrix, _this._tmpVector);
  38286. _this._anchorMesh.position.subtractInPlace(_this._tmpVector);
  38287. _this._boundingDimensions.multiplyToRef(_this.scalePivot, _this._tmpVector);
  38288. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._tmpVector, _this._tmpRotationMatrix, _this._tmpVector);
  38289. _this._anchorMesh.position.addInPlace(_this._tmpVector);
  38290. }
  38291. else {
  38292. // Scale from the position of the opposite corner
  38293. box.absolutePosition.subtractToRef(_this._anchorMesh.position, _this._tmpVector);
  38294. _this._anchorMesh.position.subtractInPlace(_this._tmpVector);
  38295. }
  38296. _this._anchorMesh.addChild(_this.attachedMesh);
  38297. _this._anchorMesh.scaling.addInPlace(deltaScale);
  38298. if (_this._anchorMesh.scaling.x < 0 || _this._anchorMesh.scaling.y < 0 || _this._anchorMesh.scaling.z < 0) {
  38299. _this._anchorMesh.scaling.subtractInPlace(deltaScale);
  38300. }
  38301. _this._anchorMesh.removeChild(_this.attachedMesh);
  38302. _this.attachedMesh.setParent(originalParent);
  38303. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(_this.attachedMesh);
  38304. }
  38305. _this._updateDummy();
  38306. });
  38307. // Selection/deselection
  38308. _dragBehavior.onDragStartObservable.add(function () {
  38309. _this.onDragStartObservable.notifyObservers({});
  38310. _this._selectNode(box);
  38311. });
  38312. _dragBehavior.onDragEndObservable.add(function () {
  38313. _this.onScaleBoxDragEndObservable.notifyObservers({});
  38314. _this._selectNode(null);
  38315. _this._updateDummy();
  38316. });
  38317. this_2._scaleBoxesParent.addChild(box);
  38318. };
  38319. var this_2 = this, _dragBehavior;
  38320. for (var k = 0; k < 2; k++) {
  38321. _loop_2();
  38322. }
  38323. }
  38324. }
  38325. _this._rootMesh.addChild(_this._scaleBoxesParent);
  38326. // Hover color change
  38327. var pointerIds = new Array();
  38328. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  38329. if (!pointerIds[pointerInfo.event.pointerId]) {
  38330. _this._rotateSpheresParent.getChildMeshes().concat(_this._scaleBoxesParent.getChildMeshes()).forEach(function (mesh) {
  38331. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh == mesh) {
  38332. pointerIds[pointerInfo.event.pointerId] = mesh;
  38333. mesh.material = _this.hoverColoredMaterial;
  38334. }
  38335. });
  38336. }
  38337. else {
  38338. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh != pointerIds[pointerInfo.event.pointerId]) {
  38339. pointerIds[pointerInfo.event.pointerId].material = _this.coloredMaterial;
  38340. delete pointerIds[pointerInfo.event.pointerId];
  38341. }
  38342. }
  38343. });
  38344. // Update bounding box positions
  38345. _this._renderObserver = _this.gizmoLayer.originalScene.onBeforeRenderObservable.add(function () {
  38346. // Only update the bouding box if scaling has changed
  38347. if (_this.attachedMesh && !_this._existingMeshScale.equals(_this.attachedMesh.scaling)) {
  38348. _this.updateBoundingBox();
  38349. }
  38350. else if (_this.fixedDragMeshScreenSize) {
  38351. _this._updateRotationSpheres();
  38352. _this._updateScaleBoxes();
  38353. }
  38354. // If dragg mesh is enabled and dragging, update the attached mesh pose to match the drag mesh
  38355. if (_this._dragMesh && _this.attachedMesh && _this.pointerDragBehavior.dragging) {
  38356. _this._lineBoundingBox.position.rotateByQuaternionToRef(_this._rootMesh.rotationQuaternion, _this._tmpVector);
  38357. _this.attachedMesh.setAbsolutePosition(_this._dragMesh.position.add(_this._tmpVector.scale(-1)));
  38358. }
  38359. });
  38360. _this.updateBoundingBox();
  38361. return _this;
  38362. }
  38363. /**
  38364. * Sets the color of the bounding box gizmo
  38365. * @param color the color to set
  38366. */
  38367. BoundingBoxGizmo.prototype.setColor = function (color) {
  38368. this.coloredMaterial.emissiveColor = color;
  38369. this.hoverColoredMaterial.emissiveColor = color.clone().add(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.3, 0.3, 0.3));
  38370. this._lineBoundingBox.getChildren().forEach(function (l) {
  38371. if (l.color) {
  38372. l.color = color;
  38373. }
  38374. });
  38375. };
  38376. BoundingBoxGizmo.prototype._attachedMeshChanged = function (value) {
  38377. var _this = this;
  38378. if (value) {
  38379. // Reset anchor mesh to match attached mesh's scale
  38380. // This is needed to avoid invalid box/sphere position on first drag
  38381. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(value);
  38382. var originalParent = value.parent;
  38383. this._anchorMesh.addChild(value);
  38384. this._anchorMesh.removeChild(value);
  38385. value.setParent(originalParent);
  38386. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(value);
  38387. this.updateBoundingBox();
  38388. value.getChildMeshes(false).forEach(function (m) {
  38389. m.markAsDirty("scaling");
  38390. });
  38391. this.gizmoLayer.utilityLayerScene.onAfterRenderObservable.addOnce(function () {
  38392. _this._updateDummy();
  38393. });
  38394. }
  38395. };
  38396. BoundingBoxGizmo.prototype._selectNode = function (selectedMesh) {
  38397. this._rotateSpheresParent.getChildMeshes()
  38398. .concat(this._scaleBoxesParent.getChildMeshes()).forEach(function (m) {
  38399. m.isVisible = (!selectedMesh || m == selectedMesh);
  38400. });
  38401. };
  38402. /**
  38403. * Updates the bounding box information for the Gizmo
  38404. */
  38405. BoundingBoxGizmo.prototype.updateBoundingBox = function () {
  38406. if (this.attachedMesh) {
  38407. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(this.attachedMesh);
  38408. var originalParent = this.attachedMesh.parent;
  38409. this.attachedMesh.setParent(null);
  38410. this._update();
  38411. // Rotate based on axis
  38412. if (!this.attachedMesh.rotationQuaternion) {
  38413. this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.attachedMesh.rotation.y, this.attachedMesh.rotation.x, this.attachedMesh.rotation.z);
  38414. }
  38415. if (!this._anchorMesh.rotationQuaternion) {
  38416. this._anchorMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this._anchorMesh.rotation.y, this._anchorMesh.rotation.x, this._anchorMesh.rotation.z);
  38417. }
  38418. this._anchorMesh.rotationQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);
  38419. // Store original position and reset mesh to origin before computing the bounding box
  38420. this._tmpQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);
  38421. this._tmpVector.copyFrom(this.attachedMesh.position);
  38422. this.attachedMesh.rotationQuaternion.set(0, 0, 0, 1);
  38423. this.attachedMesh.position.set(0, 0, 0);
  38424. // Update bounding dimensions/positions
  38425. var boundingMinMax = this.attachedMesh.getHierarchyBoundingVectors(!this.ignoreChildren, this.includeChildPredicate);
  38426. boundingMinMax.max.subtractToRef(boundingMinMax.min, this._boundingDimensions);
  38427. // Update gizmo to match bounding box scaling and rotation
  38428. this._lineBoundingBox.scaling.copyFrom(this._boundingDimensions);
  38429. 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);
  38430. this._rotateSpheresParent.position.copyFrom(this._lineBoundingBox.position);
  38431. this._scaleBoxesParent.position.copyFrom(this._lineBoundingBox.position);
  38432. this._lineBoundingBox.computeWorldMatrix();
  38433. this._anchorMesh.position.copyFrom(this._lineBoundingBox.absolutePosition);
  38434. // restore position/rotation values
  38435. this.attachedMesh.rotationQuaternion.copyFrom(this._tmpQuaternion);
  38436. this.attachedMesh.position.copyFrom(this._tmpVector);
  38437. this.attachedMesh.setParent(originalParent);
  38438. }
  38439. this._updateRotationSpheres();
  38440. this._updateScaleBoxes();
  38441. if (this.attachedMesh) {
  38442. this._existingMeshScale.copyFrom(this.attachedMesh.scaling);
  38443. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(this.attachedMesh);
  38444. }
  38445. };
  38446. BoundingBoxGizmo.prototype._updateRotationSpheres = function () {
  38447. var rotateSpheres = this._rotateSpheresParent.getChildMeshes();
  38448. for (var i = 0; i < 3; i++) {
  38449. for (var j = 0; j < 2; j++) {
  38450. for (var k = 0; k < 2; k++) {
  38451. var index = ((i * 4) + (j * 2)) + k;
  38452. if (i == 0) {
  38453. rotateSpheres[index].position.set(this._boundingDimensions.x / 2, this._boundingDimensions.y * j, this._boundingDimensions.z * k);
  38454. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  38455. 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));
  38456. }
  38457. if (i == 1) {
  38458. rotateSpheres[index].position.set(this._boundingDimensions.x * j, this._boundingDimensions.y / 2, this._boundingDimensions.z * k);
  38459. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  38460. 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));
  38461. }
  38462. if (i == 2) {
  38463. rotateSpheres[index].position.set(this._boundingDimensions.x * j, this._boundingDimensions.y * k, this._boundingDimensions.z / 2);
  38464. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  38465. 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));
  38466. }
  38467. if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
  38468. rotateSpheres[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
  38469. var distanceFromCamera = this.rotationSphereSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
  38470. rotateSpheres[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);
  38471. }
  38472. else {
  38473. rotateSpheres[index].scaling.set(this.rotationSphereSize, this.rotationSphereSize, this.rotationSphereSize);
  38474. }
  38475. }
  38476. }
  38477. }
  38478. };
  38479. BoundingBoxGizmo.prototype._updateScaleBoxes = function () {
  38480. var scaleBoxes = this._scaleBoxesParent.getChildMeshes();
  38481. for (var i = 0; i < 2; i++) {
  38482. for (var j = 0; j < 2; j++) {
  38483. for (var k = 0; k < 2; k++) {
  38484. var index = ((i * 4) + (j * 2)) + k;
  38485. if (scaleBoxes[index]) {
  38486. scaleBoxes[index].position.set(this._boundingDimensions.x * i, this._boundingDimensions.y * j, this._boundingDimensions.z * k);
  38487. scaleBoxes[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  38488. if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
  38489. scaleBoxes[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
  38490. var distanceFromCamera = this.scaleBoxSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
  38491. scaleBoxes[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);
  38492. }
  38493. else {
  38494. scaleBoxes[index].scaling.set(this.scaleBoxSize, this.scaleBoxSize, this.scaleBoxSize);
  38495. }
  38496. }
  38497. }
  38498. }
  38499. }
  38500. };
  38501. /**
  38502. * Enables rotation on the specified axis and disables rotation on the others
  38503. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  38504. */
  38505. BoundingBoxGizmo.prototype.setEnabledRotationAxis = function (axis) {
  38506. this._rotateSpheresParent.getChildMeshes().forEach(function (m, i) {
  38507. if (i < 4) {
  38508. m.setEnabled(axis.indexOf("x") != -1);
  38509. }
  38510. else if (i < 8) {
  38511. m.setEnabled(axis.indexOf("y") != -1);
  38512. }
  38513. else {
  38514. m.setEnabled(axis.indexOf("z") != -1);
  38515. }
  38516. });
  38517. };
  38518. /**
  38519. * Enables/disables scaling
  38520. * @param enable if scaling should be enabled
  38521. */
  38522. BoundingBoxGizmo.prototype.setEnabledScaling = function (enable) {
  38523. this._scaleBoxesParent.getChildMeshes().forEach(function (m, i) {
  38524. m.setEnabled(enable);
  38525. });
  38526. };
  38527. BoundingBoxGizmo.prototype._updateDummy = function () {
  38528. if (this._dragMesh) {
  38529. this._dragMesh.position.copyFrom(this._lineBoundingBox.getAbsolutePosition());
  38530. this._dragMesh.scaling.copyFrom(this._lineBoundingBox.scaling);
  38531. this._dragMesh.rotationQuaternion.copyFrom(this._rootMesh.rotationQuaternion);
  38532. }
  38533. };
  38534. /**
  38535. * Enables a pointer drag behavior on the bounding box of the gizmo
  38536. */
  38537. BoundingBoxGizmo.prototype.enableDragBehavior = function () {
  38538. this._dragMesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].CreateBox("dummy", 1, this.gizmoLayer.utilityLayerScene);
  38539. this._dragMesh.visibility = 0;
  38540. this._dragMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38541. this.pointerDragBehavior.useObjectOrienationForDragging = false;
  38542. this._dragMesh.addBehavior(this.pointerDragBehavior);
  38543. };
  38544. /**
  38545. * Disposes of the gizmo
  38546. */
  38547. BoundingBoxGizmo.prototype.dispose = function () {
  38548. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  38549. this.gizmoLayer.originalScene.onBeforeRenderObservable.remove(this._renderObserver);
  38550. this._lineBoundingBox.dispose();
  38551. this._rotateSpheresParent.dispose();
  38552. this._scaleBoxesParent.dispose();
  38553. if (this._dragMesh) {
  38554. this._dragMesh.dispose();
  38555. }
  38556. _super.prototype.dispose.call(this);
  38557. };
  38558. /**
  38559. * 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)
  38560. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  38561. * @returns the bounding box mesh with the passed in mesh as a child
  38562. */
  38563. BoundingBoxGizmo.MakeNotPickableAndWrapInBoundingBox = function (mesh) {
  38564. var makeNotPickable = function (root) {
  38565. root.isPickable = false;
  38566. root.getChildMeshes().forEach(function (c) {
  38567. makeNotPickable(c);
  38568. });
  38569. };
  38570. makeNotPickable(mesh);
  38571. // Reset position to get boudning box from origin with no rotation
  38572. if (!mesh.rotationQuaternion) {
  38573. mesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(mesh.rotation.y, mesh.rotation.x, mesh.rotation.z);
  38574. }
  38575. var oldPos = mesh.position.clone();
  38576. var oldRot = mesh.rotationQuaternion.clone();
  38577. mesh.rotationQuaternion.set(0, 0, 0, 1);
  38578. mesh.position.set(0, 0, 0);
  38579. // Update bounding dimensions/positions
  38580. var box = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__["BoxBuilder"].CreateBox("box", { size: 1 }, mesh.getScene());
  38581. var boundingMinMax = mesh.getHierarchyBoundingVectors();
  38582. boundingMinMax.max.subtractToRef(boundingMinMax.min, box.scaling);
  38583. // Adjust scale to avoid undefined behavior when adding child
  38584. if (box.scaling.y === 0) {
  38585. box.scaling.y = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  38586. }
  38587. if (box.scaling.x === 0) {
  38588. box.scaling.x = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  38589. }
  38590. if (box.scaling.z === 0) {
  38591. box.scaling.z = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  38592. }
  38593. box.position.set((boundingMinMax.max.x + boundingMinMax.min.x) / 2, (boundingMinMax.max.y + boundingMinMax.min.y) / 2, (boundingMinMax.max.z + boundingMinMax.min.z) / 2);
  38594. // Restore original positions
  38595. mesh.addChild(box);
  38596. mesh.rotationQuaternion.copyFrom(oldRot);
  38597. mesh.position.copyFrom(oldPos);
  38598. // Reverse parenting
  38599. mesh.removeChild(box);
  38600. box.addChild(mesh);
  38601. box.visibility = 0;
  38602. return box;
  38603. };
  38604. /**
  38605. * CustomMeshes are not supported by this gizmo
  38606. * @param mesh The mesh to replace the default mesh of the gizmo
  38607. */
  38608. BoundingBoxGizmo.prototype.setCustomMesh = function (mesh) {
  38609. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Error("Custom meshes are not supported on this gizmo");
  38610. };
  38611. return BoundingBoxGizmo;
  38612. }(_gizmo__WEBPACK_IMPORTED_MODULE_10__["Gizmo"]));
  38613. /***/ }),
  38614. /***/ "./Gizmos/gizmo.ts":
  38615. /*!*************************!*\
  38616. !*** ./Gizmos/gizmo.ts ***!
  38617. \*************************/
  38618. /*! exports provided: Gizmo */
  38619. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38620. "use strict";
  38621. __webpack_require__.r(__webpack_exports__);
  38622. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return Gizmo; });
  38623. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38624. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  38625. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38626. /**
  38627. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  38628. */
  38629. var Gizmo = /** @class */ (function () {
  38630. /**
  38631. * Creates a gizmo
  38632. * @param gizmoLayer The utility layer the gizmo will be added to
  38633. */
  38634. function Gizmo(
  38635. /** The utility layer the gizmo will be added to */
  38636. gizmoLayer) {
  38637. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  38638. var _this = this;
  38639. this.gizmoLayer = gizmoLayer;
  38640. /**
  38641. * Ratio for the scale of the gizmo (Default: 1)
  38642. */
  38643. this.scaleRatio = 1;
  38644. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  38645. /**
  38646. * If a custom mesh has been set (Default: false)
  38647. */
  38648. this._customMeshSet = false;
  38649. /**
  38650. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  38651. */
  38652. this.updateGizmoRotationToMatchAttachedMesh = true;
  38653. /**
  38654. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  38655. */
  38656. this.updateGizmoPositionToMatchAttachedMesh = true;
  38657. /**
  38658. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  38659. */
  38660. this._updateScale = true;
  38661. this._interactionsEnabled = true;
  38662. this._tempVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  38663. this._rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]("gizmoRootNode", gizmoLayer.utilityLayerScene);
  38664. this._beforeRenderObserver = this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.add(function () {
  38665. _this._update();
  38666. });
  38667. this.attachedMesh = null;
  38668. }
  38669. Object.defineProperty(Gizmo.prototype, "attachedMesh", {
  38670. /**
  38671. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  38672. * * When set, interactions will be enabled
  38673. */
  38674. get: function () {
  38675. return this._attachedMesh;
  38676. },
  38677. set: function (value) {
  38678. this._attachedMesh = value;
  38679. this._rootMesh.setEnabled(value ? true : false);
  38680. this._attachedMeshChanged(value);
  38681. },
  38682. enumerable: true,
  38683. configurable: true
  38684. });
  38685. /**
  38686. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  38687. * @param mesh The mesh to replace the default mesh of the gizmo
  38688. */
  38689. Gizmo.prototype.setCustomMesh = function (mesh) {
  38690. if (mesh.getScene() != this.gizmoLayer.utilityLayerScene) {
  38691. throw "When setting a custom mesh on a gizmo, the custom meshes scene must be the same as the gizmos (eg. gizmo.gizmoLayer.utilityLayerScene)";
  38692. }
  38693. this._rootMesh.getChildMeshes().forEach(function (c) {
  38694. c.dispose();
  38695. });
  38696. mesh.parent = this._rootMesh;
  38697. this._customMeshSet = true;
  38698. };
  38699. Gizmo.prototype._attachedMeshChanged = function (value) {
  38700. };
  38701. /**
  38702. * @hidden
  38703. * Updates the gizmo to match the attached mesh's position/rotation
  38704. */
  38705. Gizmo.prototype._update = function () {
  38706. if (this.attachedMesh) {
  38707. if (this.updateGizmoRotationToMatchAttachedMesh) {
  38708. if (!this._rootMesh.rotationQuaternion) {
  38709. this._rootMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(this._rootMesh.rotation.y, this._rootMesh.rotation.x, this._rootMesh.rotation.z);
  38710. }
  38711. // Remove scaling before getting rotation matrix to get rotation matrix unmodified by scale
  38712. this._tempVector.copyFrom(this.attachedMesh.scaling);
  38713. if (this.attachedMesh.scaling.x < 0) {
  38714. this.attachedMesh.scaling.x *= -1;
  38715. }
  38716. if (this.attachedMesh.scaling.y < 0) {
  38717. this.attachedMesh.scaling.y *= -1;
  38718. }
  38719. if (this.attachedMesh.scaling.z < 0) {
  38720. this.attachedMesh.scaling.z *= -1;
  38721. }
  38722. this.attachedMesh.computeWorldMatrix().getRotationMatrixToRef(this._tmpMatrix);
  38723. this.attachedMesh.scaling.copyFrom(this._tempVector);
  38724. this.attachedMesh.computeWorldMatrix();
  38725. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._tmpMatrix, this._rootMesh.rotationQuaternion);
  38726. }
  38727. else if (this._rootMesh.rotationQuaternion) {
  38728. this._rootMesh.rotationQuaternion.set(0, 0, 0, 1);
  38729. }
  38730. if (this.updateGizmoPositionToMatchAttachedMesh) {
  38731. this._rootMesh.position.copyFrom(this.attachedMesh.absolutePosition);
  38732. }
  38733. if (this._updateScale && this.gizmoLayer.utilityLayerScene.activeCamera && this.attachedMesh) {
  38734. var cameraPosition = this.gizmoLayer.utilityLayerScene.activeCamera.globalPosition;
  38735. if (this.gizmoLayer.utilityLayerScene.activeCamera.devicePosition) {
  38736. cameraPosition = this.gizmoLayer.utilityLayerScene.activeCamera.devicePosition;
  38737. }
  38738. this._rootMesh.position.subtractToRef(cameraPosition, this._tempVector);
  38739. var dist = this._tempVector.length() * this.scaleRatio;
  38740. this._rootMesh.scaling.set(dist, dist, dist);
  38741. }
  38742. }
  38743. };
  38744. /**
  38745. * Disposes of the gizmo
  38746. */
  38747. Gizmo.prototype.dispose = function () {
  38748. this._rootMesh.dispose();
  38749. if (this._beforeRenderObserver) {
  38750. this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.remove(this._beforeRenderObserver);
  38751. }
  38752. };
  38753. return Gizmo;
  38754. }());
  38755. /***/ }),
  38756. /***/ "./Gizmos/gizmoManager.ts":
  38757. /*!********************************!*\
  38758. !*** ./Gizmos/gizmoManager.ts ***!
  38759. \********************************/
  38760. /*! exports provided: GizmoManager */
  38761. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38762. "use strict";
  38763. __webpack_require__.r(__webpack_exports__);
  38764. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return GizmoManager; });
  38765. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38766. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Events/pointerEvents */ "./Events/pointerEvents.ts");
  38767. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  38768. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38769. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38770. /* harmony import */ var _Behaviors_Meshes_sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/sixDofDragBehavior */ "./Behaviors/Meshes/sixDofDragBehavior.ts");
  38771. /* harmony import */ var _rotationGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./rotationGizmo */ "./Gizmos/rotationGizmo.ts");
  38772. /* harmony import */ var _positionGizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./positionGizmo */ "./Gizmos/positionGizmo.ts");
  38773. /* harmony import */ var _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scaleGizmo */ "./Gizmos/scaleGizmo.ts");
  38774. /* harmony import */ var _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./boundingBoxGizmo */ "./Gizmos/boundingBoxGizmo.ts");
  38775. /**
  38776. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  38777. */
  38778. var GizmoManager = /** @class */ (function () {
  38779. /**
  38780. * Instatiates a gizmo manager
  38781. * @param scene the scene to overlay the gizmos on top of
  38782. */
  38783. function GizmoManager(scene) {
  38784. var _this = this;
  38785. this.scene = scene;
  38786. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  38787. this.clearGizmoOnEmptyPointerEvent = false;
  38788. /** Fires an event when the manager is attached to a mesh */
  38789. this.onAttachedToMeshObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  38790. this._gizmosEnabled = { positionGizmo: false, rotationGizmo: false, scaleGizmo: false, boundingBoxGizmo: false };
  38791. this._pointerObserver = null;
  38792. this._attachedMesh = null;
  38793. this._boundingBoxColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].FromHexString("#0984e3");
  38794. /**
  38795. * When bounding box gizmo is enabled, this can be used to track drag/end events
  38796. */
  38797. this.boundingBoxDragBehavior = new _Behaviors_Meshes_sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_5__["SixDofDragBehavior"]();
  38798. /**
  38799. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  38800. */
  38801. this.attachableMeshes = null;
  38802. /**
  38803. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  38804. */
  38805. this.usePointerToAttachGizmos = true;
  38806. this._defaultKeepDepthUtilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__["UtilityLayerRenderer"](scene);
  38807. this._defaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  38808. this._defaultUtilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__["UtilityLayerRenderer"](scene);
  38809. this.gizmos = { positionGizmo: null, rotationGizmo: null, scaleGizmo: null, boundingBoxGizmo: null };
  38810. // Instatiate/dispose gizmos based on pointer actions
  38811. this._pointerObserver = scene.onPointerObservable.add(function (pointerInfo) {
  38812. if (!_this.usePointerToAttachGizmos) {
  38813. return;
  38814. }
  38815. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  38816. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh) {
  38817. var node = pointerInfo.pickInfo.pickedMesh;
  38818. if (_this.attachableMeshes == null) {
  38819. // Attach to the most parent node
  38820. while (node && node.parent != null) {
  38821. node = node.parent;
  38822. }
  38823. }
  38824. else {
  38825. // Attach to the parent node that is an attachableMesh
  38826. var found = false;
  38827. _this.attachableMeshes.forEach(function (mesh) {
  38828. if (node && (node == mesh || node.isDescendantOf(mesh))) {
  38829. node = mesh;
  38830. found = true;
  38831. }
  38832. });
  38833. if (!found) {
  38834. node = null;
  38835. }
  38836. }
  38837. if (node instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]) {
  38838. if (_this._attachedMesh != node) {
  38839. _this.attachToMesh(node);
  38840. }
  38841. }
  38842. else {
  38843. if (_this.clearGizmoOnEmptyPointerEvent) {
  38844. _this.attachToMesh(null);
  38845. }
  38846. }
  38847. }
  38848. else {
  38849. if (_this.clearGizmoOnEmptyPointerEvent) {
  38850. _this.attachToMesh(null);
  38851. }
  38852. }
  38853. }
  38854. });
  38855. }
  38856. /**
  38857. * Attaches a set of gizmos to the specified mesh
  38858. * @param mesh The mesh the gizmo's should be attached to
  38859. */
  38860. GizmoManager.prototype.attachToMesh = function (mesh) {
  38861. if (this._attachedMesh) {
  38862. this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
  38863. }
  38864. this._attachedMesh = mesh;
  38865. for (var key in this.gizmos) {
  38866. var gizmo = (this.gizmos[key]);
  38867. if (gizmo && this._gizmosEnabled[key]) {
  38868. gizmo.attachedMesh = mesh;
  38869. }
  38870. }
  38871. if (this.boundingBoxGizmoEnabled && this._attachedMesh) {
  38872. this._attachedMesh.addBehavior(this.boundingBoxDragBehavior);
  38873. }
  38874. this.onAttachedToMeshObservable.notifyObservers(mesh);
  38875. };
  38876. Object.defineProperty(GizmoManager.prototype, "positionGizmoEnabled", {
  38877. get: function () {
  38878. return this._gizmosEnabled.positionGizmo;
  38879. },
  38880. /**
  38881. * If the position gizmo is enabled
  38882. */
  38883. set: function (value) {
  38884. if (value) {
  38885. if (!this.gizmos.positionGizmo) {
  38886. this.gizmos.positionGizmo = new _positionGizmo__WEBPACK_IMPORTED_MODULE_7__["PositionGizmo"](this._defaultUtilityLayer);
  38887. }
  38888. this.gizmos.positionGizmo.attachedMesh = this._attachedMesh;
  38889. }
  38890. else if (this.gizmos.positionGizmo) {
  38891. this.gizmos.positionGizmo.attachedMesh = null;
  38892. }
  38893. this._gizmosEnabled.positionGizmo = value;
  38894. },
  38895. enumerable: true,
  38896. configurable: true
  38897. });
  38898. Object.defineProperty(GizmoManager.prototype, "rotationGizmoEnabled", {
  38899. get: function () {
  38900. return this._gizmosEnabled.rotationGizmo;
  38901. },
  38902. /**
  38903. * If the rotation gizmo is enabled
  38904. */
  38905. set: function (value) {
  38906. if (value) {
  38907. if (!this.gizmos.rotationGizmo) {
  38908. this.gizmos.rotationGizmo = new _rotationGizmo__WEBPACK_IMPORTED_MODULE_6__["RotationGizmo"](this._defaultUtilityLayer);
  38909. }
  38910. this.gizmos.rotationGizmo.attachedMesh = this._attachedMesh;
  38911. }
  38912. else if (this.gizmos.rotationGizmo) {
  38913. this.gizmos.rotationGizmo.attachedMesh = null;
  38914. }
  38915. this._gizmosEnabled.rotationGizmo = value;
  38916. },
  38917. enumerable: true,
  38918. configurable: true
  38919. });
  38920. Object.defineProperty(GizmoManager.prototype, "scaleGizmoEnabled", {
  38921. get: function () {
  38922. return this._gizmosEnabled.scaleGizmo;
  38923. },
  38924. /**
  38925. * If the scale gizmo is enabled
  38926. */
  38927. set: function (value) {
  38928. if (value) {
  38929. this.gizmos.scaleGizmo = this.gizmos.scaleGizmo || new _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__["ScaleGizmo"](this._defaultUtilityLayer);
  38930. this.gizmos.scaleGizmo.attachedMesh = this._attachedMesh;
  38931. }
  38932. else if (this.gizmos.scaleGizmo) {
  38933. this.gizmos.scaleGizmo.attachedMesh = null;
  38934. }
  38935. this._gizmosEnabled.scaleGizmo = value;
  38936. },
  38937. enumerable: true,
  38938. configurable: true
  38939. });
  38940. Object.defineProperty(GizmoManager.prototype, "boundingBoxGizmoEnabled", {
  38941. get: function () {
  38942. return this._gizmosEnabled.boundingBoxGizmo;
  38943. },
  38944. /**
  38945. * If the boundingBox gizmo is enabled
  38946. */
  38947. set: function (value) {
  38948. if (value) {
  38949. this.gizmos.boundingBoxGizmo = this.gizmos.boundingBoxGizmo || new _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_9__["BoundingBoxGizmo"](this._boundingBoxColor, this._defaultKeepDepthUtilityLayer);
  38950. this.gizmos.boundingBoxGizmo.attachedMesh = this._attachedMesh;
  38951. if (this._attachedMesh) {
  38952. this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
  38953. this._attachedMesh.addBehavior(this.boundingBoxDragBehavior);
  38954. }
  38955. }
  38956. else if (this.gizmos.boundingBoxGizmo) {
  38957. this.gizmos.boundingBoxGizmo.attachedMesh = null;
  38958. }
  38959. this._gizmosEnabled.boundingBoxGizmo = value;
  38960. },
  38961. enumerable: true,
  38962. configurable: true
  38963. });
  38964. /**
  38965. * Disposes of the gizmo manager
  38966. */
  38967. GizmoManager.prototype.dispose = function () {
  38968. this.scene.onPointerObservable.remove(this._pointerObserver);
  38969. for (var key in this.gizmos) {
  38970. var gizmo = (this.gizmos[key]);
  38971. if (gizmo) {
  38972. gizmo.dispose();
  38973. }
  38974. }
  38975. this._defaultKeepDepthUtilityLayer.dispose();
  38976. this._defaultUtilityLayer.dispose();
  38977. this.boundingBoxDragBehavior.detach();
  38978. this.onAttachedToMeshObservable.clear();
  38979. };
  38980. return GizmoManager;
  38981. }());
  38982. /***/ }),
  38983. /***/ "./Gizmos/index.ts":
  38984. /*!*************************!*\
  38985. !*** ./Gizmos/index.ts ***!
  38986. \*************************/
  38987. /*! exports provided: AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, LightGizmo */
  38988. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38989. "use strict";
  38990. __webpack_require__.r(__webpack_exports__);
  38991. /* harmony import */ var _axisDragGizmo__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  38992. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _axisDragGizmo__WEBPACK_IMPORTED_MODULE_0__["AxisDragGizmo"]; });
  38993. /* harmony import */ var _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./axisScaleGizmo */ "./Gizmos/axisScaleGizmo.ts");
  38994. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_1__["AxisScaleGizmo"]; });
  38995. /* harmony import */ var _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boundingBoxGizmo */ "./Gizmos/boundingBoxGizmo.ts");
  38996. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_2__["BoundingBoxGizmo"]; });
  38997. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38998. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _gizmo__WEBPACK_IMPORTED_MODULE_3__["Gizmo"]; });
  38999. /* harmony import */ var _gizmoManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmoManager */ "./Gizmos/gizmoManager.ts");
  39000. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _gizmoManager__WEBPACK_IMPORTED_MODULE_4__["GizmoManager"]; });
  39001. /* harmony import */ var _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./planeRotationGizmo */ "./Gizmos/planeRotationGizmo.ts");
  39002. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__["PlaneRotationGizmo"]; });
  39003. /* harmony import */ var _positionGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./positionGizmo */ "./Gizmos/positionGizmo.ts");
  39004. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _positionGizmo__WEBPACK_IMPORTED_MODULE_6__["PositionGizmo"]; });
  39005. /* harmony import */ var _rotationGizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./rotationGizmo */ "./Gizmos/rotationGizmo.ts");
  39006. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _rotationGizmo__WEBPACK_IMPORTED_MODULE_7__["RotationGizmo"]; });
  39007. /* harmony import */ var _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scaleGizmo */ "./Gizmos/scaleGizmo.ts");
  39008. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__["ScaleGizmo"]; });
  39009. /* harmony import */ var _lightGizmo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./lightGizmo */ "./Gizmos/lightGizmo.ts");
  39010. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return _lightGizmo__WEBPACK_IMPORTED_MODULE_9__["LightGizmo"]; });
  39011. /***/ }),
  39012. /***/ "./Gizmos/lightGizmo.ts":
  39013. /*!******************************!*\
  39014. !*** ./Gizmos/lightGizmo.ts ***!
  39015. \******************************/
  39016. /*! exports provided: LightGizmo */
  39017. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39018. "use strict";
  39019. __webpack_require__.r(__webpack_exports__);
  39020. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return LightGizmo; });
  39021. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39022. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39023. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  39024. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39025. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39026. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  39027. /**
  39028. * Gizmo that enables viewing a light
  39029. */
  39030. var LightGizmo = /** @class */ (function (_super) {
  39031. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LightGizmo, _super);
  39032. /**
  39033. * Creates a LightGizmo
  39034. * @param gizmoLayer The utility layer the gizmo will be added to
  39035. */
  39036. function LightGizmo(gizmoLayer) {
  39037. var _this = _super.call(this, gizmoLayer) || this;
  39038. _this._light = null;
  39039. _this._box = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateCylinder("light", 0.02, 0, 0.02, 16, 1, _this.gizmoLayer.utilityLayerScene);
  39040. _this._box.rotation.x = -Math.PI / 2;
  39041. _this._box.bakeCurrentTransformIntoVertices();
  39042. _this._box.material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("", _this.gizmoLayer.utilityLayerScene);
  39043. _this._box.material.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Yellow();
  39044. _this._rootMesh.addChild(_this._box);
  39045. _this.attachedMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]("", _this.gizmoLayer.utilityLayerScene);
  39046. return _this;
  39047. }
  39048. Object.defineProperty(LightGizmo.prototype, "light", {
  39049. get: function () {
  39050. return this._light;
  39051. },
  39052. /**
  39053. * The light that the gizmo is attached to
  39054. */
  39055. set: function (light) {
  39056. this._light = light;
  39057. if (light.position) {
  39058. this.attachedMesh.position.copyFrom(light.position);
  39059. }
  39060. if (light.direction) {
  39061. this._box.setDirection(light.direction);
  39062. }
  39063. },
  39064. enumerable: true,
  39065. configurable: true
  39066. });
  39067. /**
  39068. * @hidden
  39069. * Updates the gizmo to match the attached mesh's position/rotation
  39070. */
  39071. LightGizmo.prototype._update = function () {
  39072. _super.prototype._update.call(this);
  39073. if (!this._light) {
  39074. return;
  39075. }
  39076. if (this._light.position) {
  39077. this._light.position.copyFrom(this.attachedMesh.position);
  39078. }
  39079. if (this._light.direction) {
  39080. this._light.direction.copyFrom(this._box.forward);
  39081. }
  39082. if (!this._light.isEnabled()) {
  39083. this._box.material.emissiveColor.set(0, 0, 0);
  39084. }
  39085. else {
  39086. this._box.material.emissiveColor.set(1, 1, 1);
  39087. }
  39088. };
  39089. return LightGizmo;
  39090. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  39091. /***/ }),
  39092. /***/ "./Gizmos/planeRotationGizmo.ts":
  39093. /*!**************************************!*\
  39094. !*** ./Gizmos/planeRotationGizmo.ts ***!
  39095. \**************************************/
  39096. /*! exports provided: PlaneRotationGizmo */
  39097. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39098. "use strict";
  39099. __webpack_require__.r(__webpack_exports__);
  39100. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return PlaneRotationGizmo; });
  39101. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39102. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39103. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39104. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  39105. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39106. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  39107. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39108. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  39109. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  39110. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  39111. /**
  39112. * Single plane rotation gizmo
  39113. */
  39114. var PlaneRotationGizmo = /** @class */ (function (_super) {
  39115. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlaneRotationGizmo, _super);
  39116. /**
  39117. * Creates a PlaneRotationGizmo
  39118. * @param gizmoLayer The utility layer the gizmo will be added to
  39119. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  39120. * @param color The color of the gizmo
  39121. * @param tessellation Amount of tessellation to be used when creating rotation circles
  39122. */
  39123. function PlaneRotationGizmo(planeNormal, color, gizmoLayer, tessellation) {
  39124. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  39125. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  39126. if (tessellation === void 0) { tessellation = 32; }
  39127. var _this = _super.call(this, gizmoLayer) || this;
  39128. _this._pointerObserver = null;
  39129. /**
  39130. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  39131. */
  39132. _this.snapDistance = 0;
  39133. /**
  39134. * Event that fires each time the gizmo snaps to a new location.
  39135. * * snapDistance is the the change in distance
  39136. */
  39137. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  39138. // Create Material
  39139. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  39140. coloredMaterial.disableLighting = true;
  39141. coloredMaterial.emissiveColor = color;
  39142. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  39143. hoverMaterial.disableLighting = true;
  39144. hoverMaterial.emissiveColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  39145. // Build mesh on root node
  39146. var parentMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  39147. // Create circle out of lines
  39148. var radius = 0.8;
  39149. var points = new Array();
  39150. for (var i = 0; i < tessellation; i++) {
  39151. var radian = (2 * Math.PI) * (i / (tessellation - 1));
  39152. points.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](radius * Math.sin(radian), 0, radius * Math.cos(radian)));
  39153. }
  39154. var rotationMesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreateLines("", points, gizmoLayer.utilityLayerScene);
  39155. rotationMesh.color = coloredMaterial.emissiveColor;
  39156. // Position arrow pointing in its drag axis
  39157. rotationMesh.scaling.scaleInPlace(0.26);
  39158. rotationMesh.material = coloredMaterial;
  39159. rotationMesh.rotation.x = Math.PI / 2;
  39160. parentMesh.addChild(rotationMesh);
  39161. parentMesh.lookAt(_this._rootMesh.position.add(planeNormal));
  39162. _this._rootMesh.addChild(parentMesh);
  39163. parentMesh.scaling.scaleInPlace(1 / 3);
  39164. // Add drag behavior to handle events when the gizmo is dragged
  39165. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]({ dragPlaneNormal: planeNormal });
  39166. _this.dragBehavior.moveAttached = false;
  39167. _this.dragBehavior.maxDragAngle = Math.PI * 9 / 20;
  39168. _this.dragBehavior._useAlternatePickedPointAboveMaxDragAngle = true;
  39169. _this._rootMesh.addBehavior(_this.dragBehavior);
  39170. var lastDragPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  39171. _this.dragBehavior.onDragStartObservable.add(function (e) {
  39172. if (_this.attachedMesh) {
  39173. lastDragPosition.copyFrom(e.dragPlanePoint);
  39174. }
  39175. });
  39176. var rotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  39177. var planeNormalTowardsCamera = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  39178. var localPlaneNormalTowardsCamera = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  39179. var tmpSnapEvent = { snapDistance: 0 };
  39180. var currentSnapDragDistance = 0;
  39181. var tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  39182. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  39183. var amountToRotate = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  39184. _this.dragBehavior.onDragObservable.add(function (event) {
  39185. if (_this.attachedMesh) {
  39186. if (!_this.attachedMesh.rotationQuaternion) {
  39187. _this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRoll(_this.attachedMesh.rotation.y, _this.attachedMesh.rotation.x, _this.attachedMesh.rotation.z);
  39188. }
  39189. // Calc angle over full 360 degree (https://stackoverflow.com/questions/43493711/the-angle-between-two-3d-vectors-with-a-result-range-0-360)
  39190. var newVector = event.dragPlanePoint.subtract(_this.attachedMesh.absolutePosition).normalize();
  39191. var originalVector = lastDragPosition.subtract(_this.attachedMesh.absolutePosition).normalize();
  39192. var cross = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(newVector, originalVector);
  39193. var dot = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(newVector, originalVector);
  39194. var angle = Math.atan2(cross.length(), dot);
  39195. planeNormalTowardsCamera.copyFrom(planeNormal);
  39196. localPlaneNormalTowardsCamera.copyFrom(planeNormal);
  39197. if (_this.updateGizmoRotationToMatchAttachedMesh) {
  39198. _this.attachedMesh.rotationQuaternion.toRotationMatrix(rotationMatrix);
  39199. localPlaneNormalTowardsCamera = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(planeNormalTowardsCamera, rotationMatrix);
  39200. }
  39201. // Flip up vector depending on which side the camera is on
  39202. if (gizmoLayer.utilityLayerScene.activeCamera) {
  39203. var camVec = gizmoLayer.utilityLayerScene.activeCamera.position.subtract(_this.attachedMesh.position);
  39204. if (_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(camVec, localPlaneNormalTowardsCamera) > 0) {
  39205. planeNormalTowardsCamera.scaleInPlace(-1);
  39206. localPlaneNormalTowardsCamera.scaleInPlace(-1);
  39207. }
  39208. }
  39209. var halfCircleSide = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(localPlaneNormalTowardsCamera, cross) > 0.0;
  39210. if (halfCircleSide) {
  39211. angle = -angle;
  39212. }
  39213. // Snapping logic
  39214. var snapped = false;
  39215. if (_this.snapDistance != 0) {
  39216. currentSnapDragDistance += angle;
  39217. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  39218. var dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  39219. if (currentSnapDragDistance < 0) {
  39220. dragSteps *= -1;
  39221. }
  39222. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  39223. angle = _this.snapDistance * dragSteps;
  39224. snapped = true;
  39225. }
  39226. else {
  39227. angle = 0;
  39228. }
  39229. }
  39230. // If the mesh has a parent, convert needed world rotation to local rotation
  39231. tmpMatrix.reset();
  39232. if (_this.attachedMesh.parent) {
  39233. _this.attachedMesh.parent.computeWorldMatrix().invertToRef(tmpMatrix);
  39234. tmpMatrix.getRotationMatrixToRef(tmpMatrix);
  39235. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(planeNormalTowardsCamera, tmpMatrix, planeNormalTowardsCamera);
  39236. }
  39237. // Convert angle and axis to quaternion (http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm)
  39238. var quaternionCoefficient = Math.sin(angle / 2);
  39239. amountToRotate.set(planeNormalTowardsCamera.x * quaternionCoefficient, planeNormalTowardsCamera.y * quaternionCoefficient, planeNormalTowardsCamera.z * quaternionCoefficient, Math.cos(angle / 2));
  39240. // 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
  39241. if (tmpMatrix.determinant() > 0) {
  39242. amountToRotate.toEulerAnglesToRef(tmpVector);
  39243. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(tmpVector.y, -tmpVector.x, -tmpVector.z, amountToRotate);
  39244. }
  39245. if (_this.updateGizmoRotationToMatchAttachedMesh) {
  39246. // Rotate selected mesh quaternion over fixed axis
  39247. _this.attachedMesh.rotationQuaternion.multiplyToRef(amountToRotate, _this.attachedMesh.rotationQuaternion);
  39248. }
  39249. else {
  39250. // Rotate selected mesh quaternion over rotated axis
  39251. amountToRotate.multiplyToRef(_this.attachedMesh.rotationQuaternion, _this.attachedMesh.rotationQuaternion);
  39252. }
  39253. lastDragPosition.copyFrom(event.dragPlanePoint);
  39254. if (snapped) {
  39255. tmpSnapEvent.snapDistance = angle;
  39256. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  39257. }
  39258. }
  39259. });
  39260. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  39261. if (_this._customMeshSet) {
  39262. return;
  39263. }
  39264. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  39265. var material = isHovered ? hoverMaterial : coloredMaterial;
  39266. _this._rootMesh.getChildMeshes().forEach(function (m) {
  39267. m.material = material;
  39268. if (m.color) {
  39269. m.color = material.emissiveColor;
  39270. }
  39271. });
  39272. });
  39273. return _this;
  39274. }
  39275. PlaneRotationGizmo.prototype._attachedMeshChanged = function (value) {
  39276. if (this.dragBehavior) {
  39277. this.dragBehavior.enabled = value ? true : false;
  39278. }
  39279. };
  39280. /**
  39281. * Disposes of the gizmo
  39282. */
  39283. PlaneRotationGizmo.prototype.dispose = function () {
  39284. this.onSnapObservable.clear();
  39285. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  39286. this.dragBehavior.detach();
  39287. _super.prototype.dispose.call(this);
  39288. };
  39289. return PlaneRotationGizmo;
  39290. }(_gizmo__WEBPACK_IMPORTED_MODULE_6__["Gizmo"]));
  39291. /***/ }),
  39292. /***/ "./Gizmos/positionGizmo.ts":
  39293. /*!*********************************!*\
  39294. !*** ./Gizmos/positionGizmo.ts ***!
  39295. \*********************************/
  39296. /*! exports provided: PositionGizmo */
  39297. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39298. "use strict";
  39299. __webpack_require__.r(__webpack_exports__);
  39300. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return PositionGizmo; });
  39301. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39302. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  39303. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39304. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39305. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39306. /* harmony import */ var _axisDragGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  39307. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  39308. /**
  39309. * Gizmo that enables dragging a mesh along 3 axis
  39310. */
  39311. var PositionGizmo = /** @class */ (function (_super) {
  39312. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PositionGizmo, _super);
  39313. /**
  39314. * Creates a PositionGizmo
  39315. * @param gizmoLayer The utility layer the gizmo will be added to
  39316. */
  39317. function PositionGizmo(gizmoLayer) {
  39318. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  39319. var _this = _super.call(this, gizmoLayer) || this;
  39320. /** Fires an event when any of it's sub gizmos are dragged */
  39321. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  39322. /** Fires an event when any of it's sub gizmos are released from dragging */
  39323. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  39324. _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);
  39325. _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);
  39326. _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);
  39327. // Relay drag events
  39328. [_this.xGizmo, _this.yGizmo, _this.zGizmo].forEach(function (gizmo) {
  39329. gizmo.dragBehavior.onDragStartObservable.add(function () {
  39330. _this.onDragStartObservable.notifyObservers({});
  39331. });
  39332. gizmo.dragBehavior.onDragEndObservable.add(function () {
  39333. _this.onDragEndObservable.notifyObservers({});
  39334. });
  39335. });
  39336. _this.attachedMesh = null;
  39337. return _this;
  39338. }
  39339. Object.defineProperty(PositionGizmo.prototype, "attachedMesh", {
  39340. set: function (mesh) {
  39341. if (this.xGizmo) {
  39342. this.xGizmo.attachedMesh = mesh;
  39343. this.yGizmo.attachedMesh = mesh;
  39344. this.zGizmo.attachedMesh = mesh;
  39345. }
  39346. },
  39347. enumerable: true,
  39348. configurable: true
  39349. });
  39350. Object.defineProperty(PositionGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  39351. get: function () {
  39352. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  39353. },
  39354. set: function (value) {
  39355. if (this.xGizmo) {
  39356. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39357. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39358. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39359. }
  39360. },
  39361. enumerable: true,
  39362. configurable: true
  39363. });
  39364. Object.defineProperty(PositionGizmo.prototype, "snapDistance", {
  39365. get: function () {
  39366. return this.xGizmo.snapDistance;
  39367. },
  39368. /**
  39369. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  39370. */
  39371. set: function (value) {
  39372. if (this.xGizmo) {
  39373. this.xGizmo.snapDistance = value;
  39374. this.yGizmo.snapDistance = value;
  39375. this.zGizmo.snapDistance = value;
  39376. }
  39377. },
  39378. enumerable: true,
  39379. configurable: true
  39380. });
  39381. Object.defineProperty(PositionGizmo.prototype, "scaleRatio", {
  39382. get: function () {
  39383. return this.xGizmo.scaleRatio;
  39384. },
  39385. /**
  39386. * Ratio for the scale of the gizmo (Default: 1)
  39387. */
  39388. set: function (value) {
  39389. if (this.xGizmo) {
  39390. this.xGizmo.scaleRatio = value;
  39391. this.yGizmo.scaleRatio = value;
  39392. this.zGizmo.scaleRatio = value;
  39393. }
  39394. },
  39395. enumerable: true,
  39396. configurable: true
  39397. });
  39398. /**
  39399. * Disposes of the gizmo
  39400. */
  39401. PositionGizmo.prototype.dispose = function () {
  39402. this.xGizmo.dispose();
  39403. this.yGizmo.dispose();
  39404. this.zGizmo.dispose();
  39405. this.onDragStartObservable.clear();
  39406. this.onDragEndObservable.clear();
  39407. };
  39408. /**
  39409. * CustomMeshes are not supported by this gizmo
  39410. * @param mesh The mesh to replace the default mesh of the gizmo
  39411. */
  39412. PositionGizmo.prototype.setCustomMesh = function (mesh) {
  39413. _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)");
  39414. };
  39415. return PositionGizmo;
  39416. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  39417. /***/ }),
  39418. /***/ "./Gizmos/rotationGizmo.ts":
  39419. /*!*********************************!*\
  39420. !*** ./Gizmos/rotationGizmo.ts ***!
  39421. \*********************************/
  39422. /*! exports provided: RotationGizmo */
  39423. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39424. "use strict";
  39425. __webpack_require__.r(__webpack_exports__);
  39426. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return RotationGizmo; });
  39427. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39428. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  39429. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39430. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39431. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39432. /* harmony import */ var _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./planeRotationGizmo */ "./Gizmos/planeRotationGizmo.ts");
  39433. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  39434. /**
  39435. * Gizmo that enables rotating a mesh along 3 axis
  39436. */
  39437. var RotationGizmo = /** @class */ (function (_super) {
  39438. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RotationGizmo, _super);
  39439. /**
  39440. * Creates a RotationGizmo
  39441. * @param gizmoLayer The utility layer the gizmo will be added to
  39442. * @param tessellation Amount of tessellation to be used when creating rotation circles
  39443. */
  39444. function RotationGizmo(gizmoLayer, tessellation) {
  39445. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  39446. if (tessellation === void 0) { tessellation = 32; }
  39447. var _this = _super.call(this, gizmoLayer) || this;
  39448. /** Fires an event when any of it's sub gizmos are dragged */
  39449. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  39450. /** Fires an event when any of it's sub gizmos are released from dragging */
  39451. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  39452. _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);
  39453. _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);
  39454. _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);
  39455. // Relay drag events
  39456. [_this.xGizmo, _this.yGizmo, _this.zGizmo].forEach(function (gizmo) {
  39457. gizmo.dragBehavior.onDragStartObservable.add(function () {
  39458. _this.onDragStartObservable.notifyObservers({});
  39459. });
  39460. gizmo.dragBehavior.onDragEndObservable.add(function () {
  39461. _this.onDragEndObservable.notifyObservers({});
  39462. });
  39463. });
  39464. _this.attachedMesh = null;
  39465. return _this;
  39466. }
  39467. Object.defineProperty(RotationGizmo.prototype, "attachedMesh", {
  39468. set: function (mesh) {
  39469. if (this.xGizmo) {
  39470. this.xGizmo.attachedMesh = mesh;
  39471. this.yGizmo.attachedMesh = mesh;
  39472. this.zGizmo.attachedMesh = mesh;
  39473. }
  39474. },
  39475. enumerable: true,
  39476. configurable: true
  39477. });
  39478. Object.defineProperty(RotationGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  39479. get: function () {
  39480. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  39481. },
  39482. set: function (value) {
  39483. if (this.xGizmo) {
  39484. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39485. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39486. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39487. }
  39488. },
  39489. enumerable: true,
  39490. configurable: true
  39491. });
  39492. Object.defineProperty(RotationGizmo.prototype, "snapDistance", {
  39493. get: function () {
  39494. return this.xGizmo.snapDistance;
  39495. },
  39496. /**
  39497. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  39498. */
  39499. set: function (value) {
  39500. if (this.xGizmo) {
  39501. this.xGizmo.snapDistance = value;
  39502. this.yGizmo.snapDistance = value;
  39503. this.zGizmo.snapDistance = value;
  39504. }
  39505. },
  39506. enumerable: true,
  39507. configurable: true
  39508. });
  39509. Object.defineProperty(RotationGizmo.prototype, "scaleRatio", {
  39510. get: function () {
  39511. return this.xGizmo.scaleRatio;
  39512. },
  39513. /**
  39514. * Ratio for the scale of the gizmo (Default: 1)
  39515. */
  39516. set: function (value) {
  39517. if (this.xGizmo) {
  39518. this.xGizmo.scaleRatio = value;
  39519. this.yGizmo.scaleRatio = value;
  39520. this.zGizmo.scaleRatio = value;
  39521. }
  39522. },
  39523. enumerable: true,
  39524. configurable: true
  39525. });
  39526. /**
  39527. * Disposes of the gizmo
  39528. */
  39529. RotationGizmo.prototype.dispose = function () {
  39530. this.xGizmo.dispose();
  39531. this.yGizmo.dispose();
  39532. this.zGizmo.dispose();
  39533. this.onDragStartObservable.clear();
  39534. this.onDragEndObservable.clear();
  39535. };
  39536. /**
  39537. * CustomMeshes are not supported by this gizmo
  39538. * @param mesh The mesh to replace the default mesh of the gizmo
  39539. */
  39540. RotationGizmo.prototype.setCustomMesh = function (mesh) {
  39541. _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)");
  39542. };
  39543. return RotationGizmo;
  39544. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  39545. /***/ }),
  39546. /***/ "./Gizmos/scaleGizmo.ts":
  39547. /*!******************************!*\
  39548. !*** ./Gizmos/scaleGizmo.ts ***!
  39549. \******************************/
  39550. /*! exports provided: ScaleGizmo */
  39551. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39552. "use strict";
  39553. __webpack_require__.r(__webpack_exports__);
  39554. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return ScaleGizmo; });
  39555. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39556. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  39557. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39558. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39559. /* harmony import */ var _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  39560. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39561. /* harmony import */ var _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./axisScaleGizmo */ "./Gizmos/axisScaleGizmo.ts");
  39562. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  39563. /**
  39564. * Gizmo that enables scaling a mesh along 3 axis
  39565. */
  39566. var ScaleGizmo = /** @class */ (function (_super) {
  39567. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScaleGizmo, _super);
  39568. /**
  39569. * Creates a ScaleGizmo
  39570. * @param gizmoLayer The utility layer the gizmo will be added to
  39571. */
  39572. function ScaleGizmo(gizmoLayer) {
  39573. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  39574. var _this = _super.call(this, gizmoLayer) || this;
  39575. /** Fires an event when any of it's sub gizmos are dragged */
  39576. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  39577. /** Fires an event when any of it's sub gizmos are released from dragging */
  39578. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  39579. _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);
  39580. _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);
  39581. _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);
  39582. // Create uniform scale gizmo
  39583. _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);
  39584. _this.uniformScaleGizmo.updateGizmoRotationToMatchAttachedMesh = false;
  39585. _this.uniformScaleGizmo.uniformScaling = true;
  39586. var uniformScalingMesh = _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_4__["PolyhedronBuilder"].CreatePolyhedron("", { type: 1 }, _this.uniformScaleGizmo.gizmoLayer.utilityLayerScene);
  39587. uniformScalingMesh.scaling.scaleInPlace(0.02);
  39588. uniformScalingMesh.visibility = 0;
  39589. var octahedron = _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_4__["PolyhedronBuilder"].CreatePolyhedron("", { type: 1 }, _this.uniformScaleGizmo.gizmoLayer.utilityLayerScene);
  39590. octahedron.scaling.scaleInPlace(0.007);
  39591. uniformScalingMesh.addChild(octahedron);
  39592. _this.uniformScaleGizmo.setCustomMesh(uniformScalingMesh, true);
  39593. // Relay drag events
  39594. [_this.xGizmo, _this.yGizmo, _this.zGizmo, _this.uniformScaleGizmo].forEach(function (gizmo) {
  39595. gizmo.dragBehavior.onDragStartObservable.add(function () {
  39596. _this.onDragStartObservable.notifyObservers({});
  39597. });
  39598. gizmo.dragBehavior.onDragEndObservable.add(function () {
  39599. _this.onDragEndObservable.notifyObservers({});
  39600. });
  39601. });
  39602. _this.attachedMesh = null;
  39603. return _this;
  39604. }
  39605. Object.defineProperty(ScaleGizmo.prototype, "attachedMesh", {
  39606. set: function (mesh) {
  39607. if (this.xGizmo) {
  39608. this.xGizmo.attachedMesh = mesh;
  39609. this.yGizmo.attachedMesh = mesh;
  39610. this.zGizmo.attachedMesh = mesh;
  39611. this.uniformScaleGizmo.attachedMesh = mesh;
  39612. }
  39613. },
  39614. enumerable: true,
  39615. configurable: true
  39616. });
  39617. Object.defineProperty(ScaleGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  39618. get: function () {
  39619. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  39620. },
  39621. set: function (value) {
  39622. if (!value) {
  39623. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Setting updateGizmoRotationToMatchAttachedMesh = false on scaling gizmo is not supported.");
  39624. }
  39625. if (this.xGizmo) {
  39626. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39627. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39628. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39629. }
  39630. },
  39631. enumerable: true,
  39632. configurable: true
  39633. });
  39634. Object.defineProperty(ScaleGizmo.prototype, "snapDistance", {
  39635. get: function () {
  39636. return this.xGizmo.snapDistance;
  39637. },
  39638. /**
  39639. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  39640. */
  39641. set: function (value) {
  39642. if (this.xGizmo) {
  39643. this.xGizmo.snapDistance = value;
  39644. this.yGizmo.snapDistance = value;
  39645. this.zGizmo.snapDistance = value;
  39646. this.uniformScaleGizmo.snapDistance = value;
  39647. }
  39648. },
  39649. enumerable: true,
  39650. configurable: true
  39651. });
  39652. Object.defineProperty(ScaleGizmo.prototype, "scaleRatio", {
  39653. get: function () {
  39654. return this.xGizmo.scaleRatio;
  39655. },
  39656. /**
  39657. * Ratio for the scale of the gizmo (Default: 1)
  39658. */
  39659. set: function (value) {
  39660. if (this.xGizmo) {
  39661. this.xGizmo.scaleRatio = value;
  39662. this.yGizmo.scaleRatio = value;
  39663. this.zGizmo.scaleRatio = value;
  39664. this.uniformScaleGizmo.scaleRatio = value;
  39665. }
  39666. },
  39667. enumerable: true,
  39668. configurable: true
  39669. });
  39670. /**
  39671. * Disposes of the gizmo
  39672. */
  39673. ScaleGizmo.prototype.dispose = function () {
  39674. this.xGizmo.dispose();
  39675. this.yGizmo.dispose();
  39676. this.zGizmo.dispose();
  39677. this.uniformScaleGizmo.dispose();
  39678. this.onDragStartObservable.clear();
  39679. this.onDragEndObservable.clear();
  39680. };
  39681. return ScaleGizmo;
  39682. }(_gizmo__WEBPACK_IMPORTED_MODULE_5__["Gizmo"]));
  39683. /***/ }),
  39684. /***/ "./Helpers/environmentHelper.ts":
  39685. /*!**************************************!*\
  39686. !*** ./Helpers/environmentHelper.ts ***!
  39687. \**************************************/
  39688. /*! exports provided: EnvironmentHelper */
  39689. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39690. "use strict";
  39691. __webpack_require__.r(__webpack_exports__);
  39692. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return EnvironmentHelper; });
  39693. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39694. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39695. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  39696. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39697. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39698. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  39699. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  39700. /* harmony import */ var _Materials_Textures_mirrorTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/mirrorTexture */ "./Materials/Textures/mirrorTexture.ts");
  39701. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  39702. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  39703. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  39704. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  39705. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  39706. /**
  39707. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  39708. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  39709. * It also helps with the default setup of your imageProcessing configuration.
  39710. */
  39711. var EnvironmentHelper = /** @class */ (function () {
  39712. /**
  39713. * constructor
  39714. * @param options Defines the options we want to customize the helper
  39715. * @param scene The scene to add the material to
  39716. */
  39717. function EnvironmentHelper(options, scene) {
  39718. var _this = this;
  39719. this._errorHandler = function (message, exception) {
  39720. _this.onErrorObservable.notifyObservers({ message: message, exception: exception });
  39721. };
  39722. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, EnvironmentHelper._getDefaultOptions(), options);
  39723. this._scene = scene;
  39724. this.onErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  39725. this._setupBackground();
  39726. this._setupImageProcessing();
  39727. }
  39728. /**
  39729. * Creates the default options for the helper.
  39730. */
  39731. EnvironmentHelper._getDefaultOptions = function () {
  39732. return {
  39733. createGround: true,
  39734. groundSize: 15,
  39735. groundTexture: this._groundTextureCDNUrl,
  39736. groundColor: new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.2, 0.2, 0.3).toLinearSpace().scale(3),
  39737. groundOpacity: 0.9,
  39738. enableGroundShadow: true,
  39739. groundShadowLevel: 0.5,
  39740. enableGroundMirror: false,
  39741. groundMirrorSizeRatio: 0.3,
  39742. groundMirrorBlurKernel: 64,
  39743. groundMirrorAmount: 1,
  39744. groundMirrorFresnelWeight: 1,
  39745. groundMirrorFallOffDistance: 0,
  39746. groundMirrorTextureType: _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT,
  39747. groundYBias: 0.00001,
  39748. createSkybox: true,
  39749. skyboxSize: 20,
  39750. skyboxTexture: this._skyboxTextureCDNUrl,
  39751. skyboxColor: new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.2, 0.2, 0.3).toLinearSpace().scale(3),
  39752. backgroundYRotation: 0,
  39753. sizeAuto: true,
  39754. rootPosition: _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(),
  39755. setupImageProcessing: true,
  39756. environmentTexture: this._environmentTextureCDNUrl,
  39757. cameraExposure: 0.8,
  39758. cameraContrast: 1.2,
  39759. toneMappingEnabled: true,
  39760. };
  39761. };
  39762. Object.defineProperty(EnvironmentHelper.prototype, "rootMesh", {
  39763. /**
  39764. * Gets the root mesh created by the helper.
  39765. */
  39766. get: function () {
  39767. return this._rootMesh;
  39768. },
  39769. enumerable: true,
  39770. configurable: true
  39771. });
  39772. Object.defineProperty(EnvironmentHelper.prototype, "skybox", {
  39773. /**
  39774. * Gets the skybox created by the helper.
  39775. */
  39776. get: function () {
  39777. return this._skybox;
  39778. },
  39779. enumerable: true,
  39780. configurable: true
  39781. });
  39782. Object.defineProperty(EnvironmentHelper.prototype, "skyboxTexture", {
  39783. /**
  39784. * Gets the skybox texture created by the helper.
  39785. */
  39786. get: function () {
  39787. return this._skyboxTexture;
  39788. },
  39789. enumerable: true,
  39790. configurable: true
  39791. });
  39792. Object.defineProperty(EnvironmentHelper.prototype, "skyboxMaterial", {
  39793. /**
  39794. * Gets the skybox material created by the helper.
  39795. */
  39796. get: function () {
  39797. return this._skyboxMaterial;
  39798. },
  39799. enumerable: true,
  39800. configurable: true
  39801. });
  39802. Object.defineProperty(EnvironmentHelper.prototype, "ground", {
  39803. /**
  39804. * Gets the ground mesh created by the helper.
  39805. */
  39806. get: function () {
  39807. return this._ground;
  39808. },
  39809. enumerable: true,
  39810. configurable: true
  39811. });
  39812. Object.defineProperty(EnvironmentHelper.prototype, "groundTexture", {
  39813. /**
  39814. * Gets the ground texture created by the helper.
  39815. */
  39816. get: function () {
  39817. return this._groundTexture;
  39818. },
  39819. enumerable: true,
  39820. configurable: true
  39821. });
  39822. Object.defineProperty(EnvironmentHelper.prototype, "groundMirror", {
  39823. /**
  39824. * Gets the ground mirror created by the helper.
  39825. */
  39826. get: function () {
  39827. return this._groundMirror;
  39828. },
  39829. enumerable: true,
  39830. configurable: true
  39831. });
  39832. Object.defineProperty(EnvironmentHelper.prototype, "groundMirrorRenderList", {
  39833. /**
  39834. * Gets the ground mirror render list to helps pushing the meshes
  39835. * you wish in the ground reflection.
  39836. */
  39837. get: function () {
  39838. if (this._groundMirror) {
  39839. return this._groundMirror.renderList;
  39840. }
  39841. return null;
  39842. },
  39843. enumerable: true,
  39844. configurable: true
  39845. });
  39846. Object.defineProperty(EnvironmentHelper.prototype, "groundMaterial", {
  39847. /**
  39848. * Gets the ground material created by the helper.
  39849. */
  39850. get: function () {
  39851. return this._groundMaterial;
  39852. },
  39853. enumerable: true,
  39854. configurable: true
  39855. });
  39856. /**
  39857. * Updates the background according to the new options
  39858. * @param options
  39859. */
  39860. EnvironmentHelper.prototype.updateOptions = function (options) {
  39861. var newOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, this._options, options);
  39862. if (this._ground && !newOptions.createGround) {
  39863. this._ground.dispose();
  39864. this._ground = null;
  39865. }
  39866. if (this._groundMaterial && !newOptions.createGround) {
  39867. this._groundMaterial.dispose();
  39868. this._groundMaterial = null;
  39869. }
  39870. if (this._groundTexture) {
  39871. if (this._options.groundTexture != newOptions.groundTexture) {
  39872. this._groundTexture.dispose();
  39873. this._groundTexture = null;
  39874. }
  39875. }
  39876. if (this._skybox && !newOptions.createSkybox) {
  39877. this._skybox.dispose();
  39878. this._skybox = null;
  39879. }
  39880. if (this._skyboxMaterial && !newOptions.createSkybox) {
  39881. this._skyboxMaterial.dispose();
  39882. this._skyboxMaterial = null;
  39883. }
  39884. if (this._skyboxTexture) {
  39885. if (this._options.skyboxTexture != newOptions.skyboxTexture) {
  39886. this._skyboxTexture.dispose();
  39887. this._skyboxTexture = null;
  39888. }
  39889. }
  39890. if (this._groundMirror && !newOptions.enableGroundMirror) {
  39891. this._groundMirror.dispose();
  39892. this._groundMirror = null;
  39893. }
  39894. if (this._scene.environmentTexture) {
  39895. if (this._options.environmentTexture != newOptions.environmentTexture) {
  39896. this._scene.environmentTexture.dispose();
  39897. }
  39898. }
  39899. this._options = newOptions;
  39900. this._setupBackground();
  39901. this._setupImageProcessing();
  39902. };
  39903. /**
  39904. * Sets the primary color of all the available elements.
  39905. * @param color the main color to affect to the ground and the background
  39906. */
  39907. EnvironmentHelper.prototype.setMainColor = function (color) {
  39908. if (this.groundMaterial) {
  39909. this.groundMaterial.primaryColor = color;
  39910. }
  39911. if (this.skyboxMaterial) {
  39912. this.skyboxMaterial.primaryColor = color;
  39913. }
  39914. if (this.groundMirror) {
  39915. this.groundMirror.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](color.r, color.g, color.b, 1.0);
  39916. }
  39917. };
  39918. /**
  39919. * Setup the image processing according to the specified options.
  39920. */
  39921. EnvironmentHelper.prototype._setupImageProcessing = function () {
  39922. if (this._options.setupImageProcessing) {
  39923. this._scene.imageProcessingConfiguration.contrast = this._options.cameraContrast;
  39924. this._scene.imageProcessingConfiguration.exposure = this._options.cameraExposure;
  39925. this._scene.imageProcessingConfiguration.toneMappingEnabled = this._options.toneMappingEnabled;
  39926. this._setupEnvironmentTexture();
  39927. }
  39928. };
  39929. /**
  39930. * Setup the environment texture according to the specified options.
  39931. */
  39932. EnvironmentHelper.prototype._setupEnvironmentTexture = function () {
  39933. if (this._scene.environmentTexture) {
  39934. return;
  39935. }
  39936. if (this._options.environmentTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  39937. this._scene.environmentTexture = this._options.environmentTexture;
  39938. return;
  39939. }
  39940. var environmentTexture = _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"].CreateFromPrefilteredData(this._options.environmentTexture, this._scene);
  39941. this._scene.environmentTexture = environmentTexture;
  39942. };
  39943. /**
  39944. * Setup the background according to the specified options.
  39945. */
  39946. EnvironmentHelper.prototype._setupBackground = function () {
  39947. if (!this._rootMesh) {
  39948. this._rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"]("BackgroundHelper", this._scene);
  39949. }
  39950. this._rootMesh.rotation.y = this._options.backgroundYRotation;
  39951. var sceneSize = this._getSceneSize();
  39952. if (this._options.createGround) {
  39953. this._setupGround(sceneSize);
  39954. this._setupGroundMaterial();
  39955. this._setupGroundDiffuseTexture();
  39956. if (this._options.enableGroundMirror) {
  39957. this._setupGroundMirrorTexture(sceneSize);
  39958. }
  39959. this._setupMirrorInGroundMaterial();
  39960. }
  39961. if (this._options.createSkybox) {
  39962. this._setupSkybox(sceneSize);
  39963. this._setupSkyboxMaterial();
  39964. this._setupSkyboxReflectionTexture();
  39965. }
  39966. this._rootMesh.position.x = sceneSize.rootPosition.x;
  39967. this._rootMesh.position.z = sceneSize.rootPosition.z;
  39968. this._rootMesh.position.y = sceneSize.rootPosition.y;
  39969. };
  39970. /**
  39971. * Get the scene sizes according to the setup.
  39972. */
  39973. EnvironmentHelper.prototype._getSceneSize = function () {
  39974. var _this = this;
  39975. var groundSize = this._options.groundSize;
  39976. var skyboxSize = this._options.skyboxSize;
  39977. var rootPosition = this._options.rootPosition;
  39978. if (!this._scene.meshes || this._scene.meshes.length === 1) { // 1 only means the root of the helper.
  39979. return { groundSize: groundSize, skyboxSize: skyboxSize, rootPosition: rootPosition };
  39980. }
  39981. var sceneExtends = this._scene.getWorldExtends(function (mesh) {
  39982. return (mesh !== _this._ground && mesh !== _this._rootMesh && mesh !== _this._skybox);
  39983. });
  39984. var sceneDiagonal = sceneExtends.max.subtract(sceneExtends.min);
  39985. if (this._options.sizeAuto) {
  39986. if (this._scene.activeCamera instanceof _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"] &&
  39987. this._scene.activeCamera.upperRadiusLimit) {
  39988. groundSize = this._scene.activeCamera.upperRadiusLimit * 2;
  39989. skyboxSize = groundSize;
  39990. }
  39991. var sceneDiagonalLenght = sceneDiagonal.length();
  39992. if (sceneDiagonalLenght > groundSize) {
  39993. groundSize = sceneDiagonalLenght * 2;
  39994. skyboxSize = groundSize;
  39995. }
  39996. // 10 % bigger.
  39997. groundSize *= 1.1;
  39998. skyboxSize *= 1.5;
  39999. rootPosition = sceneExtends.min.add(sceneDiagonal.scale(0.5));
  40000. rootPosition.y = sceneExtends.min.y - this._options.groundYBias;
  40001. }
  40002. return { groundSize: groundSize, skyboxSize: skyboxSize, rootPosition: rootPosition };
  40003. };
  40004. /**
  40005. * Setup the ground according to the specified options.
  40006. */
  40007. EnvironmentHelper.prototype._setupGround = function (sceneSize) {
  40008. var _this = this;
  40009. if (!this._ground || this._ground.isDisposed()) {
  40010. this._ground = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreatePlane("BackgroundPlane", sceneSize.groundSize, this._scene);
  40011. this._ground.rotation.x = Math.PI / 2; // Face up by default.
  40012. this._ground.parent = this._rootMesh;
  40013. this._ground.onDisposeObservable.add(function () { _this._ground = null; });
  40014. }
  40015. this._ground.receiveShadows = this._options.enableGroundShadow;
  40016. };
  40017. /**
  40018. * Setup the ground material according to the specified options.
  40019. */
  40020. EnvironmentHelper.prototype._setupGroundMaterial = function () {
  40021. if (!this._groundMaterial) {
  40022. this._groundMaterial = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__["BackgroundMaterial"]("BackgroundPlaneMaterial", this._scene);
  40023. }
  40024. this._groundMaterial.alpha = this._options.groundOpacity;
  40025. this._groundMaterial.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF;
  40026. this._groundMaterial.shadowLevel = this._options.groundShadowLevel;
  40027. this._groundMaterial.primaryColor = this._options.groundColor;
  40028. this._groundMaterial.useRGBColor = false;
  40029. this._groundMaterial.enableNoise = true;
  40030. if (this._ground) {
  40031. this._ground.material = this._groundMaterial;
  40032. }
  40033. };
  40034. /**
  40035. * Setup the ground diffuse texture according to the specified options.
  40036. */
  40037. EnvironmentHelper.prototype._setupGroundDiffuseTexture = function () {
  40038. if (!this._groundMaterial) {
  40039. return;
  40040. }
  40041. if (this._groundTexture) {
  40042. return;
  40043. }
  40044. if (this._options.groundTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  40045. this._groundMaterial.diffuseTexture = this._options.groundTexture;
  40046. return;
  40047. }
  40048. var diffuseTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"](this._options.groundTexture, this._scene, undefined, undefined, undefined, undefined, this._errorHandler);
  40049. diffuseTexture.gammaSpace = false;
  40050. diffuseTexture.hasAlpha = true;
  40051. this._groundMaterial.diffuseTexture = diffuseTexture;
  40052. };
  40053. /**
  40054. * Setup the ground mirror texture according to the specified options.
  40055. */
  40056. EnvironmentHelper.prototype._setupGroundMirrorTexture = function (sceneSize) {
  40057. var wrapping = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  40058. if (!this._groundMirror) {
  40059. 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);
  40060. this._groundMirror.mirrorPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Plane"](0, -1, 0, sceneSize.rootPosition.y);
  40061. this._groundMirror.anisotropicFilteringLevel = 1;
  40062. this._groundMirror.wrapU = wrapping;
  40063. this._groundMirror.wrapV = wrapping;
  40064. this._groundMirror.gammaSpace = false;
  40065. if (this._groundMirror.renderList) {
  40066. for (var i = 0; i < this._scene.meshes.length; i++) {
  40067. var mesh = this._scene.meshes[i];
  40068. if (mesh !== this._ground &&
  40069. mesh !== this._skybox &&
  40070. mesh !== this._rootMesh) {
  40071. this._groundMirror.renderList.push(mesh);
  40072. }
  40073. }
  40074. }
  40075. }
  40076. this._groundMirror.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](this._options.groundColor.r, this._options.groundColor.g, this._options.groundColor.b, 1);
  40077. this._groundMirror.adaptiveBlurKernel = this._options.groundMirrorBlurKernel;
  40078. };
  40079. /**
  40080. * Setup the ground to receive the mirror texture.
  40081. */
  40082. EnvironmentHelper.prototype._setupMirrorInGroundMaterial = function () {
  40083. if (this._groundMaterial) {
  40084. this._groundMaterial.reflectionTexture = this._groundMirror;
  40085. this._groundMaterial.reflectionFresnel = true;
  40086. this._groundMaterial.reflectionAmount = this._options.groundMirrorAmount;
  40087. this._groundMaterial.reflectionStandardFresnelWeight = this._options.groundMirrorFresnelWeight;
  40088. this._groundMaterial.reflectionFalloffDistance = this._options.groundMirrorFallOffDistance;
  40089. }
  40090. };
  40091. /**
  40092. * Setup the skybox according to the specified options.
  40093. */
  40094. EnvironmentHelper.prototype._setupSkybox = function (sceneSize) {
  40095. var _this = this;
  40096. if (!this._skybox || this._skybox.isDisposed()) {
  40097. this._skybox = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreateBox("BackgroundSkybox", sceneSize.skyboxSize, this._scene, undefined, _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].BACKSIDE);
  40098. this._skybox.onDisposeObservable.add(function () { _this._skybox = null; });
  40099. }
  40100. this._skybox.parent = this._rootMesh;
  40101. };
  40102. /**
  40103. * Setup the skybox material according to the specified options.
  40104. */
  40105. EnvironmentHelper.prototype._setupSkyboxMaterial = function () {
  40106. if (!this._skybox) {
  40107. return;
  40108. }
  40109. if (!this._skyboxMaterial) {
  40110. this._skyboxMaterial = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__["BackgroundMaterial"]("BackgroundSkyboxMaterial", this._scene);
  40111. }
  40112. this._skyboxMaterial.useRGBColor = false;
  40113. this._skyboxMaterial.primaryColor = this._options.skyboxColor;
  40114. this._skyboxMaterial.enableNoise = true;
  40115. this._skybox.material = this._skyboxMaterial;
  40116. };
  40117. /**
  40118. * Setup the skybox reflection texture according to the specified options.
  40119. */
  40120. EnvironmentHelper.prototype._setupSkyboxReflectionTexture = function () {
  40121. if (!this._skyboxMaterial) {
  40122. return;
  40123. }
  40124. if (this._skyboxTexture) {
  40125. return;
  40126. }
  40127. if (this._options.skyboxTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  40128. this._skyboxMaterial.reflectionTexture = this._options.skyboxTexture;
  40129. return;
  40130. }
  40131. this._skyboxTexture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"](this._options.skyboxTexture, this._scene, undefined, undefined, undefined, undefined, this._errorHandler);
  40132. this._skyboxTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].SKYBOX_MODE;
  40133. this._skyboxTexture.gammaSpace = false;
  40134. this._skyboxMaterial.reflectionTexture = this._skyboxTexture;
  40135. };
  40136. /**
  40137. * Dispose all the elements created by the Helper.
  40138. */
  40139. EnvironmentHelper.prototype.dispose = function () {
  40140. if (this._groundMaterial) {
  40141. this._groundMaterial.dispose(true, true);
  40142. }
  40143. if (this._skyboxMaterial) {
  40144. this._skyboxMaterial.dispose(true, true);
  40145. }
  40146. this._rootMesh.dispose(false);
  40147. };
  40148. /**
  40149. * Default ground texture URL.
  40150. */
  40151. EnvironmentHelper._groundTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundGround.png";
  40152. /**
  40153. * Default skybox texture URL.
  40154. */
  40155. EnvironmentHelper._skyboxTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundSkybox.dds";
  40156. /**
  40157. * Default environment texture URL.
  40158. */
  40159. EnvironmentHelper._environmentTextureCDNUrl = "https://assets.babylonjs.com/environments/environmentSpecular.env";
  40160. return EnvironmentHelper;
  40161. }());
  40162. /***/ }),
  40163. /***/ "./Helpers/index.ts":
  40164. /*!**************************!*\
  40165. !*** ./Helpers/index.ts ***!
  40166. \**************************/
  40167. /*! exports provided: EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome */
  40168. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40169. "use strict";
  40170. __webpack_require__.r(__webpack_exports__);
  40171. /* harmony import */ var _environmentHelper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./environmentHelper */ "./Helpers/environmentHelper.ts");
  40172. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _environmentHelper__WEBPACK_IMPORTED_MODULE_0__["EnvironmentHelper"]; });
  40173. /* harmony import */ var _photoDome__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./photoDome */ "./Helpers/photoDome.ts");
  40174. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _photoDome__WEBPACK_IMPORTED_MODULE_1__["PhotoDome"]; });
  40175. /* harmony import */ var _sceneHelpers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sceneHelpers */ "./Helpers/sceneHelpers.ts");
  40176. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _sceneHelpers__WEBPACK_IMPORTED_MODULE_2__["_forceSceneHelpersToBundle"]; });
  40177. /* harmony import */ var _videoDome__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./videoDome */ "./Helpers/videoDome.ts");
  40178. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _videoDome__WEBPACK_IMPORTED_MODULE_3__["VideoDome"]; });
  40179. /***/ }),
  40180. /***/ "./Helpers/photoDome.ts":
  40181. /*!******************************!*\
  40182. !*** ./Helpers/photoDome.ts ***!
  40183. \******************************/
  40184. /*! exports provided: PhotoDome */
  40185. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40186. "use strict";
  40187. __webpack_require__.r(__webpack_exports__);
  40188. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return PhotoDome; });
  40189. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  40190. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  40191. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  40192. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  40193. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  40194. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  40195. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  40196. /**
  40197. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  40198. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  40199. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  40200. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  40201. */
  40202. var PhotoDome = /** @class */ (function (_super) {
  40203. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PhotoDome, _super);
  40204. /**
  40205. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  40206. * @param name Element's name, child elements will append suffixes for their own names.
  40207. * @param urlsOfPhoto defines the url of the photo to display
  40208. * @param options defines an object containing optional or exposed sub element properties
  40209. * @param onError defines a callback called when an error occured while loading the texture
  40210. */
  40211. function PhotoDome(name, urlOfPhoto, options, scene, onError) {
  40212. if (onError === void 0) { onError = null; }
  40213. var _this = _super.call(this, name, scene) || this;
  40214. _this._useDirectMapping = false;
  40215. /**
  40216. * Observable raised when an error occured while loading the 360 image
  40217. */
  40218. _this.onLoadErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  40219. // set defaults and manage values
  40220. name = name || "photoDome";
  40221. options.resolution = (Math.abs(options.resolution) | 0) || 32;
  40222. options.size = Math.abs(options.size) || (scene.activeCamera ? scene.activeCamera.maxZ * 0.48 : 1000);
  40223. if (options.useDirectMapping === undefined) {
  40224. _this._useDirectMapping = true;
  40225. }
  40226. else {
  40227. _this._useDirectMapping = options.useDirectMapping;
  40228. }
  40229. _this._setReady(false);
  40230. // create
  40231. var material = _this._material = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__["BackgroundMaterial"](name + "_material", scene);
  40232. _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);
  40233. // configure material
  40234. material.opacityFresnel = false;
  40235. material.useEquirectangularFOV = true;
  40236. material.fovMultiplier = 1.0;
  40237. _this.photoTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"](urlOfPhoto, scene, true, !_this._useDirectMapping, undefined, undefined, function (message, exception) {
  40238. _this.onLoadErrorObservable.notifyObservers(message || "Unknown error occured");
  40239. if (onError) {
  40240. onError(message, exception);
  40241. }
  40242. });
  40243. _this.photoTexture.onLoadObservable.addOnce(function () {
  40244. _this._setReady(true);
  40245. });
  40246. // configure mesh
  40247. _this._mesh.material = material;
  40248. _this._mesh.parent = _this;
  40249. return _this;
  40250. }
  40251. Object.defineProperty(PhotoDome.prototype, "photoTexture", {
  40252. /**
  40253. * Gets or sets the texture being displayed on the sphere
  40254. */
  40255. get: function () {
  40256. return this._photoTexture;
  40257. },
  40258. set: function (value) {
  40259. if (this._photoTexture === value) {
  40260. return;
  40261. }
  40262. this._photoTexture = value;
  40263. if (this._useDirectMapping) {
  40264. this._photoTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  40265. this._photoTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  40266. this._material.diffuseTexture = this._photoTexture;
  40267. }
  40268. else {
  40269. this._photoTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE; // matches orientation
  40270. this._photoTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  40271. this._material.reflectionTexture = this._photoTexture;
  40272. }
  40273. },
  40274. enumerable: true,
  40275. configurable: true
  40276. });
  40277. Object.defineProperty(PhotoDome.prototype, "fovMultiplier", {
  40278. /**
  40279. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  40280. * Also see the options.resolution property.
  40281. */
  40282. get: function () {
  40283. return this._material.fovMultiplier;
  40284. },
  40285. set: function (value) {
  40286. this._material.fovMultiplier = value;
  40287. },
  40288. enumerable: true,
  40289. configurable: true
  40290. });
  40291. /**
  40292. * Releases resources associated with this node.
  40293. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  40294. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  40295. */
  40296. PhotoDome.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  40297. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  40298. this._photoTexture.dispose();
  40299. this._mesh.dispose();
  40300. this._material.dispose();
  40301. this.onLoadErrorObservable.clear();
  40302. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  40303. };
  40304. return PhotoDome;
  40305. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_2__["TransformNode"]));
  40306. /***/ }),
  40307. /***/ "./Helpers/sceneHelpers.ts":
  40308. /*!*********************************!*\
  40309. !*** ./Helpers/sceneHelpers.ts ***!
  40310. \*********************************/
  40311. /*! exports provided: _forceSceneHelpersToBundle */
  40312. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40313. "use strict";
  40314. __webpack_require__.r(__webpack_exports__);
  40315. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _forceSceneHelpersToBundle; });
  40316. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  40317. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  40318. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  40319. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  40320. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  40321. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  40322. /* harmony import */ var _Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/PBR/pbrMaterial */ "./Materials/PBR/pbrMaterial.ts");
  40323. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  40324. /* harmony import */ var _environmentHelper__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./environmentHelper */ "./Helpers/environmentHelper.ts");
  40325. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  40326. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  40327. /* harmony import */ var _Cameras_XR_webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Cameras/XR/webXRManagedOutputCanvas */ "./Cameras/XR/webXRManagedOutputCanvas.ts");
  40328. /* harmony import */ var _Cameras_XR_webXRInput__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Cameras/XR/webXRInput */ "./Cameras/XR/webXRInput.ts");
  40329. /* harmony import */ var _Cameras_XR_webXREnterExitUI__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Cameras/XR/webXREnterExitUI */ "./Cameras/XR/webXREnterExitUI.ts");
  40330. /* harmony import */ var _Cameras_XR_webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Cameras/XR/webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  40331. /* harmony import */ var _Cameras_VR_vrExperienceHelper__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Cameras/VR/vrExperienceHelper */ "./Cameras/VR/vrExperienceHelper.ts");
  40332. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  40333. /** @hidden */
  40334. var _forceSceneHelpersToBundle = true;
  40335. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultLight = function (replace) {
  40336. if (replace === void 0) { replace = false; }
  40337. // Dispose existing light in replace mode.
  40338. if (replace) {
  40339. if (this.lights) {
  40340. for (var i = 0; i < this.lights.length; i++) {
  40341. this.lights[i].dispose();
  40342. }
  40343. }
  40344. }
  40345. // Light
  40346. if (this.lights.length === 0) {
  40347. new _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_7__["HemisphericLight"]("default light", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up(), this);
  40348. }
  40349. };
  40350. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultCamera = function (createArcRotateCamera, replace, attachCameraControls) {
  40351. if (createArcRotateCamera === void 0) { createArcRotateCamera = false; }
  40352. if (replace === void 0) { replace = false; }
  40353. if (attachCameraControls === void 0) { attachCameraControls = false; }
  40354. // Dispose existing camera in replace mode.
  40355. if (replace) {
  40356. if (this.activeCamera) {
  40357. this.activeCamera.dispose();
  40358. this.activeCamera = null;
  40359. }
  40360. }
  40361. // Camera
  40362. if (!this.activeCamera) {
  40363. var worldExtends = this.getWorldExtends();
  40364. var worldSize = worldExtends.max.subtract(worldExtends.min);
  40365. var worldCenter = worldExtends.min.add(worldSize.scale(0.5));
  40366. var camera;
  40367. var radius = worldSize.length() * 1.5;
  40368. // empty scene scenario!
  40369. if (!isFinite(radius)) {
  40370. radius = 1;
  40371. worldCenter.copyFromFloats(0, 0, 0);
  40372. }
  40373. if (createArcRotateCamera) {
  40374. var arcRotateCamera = new _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_10__["ArcRotateCamera"]("default camera", -(Math.PI / 2), Math.PI / 2, radius, worldCenter, this);
  40375. arcRotateCamera.lowerRadiusLimit = radius * 0.01;
  40376. arcRotateCamera.wheelPrecision = 100 / radius;
  40377. camera = arcRotateCamera;
  40378. }
  40379. else {
  40380. 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);
  40381. freeCamera.setTarget(worldCenter);
  40382. camera = freeCamera;
  40383. }
  40384. camera.minZ = radius * 0.01;
  40385. camera.maxZ = radius * 1000;
  40386. camera.speed = radius * 0.2;
  40387. this.activeCamera = camera;
  40388. var canvas = this.getEngine().getRenderingCanvas();
  40389. if (attachCameraControls && canvas) {
  40390. camera.attachControl(canvas);
  40391. }
  40392. }
  40393. };
  40394. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultCameraOrLight = function (createArcRotateCamera, replace, attachCameraControls) {
  40395. if (createArcRotateCamera === void 0) { createArcRotateCamera = false; }
  40396. if (replace === void 0) { replace = false; }
  40397. if (attachCameraControls === void 0) { attachCameraControls = false; }
  40398. this.createDefaultLight(replace);
  40399. this.createDefaultCamera(createArcRotateCamera, replace, attachCameraControls);
  40400. };
  40401. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultSkybox = function (environmentTexture, pbr, scale, blur, setGlobalEnvTexture) {
  40402. if (pbr === void 0) { pbr = false; }
  40403. if (scale === void 0) { scale = 1000; }
  40404. if (blur === void 0) { blur = 0; }
  40405. if (setGlobalEnvTexture === void 0) { setGlobalEnvTexture = true; }
  40406. if (!environmentTexture) {
  40407. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Can not create default skybox without environment texture.");
  40408. return null;
  40409. }
  40410. if (setGlobalEnvTexture) {
  40411. if (environmentTexture) {
  40412. this.environmentTexture = environmentTexture;
  40413. }
  40414. }
  40415. // Skybox
  40416. var hdrSkybox = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateBox("hdrSkyBox", scale, this);
  40417. if (pbr) {
  40418. var hdrSkyboxMaterial = new _Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_6__["PBRMaterial"]("skyBox", this);
  40419. hdrSkyboxMaterial.backFaceCulling = false;
  40420. hdrSkyboxMaterial.reflectionTexture = environmentTexture.clone();
  40421. if (hdrSkyboxMaterial.reflectionTexture) {
  40422. hdrSkyboxMaterial.reflectionTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].SKYBOX_MODE;
  40423. }
  40424. hdrSkyboxMaterial.microSurface = 1.0 - blur;
  40425. hdrSkyboxMaterial.disableLighting = true;
  40426. hdrSkyboxMaterial.twoSidedLighting = true;
  40427. hdrSkybox.infiniteDistance = true;
  40428. hdrSkybox.material = hdrSkyboxMaterial;
  40429. }
  40430. else {
  40431. var skyboxMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("skyBox", this);
  40432. skyboxMaterial.backFaceCulling = false;
  40433. skyboxMaterial.reflectionTexture = environmentTexture.clone();
  40434. if (skyboxMaterial.reflectionTexture) {
  40435. skyboxMaterial.reflectionTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].SKYBOX_MODE;
  40436. }
  40437. skyboxMaterial.disableLighting = true;
  40438. hdrSkybox.infiniteDistance = true;
  40439. hdrSkybox.material = skyboxMaterial;
  40440. }
  40441. hdrSkybox.isPickable = false;
  40442. return hdrSkybox;
  40443. };
  40444. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultEnvironment = function (options) {
  40445. if (_environmentHelper__WEBPACK_IMPORTED_MODULE_8__["EnvironmentHelper"]) {
  40446. return new _environmentHelper__WEBPACK_IMPORTED_MODULE_8__["EnvironmentHelper"](options, this);
  40447. }
  40448. return null;
  40449. };
  40450. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultVRExperience = function (webVROptions) {
  40451. if (webVROptions === void 0) { webVROptions = {}; }
  40452. return new _Cameras_VR_vrExperienceHelper__WEBPACK_IMPORTED_MODULE_15__["VRExperienceHelper"](this, webVROptions);
  40453. };
  40454. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultXRExperienceAsync = function () {
  40455. var _this = this;
  40456. return _Cameras_XR_webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_14__["WebXRExperienceHelper"].CreateAsync(this).then(function (helper) {
  40457. var outputCanvas = new _Cameras_XR_webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_11__["WebXRManagedOutputCanvas"](helper);
  40458. return _Cameras_XR_webXREnterExitUI__WEBPACK_IMPORTED_MODULE_13__["WebXREnterExitUI"].CreateAsync(_this, helper, { outputCanvasContext: outputCanvas.canvasContext })
  40459. .then(function (ui) {
  40460. new _Cameras_XR_webXRInput__WEBPACK_IMPORTED_MODULE_12__["WebXRInput"](helper);
  40461. return helper;
  40462. });
  40463. });
  40464. };
  40465. /***/ }),
  40466. /***/ "./Helpers/videoDome.ts":
  40467. /*!******************************!*\
  40468. !*** ./Helpers/videoDome.ts ***!
  40469. \******************************/
  40470. /*! exports provided: VideoDome */
  40471. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40472. "use strict";
  40473. __webpack_require__.r(__webpack_exports__);
  40474. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return VideoDome; });
  40475. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  40476. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  40477. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  40478. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  40479. /* harmony import */ var _Materials_Textures_videoTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/videoTexture */ "./Materials/Textures/videoTexture.ts");
  40480. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  40481. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  40482. /**
  40483. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  40484. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  40485. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  40486. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  40487. */
  40488. var VideoDome = /** @class */ (function (_super) {
  40489. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VideoDome, _super);
  40490. /**
  40491. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  40492. * @param name Element's name, child elements will append suffixes for their own names.
  40493. * @param urlsOrVideo defines the url(s) or the video element to use
  40494. * @param options An object containing optional or exposed sub element properties
  40495. */
  40496. function VideoDome(name, urlsOrVideo, options, scene) {
  40497. var _this = _super.call(this, name, scene) || this;
  40498. _this._useDirectMapping = false;
  40499. _this._videoMode = VideoDome.MODE_MONOSCOPIC;
  40500. /**
  40501. * Oberserver used in Stereoscopic VR Mode.
  40502. */
  40503. _this._onBeforeCameraRenderObserver = null;
  40504. // set defaults and manage values
  40505. name = name || "videoDome";
  40506. options.resolution = (Math.abs(options.resolution) | 0) || 32;
  40507. options.clickToPlay = Boolean(options.clickToPlay);
  40508. options.autoPlay = options.autoPlay === undefined ? true : Boolean(options.autoPlay);
  40509. options.loop = options.loop === undefined ? true : Boolean(options.loop);
  40510. options.size = Math.abs(options.size) || (scene.activeCamera ? scene.activeCamera.maxZ * 0.48 : 1000);
  40511. if (options.useDirectMapping === undefined) {
  40512. _this._useDirectMapping = true;
  40513. }
  40514. else {
  40515. _this._useDirectMapping = options.useDirectMapping;
  40516. }
  40517. _this._setReady(false);
  40518. // create
  40519. var tempOptions = { loop: options.loop, autoPlay: options.autoPlay, autoUpdateTexture: true, poster: options.poster };
  40520. var material = _this._material = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__["BackgroundMaterial"](name + "_material", scene);
  40521. 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);
  40522. _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);
  40523. texture.onLoadObservable.addOnce(function () {
  40524. _this._setReady(true);
  40525. });
  40526. // configure material
  40527. material.useEquirectangularFOV = true;
  40528. material.fovMultiplier = 1.0;
  40529. material.opacityFresnel = false;
  40530. if (_this._useDirectMapping) {
  40531. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  40532. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  40533. material.diffuseTexture = texture;
  40534. }
  40535. else {
  40536. texture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE; // matches orientation
  40537. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  40538. material.reflectionTexture = texture;
  40539. }
  40540. // configure mesh
  40541. _this._mesh.material = material;
  40542. _this._mesh.parent = _this;
  40543. // optional configuration
  40544. if (options.clickToPlay) {
  40545. scene.onPointerUp = function () {
  40546. _this._videoTexture.video.play();
  40547. };
  40548. }
  40549. return _this;
  40550. }
  40551. Object.defineProperty(VideoDome.prototype, "videoTexture", {
  40552. /**
  40553. * Gets the video texture being displayed on the sphere
  40554. */
  40555. get: function () {
  40556. return this._videoTexture;
  40557. },
  40558. enumerable: true,
  40559. configurable: true
  40560. });
  40561. Object.defineProperty(VideoDome.prototype, "fovMultiplier", {
  40562. /**
  40563. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  40564. * Also see the options.resolution property.
  40565. */
  40566. get: function () {
  40567. return this._material.fovMultiplier;
  40568. },
  40569. set: function (value) {
  40570. this._material.fovMultiplier = value;
  40571. },
  40572. enumerable: true,
  40573. configurable: true
  40574. });
  40575. Object.defineProperty(VideoDome.prototype, "videoMode", {
  40576. /**
  40577. * Gets or set the current video mode for the video. It can be:
  40578. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  40579. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  40580. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  40581. */
  40582. get: function () {
  40583. return this._videoMode;
  40584. },
  40585. set: function (value) {
  40586. if (this._videoMode === value) {
  40587. return;
  40588. }
  40589. this._changeVideoMode(value);
  40590. },
  40591. enumerable: true,
  40592. configurable: true
  40593. });
  40594. VideoDome.prototype._changeVideoMode = function (value) {
  40595. var _this = this;
  40596. this._scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  40597. this._videoMode = value;
  40598. // Default Setup and Reset.
  40599. this._videoTexture.uScale = 1;
  40600. this._videoTexture.vScale = 1;
  40601. this._videoTexture.uOffset = 0;
  40602. this._videoTexture.vOffset = 0;
  40603. switch (value) {
  40604. case VideoDome.MODE_SIDEBYSIDE:
  40605. this._videoTexture.uScale = 0.5;
  40606. this._onBeforeCameraRenderObserver = this._scene.onBeforeCameraRenderObservable.add(function (camera) {
  40607. _this._videoTexture.uOffset = camera.isRightCamera ? 0.5 : 0.0;
  40608. });
  40609. break;
  40610. case VideoDome.MODE_TOPBOTTOM:
  40611. this._videoTexture.vScale = 0.5;
  40612. this._onBeforeCameraRenderObserver = this._scene.onBeforeCameraRenderObservable.add(function (camera) {
  40613. _this._videoTexture.vOffset = camera.isRightCamera ? 0.5 : 0.0;
  40614. });
  40615. break;
  40616. }
  40617. };
  40618. /**
  40619. * Releases resources associated with this node.
  40620. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  40621. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  40622. */
  40623. VideoDome.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  40624. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  40625. this._videoTexture.dispose();
  40626. this._mesh.dispose();
  40627. this._material.dispose();
  40628. this._scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  40629. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  40630. };
  40631. /**
  40632. * Define the video source as a Monoscopic panoramic 360 video.
  40633. */
  40634. VideoDome.MODE_MONOSCOPIC = 0;
  40635. /**
  40636. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  40637. */
  40638. VideoDome.MODE_TOPBOTTOM = 1;
  40639. /**
  40640. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  40641. */
  40642. VideoDome.MODE_SIDEBYSIDE = 2;
  40643. return VideoDome;
  40644. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]));
  40645. /***/ }),
  40646. /***/ "./Instrumentation/engineInstrumentation.ts":
  40647. /*!**************************************************!*\
  40648. !*** ./Instrumentation/engineInstrumentation.ts ***!
  40649. \**************************************************/
  40650. /*! exports provided: EngineInstrumentation */
  40651. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40652. "use strict";
  40653. __webpack_require__.r(__webpack_exports__);
  40654. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return EngineInstrumentation; });
  40655. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  40656. /**
  40657. * This class can be used to get instrumentation data from a Babylon engine
  40658. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  40659. */
  40660. var EngineInstrumentation = /** @class */ (function () {
  40661. /**
  40662. * Instantiates a new engine instrumentation.
  40663. * This class can be used to get instrumentation data from a Babylon engine
  40664. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  40665. * @param engine Defines the engine to instrument
  40666. */
  40667. function EngineInstrumentation(
  40668. /**
  40669. * Define the instrumented engine.
  40670. */
  40671. engine) {
  40672. this.engine = engine;
  40673. this._captureGPUFrameTime = false;
  40674. this._gpuFrameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40675. this._captureShaderCompilationTime = false;
  40676. this._shaderCompilationTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40677. // Observers
  40678. this._onBeginFrameObserver = null;
  40679. this._onEndFrameObserver = null;
  40680. this._onBeforeShaderCompilationObserver = null;
  40681. this._onAfterShaderCompilationObserver = null;
  40682. }
  40683. Object.defineProperty(EngineInstrumentation.prototype, "gpuFrameTimeCounter", {
  40684. // Properties
  40685. /**
  40686. * Gets the perf counter used for GPU frame time
  40687. */
  40688. get: function () {
  40689. return this._gpuFrameTime;
  40690. },
  40691. enumerable: true,
  40692. configurable: true
  40693. });
  40694. Object.defineProperty(EngineInstrumentation.prototype, "captureGPUFrameTime", {
  40695. /**
  40696. * Gets the GPU frame time capture status
  40697. */
  40698. get: function () {
  40699. return this._captureGPUFrameTime;
  40700. },
  40701. /**
  40702. * Enable or disable the GPU frame time capture
  40703. */
  40704. set: function (value) {
  40705. var _this = this;
  40706. if (value === this._captureGPUFrameTime) {
  40707. return;
  40708. }
  40709. this._captureGPUFrameTime = value;
  40710. if (value) {
  40711. this._onBeginFrameObserver = this.engine.onBeginFrameObservable.add(function () {
  40712. if (!_this._gpuFrameTimeToken) {
  40713. _this._gpuFrameTimeToken = _this.engine.startTimeQuery();
  40714. }
  40715. });
  40716. this._onEndFrameObserver = this.engine.onEndFrameObservable.add(function () {
  40717. if (!_this._gpuFrameTimeToken) {
  40718. return;
  40719. }
  40720. var time = _this.engine.endTimeQuery(_this._gpuFrameTimeToken);
  40721. if (time > -1) {
  40722. _this._gpuFrameTimeToken = null;
  40723. _this._gpuFrameTime.fetchNewFrame();
  40724. _this._gpuFrameTime.addCount(time, true);
  40725. }
  40726. });
  40727. }
  40728. else {
  40729. this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver);
  40730. this._onBeginFrameObserver = null;
  40731. this.engine.onEndFrameObservable.remove(this._onEndFrameObserver);
  40732. this._onEndFrameObserver = null;
  40733. }
  40734. },
  40735. enumerable: true,
  40736. configurable: true
  40737. });
  40738. Object.defineProperty(EngineInstrumentation.prototype, "shaderCompilationTimeCounter", {
  40739. /**
  40740. * Gets the perf counter used for shader compilation time
  40741. */
  40742. get: function () {
  40743. return this._shaderCompilationTime;
  40744. },
  40745. enumerable: true,
  40746. configurable: true
  40747. });
  40748. Object.defineProperty(EngineInstrumentation.prototype, "captureShaderCompilationTime", {
  40749. /**
  40750. * Gets the shader compilation time capture status
  40751. */
  40752. get: function () {
  40753. return this._captureShaderCompilationTime;
  40754. },
  40755. /**
  40756. * Enable or disable the shader compilation time capture
  40757. */
  40758. set: function (value) {
  40759. var _this = this;
  40760. if (value === this._captureShaderCompilationTime) {
  40761. return;
  40762. }
  40763. this._captureShaderCompilationTime = value;
  40764. if (value) {
  40765. this._onBeforeShaderCompilationObserver = this.engine.onBeforeShaderCompilationObservable.add(function () {
  40766. _this._shaderCompilationTime.fetchNewFrame();
  40767. _this._shaderCompilationTime.beginMonitoring();
  40768. });
  40769. this._onAfterShaderCompilationObserver = this.engine.onAfterShaderCompilationObservable.add(function () {
  40770. _this._shaderCompilationTime.endMonitoring();
  40771. });
  40772. }
  40773. else {
  40774. this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver);
  40775. this._onBeforeShaderCompilationObserver = null;
  40776. this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver);
  40777. this._onAfterShaderCompilationObserver = null;
  40778. }
  40779. },
  40780. enumerable: true,
  40781. configurable: true
  40782. });
  40783. /**
  40784. * Dispose and release associated resources.
  40785. */
  40786. EngineInstrumentation.prototype.dispose = function () {
  40787. this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver);
  40788. this._onBeginFrameObserver = null;
  40789. this.engine.onEndFrameObservable.remove(this._onEndFrameObserver);
  40790. this._onEndFrameObserver = null;
  40791. this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver);
  40792. this._onBeforeShaderCompilationObserver = null;
  40793. this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver);
  40794. this._onAfterShaderCompilationObserver = null;
  40795. this.engine = null;
  40796. };
  40797. return EngineInstrumentation;
  40798. }());
  40799. /***/ }),
  40800. /***/ "./Instrumentation/index.ts":
  40801. /*!**********************************!*\
  40802. !*** ./Instrumentation/index.ts ***!
  40803. \**********************************/
  40804. /*! exports provided: EngineInstrumentation, SceneInstrumentation, _TimeToken */
  40805. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40806. "use strict";
  40807. __webpack_require__.r(__webpack_exports__);
  40808. /* harmony import */ var _engineInstrumentation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engineInstrumentation */ "./Instrumentation/engineInstrumentation.ts");
  40809. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _engineInstrumentation__WEBPACK_IMPORTED_MODULE_0__["EngineInstrumentation"]; });
  40810. /* harmony import */ var _sceneInstrumentation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./sceneInstrumentation */ "./Instrumentation/sceneInstrumentation.ts");
  40811. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _sceneInstrumentation__WEBPACK_IMPORTED_MODULE_1__["SceneInstrumentation"]; });
  40812. /* harmony import */ var _timeToken__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./timeToken */ "./Instrumentation/timeToken.ts");
  40813. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _timeToken__WEBPACK_IMPORTED_MODULE_2__["_TimeToken"]; });
  40814. /***/ }),
  40815. /***/ "./Instrumentation/sceneInstrumentation.ts":
  40816. /*!*************************************************!*\
  40817. !*** ./Instrumentation/sceneInstrumentation.ts ***!
  40818. \*************************************************/
  40819. /*! exports provided: SceneInstrumentation */
  40820. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40821. "use strict";
  40822. __webpack_require__.r(__webpack_exports__);
  40823. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return SceneInstrumentation; });
  40824. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  40825. /**
  40826. * This class can be used to get instrumentation data from a Babylon engine
  40827. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  40828. */
  40829. var SceneInstrumentation = /** @class */ (function () {
  40830. /**
  40831. * Instantiates a new scene instrumentation.
  40832. * This class can be used to get instrumentation data from a Babylon engine
  40833. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  40834. * @param scene Defines the scene to instrument
  40835. */
  40836. function SceneInstrumentation(
  40837. /**
  40838. * Defines the scene to instrument
  40839. */
  40840. scene) {
  40841. var _this = this;
  40842. this.scene = scene;
  40843. this._captureActiveMeshesEvaluationTime = false;
  40844. this._activeMeshesEvaluationTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40845. this._captureRenderTargetsRenderTime = false;
  40846. this._renderTargetsRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40847. this._captureFrameTime = false;
  40848. this._frameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40849. this._captureRenderTime = false;
  40850. this._renderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40851. this._captureInterFrameTime = false;
  40852. this._interFrameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40853. this._captureParticlesRenderTime = false;
  40854. this._particlesRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40855. this._captureSpritesRenderTime = false;
  40856. this._spritesRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40857. this._capturePhysicsTime = false;
  40858. this._physicsTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40859. this._captureAnimationsTime = false;
  40860. this._animationsTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40861. this._captureCameraRenderTime = false;
  40862. this._cameraRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40863. // Observers
  40864. this._onBeforeActiveMeshesEvaluationObserver = null;
  40865. this._onAfterActiveMeshesEvaluationObserver = null;
  40866. this._onBeforeRenderTargetsRenderObserver = null;
  40867. this._onAfterRenderTargetsRenderObserver = null;
  40868. this._onAfterRenderObserver = null;
  40869. this._onBeforeDrawPhaseObserver = null;
  40870. this._onAfterDrawPhaseObserver = null;
  40871. this._onBeforeAnimationsObserver = null;
  40872. this._onBeforeParticlesRenderingObserver = null;
  40873. this._onAfterParticlesRenderingObserver = null;
  40874. this._onBeforeSpritesRenderingObserver = null;
  40875. this._onAfterSpritesRenderingObserver = null;
  40876. this._onBeforePhysicsObserver = null;
  40877. this._onAfterPhysicsObserver = null;
  40878. this._onAfterAnimationsObserver = null;
  40879. this._onBeforeCameraRenderObserver = null;
  40880. this._onAfterCameraRenderObserver = null;
  40881. // Before render
  40882. this._onBeforeAnimationsObserver = scene.onBeforeAnimationsObservable.add(function () {
  40883. if (_this._captureActiveMeshesEvaluationTime) {
  40884. _this._activeMeshesEvaluationTime.fetchNewFrame();
  40885. }
  40886. if (_this._captureRenderTargetsRenderTime) {
  40887. _this._renderTargetsRenderTime.fetchNewFrame();
  40888. }
  40889. if (_this._captureFrameTime) {
  40890. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Scene rendering");
  40891. _this._frameTime.beginMonitoring();
  40892. }
  40893. if (_this._captureInterFrameTime) {
  40894. _this._interFrameTime.endMonitoring();
  40895. }
  40896. if (_this._captureParticlesRenderTime) {
  40897. _this._particlesRenderTime.fetchNewFrame();
  40898. }
  40899. if (_this._captureSpritesRenderTime) {
  40900. _this._spritesRenderTime.fetchNewFrame();
  40901. }
  40902. if (_this._captureAnimationsTime) {
  40903. _this._animationsTime.beginMonitoring();
  40904. }
  40905. _this.scene.getEngine()._drawCalls.fetchNewFrame();
  40906. _this.scene.getEngine()._textureCollisions.fetchNewFrame();
  40907. });
  40908. // After render
  40909. this._onAfterRenderObserver = scene.onAfterRenderObservable.add(function () {
  40910. if (_this._captureFrameTime) {
  40911. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Scene rendering");
  40912. _this._frameTime.endMonitoring();
  40913. }
  40914. if (_this._captureRenderTime) {
  40915. _this._renderTime.endMonitoring(false);
  40916. }
  40917. if (_this._captureInterFrameTime) {
  40918. _this._interFrameTime.beginMonitoring();
  40919. }
  40920. });
  40921. }
  40922. Object.defineProperty(SceneInstrumentation.prototype, "activeMeshesEvaluationTimeCounter", {
  40923. // Properties
  40924. /**
  40925. * Gets the perf counter used for active meshes evaluation time
  40926. */
  40927. get: function () {
  40928. return this._activeMeshesEvaluationTime;
  40929. },
  40930. enumerable: true,
  40931. configurable: true
  40932. });
  40933. Object.defineProperty(SceneInstrumentation.prototype, "captureActiveMeshesEvaluationTime", {
  40934. /**
  40935. * Gets the active meshes evaluation time capture status
  40936. */
  40937. get: function () {
  40938. return this._captureActiveMeshesEvaluationTime;
  40939. },
  40940. /**
  40941. * Enable or disable the active meshes evaluation time capture
  40942. */
  40943. set: function (value) {
  40944. var _this = this;
  40945. if (value === this._captureActiveMeshesEvaluationTime) {
  40946. return;
  40947. }
  40948. this._captureActiveMeshesEvaluationTime = value;
  40949. if (value) {
  40950. this._onBeforeActiveMeshesEvaluationObserver = this.scene.onBeforeActiveMeshesEvaluationObservable.add(function () {
  40951. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Active meshes evaluation");
  40952. _this._activeMeshesEvaluationTime.beginMonitoring();
  40953. });
  40954. this._onAfterActiveMeshesEvaluationObserver = this.scene.onAfterActiveMeshesEvaluationObservable.add(function () {
  40955. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Active meshes evaluation");
  40956. _this._activeMeshesEvaluationTime.endMonitoring();
  40957. });
  40958. }
  40959. else {
  40960. this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver);
  40961. this._onBeforeActiveMeshesEvaluationObserver = null;
  40962. this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver);
  40963. this._onAfterActiveMeshesEvaluationObserver = null;
  40964. }
  40965. },
  40966. enumerable: true,
  40967. configurable: true
  40968. });
  40969. Object.defineProperty(SceneInstrumentation.prototype, "renderTargetsRenderTimeCounter", {
  40970. /**
  40971. * Gets the perf counter used for render targets render time
  40972. */
  40973. get: function () {
  40974. return this._renderTargetsRenderTime;
  40975. },
  40976. enumerable: true,
  40977. configurable: true
  40978. });
  40979. Object.defineProperty(SceneInstrumentation.prototype, "captureRenderTargetsRenderTime", {
  40980. /**
  40981. * Gets the render targets render time capture status
  40982. */
  40983. get: function () {
  40984. return this._captureRenderTargetsRenderTime;
  40985. },
  40986. /**
  40987. * Enable or disable the render targets render time capture
  40988. */
  40989. set: function (value) {
  40990. var _this = this;
  40991. if (value === this._captureRenderTargetsRenderTime) {
  40992. return;
  40993. }
  40994. this._captureRenderTargetsRenderTime = value;
  40995. if (value) {
  40996. this._onBeforeRenderTargetsRenderObserver = this.scene.onBeforeRenderTargetsRenderObservable.add(function () {
  40997. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Render targets rendering");
  40998. _this._renderTargetsRenderTime.beginMonitoring();
  40999. });
  41000. this._onAfterRenderTargetsRenderObserver = this.scene.onAfterRenderTargetsRenderObservable.add(function () {
  41001. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Render targets rendering");
  41002. _this._renderTargetsRenderTime.endMonitoring(false);
  41003. });
  41004. }
  41005. else {
  41006. this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver);
  41007. this._onBeforeRenderTargetsRenderObserver = null;
  41008. this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver);
  41009. this._onAfterRenderTargetsRenderObserver = null;
  41010. }
  41011. },
  41012. enumerable: true,
  41013. configurable: true
  41014. });
  41015. Object.defineProperty(SceneInstrumentation.prototype, "particlesRenderTimeCounter", {
  41016. /**
  41017. * Gets the perf counter used for particles render time
  41018. */
  41019. get: function () {
  41020. return this._particlesRenderTime;
  41021. },
  41022. enumerable: true,
  41023. configurable: true
  41024. });
  41025. Object.defineProperty(SceneInstrumentation.prototype, "captureParticlesRenderTime", {
  41026. /**
  41027. * Gets the particles render time capture status
  41028. */
  41029. get: function () {
  41030. return this._captureParticlesRenderTime;
  41031. },
  41032. /**
  41033. * Enable or disable the particles render time capture
  41034. */
  41035. set: function (value) {
  41036. var _this = this;
  41037. if (value === this._captureParticlesRenderTime) {
  41038. return;
  41039. }
  41040. this._captureParticlesRenderTime = value;
  41041. if (value) {
  41042. this._onBeforeParticlesRenderingObserver = this.scene.onBeforeParticlesRenderingObservable.add(function () {
  41043. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Particles");
  41044. _this._particlesRenderTime.beginMonitoring();
  41045. });
  41046. this._onAfterParticlesRenderingObserver = this.scene.onAfterParticlesRenderingObservable.add(function () {
  41047. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Particles");
  41048. _this._particlesRenderTime.endMonitoring(false);
  41049. });
  41050. }
  41051. else {
  41052. this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver);
  41053. this._onBeforeParticlesRenderingObserver = null;
  41054. this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver);
  41055. this._onAfterParticlesRenderingObserver = null;
  41056. }
  41057. },
  41058. enumerable: true,
  41059. configurable: true
  41060. });
  41061. Object.defineProperty(SceneInstrumentation.prototype, "spritesRenderTimeCounter", {
  41062. /**
  41063. * Gets the perf counter used for sprites render time
  41064. */
  41065. get: function () {
  41066. return this._spritesRenderTime;
  41067. },
  41068. enumerable: true,
  41069. configurable: true
  41070. });
  41071. Object.defineProperty(SceneInstrumentation.prototype, "captureSpritesRenderTime", {
  41072. /**
  41073. * Gets the sprites render time capture status
  41074. */
  41075. get: function () {
  41076. return this._captureSpritesRenderTime;
  41077. },
  41078. /**
  41079. * Enable or disable the sprites render time capture
  41080. */
  41081. set: function (value) {
  41082. var _this = this;
  41083. if (value === this._captureSpritesRenderTime) {
  41084. return;
  41085. }
  41086. this._captureSpritesRenderTime = value;
  41087. if (!this.scene.spriteManagers) {
  41088. return;
  41089. }
  41090. if (value) {
  41091. this._onBeforeSpritesRenderingObserver = this.scene.onBeforeSpritesRenderingObservable.add(function () {
  41092. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Sprites");
  41093. _this._spritesRenderTime.beginMonitoring();
  41094. });
  41095. this._onAfterSpritesRenderingObserver = this.scene.onAfterSpritesRenderingObservable.add(function () {
  41096. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Sprites");
  41097. _this._spritesRenderTime.endMonitoring(false);
  41098. });
  41099. }
  41100. else {
  41101. this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver);
  41102. this._onBeforeSpritesRenderingObserver = null;
  41103. this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver);
  41104. this._onAfterSpritesRenderingObserver = null;
  41105. }
  41106. },
  41107. enumerable: true,
  41108. configurable: true
  41109. });
  41110. Object.defineProperty(SceneInstrumentation.prototype, "physicsTimeCounter", {
  41111. /**
  41112. * Gets the perf counter used for physics time
  41113. */
  41114. get: function () {
  41115. return this._physicsTime;
  41116. },
  41117. enumerable: true,
  41118. configurable: true
  41119. });
  41120. Object.defineProperty(SceneInstrumentation.prototype, "capturePhysicsTime", {
  41121. /**
  41122. * Gets the physics time capture status
  41123. */
  41124. get: function () {
  41125. return this._capturePhysicsTime;
  41126. },
  41127. /**
  41128. * Enable or disable the physics time capture
  41129. */
  41130. set: function (value) {
  41131. var _this = this;
  41132. if (value === this._capturePhysicsTime) {
  41133. return;
  41134. }
  41135. if (!this.scene.onBeforePhysicsObservable) {
  41136. return;
  41137. }
  41138. this._capturePhysicsTime = value;
  41139. if (value) {
  41140. this._onBeforePhysicsObserver = this.scene.onBeforePhysicsObservable.add(function () {
  41141. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Physics");
  41142. _this._physicsTime.beginMonitoring();
  41143. });
  41144. this._onAfterPhysicsObserver = this.scene.onAfterPhysicsObservable.add(function () {
  41145. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Physics");
  41146. _this._physicsTime.endMonitoring();
  41147. });
  41148. }
  41149. else {
  41150. this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver);
  41151. this._onBeforePhysicsObserver = null;
  41152. this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver);
  41153. this._onAfterPhysicsObserver = null;
  41154. }
  41155. },
  41156. enumerable: true,
  41157. configurable: true
  41158. });
  41159. Object.defineProperty(SceneInstrumentation.prototype, "animationsTimeCounter", {
  41160. /**
  41161. * Gets the perf counter used for animations time
  41162. */
  41163. get: function () {
  41164. return this._animationsTime;
  41165. },
  41166. enumerable: true,
  41167. configurable: true
  41168. });
  41169. Object.defineProperty(SceneInstrumentation.prototype, "captureAnimationsTime", {
  41170. /**
  41171. * Gets the animations time capture status
  41172. */
  41173. get: function () {
  41174. return this._captureAnimationsTime;
  41175. },
  41176. /**
  41177. * Enable or disable the animations time capture
  41178. */
  41179. set: function (value) {
  41180. var _this = this;
  41181. if (value === this._captureAnimationsTime) {
  41182. return;
  41183. }
  41184. this._captureAnimationsTime = value;
  41185. if (value) {
  41186. this._onAfterAnimationsObserver = this.scene.onAfterAnimationsObservable.add(function () {
  41187. _this._animationsTime.endMonitoring();
  41188. });
  41189. }
  41190. else {
  41191. this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver);
  41192. this._onAfterAnimationsObserver = null;
  41193. }
  41194. },
  41195. enumerable: true,
  41196. configurable: true
  41197. });
  41198. Object.defineProperty(SceneInstrumentation.prototype, "frameTimeCounter", {
  41199. /**
  41200. * Gets the perf counter used for frame time capture
  41201. */
  41202. get: function () {
  41203. return this._frameTime;
  41204. },
  41205. enumerable: true,
  41206. configurable: true
  41207. });
  41208. Object.defineProperty(SceneInstrumentation.prototype, "captureFrameTime", {
  41209. /**
  41210. * Gets the frame time capture status
  41211. */
  41212. get: function () {
  41213. return this._captureFrameTime;
  41214. },
  41215. /**
  41216. * Enable or disable the frame time capture
  41217. */
  41218. set: function (value) {
  41219. this._captureFrameTime = value;
  41220. },
  41221. enumerable: true,
  41222. configurable: true
  41223. });
  41224. Object.defineProperty(SceneInstrumentation.prototype, "interFrameTimeCounter", {
  41225. /**
  41226. * Gets the perf counter used for inter-frames time capture
  41227. */
  41228. get: function () {
  41229. return this._interFrameTime;
  41230. },
  41231. enumerable: true,
  41232. configurable: true
  41233. });
  41234. Object.defineProperty(SceneInstrumentation.prototype, "captureInterFrameTime", {
  41235. /**
  41236. * Gets the inter-frames time capture status
  41237. */
  41238. get: function () {
  41239. return this._captureInterFrameTime;
  41240. },
  41241. /**
  41242. * Enable or disable the inter-frames time capture
  41243. */
  41244. set: function (value) {
  41245. this._captureInterFrameTime = value;
  41246. },
  41247. enumerable: true,
  41248. configurable: true
  41249. });
  41250. Object.defineProperty(SceneInstrumentation.prototype, "renderTimeCounter", {
  41251. /**
  41252. * Gets the perf counter used for render time capture
  41253. */
  41254. get: function () {
  41255. return this._renderTime;
  41256. },
  41257. enumerable: true,
  41258. configurable: true
  41259. });
  41260. Object.defineProperty(SceneInstrumentation.prototype, "captureRenderTime", {
  41261. /**
  41262. * Gets the render time capture status
  41263. */
  41264. get: function () {
  41265. return this._captureRenderTime;
  41266. },
  41267. /**
  41268. * Enable or disable the render time capture
  41269. */
  41270. set: function (value) {
  41271. var _this = this;
  41272. if (value === this._captureRenderTime) {
  41273. return;
  41274. }
  41275. this._captureRenderTime = value;
  41276. if (value) {
  41277. this._onBeforeDrawPhaseObserver = this.scene.onBeforeDrawPhaseObservable.add(function () {
  41278. _this._renderTime.beginMonitoring();
  41279. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Main render");
  41280. });
  41281. this._onAfterDrawPhaseObserver = this.scene.onAfterDrawPhaseObservable.add(function () {
  41282. _this._renderTime.endMonitoring(false);
  41283. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Main render");
  41284. });
  41285. }
  41286. else {
  41287. this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver);
  41288. this._onBeforeDrawPhaseObserver = null;
  41289. this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver);
  41290. this._onAfterDrawPhaseObserver = null;
  41291. }
  41292. },
  41293. enumerable: true,
  41294. configurable: true
  41295. });
  41296. Object.defineProperty(SceneInstrumentation.prototype, "cameraRenderTimeCounter", {
  41297. /**
  41298. * Gets the perf counter used for camera render time capture
  41299. */
  41300. get: function () {
  41301. return this._cameraRenderTime;
  41302. },
  41303. enumerable: true,
  41304. configurable: true
  41305. });
  41306. Object.defineProperty(SceneInstrumentation.prototype, "captureCameraRenderTime", {
  41307. /**
  41308. * Gets the camera render time capture status
  41309. */
  41310. get: function () {
  41311. return this._captureCameraRenderTime;
  41312. },
  41313. /**
  41314. * Enable or disable the camera render time capture
  41315. */
  41316. set: function (value) {
  41317. var _this = this;
  41318. if (value === this._captureCameraRenderTime) {
  41319. return;
  41320. }
  41321. this._captureCameraRenderTime = value;
  41322. if (value) {
  41323. this._onBeforeCameraRenderObserver = this.scene.onBeforeCameraRenderObservable.add(function (camera) {
  41324. _this._cameraRenderTime.beginMonitoring();
  41325. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Rendering camera " + camera.name);
  41326. });
  41327. this._onAfterCameraRenderObserver = this.scene.onAfterCameraRenderObservable.add(function (camera) {
  41328. _this._cameraRenderTime.endMonitoring(false);
  41329. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Rendering camera " + camera.name);
  41330. });
  41331. }
  41332. else {
  41333. this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  41334. this._onBeforeCameraRenderObserver = null;
  41335. this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  41336. this._onAfterCameraRenderObserver = null;
  41337. }
  41338. },
  41339. enumerable: true,
  41340. configurable: true
  41341. });
  41342. Object.defineProperty(SceneInstrumentation.prototype, "drawCallsCounter", {
  41343. /**
  41344. * Gets the perf counter used for draw calls
  41345. */
  41346. get: function () {
  41347. return this.scene.getEngine()._drawCalls;
  41348. },
  41349. enumerable: true,
  41350. configurable: true
  41351. });
  41352. Object.defineProperty(SceneInstrumentation.prototype, "textureCollisionsCounter", {
  41353. /**
  41354. * Gets the perf counter used for texture collisions
  41355. */
  41356. get: function () {
  41357. return this.scene.getEngine()._textureCollisions;
  41358. },
  41359. enumerable: true,
  41360. configurable: true
  41361. });
  41362. /**
  41363. * Dispose and release associated resources.
  41364. */
  41365. SceneInstrumentation.prototype.dispose = function () {
  41366. this.scene.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  41367. this._onAfterRenderObserver = null;
  41368. this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver);
  41369. this._onBeforeActiveMeshesEvaluationObserver = null;
  41370. this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver);
  41371. this._onAfterActiveMeshesEvaluationObserver = null;
  41372. this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver);
  41373. this._onBeforeRenderTargetsRenderObserver = null;
  41374. this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver);
  41375. this._onAfterRenderTargetsRenderObserver = null;
  41376. this.scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver);
  41377. this._onBeforeAnimationsObserver = null;
  41378. this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver);
  41379. this._onBeforeParticlesRenderingObserver = null;
  41380. this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver);
  41381. this._onAfterParticlesRenderingObserver = null;
  41382. if (this._onBeforeSpritesRenderingObserver) {
  41383. this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver);
  41384. this._onBeforeSpritesRenderingObserver = null;
  41385. }
  41386. if (this._onAfterSpritesRenderingObserver) {
  41387. this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver);
  41388. this._onAfterSpritesRenderingObserver = null;
  41389. }
  41390. this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver);
  41391. this._onBeforeDrawPhaseObserver = null;
  41392. this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver);
  41393. this._onAfterDrawPhaseObserver = null;
  41394. if (this._onBeforePhysicsObserver) {
  41395. this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver);
  41396. this._onBeforePhysicsObserver = null;
  41397. }
  41398. if (this._onAfterPhysicsObserver) {
  41399. this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver);
  41400. this._onAfterPhysicsObserver = null;
  41401. }
  41402. this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver);
  41403. this._onAfterAnimationsObserver = null;
  41404. this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  41405. this._onBeforeCameraRenderObserver = null;
  41406. this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  41407. this._onAfterCameraRenderObserver = null;
  41408. this.scene = null;
  41409. };
  41410. return SceneInstrumentation;
  41411. }());
  41412. /***/ }),
  41413. /***/ "./Instrumentation/timeToken.ts":
  41414. /*!**************************************!*\
  41415. !*** ./Instrumentation/timeToken.ts ***!
  41416. \**************************************/
  41417. /*! exports provided: _TimeToken */
  41418. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41419. "use strict";
  41420. __webpack_require__.r(__webpack_exports__);
  41421. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _TimeToken; });
  41422. /**
  41423. * @hidden
  41424. **/
  41425. var _TimeToken = /** @class */ (function () {
  41426. function _TimeToken() {
  41427. this._timeElapsedQueryEnded = false;
  41428. }
  41429. return _TimeToken;
  41430. }());
  41431. /***/ }),
  41432. /***/ "./Layers/effectLayer.ts":
  41433. /*!*******************************!*\
  41434. !*** ./Layers/effectLayer.ts ***!
  41435. \*******************************/
  41436. /*! exports provided: EffectLayer */
  41437. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41438. "use strict";
  41439. __webpack_require__.r(__webpack_exports__);
  41440. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return EffectLayer; });
  41441. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  41442. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  41443. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  41444. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  41445. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  41446. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  41447. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  41448. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  41449. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  41450. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  41451. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  41452. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  41453. /* harmony import */ var _Shaders_glowMapGeneration_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Shaders/glowMapGeneration.fragment */ "./Shaders/glowMapGeneration.fragment.ts");
  41454. /* harmony import */ var _Shaders_glowMapGeneration_vertex__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Shaders/glowMapGeneration.vertex */ "./Shaders/glowMapGeneration.vertex.ts");
  41455. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  41456. /**
  41457. * The effect layer Helps adding post process effect blended with the main pass.
  41458. *
  41459. * This can be for instance use to generate glow or higlight effects on the scene.
  41460. *
  41461. * The effect layer class can not be used directly and is intented to inherited from to be
  41462. * customized per effects.
  41463. */
  41464. var EffectLayer = /** @class */ (function () {
  41465. /**
  41466. * Instantiates a new effect Layer and references it in the scene.
  41467. * @param name The name of the layer
  41468. * @param scene The scene to use the layer in
  41469. */
  41470. function EffectLayer(
  41471. /** The Friendly of the effect in the scene */
  41472. name, scene) {
  41473. this._vertexBuffers = {};
  41474. this._maxSize = 0;
  41475. this._mainTextureDesiredSize = { width: 0, height: 0 };
  41476. this._shouldRender = true;
  41477. this._postProcesses = [];
  41478. this._textures = [];
  41479. this._emissiveTextureAndColor = { texture: null, color: new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"]() };
  41480. /**
  41481. * The clear color of the texture used to generate the glow map.
  41482. */
  41483. this.neutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"]();
  41484. /**
  41485. * Specifies wether the highlight layer is enabled or not.
  41486. */
  41487. this.isEnabled = true;
  41488. /**
  41489. * An event triggered when the effect layer has been disposed.
  41490. */
  41491. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  41492. /**
  41493. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  41494. */
  41495. this.onBeforeRenderMainTextureObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  41496. /**
  41497. * An event triggered when the generated texture is being merged in the scene.
  41498. */
  41499. this.onBeforeComposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  41500. /**
  41501. * An event triggered when the generated texture has been merged in the scene.
  41502. */
  41503. this.onAfterComposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  41504. /**
  41505. * An event triggered when the efffect layer changes its size.
  41506. */
  41507. this.onSizeChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  41508. this.name = name;
  41509. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  41510. EffectLayer._SceneComponentInitialization(this._scene);
  41511. this._engine = this._scene.getEngine();
  41512. this._maxSize = this._engine.getCaps().maxTextureSize;
  41513. this._scene.effectLayers.push(this);
  41514. // Generate Buffers
  41515. this._generateIndexBuffer();
  41516. this._genrateVertexBuffer();
  41517. }
  41518. Object.defineProperty(EffectLayer.prototype, "camera", {
  41519. /**
  41520. * Gets the camera attached to the layer.
  41521. */
  41522. get: function () {
  41523. return this._effectLayerOptions.camera;
  41524. },
  41525. enumerable: true,
  41526. configurable: true
  41527. });
  41528. Object.defineProperty(EffectLayer.prototype, "renderingGroupId", {
  41529. /**
  41530. * Gets the rendering group id the layer should render in.
  41531. */
  41532. get: function () {
  41533. return this._effectLayerOptions.renderingGroupId;
  41534. },
  41535. enumerable: true,
  41536. configurable: true
  41537. });
  41538. /**
  41539. * Initializes the effect layer with the required options.
  41540. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  41541. */
  41542. EffectLayer.prototype._init = function (options) {
  41543. // Adapt options
  41544. 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);
  41545. this._setMainTextureSize();
  41546. this._createMainTexture();
  41547. this._createTextureAndPostProcesses();
  41548. this._mergeEffect = this._createMergeEffect();
  41549. };
  41550. /**
  41551. * Generates the index buffer of the full screen quad blending to the main canvas.
  41552. */
  41553. EffectLayer.prototype._generateIndexBuffer = function () {
  41554. // Indices
  41555. var indices = [];
  41556. indices.push(0);
  41557. indices.push(1);
  41558. indices.push(2);
  41559. indices.push(0);
  41560. indices.push(2);
  41561. indices.push(3);
  41562. this._indexBuffer = this._engine.createIndexBuffer(indices);
  41563. };
  41564. /**
  41565. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  41566. */
  41567. EffectLayer.prototype._genrateVertexBuffer = function () {
  41568. // VBO
  41569. var vertices = [];
  41570. vertices.push(1, 1);
  41571. vertices.push(-1, 1);
  41572. vertices.push(-1, -1);
  41573. vertices.push(1, -1);
  41574. var vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"](this._engine, vertices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind, false, false, 2);
  41575. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind] = vertexBuffer;
  41576. };
  41577. /**
  41578. * Sets the main texture desired size which is the closest power of two
  41579. * of the engine canvas size.
  41580. */
  41581. EffectLayer.prototype._setMainTextureSize = function () {
  41582. if (this._effectLayerOptions.mainTextureFixedSize) {
  41583. this._mainTextureDesiredSize.width = this._effectLayerOptions.mainTextureFixedSize;
  41584. this._mainTextureDesiredSize.height = this._effectLayerOptions.mainTextureFixedSize;
  41585. }
  41586. else {
  41587. this._mainTextureDesiredSize.width = this._engine.getRenderWidth() * this._effectLayerOptions.mainTextureRatio;
  41588. this._mainTextureDesiredSize.height = this._engine.getRenderHeight() * this._effectLayerOptions.mainTextureRatio;
  41589. this._mainTextureDesiredSize.width = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(this._mainTextureDesiredSize.width, this._maxSize) : this._mainTextureDesiredSize.width;
  41590. this._mainTextureDesiredSize.height = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(this._mainTextureDesiredSize.height, this._maxSize) : this._mainTextureDesiredSize.height;
  41591. }
  41592. this._mainTextureDesiredSize.width = Math.floor(this._mainTextureDesiredSize.width);
  41593. this._mainTextureDesiredSize.height = Math.floor(this._mainTextureDesiredSize.height);
  41594. };
  41595. /**
  41596. * Creates the main texture for the effect layer.
  41597. */
  41598. EffectLayer.prototype._createMainTexture = function () {
  41599. var _this = this;
  41600. this._mainTexture = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__["RenderTargetTexture"]("HighlightLayerMainRTT", {
  41601. width: this._mainTextureDesiredSize.width,
  41602. height: this._mainTextureDesiredSize.height
  41603. }, this._scene, false, true, _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  41604. this._mainTexture.activeCamera = this._effectLayerOptions.camera;
  41605. this._mainTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  41606. this._mainTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  41607. this._mainTexture.anisotropicFilteringLevel = 1;
  41608. this._mainTexture.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE);
  41609. this._mainTexture.renderParticles = false;
  41610. this._mainTexture.renderList = null;
  41611. this._mainTexture.ignoreCameraViewport = true;
  41612. // Custom render function
  41613. this._mainTexture.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  41614. _this.onBeforeRenderMainTextureObservable.notifyObservers(_this);
  41615. var index;
  41616. var engine = _this._scene.getEngine();
  41617. if (depthOnlySubMeshes.length) {
  41618. engine.setColorWrite(false);
  41619. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  41620. _this._renderSubMesh(depthOnlySubMeshes.data[index]);
  41621. }
  41622. engine.setColorWrite(true);
  41623. }
  41624. for (index = 0; index < opaqueSubMeshes.length; index++) {
  41625. _this._renderSubMesh(opaqueSubMeshes.data[index]);
  41626. }
  41627. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  41628. _this._renderSubMesh(alphaTestSubMeshes.data[index]);
  41629. }
  41630. for (index = 0; index < transparentSubMeshes.length; index++) {
  41631. _this._renderSubMesh(transparentSubMeshes.data[index]);
  41632. }
  41633. };
  41634. this._mainTexture.onClearObservable.add(function (engine) {
  41635. engine.clear(_this.neutralColor, true, true, true);
  41636. });
  41637. };
  41638. /**
  41639. * Adds specific effects defines.
  41640. * @param defines The defines to add specifics to.
  41641. */
  41642. EffectLayer.prototype._addCustomEffectDefines = function (defines) {
  41643. // Nothing to add by default.
  41644. };
  41645. /**
  41646. * Checks for the readiness of the element composing the layer.
  41647. * @param subMesh the mesh to check for
  41648. * @param useInstances specify wether or not to use instances to render the mesh
  41649. * @param emissiveTexture the associated emissive texture used to generate the glow
  41650. * @return true if ready otherwise, false
  41651. */
  41652. EffectLayer.prototype._isReady = function (subMesh, useInstances, emissiveTexture) {
  41653. var material = subMesh.getMaterial();
  41654. if (!material) {
  41655. return false;
  41656. }
  41657. if (!material.isReadyForSubMesh(subMesh.getMesh(), subMesh, useInstances)) {
  41658. return false;
  41659. }
  41660. var defines = [];
  41661. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  41662. var mesh = subMesh.getMesh();
  41663. var uv1 = false;
  41664. var uv2 = false;
  41665. // Diffuse
  41666. if (material) {
  41667. var needAlphaTest = material.needAlphaTesting();
  41668. var diffuseTexture = material.getAlphaTestTexture();
  41669. var needAlphaBlendFromDiffuse = diffuseTexture && diffuseTexture.hasAlpha &&
  41670. (material.useAlphaFromDiffuseTexture || material._useAlphaFromAlbedoTexture);
  41671. if (diffuseTexture && (needAlphaTest || needAlphaBlendFromDiffuse)) {
  41672. defines.push("#define DIFFUSE");
  41673. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  41674. diffuseTexture.coordinatesIndex === 1) {
  41675. defines.push("#define DIFFUSEUV2");
  41676. uv2 = true;
  41677. }
  41678. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  41679. defines.push("#define DIFFUSEUV1");
  41680. uv1 = true;
  41681. }
  41682. if (needAlphaTest) {
  41683. defines.push("#define ALPHATEST");
  41684. defines.push("#define ALPHATESTVALUE 0.4");
  41685. }
  41686. }
  41687. var opacityTexture = material.opacityTexture;
  41688. if (opacityTexture) {
  41689. defines.push("#define OPACITY");
  41690. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  41691. opacityTexture.coordinatesIndex === 1) {
  41692. defines.push("#define OPACITYUV2");
  41693. uv2 = true;
  41694. }
  41695. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  41696. defines.push("#define OPACITYUV1");
  41697. uv1 = true;
  41698. }
  41699. }
  41700. }
  41701. // Emissive
  41702. if (emissiveTexture) {
  41703. defines.push("#define EMISSIVE");
  41704. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  41705. emissiveTexture.coordinatesIndex === 1) {
  41706. defines.push("#define EMISSIVEUV2");
  41707. uv2 = true;
  41708. }
  41709. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  41710. defines.push("#define EMISSIVEUV1");
  41711. uv1 = true;
  41712. }
  41713. }
  41714. // Vertex
  41715. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].ColorKind) && mesh.hasVertexAlpha) {
  41716. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].ColorKind);
  41717. defines.push("#define VERTEXALPHA");
  41718. }
  41719. if (uv1) {
  41720. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind);
  41721. defines.push("#define UV1");
  41722. }
  41723. if (uv2) {
  41724. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind);
  41725. defines.push("#define UV2");
  41726. }
  41727. // Bones
  41728. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  41729. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesIndicesKind);
  41730. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesWeightsKind);
  41731. if (mesh.numBoneInfluencers > 4) {
  41732. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesIndicesExtraKind);
  41733. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesWeightsExtraKind);
  41734. }
  41735. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  41736. defines.push("#define BonesPerMesh " + (mesh.skeleton ? (mesh.skeleton.bones.length + 1) : 0));
  41737. }
  41738. else {
  41739. defines.push("#define NUM_BONE_INFLUENCERS 0");
  41740. }
  41741. // Morph targets
  41742. var manager = mesh.morphTargetManager;
  41743. var morphInfluencers = 0;
  41744. if (manager) {
  41745. if (manager.numInfluencers > 0) {
  41746. defines.push("#define MORPHTARGETS");
  41747. morphInfluencers = manager.numInfluencers;
  41748. defines.push("#define NUM_MORPH_INFLUENCERS " + morphInfluencers);
  41749. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, { "NUM_MORPH_INFLUENCERS": morphInfluencers });
  41750. }
  41751. }
  41752. // Instances
  41753. if (useInstances) {
  41754. defines.push("#define INSTANCES");
  41755. attribs.push("world0");
  41756. attribs.push("world1");
  41757. attribs.push("world2");
  41758. attribs.push("world3");
  41759. }
  41760. this._addCustomEffectDefines(defines);
  41761. // Get correct effect
  41762. var join = defines.join("\n");
  41763. if (this._cachedDefines !== join) {
  41764. this._cachedDefines = join;
  41765. this._effectLayerMapGenerationEffect = this._scene.getEngine().createEffect("glowMapGeneration", attribs, ["world", "mBones", "viewProjection",
  41766. "color", "morphTargetInfluences",
  41767. "diffuseMatrix", "emissiveMatrix", "opacityMatrix", "opacityIntensity"], ["diffuseSampler", "emissiveSampler", "opacitySampler"], join, undefined, undefined, undefined, { maxSimultaneousMorphTargets: morphInfluencers });
  41768. }
  41769. return this._effectLayerMapGenerationEffect.isReady();
  41770. };
  41771. /**
  41772. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  41773. */
  41774. EffectLayer.prototype.render = function () {
  41775. var currentEffect = this._mergeEffect;
  41776. // Check
  41777. if (!currentEffect.isReady()) {
  41778. return;
  41779. }
  41780. for (var i = 0; i < this._postProcesses.length; i++) {
  41781. if (!this._postProcesses[i].isReady()) {
  41782. return;
  41783. }
  41784. }
  41785. var engine = this._scene.getEngine();
  41786. this.onBeforeComposeObservable.notifyObservers(this);
  41787. // Render
  41788. engine.enableEffect(currentEffect);
  41789. engine.setState(false);
  41790. // VBOs
  41791. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, currentEffect);
  41792. // Cache
  41793. var previousAlphaMode = engine.getAlphaMode();
  41794. // Go Blend.
  41795. engine.setAlphaMode(this._effectLayerOptions.alphaBlendingMode);
  41796. // Blends the map on the main canvas.
  41797. this._internalRender(currentEffect);
  41798. // Restore Alpha
  41799. engine.setAlphaMode(previousAlphaMode);
  41800. this.onAfterComposeObservable.notifyObservers(this);
  41801. // Handle size changes.
  41802. var size = this._mainTexture.getSize();
  41803. this._setMainTextureSize();
  41804. if (size.width !== this._mainTextureDesiredSize.width || size.height !== this._mainTextureDesiredSize.height) {
  41805. // Recreate RTT and post processes on size change.
  41806. this.onSizeChangedObservable.notifyObservers(this);
  41807. this._disposeTextureAndPostProcesses();
  41808. this._createMainTexture();
  41809. this._createTextureAndPostProcesses();
  41810. }
  41811. };
  41812. /**
  41813. * Determine if a given mesh will be used in the current effect.
  41814. * @param mesh mesh to test
  41815. * @returns true if the mesh will be used
  41816. */
  41817. EffectLayer.prototype.hasMesh = function (mesh) {
  41818. if (this.renderingGroupId === -1 || mesh.renderingGroupId === this.renderingGroupId) {
  41819. return true;
  41820. }
  41821. return false;
  41822. };
  41823. /**
  41824. * Returns true if the layer contains information to display, otherwise false.
  41825. * @returns true if the glow layer should be rendered
  41826. */
  41827. EffectLayer.prototype.shouldRender = function () {
  41828. return this.isEnabled && this._shouldRender;
  41829. };
  41830. /**
  41831. * Returns true if the mesh should render, otherwise false.
  41832. * @param mesh The mesh to render
  41833. * @returns true if it should render otherwise false
  41834. */
  41835. EffectLayer.prototype._shouldRenderMesh = function (mesh) {
  41836. return true;
  41837. };
  41838. /**
  41839. * Returns true if the mesh can be rendered, otherwise false.
  41840. * @param mesh The mesh to render
  41841. * @param material The material used on the mesh
  41842. * @returns true if it can be rendered otherwise false
  41843. */
  41844. EffectLayer.prototype._canRenderMesh = function (mesh, material) {
  41845. return !material.needAlphaBlendingForMesh(mesh);
  41846. };
  41847. /**
  41848. * Returns true if the mesh should render, otherwise false.
  41849. * @param mesh The mesh to render
  41850. * @returns true if it should render otherwise false
  41851. */
  41852. EffectLayer.prototype._shouldRenderEmissiveTextureForMesh = function () {
  41853. return true;
  41854. };
  41855. /**
  41856. * Renders the submesh passed in parameter to the generation map.
  41857. */
  41858. EffectLayer.prototype._renderSubMesh = function (subMesh) {
  41859. var _this = this;
  41860. if (!this.shouldRender()) {
  41861. return;
  41862. }
  41863. var material = subMesh.getMaterial();
  41864. var mesh = subMesh.getRenderingMesh();
  41865. var scene = this._scene;
  41866. var engine = scene.getEngine();
  41867. if (!material) {
  41868. return;
  41869. }
  41870. // Do not block in blend mode.
  41871. if (!this._canRenderMesh(mesh, material)) {
  41872. return;
  41873. }
  41874. // Culling
  41875. engine.setState(material.backFaceCulling);
  41876. // Managing instances
  41877. var batch = mesh._getInstancesRenderList(subMesh._id);
  41878. if (batch.mustReturn) {
  41879. return;
  41880. }
  41881. // Early Exit per mesh
  41882. if (!this._shouldRenderMesh(mesh)) {
  41883. return;
  41884. }
  41885. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  41886. this._setEmissiveTextureAndColor(mesh, subMesh, material);
  41887. if (this._isReady(subMesh, hardwareInstancedRendering, this._emissiveTextureAndColor.texture)) {
  41888. engine.enableEffect(this._effectLayerMapGenerationEffect);
  41889. mesh._bind(subMesh, this._effectLayerMapGenerationEffect, _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode);
  41890. this._effectLayerMapGenerationEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  41891. this._effectLayerMapGenerationEffect.setFloat4("color", this._emissiveTextureAndColor.color.r, this._emissiveTextureAndColor.color.g, this._emissiveTextureAndColor.color.b, this._emissiveTextureAndColor.color.a);
  41892. var needAlphaTest = material.needAlphaTesting();
  41893. var diffuseTexture = material.getAlphaTestTexture();
  41894. var needAlphaBlendFromDiffuse = diffuseTexture && diffuseTexture.hasAlpha &&
  41895. (material.useAlphaFromDiffuseTexture || material._useAlphaFromAlbedoTexture);
  41896. if (diffuseTexture && (needAlphaTest || needAlphaBlendFromDiffuse)) {
  41897. this._effectLayerMapGenerationEffect.setTexture("diffuseSampler", diffuseTexture);
  41898. var textureMatrix = diffuseTexture.getTextureMatrix();
  41899. if (textureMatrix) {
  41900. this._effectLayerMapGenerationEffect.setMatrix("diffuseMatrix", textureMatrix);
  41901. }
  41902. }
  41903. var opacityTexture = material.opacityTexture;
  41904. if (opacityTexture) {
  41905. this._effectLayerMapGenerationEffect.setTexture("opacitySampler", opacityTexture);
  41906. this._effectLayerMapGenerationEffect.setFloat("opacityIntensity", opacityTexture.level);
  41907. var textureMatrix = opacityTexture.getTextureMatrix();
  41908. if (textureMatrix) {
  41909. this._effectLayerMapGenerationEffect.setMatrix("opacityMatrix", textureMatrix);
  41910. }
  41911. }
  41912. // Glow emissive only
  41913. if (this._emissiveTextureAndColor.texture) {
  41914. this._effectLayerMapGenerationEffect.setTexture("emissiveSampler", this._emissiveTextureAndColor.texture);
  41915. this._effectLayerMapGenerationEffect.setMatrix("emissiveMatrix", this._emissiveTextureAndColor.texture.getTextureMatrix());
  41916. }
  41917. // Bones
  41918. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  41919. this._effectLayerMapGenerationEffect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  41920. }
  41921. // Morph targets
  41922. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindMorphTargetParameters(mesh, this._effectLayerMapGenerationEffect);
  41923. // Draw
  41924. mesh._processRendering(subMesh, this._effectLayerMapGenerationEffect, _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effectLayerMapGenerationEffect.setMatrix("world", world); });
  41925. }
  41926. else {
  41927. // Need to reset refresh rate of the main map
  41928. this._mainTexture.resetRefreshCounter();
  41929. }
  41930. };
  41931. /**
  41932. * Rebuild the required buffers.
  41933. * @hidden Internal use only.
  41934. */
  41935. EffectLayer.prototype._rebuild = function () {
  41936. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  41937. if (vb) {
  41938. vb._rebuild();
  41939. }
  41940. this._generateIndexBuffer();
  41941. };
  41942. /**
  41943. * Dispose only the render target textures and post process.
  41944. */
  41945. EffectLayer.prototype._disposeTextureAndPostProcesses = function () {
  41946. this._mainTexture.dispose();
  41947. for (var i = 0; i < this._postProcesses.length; i++) {
  41948. if (this._postProcesses[i]) {
  41949. this._postProcesses[i].dispose();
  41950. }
  41951. }
  41952. this._postProcesses = [];
  41953. for (var i = 0; i < this._textures.length; i++) {
  41954. if (this._textures[i]) {
  41955. this._textures[i].dispose();
  41956. }
  41957. }
  41958. this._textures = [];
  41959. };
  41960. /**
  41961. * Dispose the highlight layer and free resources.
  41962. */
  41963. EffectLayer.prototype.dispose = function () {
  41964. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  41965. if (vertexBuffer) {
  41966. vertexBuffer.dispose();
  41967. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind] = null;
  41968. }
  41969. if (this._indexBuffer) {
  41970. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  41971. this._indexBuffer = null;
  41972. }
  41973. // Clean textures and post processes
  41974. this._disposeTextureAndPostProcesses();
  41975. // Remove from scene
  41976. var index = this._scene.effectLayers.indexOf(this, 0);
  41977. if (index > -1) {
  41978. this._scene.effectLayers.splice(index, 1);
  41979. }
  41980. // Callback
  41981. this.onDisposeObservable.notifyObservers(this);
  41982. this.onDisposeObservable.clear();
  41983. this.onBeforeRenderMainTextureObservable.clear();
  41984. this.onBeforeComposeObservable.clear();
  41985. this.onAfterComposeObservable.clear();
  41986. this.onSizeChangedObservable.clear();
  41987. };
  41988. /**
  41989. * Gets the class name of the effect layer
  41990. * @returns the string with the class name of the effect layer
  41991. */
  41992. EffectLayer.prototype.getClassName = function () {
  41993. return "EffectLayer";
  41994. };
  41995. /**
  41996. * Creates an effect layer from parsed effect layer data
  41997. * @param parsedEffectLayer defines effect layer data
  41998. * @param scene defines the current scene
  41999. * @param rootUrl defines the root URL containing the effect layer information
  42000. * @returns a parsed effect Layer
  42001. */
  42002. EffectLayer.Parse = function (parsedEffectLayer, scene, rootUrl) {
  42003. var effectLayerType = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].Instantiate(parsedEffectLayer.customType);
  42004. return effectLayerType.Parse(parsedEffectLayer, scene, rootUrl);
  42005. };
  42006. /** @hidden */
  42007. EffectLayer._SceneComponentInitialization = function (_) {
  42008. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_14__["_DevTools"].WarnImport("EffectLayerSceneComponent");
  42009. };
  42010. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42011. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42012. ], EffectLayer.prototype, "name", void 0);
  42013. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42014. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  42015. ], EffectLayer.prototype, "neutralColor", void 0);
  42016. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42017. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42018. ], EffectLayer.prototype, "isEnabled", void 0);
  42019. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42020. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsCameraReference"])()
  42021. ], EffectLayer.prototype, "camera", null);
  42022. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42023. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42024. ], EffectLayer.prototype, "renderingGroupId", null);
  42025. return EffectLayer;
  42026. }());
  42027. /***/ }),
  42028. /***/ "./Layers/effectLayerSceneComponent.ts":
  42029. /*!*********************************************!*\
  42030. !*** ./Layers/effectLayerSceneComponent.ts ***!
  42031. \*********************************************/
  42032. /*! exports provided: EffectLayerSceneComponent */
  42033. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42034. "use strict";
  42035. __webpack_require__.r(__webpack_exports__);
  42036. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return EffectLayerSceneComponent; });
  42037. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  42038. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  42039. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  42040. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  42041. // Adds the parser to the scene parsers.
  42042. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER, function (parsedData, scene, container, rootUrl) {
  42043. if (parsedData.effectLayers) {
  42044. if (!container.effectLayers) {
  42045. container.effectLayers = new Array();
  42046. }
  42047. for (var index = 0; index < parsedData.effectLayers.length; index++) {
  42048. var effectLayer = _effectLayer__WEBPACK_IMPORTED_MODULE_2__["EffectLayer"].Parse(parsedData.effectLayers[index], scene, rootUrl);
  42049. container.effectLayers.push(effectLayer);
  42050. }
  42051. }
  42052. });
  42053. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].prototype.removeEffectLayer = function (toRemove) {
  42054. var index = this.effectLayers.indexOf(toRemove);
  42055. if (index !== -1) {
  42056. this.effectLayers.splice(index, 1);
  42057. }
  42058. return index;
  42059. };
  42060. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].prototype.addEffectLayer = function (newEffectLayer) {
  42061. this.effectLayers.push(newEffectLayer);
  42062. };
  42063. /**
  42064. * Defines the layer scene component responsible to manage any effect layers
  42065. * in a given scene.
  42066. */
  42067. var EffectLayerSceneComponent = /** @class */ (function () {
  42068. /**
  42069. * Creates a new instance of the component for the given scene
  42070. * @param scene Defines the scene to register the component in
  42071. */
  42072. function EffectLayerSceneComponent(scene) {
  42073. /**
  42074. * The component name helpfull to identify the component in the list of scene components.
  42075. */
  42076. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER;
  42077. this._renderEffects = false;
  42078. this._needStencil = false;
  42079. this._previousStencilState = false;
  42080. this.scene = scene;
  42081. this._engine = scene.getEngine();
  42082. scene.effectLayers = new Array();
  42083. }
  42084. /**
  42085. * Registers the component in a given scene
  42086. */
  42087. EffectLayerSceneComponent.prototype.register = function () {
  42088. this.scene._isReadyForMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_ISREADYFORMESH_EFFECTLAYER, this, this._isReadyForMesh);
  42089. this.scene._cameraDrawRenderTargetStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER, this, this._renderMainTexture);
  42090. this.scene._beforeCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECAMERADRAW_EFFECTLAYER, this, this._setStencil);
  42091. this.scene._afterRenderingGroupDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW, this, this._drawRenderingGroup);
  42092. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_EFFECTLAYER, this, this._setStencilBack);
  42093. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW, this, this._drawCamera);
  42094. };
  42095. /**
  42096. * Rebuilds the elements related to this component in case of
  42097. * context lost for instance.
  42098. */
  42099. EffectLayerSceneComponent.prototype.rebuild = function () {
  42100. var layers = this.scene.effectLayers;
  42101. for (var _i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
  42102. var effectLayer = layers_1[_i];
  42103. effectLayer._rebuild();
  42104. }
  42105. };
  42106. /**
  42107. * Serializes the component data to the specified json object
  42108. * @param serializationObject The object to serialize to
  42109. */
  42110. EffectLayerSceneComponent.prototype.serialize = function (serializationObject) {
  42111. // Effect layers
  42112. serializationObject.effectLayers = [];
  42113. var layers = this.scene.effectLayers;
  42114. for (var _i = 0, layers_2 = layers; _i < layers_2.length; _i++) {
  42115. var effectLayer = layers_2[_i];
  42116. if (effectLayer.serialize) {
  42117. serializationObject.effectLayers.push(effectLayer.serialize());
  42118. }
  42119. }
  42120. };
  42121. /**
  42122. * Adds all the element from the container to the scene
  42123. * @param container the container holding the elements
  42124. */
  42125. EffectLayerSceneComponent.prototype.addFromContainer = function (container) {
  42126. var _this = this;
  42127. if (!container.effectLayers) {
  42128. return;
  42129. }
  42130. container.effectLayers.forEach(function (o) {
  42131. _this.scene.addEffectLayer(o);
  42132. });
  42133. };
  42134. /**
  42135. * Removes all the elements in the container from the scene
  42136. * @param container contains the elements to remove
  42137. */
  42138. EffectLayerSceneComponent.prototype.removeFromContainer = function (container) {
  42139. var _this = this;
  42140. if (!container.effectLayers) {
  42141. return;
  42142. }
  42143. container.effectLayers.forEach(function (o) {
  42144. _this.scene.removeEffectLayer(o);
  42145. });
  42146. };
  42147. /**
  42148. * Disposes the component and the associated ressources.
  42149. */
  42150. EffectLayerSceneComponent.prototype.dispose = function () {
  42151. var layers = this.scene.effectLayers;
  42152. while (layers.length) {
  42153. layers[0].dispose();
  42154. }
  42155. };
  42156. EffectLayerSceneComponent.prototype._isReadyForMesh = function (mesh, hardwareInstancedRendering) {
  42157. var layers = this.scene.effectLayers;
  42158. for (var _i = 0, layers_3 = layers; _i < layers_3.length; _i++) {
  42159. var layer = layers_3[_i];
  42160. if (!layer.hasMesh(mesh)) {
  42161. continue;
  42162. }
  42163. for (var _a = 0, _b = mesh.subMeshes; _a < _b.length; _a++) {
  42164. var subMesh = _b[_a];
  42165. if (!layer.isReady(subMesh, hardwareInstancedRendering)) {
  42166. return false;
  42167. }
  42168. }
  42169. }
  42170. return true;
  42171. };
  42172. EffectLayerSceneComponent.prototype._renderMainTexture = function (camera) {
  42173. this._renderEffects = false;
  42174. this._needStencil = false;
  42175. var layers = this.scene.effectLayers;
  42176. if (layers && layers.length > 0) {
  42177. this._previousStencilState = this._engine.getStencilBuffer();
  42178. for (var _i = 0, layers_4 = layers; _i < layers_4.length; _i++) {
  42179. var effectLayer = layers_4[_i];
  42180. if (effectLayer.shouldRender() &&
  42181. (!effectLayer.camera ||
  42182. (effectLayer.camera.cameraRigMode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].RIG_MODE_NONE && camera === effectLayer.camera) ||
  42183. (effectLayer.camera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].RIG_MODE_NONE && effectLayer.camera._rigCameras.indexOf(camera) > -1))) {
  42184. this._renderEffects = true;
  42185. this._needStencil = this._needStencil || effectLayer.needStencil();
  42186. var renderTarget = effectLayer._mainTexture;
  42187. if (renderTarget._shouldRender()) {
  42188. this.scene.incrementRenderId();
  42189. renderTarget.render(false, false);
  42190. }
  42191. }
  42192. }
  42193. this.scene.incrementRenderId();
  42194. }
  42195. };
  42196. EffectLayerSceneComponent.prototype._setStencil = function () {
  42197. // Activate effect Layer stencil
  42198. if (this._needStencil) {
  42199. this._engine.setStencilBuffer(true);
  42200. }
  42201. };
  42202. EffectLayerSceneComponent.prototype._setStencilBack = function () {
  42203. // Restore effect Layer stencil
  42204. if (this._needStencil) {
  42205. this._engine.setStencilBuffer(this._previousStencilState);
  42206. }
  42207. };
  42208. EffectLayerSceneComponent.prototype._draw = function (renderingGroupId) {
  42209. if (this._renderEffects) {
  42210. this._engine.setDepthBuffer(false);
  42211. var layers = this.scene.effectLayers;
  42212. for (var i = 0; i < layers.length; i++) {
  42213. var effectLayer = layers[i];
  42214. if (effectLayer.renderingGroupId === renderingGroupId) {
  42215. if (effectLayer.shouldRender()) {
  42216. effectLayer.render();
  42217. }
  42218. }
  42219. }
  42220. this._engine.setDepthBuffer(true);
  42221. }
  42222. };
  42223. EffectLayerSceneComponent.prototype._drawCamera = function () {
  42224. if (this._renderEffects) {
  42225. this._draw(-1);
  42226. }
  42227. };
  42228. EffectLayerSceneComponent.prototype._drawRenderingGroup = function (index) {
  42229. if (!this.scene._isInIntermediateRendering() && this._renderEffects) {
  42230. this._draw(index);
  42231. }
  42232. };
  42233. return EffectLayerSceneComponent;
  42234. }());
  42235. _effectLayer__WEBPACK_IMPORTED_MODULE_2__["EffectLayer"]._SceneComponentInitialization = function (scene) {
  42236. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER);
  42237. if (!component) {
  42238. component = new EffectLayerSceneComponent(scene);
  42239. scene._addComponent(component);
  42240. }
  42241. };
  42242. /***/ }),
  42243. /***/ "./Layers/glowLayer.ts":
  42244. /*!*****************************!*\
  42245. !*** ./Layers/glowLayer.ts ***!
  42246. \*****************************/
  42247. /*! exports provided: GlowLayer */
  42248. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42249. "use strict";
  42250. __webpack_require__.r(__webpack_exports__);
  42251. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return GlowLayer; });
  42252. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  42253. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  42254. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  42255. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  42256. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  42257. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  42258. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  42259. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  42260. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  42261. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  42262. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  42263. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  42264. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  42265. /* harmony import */ var _Shaders_glowMapMerge_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Shaders/glowMapMerge.fragment */ "./Shaders/glowMapMerge.fragment.ts");
  42266. /* harmony import */ var _Shaders_glowMapMerge_vertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/glowMapMerge.vertex */ "./Shaders/glowMapMerge.vertex.ts");
  42267. _abstractScene__WEBPACK_IMPORTED_MODULE_10__["AbstractScene"].prototype.getGlowLayerByName = function (name) {
  42268. for (var index = 0; index < this.effectLayers.length; index++) {
  42269. if (this.effectLayers[index].name === name && this.effectLayers[index].getEffectName() === GlowLayer.EffectName) {
  42270. return this.effectLayers[index];
  42271. }
  42272. }
  42273. return null;
  42274. };
  42275. /**
  42276. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  42277. *
  42278. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  42279. * glowy meshes to your scene.
  42280. *
  42281. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  42282. */
  42283. var GlowLayer = /** @class */ (function (_super) {
  42284. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GlowLayer, _super);
  42285. /**
  42286. * Instantiates a new glow Layer and references it to the scene.
  42287. * @param name The name of the layer
  42288. * @param scene The scene to use the layer in
  42289. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  42290. */
  42291. function GlowLayer(name, scene, options) {
  42292. var _this = _super.call(this, name, scene) || this;
  42293. _this._intensity = 1.0;
  42294. _this._includedOnlyMeshes = [];
  42295. _this._excludedMeshes = [];
  42296. _this.neutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 1);
  42297. // Adapt options
  42298. _this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ mainTextureRatio: GlowLayer.DefaultTextureRatio, blurKernelSize: 32, mainTextureFixedSize: undefined, camera: null, mainTextureSamples: 1, renderingGroupId: -1 }, options);
  42299. // Initialize the layer
  42300. _this._init({
  42301. alphaBlendingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].ALPHA_ADD,
  42302. camera: _this._options.camera,
  42303. mainTextureFixedSize: _this._options.mainTextureFixedSize,
  42304. mainTextureRatio: _this._options.mainTextureRatio,
  42305. renderingGroupId: _this._options.renderingGroupId
  42306. });
  42307. return _this;
  42308. }
  42309. Object.defineProperty(GlowLayer.prototype, "blurKernelSize", {
  42310. /**
  42311. * Gets the kernel size of the blur.
  42312. */
  42313. get: function () {
  42314. return this._horizontalBlurPostprocess1.kernel;
  42315. },
  42316. /**
  42317. * Sets the kernel size of the blur.
  42318. */
  42319. set: function (value) {
  42320. this._horizontalBlurPostprocess1.kernel = value;
  42321. this._verticalBlurPostprocess1.kernel = value;
  42322. this._horizontalBlurPostprocess2.kernel = value;
  42323. this._verticalBlurPostprocess2.kernel = value;
  42324. },
  42325. enumerable: true,
  42326. configurable: true
  42327. });
  42328. Object.defineProperty(GlowLayer.prototype, "intensity", {
  42329. /**
  42330. * Gets the glow intensity.
  42331. */
  42332. get: function () {
  42333. return this._intensity;
  42334. },
  42335. /**
  42336. * Sets the glow intensity.
  42337. */
  42338. set: function (value) {
  42339. this._intensity = value;
  42340. },
  42341. enumerable: true,
  42342. configurable: true
  42343. });
  42344. /**
  42345. * Get the effect name of the layer.
  42346. * @return The effect name
  42347. */
  42348. GlowLayer.prototype.getEffectName = function () {
  42349. return GlowLayer.EffectName;
  42350. };
  42351. /**
  42352. * Create the merge effect. This is the shader use to blit the information back
  42353. * to the main canvas at the end of the scene rendering.
  42354. */
  42355. GlowLayer.prototype._createMergeEffect = function () {
  42356. // Effect
  42357. return this._engine.createEffect("glowMapMerge", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind], ["offset"], ["textureSampler", "textureSampler2"], "#define EMISSIVE \n");
  42358. };
  42359. /**
  42360. * Creates the render target textures and post processes used in the glow layer.
  42361. */
  42362. GlowLayer.prototype._createTextureAndPostProcesses = function () {
  42363. var _this = this;
  42364. var blurTextureWidth = this._mainTextureDesiredSize.width;
  42365. var blurTextureHeight = this._mainTextureDesiredSize.height;
  42366. blurTextureWidth = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(blurTextureWidth, this._maxSize) : blurTextureWidth;
  42367. blurTextureHeight = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(blurTextureHeight, this._maxSize) : blurTextureHeight;
  42368. var textureType = 0;
  42369. if (this._engine.getCaps().textureHalfFloatRender) {
  42370. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_HALF_FLOAT;
  42371. }
  42372. else {
  42373. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  42374. }
  42375. this._blurTexture1 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__["RenderTargetTexture"]("GlowLayerBlurRTT", {
  42376. width: blurTextureWidth,
  42377. height: blurTextureHeight
  42378. }, this._scene, false, true, textureType);
  42379. this._blurTexture1.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  42380. this._blurTexture1.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  42381. this._blurTexture1.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE);
  42382. this._blurTexture1.renderParticles = false;
  42383. this._blurTexture1.ignoreCameraViewport = true;
  42384. var blurTextureWidth2 = Math.floor(blurTextureWidth / 2);
  42385. var blurTextureHeight2 = Math.floor(blurTextureHeight / 2);
  42386. this._blurTexture2 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__["RenderTargetTexture"]("GlowLayerBlurRTT2", {
  42387. width: blurTextureWidth2,
  42388. height: blurTextureHeight2
  42389. }, this._scene, false, true, textureType);
  42390. this._blurTexture2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  42391. this._blurTexture2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  42392. this._blurTexture2.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE);
  42393. this._blurTexture2.renderParticles = false;
  42394. this._blurTexture2.ignoreCameraViewport = true;
  42395. this._textures = [this._blurTexture1, this._blurTexture2];
  42396. 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, {
  42397. width: blurTextureWidth,
  42398. height: blurTextureHeight
  42399. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  42400. this._horizontalBlurPostprocess1.width = blurTextureWidth;
  42401. this._horizontalBlurPostprocess1.height = blurTextureHeight;
  42402. this._horizontalBlurPostprocess1.onApplyObservable.add(function (effect) {
  42403. effect.setTexture("textureSampler", _this._mainTexture);
  42404. });
  42405. 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, {
  42406. width: blurTextureWidth,
  42407. height: blurTextureHeight
  42408. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  42409. 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, {
  42410. width: blurTextureWidth2,
  42411. height: blurTextureHeight2
  42412. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  42413. this._horizontalBlurPostprocess2.width = blurTextureWidth2;
  42414. this._horizontalBlurPostprocess2.height = blurTextureHeight2;
  42415. this._horizontalBlurPostprocess2.onApplyObservable.add(function (effect) {
  42416. effect.setTexture("textureSampler", _this._blurTexture1);
  42417. });
  42418. 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, {
  42419. width: blurTextureWidth2,
  42420. height: blurTextureHeight2
  42421. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  42422. this._postProcesses = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1, this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2];
  42423. this._postProcesses1 = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1];
  42424. this._postProcesses2 = [this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2];
  42425. this._mainTexture.samples = this._options.mainTextureSamples;
  42426. this._mainTexture.onAfterUnbindObservable.add(function () {
  42427. var internalTexture = _this._blurTexture1.getInternalTexture();
  42428. if (internalTexture) {
  42429. _this._scene.postProcessManager.directRender(_this._postProcesses1, internalTexture, true);
  42430. internalTexture = _this._blurTexture2.getInternalTexture();
  42431. if (internalTexture) {
  42432. _this._scene.postProcessManager.directRender(_this._postProcesses2, internalTexture, true);
  42433. }
  42434. }
  42435. });
  42436. // Prevent autoClear.
  42437. this._postProcesses.map(function (pp) { pp.autoClear = false; });
  42438. };
  42439. /**
  42440. * Checks for the readiness of the element composing the layer.
  42441. * @param subMesh the mesh to check for
  42442. * @param useInstances specify wether or not to use instances to render the mesh
  42443. * @param emissiveTexture the associated emissive texture used to generate the glow
  42444. * @return true if ready otherwise, false
  42445. */
  42446. GlowLayer.prototype.isReady = function (subMesh, useInstances) {
  42447. var material = subMesh.getMaterial();
  42448. var mesh = subMesh.getRenderingMesh();
  42449. if (!material || !mesh) {
  42450. return false;
  42451. }
  42452. var emissiveTexture = material.emissiveTexture;
  42453. return _super.prototype._isReady.call(this, subMesh, useInstances, emissiveTexture);
  42454. };
  42455. /**
  42456. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  42457. */
  42458. GlowLayer.prototype.needStencil = function () {
  42459. return false;
  42460. };
  42461. /**
  42462. * Returns true if the mesh can be rendered, otherwise false.
  42463. * @param mesh The mesh to render
  42464. * @param material The material used on the mesh
  42465. * @returns true if it can be rendered otherwise false
  42466. */
  42467. GlowLayer.prototype._canRenderMesh = function (mesh, material) {
  42468. return true;
  42469. };
  42470. /**
  42471. * Implementation specific of rendering the generating effect on the main canvas.
  42472. * @param effect The effect used to render through
  42473. */
  42474. GlowLayer.prototype._internalRender = function (effect) {
  42475. // Texture
  42476. effect.setTexture("textureSampler", this._blurTexture1);
  42477. effect.setTexture("textureSampler2", this._blurTexture2);
  42478. effect.setFloat("offset", this._intensity);
  42479. // Cache
  42480. var engine = this._engine;
  42481. var previousStencilBuffer = engine.getStencilBuffer();
  42482. // Draw order
  42483. engine.setStencilBuffer(false);
  42484. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, 6);
  42485. // Draw order
  42486. engine.setStencilBuffer(previousStencilBuffer);
  42487. };
  42488. /**
  42489. * Sets the required values for both the emissive texture and and the main color.
  42490. */
  42491. GlowLayer.prototype._setEmissiveTextureAndColor = function (mesh, subMesh, material) {
  42492. var textureLevel = 1.0;
  42493. if (this.customEmissiveTextureSelector) {
  42494. this._emissiveTextureAndColor.texture = this.customEmissiveTextureSelector(mesh, subMesh, material);
  42495. }
  42496. else {
  42497. if (material) {
  42498. this._emissiveTextureAndColor.texture = material.emissiveTexture;
  42499. if (this._emissiveTextureAndColor.texture) {
  42500. textureLevel = this._emissiveTextureAndColor.texture.level;
  42501. }
  42502. }
  42503. else {
  42504. this._emissiveTextureAndColor.texture = null;
  42505. }
  42506. }
  42507. if (this.customEmissiveColorSelector) {
  42508. this.customEmissiveColorSelector(mesh, subMesh, material, this._emissiveTextureAndColor.color);
  42509. }
  42510. else {
  42511. if (material.emissiveColor) {
  42512. this._emissiveTextureAndColor.color.set(material.emissiveColor.r * textureLevel, material.emissiveColor.g * textureLevel, material.emissiveColor.b * textureLevel, material.alpha);
  42513. }
  42514. else {
  42515. this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
  42516. }
  42517. }
  42518. };
  42519. /**
  42520. * Returns true if the mesh should render, otherwise false.
  42521. * @param mesh The mesh to render
  42522. * @returns true if it should render otherwise false
  42523. */
  42524. GlowLayer.prototype._shouldRenderMesh = function (mesh) {
  42525. return this.hasMesh(mesh);
  42526. };
  42527. /**
  42528. * Adds specific effects defines.
  42529. * @param defines The defines to add specifics to.
  42530. */
  42531. GlowLayer.prototype._addCustomEffectDefines = function (defines) {
  42532. defines.push("#define GLOW");
  42533. };
  42534. /**
  42535. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  42536. * @param mesh The mesh to exclude from the glow layer
  42537. */
  42538. GlowLayer.prototype.addExcludedMesh = function (mesh) {
  42539. if (this._excludedMeshes.indexOf(mesh.uniqueId) === -1) {
  42540. this._excludedMeshes.push(mesh.uniqueId);
  42541. }
  42542. };
  42543. /**
  42544. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  42545. * @param mesh The mesh to remove
  42546. */
  42547. GlowLayer.prototype.removeExcludedMesh = function (mesh) {
  42548. var index = this._excludedMeshes.indexOf(mesh.uniqueId);
  42549. if (index !== -1) {
  42550. this._excludedMeshes.splice(index, 1);
  42551. }
  42552. };
  42553. /**
  42554. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  42555. * @param mesh The mesh to include in the glow layer
  42556. */
  42557. GlowLayer.prototype.addIncludedOnlyMesh = function (mesh) {
  42558. if (this._includedOnlyMeshes.indexOf(mesh.uniqueId) === -1) {
  42559. this._includedOnlyMeshes.push(mesh.uniqueId);
  42560. }
  42561. };
  42562. /**
  42563. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  42564. * @param mesh The mesh to remove
  42565. */
  42566. GlowLayer.prototype.removeIncludedOnlyMesh = function (mesh) {
  42567. var index = this._includedOnlyMeshes.indexOf(mesh.uniqueId);
  42568. if (index !== -1) {
  42569. this._includedOnlyMeshes.splice(index, 1);
  42570. }
  42571. };
  42572. /**
  42573. * Determine if a given mesh will be used in the glow layer
  42574. * @param mesh The mesh to test
  42575. * @returns true if the mesh will be highlighted by the current glow layer
  42576. */
  42577. GlowLayer.prototype.hasMesh = function (mesh) {
  42578. if (!_super.prototype.hasMesh.call(this, mesh)) {
  42579. return false;
  42580. }
  42581. // Included Mesh
  42582. if (this._includedOnlyMeshes.length) {
  42583. return this._includedOnlyMeshes.indexOf(mesh.uniqueId) !== -1;
  42584. }
  42585. // Excluded Mesh
  42586. if (this._excludedMeshes.length) {
  42587. return this._excludedMeshes.indexOf(mesh.uniqueId) === -1;
  42588. }
  42589. return true;
  42590. };
  42591. /**
  42592. * Free any resources and references associated to a mesh.
  42593. * Internal use
  42594. * @param mesh The mesh to free.
  42595. * @hidden
  42596. */
  42597. GlowLayer.prototype._disposeMesh = function (mesh) {
  42598. this.removeIncludedOnlyMesh(mesh);
  42599. this.removeExcludedMesh(mesh);
  42600. };
  42601. /**
  42602. * Gets the class name of the effect layer
  42603. * @returns the string with the class name of the effect layer
  42604. */
  42605. GlowLayer.prototype.getClassName = function () {
  42606. return "GlowLayer";
  42607. };
  42608. /**
  42609. * Serializes this glow layer
  42610. * @returns a serialized glow layer object
  42611. */
  42612. GlowLayer.prototype.serialize = function () {
  42613. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  42614. serializationObject.customType = "BABYLON.GlowLayer";
  42615. var index;
  42616. // Included meshes
  42617. serializationObject.includedMeshes = [];
  42618. if (this._includedOnlyMeshes.length) {
  42619. for (index = 0; index < this._includedOnlyMeshes.length; index++) {
  42620. var mesh = this._scene.getMeshByUniqueID(this._includedOnlyMeshes[index]);
  42621. if (mesh) {
  42622. serializationObject.includedMeshes.push(mesh.id);
  42623. }
  42624. }
  42625. }
  42626. // Excluded meshes
  42627. serializationObject.excludedMeshes = [];
  42628. if (this._excludedMeshes.length) {
  42629. for (index = 0; index < this._excludedMeshes.length; index++) {
  42630. var mesh = this._scene.getMeshByUniqueID(this._excludedMeshes[index]);
  42631. if (mesh) {
  42632. serializationObject.excludedMeshes.push(mesh.id);
  42633. }
  42634. }
  42635. }
  42636. return serializationObject;
  42637. };
  42638. /**
  42639. * Creates a Glow Layer from parsed glow layer data
  42640. * @param parsedGlowLayer defines glow layer data
  42641. * @param scene defines the current scene
  42642. * @param rootUrl defines the root URL containing the glow layer information
  42643. * @returns a parsed Glow Layer
  42644. */
  42645. GlowLayer.Parse = function (parsedGlowLayer, scene, rootUrl) {
  42646. var gl = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new GlowLayer(parsedGlowLayer.name, scene, parsedGlowLayer.options); }, parsedGlowLayer, scene, rootUrl);
  42647. var index;
  42648. // Excluded meshes
  42649. for (index = 0; index < parsedGlowLayer.excludedMeshes.length; index++) {
  42650. var mesh = scene.getMeshByID(parsedGlowLayer.excludedMeshes[index]);
  42651. if (mesh) {
  42652. gl.addExcludedMesh(mesh);
  42653. }
  42654. }
  42655. // Included meshes
  42656. for (index = 0; index < parsedGlowLayer.includedMeshes.length; index++) {
  42657. var mesh = scene.getMeshByID(parsedGlowLayer.includedMeshes[index]);
  42658. if (mesh) {
  42659. gl.addIncludedOnlyMesh(mesh);
  42660. }
  42661. }
  42662. return gl;
  42663. };
  42664. /**
  42665. * Effect Name of the layer.
  42666. */
  42667. GlowLayer.EffectName = "GlowLayer";
  42668. /**
  42669. * The default blur kernel size used for the glow.
  42670. */
  42671. GlowLayer.DefaultBlurKernelSize = 32;
  42672. /**
  42673. * The default texture size ratio used for the glow.
  42674. */
  42675. GlowLayer.DefaultTextureRatio = 0.5;
  42676. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42677. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42678. ], GlowLayer.prototype, "blurKernelSize", null);
  42679. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42680. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42681. ], GlowLayer.prototype, "intensity", null);
  42682. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42683. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("options")
  42684. ], GlowLayer.prototype, "_options", void 0);
  42685. return GlowLayer;
  42686. }(_effectLayer__WEBPACK_IMPORTED_MODULE_9__["EffectLayer"]));
  42687. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.GlowLayer"] = GlowLayer;
  42688. /***/ }),
  42689. /***/ "./Layers/highlightLayer.ts":
  42690. /*!**********************************!*\
  42691. !*** ./Layers/highlightLayer.ts ***!
  42692. \**********************************/
  42693. /*! exports provided: HighlightLayer */
  42694. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42695. "use strict";
  42696. __webpack_require__.r(__webpack_exports__);
  42697. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return HighlightLayer; });
  42698. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  42699. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  42700. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  42701. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  42702. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  42703. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  42704. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  42705. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  42706. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  42707. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  42708. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  42709. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  42710. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  42711. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  42712. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  42713. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  42714. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  42715. /* harmony import */ var _Shaders_glowMapMerge_fragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Shaders/glowMapMerge.fragment */ "./Shaders/glowMapMerge.fragment.ts");
  42716. /* harmony import */ var _Shaders_glowMapMerge_vertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Shaders/glowMapMerge.vertex */ "./Shaders/glowMapMerge.vertex.ts");
  42717. /* harmony import */ var _Shaders_glowBlurPostProcess_fragment__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Shaders/glowBlurPostProcess.fragment */ "./Shaders/glowBlurPostProcess.fragment.ts");
  42718. _abstractScene__WEBPACK_IMPORTED_MODULE_13__["AbstractScene"].prototype.getHighlightLayerByName = function (name) {
  42719. for (var index = 0; index < this.effectLayers.length; index++) {
  42720. if (this.effectLayers[index].name === name && this.effectLayers[index].getEffectName() === HighlightLayer.EffectName) {
  42721. return this.effectLayers[index];
  42722. }
  42723. }
  42724. return null;
  42725. };
  42726. /**
  42727. * Special Glow Blur post process only blurring the alpha channel
  42728. * It enforces keeping the most luminous color in the color channel.
  42729. */
  42730. var GlowBlurPostProcess = /** @class */ (function (_super) {
  42731. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GlowBlurPostProcess, _super);
  42732. function GlowBlurPostProcess(name, direction, kernel, options, camera, samplingMode, engine, reusable) {
  42733. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE; }
  42734. var _this = _super.call(this, name, "glowBlurPostProcess", ["screenSize", "direction", "blurWidth"], null, options, camera, samplingMode, engine, reusable) || this;
  42735. _this.direction = direction;
  42736. _this.kernel = kernel;
  42737. _this.onApplyObservable.add(function (effect) {
  42738. effect.setFloat2("screenSize", _this.width, _this.height);
  42739. effect.setVector2("direction", _this.direction);
  42740. effect.setFloat("blurWidth", _this.kernel);
  42741. });
  42742. return _this;
  42743. }
  42744. return GlowBlurPostProcess;
  42745. }(_PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_9__["PostProcess"]));
  42746. /**
  42747. * The highlight layer Helps adding a glow effect around a mesh.
  42748. *
  42749. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  42750. * glowy meshes to your scene.
  42751. *
  42752. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  42753. */
  42754. var HighlightLayer = /** @class */ (function (_super) {
  42755. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HighlightLayer, _super);
  42756. /**
  42757. * Instantiates a new highlight Layer and references it to the scene..
  42758. * @param name The name of the layer
  42759. * @param scene The scene to use the layer in
  42760. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  42761. */
  42762. function HighlightLayer(name, scene, options) {
  42763. var _this = _super.call(this, name, scene) || this;
  42764. _this.name = name;
  42765. /**
  42766. * Specifies whether or not the inner glow is ACTIVE in the layer.
  42767. */
  42768. _this.innerGlow = true;
  42769. /**
  42770. * Specifies whether or not the outer glow is ACTIVE in the layer.
  42771. */
  42772. _this.outerGlow = true;
  42773. /**
  42774. * An event triggered when the highlight layer is being blurred.
  42775. */
  42776. _this.onBeforeBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  42777. /**
  42778. * An event triggered when the highlight layer has been blurred.
  42779. */
  42780. _this.onAfterBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  42781. _this._instanceGlowingMeshStencilReference = HighlightLayer.GlowingMeshStencilReference++;
  42782. _this._meshes = {};
  42783. _this._excludedMeshes = {};
  42784. _this.neutralColor = HighlightLayer.NeutralColor;
  42785. // Warn on stencil
  42786. if (!_this._engine.isStencilEnable) {
  42787. _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 }");
  42788. }
  42789. // Adapt options
  42790. _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);
  42791. // Initialize the layer
  42792. _this._init({
  42793. alphaBlendingMode: _this._options.alphaBlendingMode,
  42794. camera: _this._options.camera,
  42795. mainTextureFixedSize: _this._options.mainTextureFixedSize,
  42796. mainTextureRatio: _this._options.mainTextureRatio,
  42797. renderingGroupId: _this._options.renderingGroupId
  42798. });
  42799. // Do not render as long as no meshes have been added
  42800. _this._shouldRender = false;
  42801. return _this;
  42802. }
  42803. Object.defineProperty(HighlightLayer.prototype, "blurHorizontalSize", {
  42804. /**
  42805. * Gets the horizontal size of the blur.
  42806. */
  42807. get: function () {
  42808. return this._horizontalBlurPostprocess.kernel;
  42809. },
  42810. /**
  42811. * Specifies the horizontal size of the blur.
  42812. */
  42813. set: function (value) {
  42814. this._horizontalBlurPostprocess.kernel = value;
  42815. },
  42816. enumerable: true,
  42817. configurable: true
  42818. });
  42819. Object.defineProperty(HighlightLayer.prototype, "blurVerticalSize", {
  42820. /**
  42821. * Gets the vertical size of the blur.
  42822. */
  42823. get: function () {
  42824. return this._verticalBlurPostprocess.kernel;
  42825. },
  42826. /**
  42827. * Specifies the vertical size of the blur.
  42828. */
  42829. set: function (value) {
  42830. this._verticalBlurPostprocess.kernel = value;
  42831. },
  42832. enumerable: true,
  42833. configurable: true
  42834. });
  42835. /**
  42836. * Get the effect name of the layer.
  42837. * @return The effect name
  42838. */
  42839. HighlightLayer.prototype.getEffectName = function () {
  42840. return HighlightLayer.EffectName;
  42841. };
  42842. /**
  42843. * Create the merge effect. This is the shader use to blit the information back
  42844. * to the main canvas at the end of the scene rendering.
  42845. */
  42846. HighlightLayer.prototype._createMergeEffect = function () {
  42847. // Effect
  42848. return this._engine.createEffect("glowMapMerge", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind], ["offset"], ["textureSampler"], this._options.isStroke ? "#define STROKE \n" : undefined);
  42849. };
  42850. /**
  42851. * Creates the render target textures and post processes used in the highlight layer.
  42852. */
  42853. HighlightLayer.prototype._createTextureAndPostProcesses = function () {
  42854. var _this = this;
  42855. var blurTextureWidth = this._mainTextureDesiredSize.width * this._options.blurTextureSizeRatio;
  42856. var blurTextureHeight = this._mainTextureDesiredSize.height * this._options.blurTextureSizeRatio;
  42857. blurTextureWidth = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].GetExponentOfTwo(blurTextureWidth, this._maxSize) : blurTextureWidth;
  42858. blurTextureHeight = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].GetExponentOfTwo(blurTextureHeight, this._maxSize) : blurTextureHeight;
  42859. var textureType = 0;
  42860. if (this._engine.getCaps().textureHalfFloatRender) {
  42861. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].TEXTURETYPE_HALF_FLOAT;
  42862. }
  42863. else {
  42864. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  42865. }
  42866. this._blurTexture = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__["RenderTargetTexture"]("HighlightLayerBlurRTT", {
  42867. width: blurTextureWidth,
  42868. height: blurTextureHeight
  42869. }, this._scene, false, true, textureType);
  42870. this._blurTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  42871. this._blurTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  42872. this._blurTexture.anisotropicFilteringLevel = 16;
  42873. this._blurTexture.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].TRILINEAR_SAMPLINGMODE);
  42874. this._blurTexture.renderParticles = false;
  42875. this._blurTexture.ignoreCameraViewport = true;
  42876. this._textures = [this._blurTexture];
  42877. if (this._options.alphaBlendingMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].ALPHA_COMBINE) {
  42878. 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());
  42879. this._downSamplePostprocess.onApplyObservable.add(function (effect) {
  42880. effect.setTexture("textureSampler", _this._mainTexture);
  42881. });
  42882. 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());
  42883. this._horizontalBlurPostprocess.onApplyObservable.add(function (effect) {
  42884. effect.setFloat2("screenSize", blurTextureWidth, blurTextureHeight);
  42885. });
  42886. 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());
  42887. this._verticalBlurPostprocess.onApplyObservable.add(function (effect) {
  42888. effect.setFloat2("screenSize", blurTextureWidth, blurTextureHeight);
  42889. });
  42890. this._postProcesses = [this._downSamplePostprocess, this._horizontalBlurPostprocess, this._verticalBlurPostprocess];
  42891. }
  42892. else {
  42893. 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, {
  42894. width: blurTextureWidth,
  42895. height: blurTextureHeight
  42896. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  42897. this._horizontalBlurPostprocess.width = blurTextureWidth;
  42898. this._horizontalBlurPostprocess.height = blurTextureHeight;
  42899. this._horizontalBlurPostprocess.onApplyObservable.add(function (effect) {
  42900. effect.setTexture("textureSampler", _this._mainTexture);
  42901. });
  42902. 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, {
  42903. width: blurTextureWidth,
  42904. height: blurTextureHeight
  42905. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  42906. this._postProcesses = [this._horizontalBlurPostprocess, this._verticalBlurPostprocess];
  42907. }
  42908. this._mainTexture.onAfterUnbindObservable.add(function () {
  42909. _this.onBeforeBlurObservable.notifyObservers(_this);
  42910. var internalTexture = _this._blurTexture.getInternalTexture();
  42911. if (internalTexture) {
  42912. _this._scene.postProcessManager.directRender(_this._postProcesses, internalTexture, true);
  42913. }
  42914. _this.onAfterBlurObservable.notifyObservers(_this);
  42915. });
  42916. // Prevent autoClear.
  42917. this._postProcesses.map(function (pp) { pp.autoClear = false; });
  42918. };
  42919. /**
  42920. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  42921. */
  42922. HighlightLayer.prototype.needStencil = function () {
  42923. return true;
  42924. };
  42925. /**
  42926. * Checks for the readiness of the element composing the layer.
  42927. * @param subMesh the mesh to check for
  42928. * @param useInstances specify wether or not to use instances to render the mesh
  42929. * @param emissiveTexture the associated emissive texture used to generate the glow
  42930. * @return true if ready otherwise, false
  42931. */
  42932. HighlightLayer.prototype.isReady = function (subMesh, useInstances) {
  42933. var material = subMesh.getMaterial();
  42934. var mesh = subMesh.getRenderingMesh();
  42935. if (!material || !mesh || !this._meshes) {
  42936. return false;
  42937. }
  42938. var emissiveTexture = null;
  42939. var highlightLayerMesh = this._meshes[mesh.uniqueId];
  42940. if (highlightLayerMesh && highlightLayerMesh.glowEmissiveOnly && material) {
  42941. emissiveTexture = material.emissiveTexture;
  42942. }
  42943. return _super.prototype._isReady.call(this, subMesh, useInstances, emissiveTexture);
  42944. };
  42945. /**
  42946. * Implementation specific of rendering the generating effect on the main canvas.
  42947. * @param effect The effect used to render through
  42948. */
  42949. HighlightLayer.prototype._internalRender = function (effect) {
  42950. // Texture
  42951. effect.setTexture("textureSampler", this._blurTexture);
  42952. // Cache
  42953. var engine = this._engine;
  42954. var previousStencilBuffer = engine.getStencilBuffer();
  42955. var previousStencilFunction = engine.getStencilFunction();
  42956. var previousStencilMask = engine.getStencilMask();
  42957. var previousStencilOperationPass = engine.getStencilOperationPass();
  42958. var previousStencilOperationFail = engine.getStencilOperationFail();
  42959. var previousStencilOperationDepthFail = engine.getStencilOperationDepthFail();
  42960. var previousStencilReference = engine.getStencilFunctionReference();
  42961. // Stencil operations
  42962. engine.setStencilOperationPass(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].REPLACE);
  42963. engine.setStencilOperationFail(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].KEEP);
  42964. engine.setStencilOperationDepthFail(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].KEEP);
  42965. // Draw order
  42966. engine.setStencilMask(0x00);
  42967. engine.setStencilBuffer(true);
  42968. engine.setStencilFunctionReference(this._instanceGlowingMeshStencilReference);
  42969. // 2 passes inner outer
  42970. if (this.outerGlow) {
  42971. effect.setFloat("offset", 0);
  42972. engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].NOTEQUAL);
  42973. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  42974. }
  42975. if (this.innerGlow) {
  42976. effect.setFloat("offset", 1);
  42977. engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].EQUAL);
  42978. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  42979. }
  42980. // Restore Cache
  42981. engine.setStencilFunction(previousStencilFunction);
  42982. engine.setStencilMask(previousStencilMask);
  42983. engine.setStencilBuffer(previousStencilBuffer);
  42984. engine.setStencilOperationPass(previousStencilOperationPass);
  42985. engine.setStencilOperationFail(previousStencilOperationFail);
  42986. engine.setStencilOperationDepthFail(previousStencilOperationDepthFail);
  42987. engine.setStencilFunctionReference(previousStencilReference);
  42988. };
  42989. /**
  42990. * Returns true if the layer contains information to display, otherwise false.
  42991. */
  42992. HighlightLayer.prototype.shouldRender = function () {
  42993. if (_super.prototype.shouldRender.call(this)) {
  42994. return this._meshes ? true : false;
  42995. }
  42996. return false;
  42997. };
  42998. /**
  42999. * Returns true if the mesh should render, otherwise false.
  43000. * @param mesh The mesh to render
  43001. * @returns true if it should render otherwise false
  43002. */
  43003. HighlightLayer.prototype._shouldRenderMesh = function (mesh) {
  43004. // Excluded Mesh
  43005. if (this._excludedMeshes && this._excludedMeshes[mesh.uniqueId]) {
  43006. return false;
  43007. }
  43008. if (!_super.prototype.hasMesh.call(this, mesh)) {
  43009. return false;
  43010. }
  43011. return true;
  43012. };
  43013. /**
  43014. * Sets the required values for both the emissive texture and and the main color.
  43015. */
  43016. HighlightLayer.prototype._setEmissiveTextureAndColor = function (mesh, subMesh, material) {
  43017. var highlightLayerMesh = this._meshes[mesh.uniqueId];
  43018. if (highlightLayerMesh) {
  43019. this._emissiveTextureAndColor.color.set(highlightLayerMesh.color.r, highlightLayerMesh.color.g, highlightLayerMesh.color.b, 1.0);
  43020. }
  43021. else {
  43022. this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
  43023. }
  43024. if (highlightLayerMesh && highlightLayerMesh.glowEmissiveOnly && material) {
  43025. this._emissiveTextureAndColor.texture = material.emissiveTexture;
  43026. this._emissiveTextureAndColor.color.set(1.0, 1.0, 1.0, 1.0);
  43027. }
  43028. else {
  43029. this._emissiveTextureAndColor.texture = null;
  43030. }
  43031. };
  43032. /**
  43033. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  43034. * @param mesh The mesh to exclude from the highlight layer
  43035. */
  43036. HighlightLayer.prototype.addExcludedMesh = function (mesh) {
  43037. if (!this._excludedMeshes) {
  43038. return;
  43039. }
  43040. var meshExcluded = this._excludedMeshes[mesh.uniqueId];
  43041. if (!meshExcluded) {
  43042. this._excludedMeshes[mesh.uniqueId] = {
  43043. mesh: mesh,
  43044. beforeBind: mesh.onBeforeBindObservable.add(function (mesh) {
  43045. mesh.getEngine().setStencilBuffer(false);
  43046. }),
  43047. afterRender: mesh.onAfterRenderObservable.add(function (mesh) {
  43048. mesh.getEngine().setStencilBuffer(true);
  43049. }),
  43050. };
  43051. }
  43052. };
  43053. /**
  43054. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  43055. * @param mesh The mesh to highlight
  43056. */
  43057. HighlightLayer.prototype.removeExcludedMesh = function (mesh) {
  43058. if (!this._excludedMeshes) {
  43059. return;
  43060. }
  43061. var meshExcluded = this._excludedMeshes[mesh.uniqueId];
  43062. if (meshExcluded) {
  43063. if (meshExcluded.beforeBind) {
  43064. mesh.onBeforeBindObservable.remove(meshExcluded.beforeBind);
  43065. }
  43066. if (meshExcluded.afterRender) {
  43067. mesh.onAfterRenderObservable.remove(meshExcluded.afterRender);
  43068. }
  43069. }
  43070. this._excludedMeshes[mesh.uniqueId] = null;
  43071. };
  43072. /**
  43073. * Determine if a given mesh will be highlighted by the current HighlightLayer
  43074. * @param mesh mesh to test
  43075. * @returns true if the mesh will be highlighted by the current HighlightLayer
  43076. */
  43077. HighlightLayer.prototype.hasMesh = function (mesh) {
  43078. if (!this._meshes) {
  43079. return false;
  43080. }
  43081. if (!_super.prototype.hasMesh.call(this, mesh)) {
  43082. return false;
  43083. }
  43084. return this._meshes[mesh.uniqueId] !== undefined && this._meshes[mesh.uniqueId] !== null;
  43085. };
  43086. /**
  43087. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  43088. * @param mesh The mesh to highlight
  43089. * @param color The color of the highlight
  43090. * @param glowEmissiveOnly Extract the glow from the emissive texture
  43091. */
  43092. HighlightLayer.prototype.addMesh = function (mesh, color, glowEmissiveOnly) {
  43093. var _this = this;
  43094. if (glowEmissiveOnly === void 0) { glowEmissiveOnly = false; }
  43095. if (!this._meshes) {
  43096. return;
  43097. }
  43098. var meshHighlight = this._meshes[mesh.uniqueId];
  43099. if (meshHighlight) {
  43100. meshHighlight.color = color;
  43101. }
  43102. else {
  43103. this._meshes[mesh.uniqueId] = {
  43104. mesh: mesh,
  43105. color: color,
  43106. // Lambda required for capture due to Observable this context
  43107. observerHighlight: mesh.onBeforeBindObservable.add(function (mesh) {
  43108. if (_this._excludedMeshes && _this._excludedMeshes[mesh.uniqueId]) {
  43109. _this._defaultStencilReference(mesh);
  43110. }
  43111. else {
  43112. mesh.getScene().getEngine().setStencilFunctionReference(_this._instanceGlowingMeshStencilReference);
  43113. }
  43114. }),
  43115. observerDefault: mesh.onAfterRenderObservable.add(this._defaultStencilReference),
  43116. glowEmissiveOnly: glowEmissiveOnly
  43117. };
  43118. mesh.onDisposeObservable.add(function () {
  43119. _this._disposeMesh(mesh);
  43120. });
  43121. }
  43122. this._shouldRender = true;
  43123. };
  43124. /**
  43125. * Remove a mesh from the highlight layer in order to make it stop glowing.
  43126. * @param mesh The mesh to highlight
  43127. */
  43128. HighlightLayer.prototype.removeMesh = function (mesh) {
  43129. if (!this._meshes) {
  43130. return;
  43131. }
  43132. var meshHighlight = this._meshes[mesh.uniqueId];
  43133. if (meshHighlight) {
  43134. if (meshHighlight.observerHighlight) {
  43135. mesh.onBeforeBindObservable.remove(meshHighlight.observerHighlight);
  43136. }
  43137. if (meshHighlight.observerDefault) {
  43138. mesh.onAfterRenderObservable.remove(meshHighlight.observerDefault);
  43139. }
  43140. delete this._meshes[mesh.uniqueId];
  43141. }
  43142. this._shouldRender = false;
  43143. for (var meshHighlightToCheck in this._meshes) {
  43144. if (this._meshes[meshHighlightToCheck]) {
  43145. this._shouldRender = true;
  43146. break;
  43147. }
  43148. }
  43149. };
  43150. /**
  43151. * Force the stencil to the normal expected value for none glowing parts
  43152. */
  43153. HighlightLayer.prototype._defaultStencilReference = function (mesh) {
  43154. mesh.getScene().getEngine().setStencilFunctionReference(HighlightLayer.NormalMeshStencilReference);
  43155. };
  43156. /**
  43157. * Free any resources and references associated to a mesh.
  43158. * Internal use
  43159. * @param mesh The mesh to free.
  43160. * @hidden
  43161. */
  43162. HighlightLayer.prototype._disposeMesh = function (mesh) {
  43163. this.removeMesh(mesh);
  43164. this.removeExcludedMesh(mesh);
  43165. };
  43166. /**
  43167. * Dispose the highlight layer and free resources.
  43168. */
  43169. HighlightLayer.prototype.dispose = function () {
  43170. if (this._meshes) {
  43171. // Clean mesh references
  43172. for (var id in this._meshes) {
  43173. var meshHighlight = this._meshes[id];
  43174. if (meshHighlight && meshHighlight.mesh) {
  43175. if (meshHighlight.observerHighlight) {
  43176. meshHighlight.mesh.onBeforeBindObservable.remove(meshHighlight.observerHighlight);
  43177. }
  43178. if (meshHighlight.observerDefault) {
  43179. meshHighlight.mesh.onAfterRenderObservable.remove(meshHighlight.observerDefault);
  43180. }
  43181. }
  43182. }
  43183. this._meshes = null;
  43184. }
  43185. if (this._excludedMeshes) {
  43186. for (var id in this._excludedMeshes) {
  43187. var meshHighlight = this._excludedMeshes[id];
  43188. if (meshHighlight) {
  43189. if (meshHighlight.beforeBind) {
  43190. meshHighlight.mesh.onBeforeBindObservable.remove(meshHighlight.beforeBind);
  43191. }
  43192. if (meshHighlight.afterRender) {
  43193. meshHighlight.mesh.onAfterRenderObservable.remove(meshHighlight.afterRender);
  43194. }
  43195. }
  43196. }
  43197. this._excludedMeshes = null;
  43198. }
  43199. _super.prototype.dispose.call(this);
  43200. };
  43201. /**
  43202. * Gets the class name of the effect layer
  43203. * @returns the string with the class name of the effect layer
  43204. */
  43205. HighlightLayer.prototype.getClassName = function () {
  43206. return "HighlightLayer";
  43207. };
  43208. /**
  43209. * Serializes this Highlight layer
  43210. * @returns a serialized Highlight layer object
  43211. */
  43212. HighlightLayer.prototype.serialize = function () {
  43213. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  43214. serializationObject.customType = "BABYLON.HighlightLayer";
  43215. // Highlighted meshes
  43216. serializationObject.meshes = [];
  43217. if (this._meshes) {
  43218. for (var m in this._meshes) {
  43219. var mesh = this._meshes[m];
  43220. if (mesh) {
  43221. serializationObject.meshes.push({
  43222. glowEmissiveOnly: mesh.glowEmissiveOnly,
  43223. color: mesh.color.asArray(),
  43224. meshId: mesh.mesh.id
  43225. });
  43226. }
  43227. }
  43228. }
  43229. // Excluded meshes
  43230. serializationObject.excludedMeshes = [];
  43231. if (this._excludedMeshes) {
  43232. for (var e in this._excludedMeshes) {
  43233. var excludedMesh = this._excludedMeshes[e];
  43234. if (excludedMesh) {
  43235. serializationObject.excludedMeshes.push(excludedMesh.mesh.id);
  43236. }
  43237. }
  43238. }
  43239. return serializationObject;
  43240. };
  43241. /**
  43242. * Creates a Highlight layer from parsed Highlight layer data
  43243. * @param parsedHightlightLayer defines the Highlight layer data
  43244. * @param scene defines the current scene
  43245. * @param rootUrl defines the root URL containing the Highlight layer information
  43246. * @returns a parsed Highlight layer
  43247. */
  43248. HighlightLayer.Parse = function (parsedHightlightLayer, scene, rootUrl) {
  43249. var hl = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new HighlightLayer(parsedHightlightLayer.name, scene, parsedHightlightLayer.options); }, parsedHightlightLayer, scene, rootUrl);
  43250. var index;
  43251. // Excluded meshes
  43252. for (index = 0; index < parsedHightlightLayer.excludedMeshes.length; index++) {
  43253. var mesh = scene.getMeshByID(parsedHightlightLayer.excludedMeshes[index]);
  43254. if (mesh) {
  43255. hl.addExcludedMesh(mesh);
  43256. }
  43257. }
  43258. // Included meshes
  43259. for (index = 0; index < parsedHightlightLayer.meshes.length; index++) {
  43260. var highlightedMesh = parsedHightlightLayer.meshes[index];
  43261. var mesh = scene.getMeshByID(highlightedMesh.meshId);
  43262. if (mesh) {
  43263. hl.addMesh(mesh, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].FromArray(highlightedMesh.color), highlightedMesh.glowEmissiveOnly);
  43264. }
  43265. }
  43266. return hl;
  43267. };
  43268. /**
  43269. * Effect Name of the highlight layer.
  43270. */
  43271. HighlightLayer.EffectName = "HighlightLayer";
  43272. /**
  43273. * The neutral color used during the preparation of the glow effect.
  43274. * This is black by default as the blend operation is a blend operation.
  43275. */
  43276. HighlightLayer.NeutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"](0, 0, 0, 0);
  43277. /**
  43278. * Stencil value used for glowing meshes.
  43279. */
  43280. HighlightLayer.GlowingMeshStencilReference = 0x02;
  43281. /**
  43282. * Stencil value used for the other meshes in the scene.
  43283. */
  43284. HighlightLayer.NormalMeshStencilReference = 0x01;
  43285. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43286. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  43287. ], HighlightLayer.prototype, "innerGlow", void 0);
  43288. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43289. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  43290. ], HighlightLayer.prototype, "outerGlow", void 0);
  43291. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43292. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  43293. ], HighlightLayer.prototype, "blurHorizontalSize", null);
  43294. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43295. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  43296. ], HighlightLayer.prototype, "blurVerticalSize", null);
  43297. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43298. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("options")
  43299. ], HighlightLayer.prototype, "_options", void 0);
  43300. return HighlightLayer;
  43301. }(_effectLayer__WEBPACK_IMPORTED_MODULE_12__["EffectLayer"]));
  43302. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_16__["_TypeStore"].RegisteredTypes["BABYLON.HighlightLayer"] = HighlightLayer;
  43303. /***/ }),
  43304. /***/ "./Layers/index.ts":
  43305. /*!*************************!*\
  43306. !*** ./Layers/index.ts ***!
  43307. \*************************/
  43308. /*! exports provided: EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent */
  43309. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43310. "use strict";
  43311. __webpack_require__.r(__webpack_exports__);
  43312. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  43313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _effectLayer__WEBPACK_IMPORTED_MODULE_0__["EffectLayer"]; });
  43314. /* harmony import */ var _effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./effectLayerSceneComponent */ "./Layers/effectLayerSceneComponent.ts");
  43315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_1__["EffectLayerSceneComponent"]; });
  43316. /* harmony import */ var _glowLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glowLayer */ "./Layers/glowLayer.ts");
  43317. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _glowLayer__WEBPACK_IMPORTED_MODULE_2__["GlowLayer"]; });
  43318. /* harmony import */ var _highlightLayer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./highlightLayer */ "./Layers/highlightLayer.ts");
  43319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _highlightLayer__WEBPACK_IMPORTED_MODULE_3__["HighlightLayer"]; });
  43320. /* harmony import */ var _layer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./layer */ "./Layers/layer.ts");
  43321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _layer__WEBPACK_IMPORTED_MODULE_4__["Layer"]; });
  43322. /* harmony import */ var _layerSceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./layerSceneComponent */ "./Layers/layerSceneComponent.ts");
  43323. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _layerSceneComponent__WEBPACK_IMPORTED_MODULE_5__["LayerSceneComponent"]; });
  43324. /***/ }),
  43325. /***/ "./Layers/layer.ts":
  43326. /*!*************************!*\
  43327. !*** ./Layers/layer.ts ***!
  43328. \*************************/
  43329. /*! exports provided: Layer */
  43330. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43331. "use strict";
  43332. __webpack_require__.r(__webpack_exports__);
  43333. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return Layer; });
  43334. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  43335. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  43336. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  43337. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  43338. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  43339. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  43340. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  43341. /* harmony import */ var _layerSceneComponent__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./layerSceneComponent */ "./Layers/layerSceneComponent.ts");
  43342. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  43343. /* harmony import */ var _Shaders_layer_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/layer.fragment */ "./Shaders/layer.fragment.ts");
  43344. /* harmony import */ var _Shaders_layer_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/layer.vertex */ "./Shaders/layer.vertex.ts");
  43345. /**
  43346. * This represents a full screen 2d layer.
  43347. * This can be useful to display a picture in the background of your scene for instance.
  43348. * @see https://www.babylonjs-playground.com/#08A2BS#1
  43349. */
  43350. var Layer = /** @class */ (function () {
  43351. /**
  43352. * Instantiates a new layer.
  43353. * This represents a full screen 2d layer.
  43354. * This can be useful to display a picture in the background of your scene for instance.
  43355. * @see https://www.babylonjs-playground.com/#08A2BS#1
  43356. * @param name Define the name of the layer in the scene
  43357. * @param imgUrl Define the url of the texture to display in the layer
  43358. * @param scene Define the scene the layer belongs to
  43359. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  43360. * @param color Defines a color for the layer
  43361. */
  43362. function Layer(
  43363. /**
  43364. * Define the name of the layer.
  43365. */
  43366. name, imgUrl, scene, isBackground, color) {
  43367. this.name = name;
  43368. /**
  43369. * Define the scale of the layer in order to zoom in out of the texture.
  43370. */
  43371. this.scale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1, 1);
  43372. /**
  43373. * Define an offset for the layer in order to shift the texture.
  43374. */
  43375. this.offset = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0, 0);
  43376. /**
  43377. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  43378. */
  43379. this.alphaBlendingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE;
  43380. /**
  43381. * Define a mask to restrict the layer to only some of the scene cameras.
  43382. */
  43383. this.layerMask = 0x0FFFFFFF;
  43384. /**
  43385. * Define the list of render target the layer is visible into.
  43386. */
  43387. this.renderTargetTextures = [];
  43388. /**
  43389. * Define if the layer is only used in renderTarget or if it also
  43390. * renders in the main frame buffer of the canvas.
  43391. */
  43392. this.renderOnlyInRenderTargetTextures = false;
  43393. this._vertexBuffers = {};
  43394. /**
  43395. * An event triggered when the layer is disposed.
  43396. */
  43397. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  43398. /**
  43399. * An event triggered before rendering the scene
  43400. */
  43401. this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  43402. /**
  43403. * An event triggered after rendering the scene
  43404. */
  43405. this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  43406. this.texture = imgUrl ? new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"](imgUrl, scene, true) : null;
  43407. this.isBackground = isBackground === undefined ? true : isBackground;
  43408. this.color = color === undefined ? new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1, 1, 1, 1) : color;
  43409. this._scene = (scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene);
  43410. var layerComponent = this._scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].NAME_LAYER);
  43411. if (!layerComponent) {
  43412. layerComponent = new _layerSceneComponent__WEBPACK_IMPORTED_MODULE_7__["LayerSceneComponent"](this._scene);
  43413. this._scene._addComponent(layerComponent);
  43414. }
  43415. this._scene.layers.push(this);
  43416. var engine = this._scene.getEngine();
  43417. // VBO
  43418. var vertices = [];
  43419. vertices.push(1, 1);
  43420. vertices.push(-1, 1);
  43421. vertices.push(-1, -1);
  43422. vertices.push(1, -1);
  43423. var vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"](engine, vertices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, false, false, 2);
  43424. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = vertexBuffer;
  43425. this._createIndexBuffer();
  43426. // Effects
  43427. this._effect = engine.createEffect("layer", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], ["textureMatrix", "color", "scale", "offset"], ["textureSampler"], "");
  43428. this._alphaTestEffect = engine.createEffect("layer", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], ["textureMatrix", "color", "scale", "offset"], ["textureSampler"], "#define ALPHATEST");
  43429. }
  43430. Object.defineProperty(Layer.prototype, "onDispose", {
  43431. /**
  43432. * Back compatibility with callback before the onDisposeObservable existed.
  43433. * The set callback will be triggered when the layer has been disposed.
  43434. */
  43435. set: function (callback) {
  43436. if (this._onDisposeObserver) {
  43437. this.onDisposeObservable.remove(this._onDisposeObserver);
  43438. }
  43439. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  43440. },
  43441. enumerable: true,
  43442. configurable: true
  43443. });
  43444. Object.defineProperty(Layer.prototype, "onBeforeRender", {
  43445. /**
  43446. * Back compatibility with callback before the onBeforeRenderObservable existed.
  43447. * The set callback will be triggered just before rendering the layer.
  43448. */
  43449. set: function (callback) {
  43450. if (this._onBeforeRenderObserver) {
  43451. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  43452. }
  43453. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  43454. },
  43455. enumerable: true,
  43456. configurable: true
  43457. });
  43458. Object.defineProperty(Layer.prototype, "onAfterRender", {
  43459. /**
  43460. * Back compatibility with callback before the onAfterRenderObservable existed.
  43461. * The set callback will be triggered just after rendering the layer.
  43462. */
  43463. set: function (callback) {
  43464. if (this._onAfterRenderObserver) {
  43465. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  43466. }
  43467. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  43468. },
  43469. enumerable: true,
  43470. configurable: true
  43471. });
  43472. Layer.prototype._createIndexBuffer = function () {
  43473. var engine = this._scene.getEngine();
  43474. // Indices
  43475. var indices = [];
  43476. indices.push(0);
  43477. indices.push(1);
  43478. indices.push(2);
  43479. indices.push(0);
  43480. indices.push(2);
  43481. indices.push(3);
  43482. this._indexBuffer = engine.createIndexBuffer(indices);
  43483. };
  43484. /** @hidden */
  43485. Layer.prototype._rebuild = function () {
  43486. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  43487. if (vb) {
  43488. vb._rebuild();
  43489. }
  43490. this._createIndexBuffer();
  43491. };
  43492. /**
  43493. * Renders the layer in the scene.
  43494. */
  43495. Layer.prototype.render = function () {
  43496. var currentEffect = this.alphaTest ? this._alphaTestEffect : this._effect;
  43497. // Check
  43498. if (!currentEffect.isReady() || !this.texture || !this.texture.isReady()) {
  43499. return;
  43500. }
  43501. var engine = this._scene.getEngine();
  43502. this.onBeforeRenderObservable.notifyObservers(this);
  43503. // Render
  43504. engine.enableEffect(currentEffect);
  43505. engine.setState(false);
  43506. // Texture
  43507. currentEffect.setTexture("textureSampler", this.texture);
  43508. currentEffect.setMatrix("textureMatrix", this.texture.getTextureMatrix());
  43509. // Color
  43510. currentEffect.setFloat4("color", this.color.r, this.color.g, this.color.b, this.color.a);
  43511. // Scale / offset
  43512. currentEffect.setVector2("offset", this.offset);
  43513. currentEffect.setVector2("scale", this.scale);
  43514. // VBOs
  43515. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, currentEffect);
  43516. // Draw order
  43517. if (!this.alphaTest) {
  43518. engine.setAlphaMode(this.alphaBlendingMode);
  43519. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, 0, 6);
  43520. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  43521. }
  43522. else {
  43523. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, 0, 6);
  43524. }
  43525. this.onAfterRenderObservable.notifyObservers(this);
  43526. };
  43527. /**
  43528. * Disposes and releases the associated ressources.
  43529. */
  43530. Layer.prototype.dispose = function () {
  43531. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  43532. if (vertexBuffer) {
  43533. vertexBuffer.dispose();
  43534. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = null;
  43535. }
  43536. if (this._indexBuffer) {
  43537. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  43538. this._indexBuffer = null;
  43539. }
  43540. if (this.texture) {
  43541. this.texture.dispose();
  43542. this.texture = null;
  43543. }
  43544. // Clean RTT list
  43545. this.renderTargetTextures = [];
  43546. // Remove from scene
  43547. var index = this._scene.layers.indexOf(this);
  43548. this._scene.layers.splice(index, 1);
  43549. // Callback
  43550. this.onDisposeObservable.notifyObservers(this);
  43551. this.onDisposeObservable.clear();
  43552. this.onAfterRenderObservable.clear();
  43553. this.onBeforeRenderObservable.clear();
  43554. };
  43555. return Layer;
  43556. }());
  43557. /***/ }),
  43558. /***/ "./Layers/layerSceneComponent.ts":
  43559. /*!***************************************!*\
  43560. !*** ./Layers/layerSceneComponent.ts ***!
  43561. \***************************************/
  43562. /*! exports provided: LayerSceneComponent */
  43563. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43564. "use strict";
  43565. __webpack_require__.r(__webpack_exports__);
  43566. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return LayerSceneComponent; });
  43567. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  43568. /**
  43569. * Defines the layer scene component responsible to manage any layers
  43570. * in a given scene.
  43571. */
  43572. var LayerSceneComponent = /** @class */ (function () {
  43573. /**
  43574. * Creates a new instance of the component for the given scene
  43575. * @param scene Defines the scene to register the component in
  43576. */
  43577. function LayerSceneComponent(scene) {
  43578. /**
  43579. * The component name helpfull to identify the component in the list of scene components.
  43580. */
  43581. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_LAYER;
  43582. this.scene = scene;
  43583. this._engine = scene.getEngine();
  43584. scene.layers = new Array();
  43585. }
  43586. /**
  43587. * Registers the component in a given scene
  43588. */
  43589. LayerSceneComponent.prototype.register = function () {
  43590. this.scene._beforeCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_BEFORECAMERADRAW_LAYER, this, this._drawCameraBackground);
  43591. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_LAYER, this, this._drawCameraForeground);
  43592. this.scene._beforeRenderTargetDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_BEFORERENDERTARGETDRAW_LAYER, this, this._drawRenderTargetBackground);
  43593. this.scene._afterRenderTargetDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_AFTERRENDERTARGETDRAW_LAYER, this, this._drawRenderTargetForeground);
  43594. };
  43595. /**
  43596. * Rebuilds the elements related to this component in case of
  43597. * context lost for instance.
  43598. */
  43599. LayerSceneComponent.prototype.rebuild = function () {
  43600. var layers = this.scene.layers;
  43601. for (var _i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
  43602. var layer = layers_1[_i];
  43603. layer._rebuild();
  43604. }
  43605. };
  43606. /**
  43607. * Disposes the component and the associated ressources.
  43608. */
  43609. LayerSceneComponent.prototype.dispose = function () {
  43610. var layers = this.scene.layers;
  43611. while (layers.length) {
  43612. layers[0].dispose();
  43613. }
  43614. };
  43615. LayerSceneComponent.prototype._draw = function (predicate) {
  43616. var layers = this.scene.layers;
  43617. if (layers.length) {
  43618. this._engine.setDepthBuffer(false);
  43619. for (var _i = 0, layers_2 = layers; _i < layers_2.length; _i++) {
  43620. var layer = layers_2[_i];
  43621. if (predicate(layer)) {
  43622. layer.render();
  43623. }
  43624. }
  43625. this._engine.setDepthBuffer(true);
  43626. }
  43627. };
  43628. LayerSceneComponent.prototype._drawCameraPredicate = function (layer, isBackground, cameraLayerMask) {
  43629. return !layer.renderOnlyInRenderTargetTextures &&
  43630. layer.isBackground === isBackground &&
  43631. ((layer.layerMask & cameraLayerMask) !== 0);
  43632. };
  43633. LayerSceneComponent.prototype._drawCameraBackground = function (camera) {
  43634. var _this = this;
  43635. this._draw(function (layer) {
  43636. return _this._drawCameraPredicate(layer, true, camera.layerMask);
  43637. });
  43638. };
  43639. LayerSceneComponent.prototype._drawCameraForeground = function (camera) {
  43640. var _this = this;
  43641. this._draw(function (layer) {
  43642. return _this._drawCameraPredicate(layer, false, camera.layerMask);
  43643. });
  43644. };
  43645. LayerSceneComponent.prototype._drawRenderTargetPredicate = function (layer, isBackground, cameraLayerMask, renderTargetTexture) {
  43646. return (layer.renderTargetTextures.length > 0) &&
  43647. layer.isBackground === isBackground &&
  43648. (layer.renderTargetTextures.indexOf(renderTargetTexture) > -1) &&
  43649. ((layer.layerMask & cameraLayerMask) !== 0);
  43650. };
  43651. LayerSceneComponent.prototype._drawRenderTargetBackground = function (renderTarget) {
  43652. var _this = this;
  43653. this._draw(function (layer) {
  43654. return _this._drawRenderTargetPredicate(layer, true, _this.scene.activeCamera.layerMask, renderTarget);
  43655. });
  43656. };
  43657. LayerSceneComponent.prototype._drawRenderTargetForeground = function (renderTarget) {
  43658. var _this = this;
  43659. this._draw(function (layer) {
  43660. return _this._drawRenderTargetPredicate(layer, false, _this.scene.activeCamera.layerMask, renderTarget);
  43661. });
  43662. };
  43663. return LayerSceneComponent;
  43664. }());
  43665. /***/ }),
  43666. /***/ "./Legacy/legacy.ts":
  43667. /*!**************************!*\
  43668. !*** ./Legacy/legacy.ts ***!
  43669. \**************************/
  43670. /*! exports provided: Debug, AbstractScene, KeepAssets, AssetContainer, Node, Scene, SceneComponentConstants, Stage, Action, ActionEvent, ActionManager, Condition, ValueCondition, PredicateCondition, StateCondition, SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction, PlaySoundAction, StopSoundAction, InterpolateValueAction, Animatable, Animation, TargetedAnimation, AnimationGroup, AnimationPropertiesOverride, EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase, RuntimeAnimation, AnimationEvent, AnimationKeyInterpolation, AnimationRange, Analyser, AudioEngine, AudioSceneComponent, Sound, SoundTrack, WeightedSound, Bone, BoneIKController, BoneLookController, Skeleton, CameraInputTypes, CameraInputsManager, Camera, TargetCamera, FreeCamera, FreeCameraInputsManager, TouchCamera, ArcRotateCamera, ArcRotateCameraInputsManager, DeviceOrientationCamera, FlyCamera, FlyCameraInputsManager, FollowCamera, ArcFollowCamera, GamepadCamera, UniversalCamera, VirtualJoysticksCamera, Collider, DefaultCollisionCoordinator, PickingInfo, IntersectionInfo, BoundingBox, BoundingInfo, BoundingSphere, Ray, AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer, Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad, AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, LightGizmo, EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome, EngineInstrumentation, SceneInstrumentation, _TimeToken, EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent, LensFlare, LensFlareSystem, LensFlareSystemSceneComponent, Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, ColorCurves, EffectFallbacks, EffectCreationOptions, Effect, FresnelParameters, ImageProcessingConfigurationDefines, ImageProcessingConfiguration, Material, MaterialDefines, MaterialHelper, MultiMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, DynamicTexture, InternalTexture, MirrorTexture, RawTexture, RenderTargetTexture, Texture, UniformBuffer, MaterialFlags, Scalar, ToGammaSpace, ToLinearSpace, Epsilon, Color3, Color4, Vector2, Vector3, Vector4, Size, Quaternion, Matrix, Plane, Viewport, Frustum, Space, Axis, BezierCurve, Orientation, Angle, Arc2, Path2, Path3D, Curve3, PositionNormalVertex, PositionNormalTextureVertex, Tmp, SphericalPolynomial, SphericalHarmonics, AbstractMesh, Buffer, VertexBuffer, CSG, Geometry, GroundMesh, TrailMesh, InstancedMesh, LinesMesh, InstancedLinesMesh, MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh, VertexData, MeshBuilder, SimplificationSettings, SimplificationQueue, SimplificationType, SimplicationQueueSceneComponent, Polygon, PolygonMeshBuilder, BaseSubMesh, SubMesh, TransformNode, BoxBuilder, SphereBuilder, CylinderBuilder, TorusBuilder, LinesBuilder, PlaneBuilder, GroundBuilder, 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, FollowCameraKeyboardMoveInput, FollowCameraMouseWheelInput, FollowCameraPointersInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput, AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera, VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, OnAfterEnteringVRObservableEvent, VRExperienceHelper, WebVRFreeCamera, WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager, Octree, OctreeBlock, OctreeSceneComponent, _OcclusionDataStorage, _forceTransformFeedbackToBundle, DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, ShadowGenerator, ShadowGeneratorSceneComponent, _BabylonLoaderRegistered, BackgroundMaterial, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, HDRCubeTexture, DummyInternalTextureTracker, MultiRenderTarget, RawCubeTexture, RawTexture3D, RefractionTexture, VideoTexture, DracoCompression, DiscBuilder, RibbonBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, 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, ProceduralTexture, ProceduralTextureSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  43671. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43672. "use strict";
  43673. __webpack_require__.r(__webpack_exports__);
  43674. /* WEBPACK VAR INJECTION */(function(global) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Debug", function() { return Debug; });
  43675. /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  43676. /* harmony import */ var _Debug_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Debug/index */ "./Debug/index.ts");
  43677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractScene"]; });
  43678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeepAssets"]; });
  43679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetContainer"]; });
  43680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Node"]; });
  43681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Scene"]; });
  43682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"]; });
  43683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Stage"]; });
  43684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Action"]; });
  43685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ActionEvent"]; });
  43686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ActionManager"]; });
  43687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Condition"]; });
  43688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueCondition"]; });
  43689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PredicateCondition"]; });
  43690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StateCondition"]; });
  43691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SwitchBooleanAction"]; });
  43692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetStateAction"]; });
  43693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetValueAction"]; });
  43694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IncrementValueAction"]; });
  43695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlayAnimationAction"]; });
  43696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StopAnimationAction"]; });
  43697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DoNothingAction"]; });
  43698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CombineAction"]; });
  43699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExecuteCodeAction"]; });
  43700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetParentAction"]; });
  43701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaySoundAction"]; });
  43702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StopSoundAction"]; });
  43703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InterpolateValueAction"]; });
  43704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Animatable"]; });
  43705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Animation"]; });
  43706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TargetedAnimation"]; });
  43707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationGroup"]; });
  43708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationPropertiesOverride"]; });
  43709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"]; });
  43710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CircleEase"]; });
  43711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BackEase"]; });
  43712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BounceEase"]; });
  43713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubicEase"]; });
  43714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ElasticEase"]; });
  43715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExponentialEase"]; });
  43716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PowerEase"]; });
  43717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuadraticEase"]; });
  43718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuarticEase"]; });
  43719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuinticEase"]; });
  43720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SineEase"]; });
  43721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BezierCurveEase"]; });
  43722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RuntimeAnimation"]; });
  43723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationEvent"]; });
  43724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationKeyInterpolation"]; });
  43725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationRange"]; });
  43726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Analyser"]; });
  43727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AudioEngine"]; });
  43728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AudioSceneComponent"]; });
  43729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Sound"]; });
  43730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SoundTrack"]; });
  43731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WeightedSound"]; });
  43732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Bone"]; });
  43733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneIKController"]; });
  43734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneLookController"]; });
  43735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Skeleton"]; });
  43736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]; });
  43737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CameraInputsManager"]; });
  43738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Camera"]; });
  43739. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TargetCamera"]; });
  43740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCamera"]; });
  43741. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraInputsManager"]; });
  43742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TouchCamera"]; });
  43743. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCamera"]; });
  43744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraInputsManager"]; });
  43745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DeviceOrientationCamera"]; });
  43746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCamera"]; });
  43747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraInputsManager"]; });
  43748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCamera"]; });
  43749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcFollowCamera"]; });
  43750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadCamera"]; });
  43751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UniversalCamera"]; });
  43752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualJoysticksCamera"]; });
  43753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Collider"]; });
  43754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultCollisionCoordinator"]; });
  43755. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PickingInfo"]; });
  43756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IntersectionInfo"]; });
  43757. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBox"]; });
  43758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingInfo"]; });
  43759. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingSphere"]; });
  43760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ray"]; });
  43761. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxesViewer"]; });
  43762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneAxesViewer"]; });
  43763. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DebugLayer"]; });
  43764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsViewer"]; });
  43765. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RayHelper"]; });
  43766. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SkeletonViewer"]; });
  43767. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Constants"]; });
  43768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancingAttributeInfo"]; });
  43769. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthTextureCreationOptions"]; });
  43770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineCapabilities"]; });
  43771. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Engine"]; });
  43772. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineStore"]; });
  43773. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NullEngineOptions"]; });
  43774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NullEngine"]; });
  43775. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardEventTypes"]; });
  43776. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfo"]; });
  43777. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfoPre"]; });
  43778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"]; });
  43779. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfoBase"]; });
  43780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfoPre"]; });
  43781. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfo"]; });
  43782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ClipboardEventTypes"]; });
  43783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ClipboardInfo"]; });
  43784. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StickValues"]; });
  43785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Gamepad"]; });
  43786. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GenericPad"]; });
  43787. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadManager"]; });
  43788. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadSystemSceneComponent"]; });
  43789. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Button"]; });
  43790. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Dpad"]; });
  43791. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Pad"]; });
  43792. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxisDragGizmo"]; });
  43793. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxisScaleGizmo"]; });
  43794. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxGizmo"]; });
  43795. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Gizmo"]; });
  43796. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GizmoManager"]; });
  43797. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaneRotationGizmo"]; });
  43798. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionGizmo"]; });
  43799. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RotationGizmo"]; });
  43800. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScaleGizmo"]; });
  43801. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LightGizmo"]; });
  43802. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EnvironmentHelper"]; });
  43803. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhotoDome"]; });
  43804. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_forceSceneHelpersToBundle"]; });
  43805. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoDome"]; });
  43806. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineInstrumentation"]; });
  43807. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneInstrumentation"]; });
  43808. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TimeToken"]; });
  43809. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectLayer"]; });
  43810. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectLayerSceneComponent"]; });
  43811. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GlowLayer"]; });
  43812. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HighlightLayer"]; });
  43813. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Layer"]; });
  43814. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LayerSceneComponent"]; });
  43815. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlare"]; });
  43816. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlareSystem"]; });
  43817. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlareSystemSceneComponent"]; });
  43818. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Light"]; });
  43819. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowLight"]; });
  43820. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DirectionalLight"]; });
  43821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]; });
  43822. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointLight"]; });
  43823. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpotLight"]; });
  43824. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultLoadingScreen"]; });
  43825. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoaderProgressEvent"]; });
  43826. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"]; });
  43827. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoaderFlags"]; });
  43828. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorCurves"]; });
  43829. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectFallbacks"]; });
  43830. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectCreationOptions"]; });
  43831. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Effect"]; });
  43832. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FresnelParameters"]; });
  43833. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingConfigurationDefines"]; });
  43834. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingConfiguration"]; });
  43835. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Material"]; });
  43836. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialDefines"]; });
  43837. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialHelper"]; });
  43838. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiMaterial"]; });
  43839. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PushMaterial"]; });
  43840. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShaderMaterial"]; });
  43841. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardMaterialDefines"]; });
  43842. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardMaterial"]; });
  43843. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseTexture"]; });
  43844. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeTexture"]; });
  43845. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DynamicTexture"]; });
  43846. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InternalTexture"]; });
  43847. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MirrorTexture"]; });
  43848. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawTexture"]; });
  43849. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderTargetTexture"]; });
  43850. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Texture"]; });
  43851. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UniformBuffer"]; });
  43852. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialFlags"]; });
  43853. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Scalar"]; });
  43854. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ToGammaSpace"]; });
  43855. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]; });
  43856. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]; });
  43857. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color3"]; });
  43858. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color4"]; });
  43859. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2"]; });
  43860. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3"]; });
  43861. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector4"]; });
  43862. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Size"]; });
  43863. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]; });
  43864. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix"]; });
  43865. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Plane"]; });
  43866. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Viewport"]; });
  43867. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Frustum"]; });
  43868. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Space"]; });
  43869. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Axis"]; });
  43870. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BezierCurve"]; });
  43871. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Orientation"]; });
  43872. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Angle"]; });
  43873. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Arc2"]; });
  43874. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Path2"]; });
  43875. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Path3D"]; });
  43876. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Curve3"]; });
  43877. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionNormalVertex"]; });
  43878. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionNormalTextureVertex"]; });
  43879. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tmp"]; });
  43880. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphericalPolynomial"]; });
  43881. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphericalHarmonics"]; });
  43882. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]; });
  43883. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Buffer"]; });
  43884. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"]; });
  43885. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CSG"]; });
  43886. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Geometry"]; });
  43887. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GroundMesh"]; });
  43888. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TrailMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TrailMesh"]; });
  43889. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancedMesh"]; });
  43890. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LinesMesh"]; });
  43891. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancedLinesMesh"]; });
  43892. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshLODLevel"]; });
  43893. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_CreationDataStorage"]; });
  43894. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_InstancesBatch"]; });
  43895. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Mesh"]; });
  43896. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VertexData"]; });
  43897. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshBuilder"]; });
  43898. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationSettings"]; });
  43899. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationQueue"]; });
  43900. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationType"]; });
  43901. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplicationQueueSceneComponent"]; });
  43902. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Polygon"]; });
  43903. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolygonMeshBuilder"]; });
  43904. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSubMesh"]; });
  43905. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubMesh"]; });
  43906. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TransformNode"]; });
  43907. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoxBuilder"]; });
  43908. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereBuilder"]; });
  43909. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderBuilder"]; });
  43910. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TorusBuilder"]; });
  43911. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LinesBuilder"]; });
  43912. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaneBuilder"]; });
  43913. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GroundBuilder"]; });
  43914. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MorphTarget"]; });
  43915. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MorphTargetManager"]; });
  43916. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Database"]; });
  43917. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseParticleSystem"]; });
  43918. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GPUParticleSystem"]; });
  43919. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Particle"]; });
  43920. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleHelper"]; });
  43921. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleSystem"]; });
  43922. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_IDoNeedToBeInTheBuild"]; });
  43923. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleSystemSet"]; });
  43924. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SolidParticle"]; });
  43925. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ModelShape"]; });
  43926. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthSortedParticle"]; });
  43927. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SolidParticleSystem"]; });
  43928. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubEmitterType"]; });
  43929. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubEmitter"]; });
  43930. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngine"]; });
  43931. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngineSceneComponent"]; });
  43932. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsHelper"]; });
  43933. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsRadialExplosionEvent"]; });
  43934. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsGravitationalFieldEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsGravitationalFieldEvent"]; });
  43935. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsUpdraftEvent"]; });
  43936. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsVortexEvent"]; });
  43937. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsRadialImpulseFalloff"]; });
  43938. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsUpdraftMode"]; });
  43939. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"]; });
  43940. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsJoint"]; });
  43941. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DistanceJoint"]; });
  43942. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MotorEnabledJoint"]; });
  43943. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HingeJoint"]; });
  43944. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Hinge2Joint"]; });
  43945. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphPostProcess"]; });
  43946. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BlackAndWhitePostProcess"]; });
  43947. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BloomEffect"]; });
  43948. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BloomMergePostProcess"]; });
  43949. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BlurPostProcess"]; });
  43950. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ChromaticAberrationPostProcess"]; });
  43951. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CircleOfConfusionPostProcess"]; });
  43952. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorCorrectionPostProcess"]; });
  43953. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ConvolutionPostProcess"]; });
  43954. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldBlurPostProcess"]; });
  43955. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldEffectBlurLevel"]; });
  43956. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldEffect"]; });
  43957. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldMergePostProcessOptions"]; });
  43958. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldMergePostProcess"]; });
  43959. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayPassPostProcess"]; });
  43960. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExtractHighlightsPostProcess"]; });
  43961. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilterPostProcess"]; });
  43962. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FxaaPostProcess"]; });
  43963. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GrainPostProcess"]; });
  43964. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HighlightsPostProcess"]; });
  43965. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingPostProcess"]; });
  43966. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MotionBlurPostProcess"]; });
  43967. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PassPostProcess"]; });
  43968. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PassCubePostProcess"]; });
  43969. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcess"]; });
  43970. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessManager"]; });
  43971. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RefractionPostProcess"]; });
  43972. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SharpenPostProcess"]; });
  43973. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicInterlacePostProcess"]; });
  43974. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TonemappingOperator"]; });
  43975. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TonemapPostProcess"]; });
  43976. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumetricLightScatteringPostProcess"]; });
  43977. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDistortionCorrectionPostProcess"]; });
  43978. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ReflectionProbe"]; });
  43979. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxRenderer"]; });
  43980. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthRenderer"]; });
  43981. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthRendererSceneComponent"]; });
  43982. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EdgesRenderer"]; });
  43983. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LineEdgesRenderer"]; });
  43984. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GeometryBufferRenderer"]; });
  43985. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GeometryBufferRendererSceneComponent"]; });
  43986. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OutlineRenderer"]; });
  43987. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingGroup"]; });
  43988. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingGroupInfo"]; });
  43989. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingManager"]; });
  43990. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"]; });
  43991. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Sprite"]; });
  43992. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpriteManager"]; });
  43993. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpriteSceneComponent"]; });
  43994. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_AlphaState"]; });
  43995. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_DepthCullingState"]; });
  43996. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_StencilState"]; });
  43997. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AndOrNotEvaluator"]; });
  43998. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetTaskState"]; });
  43999. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractAssetTask"]; });
  44000. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetsProgressEvent"]; });
  44001. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshAssetTask"]; });
  44002. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextFileAssetTask"]; });
  44003. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BinaryFileAssetTask"]; });
  44004. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageAssetTask"]; });
  44005. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureAssetTask"]; });
  44006. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeTextureAssetTask"]; });
  44007. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRCubeTextureAssetTask"]; });
  44008. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetsManager"]; });
  44009. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DDSTools"]; });
  44010. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["expandToProperty"]; });
  44011. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serialize"]; });
  44012. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsTexture"]; });
  44013. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColor3"]; });
  44014. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsFresnelParameters"]; });
  44015. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsVector2"]; });
  44016. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsVector3"]; });
  44017. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsMeshReference"]; });
  44018. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColorCurves"]; });
  44019. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColor4"]; });
  44020. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsImageProcessingConfiguration"]; });
  44021. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsQuaternion"]; });
  44022. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsCameraReference"]; });
  44023. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SerializationHelper"]; });
  44024. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Deferred"]; });
  44025. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"]; });
  44026. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilesInput"]; });
  44027. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"]; });
  44028. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EventState"]; });
  44029. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Observer"]; });
  44030. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiObserver"]; });
  44031. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Observable"]; });
  44032. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PerformanceMonitor"]; });
  44033. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RollingAverage"]; });
  44034. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PromisePolyfill"]; });
  44035. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimization"]; });
  44036. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureOptimization"]; });
  44037. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HardwareScalingOptimization"]; });
  44038. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowsOptimization"]; });
  44039. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessesOptimization"]; });
  44040. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlaresOptimization"]; });
  44041. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CustomOptimization"]; });
  44042. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticlesOptimization"]; });
  44043. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderTargetsOptimization"]; });
  44044. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MergeMeshesOptimization"]; });
  44045. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimizerOptions"]; });
  44046. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimizer"]; });
  44047. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneSerializer"]; });
  44048. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SmartArray"]; });
  44049. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SmartArrayNoDuplicate"]; });
  44050. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StringDictionary"]; });
  44051. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tags"]; });
  44052. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureTools"]; });
  44053. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TGATools"]; });
  44054. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorGradient"]; });
  44055. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color3Gradient"]; });
  44056. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FactorGradient"]; });
  44057. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LoadFileError"]; });
  44058. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RetryStrategy"]; });
  44059. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tools"]; });
  44060. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]; });
  44061. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["className"]; });
  44062. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AsyncLoop"]; });
  44063. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoRecorder"]; });
  44064. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"]; });
  44065. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"]; });
  44066. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WorkerPool"]; });
  44067. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Logger"]; });
  44068. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"]; });
  44069. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilesInputStore"]; });
  44070. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"]; });
  44071. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PivotTools"]; });
  44072. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PrecisionDate"]; });
  44073. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScreenshotTools"]; });
  44074. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  44075. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BouncingBehavior"]; });
  44076. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FramingBehavior"]; });
  44077. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AttachToBoxBehavior"]; });
  44078. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FadeInOutBehavior"]; });
  44079. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiPointerScaleBehavior"]; });
  44080. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]; });
  44081. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SixDofDragBehavior"]; });
  44082. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  44083. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraKeyboardMoveInput"]; });
  44084. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraMouseWheelInput"]; });
  44085. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraPointersInput"]; });
  44086. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraVRDeviceOrientationInput"]; });
  44087. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraKeyboardInput"]; });
  44088. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraMouseInput"]; });
  44089. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraKeyboardMoveInput"]; });
  44090. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraMouseWheelInput"]; });
  44091. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraPointersInput"]; });
  44092. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraDeviceOrientationInput"]; });
  44093. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraGamepadInput"]; });
  44094. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraKeyboardMoveInput"]; });
  44095. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraMouseInput"]; });
  44096. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraTouchInput"]; });
  44097. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraVirtualJoystickInput"]; });
  44098. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphArcRotateCamera"]; });
  44099. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphFreeCamera"]; });
  44100. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphGamepadCamera"]; });
  44101. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphUniversalCamera"]; });
  44102. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicArcRotateCamera"]; });
  44103. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicFreeCamera"]; });
  44104. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicGamepadCamera"]; });
  44105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicUniversalCamera"]; });
  44106. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRCameraMetrics"]; });
  44107. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationArcRotateCamera"]; });
  44108. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationFreeCamera"]; });
  44109. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationGamepadCamera"]; });
  44110. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OnAfterEnteringVRObservableEvent"]; });
  44111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRExperienceHelper"]; });
  44112. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebVRFreeCamera"]; });
  44113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRCamera"]; });
  44114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUIButton"]; });
  44115. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUIOptions"]; });
  44116. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUI"]; });
  44117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRState"]; });
  44118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRExperienceHelper"]; });
  44119. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRController"]; });
  44120. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRInput"]; });
  44121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRManagedOutputCanvas"]; });
  44122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRSessionManager"]; });
  44123. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Octree"]; });
  44124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OctreeBlock"]; });
  44125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OctreeSceneComponent"]; });
  44126. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_OcclusionDataStorage"]; });
  44127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_forceTransformFeedbackToBundle"]; });
  44128. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  44129. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GearVRController"]; });
  44130. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GenericController"]; });
  44131. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OculusTouchController"]; });
  44132. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerType"]; });
  44133. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerHelper"]; });
  44134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledController"]; });
  44135. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ViveController"]; });
  44136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebVRController"]; });
  44137. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WindowsMotionController"]; });
  44138. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]; });
  44139. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowGeneratorSceneComponent"]; });
  44140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_BabylonLoaderRegistered"]; });
  44141. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  44142. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRBaseMaterial"]; });
  44143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRBaseSimpleMaterial"]; });
  44144. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRMaterial"]; });
  44145. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRMetallicRoughnessMaterial"]; });
  44146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRSpecularGlossinessMaterial"]; });
  44147. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorGradingTexture"]; });
  44148. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRCubeTexture"]; });
  44149. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DummyInternalTextureTracker"]; });
  44150. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiRenderTarget"]; });
  44151. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawCubeTexture"]; });
  44152. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawTexture3D"]; });
  44153. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RefractionTexture"]; });
  44154. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoTexture"]; });
  44155. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DracoCompression"]; });
  44156. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DiscBuilder"]; });
  44157. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RibbonBuilder"]; });
  44158. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TorusKnotBuilder"]; });
  44159. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolygonBuilder"]; });
  44160. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShapeBuilder"]; });
  44161. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LatheBuilder"]; });
  44162. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TubeBuilder"]; });
  44163. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolyhedronBuilder"]; });
  44164. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IcoSphereBuilder"]; });
  44165. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DecalBuilder"]; });
  44166. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoxParticleEmitter"]; });
  44167. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ConeParticleEmitter"]; });
  44168. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderParticleEmitter"]; });
  44169. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderDirectedParticleEmitter"]; });
  44170. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HemisphericParticleEmitter"]; });
  44171. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointParticleEmitter"]; });
  44172. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereParticleEmitter"]; });
  44173. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereDirectedParticleEmitter"]; });
  44174. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CannonJSPlugin"]; });
  44175. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AmmoJSPlugin"]; });
  44176. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OimoJSPlugin"]; });
  44177. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderEffect"]; });
  44178. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipeline"]; });
  44179. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipelineManager"]; });
  44180. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipelineManagerSceneComponent"]; });
  44181. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeMapToSphericalPolynomialTools"]; });
  44182. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRTools"]; });
  44183. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PanoramaToCubeMapTools"]; });
  44184. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_DDSTextureLoader"]; });
  44185. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_ENVTextureLoader"]; });
  44186. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_KTXTextureLoader"]; });
  44187. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TGATextureLoader"]; });
  44188. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CustomProceduralTexture"]; });
  44189. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NoiseProceduralTexture"]; });
  44190. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ProceduralTexture"]; });
  44191. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ProceduralTextureSceneComponent"]; });
  44192. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  44193. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensRenderingPipeline"]; });
  44194. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SSAO2RenderingPipeline"]; });
  44195. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SSAORenderingPipeline"]; });
  44196. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardRenderingPipeline"]; });
  44197. /**
  44198. * Legacy support, defining window.BABYLON (global variable).
  44199. *
  44200. * This is the entry point for the UMD module.
  44201. * The entry point for a future ESM package should be index.ts
  44202. */
  44203. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  44204. if (typeof globalObject !== "undefined") {
  44205. globalObject.BABYLON = BABYLON;
  44206. globalObject.BABYLON = globalObject.BABYLON || {};
  44207. var BABYLON = globalObject.BABYLON;
  44208. BABYLON.Debug = BABYLON.Debug || {};
  44209. var keys = [];
  44210. for (var key in _Debug_index__WEBPACK_IMPORTED_MODULE_1__) {
  44211. BABYLON.Debug[key] = _Debug_index__WEBPACK_IMPORTED_MODULE_1__[key];
  44212. keys.push(key);
  44213. }
  44214. for (var key in _index__WEBPACK_IMPORTED_MODULE_0__) {
  44215. BABYLON[key] = _index__WEBPACK_IMPORTED_MODULE_0__[key];
  44216. }
  44217. }
  44218. var Debug = {
  44219. AxesViewer: _Debug_index__WEBPACK_IMPORTED_MODULE_1__["AxesViewer"],
  44220. BoneAxesViewer: _Debug_index__WEBPACK_IMPORTED_MODULE_1__["BoneAxesViewer"],
  44221. PhysicsViewer: _Debug_index__WEBPACK_IMPORTED_MODULE_1__["PhysicsViewer"],
  44222. SkeletonViewer: _Debug_index__WEBPACK_IMPORTED_MODULE_1__["SkeletonViewer"],
  44223. };
  44224. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../node_modules/webpack/buildin/global.js */ "../node_modules/webpack/buildin/global.js")))
  44225. /***/ }),
  44226. /***/ "./LensFlares/index.ts":
  44227. /*!*****************************!*\
  44228. !*** ./LensFlares/index.ts ***!
  44229. \*****************************/
  44230. /*! exports provided: LensFlare, LensFlareSystem, LensFlareSystemSceneComponent */
  44231. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44232. "use strict";
  44233. __webpack_require__.r(__webpack_exports__);
  44234. /* harmony import */ var _lensFlare__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lensFlare */ "./LensFlares/lensFlare.ts");
  44235. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _lensFlare__WEBPACK_IMPORTED_MODULE_0__["LensFlare"]; });
  44236. /* harmony import */ var _lensFlareSystem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lensFlareSystem */ "./LensFlares/lensFlareSystem.ts");
  44237. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _lensFlareSystem__WEBPACK_IMPORTED_MODULE_1__["LensFlareSystem"]; });
  44238. /* harmony import */ var _lensFlareSystemSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./lensFlareSystemSceneComponent */ "./LensFlares/lensFlareSystemSceneComponent.ts");
  44239. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _lensFlareSystemSceneComponent__WEBPACK_IMPORTED_MODULE_2__["LensFlareSystemSceneComponent"]; });
  44240. /***/ }),
  44241. /***/ "./LensFlares/lensFlare.ts":
  44242. /*!*********************************!*\
  44243. !*** ./LensFlares/lensFlare.ts ***!
  44244. \*********************************/
  44245. /*! exports provided: LensFlare */
  44246. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44247. "use strict";
  44248. __webpack_require__.r(__webpack_exports__);
  44249. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return LensFlare; });
  44250. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  44251. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  44252. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  44253. /**
  44254. * This represents one of the lens effect in a `lensFlareSystem`.
  44255. * It controls one of the indiviual texture used in the effect.
  44256. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44257. */
  44258. var LensFlare = /** @class */ (function () {
  44259. /**
  44260. * Instantiates a new Lens Flare.
  44261. * This represents one of the lens effect in a `lensFlareSystem`.
  44262. * It controls one of the indiviual texture used in the effect.
  44263. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44264. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  44265. * @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.
  44266. * @param color Define the lens color
  44267. * @param imgUrl Define the lens texture url
  44268. * @param system Define the `lensFlareSystem` this flare is part of
  44269. */
  44270. function LensFlare(
  44271. /**
  44272. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  44273. */
  44274. size,
  44275. /**
  44276. * 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.
  44277. */
  44278. position, color, imgUrl, system) {
  44279. this.size = size;
  44280. this.position = position;
  44281. /**
  44282. * Define the alpha mode to render this particular lens.
  44283. */
  44284. this.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_ONEONE;
  44285. this.color = color || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](1, 1, 1);
  44286. this.texture = imgUrl ? new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](imgUrl, system.getScene(), true) : null;
  44287. this._system = system;
  44288. system.lensFlares.push(this);
  44289. }
  44290. /**
  44291. * Creates a new Lens Flare.
  44292. * This represents one of the lens effect in a `lensFlareSystem`.
  44293. * It controls one of the indiviual texture used in the effect.
  44294. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44295. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  44296. * @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.
  44297. * @param color Define the lens color
  44298. * @param imgUrl Define the lens texture url
  44299. * @param system Define the `lensFlareSystem` this flare is part of
  44300. * @returns The newly created Lens Flare
  44301. */
  44302. LensFlare.AddFlare = function (size, position, color, imgUrl, system) {
  44303. return new LensFlare(size, position, color, imgUrl, system);
  44304. };
  44305. /**
  44306. * Dispose and release the lens flare with its associated resources.
  44307. */
  44308. LensFlare.prototype.dispose = function () {
  44309. if (this.texture) {
  44310. this.texture.dispose();
  44311. }
  44312. // Remove from scene
  44313. var index = this._system.lensFlares.indexOf(this);
  44314. this._system.lensFlares.splice(index, 1);
  44315. };
  44316. return LensFlare;
  44317. }());
  44318. /***/ }),
  44319. /***/ "./LensFlares/lensFlareSystem.ts":
  44320. /*!***************************************!*\
  44321. !*** ./LensFlares/lensFlareSystem.ts ***!
  44322. \***************************************/
  44323. /*! exports provided: LensFlareSystem */
  44324. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44325. "use strict";
  44326. __webpack_require__.r(__webpack_exports__);
  44327. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return LensFlareSystem; });
  44328. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  44329. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  44330. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  44331. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  44332. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  44333. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  44334. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  44335. /* harmony import */ var _lensFlare__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./lensFlare */ "./LensFlares/lensFlare.ts");
  44336. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  44337. /* harmony import */ var _Shaders_lensFlare_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/lensFlare.fragment */ "./Shaders/lensFlare.fragment.ts");
  44338. /* harmony import */ var _Shaders_lensFlare_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/lensFlare.vertex */ "./Shaders/lensFlare.vertex.ts");
  44339. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  44340. /**
  44341. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  44342. * It is usually composed of several `lensFlare`.
  44343. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44344. */
  44345. var LensFlareSystem = /** @class */ (function () {
  44346. /**
  44347. * Instantiates a lens flare system.
  44348. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  44349. * It is usually composed of several `lensFlare`.
  44350. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44351. * @param name Define the name of the lens flare system in the scene
  44352. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  44353. * @param scene Define the scene the lens flare system belongs to
  44354. */
  44355. function LensFlareSystem(
  44356. /**
  44357. * Define the name of the lens flare system
  44358. */
  44359. name, emitter, scene) {
  44360. this.name = name;
  44361. /**
  44362. * List of lens flares used in this system.
  44363. */
  44364. this.lensFlares = new Array();
  44365. /**
  44366. * Define a limit from the border the lens flare can be visible.
  44367. */
  44368. this.borderLimit = 300;
  44369. /**
  44370. * Define a viewport border we do not want to see the lens flare in.
  44371. */
  44372. this.viewportBorder = 0;
  44373. /**
  44374. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  44375. */
  44376. this.layerMask = 0x0FFFFFFF;
  44377. this._vertexBuffers = {};
  44378. this._isEnabled = true;
  44379. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  44380. LensFlareSystem._SceneComponentInitialization(this._scene);
  44381. this._emitter = emitter;
  44382. this.id = name;
  44383. scene.lensFlareSystems.push(this);
  44384. this.meshesSelectionPredicate = function (m) { return (scene.activeCamera && m.material && m.isVisible && m.isEnabled() && m.isBlocker && ((m.layerMask & scene.activeCamera.layerMask) != 0)); };
  44385. var engine = scene.getEngine();
  44386. // VBO
  44387. var vertices = [];
  44388. vertices.push(1, 1);
  44389. vertices.push(-1, 1);
  44390. vertices.push(-1, -1);
  44391. vertices.push(1, -1);
  44392. 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);
  44393. // Indices
  44394. var indices = [];
  44395. indices.push(0);
  44396. indices.push(1);
  44397. indices.push(2);
  44398. indices.push(0);
  44399. indices.push(2);
  44400. indices.push(3);
  44401. this._indexBuffer = engine.createIndexBuffer(indices);
  44402. // Effects
  44403. this._effect = engine.createEffect("lensFlare", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind], ["color", "viewportMatrix"], ["textureSampler"], "");
  44404. }
  44405. Object.defineProperty(LensFlareSystem.prototype, "isEnabled", {
  44406. /**
  44407. * Define if the lens flare system is enabled.
  44408. */
  44409. get: function () {
  44410. return this._isEnabled;
  44411. },
  44412. set: function (value) {
  44413. this._isEnabled = value;
  44414. },
  44415. enumerable: true,
  44416. configurable: true
  44417. });
  44418. /**
  44419. * Get the scene the effects belongs to.
  44420. * @returns the scene holding the lens flare system
  44421. */
  44422. LensFlareSystem.prototype.getScene = function () {
  44423. return this._scene;
  44424. };
  44425. /**
  44426. * Get the emitter of the lens flare system.
  44427. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  44428. * @returns the emitter of the lens flare system
  44429. */
  44430. LensFlareSystem.prototype.getEmitter = function () {
  44431. return this._emitter;
  44432. };
  44433. /**
  44434. * Set the emitter of the lens flare system.
  44435. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  44436. * @param newEmitter Define the new emitter of the system
  44437. */
  44438. LensFlareSystem.prototype.setEmitter = function (newEmitter) {
  44439. this._emitter = newEmitter;
  44440. };
  44441. /**
  44442. * Get the lens flare system emitter position.
  44443. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  44444. * @returns the position
  44445. */
  44446. LensFlareSystem.prototype.getEmitterPosition = function () {
  44447. return this._emitter.getAbsolutePosition ? this._emitter.getAbsolutePosition() : this._emitter.position;
  44448. };
  44449. /**
  44450. * @hidden
  44451. */
  44452. LensFlareSystem.prototype.computeEffectivePosition = function (globalViewport) {
  44453. var position = this.getEmitterPosition();
  44454. position = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), this._scene.getTransformMatrix(), globalViewport);
  44455. this._positionX = position.x;
  44456. this._positionY = position.y;
  44457. position = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(this.getEmitterPosition(), this._scene.getViewMatrix());
  44458. if (this.viewportBorder > 0) {
  44459. globalViewport.x -= this.viewportBorder;
  44460. globalViewport.y -= this.viewportBorder;
  44461. globalViewport.width += this.viewportBorder * 2;
  44462. globalViewport.height += this.viewportBorder * 2;
  44463. position.x += this.viewportBorder;
  44464. position.y += this.viewportBorder;
  44465. this._positionX += this.viewportBorder;
  44466. this._positionY += this.viewportBorder;
  44467. }
  44468. if (position.z > 0) {
  44469. if ((this._positionX > globalViewport.x) && (this._positionX < globalViewport.x + globalViewport.width)) {
  44470. if ((this._positionY > globalViewport.y) && (this._positionY < globalViewport.y + globalViewport.height)) {
  44471. return true;
  44472. }
  44473. }
  44474. return true;
  44475. }
  44476. return false;
  44477. };
  44478. /** @hidden */
  44479. LensFlareSystem.prototype._isVisible = function () {
  44480. if (!this._isEnabled || !this._scene.activeCamera) {
  44481. return false;
  44482. }
  44483. var emitterPosition = this.getEmitterPosition();
  44484. var direction = emitterPosition.subtract(this._scene.activeCamera.globalPosition);
  44485. var distance = direction.length();
  44486. direction.normalize();
  44487. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](this._scene.activeCamera.globalPosition, direction);
  44488. var pickInfo = this._scene.pickWithRay(ray, this.meshesSelectionPredicate, true);
  44489. return !pickInfo || !pickInfo.hit || pickInfo.distance > distance;
  44490. };
  44491. /**
  44492. * @hidden
  44493. */
  44494. LensFlareSystem.prototype.render = function () {
  44495. if (!this._effect.isReady() || !this._scene.activeCamera) {
  44496. return false;
  44497. }
  44498. var engine = this._scene.getEngine();
  44499. var viewport = this._scene.activeCamera.viewport;
  44500. var globalViewport = viewport.toGlobal(engine.getRenderWidth(true), engine.getRenderHeight(true));
  44501. // Position
  44502. if (!this.computeEffectivePosition(globalViewport)) {
  44503. return false;
  44504. }
  44505. // Visibility
  44506. if (!this._isVisible()) {
  44507. return false;
  44508. }
  44509. // Intensity
  44510. var awayX;
  44511. var awayY;
  44512. if (this._positionX < this.borderLimit + globalViewport.x) {
  44513. awayX = this.borderLimit + globalViewport.x - this._positionX;
  44514. }
  44515. else if (this._positionX > globalViewport.x + globalViewport.width - this.borderLimit) {
  44516. awayX = this._positionX - globalViewport.x - globalViewport.width + this.borderLimit;
  44517. }
  44518. else {
  44519. awayX = 0;
  44520. }
  44521. if (this._positionY < this.borderLimit + globalViewport.y) {
  44522. awayY = this.borderLimit + globalViewport.y - this._positionY;
  44523. }
  44524. else if (this._positionY > globalViewport.y + globalViewport.height - this.borderLimit) {
  44525. awayY = this._positionY - globalViewport.y - globalViewport.height + this.borderLimit;
  44526. }
  44527. else {
  44528. awayY = 0;
  44529. }
  44530. var away = (awayX > awayY) ? awayX : awayY;
  44531. away -= this.viewportBorder;
  44532. if (away > this.borderLimit) {
  44533. away = this.borderLimit;
  44534. }
  44535. var intensity = 1.0 - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Clamp(away / this.borderLimit, 0, 1);
  44536. if (intensity < 0) {
  44537. return false;
  44538. }
  44539. if (intensity > 1.0) {
  44540. intensity = 1.0;
  44541. }
  44542. if (this.viewportBorder > 0) {
  44543. globalViewport.x += this.viewportBorder;
  44544. globalViewport.y += this.viewportBorder;
  44545. globalViewport.width -= this.viewportBorder * 2;
  44546. globalViewport.height -= this.viewportBorder * 2;
  44547. this._positionX -= this.viewportBorder;
  44548. this._positionY -= this.viewportBorder;
  44549. }
  44550. // Position
  44551. var centerX = globalViewport.x + globalViewport.width / 2;
  44552. var centerY = globalViewport.y + globalViewport.height / 2;
  44553. var distX = centerX - this._positionX;
  44554. var distY = centerY - this._positionY;
  44555. // Effects
  44556. engine.enableEffect(this._effect);
  44557. engine.setState(false);
  44558. engine.setDepthBuffer(false);
  44559. // VBOs
  44560. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  44561. // Flares
  44562. for (var index = 0; index < this.lensFlares.length; index++) {
  44563. var flare = this.lensFlares[index];
  44564. engine.setAlphaMode(flare.alphaMode);
  44565. var x = centerX - (distX * flare.position);
  44566. var y = centerY - (distY * flare.position);
  44567. var cw = flare.size;
  44568. var ch = flare.size * engine.getAspectRatio(this._scene.activeCamera, true);
  44569. var cx = 2 * (x / (globalViewport.width + globalViewport.x * 2)) - 1.0;
  44570. var cy = 1.0 - 2 * (y / (globalViewport.height + globalViewport.y * 2));
  44571. 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);
  44572. this._effect.setMatrix("viewportMatrix", viewportMatrix);
  44573. // Texture
  44574. this._effect.setTexture("textureSampler", flare.texture);
  44575. // Color
  44576. this._effect.setFloat4("color", flare.color.r * intensity, flare.color.g * intensity, flare.color.b * intensity, 1.0);
  44577. // Draw order
  44578. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  44579. }
  44580. engine.setDepthBuffer(true);
  44581. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  44582. return true;
  44583. };
  44584. /**
  44585. * Dispose and release the lens flare with its associated resources.
  44586. */
  44587. LensFlareSystem.prototype.dispose = function () {
  44588. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind];
  44589. if (vertexBuffer) {
  44590. vertexBuffer.dispose();
  44591. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind] = null;
  44592. }
  44593. if (this._indexBuffer) {
  44594. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  44595. this._indexBuffer = null;
  44596. }
  44597. while (this.lensFlares.length) {
  44598. this.lensFlares[0].dispose();
  44599. }
  44600. // Remove from scene
  44601. var index = this._scene.lensFlareSystems.indexOf(this);
  44602. this._scene.lensFlareSystems.splice(index, 1);
  44603. };
  44604. /**
  44605. * Parse a lens flare system from a JSON repressentation
  44606. * @param parsedLensFlareSystem Define the JSON to parse
  44607. * @param scene Define the scene the parsed system should be instantiated in
  44608. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  44609. * @returns the parsed system
  44610. */
  44611. LensFlareSystem.Parse = function (parsedLensFlareSystem, scene, rootUrl) {
  44612. var emitter = scene.getLastEntryByID(parsedLensFlareSystem.emitterId);
  44613. var name = parsedLensFlareSystem.name || "lensFlareSystem#" + parsedLensFlareSystem.emitterId;
  44614. var lensFlareSystem = new LensFlareSystem(name, emitter, scene);
  44615. lensFlareSystem.id = parsedLensFlareSystem.id || name;
  44616. lensFlareSystem.borderLimit = parsedLensFlareSystem.borderLimit;
  44617. for (var index = 0; index < parsedLensFlareSystem.flares.length; index++) {
  44618. var parsedFlare = parsedLensFlareSystem.flares[index];
  44619. _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);
  44620. }
  44621. return lensFlareSystem;
  44622. };
  44623. /**
  44624. * Serialize the current Lens Flare System into a JSON representation.
  44625. * @returns the serialized JSON
  44626. */
  44627. LensFlareSystem.prototype.serialize = function () {
  44628. var serializationObject = {};
  44629. serializationObject.id = this.id;
  44630. serializationObject.name = this.name;
  44631. serializationObject.emitterId = this.getEmitter().id;
  44632. serializationObject.borderLimit = this.borderLimit;
  44633. serializationObject.flares = [];
  44634. for (var index = 0; index < this.lensFlares.length; index++) {
  44635. var flare = this.lensFlares[index];
  44636. serializationObject.flares.push({
  44637. size: flare.size,
  44638. position: flare.position,
  44639. color: flare.color.asArray(),
  44640. textureName: _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFilename(flare.texture ? flare.texture.name : "")
  44641. });
  44642. }
  44643. return serializationObject;
  44644. };
  44645. /** @hidden */
  44646. LensFlareSystem._SceneComponentInitialization = function (_) {
  44647. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_11__["_DevTools"].WarnImport("LensFlareSystemSceneComponent");
  44648. };
  44649. return LensFlareSystem;
  44650. }());
  44651. /***/ }),
  44652. /***/ "./LensFlares/lensFlareSystemSceneComponent.ts":
  44653. /*!*****************************************************!*\
  44654. !*** ./LensFlares/lensFlareSystemSceneComponent.ts ***!
  44655. \*****************************************************/
  44656. /*! exports provided: LensFlareSystemSceneComponent */
  44657. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44658. "use strict";
  44659. __webpack_require__.r(__webpack_exports__);
  44660. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return LensFlareSystemSceneComponent; });
  44661. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  44662. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  44663. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  44664. /* harmony import */ var _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./lensFlareSystem */ "./LensFlares/lensFlareSystem.ts");
  44665. // Adds the parser to the scene parsers.
  44666. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM, function (parsedData, scene, container, rootUrl) {
  44667. // Lens flares
  44668. if (parsedData.lensFlareSystems !== undefined && parsedData.lensFlareSystems !== null) {
  44669. if (!container.lensFlareSystems) {
  44670. container.lensFlareSystems = new Array();
  44671. }
  44672. for (var index = 0, cache = parsedData.lensFlareSystems.length; index < cache; index++) {
  44673. var parsedLensFlareSystem = parsedData.lensFlareSystems[index];
  44674. var lf = _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__["LensFlareSystem"].Parse(parsedLensFlareSystem, scene, rootUrl);
  44675. container.lensFlareSystems.push(lf);
  44676. }
  44677. }
  44678. });
  44679. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.getLensFlareSystemByName = function (name) {
  44680. for (var index = 0; index < this.lensFlareSystems.length; index++) {
  44681. if (this.lensFlareSystems[index].name === name) {
  44682. return this.lensFlareSystems[index];
  44683. }
  44684. }
  44685. return null;
  44686. };
  44687. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.getLensFlareSystemByID = function (id) {
  44688. for (var index = 0; index < this.lensFlareSystems.length; index++) {
  44689. if (this.lensFlareSystems[index].id === id) {
  44690. return this.lensFlareSystems[index];
  44691. }
  44692. }
  44693. return null;
  44694. };
  44695. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.removeLensFlareSystem = function (toRemove) {
  44696. var index = this.lensFlareSystems.indexOf(toRemove);
  44697. if (index !== -1) {
  44698. this.lensFlareSystems.splice(index, 1);
  44699. }
  44700. return index;
  44701. };
  44702. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.addLensFlareSystem = function (newLensFlareSystem) {
  44703. this.lensFlareSystems.push(newLensFlareSystem);
  44704. };
  44705. /**
  44706. * Defines the lens flare scene component responsible to manage any lens flares
  44707. * in a given scene.
  44708. */
  44709. var LensFlareSystemSceneComponent = /** @class */ (function () {
  44710. /**
  44711. * Creates a new instance of the component for the given scene
  44712. * @param scene Defines the scene to register the component in
  44713. */
  44714. function LensFlareSystemSceneComponent(scene) {
  44715. /**
  44716. * The component name helpfull to identify the component in the list of scene components.
  44717. */
  44718. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM;
  44719. this.scene = scene;
  44720. scene.lensFlareSystems = new Array();
  44721. }
  44722. /**
  44723. * Registers the component in a given scene
  44724. */
  44725. LensFlareSystemSceneComponent.prototype.register = function () {
  44726. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_LENSFLARESYSTEM, this, this._draw);
  44727. };
  44728. /**
  44729. * Rebuilds the elements related to this component in case of
  44730. * context lost for instance.
  44731. */
  44732. LensFlareSystemSceneComponent.prototype.rebuild = function () {
  44733. // Nothing to do for lens flare
  44734. };
  44735. /**
  44736. * Adds all the element from the container to the scene
  44737. * @param container the container holding the elements
  44738. */
  44739. LensFlareSystemSceneComponent.prototype.addFromContainer = function (container) {
  44740. var _this = this;
  44741. if (!container.lensFlareSystems) {
  44742. return;
  44743. }
  44744. container.lensFlareSystems.forEach(function (o) {
  44745. _this.scene.addLensFlareSystem(o);
  44746. });
  44747. };
  44748. /**
  44749. * Removes all the elements in the container from the scene
  44750. * @param container contains the elements to remove
  44751. */
  44752. LensFlareSystemSceneComponent.prototype.removeFromContainer = function (container) {
  44753. var _this = this;
  44754. if (!container.lensFlareSystems) {
  44755. return;
  44756. }
  44757. container.lensFlareSystems.forEach(function (o) {
  44758. _this.scene.removeLensFlareSystem(o);
  44759. });
  44760. };
  44761. /**
  44762. * Serializes the component data to the specified json object
  44763. * @param serializationObject The object to serialize to
  44764. */
  44765. LensFlareSystemSceneComponent.prototype.serialize = function (serializationObject) {
  44766. // Lens flares
  44767. serializationObject.lensFlareSystems = [];
  44768. var lensFlareSystems = this.scene.lensFlareSystems;
  44769. for (var _i = 0, lensFlareSystems_1 = lensFlareSystems; _i < lensFlareSystems_1.length; _i++) {
  44770. var lensFlareSystem = lensFlareSystems_1[_i];
  44771. serializationObject.lensFlareSystems.push(lensFlareSystem.serialize());
  44772. }
  44773. };
  44774. /**
  44775. * Disposes the component and the associated ressources.
  44776. */
  44777. LensFlareSystemSceneComponent.prototype.dispose = function () {
  44778. var lensFlareSystems = this.scene.lensFlareSystems;
  44779. while (lensFlareSystems.length) {
  44780. lensFlareSystems[0].dispose();
  44781. }
  44782. };
  44783. LensFlareSystemSceneComponent.prototype._draw = function (camera) {
  44784. // Lens flares
  44785. if (this.scene.lensFlaresEnabled) {
  44786. var lensFlareSystems = this.scene.lensFlareSystems;
  44787. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Lens flares", lensFlareSystems.length > 0);
  44788. for (var _i = 0, lensFlareSystems_2 = lensFlareSystems; _i < lensFlareSystems_2.length; _i++) {
  44789. var lensFlareSystem = lensFlareSystems_2[_i];
  44790. if ((camera.layerMask & lensFlareSystem.layerMask) !== 0) {
  44791. lensFlareSystem.render();
  44792. }
  44793. }
  44794. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Lens flares", lensFlareSystems.length > 0);
  44795. }
  44796. };
  44797. return LensFlareSystemSceneComponent;
  44798. }());
  44799. _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__["LensFlareSystem"]._SceneComponentInitialization = function (scene) {
  44800. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM);
  44801. if (!component) {
  44802. component = new LensFlareSystemSceneComponent(scene);
  44803. scene._addComponent(component);
  44804. }
  44805. };
  44806. /***/ }),
  44807. /***/ "./Lights/Shadows/index.ts":
  44808. /*!*********************************!*\
  44809. !*** ./Lights/Shadows/index.ts ***!
  44810. \*********************************/
  44811. /*! exports provided: ShadowGenerator, ShadowGeneratorSceneComponent */
  44812. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44813. "use strict";
  44814. __webpack_require__.r(__webpack_exports__);
  44815. /* harmony import */ var _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./shadowGenerator */ "./Lights/Shadows/shadowGenerator.ts");
  44816. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]; });
  44817. /* harmony import */ var _shadowGeneratorSceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./shadowGeneratorSceneComponent */ "./Lights/Shadows/shadowGeneratorSceneComponent.ts");
  44818. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _shadowGeneratorSceneComponent__WEBPACK_IMPORTED_MODULE_1__["ShadowGeneratorSceneComponent"]; });
  44819. /***/ }),
  44820. /***/ "./Lights/Shadows/shadowGenerator.ts":
  44821. /*!*******************************************!*\
  44822. !*** ./Lights/Shadows/shadowGenerator.ts ***!
  44823. \*******************************************/
  44824. /*! exports provided: ShadowGenerator */
  44825. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44826. "use strict";
  44827. __webpack_require__.r(__webpack_exports__);
  44828. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return ShadowGenerator; });
  44829. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  44830. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  44831. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  44832. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Lights/light */ "./Lights/light.ts");
  44833. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/material */ "./Materials/material.ts");
  44834. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  44835. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  44836. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  44837. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  44838. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  44839. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  44840. /* harmony import */ var _Shaders_shadowMap_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Shaders/shadowMap.fragment */ "./Shaders/shadowMap.fragment.ts");
  44841. /* harmony import */ var _Shaders_shadowMap_vertex__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Shaders/shadowMap.vertex */ "./Shaders/shadowMap.vertex.ts");
  44842. /* harmony import */ var _Shaders_depthBoxBlur_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Shaders/depthBoxBlur.fragment */ "./Shaders/depthBoxBlur.fragment.ts");
  44843. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  44844. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Misc/devTools */ "./Misc/devTools.ts");
  44845. /**
  44846. * Default implementation IShadowGenerator.
  44847. * This is the main object responsible of generating shadows in the framework.
  44848. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  44849. */
  44850. var ShadowGenerator = /** @class */ (function () {
  44851. /**
  44852. * Creates a ShadowGenerator object.
  44853. * A ShadowGenerator is the required tool to use the shadows.
  44854. * Each light casting shadows needs to use its own ShadowGenerator.
  44855. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  44856. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  44857. * @param light The light object generating the shadows.
  44858. * @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.
  44859. */
  44860. function ShadowGenerator(mapSize, light, usefulFloatFirst) {
  44861. /**
  44862. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  44863. */
  44864. this.onBeforeShadowMapRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_14__["Observable"]();
  44865. this._bias = 0.00005;
  44866. this._normalBias = 0;
  44867. this._blurBoxOffset = 1;
  44868. this._blurScale = 2;
  44869. this._blurKernel = 1;
  44870. this._useKernelBlur = false;
  44871. this._filter = ShadowGenerator.FILTER_NONE;
  44872. this._filteringQuality = ShadowGenerator.QUALITY_HIGH;
  44873. this._contactHardeningLightSizeUVRatio = 0.1;
  44874. this._darkness = 0;
  44875. this._transparencyShadow = false;
  44876. /**
  44877. * Controls the extent to which the shadows fade out at the edge of the frustum
  44878. * Used only by directionals and spots
  44879. */
  44880. this.frustumEdgeFalloff = 0;
  44881. /**
  44882. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  44883. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  44884. * It might on the other hand introduce peter panning.
  44885. */
  44886. this.forceBackFacesOnly = false;
  44887. this._lightDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  44888. this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  44889. this._projectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  44890. this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  44891. this._cachedPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  44892. this._cachedDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  44893. this._currentFaceIndex = 0;
  44894. this._currentFaceIndexCache = 0;
  44895. this._defaultTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  44896. this._mapSize = mapSize;
  44897. this._light = light;
  44898. this._scene = light.getScene();
  44899. light._shadowGenerator = this;
  44900. ShadowGenerator._SceneComponentInitialization(this._scene);
  44901. // Texture type fallback from float to int if not supported.
  44902. var caps = this._scene.getEngine().getCaps();
  44903. if (!usefulFloatFirst) {
  44904. if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  44905. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_HALF_FLOAT;
  44906. }
  44907. else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  44908. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_FLOAT;
  44909. }
  44910. else {
  44911. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  44912. }
  44913. }
  44914. else {
  44915. if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  44916. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_FLOAT;
  44917. }
  44918. else if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  44919. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_HALF_FLOAT;
  44920. }
  44921. else {
  44922. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  44923. }
  44924. }
  44925. this._initializeGenerator();
  44926. this._applyFilterValues();
  44927. }
  44928. Object.defineProperty(ShadowGenerator.prototype, "bias", {
  44929. /**
  44930. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  44931. */
  44932. get: function () {
  44933. return this._bias;
  44934. },
  44935. /**
  44936. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  44937. */
  44938. set: function (bias) {
  44939. this._bias = bias;
  44940. },
  44941. enumerable: true,
  44942. configurable: true
  44943. });
  44944. Object.defineProperty(ShadowGenerator.prototype, "normalBias", {
  44945. /**
  44946. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44947. */
  44948. get: function () {
  44949. return this._normalBias;
  44950. },
  44951. /**
  44952. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44953. */
  44954. set: function (normalBias) {
  44955. this._normalBias = normalBias;
  44956. },
  44957. enumerable: true,
  44958. configurable: true
  44959. });
  44960. Object.defineProperty(ShadowGenerator.prototype, "blurBoxOffset", {
  44961. /**
  44962. * Gets the blur box offset: offset applied during the blur pass.
  44963. * Only useful if useKernelBlur = false
  44964. */
  44965. get: function () {
  44966. return this._blurBoxOffset;
  44967. },
  44968. /**
  44969. * Sets the blur box offset: offset applied during the blur pass.
  44970. * Only useful if useKernelBlur = false
  44971. */
  44972. set: function (value) {
  44973. if (this._blurBoxOffset === value) {
  44974. return;
  44975. }
  44976. this._blurBoxOffset = value;
  44977. this._disposeBlurPostProcesses();
  44978. },
  44979. enumerable: true,
  44980. configurable: true
  44981. });
  44982. Object.defineProperty(ShadowGenerator.prototype, "blurScale", {
  44983. /**
  44984. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  44985. * 2 means half of the size.
  44986. */
  44987. get: function () {
  44988. return this._blurScale;
  44989. },
  44990. /**
  44991. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  44992. * 2 means half of the size.
  44993. */
  44994. set: function (value) {
  44995. if (this._blurScale === value) {
  44996. return;
  44997. }
  44998. this._blurScale = value;
  44999. this._disposeBlurPostProcesses();
  45000. },
  45001. enumerable: true,
  45002. configurable: true
  45003. });
  45004. Object.defineProperty(ShadowGenerator.prototype, "blurKernel", {
  45005. /**
  45006. * Gets the blur kernel: kernel size of the blur pass.
  45007. * Only useful if useKernelBlur = true
  45008. */
  45009. get: function () {
  45010. return this._blurKernel;
  45011. },
  45012. /**
  45013. * Sets the blur kernel: kernel size of the blur pass.
  45014. * Only useful if useKernelBlur = true
  45015. */
  45016. set: function (value) {
  45017. if (this._blurKernel === value) {
  45018. return;
  45019. }
  45020. this._blurKernel = value;
  45021. this._disposeBlurPostProcesses();
  45022. },
  45023. enumerable: true,
  45024. configurable: true
  45025. });
  45026. Object.defineProperty(ShadowGenerator.prototype, "useKernelBlur", {
  45027. /**
  45028. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  45029. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  45030. */
  45031. get: function () {
  45032. return this._useKernelBlur;
  45033. },
  45034. /**
  45035. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  45036. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  45037. */
  45038. set: function (value) {
  45039. if (this._useKernelBlur === value) {
  45040. return;
  45041. }
  45042. this._useKernelBlur = value;
  45043. this._disposeBlurPostProcesses();
  45044. },
  45045. enumerable: true,
  45046. configurable: true
  45047. });
  45048. Object.defineProperty(ShadowGenerator.prototype, "depthScale", {
  45049. /**
  45050. * Gets the depth scale used in ESM mode.
  45051. */
  45052. get: function () {
  45053. return this._depthScale !== undefined ? this._depthScale : this._light.getDepthScale();
  45054. },
  45055. /**
  45056. * Sets the depth scale used in ESM mode.
  45057. * This can override the scale stored on the light.
  45058. */
  45059. set: function (value) {
  45060. this._depthScale = value;
  45061. },
  45062. enumerable: true,
  45063. configurable: true
  45064. });
  45065. Object.defineProperty(ShadowGenerator.prototype, "filter", {
  45066. /**
  45067. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  45068. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  45069. */
  45070. get: function () {
  45071. return this._filter;
  45072. },
  45073. /**
  45074. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  45075. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  45076. */
  45077. set: function (value) {
  45078. // Blurring the cubemap is going to be too expensive. Reverting to unblurred version
  45079. if (this._light.needCube()) {
  45080. if (value === ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP) {
  45081. this.useExponentialShadowMap = true;
  45082. return;
  45083. }
  45084. else if (value === ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) {
  45085. this.useCloseExponentialShadowMap = true;
  45086. return;
  45087. }
  45088. // PCF on cubemap would also be expensive
  45089. else if (value === ShadowGenerator.FILTER_PCF || value === ShadowGenerator.FILTER_PCSS) {
  45090. this.usePoissonSampling = true;
  45091. return;
  45092. }
  45093. }
  45094. // Weblg1 fallback for PCF.
  45095. if (value === ShadowGenerator.FILTER_PCF || value === ShadowGenerator.FILTER_PCSS) {
  45096. if (this._scene.getEngine().webGLVersion === 1) {
  45097. this.usePoissonSampling = true;
  45098. return;
  45099. }
  45100. }
  45101. if (this._filter === value) {
  45102. return;
  45103. }
  45104. this._filter = value;
  45105. this._disposeBlurPostProcesses();
  45106. this._applyFilterValues();
  45107. this._light._markMeshesAsLightDirty();
  45108. },
  45109. enumerable: true,
  45110. configurable: true
  45111. });
  45112. Object.defineProperty(ShadowGenerator.prototype, "usePoissonSampling", {
  45113. /**
  45114. * Gets if the current filter is set to Poisson Sampling.
  45115. */
  45116. get: function () {
  45117. return this.filter === ShadowGenerator.FILTER_POISSONSAMPLING;
  45118. },
  45119. /**
  45120. * Sets the current filter to Poisson Sampling.
  45121. */
  45122. set: function (value) {
  45123. if (!value && this.filter !== ShadowGenerator.FILTER_POISSONSAMPLING) {
  45124. return;
  45125. }
  45126. this.filter = (value ? ShadowGenerator.FILTER_POISSONSAMPLING : ShadowGenerator.FILTER_NONE);
  45127. },
  45128. enumerable: true,
  45129. configurable: true
  45130. });
  45131. Object.defineProperty(ShadowGenerator.prototype, "useExponentialShadowMap", {
  45132. /**
  45133. * Gets if the current filter is set to ESM.
  45134. */
  45135. get: function () {
  45136. return this.filter === ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP;
  45137. },
  45138. /**
  45139. * Sets the current filter is to ESM.
  45140. */
  45141. set: function (value) {
  45142. if (!value && this.filter !== ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP) {
  45143. return;
  45144. }
  45145. this.filter = (value ? ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  45146. },
  45147. enumerable: true,
  45148. configurable: true
  45149. });
  45150. Object.defineProperty(ShadowGenerator.prototype, "useBlurExponentialShadowMap", {
  45151. /**
  45152. * Gets if the current filter is set to filtered ESM.
  45153. */
  45154. get: function () {
  45155. return this.filter === ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP;
  45156. },
  45157. /**
  45158. * Gets if the current filter is set to filtered ESM.
  45159. */
  45160. set: function (value) {
  45161. if (!value && this.filter !== ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP) {
  45162. return;
  45163. }
  45164. this.filter = (value ? ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  45165. },
  45166. enumerable: true,
  45167. configurable: true
  45168. });
  45169. Object.defineProperty(ShadowGenerator.prototype, "useCloseExponentialShadowMap", {
  45170. /**
  45171. * Gets if the current filter is set to "close ESM" (using the inverse of the
  45172. * exponential to prevent steep falloff artifacts).
  45173. */
  45174. get: function () {
  45175. return this.filter === ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP;
  45176. },
  45177. /**
  45178. * Sets the current filter to "close ESM" (using the inverse of the
  45179. * exponential to prevent steep falloff artifacts).
  45180. */
  45181. set: function (value) {
  45182. if (!value && this.filter !== ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP) {
  45183. return;
  45184. }
  45185. this.filter = (value ? ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  45186. },
  45187. enumerable: true,
  45188. configurable: true
  45189. });
  45190. Object.defineProperty(ShadowGenerator.prototype, "useBlurCloseExponentialShadowMap", {
  45191. /**
  45192. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  45193. * exponential to prevent steep falloff artifacts).
  45194. */
  45195. get: function () {
  45196. return this.filter === ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP;
  45197. },
  45198. /**
  45199. * Sets the current filter to filtered "close ESM" (using the inverse of the
  45200. * exponential to prevent steep falloff artifacts).
  45201. */
  45202. set: function (value) {
  45203. if (!value && this.filter !== ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) {
  45204. return;
  45205. }
  45206. this.filter = (value ? ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  45207. },
  45208. enumerable: true,
  45209. configurable: true
  45210. });
  45211. Object.defineProperty(ShadowGenerator.prototype, "usePercentageCloserFiltering", {
  45212. /**
  45213. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  45214. */
  45215. get: function () {
  45216. return this.filter === ShadowGenerator.FILTER_PCF;
  45217. },
  45218. /**
  45219. * Sets the current filter to "PCF" (percentage closer filtering).
  45220. */
  45221. set: function (value) {
  45222. if (!value && this.filter !== ShadowGenerator.FILTER_PCF) {
  45223. return;
  45224. }
  45225. this.filter = (value ? ShadowGenerator.FILTER_PCF : ShadowGenerator.FILTER_NONE);
  45226. },
  45227. enumerable: true,
  45228. configurable: true
  45229. });
  45230. Object.defineProperty(ShadowGenerator.prototype, "filteringQuality", {
  45231. /**
  45232. * Gets the PCF or PCSS Quality.
  45233. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  45234. */
  45235. get: function () {
  45236. return this._filteringQuality;
  45237. },
  45238. /**
  45239. * Sets the PCF or PCSS Quality.
  45240. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  45241. */
  45242. set: function (filteringQuality) {
  45243. this._filteringQuality = filteringQuality;
  45244. },
  45245. enumerable: true,
  45246. configurable: true
  45247. });
  45248. Object.defineProperty(ShadowGenerator.prototype, "useContactHardeningShadow", {
  45249. /**
  45250. * Gets if the current filter is set to "PCSS" (contact hardening).
  45251. */
  45252. get: function () {
  45253. return this.filter === ShadowGenerator.FILTER_PCSS;
  45254. },
  45255. /**
  45256. * Sets the current filter to "PCSS" (contact hardening).
  45257. */
  45258. set: function (value) {
  45259. if (!value && this.filter !== ShadowGenerator.FILTER_PCSS) {
  45260. return;
  45261. }
  45262. this.filter = (value ? ShadowGenerator.FILTER_PCSS : ShadowGenerator.FILTER_NONE);
  45263. },
  45264. enumerable: true,
  45265. configurable: true
  45266. });
  45267. Object.defineProperty(ShadowGenerator.prototype, "contactHardeningLightSizeUVRatio", {
  45268. /**
  45269. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  45270. * Using a ratio helps keeping shape stability independently of the map size.
  45271. *
  45272. * It does not account for the light projection as it was having too much
  45273. * instability during the light setup or during light position changes.
  45274. *
  45275. * Only valid if useContactHardeningShadow is true.
  45276. */
  45277. get: function () {
  45278. return this._contactHardeningLightSizeUVRatio;
  45279. },
  45280. /**
  45281. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  45282. * Using a ratio helps keeping shape stability independently of the map size.
  45283. *
  45284. * It does not account for the light projection as it was having too much
  45285. * instability during the light setup or during light position changes.
  45286. *
  45287. * Only valid if useContactHardeningShadow is true.
  45288. */
  45289. set: function (contactHardeningLightSizeUVRatio) {
  45290. this._contactHardeningLightSizeUVRatio = contactHardeningLightSizeUVRatio;
  45291. },
  45292. enumerable: true,
  45293. configurable: true
  45294. });
  45295. /**
  45296. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  45297. * 0 means strongest and 1 would means no shadow.
  45298. * @returns the darkness.
  45299. */
  45300. ShadowGenerator.prototype.getDarkness = function () {
  45301. return this._darkness;
  45302. };
  45303. /**
  45304. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  45305. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  45306. * @returns the shadow generator allowing fluent coding.
  45307. */
  45308. ShadowGenerator.prototype.setDarkness = function (darkness) {
  45309. if (darkness >= 1.0) {
  45310. this._darkness = 1.0;
  45311. }
  45312. else if (darkness <= 0.0) {
  45313. this._darkness = 0.0;
  45314. }
  45315. else {
  45316. this._darkness = darkness;
  45317. }
  45318. return this;
  45319. };
  45320. /**
  45321. * Sets the ability to have transparent shadow (boolean).
  45322. * @param transparent True if transparent else False
  45323. * @returns the shadow generator allowing fluent coding
  45324. */
  45325. ShadowGenerator.prototype.setTransparencyShadow = function (transparent) {
  45326. this._transparencyShadow = transparent;
  45327. return this;
  45328. };
  45329. /**
  45330. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  45331. * @returns The render target texture if present otherwise, null
  45332. */
  45333. ShadowGenerator.prototype.getShadowMap = function () {
  45334. return this._shadowMap;
  45335. };
  45336. /**
  45337. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  45338. * @returns The render target texture if the shadow map is present otherwise, null
  45339. */
  45340. ShadowGenerator.prototype.getShadowMapForRendering = function () {
  45341. if (this._shadowMap2) {
  45342. return this._shadowMap2;
  45343. }
  45344. return this._shadowMap;
  45345. };
  45346. /**
  45347. * Helper function to add a mesh and its descendants to the list of shadow casters.
  45348. * @param mesh Mesh to add
  45349. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  45350. * @returns the Shadow Generator itself
  45351. */
  45352. ShadowGenerator.prototype.addShadowCaster = function (mesh, includeDescendants) {
  45353. if (includeDescendants === void 0) { includeDescendants = true; }
  45354. var _a;
  45355. if (!this._shadowMap) {
  45356. return this;
  45357. }
  45358. if (!this._shadowMap.renderList) {
  45359. this._shadowMap.renderList = [];
  45360. }
  45361. this._shadowMap.renderList.push(mesh);
  45362. if (includeDescendants) {
  45363. (_a = this._shadowMap.renderList).push.apply(_a, mesh.getChildMeshes());
  45364. }
  45365. return this;
  45366. };
  45367. /**
  45368. * Helper function to remove a mesh and its descendants from the list of shadow casters
  45369. * @param mesh Mesh to remove
  45370. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  45371. * @returns the Shadow Generator itself
  45372. */
  45373. ShadowGenerator.prototype.removeShadowCaster = function (mesh, includeDescendants) {
  45374. if (includeDescendants === void 0) { includeDescendants = true; }
  45375. if (!this._shadowMap || !this._shadowMap.renderList) {
  45376. return this;
  45377. }
  45378. var index = this._shadowMap.renderList.indexOf(mesh);
  45379. if (index !== -1) {
  45380. this._shadowMap.renderList.splice(index, 1);
  45381. }
  45382. if (includeDescendants) {
  45383. for (var _i = 0, _a = mesh.getChildren(); _i < _a.length; _i++) {
  45384. var child = _a[_i];
  45385. this.removeShadowCaster(child);
  45386. }
  45387. }
  45388. return this;
  45389. };
  45390. /**
  45391. * Returns the associated light object.
  45392. * @returns the light generating the shadow
  45393. */
  45394. ShadowGenerator.prototype.getLight = function () {
  45395. return this._light;
  45396. };
  45397. ShadowGenerator.prototype._initializeGenerator = function () {
  45398. this._light._markMeshesAsLightDirty();
  45399. this._initializeShadowMap();
  45400. };
  45401. ShadowGenerator.prototype._initializeShadowMap = function () {
  45402. var _this = this;
  45403. // Render target
  45404. var engine = this._scene.getEngine();
  45405. if (engine.webGLVersion > 1) {
  45406. 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);
  45407. this._shadowMap.createDepthStencilTexture(_Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].LESS, true);
  45408. }
  45409. else {
  45410. 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());
  45411. }
  45412. this._shadowMap.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  45413. this._shadowMap.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  45414. this._shadowMap.anisotropicFilteringLevel = 1;
  45415. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  45416. this._shadowMap.renderParticles = false;
  45417. this._shadowMap.ignoreCameraViewport = true;
  45418. // Record Face Index before render.
  45419. this._shadowMap.onBeforeRenderObservable.add(function (faceIndex) {
  45420. _this._currentFaceIndex = faceIndex;
  45421. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  45422. engine.setColorWrite(false);
  45423. }
  45424. });
  45425. // Custom render function.
  45426. this._shadowMap.customRenderFunction = this._renderForShadowMap.bind(this);
  45427. // Blur if required afer render.
  45428. this._shadowMap.onAfterUnbindObservable.add(function () {
  45429. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  45430. engine.setColorWrite(true);
  45431. }
  45432. if (!_this.useBlurExponentialShadowMap && !_this.useBlurCloseExponentialShadowMap) {
  45433. return;
  45434. }
  45435. var shadowMap = _this.getShadowMapForRendering();
  45436. if (shadowMap) {
  45437. _this._scene.postProcessManager.directRender(_this._blurPostProcesses, shadowMap.getInternalTexture(), true);
  45438. }
  45439. });
  45440. // Clear according to the chosen filter.
  45441. var clearZero = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](0, 0, 0, 0);
  45442. var clearOne = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  45443. this._shadowMap.onClearObservable.add(function (engine) {
  45444. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  45445. engine.clear(clearOne, false, true, false);
  45446. }
  45447. else if (_this.useExponentialShadowMap || _this.useBlurExponentialShadowMap) {
  45448. engine.clear(clearZero, true, true, false);
  45449. }
  45450. else {
  45451. engine.clear(clearOne, true, true, false);
  45452. }
  45453. });
  45454. };
  45455. ShadowGenerator.prototype._initializeBlurRTTAndPostProcesses = function () {
  45456. var _this = this;
  45457. var engine = this._scene.getEngine();
  45458. var targetSize = this._mapSize / this.blurScale;
  45459. if (!this.useKernelBlur || this.blurScale !== 1.0) {
  45460. this._shadowMap2 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"](this._light.name + "_shadowMap2", targetSize, this._scene, false, true, this._textureType);
  45461. this._shadowMap2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  45462. this._shadowMap2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  45463. this._shadowMap2.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  45464. }
  45465. if (this.useKernelBlur) {
  45466. 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);
  45467. this._kernelBlurXPostprocess.width = targetSize;
  45468. this._kernelBlurXPostprocess.height = targetSize;
  45469. this._kernelBlurXPostprocess.onApplyObservable.add(function (effect) {
  45470. effect.setTexture("textureSampler", _this._shadowMap);
  45471. });
  45472. 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);
  45473. this._kernelBlurXPostprocess.autoClear = false;
  45474. this._kernelBlurYPostprocess.autoClear = false;
  45475. if (this._textureType === _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  45476. this._kernelBlurXPostprocess.packedFloat = true;
  45477. this._kernelBlurYPostprocess.packedFloat = true;
  45478. }
  45479. this._blurPostProcesses = [this._kernelBlurXPostprocess, this._kernelBlurYPostprocess];
  45480. }
  45481. else {
  45482. 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);
  45483. this._boxBlurPostprocess.onApplyObservable.add(function (effect) {
  45484. effect.setFloat2("screenSize", targetSize, targetSize);
  45485. effect.setTexture("textureSampler", _this._shadowMap);
  45486. });
  45487. this._boxBlurPostprocess.autoClear = false;
  45488. this._blurPostProcesses = [this._boxBlurPostprocess];
  45489. }
  45490. };
  45491. ShadowGenerator.prototype._renderForShadowMap = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  45492. var index;
  45493. var engine = this._scene.getEngine();
  45494. if (depthOnlySubMeshes.length) {
  45495. engine.setColorWrite(false);
  45496. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  45497. this._renderSubMeshForShadowMap(depthOnlySubMeshes.data[index]);
  45498. }
  45499. engine.setColorWrite(true);
  45500. }
  45501. for (index = 0; index < opaqueSubMeshes.length; index++) {
  45502. this._renderSubMeshForShadowMap(opaqueSubMeshes.data[index]);
  45503. }
  45504. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  45505. this._renderSubMeshForShadowMap(alphaTestSubMeshes.data[index]);
  45506. }
  45507. if (this._transparencyShadow) {
  45508. for (index = 0; index < transparentSubMeshes.length; index++) {
  45509. this._renderSubMeshForShadowMap(transparentSubMeshes.data[index]);
  45510. }
  45511. }
  45512. };
  45513. ShadowGenerator.prototype._renderSubMeshForShadowMap = function (subMesh) {
  45514. var _this = this;
  45515. var mesh = subMesh.getRenderingMesh();
  45516. var scene = this._scene;
  45517. var engine = scene.getEngine();
  45518. var material = subMesh.getMaterial();
  45519. if (!material || subMesh.verticesCount === 0) {
  45520. return;
  45521. }
  45522. // Culling
  45523. engine.setState(material.backFaceCulling);
  45524. // Managing instances
  45525. var batch = mesh._getInstancesRenderList(subMesh._id);
  45526. if (batch.mustReturn) {
  45527. return;
  45528. }
  45529. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  45530. if (this.isReady(subMesh, hardwareInstancedRendering)) {
  45531. engine.enableEffect(this._effect);
  45532. mesh._bind(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode);
  45533. this._effect.setFloat3("biasAndScale", this.bias, this.normalBias, this.depthScale);
  45534. this._effect.setMatrix("viewProjection", this.getTransformMatrix());
  45535. if (this.getLight().getTypeID() === _Lights_light__WEBPACK_IMPORTED_MODULE_3__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT) {
  45536. this._effect.setVector3("lightData", this._cachedDirection);
  45537. }
  45538. else {
  45539. this._effect.setVector3("lightData", this._cachedPosition);
  45540. }
  45541. if (scene.activeCamera) {
  45542. this._effect.setFloat2("depthValues", this.getLight().getDepthMinZ(scene.activeCamera), this.getLight().getDepthMinZ(scene.activeCamera) + this.getLight().getDepthMaxZ(scene.activeCamera));
  45543. }
  45544. // Alpha test
  45545. if (material && material.needAlphaTesting()) {
  45546. var alphaTexture = material.getAlphaTestTexture();
  45547. if (alphaTexture) {
  45548. this._effect.setTexture("diffuseSampler", alphaTexture);
  45549. this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix() || this._defaultTextureMatrix);
  45550. }
  45551. }
  45552. // Bones
  45553. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  45554. var skeleton = mesh.skeleton;
  45555. if (skeleton.isUsingTextureForMatrices) {
  45556. var boneTexture = skeleton.getTransformMatrixTexture();
  45557. if (!boneTexture) {
  45558. return;
  45559. }
  45560. this._effect.setTexture("boneSampler", boneTexture);
  45561. this._effect.setFloat("boneTextureWidth", 4.0 * (skeleton.bones.length + 1));
  45562. }
  45563. else {
  45564. this._effect.setMatrices("mBones", skeleton.getTransformMatrices((mesh)));
  45565. }
  45566. }
  45567. // Morph targets
  45568. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindMorphTargetParameters(mesh, this._effect);
  45569. if (this.forceBackFacesOnly) {
  45570. engine.setState(true, 0, false, true);
  45571. }
  45572. // Observable
  45573. this.onBeforeShadowMapRenderObservable.notifyObservers(this._effect);
  45574. // Draw
  45575. mesh._processRendering(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  45576. if (this.forceBackFacesOnly) {
  45577. engine.setState(true, 0, false, false);
  45578. }
  45579. }
  45580. else {
  45581. // Need to reset refresh rate of the shadowMap
  45582. if (this._shadowMap) {
  45583. this._shadowMap.resetRefreshCounter();
  45584. }
  45585. }
  45586. };
  45587. ShadowGenerator.prototype._applyFilterValues = function () {
  45588. if (!this._shadowMap) {
  45589. return;
  45590. }
  45591. if (this.filter === ShadowGenerator.FILTER_NONE || this.filter === ShadowGenerator.FILTER_PCSS) {
  45592. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].NEAREST_SAMPLINGMODE);
  45593. }
  45594. else {
  45595. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  45596. }
  45597. };
  45598. /**
  45599. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  45600. * @param onCompiled Callback triggered at the and of the effects compilation
  45601. * @param options Sets of optional options forcing the compilation with different modes
  45602. */
  45603. ShadowGenerator.prototype.forceCompilation = function (onCompiled, options) {
  45604. var _this = this;
  45605. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ useInstances: false }, options);
  45606. var shadowMap = this.getShadowMap();
  45607. if (!shadowMap) {
  45608. if (onCompiled) {
  45609. onCompiled(this);
  45610. }
  45611. return;
  45612. }
  45613. var renderList = shadowMap.renderList;
  45614. if (!renderList) {
  45615. if (onCompiled) {
  45616. onCompiled(this);
  45617. }
  45618. return;
  45619. }
  45620. var subMeshes = new Array();
  45621. for (var _i = 0, renderList_1 = renderList; _i < renderList_1.length; _i++) {
  45622. var mesh = renderList_1[_i];
  45623. subMeshes.push.apply(subMeshes, mesh.subMeshes);
  45624. }
  45625. if (subMeshes.length === 0) {
  45626. if (onCompiled) {
  45627. onCompiled(this);
  45628. }
  45629. return;
  45630. }
  45631. var currentIndex = 0;
  45632. var checkReady = function () {
  45633. if (!_this._scene || !_this._scene.getEngine()) {
  45634. return;
  45635. }
  45636. while (_this.isReady(subMeshes[currentIndex], localOptions.useInstances)) {
  45637. currentIndex++;
  45638. if (currentIndex >= subMeshes.length) {
  45639. if (onCompiled) {
  45640. onCompiled(_this);
  45641. }
  45642. return;
  45643. }
  45644. }
  45645. setTimeout(checkReady, 16);
  45646. };
  45647. checkReady();
  45648. };
  45649. /**
  45650. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  45651. * @param options Sets of optional options forcing the compilation with different modes
  45652. * @returns A promise that resolves when the compilation completes
  45653. */
  45654. ShadowGenerator.prototype.forceCompilationAsync = function (options) {
  45655. var _this = this;
  45656. return new Promise(function (resolve) {
  45657. _this.forceCompilation(function () {
  45658. resolve();
  45659. }, options);
  45660. });
  45661. };
  45662. /**
  45663. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  45664. * @param subMesh The submesh we want to render in the shadow map
  45665. * @param useInstances Defines wether will draw in the map using instances
  45666. * @returns true if ready otherwise, false
  45667. */
  45668. ShadowGenerator.prototype.isReady = function (subMesh, useInstances) {
  45669. var defines = [];
  45670. if (this._textureType !== _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  45671. defines.push("#define FLOAT");
  45672. }
  45673. if (this.useExponentialShadowMap || this.useBlurExponentialShadowMap) {
  45674. defines.push("#define ESM");
  45675. }
  45676. else if (this.usePercentageCloserFiltering || this.useContactHardeningShadow) {
  45677. defines.push("#define DEPTHTEXTURE");
  45678. }
  45679. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind];
  45680. var mesh = subMesh.getMesh();
  45681. var material = subMesh.getMaterial();
  45682. // Normal bias.
  45683. if (this.normalBias && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  45684. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  45685. defines.push("#define NORMAL");
  45686. if (mesh.nonUniformScaling) {
  45687. defines.push("#define NONUNIFORMSCALING");
  45688. }
  45689. if (this.getLight().getTypeID() === _Lights_light__WEBPACK_IMPORTED_MODULE_3__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT) {
  45690. defines.push("#define DIRECTIONINLIGHTDATA");
  45691. }
  45692. }
  45693. // Alpha test
  45694. if (material && material.needAlphaTesting()) {
  45695. var alphaTexture = material.getAlphaTestTexture();
  45696. if (alphaTexture) {
  45697. defines.push("#define ALPHATEST");
  45698. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  45699. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  45700. defines.push("#define UV1");
  45701. }
  45702. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  45703. if (alphaTexture.coordinatesIndex === 1) {
  45704. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind);
  45705. defines.push("#define UV2");
  45706. }
  45707. }
  45708. }
  45709. }
  45710. // Bones
  45711. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  45712. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  45713. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind);
  45714. if (mesh.numBoneInfluencers > 4) {
  45715. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind);
  45716. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsExtraKind);
  45717. }
  45718. var skeleton = mesh.skeleton;
  45719. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  45720. if (skeleton.isUsingTextureForMatrices) {
  45721. defines.push("#define BONETEXTURE");
  45722. }
  45723. else {
  45724. defines.push("#define BonesPerMesh " + (skeleton.bones.length + 1));
  45725. }
  45726. }
  45727. else {
  45728. defines.push("#define NUM_BONE_INFLUENCERS 0");
  45729. }
  45730. // Morph targets
  45731. var manager = mesh.morphTargetManager;
  45732. var morphInfluencers = 0;
  45733. if (manager) {
  45734. if (manager.numInfluencers > 0) {
  45735. defines.push("#define MORPHTARGETS");
  45736. morphInfluencers = manager.numInfluencers;
  45737. defines.push("#define NUM_MORPH_INFLUENCERS " + morphInfluencers);
  45738. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, { "NUM_MORPH_INFLUENCERS": morphInfluencers });
  45739. }
  45740. }
  45741. // Instances
  45742. if (useInstances) {
  45743. defines.push("#define INSTANCES");
  45744. attribs.push("world0");
  45745. attribs.push("world1");
  45746. attribs.push("world2");
  45747. attribs.push("world3");
  45748. }
  45749. if (this.customShaderOptions) {
  45750. if (this.customShaderOptions.defines) {
  45751. for (var _i = 0, _a = this.customShaderOptions.defines; _i < _a.length; _i++) {
  45752. var define = _a[_i];
  45753. if (defines.indexOf(define) === -1) {
  45754. defines.push(define);
  45755. }
  45756. }
  45757. }
  45758. }
  45759. // Get correct effect
  45760. var join = defines.join("\n");
  45761. if (this._cachedDefines !== join) {
  45762. this._cachedDefines = join;
  45763. var shaderName = "shadowMap";
  45764. var uniforms = ["world", "mBones", "viewProjection", "diffuseMatrix", "lightData", "depthValues", "biasAndScale", "morphTargetInfluences", "boneTextureWidth"];
  45765. var samplers = ["diffuseSampler", "boneSampler"];
  45766. // Custom shader?
  45767. if (this.customShaderOptions) {
  45768. shaderName = this.customShaderOptions.shaderName;
  45769. if (this.customShaderOptions.attributes) {
  45770. for (var _b = 0, _c = this.customShaderOptions.attributes; _b < _c.length; _b++) {
  45771. var attrib = _c[_b];
  45772. if (attribs.indexOf(attrib) === -1) {
  45773. attribs.push(attrib);
  45774. }
  45775. }
  45776. }
  45777. if (this.customShaderOptions.uniforms) {
  45778. for (var _d = 0, _e = this.customShaderOptions.uniforms; _d < _e.length; _d++) {
  45779. var uniform = _e[_d];
  45780. if (uniforms.indexOf(uniform) === -1) {
  45781. uniforms.push(uniform);
  45782. }
  45783. }
  45784. }
  45785. if (this.customShaderOptions.samplers) {
  45786. for (var _f = 0, _g = this.customShaderOptions.samplers; _f < _g.length; _f++) {
  45787. var sampler = _g[_f];
  45788. if (samplers.indexOf(sampler) === -1) {
  45789. samplers.push(sampler);
  45790. }
  45791. }
  45792. }
  45793. }
  45794. this._effect = this._scene.getEngine().createEffect(shaderName, attribs, uniforms, samplers, join, undefined, undefined, undefined, { maxSimultaneousMorphTargets: morphInfluencers });
  45795. }
  45796. if (!this._effect.isReady()) {
  45797. return false;
  45798. }
  45799. if (this.useBlurExponentialShadowMap || this.useBlurCloseExponentialShadowMap) {
  45800. if (!this._blurPostProcesses || !this._blurPostProcesses.length) {
  45801. this._initializeBlurRTTAndPostProcesses();
  45802. }
  45803. }
  45804. if (this._kernelBlurXPostprocess && !this._kernelBlurXPostprocess.isReady()) {
  45805. return false;
  45806. }
  45807. if (this._kernelBlurYPostprocess && !this._kernelBlurYPostprocess.isReady()) {
  45808. return false;
  45809. }
  45810. if (this._boxBlurPostprocess && !this._boxBlurPostprocess.isReady()) {
  45811. return false;
  45812. }
  45813. return true;
  45814. };
  45815. /**
  45816. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  45817. * @param defines Defines of the material we want to update
  45818. * @param lightIndex Index of the light in the enabled light list of the material
  45819. */
  45820. ShadowGenerator.prototype.prepareDefines = function (defines, lightIndex) {
  45821. var scene = this._scene;
  45822. var light = this._light;
  45823. if (!scene.shadowsEnabled || !light.shadowEnabled) {
  45824. return;
  45825. }
  45826. defines["SHADOW" + lightIndex] = true;
  45827. if (this.useContactHardeningShadow) {
  45828. defines["SHADOWPCSS" + lightIndex] = true;
  45829. if (this._filteringQuality === ShadowGenerator.QUALITY_LOW) {
  45830. defines["SHADOWLOWQUALITY" + lightIndex] = true;
  45831. }
  45832. else if (this._filteringQuality === ShadowGenerator.QUALITY_MEDIUM) {
  45833. defines["SHADOWMEDIUMQUALITY" + lightIndex] = true;
  45834. }
  45835. // else default to high.
  45836. }
  45837. if (this.usePercentageCloserFiltering) {
  45838. defines["SHADOWPCF" + lightIndex] = true;
  45839. if (this._filteringQuality === ShadowGenerator.QUALITY_LOW) {
  45840. defines["SHADOWLOWQUALITY" + lightIndex] = true;
  45841. }
  45842. else if (this._filteringQuality === ShadowGenerator.QUALITY_MEDIUM) {
  45843. defines["SHADOWMEDIUMQUALITY" + lightIndex] = true;
  45844. }
  45845. // else default to high.
  45846. }
  45847. else if (this.usePoissonSampling) {
  45848. defines["SHADOWPOISSON" + lightIndex] = true;
  45849. }
  45850. else if (this.useExponentialShadowMap || this.useBlurExponentialShadowMap) {
  45851. defines["SHADOWESM" + lightIndex] = true;
  45852. }
  45853. else if (this.useCloseExponentialShadowMap || this.useBlurCloseExponentialShadowMap) {
  45854. defines["SHADOWCLOSEESM" + lightIndex] = true;
  45855. }
  45856. if (light.needCube()) {
  45857. defines["SHADOWCUBE" + lightIndex] = true;
  45858. }
  45859. };
  45860. /**
  45861. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  45862. * defined in the generator but impacting the effect).
  45863. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  45864. * @param effect The effect we are binfing the information for
  45865. */
  45866. ShadowGenerator.prototype.bindShadowLight = function (lightIndex, effect) {
  45867. var light = this._light;
  45868. var scene = this._scene;
  45869. if (!scene.shadowsEnabled || !light.shadowEnabled) {
  45870. return;
  45871. }
  45872. var camera = scene.activeCamera;
  45873. if (!camera) {
  45874. return;
  45875. }
  45876. var shadowMap = this.getShadowMap();
  45877. if (!shadowMap) {
  45878. return;
  45879. }
  45880. if (!light.needCube()) {
  45881. effect.setMatrix("lightMatrix" + lightIndex, this.getTransformMatrix());
  45882. }
  45883. // Only PCF uses depth stencil texture.
  45884. if (this._filter === ShadowGenerator.FILTER_PCF) {
  45885. effect.setDepthStencilTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  45886. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), shadowMap.getSize().width, 1 / shadowMap.getSize().width, this.frustumEdgeFalloff, lightIndex);
  45887. }
  45888. else if (this._filter === ShadowGenerator.FILTER_PCSS) {
  45889. effect.setDepthStencilTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  45890. effect.setTexture("depthSampler" + lightIndex, this.getShadowMapForRendering());
  45891. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), 1 / shadowMap.getSize().width, this._contactHardeningLightSizeUVRatio * shadowMap.getSize().width, this.frustumEdgeFalloff, lightIndex);
  45892. }
  45893. else {
  45894. effect.setTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  45895. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), this.blurScale / shadowMap.getSize().width, this.depthScale, this.frustumEdgeFalloff, lightIndex);
  45896. }
  45897. light._uniformBuffer.updateFloat2("depthValues", this.getLight().getDepthMinZ(camera), this.getLight().getDepthMinZ(camera) + this.getLight().getDepthMaxZ(camera), lightIndex);
  45898. };
  45899. /**
  45900. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  45901. * (eq to shadow prjection matrix * light transform matrix)
  45902. * @returns The transform matrix used to create the shadow map
  45903. */
  45904. ShadowGenerator.prototype.getTransformMatrix = function () {
  45905. var scene = this._scene;
  45906. if (this._currentRenderID === scene.getRenderId() && this._currentFaceIndexCache === this._currentFaceIndex) {
  45907. return this._transformMatrix;
  45908. }
  45909. this._currentRenderID = scene.getRenderId();
  45910. this._currentFaceIndexCache = this._currentFaceIndex;
  45911. var lightPosition = this._light.position;
  45912. if (this._light.computeTransformedInformation()) {
  45913. lightPosition = this._light.transformedPosition;
  45914. }
  45915. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex), this._lightDirection);
  45916. if (Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(this._lightDirection, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up())) === 1.0) {
  45917. this._lightDirection.z = 0.0000000000001; // Required to avoid perfectly perpendicular light
  45918. }
  45919. if (this._light.needProjectionMatrixCompute() || !this._cachedPosition || !this._cachedDirection || !lightPosition.equals(this._cachedPosition) || !this._lightDirection.equals(this._cachedDirection)) {
  45920. this._cachedPosition.copyFrom(lightPosition);
  45921. this._cachedDirection.copyFrom(this._lightDirection);
  45922. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].LookAtLHToRef(lightPosition, lightPosition.add(this._lightDirection), _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up(), this._viewMatrix);
  45923. var shadowMap = this.getShadowMap();
  45924. if (shadowMap) {
  45925. var renderList = shadowMap.renderList;
  45926. if (renderList) {
  45927. this._light.setShadowProjectionMatrix(this._projectionMatrix, this._viewMatrix, renderList);
  45928. }
  45929. }
  45930. this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  45931. }
  45932. return this._transformMatrix;
  45933. };
  45934. /**
  45935. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  45936. * Cube and 2D textures for instance.
  45937. */
  45938. ShadowGenerator.prototype.recreateShadowMap = function () {
  45939. var shadowMap = this._shadowMap;
  45940. if (!shadowMap) {
  45941. return;
  45942. }
  45943. // Track render list.
  45944. var renderList = shadowMap.renderList;
  45945. // Clean up existing data.
  45946. this._disposeRTTandPostProcesses();
  45947. // Reinitializes.
  45948. this._initializeGenerator();
  45949. // Reaffect the filter to ensure a correct fallback if necessary.
  45950. this.filter = this.filter;
  45951. // Reaffect the filter.
  45952. this._applyFilterValues();
  45953. // Reaffect Render List.
  45954. this._shadowMap.renderList = renderList;
  45955. };
  45956. ShadowGenerator.prototype._disposeBlurPostProcesses = function () {
  45957. if (this._shadowMap2) {
  45958. this._shadowMap2.dispose();
  45959. this._shadowMap2 = null;
  45960. }
  45961. if (this._boxBlurPostprocess) {
  45962. this._boxBlurPostprocess.dispose();
  45963. this._boxBlurPostprocess = null;
  45964. }
  45965. if (this._kernelBlurXPostprocess) {
  45966. this._kernelBlurXPostprocess.dispose();
  45967. this._kernelBlurXPostprocess = null;
  45968. }
  45969. if (this._kernelBlurYPostprocess) {
  45970. this._kernelBlurYPostprocess.dispose();
  45971. this._kernelBlurYPostprocess = null;
  45972. }
  45973. this._blurPostProcesses = [];
  45974. };
  45975. ShadowGenerator.prototype._disposeRTTandPostProcesses = function () {
  45976. if (this._shadowMap) {
  45977. this._shadowMap.dispose();
  45978. this._shadowMap = null;
  45979. }
  45980. this._disposeBlurPostProcesses();
  45981. };
  45982. /**
  45983. * Disposes the ShadowGenerator.
  45984. * Returns nothing.
  45985. */
  45986. ShadowGenerator.prototype.dispose = function () {
  45987. this._disposeRTTandPostProcesses();
  45988. if (this._light) {
  45989. this._light._shadowGenerator = null;
  45990. this._light._markMeshesAsLightDirty();
  45991. }
  45992. };
  45993. /**
  45994. * Serializes the shadow generator setup to a json object.
  45995. * @returns The serialized JSON object
  45996. */
  45997. ShadowGenerator.prototype.serialize = function () {
  45998. var serializationObject = {};
  45999. var shadowMap = this.getShadowMap();
  46000. if (!shadowMap) {
  46001. return serializationObject;
  46002. }
  46003. serializationObject.lightId = this._light.id;
  46004. serializationObject.mapSize = shadowMap.getRenderSize();
  46005. serializationObject.useExponentialShadowMap = this.useExponentialShadowMap;
  46006. serializationObject.useBlurExponentialShadowMap = this.useBlurExponentialShadowMap;
  46007. serializationObject.useCloseExponentialShadowMap = this.useBlurExponentialShadowMap;
  46008. serializationObject.useBlurCloseExponentialShadowMap = this.useBlurExponentialShadowMap;
  46009. serializationObject.usePoissonSampling = this.usePoissonSampling;
  46010. serializationObject.forceBackFacesOnly = this.forceBackFacesOnly;
  46011. serializationObject.depthScale = this.depthScale;
  46012. serializationObject.darkness = this.getDarkness();
  46013. serializationObject.blurBoxOffset = this.blurBoxOffset;
  46014. serializationObject.blurKernel = this.blurKernel;
  46015. serializationObject.blurScale = this.blurScale;
  46016. serializationObject.useKernelBlur = this.useKernelBlur;
  46017. serializationObject.transparencyShadow = this._transparencyShadow;
  46018. serializationObject.frustumEdgeFalloff = this.frustumEdgeFalloff;
  46019. serializationObject.bias = this.bias;
  46020. serializationObject.normalBias = this.normalBias;
  46021. serializationObject.usePercentageCloserFiltering = this.usePercentageCloserFiltering;
  46022. serializationObject.useContactHardeningShadow = this.useContactHardeningShadow;
  46023. serializationObject.filteringQuality = this.filteringQuality;
  46024. serializationObject.contactHardeningLightSizeUVRatio = this.contactHardeningLightSizeUVRatio;
  46025. serializationObject.renderList = [];
  46026. if (shadowMap.renderList) {
  46027. for (var meshIndex = 0; meshIndex < shadowMap.renderList.length; meshIndex++) {
  46028. var mesh = shadowMap.renderList[meshIndex];
  46029. serializationObject.renderList.push(mesh.id);
  46030. }
  46031. }
  46032. return serializationObject;
  46033. };
  46034. /**
  46035. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  46036. * @param parsedShadowGenerator The JSON object to parse
  46037. * @param scene The scene to create the shadow map for
  46038. * @returns The parsed shadow generator
  46039. */
  46040. ShadowGenerator.Parse = function (parsedShadowGenerator, scene) {
  46041. var light = scene.getLightByID(parsedShadowGenerator.lightId);
  46042. var shadowGenerator = new ShadowGenerator(parsedShadowGenerator.mapSize, light);
  46043. var shadowMap = shadowGenerator.getShadowMap();
  46044. for (var meshIndex = 0; meshIndex < parsedShadowGenerator.renderList.length; meshIndex++) {
  46045. var meshes = scene.getMeshesByID(parsedShadowGenerator.renderList[meshIndex]);
  46046. meshes.forEach(function (mesh) {
  46047. if (!shadowMap) {
  46048. return;
  46049. }
  46050. if (!shadowMap.renderList) {
  46051. shadowMap.renderList = [];
  46052. }
  46053. shadowMap.renderList.push(mesh);
  46054. });
  46055. }
  46056. if (parsedShadowGenerator.usePoissonSampling) {
  46057. shadowGenerator.usePoissonSampling = true;
  46058. }
  46059. else if (parsedShadowGenerator.useExponentialShadowMap) {
  46060. shadowGenerator.useExponentialShadowMap = true;
  46061. }
  46062. else if (parsedShadowGenerator.useBlurExponentialShadowMap) {
  46063. shadowGenerator.useBlurExponentialShadowMap = true;
  46064. }
  46065. else if (parsedShadowGenerator.useCloseExponentialShadowMap) {
  46066. shadowGenerator.useCloseExponentialShadowMap = true;
  46067. }
  46068. else if (parsedShadowGenerator.useBlurCloseExponentialShadowMap) {
  46069. shadowGenerator.useBlurCloseExponentialShadowMap = true;
  46070. }
  46071. else if (parsedShadowGenerator.usePercentageCloserFiltering) {
  46072. shadowGenerator.usePercentageCloserFiltering = true;
  46073. }
  46074. else if (parsedShadowGenerator.useContactHardeningShadow) {
  46075. shadowGenerator.useContactHardeningShadow = true;
  46076. }
  46077. if (parsedShadowGenerator.filteringQuality) {
  46078. shadowGenerator.filteringQuality = parsedShadowGenerator.filteringQuality;
  46079. }
  46080. if (parsedShadowGenerator.contactHardeningLightSizeUVRatio) {
  46081. shadowGenerator.contactHardeningLightSizeUVRatio = parsedShadowGenerator.contactHardeningLightSizeUVRatio;
  46082. }
  46083. // Backward compat
  46084. else if (parsedShadowGenerator.useVarianceShadowMap) {
  46085. shadowGenerator.useExponentialShadowMap = true;
  46086. }
  46087. else if (parsedShadowGenerator.useBlurVarianceShadowMap) {
  46088. shadowGenerator.useBlurExponentialShadowMap = true;
  46089. }
  46090. if (parsedShadowGenerator.depthScale) {
  46091. shadowGenerator.depthScale = parsedShadowGenerator.depthScale;
  46092. }
  46093. if (parsedShadowGenerator.blurScale) {
  46094. shadowGenerator.blurScale = parsedShadowGenerator.blurScale;
  46095. }
  46096. if (parsedShadowGenerator.blurBoxOffset) {
  46097. shadowGenerator.blurBoxOffset = parsedShadowGenerator.blurBoxOffset;
  46098. }
  46099. if (parsedShadowGenerator.useKernelBlur) {
  46100. shadowGenerator.useKernelBlur = parsedShadowGenerator.useKernelBlur;
  46101. }
  46102. if (parsedShadowGenerator.blurKernel) {
  46103. shadowGenerator.blurKernel = parsedShadowGenerator.blurKernel;
  46104. }
  46105. if (parsedShadowGenerator.bias !== undefined) {
  46106. shadowGenerator.bias = parsedShadowGenerator.bias;
  46107. }
  46108. if (parsedShadowGenerator.normalBias !== undefined) {
  46109. shadowGenerator.normalBias = parsedShadowGenerator.normalBias;
  46110. }
  46111. if (parsedShadowGenerator.frustumEdgeFalloff !== undefined) {
  46112. shadowGenerator.frustumEdgeFalloff = parsedShadowGenerator.frustumEdgeFalloff;
  46113. }
  46114. if (parsedShadowGenerator.darkness) {
  46115. shadowGenerator.setDarkness(parsedShadowGenerator.darkness);
  46116. }
  46117. if (parsedShadowGenerator.transparencyShadow) {
  46118. shadowGenerator.setTransparencyShadow(true);
  46119. }
  46120. shadowGenerator.forceBackFacesOnly = parsedShadowGenerator.forceBackFacesOnly;
  46121. return shadowGenerator;
  46122. };
  46123. /**
  46124. * Shadow generator mode None: no filtering applied.
  46125. */
  46126. ShadowGenerator.FILTER_NONE = 0;
  46127. /**
  46128. * Shadow generator mode ESM: Exponential Shadow Mapping.
  46129. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  46130. */
  46131. ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP = 1;
  46132. /**
  46133. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  46134. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  46135. */
  46136. ShadowGenerator.FILTER_POISSONSAMPLING = 2;
  46137. /**
  46138. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  46139. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  46140. */
  46141. ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP = 3;
  46142. /**
  46143. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  46144. * edge artifacts on steep falloff.
  46145. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  46146. */
  46147. ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP = 4;
  46148. /**
  46149. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  46150. * edge artifacts on steep falloff.
  46151. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  46152. */
  46153. ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP = 5;
  46154. /**
  46155. * Shadow generator mode PCF: Percentage Closer Filtering
  46156. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  46157. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  46158. */
  46159. ShadowGenerator.FILTER_PCF = 6;
  46160. /**
  46161. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  46162. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  46163. * Contact Hardening
  46164. */
  46165. ShadowGenerator.FILTER_PCSS = 7;
  46166. /**
  46167. * Reserved for PCF and PCSS
  46168. * Highest Quality.
  46169. *
  46170. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  46171. *
  46172. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  46173. */
  46174. ShadowGenerator.QUALITY_HIGH = 0;
  46175. /**
  46176. * Reserved for PCF and PCSS
  46177. * Good tradeoff for quality/perf cross devices
  46178. *
  46179. * Execute PCF on a 3*3 kernel.
  46180. *
  46181. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  46182. */
  46183. ShadowGenerator.QUALITY_MEDIUM = 1;
  46184. /**
  46185. * Reserved for PCF and PCSS
  46186. * The lowest quality but the fastest.
  46187. *
  46188. * Execute PCF on a 1*1 kernel.
  46189. *
  46190. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  46191. */
  46192. ShadowGenerator.QUALITY_LOW = 2;
  46193. /** @hidden */
  46194. ShadowGenerator._SceneComponentInitialization = function (_) {
  46195. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_15__["_DevTools"].WarnImport("ShadowGeneratorSceneComponent");
  46196. };
  46197. return ShadowGenerator;
  46198. }());
  46199. /***/ }),
  46200. /***/ "./Lights/Shadows/shadowGeneratorSceneComponent.ts":
  46201. /*!*********************************************************!*\
  46202. !*** ./Lights/Shadows/shadowGeneratorSceneComponent.ts ***!
  46203. \*********************************************************/
  46204. /*! exports provided: ShadowGeneratorSceneComponent */
  46205. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46206. "use strict";
  46207. __webpack_require__.r(__webpack_exports__);
  46208. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return ShadowGeneratorSceneComponent; });
  46209. /* harmony import */ var _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./shadowGenerator */ "./Lights/Shadows/shadowGenerator.ts");
  46210. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  46211. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../abstractScene */ "./abstractScene.ts");
  46212. // Adds the parser to the scene parsers.
  46213. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR, function (parsedData, scene) {
  46214. // Shadows
  46215. if (parsedData.shadowGenerators !== undefined && parsedData.shadowGenerators !== null) {
  46216. for (var index = 0, cache = parsedData.shadowGenerators.length; index < cache; index++) {
  46217. var parsedShadowGenerator = parsedData.shadowGenerators[index];
  46218. _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"].Parse(parsedShadowGenerator, scene);
  46219. // SG would be available on their associated lights
  46220. }
  46221. }
  46222. });
  46223. /**
  46224. * Defines the shadow generator component responsible to manage any shadow generators
  46225. * in a given scene.
  46226. */
  46227. var ShadowGeneratorSceneComponent = /** @class */ (function () {
  46228. /**
  46229. * Creates a new instance of the component for the given scene
  46230. * @param scene Defines the scene to register the component in
  46231. */
  46232. function ShadowGeneratorSceneComponent(scene) {
  46233. /**
  46234. * The component name helpfull to identify the component in the list of scene components.
  46235. */
  46236. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR;
  46237. this.scene = scene;
  46238. }
  46239. /**
  46240. * Registers the component in a given scene
  46241. */
  46242. ShadowGeneratorSceneComponent.prototype.register = function () {
  46243. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_SHADOWGENERATOR, this, this._gatherRenderTargets);
  46244. };
  46245. /**
  46246. * Rebuilds the elements related to this component in case of
  46247. * context lost for instance.
  46248. */
  46249. ShadowGeneratorSceneComponent.prototype.rebuild = function () {
  46250. // Nothing To Do Here.
  46251. };
  46252. /**
  46253. * Serializes the component data to the specified json object
  46254. * @param serializationObject The object to serialize to
  46255. */
  46256. ShadowGeneratorSceneComponent.prototype.serialize = function (serializationObject) {
  46257. // Shadows
  46258. serializationObject.shadowGenerators = [];
  46259. var lights = this.scene.lights;
  46260. for (var _i = 0, lights_1 = lights; _i < lights_1.length; _i++) {
  46261. var light = lights_1[_i];
  46262. var shadowGenerator = light.getShadowGenerator();
  46263. if (shadowGenerator) {
  46264. serializationObject.shadowGenerators.push(shadowGenerator.serialize());
  46265. }
  46266. }
  46267. };
  46268. /**
  46269. * Adds all the element from the container to the scene
  46270. * @param container the container holding the elements
  46271. */
  46272. ShadowGeneratorSceneComponent.prototype.addFromContainer = function (container) {
  46273. // Nothing To Do Here. (directly attached to a light)
  46274. };
  46275. /**
  46276. * Removes all the elements in the container from the scene
  46277. * @param container contains the elements to remove
  46278. */
  46279. ShadowGeneratorSceneComponent.prototype.removeFromContainer = function (container) {
  46280. // Nothing To Do Here. (directly attached to a light)
  46281. };
  46282. /**
  46283. * Rebuilds the elements related to this component in case of
  46284. * context lost for instance.
  46285. */
  46286. ShadowGeneratorSceneComponent.prototype.dispose = function () {
  46287. // Nothing To Do Here.
  46288. };
  46289. ShadowGeneratorSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  46290. // Shadows
  46291. var scene = this.scene;
  46292. if (this.scene.shadowsEnabled) {
  46293. for (var lightIndex = 0; lightIndex < scene.lights.length; lightIndex++) {
  46294. var light = scene.lights[lightIndex];
  46295. var shadowGenerator = light.getShadowGenerator();
  46296. if (light.isEnabled() && light.shadowEnabled && shadowGenerator) {
  46297. var shadowMap = (shadowGenerator.getShadowMap());
  46298. if (scene.textures.indexOf(shadowMap) !== -1) {
  46299. renderTargets.push(shadowMap);
  46300. }
  46301. }
  46302. }
  46303. }
  46304. };
  46305. return ShadowGeneratorSceneComponent;
  46306. }());
  46307. _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]._SceneComponentInitialization = function (scene) {
  46308. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR);
  46309. if (!component) {
  46310. component = new ShadowGeneratorSceneComponent(scene);
  46311. scene._addComponent(component);
  46312. }
  46313. };
  46314. /***/ }),
  46315. /***/ "./Lights/directionalLight.ts":
  46316. /*!************************************!*\
  46317. !*** ./Lights/directionalLight.ts ***!
  46318. \************************************/
  46319. /*! exports provided: DirectionalLight */
  46320. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46321. "use strict";
  46322. __webpack_require__.r(__webpack_exports__);
  46323. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return DirectionalLight; });
  46324. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  46325. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  46326. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  46327. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  46328. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  46329. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  46330. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_1", function (name, scene) {
  46331. return function () { return new DirectionalLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  46332. });
  46333. /**
  46334. * A directional light is defined by a direction (what a surprise!).
  46335. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46336. * 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.
  46337. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46338. */
  46339. var DirectionalLight = /** @class */ (function (_super) {
  46340. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DirectionalLight, _super);
  46341. /**
  46342. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46343. * The directional light is emitted from everywhere in the given direction.
  46344. * It can cast shadows.
  46345. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46346. * @param name The friendly name of the light
  46347. * @param direction The direction of the light
  46348. * @param scene The scene the light belongs to
  46349. */
  46350. function DirectionalLight(name, direction, scene) {
  46351. var _this = _super.call(this, name, scene) || this;
  46352. _this._shadowFrustumSize = 0;
  46353. _this._shadowOrthoScale = 0.1;
  46354. /**
  46355. * Automatically compute the projection matrix to best fit (including all the casters)
  46356. * on each frame.
  46357. */
  46358. _this.autoUpdateExtends = true;
  46359. // Cache
  46360. _this._orthoLeft = Number.MAX_VALUE;
  46361. _this._orthoRight = Number.MIN_VALUE;
  46362. _this._orthoTop = Number.MIN_VALUE;
  46363. _this._orthoBottom = Number.MAX_VALUE;
  46364. _this.position = direction.scale(-1.0);
  46365. _this.direction = direction;
  46366. return _this;
  46367. }
  46368. Object.defineProperty(DirectionalLight.prototype, "shadowFrustumSize", {
  46369. /**
  46370. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46371. */
  46372. get: function () {
  46373. return this._shadowFrustumSize;
  46374. },
  46375. /**
  46376. * Specifies a fix frustum size for the shadow generation.
  46377. */
  46378. set: function (value) {
  46379. this._shadowFrustumSize = value;
  46380. this.forceProjectionMatrixCompute();
  46381. },
  46382. enumerable: true,
  46383. configurable: true
  46384. });
  46385. Object.defineProperty(DirectionalLight.prototype, "shadowOrthoScale", {
  46386. /**
  46387. * Gets the shadow projection scale against the optimal computed one.
  46388. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46389. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46390. */
  46391. get: function () {
  46392. return this._shadowOrthoScale;
  46393. },
  46394. /**
  46395. * Sets the shadow projection scale against the optimal computed one.
  46396. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46397. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46398. */
  46399. set: function (value) {
  46400. this._shadowOrthoScale = value;
  46401. this.forceProjectionMatrixCompute();
  46402. },
  46403. enumerable: true,
  46404. configurable: true
  46405. });
  46406. /**
  46407. * Returns the string "DirectionalLight".
  46408. * @return The class name
  46409. */
  46410. DirectionalLight.prototype.getClassName = function () {
  46411. return "DirectionalLight";
  46412. };
  46413. /**
  46414. * Returns the integer 1.
  46415. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46416. */
  46417. DirectionalLight.prototype.getTypeID = function () {
  46418. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT;
  46419. };
  46420. /**
  46421. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46422. * Returns the DirectionalLight Shadow projection matrix.
  46423. */
  46424. DirectionalLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  46425. if (this.shadowFrustumSize > 0) {
  46426. this._setDefaultFixedFrustumShadowProjectionMatrix(matrix);
  46427. }
  46428. else {
  46429. this._setDefaultAutoExtendShadowProjectionMatrix(matrix, viewMatrix, renderList);
  46430. }
  46431. };
  46432. /**
  46433. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46434. * Returns the DirectionalLight Shadow projection matrix.
  46435. */
  46436. DirectionalLight.prototype._setDefaultFixedFrustumShadowProjectionMatrix = function (matrix) {
  46437. var activeCamera = this.getScene().activeCamera;
  46438. if (!activeCamera) {
  46439. return;
  46440. }
  46441. _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);
  46442. };
  46443. /**
  46444. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46445. * Returns the DirectionalLight Shadow projection matrix.
  46446. */
  46447. DirectionalLight.prototype._setDefaultAutoExtendShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  46448. var activeCamera = this.getScene().activeCamera;
  46449. if (!activeCamera) {
  46450. return;
  46451. }
  46452. // Check extends
  46453. if (this.autoUpdateExtends || this._orthoLeft === Number.MAX_VALUE) {
  46454. var tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  46455. this._orthoLeft = Number.MAX_VALUE;
  46456. this._orthoRight = Number.MIN_VALUE;
  46457. this._orthoTop = Number.MIN_VALUE;
  46458. this._orthoBottom = Number.MAX_VALUE;
  46459. for (var meshIndex = 0; meshIndex < renderList.length; meshIndex++) {
  46460. var mesh = renderList[meshIndex];
  46461. if (!mesh) {
  46462. continue;
  46463. }
  46464. var boundingInfo = mesh.getBoundingInfo();
  46465. var boundingBox = boundingInfo.boundingBox;
  46466. for (var index = 0; index < boundingBox.vectorsWorld.length; index++) {
  46467. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(boundingBox.vectorsWorld[index], viewMatrix, tempVector3);
  46468. if (tempVector3.x < this._orthoLeft) {
  46469. this._orthoLeft = tempVector3.x;
  46470. }
  46471. if (tempVector3.y < this._orthoBottom) {
  46472. this._orthoBottom = tempVector3.y;
  46473. }
  46474. if (tempVector3.x > this._orthoRight) {
  46475. this._orthoRight = tempVector3.x;
  46476. }
  46477. if (tempVector3.y > this._orthoTop) {
  46478. this._orthoTop = tempVector3.y;
  46479. }
  46480. }
  46481. }
  46482. }
  46483. var xOffset = this._orthoRight - this._orthoLeft;
  46484. var yOffset = this._orthoTop - this._orthoBottom;
  46485. _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);
  46486. };
  46487. DirectionalLight.prototype._buildUniformLayout = function () {
  46488. this._uniformBuffer.addUniform("vLightData", 4);
  46489. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  46490. this._uniformBuffer.addUniform("vLightSpecular", 3);
  46491. this._uniformBuffer.addUniform("shadowsInfo", 3);
  46492. this._uniformBuffer.addUniform("depthValues", 2);
  46493. this._uniformBuffer.create();
  46494. };
  46495. /**
  46496. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46497. * @param effect The effect to update
  46498. * @param lightIndex The index of the light in the effect to update
  46499. * @returns The directional light
  46500. */
  46501. DirectionalLight.prototype.transferToEffect = function (effect, lightIndex) {
  46502. if (this.computeTransformedInformation()) {
  46503. this._uniformBuffer.updateFloat4("vLightData", this.transformedDirection.x, this.transformedDirection.y, this.transformedDirection.z, 1, lightIndex);
  46504. return this;
  46505. }
  46506. this._uniformBuffer.updateFloat4("vLightData", this.direction.x, this.direction.y, this.direction.z, 1, lightIndex);
  46507. return this;
  46508. };
  46509. /**
  46510. * Gets the minZ used for shadow according to both the scene and the light.
  46511. *
  46512. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46513. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46514. * @param activeCamera The camera we are returning the min for
  46515. * @returns the depth min z
  46516. */
  46517. DirectionalLight.prototype.getDepthMinZ = function (activeCamera) {
  46518. return 1;
  46519. };
  46520. /**
  46521. * Gets the maxZ used for shadow according to both the scene and the light.
  46522. *
  46523. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46524. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46525. * @param activeCamera The camera we are returning the max for
  46526. * @returns the depth max z
  46527. */
  46528. DirectionalLight.prototype.getDepthMaxZ = function (activeCamera) {
  46529. return 1;
  46530. };
  46531. /**
  46532. * Prepares the list of defines specific to the light type.
  46533. * @param defines the list of defines
  46534. * @param lightIndex defines the index of the light for the effect
  46535. */
  46536. DirectionalLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  46537. defines["DIRLIGHT" + lightIndex] = true;
  46538. };
  46539. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46540. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46541. ], DirectionalLight.prototype, "shadowFrustumSize", null);
  46542. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46543. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46544. ], DirectionalLight.prototype, "shadowOrthoScale", null);
  46545. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46546. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46547. ], DirectionalLight.prototype, "autoUpdateExtends", void 0);
  46548. return DirectionalLight;
  46549. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  46550. /***/ }),
  46551. /***/ "./Lights/hemisphericLight.ts":
  46552. /*!************************************!*\
  46553. !*** ./Lights/hemisphericLight.ts ***!
  46554. \************************************/
  46555. /*! exports provided: HemisphericLight */
  46556. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46557. "use strict";
  46558. __webpack_require__.r(__webpack_exports__);
  46559. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return HemisphericLight; });
  46560. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  46561. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  46562. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  46563. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  46564. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  46565. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_3", function (name, scene) {
  46566. return function () { return new HemisphericLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  46567. });
  46568. /**
  46569. * The HemisphericLight simulates the ambient environment light,
  46570. * so the passed direction is the light reflection direction, not the incoming direction.
  46571. */
  46572. var HemisphericLight = /** @class */ (function (_super) {
  46573. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HemisphericLight, _super);
  46574. /**
  46575. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  46576. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  46577. * The HemisphericLight can't cast shadows.
  46578. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46579. * @param name The friendly name of the light
  46580. * @param direction The direction of the light reflection
  46581. * @param scene The scene the light belongs to
  46582. */
  46583. function HemisphericLight(name, direction, scene) {
  46584. var _this = _super.call(this, name, scene) || this;
  46585. /**
  46586. * The groundColor is the light in the opposite direction to the one specified during creation.
  46587. * 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.
  46588. */
  46589. _this.groundColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.0, 0.0, 0.0);
  46590. _this.direction = direction || _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up();
  46591. return _this;
  46592. }
  46593. HemisphericLight.prototype._buildUniformLayout = function () {
  46594. this._uniformBuffer.addUniform("vLightData", 4);
  46595. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  46596. this._uniformBuffer.addUniform("vLightSpecular", 3);
  46597. this._uniformBuffer.addUniform("vLightGround", 3);
  46598. this._uniformBuffer.addUniform("shadowsInfo", 3);
  46599. this._uniformBuffer.addUniform("depthValues", 2);
  46600. this._uniformBuffer.create();
  46601. };
  46602. /**
  46603. * Returns the string "HemisphericLight".
  46604. * @return The class name
  46605. */
  46606. HemisphericLight.prototype.getClassName = function () {
  46607. return "HemisphericLight";
  46608. };
  46609. /**
  46610. * Sets the HemisphericLight direction towards the passed target (Vector3).
  46611. * Returns the updated direction.
  46612. * @param target The target the direction should point to
  46613. * @return The computed direction
  46614. */
  46615. HemisphericLight.prototype.setDirectionToTarget = function (target) {
  46616. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(target.subtract(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero()));
  46617. return this.direction;
  46618. };
  46619. /**
  46620. * Returns the shadow generator associated to the light.
  46621. * @returns Always null for hemispheric lights because it does not support shadows.
  46622. */
  46623. HemisphericLight.prototype.getShadowGenerator = function () {
  46624. return null;
  46625. };
  46626. /**
  46627. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  46628. * @param effect The effect to update
  46629. * @param lightIndex The index of the light in the effect to update
  46630. * @returns The hemispheric light
  46631. */
  46632. HemisphericLight.prototype.transferToEffect = function (effect, lightIndex) {
  46633. var normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.direction);
  46634. this._uniformBuffer.updateFloat4("vLightData", normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, 0.0, lightIndex);
  46635. this._uniformBuffer.updateColor3("vLightGround", this.groundColor.scale(this.intensity), lightIndex);
  46636. return this;
  46637. };
  46638. /**
  46639. * Computes the world matrix of the node
  46640. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  46641. * @param useWasUpdatedFlag defines a reserved property
  46642. * @returns the world matrix
  46643. */
  46644. HemisphericLight.prototype.computeWorldMatrix = function () {
  46645. if (!this._worldMatrix) {
  46646. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  46647. }
  46648. return this._worldMatrix;
  46649. };
  46650. /**
  46651. * Returns the integer 3.
  46652. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46653. */
  46654. HemisphericLight.prototype.getTypeID = function () {
  46655. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_HEMISPHERICLIGHT;
  46656. };
  46657. /**
  46658. * Prepares the list of defines specific to the light type.
  46659. * @param defines the list of defines
  46660. * @param lightIndex defines the index of the light for the effect
  46661. */
  46662. HemisphericLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  46663. defines["HEMILIGHT" + lightIndex] = true;
  46664. };
  46665. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46666. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  46667. ], HemisphericLight.prototype, "groundColor", void 0);
  46668. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46669. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  46670. ], HemisphericLight.prototype, "direction", void 0);
  46671. return HemisphericLight;
  46672. }(_light__WEBPACK_IMPORTED_MODULE_4__["Light"]));
  46673. /***/ }),
  46674. /***/ "./Lights/index.ts":
  46675. /*!*************************!*\
  46676. !*** ./Lights/index.ts ***!
  46677. \*************************/
  46678. /*! exports provided: Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, ShadowGenerator, ShadowGeneratorSceneComponent */
  46679. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46680. "use strict";
  46681. __webpack_require__.r(__webpack_exports__);
  46682. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  46683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _light__WEBPACK_IMPORTED_MODULE_0__["Light"]; });
  46684. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  46685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _shadowLight__WEBPACK_IMPORTED_MODULE_1__["ShadowLight"]; });
  46686. /* harmony import */ var _Shadows_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Shadows/index */ "./Lights/Shadows/index.ts");
  46687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _Shadows_index__WEBPACK_IMPORTED_MODULE_2__["ShadowGenerator"]; });
  46688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _Shadows_index__WEBPACK_IMPORTED_MODULE_2__["ShadowGeneratorSceneComponent"]; });
  46689. /* harmony import */ var _directionalLight__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./directionalLight */ "./Lights/directionalLight.ts");
  46690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _directionalLight__WEBPACK_IMPORTED_MODULE_3__["DirectionalLight"]; });
  46691. /* harmony import */ var _hemisphericLight__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./hemisphericLight */ "./Lights/hemisphericLight.ts");
  46692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _hemisphericLight__WEBPACK_IMPORTED_MODULE_4__["HemisphericLight"]; });
  46693. /* harmony import */ var _pointLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./pointLight */ "./Lights/pointLight.ts");
  46694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _pointLight__WEBPACK_IMPORTED_MODULE_5__["PointLight"]; });
  46695. /* harmony import */ var _spotLight__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./spotLight */ "./Lights/spotLight.ts");
  46696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _spotLight__WEBPACK_IMPORTED_MODULE_6__["SpotLight"]; });
  46697. /***/ }),
  46698. /***/ "./Lights/light.ts":
  46699. /*!*************************!*\
  46700. !*** ./Lights/light.ts ***!
  46701. \*************************/
  46702. /*! exports provided: Light */
  46703. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46704. "use strict";
  46705. __webpack_require__.r(__webpack_exports__);
  46706. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return Light; });
  46707. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  46708. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  46709. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  46710. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  46711. /* harmony import */ var _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/uniformBuffer */ "./Materials/uniformBuffer.ts");
  46712. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  46713. /**
  46714. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  46715. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  46716. * 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.
  46717. */
  46718. var Light = /** @class */ (function (_super) {
  46719. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Light, _super);
  46720. /**
  46721. * Creates a Light object in the scene.
  46722. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46723. * @param name The firendly name of the light
  46724. * @param scene The scene the light belongs too
  46725. */
  46726. function Light(name, scene) {
  46727. var _this = _super.call(this, name, scene) || this;
  46728. /**
  46729. * Diffuse gives the basic color to an object.
  46730. */
  46731. _this.diffuse = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](1.0, 1.0, 1.0);
  46732. /**
  46733. * Specular produces a highlight color on an object.
  46734. * Note: This is note affecting PBR materials.
  46735. */
  46736. _this.specular = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](1.0, 1.0, 1.0);
  46737. /**
  46738. * Defines the falloff type for this light. This lets overrriding how punctual light are
  46739. * falling off base on range or angle.
  46740. * This can be set to any values in Light.FALLOFF_x.
  46741. *
  46742. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  46743. * other types of materials.
  46744. */
  46745. _this.falloffType = Light.FALLOFF_DEFAULT;
  46746. /**
  46747. * Strength of the light.
  46748. * Note: By default it is define in the framework own unit.
  46749. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  46750. */
  46751. _this.intensity = 1.0;
  46752. _this._range = Number.MAX_VALUE;
  46753. _this._inverseSquaredRange = 0;
  46754. /**
  46755. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  46756. * of light.
  46757. */
  46758. _this._photometricScale = 1.0;
  46759. _this._intensityMode = Light.INTENSITYMODE_AUTOMATIC;
  46760. _this._radius = 0.00001;
  46761. /**
  46762. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  46763. * exceeding the number allowed of the materials.
  46764. */
  46765. _this.renderPriority = 0;
  46766. _this._shadowEnabled = true;
  46767. _this._excludeWithLayerMask = 0;
  46768. _this._includeOnlyWithLayerMask = 0;
  46769. _this._lightmapMode = 0;
  46770. /**
  46771. * @hidden Internal use only.
  46772. */
  46773. _this._excludedMeshesIds = new Array();
  46774. /**
  46775. * @hidden Internal use only.
  46776. */
  46777. _this._includedOnlyMeshesIds = new Array();
  46778. /** @hidden */
  46779. _this._isLight = true;
  46780. _this.getScene().addLight(_this);
  46781. _this._uniformBuffer = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_4__["UniformBuffer"](_this.getScene().getEngine());
  46782. _this._buildUniformLayout();
  46783. _this.includedOnlyMeshes = new Array();
  46784. _this.excludedMeshes = new Array();
  46785. _this._resyncMeshes();
  46786. return _this;
  46787. }
  46788. Object.defineProperty(Light.prototype, "range", {
  46789. /**
  46790. * Defines how far from the source the light is impacting in scene units.
  46791. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  46792. */
  46793. get: function () {
  46794. return this._range;
  46795. },
  46796. /**
  46797. * Defines how far from the source the light is impacting in scene units.
  46798. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  46799. */
  46800. set: function (value) {
  46801. this._range = value;
  46802. this._inverseSquaredRange = 1.0 / (this.range * this.range);
  46803. },
  46804. enumerable: true,
  46805. configurable: true
  46806. });
  46807. Object.defineProperty(Light.prototype, "intensityMode", {
  46808. /**
  46809. * Gets the photometric scale used to interpret the intensity.
  46810. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  46811. */
  46812. get: function () {
  46813. return this._intensityMode;
  46814. },
  46815. /**
  46816. * Sets the photometric scale used to interpret the intensity.
  46817. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  46818. */
  46819. set: function (value) {
  46820. this._intensityMode = value;
  46821. this._computePhotometricScale();
  46822. },
  46823. enumerable: true,
  46824. configurable: true
  46825. });
  46826. Object.defineProperty(Light.prototype, "radius", {
  46827. /**
  46828. * Gets the light radius used by PBR Materials to simulate soft area lights.
  46829. */
  46830. get: function () {
  46831. return this._radius;
  46832. },
  46833. /**
  46834. * sets the light radius used by PBR Materials to simulate soft area lights.
  46835. */
  46836. set: function (value) {
  46837. this._radius = value;
  46838. this._computePhotometricScale();
  46839. },
  46840. enumerable: true,
  46841. configurable: true
  46842. });
  46843. Object.defineProperty(Light.prototype, "shadowEnabled", {
  46844. /**
  46845. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  46846. * the current shadow generator.
  46847. */
  46848. get: function () {
  46849. return this._shadowEnabled;
  46850. },
  46851. /**
  46852. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  46853. * the current shadow generator.
  46854. */
  46855. set: function (value) {
  46856. if (this._shadowEnabled === value) {
  46857. return;
  46858. }
  46859. this._shadowEnabled = value;
  46860. this._markMeshesAsLightDirty();
  46861. },
  46862. enumerable: true,
  46863. configurable: true
  46864. });
  46865. Object.defineProperty(Light.prototype, "includedOnlyMeshes", {
  46866. /**
  46867. * Gets the only meshes impacted by this light.
  46868. */
  46869. get: function () {
  46870. return this._includedOnlyMeshes;
  46871. },
  46872. /**
  46873. * Sets the only meshes impacted by this light.
  46874. */
  46875. set: function (value) {
  46876. this._includedOnlyMeshes = value;
  46877. this._hookArrayForIncludedOnly(value);
  46878. },
  46879. enumerable: true,
  46880. configurable: true
  46881. });
  46882. Object.defineProperty(Light.prototype, "excludedMeshes", {
  46883. /**
  46884. * Gets the meshes not impacted by this light.
  46885. */
  46886. get: function () {
  46887. return this._excludedMeshes;
  46888. },
  46889. /**
  46890. * Sets the meshes not impacted by this light.
  46891. */
  46892. set: function (value) {
  46893. this._excludedMeshes = value;
  46894. this._hookArrayForExcluded(value);
  46895. },
  46896. enumerable: true,
  46897. configurable: true
  46898. });
  46899. Object.defineProperty(Light.prototype, "excludeWithLayerMask", {
  46900. /**
  46901. * Gets the layer id use to find what meshes are not impacted by the light.
  46902. * Inactive if 0
  46903. */
  46904. get: function () {
  46905. return this._excludeWithLayerMask;
  46906. },
  46907. /**
  46908. * Sets the layer id use to find what meshes are not impacted by the light.
  46909. * Inactive if 0
  46910. */
  46911. set: function (value) {
  46912. this._excludeWithLayerMask = value;
  46913. this._resyncMeshes();
  46914. },
  46915. enumerable: true,
  46916. configurable: true
  46917. });
  46918. Object.defineProperty(Light.prototype, "includeOnlyWithLayerMask", {
  46919. /**
  46920. * Gets the layer id use to find what meshes are impacted by the light.
  46921. * Inactive if 0
  46922. */
  46923. get: function () {
  46924. return this._includeOnlyWithLayerMask;
  46925. },
  46926. /**
  46927. * Sets the layer id use to find what meshes are impacted by the light.
  46928. * Inactive if 0
  46929. */
  46930. set: function (value) {
  46931. this._includeOnlyWithLayerMask = value;
  46932. this._resyncMeshes();
  46933. },
  46934. enumerable: true,
  46935. configurable: true
  46936. });
  46937. Object.defineProperty(Light.prototype, "lightmapMode", {
  46938. /**
  46939. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  46940. */
  46941. get: function () {
  46942. return this._lightmapMode;
  46943. },
  46944. /**
  46945. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  46946. */
  46947. set: function (value) {
  46948. if (this._lightmapMode === value) {
  46949. return;
  46950. }
  46951. this._lightmapMode = value;
  46952. this._markMeshesAsLightDirty();
  46953. },
  46954. enumerable: true,
  46955. configurable: true
  46956. });
  46957. /**
  46958. * Returns the string "Light".
  46959. * @returns the class name
  46960. */
  46961. Light.prototype.getClassName = function () {
  46962. return "Light";
  46963. };
  46964. /**
  46965. * Converts the light information to a readable string for debug purpose.
  46966. * @param fullDetails Supports for multiple levels of logging within scene loading
  46967. * @returns the human readable light info
  46968. */
  46969. Light.prototype.toString = function (fullDetails) {
  46970. var ret = "Name: " + this.name;
  46971. ret += ", type: " + (["Point", "Directional", "Spot", "Hemispheric"])[this.getTypeID()];
  46972. if (this.animations) {
  46973. for (var i = 0; i < this.animations.length; i++) {
  46974. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  46975. }
  46976. }
  46977. if (fullDetails) {
  46978. }
  46979. return ret;
  46980. };
  46981. /** @hidden */
  46982. Light.prototype._syncParentEnabledState = function () {
  46983. _super.prototype._syncParentEnabledState.call(this);
  46984. this._resyncMeshes();
  46985. };
  46986. /**
  46987. * Set the enabled state of this node.
  46988. * @param value - the new enabled state
  46989. */
  46990. Light.prototype.setEnabled = function (value) {
  46991. _super.prototype.setEnabled.call(this, value);
  46992. this._resyncMeshes();
  46993. };
  46994. /**
  46995. * Returns the Light associated shadow generator if any.
  46996. * @return the associated shadow generator.
  46997. */
  46998. Light.prototype.getShadowGenerator = function () {
  46999. return this._shadowGenerator;
  47000. };
  47001. /**
  47002. * Returns a Vector3, the absolute light position in the World.
  47003. * @returns the world space position of the light
  47004. */
  47005. Light.prototype.getAbsolutePosition = function () {
  47006. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47007. };
  47008. /**
  47009. * Specifies if the light will affect the passed mesh.
  47010. * @param mesh The mesh to test against the light
  47011. * @return true the mesh is affected otherwise, false.
  47012. */
  47013. Light.prototype.canAffectMesh = function (mesh) {
  47014. if (!mesh) {
  47015. return true;
  47016. }
  47017. if (this.includedOnlyMeshes && this.includedOnlyMeshes.length > 0 && this.includedOnlyMeshes.indexOf(mesh) === -1) {
  47018. return false;
  47019. }
  47020. if (this.excludedMeshes && this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {
  47021. return false;
  47022. }
  47023. if (this.includeOnlyWithLayerMask !== 0 && (this.includeOnlyWithLayerMask & mesh.layerMask) === 0) {
  47024. return false;
  47025. }
  47026. if (this.excludeWithLayerMask !== 0 && this.excludeWithLayerMask & mesh.layerMask) {
  47027. return false;
  47028. }
  47029. return true;
  47030. };
  47031. /**
  47032. * Sort function to order lights for rendering.
  47033. * @param a First Light object to compare to second.
  47034. * @param b Second Light object to compare first.
  47035. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  47036. */
  47037. Light.CompareLightsPriority = function (a, b) {
  47038. //shadow-casting lights have priority over non-shadow-casting lights
  47039. //the renderPrioirty is a secondary sort criterion
  47040. if (a.shadowEnabled !== b.shadowEnabled) {
  47041. return (b.shadowEnabled ? 1 : 0) - (a.shadowEnabled ? 1 : 0);
  47042. }
  47043. return b.renderPriority - a.renderPriority;
  47044. };
  47045. /**
  47046. * Releases resources associated with this node.
  47047. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47048. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47049. */
  47050. Light.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  47051. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  47052. if (this._shadowGenerator) {
  47053. this._shadowGenerator.dispose();
  47054. this._shadowGenerator = null;
  47055. }
  47056. // Animations
  47057. this.getScene().stopAnimation(this);
  47058. // Remove from meshes
  47059. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  47060. var mesh = _a[_i];
  47061. mesh._removeLightSource(this);
  47062. }
  47063. this._uniformBuffer.dispose();
  47064. // Remove from scene
  47065. this.getScene().removeLight(this);
  47066. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  47067. };
  47068. /**
  47069. * Returns the light type ID (integer).
  47070. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47071. */
  47072. Light.prototype.getTypeID = function () {
  47073. return 0;
  47074. };
  47075. /**
  47076. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  47077. * @returns the scaled intensity in intensity mode unit
  47078. */
  47079. Light.prototype.getScaledIntensity = function () {
  47080. return this._photometricScale * this.intensity;
  47081. };
  47082. /**
  47083. * Returns a new Light object, named "name", from the current one.
  47084. * @param name The name of the cloned light
  47085. * @returns the new created light
  47086. */
  47087. Light.prototype.clone = function (name) {
  47088. var constructor = Light.GetConstructorFromName(this.getTypeID(), name, this.getScene());
  47089. if (!constructor) {
  47090. return null;
  47091. }
  47092. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(constructor, this);
  47093. };
  47094. /**
  47095. * Serializes the current light into a Serialization object.
  47096. * @returns the serialized object.
  47097. */
  47098. Light.prototype.serialize = function () {
  47099. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  47100. // Type
  47101. serializationObject.type = this.getTypeID();
  47102. // Parent
  47103. if (this.parent) {
  47104. serializationObject.parentId = this.parent.id;
  47105. }
  47106. // Inclusion / exclusions
  47107. if (this.excludedMeshes.length > 0) {
  47108. serializationObject.excludedMeshesIds = [];
  47109. this.excludedMeshes.forEach(function (mesh) {
  47110. serializationObject.excludedMeshesIds.push(mesh.id);
  47111. });
  47112. }
  47113. if (this.includedOnlyMeshes.length > 0) {
  47114. serializationObject.includedOnlyMeshesIds = [];
  47115. this.includedOnlyMeshes.forEach(function (mesh) {
  47116. serializationObject.includedOnlyMeshesIds.push(mesh.id);
  47117. });
  47118. }
  47119. // Animations
  47120. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  47121. serializationObject.ranges = this.serializeAnimationRanges();
  47122. return serializationObject;
  47123. };
  47124. /**
  47125. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  47126. * This new light is named "name" and added to the passed scene.
  47127. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  47128. * @param name The friendly name of the light
  47129. * @param scene The scene the new light will belong to
  47130. * @returns the constructor function
  47131. */
  47132. Light.GetConstructorFromName = function (type, name, scene) {
  47133. var constructorFunc = _node__WEBPACK_IMPORTED_MODULE_3__["Node"].Construct("Light_Type_" + type, name, scene);
  47134. if (constructorFunc) {
  47135. return constructorFunc;
  47136. }
  47137. // Default to no light for none present once.
  47138. return null;
  47139. };
  47140. /**
  47141. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  47142. * @param parsedLight The JSON representation of the light
  47143. * @param scene The scene to create the parsed light in
  47144. * @returns the created light after parsing
  47145. */
  47146. Light.Parse = function (parsedLight, scene) {
  47147. var constructor = Light.GetConstructorFromName(parsedLight.type, parsedLight.name, scene);
  47148. if (!constructor) {
  47149. return null;
  47150. }
  47151. var light = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(constructor, parsedLight, scene);
  47152. // Inclusion / exclusions
  47153. if (parsedLight.excludedMeshesIds) {
  47154. light._excludedMeshesIds = parsedLight.excludedMeshesIds;
  47155. }
  47156. if (parsedLight.includedOnlyMeshesIds) {
  47157. light._includedOnlyMeshesIds = parsedLight.includedOnlyMeshesIds;
  47158. }
  47159. // Parent
  47160. if (parsedLight.parentId) {
  47161. light._waitingParentId = parsedLight.parentId;
  47162. }
  47163. // Animations
  47164. if (parsedLight.animations) {
  47165. for (var animationIndex = 0; animationIndex < parsedLight.animations.length; animationIndex++) {
  47166. var parsedAnimation = parsedLight.animations[animationIndex];
  47167. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].GetClass("BABYLON.Animation");
  47168. if (internalClass) {
  47169. light.animations.push(internalClass.Parse(parsedAnimation));
  47170. }
  47171. }
  47172. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].ParseAnimationRanges(light, parsedLight, scene);
  47173. }
  47174. if (parsedLight.autoAnimate) {
  47175. scene.beginAnimation(light, parsedLight.autoAnimateFrom, parsedLight.autoAnimateTo, parsedLight.autoAnimateLoop, parsedLight.autoAnimateSpeed || 1.0);
  47176. }
  47177. return light;
  47178. };
  47179. Light.prototype._hookArrayForExcluded = function (array) {
  47180. var _this = this;
  47181. var oldPush = array.push;
  47182. array.push = function () {
  47183. var items = [];
  47184. for (var _i = 0; _i < arguments.length; _i++) {
  47185. items[_i] = arguments[_i];
  47186. }
  47187. var result = oldPush.apply(array, items);
  47188. for (var _a = 0, items_1 = items; _a < items_1.length; _a++) {
  47189. var item = items_1[_a];
  47190. item._resyncLighSource(_this);
  47191. }
  47192. return result;
  47193. };
  47194. var oldSplice = array.splice;
  47195. array.splice = function (index, deleteCount) {
  47196. var deleted = oldSplice.apply(array, [index, deleteCount]);
  47197. for (var _i = 0, deleted_1 = deleted; _i < deleted_1.length; _i++) {
  47198. var item = deleted_1[_i];
  47199. item._resyncLighSource(_this);
  47200. }
  47201. return deleted;
  47202. };
  47203. for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
  47204. var item = array_1[_i];
  47205. item._resyncLighSource(this);
  47206. }
  47207. };
  47208. Light.prototype._hookArrayForIncludedOnly = function (array) {
  47209. var _this = this;
  47210. var oldPush = array.push;
  47211. array.push = function () {
  47212. var items = [];
  47213. for (var _i = 0; _i < arguments.length; _i++) {
  47214. items[_i] = arguments[_i];
  47215. }
  47216. var result = oldPush.apply(array, items);
  47217. _this._resyncMeshes();
  47218. return result;
  47219. };
  47220. var oldSplice = array.splice;
  47221. array.splice = function (index, deleteCount) {
  47222. var deleted = oldSplice.apply(array, [index, deleteCount]);
  47223. _this._resyncMeshes();
  47224. return deleted;
  47225. };
  47226. this._resyncMeshes();
  47227. };
  47228. Light.prototype._resyncMeshes = function () {
  47229. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  47230. var mesh = _a[_i];
  47231. mesh._resyncLighSource(this);
  47232. }
  47233. };
  47234. /**
  47235. * Forces the meshes to update their light related information in their rendering used effects
  47236. * @hidden Internal Use Only
  47237. */
  47238. Light.prototype._markMeshesAsLightDirty = function () {
  47239. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  47240. var mesh = _a[_i];
  47241. if (mesh._lightSources.indexOf(this) !== -1) {
  47242. mesh._markSubMeshesAsLightDirty();
  47243. }
  47244. }
  47245. };
  47246. /**
  47247. * Recomputes the cached photometric scale if needed.
  47248. */
  47249. Light.prototype._computePhotometricScale = function () {
  47250. this._photometricScale = this._getPhotometricScale();
  47251. this.getScene().resetCachedMaterial();
  47252. };
  47253. /**
  47254. * Returns the Photometric Scale according to the light type and intensity mode.
  47255. */
  47256. Light.prototype._getPhotometricScale = function () {
  47257. var photometricScale = 0.0;
  47258. var lightTypeID = this.getTypeID();
  47259. //get photometric mode
  47260. var photometricMode = this.intensityMode;
  47261. if (photometricMode === Light.INTENSITYMODE_AUTOMATIC) {
  47262. if (lightTypeID === Light.LIGHTTYPEID_DIRECTIONALLIGHT) {
  47263. photometricMode = Light.INTENSITYMODE_ILLUMINANCE;
  47264. }
  47265. else {
  47266. photometricMode = Light.INTENSITYMODE_LUMINOUSINTENSITY;
  47267. }
  47268. }
  47269. //compute photometric scale
  47270. switch (lightTypeID) {
  47271. case Light.LIGHTTYPEID_POINTLIGHT:
  47272. case Light.LIGHTTYPEID_SPOTLIGHT:
  47273. switch (photometricMode) {
  47274. case Light.INTENSITYMODE_LUMINOUSPOWER:
  47275. photometricScale = 1.0 / (4.0 * Math.PI);
  47276. break;
  47277. case Light.INTENSITYMODE_LUMINOUSINTENSITY:
  47278. photometricScale = 1.0;
  47279. break;
  47280. case Light.INTENSITYMODE_LUMINANCE:
  47281. photometricScale = this.radius * this.radius;
  47282. break;
  47283. }
  47284. break;
  47285. case Light.LIGHTTYPEID_DIRECTIONALLIGHT:
  47286. switch (photometricMode) {
  47287. case Light.INTENSITYMODE_ILLUMINANCE:
  47288. photometricScale = 1.0;
  47289. break;
  47290. case Light.INTENSITYMODE_LUMINANCE:
  47291. // When radius (and therefore solid angle) is non-zero a directional lights brightness can be specified via central (peak) luminance.
  47292. // For a directional light the 'radius' defines the angular radius (in radians) rather than world-space radius (e.g. in metres).
  47293. var apexAngleRadians = this.radius;
  47294. // Impose a minimum light angular size to avoid the light becoming an infinitely small angular light source (i.e. a dirac delta function).
  47295. apexAngleRadians = Math.max(apexAngleRadians, 0.001);
  47296. var solidAngle = 2.0 * Math.PI * (1.0 - Math.cos(apexAngleRadians));
  47297. photometricScale = solidAngle;
  47298. break;
  47299. }
  47300. break;
  47301. case Light.LIGHTTYPEID_HEMISPHERICLIGHT:
  47302. // No fall off in hemisperic light.
  47303. photometricScale = 1.0;
  47304. break;
  47305. }
  47306. return photometricScale;
  47307. };
  47308. /**
  47309. * Reorder the light in the scene according to their defined priority.
  47310. * @hidden Internal Use Only
  47311. */
  47312. Light.prototype._reorderLightsInScene = function () {
  47313. var scene = this.getScene();
  47314. if (this._renderPriority != 0) {
  47315. scene.requireLightSorting = true;
  47316. }
  47317. this.getScene().sortLightsByPriority();
  47318. };
  47319. /**
  47320. * Falloff Default: light is falling off following the material specification:
  47321. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  47322. */
  47323. Light.FALLOFF_DEFAULT = 0;
  47324. /**
  47325. * Falloff Physical: light is falling off following the inverse squared distance law.
  47326. */
  47327. Light.FALLOFF_PHYSICAL = 1;
  47328. /**
  47329. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  47330. * to enhance interoperability with other engines.
  47331. */
  47332. Light.FALLOFF_GLTF = 2;
  47333. /**
  47334. * Falloff Standard: light is falling off like in the standard material
  47335. * to enhance interoperability with other materials.
  47336. */
  47337. Light.FALLOFF_STANDARD = 3;
  47338. //lightmapMode Consts
  47339. /**
  47340. * If every light affecting the material is in this lightmapMode,
  47341. * material.lightmapTexture adds or multiplies
  47342. * (depends on material.useLightmapAsShadowmap)
  47343. * after every other light calculations.
  47344. */
  47345. Light.LIGHTMAP_DEFAULT = 0;
  47346. /**
  47347. * material.lightmapTexture as only diffuse lighting from this light
  47348. * adds only specular lighting from this light
  47349. * adds dynamic shadows
  47350. */
  47351. Light.LIGHTMAP_SPECULAR = 1;
  47352. /**
  47353. * material.lightmapTexture as only lighting
  47354. * no light calculation from this light
  47355. * only adds dynamic shadows from this light
  47356. */
  47357. Light.LIGHTMAP_SHADOWSONLY = 2;
  47358. // Intensity Mode Consts
  47359. /**
  47360. * Each light type uses the default quantity according to its type:
  47361. * point/spot lights use luminous intensity
  47362. * directional lights use illuminance
  47363. */
  47364. Light.INTENSITYMODE_AUTOMATIC = 0;
  47365. /**
  47366. * lumen (lm)
  47367. */
  47368. Light.INTENSITYMODE_LUMINOUSPOWER = 1;
  47369. /**
  47370. * candela (lm/sr)
  47371. */
  47372. Light.INTENSITYMODE_LUMINOUSINTENSITY = 2;
  47373. /**
  47374. * lux (lm/m^2)
  47375. */
  47376. Light.INTENSITYMODE_ILLUMINANCE = 3;
  47377. /**
  47378. * nit (cd/m^2)
  47379. */
  47380. Light.INTENSITYMODE_LUMINANCE = 4;
  47381. // Light types ids const.
  47382. /**
  47383. * Light type const id of the point light.
  47384. */
  47385. Light.LIGHTTYPEID_POINTLIGHT = 0;
  47386. /**
  47387. * Light type const id of the directional light.
  47388. */
  47389. Light.LIGHTTYPEID_DIRECTIONALLIGHT = 1;
  47390. /**
  47391. * Light type const id of the spot light.
  47392. */
  47393. Light.LIGHTTYPEID_SPOTLIGHT = 2;
  47394. /**
  47395. * Light type const id of the hemispheric light.
  47396. */
  47397. Light.LIGHTTYPEID_HEMISPHERICLIGHT = 3;
  47398. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47399. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  47400. ], Light.prototype, "diffuse", void 0);
  47401. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47402. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  47403. ], Light.prototype, "specular", void 0);
  47404. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47405. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47406. ], Light.prototype, "falloffType", void 0);
  47407. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47408. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47409. ], Light.prototype, "intensity", void 0);
  47410. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47411. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47412. ], Light.prototype, "range", null);
  47413. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47414. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47415. ], Light.prototype, "intensityMode", null);
  47416. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47417. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47418. ], Light.prototype, "radius", null);
  47419. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47420. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47421. ], Light.prototype, "_renderPriority", void 0);
  47422. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47423. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_reorderLightsInScene")
  47424. ], Light.prototype, "renderPriority", void 0);
  47425. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47426. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("shadowEnabled")
  47427. ], Light.prototype, "_shadowEnabled", void 0);
  47428. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47429. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("excludeWithLayerMask")
  47430. ], Light.prototype, "_excludeWithLayerMask", void 0);
  47431. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47432. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("includeOnlyWithLayerMask")
  47433. ], Light.prototype, "_includeOnlyWithLayerMask", void 0);
  47434. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47435. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("lightmapMode")
  47436. ], Light.prototype, "_lightmapMode", void 0);
  47437. return Light;
  47438. }(_node__WEBPACK_IMPORTED_MODULE_3__["Node"]));
  47439. /***/ }),
  47440. /***/ "./Lights/pointLight.ts":
  47441. /*!******************************!*\
  47442. !*** ./Lights/pointLight.ts ***!
  47443. \******************************/
  47444. /*! exports provided: PointLight */
  47445. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47446. "use strict";
  47447. __webpack_require__.r(__webpack_exports__);
  47448. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return PointLight; });
  47449. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  47450. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  47451. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  47452. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  47453. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  47454. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  47455. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_0", function (name, scene) {
  47456. return function () { return new PointLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  47457. });
  47458. /**
  47459. * A point light is a light defined by an unique point in world space.
  47460. * The light is emitted in every direction from this point.
  47461. * A good example of a point light is a standard light bulb.
  47462. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47463. */
  47464. var PointLight = /** @class */ (function (_super) {
  47465. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointLight, _super);
  47466. /**
  47467. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  47468. * A PointLight emits the light in every direction.
  47469. * It can cast shadows.
  47470. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  47471. * ```javascript
  47472. * var pointLight = new PointLight("pl", camera.position, scene);
  47473. * ```
  47474. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47475. * @param name The light friendly name
  47476. * @param position The position of the point light in the scene
  47477. * @param scene The scene the lights belongs to
  47478. */
  47479. function PointLight(name, position, scene) {
  47480. var _this = _super.call(this, name, scene) || this;
  47481. _this._shadowAngle = Math.PI / 2;
  47482. _this.position = position;
  47483. return _this;
  47484. }
  47485. Object.defineProperty(PointLight.prototype, "shadowAngle", {
  47486. /**
  47487. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47488. * This specifies what angle the shadow will use to be created.
  47489. *
  47490. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47491. */
  47492. get: function () {
  47493. return this._shadowAngle;
  47494. },
  47495. /**
  47496. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47497. * This specifies what angle the shadow will use to be created.
  47498. *
  47499. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47500. */
  47501. set: function (value) {
  47502. this._shadowAngle = value;
  47503. this.forceProjectionMatrixCompute();
  47504. },
  47505. enumerable: true,
  47506. configurable: true
  47507. });
  47508. Object.defineProperty(PointLight.prototype, "direction", {
  47509. /**
  47510. * Gets the direction if it has been set.
  47511. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47512. */
  47513. get: function () {
  47514. return this._direction;
  47515. },
  47516. /**
  47517. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47518. */
  47519. set: function (value) {
  47520. var previousNeedCube = this.needCube();
  47521. this._direction = value;
  47522. if (this.needCube() !== previousNeedCube && this._shadowGenerator) {
  47523. this._shadowGenerator.recreateShadowMap();
  47524. }
  47525. },
  47526. enumerable: true,
  47527. configurable: true
  47528. });
  47529. /**
  47530. * Returns the string "PointLight"
  47531. * @returns the class name
  47532. */
  47533. PointLight.prototype.getClassName = function () {
  47534. return "PointLight";
  47535. };
  47536. /**
  47537. * Returns the integer 0.
  47538. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47539. */
  47540. PointLight.prototype.getTypeID = function () {
  47541. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_POINTLIGHT;
  47542. };
  47543. /**
  47544. * Specifies wether or not the shadowmap should be a cube texture.
  47545. * @returns true if the shadowmap needs to be a cube texture.
  47546. */
  47547. PointLight.prototype.needCube = function () {
  47548. return !this.direction;
  47549. };
  47550. /**
  47551. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  47552. * @param faceIndex The index of the face we are computed the direction to generate shadow
  47553. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  47554. */
  47555. PointLight.prototype.getShadowDirection = function (faceIndex) {
  47556. if (this.direction) {
  47557. return _super.prototype.getShadowDirection.call(this, faceIndex);
  47558. }
  47559. else {
  47560. switch (faceIndex) {
  47561. case 0:
  47562. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1.0, 0.0, 0.0);
  47563. case 1:
  47564. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](-1.0, 0.0, 0.0);
  47565. case 2:
  47566. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, -1.0, 0.0);
  47567. case 3:
  47568. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 1.0, 0.0);
  47569. case 4:
  47570. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 0.0, 1.0);
  47571. case 5:
  47572. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 0.0, -1.0);
  47573. }
  47574. }
  47575. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47576. };
  47577. /**
  47578. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  47579. * - fov = PI / 2
  47580. * - aspect ratio : 1.0
  47581. * - z-near and far equal to the active camera minZ and maxZ.
  47582. * Returns the PointLight.
  47583. */
  47584. PointLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  47585. var activeCamera = this.getScene().activeCamera;
  47586. if (!activeCamera) {
  47587. return;
  47588. }
  47589. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].PerspectiveFovLHToRef(this.shadowAngle, 1.0, this.getDepthMinZ(activeCamera), this.getDepthMaxZ(activeCamera), matrix);
  47590. };
  47591. PointLight.prototype._buildUniformLayout = function () {
  47592. this._uniformBuffer.addUniform("vLightData", 4);
  47593. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  47594. this._uniformBuffer.addUniform("vLightSpecular", 3);
  47595. this._uniformBuffer.addUniform("vLightFalloff", 4);
  47596. this._uniformBuffer.addUniform("shadowsInfo", 3);
  47597. this._uniformBuffer.addUniform("depthValues", 2);
  47598. this._uniformBuffer.create();
  47599. };
  47600. /**
  47601. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  47602. * @param effect The effect to update
  47603. * @param lightIndex The index of the light in the effect to update
  47604. * @returns The point light
  47605. */
  47606. PointLight.prototype.transferToEffect = function (effect, lightIndex) {
  47607. if (this.computeTransformedInformation()) {
  47608. this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, 0.0, lightIndex);
  47609. }
  47610. else {
  47611. this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, 0, lightIndex);
  47612. }
  47613. this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, 0, 0, lightIndex);
  47614. return this;
  47615. };
  47616. /**
  47617. * Prepares the list of defines specific to the light type.
  47618. * @param defines the list of defines
  47619. * @param lightIndex defines the index of the light for the effect
  47620. */
  47621. PointLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  47622. defines["POINTLIGHT" + lightIndex] = true;
  47623. };
  47624. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47625. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47626. ], PointLight.prototype, "shadowAngle", null);
  47627. return PointLight;
  47628. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  47629. /***/ }),
  47630. /***/ "./Lights/shadowLight.ts":
  47631. /*!*******************************!*\
  47632. !*** ./Lights/shadowLight.ts ***!
  47633. \*******************************/
  47634. /*! exports provided: ShadowLight */
  47635. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47636. "use strict";
  47637. __webpack_require__.r(__webpack_exports__);
  47638. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return ShadowLight; });
  47639. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  47640. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  47641. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  47642. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  47643. /**
  47644. * Base implementation IShadowLight
  47645. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  47646. */
  47647. var ShadowLight = /** @class */ (function (_super) {
  47648. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShadowLight, _super);
  47649. function ShadowLight() {
  47650. var _this = _super !== null && _super.apply(this, arguments) || this;
  47651. _this._needProjectionMatrixCompute = true;
  47652. return _this;
  47653. }
  47654. ShadowLight.prototype._setPosition = function (value) {
  47655. this._position = value;
  47656. };
  47657. Object.defineProperty(ShadowLight.prototype, "position", {
  47658. /**
  47659. * Sets the position the shadow will be casted from. Also use as the light position for both
  47660. * point and spot lights.
  47661. */
  47662. get: function () {
  47663. return this._position;
  47664. },
  47665. /**
  47666. * Sets the position the shadow will be casted from. Also use as the light position for both
  47667. * point and spot lights.
  47668. */
  47669. set: function (value) {
  47670. this._setPosition(value);
  47671. },
  47672. enumerable: true,
  47673. configurable: true
  47674. });
  47675. ShadowLight.prototype._setDirection = function (value) {
  47676. this._direction = value;
  47677. };
  47678. Object.defineProperty(ShadowLight.prototype, "direction", {
  47679. /**
  47680. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  47681. * Also use as the light direction on spot and directional lights.
  47682. */
  47683. get: function () {
  47684. return this._direction;
  47685. },
  47686. /**
  47687. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  47688. * Also use as the light direction on spot and directional lights.
  47689. */
  47690. set: function (value) {
  47691. this._setDirection(value);
  47692. },
  47693. enumerable: true,
  47694. configurable: true
  47695. });
  47696. Object.defineProperty(ShadowLight.prototype, "shadowMinZ", {
  47697. /**
  47698. * Gets the shadow projection clipping minimum z value.
  47699. */
  47700. get: function () {
  47701. return this._shadowMinZ;
  47702. },
  47703. /**
  47704. * Sets the shadow projection clipping minimum z value.
  47705. */
  47706. set: function (value) {
  47707. this._shadowMinZ = value;
  47708. this.forceProjectionMatrixCompute();
  47709. },
  47710. enumerable: true,
  47711. configurable: true
  47712. });
  47713. Object.defineProperty(ShadowLight.prototype, "shadowMaxZ", {
  47714. /**
  47715. * Sets the shadow projection clipping maximum z value.
  47716. */
  47717. get: function () {
  47718. return this._shadowMaxZ;
  47719. },
  47720. /**
  47721. * Gets the shadow projection clipping maximum z value.
  47722. */
  47723. set: function (value) {
  47724. this._shadowMaxZ = value;
  47725. this.forceProjectionMatrixCompute();
  47726. },
  47727. enumerable: true,
  47728. configurable: true
  47729. });
  47730. /**
  47731. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  47732. * @returns true if the information has been computed, false if it does not need to (no parenting)
  47733. */
  47734. ShadowLight.prototype.computeTransformedInformation = function () {
  47735. if (this.parent && this.parent.getWorldMatrix) {
  47736. if (!this.transformedPosition) {
  47737. this.transformedPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47738. }
  47739. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this.transformedPosition);
  47740. // In case the direction is present.
  47741. if (this.direction) {
  47742. if (!this.transformedDirection) {
  47743. this.transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47744. }
  47745. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormalToRef(this.direction, this.parent.getWorldMatrix(), this.transformedDirection);
  47746. }
  47747. return true;
  47748. }
  47749. return false;
  47750. };
  47751. /**
  47752. * Return the depth scale used for the shadow map.
  47753. * @returns the depth scale.
  47754. */
  47755. ShadowLight.prototype.getDepthScale = function () {
  47756. return 50.0;
  47757. };
  47758. /**
  47759. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  47760. * @param faceIndex The index of the face we are computed the direction to generate shadow
  47761. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  47762. */
  47763. ShadowLight.prototype.getShadowDirection = function (faceIndex) {
  47764. return this.transformedDirection ? this.transformedDirection : this.direction;
  47765. };
  47766. /**
  47767. * Returns the ShadowLight absolute position in the World.
  47768. * @returns the position vector in world space
  47769. */
  47770. ShadowLight.prototype.getAbsolutePosition = function () {
  47771. return this.transformedPosition ? this.transformedPosition : this.position;
  47772. };
  47773. /**
  47774. * Sets the ShadowLight direction toward the passed target.
  47775. * @param target The point to target in local space
  47776. * @returns the updated ShadowLight direction
  47777. */
  47778. ShadowLight.prototype.setDirectionToTarget = function (target) {
  47779. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(target.subtract(this.position));
  47780. return this.direction;
  47781. };
  47782. /**
  47783. * Returns the light rotation in euler definition.
  47784. * @returns the x y z rotation in local space.
  47785. */
  47786. ShadowLight.prototype.getRotation = function () {
  47787. this.direction.normalize();
  47788. var xaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(this.direction, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y);
  47789. var yaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(xaxis, this.direction);
  47790. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].RotationFromAxis(xaxis, yaxis, this.direction);
  47791. };
  47792. /**
  47793. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  47794. * @returns true if a cube texture needs to be use
  47795. */
  47796. ShadowLight.prototype.needCube = function () {
  47797. return false;
  47798. };
  47799. /**
  47800. * Detects if the projection matrix requires to be recomputed this frame.
  47801. * @returns true if it requires to be recomputed otherwise, false.
  47802. */
  47803. ShadowLight.prototype.needProjectionMatrixCompute = function () {
  47804. return this._needProjectionMatrixCompute;
  47805. };
  47806. /**
  47807. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  47808. */
  47809. ShadowLight.prototype.forceProjectionMatrixCompute = function () {
  47810. this._needProjectionMatrixCompute = true;
  47811. };
  47812. /** @hidden */
  47813. ShadowLight.prototype._initCache = function () {
  47814. _super.prototype._initCache.call(this);
  47815. this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47816. };
  47817. /** @hidden */
  47818. ShadowLight.prototype._isSynchronized = function () {
  47819. if (!this._cache.position.equals(this.position)) {
  47820. return false;
  47821. }
  47822. return true;
  47823. };
  47824. /**
  47825. * Computes the world matrix of the node
  47826. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  47827. * @returns the world matrix
  47828. */
  47829. ShadowLight.prototype.computeWorldMatrix = function (force) {
  47830. if (!force && this.isSynchronized()) {
  47831. this._currentRenderId = this.getScene().getRenderId();
  47832. return this._worldMatrix;
  47833. }
  47834. this._updateCache();
  47835. this._cache.position.copyFrom(this.position);
  47836. if (!this._worldMatrix) {
  47837. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  47838. }
  47839. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);
  47840. if (this.parent && this.parent.getWorldMatrix) {
  47841. this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);
  47842. this._markSyncedWithParent();
  47843. }
  47844. // Cache the determinant
  47845. this._worldMatrixDeterminant = this._worldMatrix.determinant();
  47846. return this._worldMatrix;
  47847. };
  47848. /**
  47849. * Gets the minZ used for shadow according to both the scene and the light.
  47850. * @param activeCamera The camera we are returning the min for
  47851. * @returns the depth min z
  47852. */
  47853. ShadowLight.prototype.getDepthMinZ = function (activeCamera) {
  47854. return this.shadowMinZ !== undefined ? this.shadowMinZ : activeCamera.minZ;
  47855. };
  47856. /**
  47857. * Gets the maxZ used for shadow according to both the scene and the light.
  47858. * @param activeCamera The camera we are returning the max for
  47859. * @returns the depth max z
  47860. */
  47861. ShadowLight.prototype.getDepthMaxZ = function (activeCamera) {
  47862. return this.shadowMaxZ !== undefined ? this.shadowMaxZ : activeCamera.maxZ;
  47863. };
  47864. /**
  47865. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  47866. * @param matrix The materix to updated with the projection information
  47867. * @param viewMatrix The transform matrix of the light
  47868. * @param renderList The list of mesh to render in the map
  47869. * @returns The current light
  47870. */
  47871. ShadowLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  47872. if (this.customProjectionMatrixBuilder) {
  47873. this.customProjectionMatrixBuilder(viewMatrix, renderList, matrix);
  47874. }
  47875. else {
  47876. this._setDefaultShadowProjectionMatrix(matrix, viewMatrix, renderList);
  47877. }
  47878. return this;
  47879. };
  47880. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47881. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  47882. ], ShadowLight.prototype, "position", null);
  47883. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47884. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  47885. ], ShadowLight.prototype, "direction", null);
  47886. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47887. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47888. ], ShadowLight.prototype, "shadowMinZ", null);
  47889. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47890. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47891. ], ShadowLight.prototype, "shadowMaxZ", null);
  47892. return ShadowLight;
  47893. }(_light__WEBPACK_IMPORTED_MODULE_3__["Light"]));
  47894. /***/ }),
  47895. /***/ "./Lights/spotLight.ts":
  47896. /*!*****************************!*\
  47897. !*** ./Lights/spotLight.ts ***!
  47898. \*****************************/
  47899. /*! exports provided: SpotLight */
  47900. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47901. "use strict";
  47902. __webpack_require__.r(__webpack_exports__);
  47903. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return SpotLight; });
  47904. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  47905. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  47906. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  47907. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  47908. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  47909. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  47910. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_2", function (name, scene) {
  47911. 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); };
  47912. });
  47913. /**
  47914. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47915. * These values define a cone of light starting from the position, emitting toward the direction.
  47916. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47917. * and the exponent defines the speed of the decay of the light with distance (reach).
  47918. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47919. */
  47920. var SpotLight = /** @class */ (function (_super) {
  47921. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SpotLight, _super);
  47922. /**
  47923. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47924. * It can cast shadows.
  47925. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47926. * @param name The light friendly name
  47927. * @param position The position of the spot light in the scene
  47928. * @param direction The direction of the light in the scene
  47929. * @param angle The cone angle of the light in Radians
  47930. * @param exponent The light decay speed with the distance from the emission spot
  47931. * @param scene The scene the lights belongs to
  47932. */
  47933. function SpotLight(name, position, direction, angle, exponent, scene) {
  47934. var _this = _super.call(this, name, scene) || this;
  47935. _this._innerAngle = 0;
  47936. _this._projectionTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  47937. _this._projectionTextureLightNear = 1e-6;
  47938. _this._projectionTextureLightFar = 1000.0;
  47939. _this._projectionTextureUpDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up();
  47940. _this._projectionTextureViewLightDirty = true;
  47941. _this._projectionTextureProjectionLightDirty = true;
  47942. _this._projectionTextureDirty = true;
  47943. _this._projectionTextureViewTargetVector = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47944. _this._projectionTextureViewLightMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  47945. _this._projectionTextureProjectionLightMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  47946. _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);
  47947. _this.position = position;
  47948. _this.direction = direction;
  47949. _this.angle = angle;
  47950. _this.exponent = exponent;
  47951. return _this;
  47952. }
  47953. Object.defineProperty(SpotLight.prototype, "angle", {
  47954. /**
  47955. * Gets the cone angle of the spot light in Radians.
  47956. */
  47957. get: function () {
  47958. return this._angle;
  47959. },
  47960. /**
  47961. * Sets the cone angle of the spot light in Radians.
  47962. */
  47963. set: function (value) {
  47964. this._angle = value;
  47965. this._cosHalfAngle = Math.cos(value * 0.5);
  47966. this._projectionTextureProjectionLightDirty = true;
  47967. this.forceProjectionMatrixCompute();
  47968. this._computeAngleValues();
  47969. },
  47970. enumerable: true,
  47971. configurable: true
  47972. });
  47973. Object.defineProperty(SpotLight.prototype, "innerAngle", {
  47974. /**
  47975. * Only used in gltf falloff mode, this defines the angle where
  47976. * the directional falloff will start before cutting at angle which could be seen
  47977. * as outer angle.
  47978. */
  47979. get: function () {
  47980. return this._innerAngle;
  47981. },
  47982. /**
  47983. * Only used in gltf falloff mode, this defines the angle where
  47984. * the directional falloff will start before cutting at angle which could be seen
  47985. * as outer angle.
  47986. */
  47987. set: function (value) {
  47988. this._innerAngle = value;
  47989. this._computeAngleValues();
  47990. },
  47991. enumerable: true,
  47992. configurable: true
  47993. });
  47994. Object.defineProperty(SpotLight.prototype, "shadowAngleScale", {
  47995. /**
  47996. * Allows scaling the angle of the light for shadow generation only.
  47997. */
  47998. get: function () {
  47999. return this._shadowAngleScale;
  48000. },
  48001. /**
  48002. * Allows scaling the angle of the light for shadow generation only.
  48003. */
  48004. set: function (value) {
  48005. this._shadowAngleScale = value;
  48006. this.forceProjectionMatrixCompute();
  48007. },
  48008. enumerable: true,
  48009. configurable: true
  48010. });
  48011. Object.defineProperty(SpotLight.prototype, "projectionTextureMatrix", {
  48012. /**
  48013. * Allows reading the projecton texture
  48014. */
  48015. get: function () {
  48016. return this._projectionTextureMatrix;
  48017. },
  48018. enumerable: true,
  48019. configurable: true
  48020. });
  48021. Object.defineProperty(SpotLight.prototype, "projectionTextureLightNear", {
  48022. /**
  48023. * Gets the near clip of the Spotlight for texture projection.
  48024. */
  48025. get: function () {
  48026. return this._projectionTextureLightNear;
  48027. },
  48028. /**
  48029. * Sets the near clip of the Spotlight for texture projection.
  48030. */
  48031. set: function (value) {
  48032. this._projectionTextureLightNear = value;
  48033. this._projectionTextureProjectionLightDirty = true;
  48034. },
  48035. enumerable: true,
  48036. configurable: true
  48037. });
  48038. Object.defineProperty(SpotLight.prototype, "projectionTextureLightFar", {
  48039. /**
  48040. * Gets the far clip of the Spotlight for texture projection.
  48041. */
  48042. get: function () {
  48043. return this._projectionTextureLightFar;
  48044. },
  48045. /**
  48046. * Sets the far clip of the Spotlight for texture projection.
  48047. */
  48048. set: function (value) {
  48049. this._projectionTextureLightFar = value;
  48050. this._projectionTextureProjectionLightDirty = true;
  48051. },
  48052. enumerable: true,
  48053. configurable: true
  48054. });
  48055. Object.defineProperty(SpotLight.prototype, "projectionTextureUpDirection", {
  48056. /**
  48057. * Gets the Up vector of the Spotlight for texture projection.
  48058. */
  48059. get: function () {
  48060. return this._projectionTextureUpDirection;
  48061. },
  48062. /**
  48063. * Sets the Up vector of the Spotlight for texture projection.
  48064. */
  48065. set: function (value) {
  48066. this._projectionTextureUpDirection = value;
  48067. this._projectionTextureProjectionLightDirty = true;
  48068. },
  48069. enumerable: true,
  48070. configurable: true
  48071. });
  48072. Object.defineProperty(SpotLight.prototype, "projectionTexture", {
  48073. /**
  48074. * Gets the projection texture of the light.
  48075. */
  48076. get: function () {
  48077. return this._projectionTexture;
  48078. },
  48079. /**
  48080. * Sets the projection texture of the light.
  48081. */
  48082. set: function (value) {
  48083. this._projectionTexture = value;
  48084. this._projectionTextureDirty = true;
  48085. },
  48086. enumerable: true,
  48087. configurable: true
  48088. });
  48089. /**
  48090. * Returns the string "SpotLight".
  48091. * @returns the class name
  48092. */
  48093. SpotLight.prototype.getClassName = function () {
  48094. return "SpotLight";
  48095. };
  48096. /**
  48097. * Returns the integer 2.
  48098. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48099. */
  48100. SpotLight.prototype.getTypeID = function () {
  48101. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_SPOTLIGHT;
  48102. };
  48103. /**
  48104. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48105. */
  48106. SpotLight.prototype._setDirection = function (value) {
  48107. _super.prototype._setDirection.call(this, value);
  48108. this._projectionTextureViewLightDirty = true;
  48109. };
  48110. /**
  48111. * Overrides the position setter to recompute the projection texture view light Matrix.
  48112. */
  48113. SpotLight.prototype._setPosition = function (value) {
  48114. _super.prototype._setPosition.call(this, value);
  48115. this._projectionTextureViewLightDirty = true;
  48116. };
  48117. /**
  48118. * 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.
  48119. * Returns the SpotLight.
  48120. */
  48121. SpotLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  48122. var activeCamera = this.getScene().activeCamera;
  48123. if (!activeCamera) {
  48124. return;
  48125. }
  48126. this._shadowAngleScale = this._shadowAngleScale || 1;
  48127. var angle = this._shadowAngleScale * this._angle;
  48128. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].PerspectiveFovLHToRef(angle, 1.0, this.getDepthMinZ(activeCamera), this.getDepthMaxZ(activeCamera), matrix);
  48129. };
  48130. SpotLight.prototype._computeProjectionTextureViewLightMatrix = function () {
  48131. this._projectionTextureViewLightDirty = false;
  48132. this._projectionTextureDirty = true;
  48133. this.position.addToRef(this.direction, this._projectionTextureViewTargetVector);
  48134. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].LookAtLHToRef(this.position, this._projectionTextureViewTargetVector, this._projectionTextureUpDirection, this._projectionTextureViewLightMatrix);
  48135. };
  48136. SpotLight.prototype._computeProjectionTextureProjectionLightMatrix = function () {
  48137. this._projectionTextureProjectionLightDirty = false;
  48138. this._projectionTextureDirty = true;
  48139. var light_far = this.projectionTextureLightFar;
  48140. var light_near = this.projectionTextureLightNear;
  48141. var P = light_far / (light_far - light_near);
  48142. var Q = -P * light_near;
  48143. var S = 1.0 / Math.tan(this._angle / 2.0);
  48144. var A = 1.0;
  48145. _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);
  48146. };
  48147. /**
  48148. * Main function for light texture projection matrix computing.
  48149. */
  48150. SpotLight.prototype._computeProjectionTextureMatrix = function () {
  48151. this._projectionTextureDirty = false;
  48152. this._projectionTextureViewLightMatrix.multiplyToRef(this._projectionTextureProjectionLightMatrix, this._projectionTextureMatrix);
  48153. this._projectionTextureMatrix.multiplyToRef(this._projectionTextureScalingMatrix, this._projectionTextureMatrix);
  48154. };
  48155. SpotLight.prototype._buildUniformLayout = function () {
  48156. this._uniformBuffer.addUniform("vLightData", 4);
  48157. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  48158. this._uniformBuffer.addUniform("vLightSpecular", 3);
  48159. this._uniformBuffer.addUniform("vLightDirection", 3);
  48160. this._uniformBuffer.addUniform("vLightFalloff", 4);
  48161. this._uniformBuffer.addUniform("shadowsInfo", 3);
  48162. this._uniformBuffer.addUniform("depthValues", 2);
  48163. this._uniformBuffer.create();
  48164. };
  48165. SpotLight.prototype._computeAngleValues = function () {
  48166. this._lightAngleScale = 1.0 / Math.max(0.001, (Math.cos(this._innerAngle * 0.5) - this._cosHalfAngle));
  48167. this._lightAngleOffset = -this._cosHalfAngle * this._lightAngleScale;
  48168. };
  48169. /**
  48170. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48171. * @param effect The effect to update
  48172. * @param lightIndex The index of the light in the effect to update
  48173. * @returns The spot light
  48174. */
  48175. SpotLight.prototype.transferToEffect = function (effect, lightIndex) {
  48176. var normalizeDirection;
  48177. if (this.computeTransformedInformation()) {
  48178. this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, this.exponent, lightIndex);
  48179. normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.transformedDirection);
  48180. }
  48181. else {
  48182. this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, this.exponent, lightIndex);
  48183. normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.direction);
  48184. }
  48185. this._uniformBuffer.updateFloat4("vLightDirection", normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, this._cosHalfAngle, lightIndex);
  48186. this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, this._lightAngleScale, this._lightAngleOffset, lightIndex);
  48187. if (this.projectionTexture && this.projectionTexture.isReady()) {
  48188. if (this._projectionTextureViewLightDirty) {
  48189. this._computeProjectionTextureViewLightMatrix();
  48190. }
  48191. if (this._projectionTextureProjectionLightDirty) {
  48192. this._computeProjectionTextureProjectionLightMatrix();
  48193. }
  48194. if (this._projectionTextureDirty) {
  48195. this._computeProjectionTextureMatrix();
  48196. }
  48197. effect.setMatrix("textureProjectionMatrix" + lightIndex, this._projectionTextureMatrix);
  48198. effect.setTexture("projectionLightSampler" + lightIndex, this.projectionTexture);
  48199. }
  48200. return this;
  48201. };
  48202. /**
  48203. * Disposes the light and the associated resources.
  48204. */
  48205. SpotLight.prototype.dispose = function () {
  48206. _super.prototype.dispose.call(this);
  48207. if (this._projectionTexture) {
  48208. this._projectionTexture.dispose();
  48209. }
  48210. };
  48211. /**
  48212. * Prepares the list of defines specific to the light type.
  48213. * @param defines the list of defines
  48214. * @param lightIndex defines the index of the light for the effect
  48215. */
  48216. SpotLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  48217. defines["SPOTLIGHT" + lightIndex] = true;
  48218. defines["PROJECTEDLIGHTTEXTURE" + lightIndex] = this.projectionTexture ? true : false;
  48219. };
  48220. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48221. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48222. ], SpotLight.prototype, "angle", null);
  48223. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48224. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48225. ], SpotLight.prototype, "innerAngle", null);
  48226. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48227. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48228. ], SpotLight.prototype, "shadowAngleScale", null);
  48229. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48230. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48231. ], SpotLight.prototype, "exponent", void 0);
  48232. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48233. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48234. ], SpotLight.prototype, "projectionTextureLightNear", null);
  48235. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48236. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48237. ], SpotLight.prototype, "projectionTextureLightFar", null);
  48238. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48239. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48240. ], SpotLight.prototype, "projectionTextureUpDirection", null);
  48241. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48242. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("projectedLightTexture")
  48243. ], SpotLight.prototype, "_projectionTexture", void 0);
  48244. return SpotLight;
  48245. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  48246. /***/ }),
  48247. /***/ "./Loading/Plugins/babylonFileLoader.ts":
  48248. /*!**********************************************!*\
  48249. !*** ./Loading/Plugins/babylonFileLoader.ts ***!
  48250. \**********************************************/
  48251. /*! exports provided: _BabylonLoaderRegistered */
  48252. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48253. "use strict";
  48254. __webpack_require__.r(__webpack_exports__);
  48255. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _BabylonLoaderRegistered; });
  48256. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  48257. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  48258. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  48259. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  48260. /* harmony import */ var _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/geometry */ "./Meshes/geometry.ts");
  48261. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/transformNode */ "./Meshes/transformNode.ts");
  48262. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/material */ "./Materials/material.ts");
  48263. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  48264. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  48265. /* harmony import */ var _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/Textures/hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  48266. /* harmony import */ var _Animations_animationGroup__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Animations/animationGroup */ "./Animations/animationGroup.ts");
  48267. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Lights/light */ "./Lights/light.ts");
  48268. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  48269. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  48270. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../abstractScene */ "./abstractScene.ts");
  48271. /* harmony import */ var _assetContainer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../assetContainer */ "./assetContainer.ts");
  48272. /* harmony import */ var _Actions_actionManager__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Actions/actionManager */ "./Actions/actionManager.ts");
  48273. /* harmony import */ var _Bones_skeleton__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Bones/skeleton */ "./Bones/skeleton.ts");
  48274. /* harmony import */ var _Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Morph/morphTargetManager */ "./Morph/morphTargetManager.ts");
  48275. /* harmony import */ var _Physics_Plugins_cannonJSPlugin__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../Physics/Plugins/cannonJSPlugin */ "./Physics/Plugins/cannonJSPlugin.ts");
  48276. /* harmony import */ var _Physics_Plugins_oimoJSPlugin__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Physics/Plugins/oimoJSPlugin */ "./Physics/Plugins/oimoJSPlugin.ts");
  48277. /* harmony import */ var _Probes_reflectionProbe__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Probes/reflectionProbe */ "./Probes/reflectionProbe.ts");
  48278. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  48279. /** @hidden */
  48280. var _BabylonLoaderRegistered = true;
  48281. var parseMaterialById = function (id, parsedData, scene, rootUrl) {
  48282. for (var index = 0, cache = parsedData.materials.length; index < cache; index++) {
  48283. var parsedMaterial = parsedData.materials[index];
  48284. if (parsedMaterial.id === id) {
  48285. return _Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].Parse(parsedMaterial, scene, rootUrl);
  48286. }
  48287. }
  48288. return null;
  48289. };
  48290. var isDescendantOf = function (mesh, names, hierarchyIds) {
  48291. for (var i in names) {
  48292. if (mesh.name === names[i]) {
  48293. hierarchyIds.push(mesh.id);
  48294. return true;
  48295. }
  48296. }
  48297. if (mesh.parentId && hierarchyIds.indexOf(mesh.parentId) !== -1) {
  48298. hierarchyIds.push(mesh.id);
  48299. return true;
  48300. }
  48301. return false;
  48302. };
  48303. var logOperation = function (operation, producer) {
  48304. return operation + " of " + (producer ? producer.file + " from " + producer.name + " version: " + producer.version + ", exporter version: " + producer.exporter_version : "unknown");
  48305. };
  48306. var loadAssetContainer = function (scene, data, rootUrl, onError, addToScene) {
  48307. if (addToScene === void 0) { addToScene = false; }
  48308. var container = new _assetContainer__WEBPACK_IMPORTED_MODULE_15__["AssetContainer"](scene);
  48309. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  48310. // when SceneLoader.debugLogging = true (default), or exception encountered.
  48311. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  48312. // and avoid problems with multiple concurrent .babylon loads.
  48313. var log = "importScene has failed JSON parse";
  48314. try {
  48315. var parsedData = JSON.parse(data);
  48316. log = "";
  48317. var fullDetails = _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel === _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].DETAILED_LOGGING;
  48318. var index;
  48319. var cache;
  48320. // Lights
  48321. if (parsedData.lights !== undefined && parsedData.lights !== null) {
  48322. for (index = 0, cache = parsedData.lights.length; index < cache; index++) {
  48323. var parsedLight = parsedData.lights[index];
  48324. var light = _Lights_light__WEBPACK_IMPORTED_MODULE_11__["Light"].Parse(parsedLight, scene);
  48325. if (light) {
  48326. container.lights.push(light);
  48327. log += (index === 0 ? "\n\tLights:" : "");
  48328. log += "\n\t\t" + light.toString(fullDetails);
  48329. }
  48330. }
  48331. }
  48332. // Reflection probes
  48333. if (parsedData.reflectionProbes !== undefined && parsedData.reflectionProbes !== null) {
  48334. for (index = 0, cache = parsedData.reflectionProbes.length; index < cache; index++) {
  48335. var parsedReflectionProbe = parsedData.reflectionProbes[index];
  48336. var reflectionProbe = _Probes_reflectionProbe__WEBPACK_IMPORTED_MODULE_21__["ReflectionProbe"].Parse(parsedReflectionProbe, scene, rootUrl);
  48337. if (reflectionProbe) {
  48338. container.reflectionProbes.push(reflectionProbe);
  48339. log += (index === 0 ? "\n\tReflection Probes:" : "");
  48340. log += "\n\t\t" + reflectionProbe.toString(fullDetails);
  48341. }
  48342. }
  48343. }
  48344. // Animations
  48345. if (parsedData.animations !== undefined && parsedData.animations !== null) {
  48346. for (index = 0, cache = parsedData.animations.length; index < cache; index++) {
  48347. var parsedAnimation = parsedData.animations[index];
  48348. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_22__["_TypeStore"].GetClass("BABYLON.Animation");
  48349. if (internalClass) {
  48350. var animation = internalClass.Parse(parsedAnimation);
  48351. scene.animations.push(animation);
  48352. container.animations.push(animation);
  48353. log += (index === 0 ? "\n\tAnimations:" : "");
  48354. log += "\n\t\t" + animation.toString(fullDetails);
  48355. }
  48356. }
  48357. }
  48358. // Materials
  48359. if (parsedData.materials !== undefined && parsedData.materials !== null) {
  48360. for (index = 0, cache = parsedData.materials.length; index < cache; index++) {
  48361. var parsedMaterial = parsedData.materials[index];
  48362. var mat = _Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].Parse(parsedMaterial, scene, rootUrl);
  48363. container.materials.push(mat);
  48364. log += (index === 0 ? "\n\tMaterials:" : "");
  48365. log += "\n\t\t" + mat.toString(fullDetails);
  48366. }
  48367. }
  48368. if (parsedData.multiMaterials !== undefined && parsedData.multiMaterials !== null) {
  48369. for (index = 0, cache = parsedData.multiMaterials.length; index < cache; index++) {
  48370. var parsedMultiMaterial = parsedData.multiMaterials[index];
  48371. var mmat = _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__["MultiMaterial"].ParseMultiMaterial(parsedMultiMaterial, scene);
  48372. container.multiMaterials.push(mmat);
  48373. log += (index === 0 ? "\n\tMultiMaterials:" : "");
  48374. log += "\n\t\t" + mmat.toString(fullDetails);
  48375. }
  48376. }
  48377. // Morph targets
  48378. if (parsedData.morphTargetManagers !== undefined && parsedData.morphTargetManagers !== null) {
  48379. for (var _i = 0, _a = parsedData.morphTargetManagers; _i < _a.length; _i++) {
  48380. var managerData = _a[_i];
  48381. container.morphTargetManagers.push(_Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_18__["MorphTargetManager"].Parse(managerData, scene));
  48382. }
  48383. }
  48384. // Skeletons
  48385. if (parsedData.skeletons !== undefined && parsedData.skeletons !== null) {
  48386. for (index = 0, cache = parsedData.skeletons.length; index < cache; index++) {
  48387. var parsedSkeleton = parsedData.skeletons[index];
  48388. var skeleton = _Bones_skeleton__WEBPACK_IMPORTED_MODULE_17__["Skeleton"].Parse(parsedSkeleton, scene);
  48389. container.skeletons.push(skeleton);
  48390. log += (index === 0 ? "\n\tSkeletons:" : "");
  48391. log += "\n\t\t" + skeleton.toString(fullDetails);
  48392. }
  48393. }
  48394. // Geometries
  48395. var geometries = parsedData.geometries;
  48396. if (geometries !== undefined && geometries !== null) {
  48397. var addedGeometry = new Array();
  48398. // VertexData
  48399. var vertexData = geometries.vertexData;
  48400. if (vertexData !== undefined && vertexData !== null) {
  48401. for (index = 0, cache = vertexData.length; index < cache; index++) {
  48402. var parsedVertexData = vertexData[index];
  48403. addedGeometry.push(_Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"].Parse(parsedVertexData, scene, rootUrl));
  48404. }
  48405. }
  48406. addedGeometry.forEach(function (g) {
  48407. if (g) {
  48408. container.geometries.push(g);
  48409. }
  48410. });
  48411. }
  48412. // Transform nodes
  48413. if (parsedData.transformNodes !== undefined && parsedData.transformNodes !== null) {
  48414. for (index = 0, cache = parsedData.transformNodes.length; index < cache; index++) {
  48415. var parsedTransformNode = parsedData.transformNodes[index];
  48416. var node = _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_5__["TransformNode"].Parse(parsedTransformNode, scene, rootUrl);
  48417. container.transformNodes.push(node);
  48418. }
  48419. }
  48420. // Meshes
  48421. if (parsedData.meshes !== undefined && parsedData.meshes !== null) {
  48422. for (index = 0, cache = parsedData.meshes.length; index < cache; index++) {
  48423. var parsedMesh = parsedData.meshes[index];
  48424. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].Parse(parsedMesh, scene, rootUrl);
  48425. container.meshes.push(mesh);
  48426. log += (index === 0 ? "\n\tMeshes:" : "");
  48427. log += "\n\t\t" + mesh.toString(fullDetails);
  48428. }
  48429. }
  48430. // Cameras
  48431. if (parsedData.cameras !== undefined && parsedData.cameras !== null) {
  48432. for (index = 0, cache = parsedData.cameras.length; index < cache; index++) {
  48433. var parsedCamera = parsedData.cameras[index];
  48434. var camera = _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].Parse(parsedCamera, scene);
  48435. container.cameras.push(camera);
  48436. log += (index === 0 ? "\n\tCameras:" : "");
  48437. log += "\n\t\t" + camera.toString(fullDetails);
  48438. }
  48439. }
  48440. // Animation Groups
  48441. if (parsedData.animationGroups !== undefined && parsedData.animationGroups !== null) {
  48442. for (index = 0, cache = parsedData.animationGroups.length; index < cache; index++) {
  48443. var parsedAnimationGroup = parsedData.animationGroups[index];
  48444. var animationGroup = _Animations_animationGroup__WEBPACK_IMPORTED_MODULE_10__["AnimationGroup"].Parse(parsedAnimationGroup, scene);
  48445. container.animationGroups.push(animationGroup);
  48446. log += (index === 0 ? "\n\tAnimationGroups:" : "");
  48447. log += "\n\t\t" + animationGroup.toString(fullDetails);
  48448. }
  48449. }
  48450. // Browsing all the graph to connect the dots
  48451. for (index = 0, cache = scene.cameras.length; index < cache; index++) {
  48452. var camera = scene.cameras[index];
  48453. if (camera._waitingParentId) {
  48454. camera.parent = scene.getLastEntryByID(camera._waitingParentId);
  48455. camera._waitingParentId = null;
  48456. }
  48457. }
  48458. for (index = 0, cache = scene.lights.length; index < cache; index++) {
  48459. var light_1 = scene.lights[index];
  48460. if (light_1 && light_1._waitingParentId) {
  48461. light_1.parent = scene.getLastEntryByID(light_1._waitingParentId);
  48462. light_1._waitingParentId = null;
  48463. }
  48464. }
  48465. // Connect parents & children and parse actions
  48466. for (index = 0, cache = scene.transformNodes.length; index < cache; index++) {
  48467. var transformNode = scene.transformNodes[index];
  48468. if (transformNode._waitingParentId) {
  48469. transformNode.parent = scene.getLastEntryByID(transformNode._waitingParentId);
  48470. transformNode._waitingParentId = null;
  48471. }
  48472. }
  48473. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  48474. var mesh = scene.meshes[index];
  48475. if (mesh._waitingParentId) {
  48476. mesh.parent = scene.getLastEntryByID(mesh._waitingParentId);
  48477. mesh._waitingParentId = null;
  48478. }
  48479. }
  48480. // freeze world matrix application
  48481. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  48482. var currentMesh = scene.meshes[index];
  48483. if (currentMesh._waitingFreezeWorldMatrix) {
  48484. currentMesh.freezeWorldMatrix();
  48485. currentMesh._waitingFreezeWorldMatrix = null;
  48486. }
  48487. else {
  48488. currentMesh.computeWorldMatrix(true);
  48489. }
  48490. }
  48491. // Lights exclusions / inclusions
  48492. for (index = 0, cache = scene.lights.length; index < cache; index++) {
  48493. var light_2 = scene.lights[index];
  48494. // Excluded check
  48495. if (light_2._excludedMeshesIds.length > 0) {
  48496. for (var excludedIndex = 0; excludedIndex < light_2._excludedMeshesIds.length; excludedIndex++) {
  48497. var excludedMesh = scene.getMeshByID(light_2._excludedMeshesIds[excludedIndex]);
  48498. if (excludedMesh) {
  48499. light_2.excludedMeshes.push(excludedMesh);
  48500. }
  48501. }
  48502. light_2._excludedMeshesIds = [];
  48503. }
  48504. // Included check
  48505. if (light_2._includedOnlyMeshesIds.length > 0) {
  48506. for (var includedOnlyIndex = 0; includedOnlyIndex < light_2._includedOnlyMeshesIds.length; includedOnlyIndex++) {
  48507. var includedOnlyMesh = scene.getMeshByID(light_2._includedOnlyMeshesIds[includedOnlyIndex]);
  48508. if (includedOnlyMesh) {
  48509. light_2.includedOnlyMeshes.push(includedOnlyMesh);
  48510. }
  48511. }
  48512. light_2._includedOnlyMeshesIds = [];
  48513. }
  48514. }
  48515. _abstractScene__WEBPACK_IMPORTED_MODULE_14__["AbstractScene"].Parse(parsedData, scene, container, rootUrl);
  48516. // Actions (scene) Done last as it can access other objects.
  48517. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  48518. var mesh = scene.meshes[index];
  48519. if (mesh._waitingActions) {
  48520. _Actions_actionManager__WEBPACK_IMPORTED_MODULE_16__["ActionManager"].Parse(mesh._waitingActions, mesh, scene);
  48521. mesh._waitingActions = null;
  48522. }
  48523. }
  48524. if (parsedData.actions !== undefined && parsedData.actions !== null) {
  48525. _Actions_actionManager__WEBPACK_IMPORTED_MODULE_16__["ActionManager"].Parse(parsedData.actions, null, scene);
  48526. }
  48527. if (!addToScene) {
  48528. container.removeAllFromScene();
  48529. }
  48530. }
  48531. catch (err) {
  48532. var msg = logOperation("loadAssets", parsedData ? parsedData.producer : "Unknown") + log;
  48533. if (onError) {
  48534. onError(msg, err);
  48535. }
  48536. else {
  48537. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  48538. throw err;
  48539. }
  48540. }
  48541. finally {
  48542. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].NO_LOGGING) {
  48543. _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 : ""));
  48544. }
  48545. }
  48546. return container;
  48547. };
  48548. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].RegisterPlugin({
  48549. name: "babylon.js",
  48550. extensions: ".babylon",
  48551. canDirectLoad: function (data) {
  48552. if (data.indexOf("babylon") !== -1) { // We consider that the producer string is filled
  48553. return true;
  48554. }
  48555. return false;
  48556. },
  48557. importMesh: function (meshesNames, scene, data, rootUrl, meshes, particleSystems, skeletons, onError) {
  48558. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  48559. // when SceneLoader.debugLogging = true (default), or exception encountered.
  48560. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  48561. // and avoid problems with multiple concurrent .babylon loads.
  48562. var log = "importMesh has failed JSON parse";
  48563. try {
  48564. var parsedData = JSON.parse(data);
  48565. log = "";
  48566. var fullDetails = _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel === _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].DETAILED_LOGGING;
  48567. if (!meshesNames) {
  48568. meshesNames = null;
  48569. }
  48570. else if (!Array.isArray(meshesNames)) {
  48571. meshesNames = [meshesNames];
  48572. }
  48573. var hierarchyIds = new Array();
  48574. if (parsedData.meshes !== undefined && parsedData.meshes !== null) {
  48575. var loadedSkeletonsIds = [];
  48576. var loadedMaterialsIds = [];
  48577. var index;
  48578. var cache;
  48579. for (index = 0, cache = parsedData.meshes.length; index < cache; index++) {
  48580. var parsedMesh = parsedData.meshes[index];
  48581. if (meshesNames === null || isDescendantOf(parsedMesh, meshesNames, hierarchyIds)) {
  48582. if (meshesNames !== null) {
  48583. // Remove found mesh name from list.
  48584. delete meshesNames[meshesNames.indexOf(parsedMesh.name)];
  48585. }
  48586. //Geometry?
  48587. if (parsedMesh.geometryId !== undefined && parsedMesh.geometryId !== null) {
  48588. //does the file contain geometries?
  48589. if (parsedData.geometries !== undefined && parsedData.geometries !== null) {
  48590. //find the correct geometry and add it to the scene
  48591. var found = false;
  48592. ["boxes", "spheres", "cylinders", "toruses", "grounds", "planes", "torusKnots", "vertexData"].forEach(function (geometryType) {
  48593. if (found === true || !parsedData.geometries[geometryType] || !(Array.isArray(parsedData.geometries[geometryType]))) {
  48594. return;
  48595. }
  48596. else {
  48597. parsedData.geometries[geometryType].forEach(function (parsedGeometryData) {
  48598. if (parsedGeometryData.id === parsedMesh.geometryId) {
  48599. switch (geometryType) {
  48600. case "vertexData":
  48601. _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"].Parse(parsedGeometryData, scene, rootUrl);
  48602. break;
  48603. }
  48604. found = true;
  48605. }
  48606. });
  48607. }
  48608. });
  48609. if (found === false) {
  48610. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Geometry not found for mesh " + parsedMesh.id);
  48611. }
  48612. }
  48613. }
  48614. // Material ?
  48615. if (parsedMesh.materialId) {
  48616. var materialFound = (loadedMaterialsIds.indexOf(parsedMesh.materialId) !== -1);
  48617. if (materialFound === false && parsedData.multiMaterials !== undefined && parsedData.multiMaterials !== null) {
  48618. for (var multimatIndex = 0, multimatCache = parsedData.multiMaterials.length; multimatIndex < multimatCache; multimatIndex++) {
  48619. var parsedMultiMaterial = parsedData.multiMaterials[multimatIndex];
  48620. if (parsedMultiMaterial.id === parsedMesh.materialId) {
  48621. for (var matIndex = 0, matCache = parsedMultiMaterial.materials.length; matIndex < matCache; matIndex++) {
  48622. var subMatId = parsedMultiMaterial.materials[matIndex];
  48623. loadedMaterialsIds.push(subMatId);
  48624. var mat = parseMaterialById(subMatId, parsedData, scene, rootUrl);
  48625. if (mat) {
  48626. log += "\n\tMaterial " + mat.toString(fullDetails);
  48627. }
  48628. }
  48629. loadedMaterialsIds.push(parsedMultiMaterial.id);
  48630. var mmat = _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__["MultiMaterial"].ParseMultiMaterial(parsedMultiMaterial, scene);
  48631. if (mmat) {
  48632. materialFound = true;
  48633. log += "\n\tMulti-Material " + mmat.toString(fullDetails);
  48634. }
  48635. break;
  48636. }
  48637. }
  48638. }
  48639. if (materialFound === false) {
  48640. loadedMaterialsIds.push(parsedMesh.materialId);
  48641. var mat = parseMaterialById(parsedMesh.materialId, parsedData, scene, rootUrl);
  48642. if (!mat) {
  48643. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Material not found for mesh " + parsedMesh.id);
  48644. }
  48645. else {
  48646. log += "\n\tMaterial " + mat.toString(fullDetails);
  48647. }
  48648. }
  48649. }
  48650. // Skeleton ?
  48651. if (parsedMesh.skeletonId > -1 && parsedData.skeletons !== undefined && parsedData.skeletons !== null) {
  48652. var skeletonAlreadyLoaded = (loadedSkeletonsIds.indexOf(parsedMesh.skeletonId) > -1);
  48653. if (skeletonAlreadyLoaded === false) {
  48654. for (var skeletonIndex = 0, skeletonCache = parsedData.skeletons.length; skeletonIndex < skeletonCache; skeletonIndex++) {
  48655. var parsedSkeleton = parsedData.skeletons[skeletonIndex];
  48656. if (parsedSkeleton.id === parsedMesh.skeletonId) {
  48657. var skeleton = _Bones_skeleton__WEBPACK_IMPORTED_MODULE_17__["Skeleton"].Parse(parsedSkeleton, scene);
  48658. skeletons.push(skeleton);
  48659. loadedSkeletonsIds.push(parsedSkeleton.id);
  48660. log += "\n\tSkeleton " + skeleton.toString(fullDetails);
  48661. }
  48662. }
  48663. }
  48664. }
  48665. // Morph targets ?
  48666. if (parsedData.morphTargetManagers !== undefined && parsedData.morphTargetManagers !== null) {
  48667. for (var _i = 0, _a = parsedData.morphTargetManagers; _i < _a.length; _i++) {
  48668. var managerData = _a[_i];
  48669. _Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_18__["MorphTargetManager"].Parse(managerData, scene);
  48670. }
  48671. }
  48672. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].Parse(parsedMesh, scene, rootUrl);
  48673. meshes.push(mesh);
  48674. log += "\n\tMesh " + mesh.toString(fullDetails);
  48675. }
  48676. }
  48677. // Connecting parents
  48678. var currentMesh;
  48679. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  48680. currentMesh = scene.meshes[index];
  48681. if (currentMesh._waitingParentId) {
  48682. currentMesh.parent = scene.getLastEntryByID(currentMesh._waitingParentId);
  48683. currentMesh._waitingParentId = null;
  48684. }
  48685. }
  48686. // freeze and compute world matrix application
  48687. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  48688. currentMesh = scene.meshes[index];
  48689. if (currentMesh._waitingFreezeWorldMatrix) {
  48690. currentMesh.freezeWorldMatrix();
  48691. currentMesh._waitingFreezeWorldMatrix = null;
  48692. }
  48693. else {
  48694. currentMesh.computeWorldMatrix(true);
  48695. }
  48696. }
  48697. }
  48698. // Particles
  48699. if (parsedData.particleSystems !== undefined && parsedData.particleSystems !== null) {
  48700. var parser = _abstractScene__WEBPACK_IMPORTED_MODULE_14__["AbstractScene"].GetIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_12__["SceneComponentConstants"].NAME_PARTICLESYSTEM);
  48701. if (parser) {
  48702. for (index = 0, cache = parsedData.particleSystems.length; index < cache; index++) {
  48703. var parsedParticleSystem = parsedData.particleSystems[index];
  48704. if (hierarchyIds.indexOf(parsedParticleSystem.emitterId) !== -1) {
  48705. particleSystems.push(parser(parsedParticleSystem, scene, rootUrl));
  48706. }
  48707. }
  48708. }
  48709. }
  48710. return true;
  48711. }
  48712. catch (err) {
  48713. var msg = logOperation("importMesh", parsedData ? parsedData.producer : "Unknown") + log;
  48714. if (onError) {
  48715. onError(msg, err);
  48716. }
  48717. else {
  48718. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  48719. throw err;
  48720. }
  48721. }
  48722. finally {
  48723. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].NO_LOGGING) {
  48724. _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 : ""));
  48725. }
  48726. }
  48727. return false;
  48728. },
  48729. load: function (scene, data, rootUrl, onError) {
  48730. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  48731. // when SceneLoader.debugLogging = true (default), or exception encountered.
  48732. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  48733. // and avoid problems with multiple concurrent .babylon loads.
  48734. var log = "importScene has failed JSON parse";
  48735. try {
  48736. var parsedData = JSON.parse(data);
  48737. log = "";
  48738. // Scene
  48739. if (parsedData.useDelayedTextureLoading !== undefined && parsedData.useDelayedTextureLoading !== null) {
  48740. scene.useDelayedTextureLoading = parsedData.useDelayedTextureLoading && !_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].ForceFullSceneLoadingForIncremental;
  48741. }
  48742. if (parsedData.autoClear !== undefined && parsedData.autoClear !== null) {
  48743. scene.autoClear = parsedData.autoClear;
  48744. }
  48745. if (parsedData.clearColor !== undefined && parsedData.clearColor !== null) {
  48746. scene.clearColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"].FromArray(parsedData.clearColor);
  48747. }
  48748. if (parsedData.ambientColor !== undefined && parsedData.ambientColor !== null) {
  48749. scene.ambientColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(parsedData.ambientColor);
  48750. }
  48751. if (parsedData.gravity !== undefined && parsedData.gravity !== null) {
  48752. scene.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedData.gravity);
  48753. }
  48754. // Fog
  48755. if (parsedData.fogMode && parsedData.fogMode !== 0) {
  48756. scene.fogMode = parsedData.fogMode;
  48757. scene.fogColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(parsedData.fogColor);
  48758. scene.fogStart = parsedData.fogStart;
  48759. scene.fogEnd = parsedData.fogEnd;
  48760. scene.fogDensity = parsedData.fogDensity;
  48761. log += "\tFog mode for scene: ";
  48762. switch (scene.fogMode) {
  48763. // getters not compiling, so using hardcoded
  48764. case 1:
  48765. log += "exp\n";
  48766. break;
  48767. case 2:
  48768. log += "exp2\n";
  48769. break;
  48770. case 3:
  48771. log += "linear\n";
  48772. break;
  48773. }
  48774. }
  48775. //Physics
  48776. if (parsedData.physicsEnabled) {
  48777. var physicsPlugin;
  48778. if (parsedData.physicsEngine === "cannon") {
  48779. physicsPlugin = new _Physics_Plugins_cannonJSPlugin__WEBPACK_IMPORTED_MODULE_19__["CannonJSPlugin"]();
  48780. }
  48781. else if (parsedData.physicsEngine === "oimo") {
  48782. physicsPlugin = new _Physics_Plugins_oimoJSPlugin__WEBPACK_IMPORTED_MODULE_20__["OimoJSPlugin"]();
  48783. }
  48784. log = "\tPhysics engine " + (parsedData.physicsEngine ? parsedData.physicsEngine : "oimo") + " enabled\n";
  48785. //else - default engine, which is currently oimo
  48786. var physicsGravity = parsedData.physicsGravity ? _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedData.physicsGravity) : null;
  48787. scene.enablePhysics(physicsGravity, physicsPlugin);
  48788. }
  48789. // Metadata
  48790. if (parsedData.metadata !== undefined && parsedData.metadata !== null) {
  48791. scene.metadata = parsedData.metadata;
  48792. }
  48793. //collisions, if defined. otherwise, default is true
  48794. if (parsedData.collisionsEnabled !== undefined && parsedData.collisionsEnabled !== null) {
  48795. scene.collisionsEnabled = parsedData.collisionsEnabled;
  48796. }
  48797. var container = loadAssetContainer(scene, data, rootUrl, onError, true);
  48798. if (!container) {
  48799. return false;
  48800. }
  48801. if (parsedData.autoAnimate) {
  48802. scene.beginAnimation(scene, parsedData.autoAnimateFrom, parsedData.autoAnimateTo, parsedData.autoAnimateLoop, parsedData.autoAnimateSpeed || 1.0);
  48803. }
  48804. if (parsedData.activeCameraID !== undefined && parsedData.activeCameraID !== null) {
  48805. scene.setActiveCameraByID(parsedData.activeCameraID);
  48806. }
  48807. // Environment texture
  48808. if (parsedData.environmentTexture !== undefined && parsedData.environmentTexture !== null) {
  48809. // PBR needed for both HDR texture (gamma space) & a sky box
  48810. var isPBR = parsedData.isPBR !== undefined ? parsedData.isPBR : true;
  48811. if (parsedData.environmentTextureType && parsedData.environmentTextureType === "BABYLON.HDRCubeTexture") {
  48812. var hdrSize = (parsedData.environmentTextureSize) ? parsedData.environmentTextureSize : 128;
  48813. var hdrTexture = new _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_9__["HDRCubeTexture"](rootUrl + parsedData.environmentTexture, scene, hdrSize, true, !isPBR);
  48814. if (parsedData.environmentTextureRotationY) {
  48815. hdrTexture.rotationY = parsedData.environmentTextureRotationY;
  48816. }
  48817. scene.environmentTexture = hdrTexture;
  48818. }
  48819. else {
  48820. var cubeTexture = _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"].CreateFromPrefilteredData(rootUrl + parsedData.environmentTexture, scene);
  48821. if (parsedData.environmentTextureRotationY) {
  48822. cubeTexture.rotationY = parsedData.environmentTextureRotationY;
  48823. }
  48824. scene.environmentTexture = cubeTexture;
  48825. }
  48826. if (parsedData.createDefaultSkybox === true) {
  48827. var skyboxScale = (scene.activeCamera !== undefined && scene.activeCamera !== null) ? (scene.activeCamera.maxZ - scene.activeCamera.minZ) / 2 : 1000;
  48828. var skyboxBlurLevel = parsedData.skyboxBlurLevel || 0;
  48829. scene.createDefaultSkybox(scene.environmentTexture, isPBR, skyboxScale, skyboxBlurLevel);
  48830. }
  48831. }
  48832. // Finish
  48833. return true;
  48834. }
  48835. catch (err) {
  48836. var msg = logOperation("importScene", parsedData ? parsedData.producer : "Unknown") + log;
  48837. if (onError) {
  48838. onError(msg, err);
  48839. }
  48840. else {
  48841. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  48842. throw err;
  48843. }
  48844. }
  48845. finally {
  48846. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].NO_LOGGING) {
  48847. _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 : ""));
  48848. }
  48849. }
  48850. return false;
  48851. },
  48852. loadAssetContainer: function (scene, data, rootUrl, onError) {
  48853. var container = loadAssetContainer(scene, data, rootUrl, onError);
  48854. return container;
  48855. }
  48856. });
  48857. /***/ }),
  48858. /***/ "./Loading/Plugins/index.ts":
  48859. /*!**********************************!*\
  48860. !*** ./Loading/Plugins/index.ts ***!
  48861. \**********************************/
  48862. /*! exports provided: _BabylonLoaderRegistered */
  48863. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48864. "use strict";
  48865. __webpack_require__.r(__webpack_exports__);
  48866. /* harmony import */ var _babylonFileLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./babylonFileLoader */ "./Loading/Plugins/babylonFileLoader.ts");
  48867. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _babylonFileLoader__WEBPACK_IMPORTED_MODULE_0__["_BabylonLoaderRegistered"]; });
  48868. /***/ }),
  48869. /***/ "./Loading/index.ts":
  48870. /*!**************************!*\
  48871. !*** ./Loading/index.ts ***!
  48872. \**************************/
  48873. /*! exports provided: DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, _BabylonLoaderRegistered */
  48874. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48875. "use strict";
  48876. __webpack_require__.r(__webpack_exports__);
  48877. /* harmony import */ var _loadingScreen__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./loadingScreen */ "./Loading/loadingScreen.ts");
  48878. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _loadingScreen__WEBPACK_IMPORTED_MODULE_0__["DefaultLoadingScreen"]; });
  48879. /* harmony import */ var _Plugins_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Plugins/index */ "./Loading/Plugins/index.ts");
  48880. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_1__["_BabylonLoaderRegistered"]; });
  48881. /* harmony import */ var _sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sceneLoader */ "./Loading/sceneLoader.ts");
  48882. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoaderProgressEvent"]; });
  48883. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"]; });
  48884. /* harmony import */ var _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  48885. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_3__["SceneLoaderFlags"]; });
  48886. /***/ }),
  48887. /***/ "./Loading/loadingScreen.ts":
  48888. /*!**********************************!*\
  48889. !*** ./Loading/loadingScreen.ts ***!
  48890. \**********************************/
  48891. /*! exports provided: DefaultLoadingScreen */
  48892. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48893. "use strict";
  48894. __webpack_require__.r(__webpack_exports__);
  48895. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return DefaultLoadingScreen; });
  48896. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  48897. /**
  48898. * Class used for the default loading screen
  48899. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  48900. */
  48901. var DefaultLoadingScreen = /** @class */ (function () {
  48902. /**
  48903. * Creates a new default loading screen
  48904. * @param _renderingCanvas defines the canvas used to render the scene
  48905. * @param _loadingText defines the default text to display
  48906. * @param _loadingDivBackgroundColor defines the default background color
  48907. */
  48908. function DefaultLoadingScreen(_renderingCanvas, _loadingText, _loadingDivBackgroundColor) {
  48909. if (_loadingText === void 0) { _loadingText = ""; }
  48910. if (_loadingDivBackgroundColor === void 0) { _loadingDivBackgroundColor = "black"; }
  48911. var _this = this;
  48912. this._renderingCanvas = _renderingCanvas;
  48913. this._loadingText = _loadingText;
  48914. this._loadingDivBackgroundColor = _loadingDivBackgroundColor;
  48915. // Resize
  48916. this._resizeLoadingUI = function () {
  48917. var canvasRect = _this._renderingCanvas.getBoundingClientRect();
  48918. var canvasPositioning = window.getComputedStyle(_this._renderingCanvas).position;
  48919. if (!_this._loadingDiv) {
  48920. return;
  48921. }
  48922. _this._loadingDiv.style.position = (canvasPositioning === "fixed") ? "fixed" : "absolute";
  48923. _this._loadingDiv.style.left = canvasRect.left + "px";
  48924. _this._loadingDiv.style.top = canvasRect.top + "px";
  48925. _this._loadingDiv.style.width = canvasRect.width + "px";
  48926. _this._loadingDiv.style.height = canvasRect.height + "px";
  48927. };
  48928. }
  48929. /**
  48930. * Function called to display the loading screen
  48931. */
  48932. DefaultLoadingScreen.prototype.displayLoadingUI = function () {
  48933. if (this._loadingDiv) {
  48934. // Do not add a loading screen if there is already one
  48935. return;
  48936. }
  48937. this._loadingDiv = document.createElement("div");
  48938. this._loadingDiv.id = "babylonjsLoadingDiv";
  48939. this._loadingDiv.style.opacity = "0";
  48940. this._loadingDiv.style.transition = "opacity 1.5s ease";
  48941. this._loadingDiv.style.pointerEvents = "none";
  48942. // Loading text
  48943. this._loadingTextDiv = document.createElement("div");
  48944. this._loadingTextDiv.style.position = "absolute";
  48945. this._loadingTextDiv.style.left = "0";
  48946. this._loadingTextDiv.style.top = "50%";
  48947. this._loadingTextDiv.style.marginTop = "80px";
  48948. this._loadingTextDiv.style.width = "100%";
  48949. this._loadingTextDiv.style.height = "20px";
  48950. this._loadingTextDiv.style.fontFamily = "Arial";
  48951. this._loadingTextDiv.style.fontSize = "14px";
  48952. this._loadingTextDiv.style.color = "white";
  48953. this._loadingTextDiv.style.textAlign = "center";
  48954. this._loadingTextDiv.innerHTML = "Loading";
  48955. this._loadingDiv.appendChild(this._loadingTextDiv);
  48956. //set the predefined text
  48957. this._loadingTextDiv.innerHTML = this._loadingText;
  48958. // Generating keyframes
  48959. var style = document.createElement('style');
  48960. style.type = 'text/css';
  48961. 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 }";
  48962. style.innerHTML = keyFrames;
  48963. document.getElementsByTagName('head')[0].appendChild(style);
  48964. // Loading img
  48965. var imgBack = new Image();
  48966. 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";
  48967. imgBack.style.position = "absolute";
  48968. imgBack.style.left = "50%";
  48969. imgBack.style.top = "50%";
  48970. imgBack.style.marginLeft = "-60px";
  48971. imgBack.style.marginTop = "-60px";
  48972. imgBack.style.animation = "spin1 2s infinite ease-in-out";
  48973. imgBack.style.webkitAnimation = "spin1 2s infinite ease-in-out";
  48974. imgBack.style.transformOrigin = "50% 50%";
  48975. imgBack.style.webkitTransformOrigin = "50% 50%";
  48976. this._loadingDiv.appendChild(imgBack);
  48977. this._resizeLoadingUI();
  48978. window.addEventListener("resize", this._resizeLoadingUI);
  48979. this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor;
  48980. document.body.appendChild(this._loadingDiv);
  48981. this._loadingDiv.style.opacity = "1";
  48982. };
  48983. /**
  48984. * Function called to hide the loading screen
  48985. */
  48986. DefaultLoadingScreen.prototype.hideLoadingUI = function () {
  48987. var _this = this;
  48988. if (!this._loadingDiv) {
  48989. return;
  48990. }
  48991. var onTransitionEnd = function () {
  48992. if (!_this._loadingDiv) {
  48993. return;
  48994. }
  48995. if (_this._loadingDiv.parentElement) {
  48996. _this._loadingDiv.parentElement.removeChild(_this._loadingDiv);
  48997. }
  48998. window.removeEventListener("resize", _this._resizeLoadingUI);
  48999. _this._loadingDiv = null;
  49000. };
  49001. this._loadingDiv.style.opacity = "0";
  49002. this._loadingDiv.addEventListener("transitionend", onTransitionEnd);
  49003. };
  49004. Object.defineProperty(DefaultLoadingScreen.prototype, "loadingUIText", {
  49005. get: function () {
  49006. return this._loadingText;
  49007. },
  49008. /**
  49009. * Gets or sets the text to display while loading
  49010. */
  49011. set: function (text) {
  49012. this._loadingText = text;
  49013. if (this._loadingTextDiv) {
  49014. this._loadingTextDiv.innerHTML = this._loadingText;
  49015. }
  49016. },
  49017. enumerable: true,
  49018. configurable: true
  49019. });
  49020. Object.defineProperty(DefaultLoadingScreen.prototype, "loadingUIBackgroundColor", {
  49021. /**
  49022. * Gets or sets the color to use for the background
  49023. */
  49024. get: function () {
  49025. return this._loadingDivBackgroundColor;
  49026. },
  49027. set: function (color) {
  49028. this._loadingDivBackgroundColor = color;
  49029. if (!this._loadingDiv) {
  49030. return;
  49031. }
  49032. this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor;
  49033. },
  49034. enumerable: true,
  49035. configurable: true
  49036. });
  49037. return DefaultLoadingScreen;
  49038. }());
  49039. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].DefaultLoadingScreenFactory = function (canvas) { return new DefaultLoadingScreen(canvas); };
  49040. /***/ }),
  49041. /***/ "./Loading/sceneLoader.ts":
  49042. /*!********************************!*\
  49043. !*** ./Loading/sceneLoader.ts ***!
  49044. \********************************/
  49045. /*! exports provided: SceneLoaderProgressEvent, SceneLoader */
  49046. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49047. "use strict";
  49048. __webpack_require__.r(__webpack_exports__);
  49049. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return SceneLoaderProgressEvent; });
  49050. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return SceneLoader; });
  49051. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  49052. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  49053. /* harmony import */ var _Misc_filesInputStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/filesInputStore */ "./Misc/filesInputStore.ts");
  49054. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  49055. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  49056. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  49057. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  49058. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  49059. /* harmony import */ var _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  49060. /**
  49061. * Class used to represent data loading progression
  49062. */
  49063. var SceneLoaderProgressEvent = /** @class */ (function () {
  49064. /**
  49065. * Create a new progress event
  49066. * @param lengthComputable defines if data length to load can be evaluated
  49067. * @param loaded defines the loaded data length
  49068. * @param total defines the data length to load
  49069. */
  49070. function SceneLoaderProgressEvent(
  49071. /** defines if data length to load can be evaluated */
  49072. lengthComputable,
  49073. /** defines the loaded data length */
  49074. loaded,
  49075. /** defines the data length to load */
  49076. total) {
  49077. this.lengthComputable = lengthComputable;
  49078. this.loaded = loaded;
  49079. this.total = total;
  49080. }
  49081. /**
  49082. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  49083. * @param event defines the source event
  49084. * @returns a new SceneLoaderProgressEvent
  49085. */
  49086. SceneLoaderProgressEvent.FromProgressEvent = function (event) {
  49087. return new SceneLoaderProgressEvent(event.lengthComputable, event.loaded, event.total);
  49088. };
  49089. return SceneLoaderProgressEvent;
  49090. }());
  49091. /**
  49092. * Class used to load scene from various file formats using registered plugins
  49093. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  49094. */
  49095. var SceneLoader = /** @class */ (function () {
  49096. function SceneLoader() {
  49097. }
  49098. Object.defineProperty(SceneLoader, "ForceFullSceneLoadingForIncremental", {
  49099. /**
  49100. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  49101. */
  49102. get: function () {
  49103. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental;
  49104. },
  49105. set: function (value) {
  49106. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental = value;
  49107. },
  49108. enumerable: true,
  49109. configurable: true
  49110. });
  49111. Object.defineProperty(SceneLoader, "ShowLoadingScreen", {
  49112. /**
  49113. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  49114. */
  49115. get: function () {
  49116. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ShowLoadingScreen;
  49117. },
  49118. set: function (value) {
  49119. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ShowLoadingScreen = value;
  49120. },
  49121. enumerable: true,
  49122. configurable: true
  49123. });
  49124. Object.defineProperty(SceneLoader, "loggingLevel", {
  49125. /**
  49126. * Defines the current logging level (while loading the scene)
  49127. * @ignorenaming
  49128. */
  49129. get: function () {
  49130. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].loggingLevel;
  49131. },
  49132. set: function (value) {
  49133. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].loggingLevel = value;
  49134. },
  49135. enumerable: true,
  49136. configurable: true
  49137. });
  49138. Object.defineProperty(SceneLoader, "CleanBoneMatrixWeights", {
  49139. /**
  49140. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  49141. */
  49142. get: function () {
  49143. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].CleanBoneMatrixWeights;
  49144. },
  49145. set: function (value) {
  49146. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].CleanBoneMatrixWeights = value;
  49147. },
  49148. enumerable: true,
  49149. configurable: true
  49150. });
  49151. SceneLoader._getDefaultPlugin = function () {
  49152. return SceneLoader._registeredPlugins[".babylon"];
  49153. };
  49154. SceneLoader._getPluginForExtension = function (extension) {
  49155. var registeredPlugin = SceneLoader._registeredPlugins[extension];
  49156. if (registeredPlugin) {
  49157. return registeredPlugin;
  49158. }
  49159. _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");
  49160. return SceneLoader._getDefaultPlugin();
  49161. };
  49162. SceneLoader._getPluginForDirectLoad = function (data) {
  49163. for (var extension in SceneLoader._registeredPlugins) {
  49164. var plugin = SceneLoader._registeredPlugins[extension].plugin;
  49165. if (plugin.canDirectLoad && plugin.canDirectLoad(data)) {
  49166. return SceneLoader._registeredPlugins[extension];
  49167. }
  49168. }
  49169. return SceneLoader._getDefaultPlugin();
  49170. };
  49171. SceneLoader._getPluginForFilename = function (sceneFilename) {
  49172. var queryStringPosition = sceneFilename.indexOf("?");
  49173. if (queryStringPosition !== -1) {
  49174. sceneFilename = sceneFilename.substring(0, queryStringPosition);
  49175. }
  49176. var dotPosition = sceneFilename.lastIndexOf(".");
  49177. var extension = sceneFilename.substring(dotPosition, sceneFilename.length).toLowerCase();
  49178. return SceneLoader._getPluginForExtension(extension);
  49179. };
  49180. // use babylon file loader directly if sceneFilename is prefixed with "data:"
  49181. SceneLoader._getDirectLoad = function (sceneFilename) {
  49182. if (sceneFilename.substr(0, 5) === "data:") {
  49183. return sceneFilename.substr(5);
  49184. }
  49185. return null;
  49186. };
  49187. SceneLoader._loadData = function (fileInfo, scene, onSuccess, onProgress, onError, onDispose, pluginExtension) {
  49188. var directLoad = SceneLoader._getDirectLoad(fileInfo.name);
  49189. var registeredPlugin = pluginExtension ? SceneLoader._getPluginForExtension(pluginExtension) : (directLoad ? SceneLoader._getPluginForDirectLoad(fileInfo.name) : SceneLoader._getPluginForFilename(fileInfo.name));
  49190. var plugin;
  49191. if (registeredPlugin.plugin.createPlugin) {
  49192. plugin = registeredPlugin.plugin.createPlugin();
  49193. }
  49194. else {
  49195. plugin = registeredPlugin.plugin;
  49196. }
  49197. if (!plugin) {
  49198. 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.";
  49199. }
  49200. var useArrayBuffer = registeredPlugin.isBinary;
  49201. var offlineProvider;
  49202. SceneLoader.OnPluginActivatedObservable.notifyObservers(plugin);
  49203. var dataCallback = function (data, responseURL) {
  49204. if (scene.isDisposed) {
  49205. onError("Scene has been disposed");
  49206. return;
  49207. }
  49208. scene.offlineProvider = offlineProvider;
  49209. onSuccess(plugin, data, responseURL);
  49210. };
  49211. var request = null;
  49212. var pluginDisposed = false;
  49213. var onDisposeObservable = plugin.onDisposeObservable;
  49214. if (onDisposeObservable) {
  49215. onDisposeObservable.add(function () {
  49216. pluginDisposed = true;
  49217. if (request) {
  49218. request.abort();
  49219. request = null;
  49220. }
  49221. onDispose();
  49222. });
  49223. }
  49224. var manifestChecked = function () {
  49225. if (pluginDisposed) {
  49226. return;
  49227. }
  49228. request = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(fileInfo.url, dataCallback, onProgress ? function (event) {
  49229. onProgress(SceneLoaderProgressEvent.FromProgressEvent(event));
  49230. } : undefined, offlineProvider, useArrayBuffer, function (request, exception) {
  49231. onError("Failed to load scene." + (exception ? " " + exception.message : ""), exception);
  49232. });
  49233. };
  49234. if (directLoad) {
  49235. dataCallback(directLoad);
  49236. return plugin;
  49237. }
  49238. var file = fileInfo.file || _Misc_filesInputStore__WEBPACK_IMPORTED_MODULE_2__["FilesInputStore"].FilesToLoad[fileInfo.name.toLowerCase()];
  49239. if (fileInfo.rootUrl.indexOf("file:") === -1 || (fileInfo.rootUrl.indexOf("file:") !== -1 && !file)) {
  49240. var engine = scene.getEngine();
  49241. var canUseOfflineSupport = engine.enableOfflineSupport;
  49242. if (canUseOfflineSupport) {
  49243. // Also check for exceptions
  49244. var exceptionFound = false;
  49245. for (var _i = 0, _a = scene.disableOfflineSupportExceptionRules; _i < _a.length; _i++) {
  49246. var regex = _a[_i];
  49247. if (regex.test(fileInfo.url)) {
  49248. exceptionFound = true;
  49249. break;
  49250. }
  49251. }
  49252. canUseOfflineSupport = !exceptionFound;
  49253. }
  49254. if (canUseOfflineSupport && _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].OfflineProviderFactory) {
  49255. // Checking if a manifest file has been set for this scene and if offline mode has been requested
  49256. offlineProvider = _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].OfflineProviderFactory(fileInfo.url, manifestChecked, engine.disableManifestCheck);
  49257. }
  49258. else {
  49259. manifestChecked();
  49260. }
  49261. }
  49262. // Loading file from disk via input file or drag'n'drop
  49263. else {
  49264. if (file) {
  49265. request = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].ReadFile(file, dataCallback, onProgress, useArrayBuffer);
  49266. }
  49267. else {
  49268. onError("Unable to find file named " + fileInfo.name);
  49269. }
  49270. }
  49271. return plugin;
  49272. };
  49273. SceneLoader._getFileInfo = function (rootUrl, sceneFilename) {
  49274. var url;
  49275. var name;
  49276. var file = null;
  49277. if (!sceneFilename) {
  49278. url = rootUrl;
  49279. name = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFilename(rootUrl);
  49280. rootUrl = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFolderPath(rootUrl);
  49281. }
  49282. else if (sceneFilename.name) {
  49283. var sceneFile = sceneFilename;
  49284. url = rootUrl + sceneFile.name;
  49285. name = sceneFile.name;
  49286. file = sceneFile;
  49287. }
  49288. else {
  49289. var filename = sceneFilename;
  49290. if (filename.substr(0, 1) === "/") {
  49291. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Wrong sceneFilename parameter");
  49292. return null;
  49293. }
  49294. url = rootUrl + filename;
  49295. name = filename;
  49296. }
  49297. return {
  49298. url: url,
  49299. rootUrl: rootUrl,
  49300. name: name,
  49301. file: file
  49302. };
  49303. };
  49304. // Public functions
  49305. /**
  49306. * Gets a plugin that can load the given extension
  49307. * @param extension defines the extension to load
  49308. * @returns a plugin or null if none works
  49309. */
  49310. SceneLoader.GetPluginForExtension = function (extension) {
  49311. return SceneLoader._getPluginForExtension(extension).plugin;
  49312. };
  49313. /**
  49314. * Gets a boolean indicating that the given extension can be loaded
  49315. * @param extension defines the extension to load
  49316. * @returns true if the extension is supported
  49317. */
  49318. SceneLoader.IsPluginForExtensionAvailable = function (extension) {
  49319. return !!SceneLoader._registeredPlugins[extension];
  49320. };
  49321. /**
  49322. * Adds a new plugin to the list of registered plugins
  49323. * @param plugin defines the plugin to add
  49324. */
  49325. SceneLoader.RegisterPlugin = function (plugin) {
  49326. if (typeof plugin.extensions === "string") {
  49327. var extension = plugin.extensions;
  49328. SceneLoader._registeredPlugins[extension.toLowerCase()] = {
  49329. plugin: plugin,
  49330. isBinary: false
  49331. };
  49332. }
  49333. else {
  49334. var extensions = plugin.extensions;
  49335. Object.keys(extensions).forEach(function (extension) {
  49336. SceneLoader._registeredPlugins[extension.toLowerCase()] = {
  49337. plugin: plugin,
  49338. isBinary: extensions[extension].isBinary
  49339. };
  49340. });
  49341. }
  49342. };
  49343. /**
  49344. * Import meshes into a scene
  49345. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49346. * @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)
  49347. * @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)
  49348. * @param scene the instance of BABYLON.Scene to append to
  49349. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  49350. * @param onProgress a callback with a progress event for each file being loaded
  49351. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49352. * @param pluginExtension the extension used to determine the plugin
  49353. * @returns The loaded plugin
  49354. */
  49355. SceneLoader.ImportMesh = function (meshNames, rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  49356. if (sceneFilename === void 0) { sceneFilename = ""; }
  49357. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  49358. if (onSuccess === void 0) { onSuccess = null; }
  49359. if (onProgress === void 0) { onProgress = null; }
  49360. if (onError === void 0) { onError = null; }
  49361. if (pluginExtension === void 0) { pluginExtension = null; }
  49362. if (!scene) {
  49363. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to import mesh to");
  49364. return null;
  49365. }
  49366. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  49367. if (!fileInfo) {
  49368. return null;
  49369. }
  49370. var loadingToken = {};
  49371. scene._addPendingData(loadingToken);
  49372. var disposeHandler = function () {
  49373. scene._removePendingData(loadingToken);
  49374. };
  49375. var errorHandler = function (message, exception) {
  49376. var errorMessage = "Unable to import meshes from " + fileInfo.url + ": " + message;
  49377. if (onError) {
  49378. onError(scene, errorMessage, exception);
  49379. }
  49380. else {
  49381. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  49382. // should the exception be thrown?
  49383. }
  49384. disposeHandler();
  49385. };
  49386. var progressHandler = onProgress ? function (event) {
  49387. try {
  49388. onProgress(event);
  49389. }
  49390. catch (e) {
  49391. errorHandler("Error in onProgress callback", e);
  49392. }
  49393. } : undefined;
  49394. var successHandler = function (meshes, particleSystems, skeletons, animationGroups) {
  49395. scene.importedMeshesFiles.push(fileInfo.url);
  49396. if (onSuccess) {
  49397. try {
  49398. onSuccess(meshes, particleSystems, skeletons, animationGroups);
  49399. }
  49400. catch (e) {
  49401. errorHandler("Error in onSuccess callback", e);
  49402. }
  49403. }
  49404. scene._removePendingData(loadingToken);
  49405. };
  49406. return SceneLoader._loadData(fileInfo, scene, function (plugin, data, responseURL) {
  49407. if (plugin.rewriteRootURL) {
  49408. fileInfo.rootUrl = plugin.rewriteRootURL(fileInfo.rootUrl, responseURL);
  49409. }
  49410. if (plugin.importMesh) {
  49411. var syncedPlugin = plugin;
  49412. var meshes = new Array();
  49413. var particleSystems = new Array();
  49414. var skeletons = new Array();
  49415. if (!syncedPlugin.importMesh(meshNames, scene, data, fileInfo.rootUrl, meshes, particleSystems, skeletons, errorHandler)) {
  49416. return;
  49417. }
  49418. scene.loadingPluginName = plugin.name;
  49419. successHandler(meshes, particleSystems, skeletons, []);
  49420. }
  49421. else {
  49422. var asyncedPlugin = plugin;
  49423. asyncedPlugin.importMeshAsync(meshNames, scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function (result) {
  49424. scene.loadingPluginName = plugin.name;
  49425. successHandler(result.meshes, result.particleSystems, result.skeletons, result.animationGroups);
  49426. }).catch(function (error) {
  49427. errorHandler(error.message, error);
  49428. });
  49429. }
  49430. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  49431. };
  49432. /**
  49433. * Import meshes into a scene
  49434. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49435. * @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)
  49436. * @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)
  49437. * @param scene the instance of BABYLON.Scene to append to
  49438. * @param onProgress a callback with a progress event for each file being loaded
  49439. * @param pluginExtension the extension used to determine the plugin
  49440. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  49441. */
  49442. SceneLoader.ImportMeshAsync = function (meshNames, rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  49443. if (sceneFilename === void 0) { sceneFilename = ""; }
  49444. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  49445. if (onProgress === void 0) { onProgress = null; }
  49446. if (pluginExtension === void 0) { pluginExtension = null; }
  49447. return new Promise(function (resolve, reject) {
  49448. SceneLoader.ImportMesh(meshNames, rootUrl, sceneFilename, scene, function (meshes, particleSystems, skeletons, animationGroups) {
  49449. resolve({
  49450. meshes: meshes,
  49451. particleSystems: particleSystems,
  49452. skeletons: skeletons,
  49453. animationGroups: animationGroups
  49454. });
  49455. }, onProgress, function (scene, message, exception) {
  49456. reject(exception || new Error(message));
  49457. }, pluginExtension);
  49458. });
  49459. };
  49460. /**
  49461. * Load a scene
  49462. * @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)
  49463. * @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)
  49464. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49465. * @param onSuccess a callback with the scene when import succeeds
  49466. * @param onProgress a callback with a progress event for each file being loaded
  49467. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49468. * @param pluginExtension the extension used to determine the plugin
  49469. * @returns The loaded plugin
  49470. */
  49471. SceneLoader.Load = function (rootUrl, sceneFilename, engine, onSuccess, onProgress, onError, pluginExtension) {
  49472. if (sceneFilename === void 0) { sceneFilename = ""; }
  49473. if (engine === void 0) { engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedEngine; }
  49474. if (onSuccess === void 0) { onSuccess = null; }
  49475. if (onProgress === void 0) { onProgress = null; }
  49476. if (onError === void 0) { onError = null; }
  49477. if (pluginExtension === void 0) { pluginExtension = null; }
  49478. if (!engine) {
  49479. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("No engine available");
  49480. return null;
  49481. }
  49482. return SceneLoader.Append(rootUrl, sceneFilename, new _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"](engine), onSuccess, onProgress, onError, pluginExtension);
  49483. };
  49484. /**
  49485. * Load a scene
  49486. * @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)
  49487. * @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)
  49488. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49489. * @param onProgress a callback with a progress event for each file being loaded
  49490. * @param pluginExtension the extension used to determine the plugin
  49491. * @returns The loaded scene
  49492. */
  49493. SceneLoader.LoadAsync = function (rootUrl, sceneFilename, engine, onProgress, pluginExtension) {
  49494. if (sceneFilename === void 0) { sceneFilename = ""; }
  49495. if (engine === void 0) { engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedEngine; }
  49496. if (onProgress === void 0) { onProgress = null; }
  49497. if (pluginExtension === void 0) { pluginExtension = null; }
  49498. return new Promise(function (resolve, reject) {
  49499. SceneLoader.Load(rootUrl, sceneFilename, engine, function (scene) {
  49500. resolve(scene);
  49501. }, onProgress, function (scene, message, exception) {
  49502. reject(exception || new Error(message));
  49503. }, pluginExtension);
  49504. });
  49505. };
  49506. /**
  49507. * Append a scene
  49508. * @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)
  49509. * @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)
  49510. * @param scene is the instance of BABYLON.Scene to append to
  49511. * @param onSuccess a callback with the scene when import succeeds
  49512. * @param onProgress a callback with a progress event for each file being loaded
  49513. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49514. * @param pluginExtension the extension used to determine the plugin
  49515. * @returns The loaded plugin
  49516. */
  49517. SceneLoader.Append = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  49518. if (sceneFilename === void 0) { sceneFilename = ""; }
  49519. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  49520. if (onSuccess === void 0) { onSuccess = null; }
  49521. if (onProgress === void 0) { onProgress = null; }
  49522. if (onError === void 0) { onError = null; }
  49523. if (pluginExtension === void 0) { pluginExtension = null; }
  49524. if (!scene) {
  49525. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to append to");
  49526. return null;
  49527. }
  49528. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  49529. if (!fileInfo) {
  49530. return null;
  49531. }
  49532. if (SceneLoader.ShowLoadingScreen) {
  49533. scene.getEngine().displayLoadingUI();
  49534. }
  49535. var loadingToken = {};
  49536. scene._addPendingData(loadingToken);
  49537. var disposeHandler = function () {
  49538. scene._removePendingData(loadingToken);
  49539. scene.getEngine().hideLoadingUI();
  49540. };
  49541. var errorHandler = function (message, exception) {
  49542. var errorMessage = "Unable to load from " + fileInfo.url + (message ? ": " + message : "");
  49543. if (onError) {
  49544. onError(scene, errorMessage, exception);
  49545. }
  49546. else {
  49547. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  49548. // should the exception be thrown?
  49549. }
  49550. disposeHandler();
  49551. };
  49552. var progressHandler = onProgress ? function (event) {
  49553. try {
  49554. onProgress(event);
  49555. }
  49556. catch (e) {
  49557. errorHandler("Error in onProgress callback", e);
  49558. }
  49559. } : undefined;
  49560. var successHandler = function () {
  49561. if (onSuccess) {
  49562. try {
  49563. onSuccess(scene);
  49564. }
  49565. catch (e) {
  49566. errorHandler("Error in onSuccess callback", e);
  49567. }
  49568. }
  49569. scene._removePendingData(loadingToken);
  49570. };
  49571. return SceneLoader._loadData(fileInfo, scene, function (plugin, data) {
  49572. if (plugin.load) {
  49573. var syncedPlugin = plugin;
  49574. if (!syncedPlugin.load(scene, data, fileInfo.rootUrl, errorHandler)) {
  49575. return;
  49576. }
  49577. scene.loadingPluginName = plugin.name;
  49578. successHandler();
  49579. }
  49580. else {
  49581. var asyncedPlugin = plugin;
  49582. asyncedPlugin.loadAsync(scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function () {
  49583. scene.loadingPluginName = plugin.name;
  49584. successHandler();
  49585. }).catch(function (error) {
  49586. errorHandler(error.message, error);
  49587. });
  49588. }
  49589. if (SceneLoader.ShowLoadingScreen) {
  49590. scene.executeWhenReady(function () {
  49591. scene.getEngine().hideLoadingUI();
  49592. });
  49593. }
  49594. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  49595. };
  49596. /**
  49597. * Append a scene
  49598. * @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)
  49599. * @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)
  49600. * @param scene is the instance of BABYLON.Scene to append to
  49601. * @param onProgress a callback with a progress event for each file being loaded
  49602. * @param pluginExtension the extension used to determine the plugin
  49603. * @returns The given scene
  49604. */
  49605. SceneLoader.AppendAsync = function (rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  49606. if (sceneFilename === void 0) { sceneFilename = ""; }
  49607. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  49608. if (onProgress === void 0) { onProgress = null; }
  49609. if (pluginExtension === void 0) { pluginExtension = null; }
  49610. return new Promise(function (resolve, reject) {
  49611. SceneLoader.Append(rootUrl, sceneFilename, scene, function (scene) {
  49612. resolve(scene);
  49613. }, onProgress, function (scene, message, exception) {
  49614. reject(exception || new Error(message));
  49615. }, pluginExtension);
  49616. });
  49617. };
  49618. /**
  49619. * Load a scene into an asset container
  49620. * @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)
  49621. * @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)
  49622. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49623. * @param onSuccess a callback with the scene when import succeeds
  49624. * @param onProgress a callback with a progress event for each file being loaded
  49625. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49626. * @param pluginExtension the extension used to determine the plugin
  49627. * @returns The loaded plugin
  49628. */
  49629. SceneLoader.LoadAssetContainer = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  49630. if (sceneFilename === void 0) { sceneFilename = ""; }
  49631. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  49632. if (onSuccess === void 0) { onSuccess = null; }
  49633. if (onProgress === void 0) { onProgress = null; }
  49634. if (onError === void 0) { onError = null; }
  49635. if (pluginExtension === void 0) { pluginExtension = null; }
  49636. if (!scene) {
  49637. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to load asset container to");
  49638. return null;
  49639. }
  49640. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  49641. if (!fileInfo) {
  49642. return null;
  49643. }
  49644. var loadingToken = {};
  49645. scene._addPendingData(loadingToken);
  49646. var disposeHandler = function () {
  49647. scene._removePendingData(loadingToken);
  49648. };
  49649. var errorHandler = function (message, exception) {
  49650. var errorMessage = "Unable to load assets from " + fileInfo.url + (message ? ": " + message : "");
  49651. if (onError) {
  49652. onError(scene, errorMessage, exception);
  49653. }
  49654. else {
  49655. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  49656. // should the exception be thrown?
  49657. }
  49658. disposeHandler();
  49659. };
  49660. var progressHandler = onProgress ? function (event) {
  49661. try {
  49662. onProgress(event);
  49663. }
  49664. catch (e) {
  49665. errorHandler("Error in onProgress callback", e);
  49666. }
  49667. } : undefined;
  49668. var successHandler = function (assets) {
  49669. if (onSuccess) {
  49670. try {
  49671. onSuccess(assets);
  49672. }
  49673. catch (e) {
  49674. errorHandler("Error in onSuccess callback", e);
  49675. }
  49676. }
  49677. scene._removePendingData(loadingToken);
  49678. };
  49679. return SceneLoader._loadData(fileInfo, scene, function (plugin, data) {
  49680. if (plugin.loadAssetContainer) {
  49681. var syncedPlugin = plugin;
  49682. var assetContainer = syncedPlugin.loadAssetContainer(scene, data, fileInfo.rootUrl, errorHandler);
  49683. if (!assetContainer) {
  49684. return;
  49685. }
  49686. scene.loadingPluginName = plugin.name;
  49687. successHandler(assetContainer);
  49688. }
  49689. else if (plugin.loadAssetContainerAsync) {
  49690. var asyncedPlugin = plugin;
  49691. asyncedPlugin.loadAssetContainerAsync(scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function (assetContainer) {
  49692. scene.loadingPluginName = plugin.name;
  49693. successHandler(assetContainer);
  49694. }).catch(function (error) {
  49695. errorHandler(error.message, error);
  49696. });
  49697. }
  49698. else {
  49699. errorHandler("LoadAssetContainer is not supported by this plugin. Plugin did not provide a loadAssetContainer or loadAssetContainerAsync method.");
  49700. }
  49701. if (SceneLoader.ShowLoadingScreen) {
  49702. scene.executeWhenReady(function () {
  49703. scene.getEngine().hideLoadingUI();
  49704. });
  49705. }
  49706. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  49707. };
  49708. /**
  49709. * Load a scene into an asset container
  49710. * @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)
  49711. * @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)
  49712. * @param scene is the instance of Scene to append to
  49713. * @param onProgress a callback with a progress event for each file being loaded
  49714. * @param pluginExtension the extension used to determine the plugin
  49715. * @returns The loaded asset container
  49716. */
  49717. SceneLoader.LoadAssetContainerAsync = function (rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  49718. if (sceneFilename === void 0) { sceneFilename = ""; }
  49719. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  49720. if (onProgress === void 0) { onProgress = null; }
  49721. if (pluginExtension === void 0) { pluginExtension = null; }
  49722. return new Promise(function (resolve, reject) {
  49723. SceneLoader.LoadAssetContainer(rootUrl, sceneFilename, scene, function (assetContainer) {
  49724. resolve(assetContainer);
  49725. }, onProgress, function (scene, message, exception) {
  49726. reject(exception || new Error(message));
  49727. }, pluginExtension);
  49728. });
  49729. };
  49730. /**
  49731. * No logging while loading
  49732. */
  49733. SceneLoader.NO_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_NO_LOGGING;
  49734. /**
  49735. * Minimal logging while loading
  49736. */
  49737. SceneLoader.MINIMAL_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_MINIMAL_LOGGING;
  49738. /**
  49739. * Summary logging while loading
  49740. */
  49741. SceneLoader.SUMMARY_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_SUMMARY_LOGGING;
  49742. /**
  49743. * Detailled logging while loading
  49744. */
  49745. SceneLoader.DETAILED_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_DETAILED_LOGGING;
  49746. // Members
  49747. /**
  49748. * Event raised when a plugin is used to load a scene
  49749. */
  49750. SceneLoader.OnPluginActivatedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  49751. SceneLoader._registeredPlugins = {};
  49752. return SceneLoader;
  49753. }());
  49754. /***/ }),
  49755. /***/ "./Loading/sceneLoaderFlags.ts":
  49756. /*!*************************************!*\
  49757. !*** ./Loading/sceneLoaderFlags.ts ***!
  49758. \*************************************/
  49759. /*! exports provided: SceneLoaderFlags */
  49760. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49761. "use strict";
  49762. __webpack_require__.r(__webpack_exports__);
  49763. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return SceneLoaderFlags; });
  49764. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  49765. /**
  49766. * Class used to represent data loading progression
  49767. */
  49768. var SceneLoaderFlags = /** @class */ (function () {
  49769. function SceneLoaderFlags() {
  49770. }
  49771. Object.defineProperty(SceneLoaderFlags, "ForceFullSceneLoadingForIncremental", {
  49772. /**
  49773. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  49774. */
  49775. get: function () {
  49776. return SceneLoaderFlags._ForceFullSceneLoadingForIncremental;
  49777. },
  49778. set: function (value) {
  49779. SceneLoaderFlags._ForceFullSceneLoadingForIncremental = value;
  49780. },
  49781. enumerable: true,
  49782. configurable: true
  49783. });
  49784. Object.defineProperty(SceneLoaderFlags, "ShowLoadingScreen", {
  49785. /**
  49786. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  49787. */
  49788. get: function () {
  49789. return SceneLoaderFlags._ShowLoadingScreen;
  49790. },
  49791. set: function (value) {
  49792. SceneLoaderFlags._ShowLoadingScreen = value;
  49793. },
  49794. enumerable: true,
  49795. configurable: true
  49796. });
  49797. Object.defineProperty(SceneLoaderFlags, "loggingLevel", {
  49798. /**
  49799. * Defines the current logging level (while loading the scene)
  49800. * @ignorenaming
  49801. */
  49802. get: function () {
  49803. return SceneLoaderFlags._loggingLevel;
  49804. },
  49805. set: function (value) {
  49806. SceneLoaderFlags._loggingLevel = value;
  49807. },
  49808. enumerable: true,
  49809. configurable: true
  49810. });
  49811. Object.defineProperty(SceneLoaderFlags, "CleanBoneMatrixWeights", {
  49812. /**
  49813. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  49814. */
  49815. get: function () {
  49816. return SceneLoaderFlags._CleanBoneMatrixWeights;
  49817. },
  49818. set: function (value) {
  49819. SceneLoaderFlags._CleanBoneMatrixWeights = value;
  49820. },
  49821. enumerable: true,
  49822. configurable: true
  49823. });
  49824. // Flags
  49825. SceneLoaderFlags._ForceFullSceneLoadingForIncremental = false;
  49826. SceneLoaderFlags._ShowLoadingScreen = true;
  49827. SceneLoaderFlags._CleanBoneMatrixWeights = false;
  49828. SceneLoaderFlags._loggingLevel = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].SCENELOADER_NO_LOGGING;
  49829. return SceneLoaderFlags;
  49830. }());
  49831. /***/ }),
  49832. /***/ "./Materials/Background/backgroundMaterial.ts":
  49833. /*!****************************************************!*\
  49834. !*** ./Materials/Background/backgroundMaterial.ts ***!
  49835. \****************************************************/
  49836. /*! exports provided: BackgroundMaterial */
  49837. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49838. "use strict";
  49839. __webpack_require__.r(__webpack_exports__);
  49840. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return BackgroundMaterial; });
  49841. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  49842. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  49843. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  49844. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  49845. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  49846. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  49847. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  49848. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  49849. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/materialDefines */ "./Materials/materialDefines.ts");
  49850. /* harmony import */ var _Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/pushMaterial */ "./Materials/pushMaterial.ts");
  49851. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  49852. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  49853. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  49854. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  49855. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  49856. /* harmony import */ var _Shaders_background_fragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Shaders/background.fragment */ "./Shaders/background.fragment.ts");
  49857. /* harmony import */ var _Shaders_background_vertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Shaders/background.vertex */ "./Shaders/background.vertex.ts");
  49858. /**
  49859. * Background material defines definition.
  49860. * @hidden Mainly internal Use
  49861. */
  49862. var BackgroundMaterialDefines = /** @class */ (function (_super) {
  49863. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackgroundMaterialDefines, _super);
  49864. /**
  49865. * Constructor of the defines.
  49866. */
  49867. function BackgroundMaterialDefines() {
  49868. var _this = _super.call(this) || this;
  49869. /**
  49870. * True if the diffuse texture is in use.
  49871. */
  49872. _this.DIFFUSE = false;
  49873. /**
  49874. * The direct UV channel to use.
  49875. */
  49876. _this.DIFFUSEDIRECTUV = 0;
  49877. /**
  49878. * True if the diffuse texture is in gamma space.
  49879. */
  49880. _this.GAMMADIFFUSE = false;
  49881. /**
  49882. * True if the diffuse texture has opacity in the alpha channel.
  49883. */
  49884. _this.DIFFUSEHASALPHA = false;
  49885. /**
  49886. * True if you want the material to fade to transparent at grazing angle.
  49887. */
  49888. _this.OPACITYFRESNEL = false;
  49889. /**
  49890. * True if an extra blur needs to be added in the reflection.
  49891. */
  49892. _this.REFLECTIONBLUR = false;
  49893. /**
  49894. * True if you want the material to fade to reflection at grazing angle.
  49895. */
  49896. _this.REFLECTIONFRESNEL = false;
  49897. /**
  49898. * True if you want the material to falloff as far as you move away from the scene center.
  49899. */
  49900. _this.REFLECTIONFALLOFF = false;
  49901. /**
  49902. * False if the current Webgl implementation does not support the texture lod extension.
  49903. */
  49904. _this.TEXTURELODSUPPORT = false;
  49905. /**
  49906. * True to ensure the data are premultiplied.
  49907. */
  49908. _this.PREMULTIPLYALPHA = false;
  49909. /**
  49910. * True if the texture contains cooked RGB values and not gray scaled multipliers.
  49911. */
  49912. _this.USERGBCOLOR = false;
  49913. /**
  49914. * True if highlight and shadow levels have been specified. It can help ensuring the main perceived color
  49915. * stays aligned with the desired configuration.
  49916. */
  49917. _this.USEHIGHLIGHTANDSHADOWCOLORS = false;
  49918. /**
  49919. * True to add noise in order to reduce the banding effect.
  49920. */
  49921. _this.NOISE = false;
  49922. /**
  49923. * is the reflection texture in BGR color scheme?
  49924. * Mainly used to solve a bug in ios10 video tag
  49925. */
  49926. _this.REFLECTIONBGR = false;
  49927. _this.IMAGEPROCESSING = false;
  49928. _this.VIGNETTE = false;
  49929. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  49930. _this.VIGNETTEBLENDMODEOPAQUE = false;
  49931. _this.TONEMAPPING = false;
  49932. _this.TONEMAPPING_ACES = false;
  49933. _this.CONTRAST = false;
  49934. _this.COLORCURVES = false;
  49935. _this.COLORGRADING = false;
  49936. _this.COLORGRADING3D = false;
  49937. _this.SAMPLER3DGREENDEPTH = false;
  49938. _this.SAMPLER3DBGRMAP = false;
  49939. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  49940. _this.EXPOSURE = false;
  49941. // Reflection.
  49942. _this.REFLECTION = false;
  49943. _this.REFLECTIONMAP_3D = false;
  49944. _this.REFLECTIONMAP_SPHERICAL = false;
  49945. _this.REFLECTIONMAP_PLANAR = false;
  49946. _this.REFLECTIONMAP_CUBIC = false;
  49947. _this.REFLECTIONMAP_PROJECTION = false;
  49948. _this.REFLECTIONMAP_SKYBOX = false;
  49949. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  49950. _this.REFLECTIONMAP_EXPLICIT = false;
  49951. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  49952. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  49953. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  49954. _this.INVERTCUBICMAP = false;
  49955. _this.REFLECTIONMAP_OPPOSITEZ = false;
  49956. _this.LODINREFLECTIONALPHA = false;
  49957. _this.GAMMAREFLECTION = false;
  49958. _this.RGBDREFLECTION = false;
  49959. _this.EQUIRECTANGULAR_RELFECTION_FOV = false;
  49960. // Default BJS.
  49961. _this.MAINUV1 = false;
  49962. _this.MAINUV2 = false;
  49963. _this.UV1 = false;
  49964. _this.UV2 = false;
  49965. _this.CLIPPLANE = false;
  49966. _this.CLIPPLANE2 = false;
  49967. _this.CLIPPLANE3 = false;
  49968. _this.CLIPPLANE4 = false;
  49969. _this.POINTSIZE = false;
  49970. _this.FOG = false;
  49971. _this.NORMAL = false;
  49972. _this.NUM_BONE_INFLUENCERS = 0;
  49973. _this.BonesPerMesh = 0;
  49974. _this.INSTANCES = false;
  49975. _this.SHADOWFLOAT = false;
  49976. _this.rebuild();
  49977. return _this;
  49978. }
  49979. return BackgroundMaterialDefines;
  49980. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__["MaterialDefines"]));
  49981. /**
  49982. * Background material used to create an efficient environement around your scene.
  49983. */
  49984. var BackgroundMaterial = /** @class */ (function (_super) {
  49985. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackgroundMaterial, _super);
  49986. /**
  49987. * Instantiates a Background Material in the given scene
  49988. * @param name The friendly name of the material
  49989. * @param scene The scene to add the material to
  49990. */
  49991. function BackgroundMaterial(name, scene) {
  49992. var _this = _super.call(this, name, scene) || this;
  49993. /**
  49994. * Key light Color (multiply against the environement texture)
  49995. */
  49996. _this.primaryColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].White();
  49997. _this._primaryColorShadowLevel = 0;
  49998. _this._primaryColorHighlightLevel = 0;
  49999. /**
  50000. * Reflection Texture used in the material.
  50001. * Should be author in a specific way for the best result (refer to the documentation).
  50002. */
  50003. _this.reflectionTexture = null;
  50004. /**
  50005. * Reflection Texture level of blur.
  50006. *
  50007. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  50008. * texture twice.
  50009. */
  50010. _this.reflectionBlur = 0;
  50011. /**
  50012. * Diffuse Texture used in the material.
  50013. * Should be author in a specific way for the best result (refer to the documentation).
  50014. */
  50015. _this.diffuseTexture = null;
  50016. _this._shadowLights = null;
  50017. /**
  50018. * Specify the list of lights casting shadow on the material.
  50019. * All scene shadow lights will be included if null.
  50020. */
  50021. _this.shadowLights = null;
  50022. /**
  50023. * Helps adjusting the shadow to a softer level if required.
  50024. * 0 means black shadows and 1 means no shadows.
  50025. */
  50026. _this.shadowLevel = 0;
  50027. /**
  50028. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  50029. * It is usually zero but might be interesting to modify according to your setup.
  50030. */
  50031. _this.sceneCenter = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  50032. /**
  50033. * This helps specifying that the material is falling off to the sky box at grazing angle.
  50034. * This helps ensuring a nice transition when the camera goes under the ground.
  50035. */
  50036. _this.opacityFresnel = true;
  50037. /**
  50038. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  50039. * This helps adding a mirror texture on the ground.
  50040. */
  50041. _this.reflectionFresnel = false;
  50042. /**
  50043. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  50044. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  50045. */
  50046. _this.reflectionFalloffDistance = 0.0;
  50047. /**
  50048. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  50049. */
  50050. _this.reflectionAmount = 1.0;
  50051. /**
  50052. * This specifies the weight of the reflection at grazing angle.
  50053. */
  50054. _this.reflectionReflectance0 = 0.05;
  50055. /**
  50056. * This specifies the weight of the reflection at a perpendicular point of view.
  50057. */
  50058. _this.reflectionReflectance90 = 0.5;
  50059. /**
  50060. * Helps to directly use the maps channels instead of their level.
  50061. */
  50062. _this.useRGBColor = true;
  50063. /**
  50064. * This helps reducing the banding effect that could occur on the background.
  50065. */
  50066. _this.enableNoise = false;
  50067. _this._fovMultiplier = 1.0;
  50068. /**
  50069. * Enable the FOV adjustment feature controlled by fovMultiplier.
  50070. */
  50071. _this.useEquirectangularFOV = false;
  50072. _this._maxSimultaneousLights = 4;
  50073. /**
  50074. * Number of Simultaneous lights allowed on the material.
  50075. */
  50076. _this.maxSimultaneousLights = 4;
  50077. /**
  50078. * Keep track of the image processing observer to allow dispose and replace.
  50079. */
  50080. _this._imageProcessingObserver = null;
  50081. /**
  50082. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  50083. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  50084. */
  50085. _this.switchToBGR = false;
  50086. // Temp values kept as cache in the material.
  50087. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](16);
  50088. _this._reflectionControls = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector4"].Zero();
  50089. _this._white = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].White();
  50090. _this._primaryShadowColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].Black();
  50091. _this._primaryHighlightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].Black();
  50092. // Setup the default processing configuration to the scene.
  50093. _this._attachImageProcessingConfiguration(null);
  50094. _this.getRenderTargetTextures = function () {
  50095. _this._renderTargets.reset();
  50096. if (_this._diffuseTexture && _this._diffuseTexture.isRenderTarget) {
  50097. _this._renderTargets.push(_this._diffuseTexture);
  50098. }
  50099. if (_this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  50100. _this._renderTargets.push(_this._reflectionTexture);
  50101. }
  50102. return _this._renderTargets;
  50103. };
  50104. return _this;
  50105. }
  50106. Object.defineProperty(BackgroundMaterial.prototype, "_perceptualColor", {
  50107. /**
  50108. * Experimental Internal Use Only.
  50109. *
  50110. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  50111. * This acts as a helper to set the primary color to a more "human friendly" value.
  50112. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  50113. * output color as close as possible from the chosen value.
  50114. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  50115. * part of lighting setup.)
  50116. */
  50117. get: function () {
  50118. return this.__perceptualColor;
  50119. },
  50120. set: function (value) {
  50121. this.__perceptualColor = value;
  50122. this._computePrimaryColorFromPerceptualColor();
  50123. this._markAllSubMeshesAsLightsDirty();
  50124. },
  50125. enumerable: true,
  50126. configurable: true
  50127. });
  50128. Object.defineProperty(BackgroundMaterial.prototype, "primaryColorShadowLevel", {
  50129. /**
  50130. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  50131. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  50132. */
  50133. get: function () {
  50134. return this._primaryColorShadowLevel;
  50135. },
  50136. set: function (value) {
  50137. this._primaryColorShadowLevel = value;
  50138. this._computePrimaryColors();
  50139. this._markAllSubMeshesAsLightsDirty();
  50140. },
  50141. enumerable: true,
  50142. configurable: true
  50143. });
  50144. Object.defineProperty(BackgroundMaterial.prototype, "primaryColorHighlightLevel", {
  50145. /**
  50146. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  50147. * The primary color is used at the level chosen to define what the white area would look.
  50148. */
  50149. get: function () {
  50150. return this._primaryColorHighlightLevel;
  50151. },
  50152. set: function (value) {
  50153. this._primaryColorHighlightLevel = value;
  50154. this._computePrimaryColors();
  50155. this._markAllSubMeshesAsLightsDirty();
  50156. },
  50157. enumerable: true,
  50158. configurable: true
  50159. });
  50160. Object.defineProperty(BackgroundMaterial.prototype, "reflectionStandardFresnelWeight", {
  50161. /**
  50162. * Sets the reflection reflectance fresnel values according to the default standard
  50163. * empirically know to work well :-)
  50164. */
  50165. set: function (value) {
  50166. var reflectionWeight = value;
  50167. if (reflectionWeight < 0.5) {
  50168. reflectionWeight = reflectionWeight * 2.0;
  50169. this.reflectionReflectance0 = BackgroundMaterial.StandardReflectance0 * reflectionWeight;
  50170. this.reflectionReflectance90 = BackgroundMaterial.StandardReflectance90 * reflectionWeight;
  50171. }
  50172. else {
  50173. reflectionWeight = reflectionWeight * 2.0 - 1.0;
  50174. this.reflectionReflectance0 = BackgroundMaterial.StandardReflectance0 + (1.0 - BackgroundMaterial.StandardReflectance0) * reflectionWeight;
  50175. this.reflectionReflectance90 = BackgroundMaterial.StandardReflectance90 + (1.0 - BackgroundMaterial.StandardReflectance90) * reflectionWeight;
  50176. }
  50177. },
  50178. enumerable: true,
  50179. configurable: true
  50180. });
  50181. Object.defineProperty(BackgroundMaterial.prototype, "fovMultiplier", {
  50182. /**
  50183. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50184. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  50185. * Recommended to be keep at 1.0 except for special cases.
  50186. */
  50187. get: function () {
  50188. return this._fovMultiplier;
  50189. },
  50190. set: function (value) {
  50191. if (isNaN(value)) {
  50192. value = 1.0;
  50193. }
  50194. this._fovMultiplier = Math.max(0.0, Math.min(2.0, value));
  50195. },
  50196. enumerable: true,
  50197. configurable: true
  50198. });
  50199. /**
  50200. * Attaches a new image processing configuration to the PBR Material.
  50201. * @param configuration (if null the scene configuration will be use)
  50202. */
  50203. BackgroundMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  50204. var _this = this;
  50205. if (configuration === this._imageProcessingConfiguration) {
  50206. return;
  50207. }
  50208. // Detaches observer.
  50209. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  50210. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  50211. }
  50212. // Pick the scene configuration if needed.
  50213. if (!configuration) {
  50214. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  50215. }
  50216. else {
  50217. this._imageProcessingConfiguration = configuration;
  50218. }
  50219. // Attaches observer.
  50220. if (this._imageProcessingConfiguration) {
  50221. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  50222. _this._computePrimaryColorFromPerceptualColor();
  50223. _this._markAllSubMeshesAsImageProcessingDirty();
  50224. });
  50225. }
  50226. };
  50227. Object.defineProperty(BackgroundMaterial.prototype, "imageProcessingConfiguration", {
  50228. /**
  50229. * Gets the image processing configuration used either in this material.
  50230. */
  50231. get: function () {
  50232. return this._imageProcessingConfiguration;
  50233. },
  50234. /**
  50235. * Sets the Default image processing configuration used either in the this material.
  50236. *
  50237. * If sets to null, the scene one is in use.
  50238. */
  50239. set: function (value) {
  50240. this._attachImageProcessingConfiguration(value);
  50241. // Ensure the effect will be rebuilt.
  50242. this._markAllSubMeshesAsTexturesDirty();
  50243. },
  50244. enumerable: true,
  50245. configurable: true
  50246. });
  50247. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorCurvesEnabled", {
  50248. /**
  50249. * Gets wether the color curves effect is enabled.
  50250. */
  50251. get: function () {
  50252. return this.imageProcessingConfiguration.colorCurvesEnabled;
  50253. },
  50254. /**
  50255. * Sets wether the color curves effect is enabled.
  50256. */
  50257. set: function (value) {
  50258. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  50259. },
  50260. enumerable: true,
  50261. configurable: true
  50262. });
  50263. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorGradingEnabled", {
  50264. /**
  50265. * Gets wether the color grading effect is enabled.
  50266. */
  50267. get: function () {
  50268. return this.imageProcessingConfiguration.colorGradingEnabled;
  50269. },
  50270. /**
  50271. * Gets wether the color grading effect is enabled.
  50272. */
  50273. set: function (value) {
  50274. this.imageProcessingConfiguration.colorGradingEnabled = value;
  50275. },
  50276. enumerable: true,
  50277. configurable: true
  50278. });
  50279. Object.defineProperty(BackgroundMaterial.prototype, "cameraToneMappingEnabled", {
  50280. /**
  50281. * Gets wether tonemapping is enabled or not.
  50282. */
  50283. get: function () {
  50284. return this._imageProcessingConfiguration.toneMappingEnabled;
  50285. },
  50286. /**
  50287. * Sets wether tonemapping is enabled or not
  50288. */
  50289. set: function (value) {
  50290. this._imageProcessingConfiguration.toneMappingEnabled = value;
  50291. },
  50292. enumerable: true,
  50293. configurable: true
  50294. });
  50295. Object.defineProperty(BackgroundMaterial.prototype, "cameraExposure", {
  50296. /**
  50297. * The camera exposure used on this material.
  50298. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50299. * This corresponds to a photographic exposure.
  50300. */
  50301. get: function () {
  50302. return this._imageProcessingConfiguration.exposure;
  50303. },
  50304. /**
  50305. * The camera exposure used on this material.
  50306. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50307. * This corresponds to a photographic exposure.
  50308. */
  50309. set: function (value) {
  50310. this._imageProcessingConfiguration.exposure = value;
  50311. },
  50312. enumerable: true,
  50313. configurable: true
  50314. });
  50315. Object.defineProperty(BackgroundMaterial.prototype, "cameraContrast", {
  50316. /**
  50317. * Gets The camera contrast used on this material.
  50318. */
  50319. get: function () {
  50320. return this._imageProcessingConfiguration.contrast;
  50321. },
  50322. /**
  50323. * Sets The camera contrast used on this material.
  50324. */
  50325. set: function (value) {
  50326. this._imageProcessingConfiguration.contrast = value;
  50327. },
  50328. enumerable: true,
  50329. configurable: true
  50330. });
  50331. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorGradingTexture", {
  50332. /**
  50333. * Gets the Color Grading 2D Lookup Texture.
  50334. */
  50335. get: function () {
  50336. return this._imageProcessingConfiguration.colorGradingTexture;
  50337. },
  50338. /**
  50339. * Sets the Color Grading 2D Lookup Texture.
  50340. */
  50341. set: function (value) {
  50342. this.imageProcessingConfiguration.colorGradingTexture = value;
  50343. },
  50344. enumerable: true,
  50345. configurable: true
  50346. });
  50347. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorCurves", {
  50348. /**
  50349. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50350. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50351. * 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;
  50352. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50353. */
  50354. get: function () {
  50355. return this.imageProcessingConfiguration.colorCurves;
  50356. },
  50357. /**
  50358. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50359. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50360. * 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;
  50361. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50362. */
  50363. set: function (value) {
  50364. this.imageProcessingConfiguration.colorCurves = value;
  50365. },
  50366. enumerable: true,
  50367. configurable: true
  50368. });
  50369. Object.defineProperty(BackgroundMaterial.prototype, "hasRenderTargetTextures", {
  50370. /**
  50371. * Gets a boolean indicating that current material needs to register RTT
  50372. */
  50373. get: function () {
  50374. if (this._diffuseTexture && this._diffuseTexture.isRenderTarget) {
  50375. return true;
  50376. }
  50377. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  50378. return true;
  50379. }
  50380. return false;
  50381. },
  50382. enumerable: true,
  50383. configurable: true
  50384. });
  50385. /**
  50386. * The entire material has been created in order to prevent overdraw.
  50387. * @returns false
  50388. */
  50389. BackgroundMaterial.prototype.needAlphaTesting = function () {
  50390. return true;
  50391. };
  50392. /**
  50393. * The entire material has been created in order to prevent overdraw.
  50394. * @returns true if blending is enable
  50395. */
  50396. BackgroundMaterial.prototype.needAlphaBlending = function () {
  50397. return ((this.alpha < 0) || (this._diffuseTexture != null && this._diffuseTexture.hasAlpha));
  50398. };
  50399. /**
  50400. * Checks wether the material is ready to be rendered for a given mesh.
  50401. * @param mesh The mesh to render
  50402. * @param subMesh The submesh to check against
  50403. * @param useInstances Specify wether or not the material is used with instances
  50404. * @returns true if all the dependencies are ready (Textures, Effects...)
  50405. */
  50406. BackgroundMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  50407. var _this = this;
  50408. if (useInstances === void 0) { useInstances = false; }
  50409. if (subMesh.effect && this.isFrozen) {
  50410. if (this._wasPreviouslyReady) {
  50411. return true;
  50412. }
  50413. }
  50414. if (!subMesh._materialDefines) {
  50415. subMesh._materialDefines = new BackgroundMaterialDefines();
  50416. }
  50417. var scene = this.getScene();
  50418. var defines = subMesh._materialDefines;
  50419. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  50420. if (defines._renderId === scene.getRenderId()) {
  50421. return true;
  50422. }
  50423. }
  50424. var engine = scene.getEngine();
  50425. // Lights
  50426. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights);
  50427. defines._needNormals = true;
  50428. // Textures
  50429. if (defines._areTexturesDirty) {
  50430. defines._needUVs = false;
  50431. if (scene.texturesEnabled) {
  50432. if (scene.getEngine().getCaps().textureLOD) {
  50433. defines.TEXTURELODSUPPORT = true;
  50434. }
  50435. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  50436. if (!this._diffuseTexture.isReadyOrNotBlocking()) {
  50437. return false;
  50438. }
  50439. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForMergedUV(this._diffuseTexture, defines, "DIFFUSE");
  50440. defines.DIFFUSEHASALPHA = this._diffuseTexture.hasAlpha;
  50441. defines.GAMMADIFFUSE = this._diffuseTexture.gammaSpace;
  50442. defines.OPACITYFRESNEL = this._opacityFresnel;
  50443. }
  50444. else {
  50445. defines.DIFFUSE = false;
  50446. defines.DIFFUSEHASALPHA = false;
  50447. defines.GAMMADIFFUSE = false;
  50448. defines.OPACITYFRESNEL = false;
  50449. }
  50450. var reflectionTexture = this._reflectionTexture;
  50451. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  50452. if (!reflectionTexture.isReadyOrNotBlocking()) {
  50453. return false;
  50454. }
  50455. defines.REFLECTION = true;
  50456. defines.GAMMAREFLECTION = reflectionTexture.gammaSpace;
  50457. defines.RGBDREFLECTION = reflectionTexture.isRGBD;
  50458. defines.REFLECTIONBLUR = this._reflectionBlur > 0;
  50459. defines.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !reflectionTexture.invertZ : reflectionTexture.invertZ;
  50460. defines.LODINREFLECTIONALPHA = reflectionTexture.lodLevelInAlpha;
  50461. defines.EQUIRECTANGULAR_RELFECTION_FOV = this.useEquirectangularFOV;
  50462. defines.REFLECTIONBGR = this.switchToBGR;
  50463. if (reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE) {
  50464. defines.INVERTCUBICMAP = true;
  50465. }
  50466. defines.REFLECTIONMAP_3D = reflectionTexture.isCube;
  50467. switch (reflectionTexture.coordinatesMode) {
  50468. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EXPLICIT_MODE:
  50469. defines.REFLECTIONMAP_EXPLICIT = true;
  50470. break;
  50471. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PLANAR_MODE:
  50472. defines.REFLECTIONMAP_PLANAR = true;
  50473. break;
  50474. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PROJECTION_MODE:
  50475. defines.REFLECTIONMAP_PROJECTION = true;
  50476. break;
  50477. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SKYBOX_MODE:
  50478. defines.REFLECTIONMAP_SKYBOX = true;
  50479. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !reflectionTexture.getReflectionTextureMatrix().isIdentity();
  50480. break;
  50481. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SPHERICAL_MODE:
  50482. defines.REFLECTIONMAP_SPHERICAL = true;
  50483. break;
  50484. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EQUIRECTANGULAR_MODE:
  50485. defines.REFLECTIONMAP_EQUIRECTANGULAR = true;
  50486. break;
  50487. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  50488. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = true;
  50489. break;
  50490. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  50491. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = true;
  50492. break;
  50493. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].CUBIC_MODE:
  50494. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE:
  50495. default:
  50496. defines.REFLECTIONMAP_CUBIC = true;
  50497. break;
  50498. }
  50499. if (this.reflectionFresnel) {
  50500. defines.REFLECTIONFRESNEL = true;
  50501. defines.REFLECTIONFALLOFF = this.reflectionFalloffDistance > 0;
  50502. this._reflectionControls.x = this.reflectionAmount;
  50503. this._reflectionControls.y = this.reflectionReflectance0;
  50504. this._reflectionControls.z = this.reflectionReflectance90;
  50505. this._reflectionControls.w = 1 / this.reflectionFalloffDistance;
  50506. }
  50507. else {
  50508. defines.REFLECTIONFRESNEL = false;
  50509. defines.REFLECTIONFALLOFF = false;
  50510. }
  50511. }
  50512. else {
  50513. defines.REFLECTION = false;
  50514. defines.REFLECTIONFRESNEL = false;
  50515. defines.REFLECTIONFALLOFF = false;
  50516. defines.REFLECTIONBLUR = false;
  50517. defines.REFLECTIONMAP_3D = false;
  50518. defines.REFLECTIONMAP_SPHERICAL = false;
  50519. defines.REFLECTIONMAP_PLANAR = false;
  50520. defines.REFLECTIONMAP_CUBIC = false;
  50521. defines.REFLECTIONMAP_PROJECTION = false;
  50522. defines.REFLECTIONMAP_SKYBOX = false;
  50523. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  50524. defines.REFLECTIONMAP_EXPLICIT = false;
  50525. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  50526. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  50527. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  50528. defines.INVERTCUBICMAP = false;
  50529. defines.REFLECTIONMAP_OPPOSITEZ = false;
  50530. defines.LODINREFLECTIONALPHA = false;
  50531. defines.GAMMAREFLECTION = false;
  50532. defines.RGBDREFLECTION = false;
  50533. }
  50534. }
  50535. 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);
  50536. defines.USERGBCOLOR = this._useRGBColor;
  50537. defines.NOISE = this._enableNoise;
  50538. }
  50539. if (defines._areLightsDirty) {
  50540. defines.USEHIGHLIGHTANDSHADOWCOLORS = !this._useRGBColor && (this._primaryColorShadowLevel !== 0 || this._primaryColorHighlightLevel !== 0);
  50541. }
  50542. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  50543. if (!this._imageProcessingConfiguration.isReady()) {
  50544. return false;
  50545. }
  50546. this._imageProcessingConfiguration.prepareDefines(defines);
  50547. }
  50548. // Misc.
  50549. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  50550. // Values that need to be evaluated on every frame
  50551. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
  50552. // Attribs
  50553. if (_Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, false, true, false)) {
  50554. if (mesh) {
  50555. if (!scene.getEngine().getCaps().standardDerivatives && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind)) {
  50556. mesh.createNormals(true);
  50557. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Warn("BackgroundMaterial: Normals have been created for the mesh: " + mesh.name);
  50558. }
  50559. }
  50560. }
  50561. // Get correct effect
  50562. if (defines.isDirty) {
  50563. defines.markAsProcessed();
  50564. scene.resetCachedMaterial();
  50565. // Fallbacks
  50566. var fallbacks = new _Materials_effect__WEBPACK_IMPORTED_MODULE_6__["EffectFallbacks"]();
  50567. if (defines.FOG) {
  50568. fallbacks.addFallback(0, "FOG");
  50569. }
  50570. if (defines.POINTSIZE) {
  50571. fallbacks.addFallback(1, "POINTSIZE");
  50572. }
  50573. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights);
  50574. if (defines.NUM_BONE_INFLUENCERS > 0) {
  50575. fallbacks.addCPUSkinningFallback(0, mesh);
  50576. }
  50577. //Attributes
  50578. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind];
  50579. if (defines.NORMAL) {
  50580. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  50581. }
  50582. if (defines.UV1) {
  50583. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UVKind);
  50584. }
  50585. if (defines.UV2) {
  50586. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UV2Kind);
  50587. }
  50588. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  50589. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  50590. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType",
  50591. "vFogInfos", "vFogColor", "pointSize",
  50592. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "mBones",
  50593. "vPrimaryColor", "vPrimaryColorShadow",
  50594. "vReflectionInfos", "reflectionMatrix", "vReflectionMicrosurfaceInfos", "fFovMultiplier",
  50595. "shadowLevel", "alpha",
  50596. "vBackgroundCenter", "vReflectionControl",
  50597. "vDiffuseInfos", "diffuseMatrix",
  50598. ];
  50599. var samplers = ["diffuseSampler", "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh"];
  50600. var uniformBuffers = ["Material", "Scene"];
  50601. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"]) {
  50602. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  50603. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  50604. }
  50605. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareUniformsAndSamplersList({
  50606. uniformsNames: uniforms,
  50607. uniformBuffersNames: uniformBuffers,
  50608. samplers: samplers,
  50609. defines: defines,
  50610. maxSimultaneousLights: this._maxSimultaneousLights
  50611. });
  50612. var onCompiled = function (effect) {
  50613. if (_this.onCompiled) {
  50614. _this.onCompiled(effect);
  50615. }
  50616. _this.bindSceneUniformBuffer(effect, scene.getSceneUniformBuffer());
  50617. };
  50618. var join = defines.toString();
  50619. subMesh.setEffect(scene.getEngine().createEffect("background", {
  50620. attributes: attribs,
  50621. uniformsNames: uniforms,
  50622. uniformBuffersNames: uniformBuffers,
  50623. samplers: samplers,
  50624. defines: join,
  50625. fallbacks: fallbacks,
  50626. onCompiled: onCompiled,
  50627. onError: this.onError,
  50628. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights }
  50629. }, engine), defines);
  50630. this.buildUniformLayout();
  50631. }
  50632. if (!subMesh.effect || !subMesh.effect.isReady()) {
  50633. return false;
  50634. }
  50635. defines._renderId = scene.getRenderId();
  50636. this._wasPreviouslyReady = true;
  50637. return true;
  50638. };
  50639. /**
  50640. * Compute the primary color according to the chosen perceptual color.
  50641. */
  50642. BackgroundMaterial.prototype._computePrimaryColorFromPerceptualColor = function () {
  50643. if (!this.__perceptualColor) {
  50644. return;
  50645. }
  50646. this._primaryColor.copyFrom(this.__perceptualColor);
  50647. // Revert gamma space.
  50648. this._primaryColor.toLinearSpaceToRef(this._primaryColor);
  50649. // Revert image processing configuration.
  50650. if (this._imageProcessingConfiguration) {
  50651. // Revert Exposure.
  50652. this._primaryColor.scaleToRef(1 / this._imageProcessingConfiguration.exposure, this._primaryColor);
  50653. }
  50654. this._computePrimaryColors();
  50655. };
  50656. /**
  50657. * Compute the highlights and shadow colors according to their chosen levels.
  50658. */
  50659. BackgroundMaterial.prototype._computePrimaryColors = function () {
  50660. if (this._primaryColorShadowLevel === 0 && this._primaryColorHighlightLevel === 0) {
  50661. return;
  50662. }
  50663. // Find the highlight color based on the configuration.
  50664. this._primaryColor.scaleToRef(this._primaryColorShadowLevel, this._primaryShadowColor);
  50665. this._primaryColor.subtractToRef(this._primaryShadowColor, this._primaryShadowColor);
  50666. // Find the shadow color based on the configuration.
  50667. this._white.subtractToRef(this._primaryColor, this._primaryHighlightColor);
  50668. this._primaryHighlightColor.scaleToRef(this._primaryColorHighlightLevel, this._primaryHighlightColor);
  50669. this._primaryColor.addToRef(this._primaryHighlightColor, this._primaryHighlightColor);
  50670. };
  50671. /**
  50672. * Build the uniform buffer used in the material.
  50673. */
  50674. BackgroundMaterial.prototype.buildUniformLayout = function () {
  50675. // Order is important !
  50676. this._uniformBuffer.addUniform("vPrimaryColor", 4);
  50677. this._uniformBuffer.addUniform("vPrimaryColorShadow", 4);
  50678. this._uniformBuffer.addUniform("vDiffuseInfos", 2);
  50679. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  50680. this._uniformBuffer.addUniform("diffuseMatrix", 16);
  50681. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  50682. this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos", 3);
  50683. this._uniformBuffer.addUniform("fFovMultiplier", 1);
  50684. this._uniformBuffer.addUniform("pointSize", 1);
  50685. this._uniformBuffer.addUniform("shadowLevel", 1);
  50686. this._uniformBuffer.addUniform("alpha", 1);
  50687. this._uniformBuffer.addUniform("vBackgroundCenter", 3);
  50688. this._uniformBuffer.addUniform("vReflectionControl", 4);
  50689. this._uniformBuffer.create();
  50690. };
  50691. /**
  50692. * Unbind the material.
  50693. */
  50694. BackgroundMaterial.prototype.unbind = function () {
  50695. if (this._diffuseTexture && this._diffuseTexture.isRenderTarget) {
  50696. this._uniformBuffer.setTexture("diffuseSampler", null);
  50697. }
  50698. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  50699. this._uniformBuffer.setTexture("reflectionSampler", null);
  50700. }
  50701. _super.prototype.unbind.call(this);
  50702. };
  50703. /**
  50704. * Bind only the world matrix to the material.
  50705. * @param world The world matrix to bind.
  50706. */
  50707. BackgroundMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  50708. this._activeEffect.setMatrix("world", world);
  50709. };
  50710. /**
  50711. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  50712. * @param world The world matrix to bind.
  50713. * @param subMesh The submesh to bind for.
  50714. */
  50715. BackgroundMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  50716. var scene = this.getScene();
  50717. var defines = subMesh._materialDefines;
  50718. if (!defines) {
  50719. return;
  50720. }
  50721. var effect = subMesh.effect;
  50722. if (!effect) {
  50723. return;
  50724. }
  50725. this._activeEffect = effect;
  50726. // Matrices
  50727. this.bindOnlyWorldMatrix(world);
  50728. // Bones
  50729. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
  50730. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  50731. if (mustRebind) {
  50732. this._uniformBuffer.bindToEffect(effect, "Material");
  50733. this.bindViewProjection(effect);
  50734. var reflectionTexture = this._reflectionTexture;
  50735. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  50736. // Texture uniforms
  50737. if (scene.texturesEnabled) {
  50738. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  50739. this._uniformBuffer.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
  50740. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindTextureMatrix(this._diffuseTexture, this._uniformBuffer, "diffuse");
  50741. }
  50742. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  50743. this._uniformBuffer.updateMatrix("reflectionMatrix", reflectionTexture.getReflectionTextureMatrix());
  50744. this._uniformBuffer.updateFloat2("vReflectionInfos", reflectionTexture.level, this._reflectionBlur);
  50745. this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos", reflectionTexture.getSize().width, reflectionTexture.lodGenerationScale, reflectionTexture.lodGenerationOffset);
  50746. }
  50747. }
  50748. if (this.shadowLevel > 0) {
  50749. this._uniformBuffer.updateFloat("shadowLevel", this.shadowLevel);
  50750. }
  50751. this._uniformBuffer.updateFloat("alpha", this.alpha);
  50752. // Point size
  50753. if (this.pointsCloud) {
  50754. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  50755. }
  50756. if (defines.USEHIGHLIGHTANDSHADOWCOLORS) {
  50757. this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryHighlightColor, 1.0);
  50758. this._uniformBuffer.updateColor4("vPrimaryColorShadow", this._primaryShadowColor, 1.0);
  50759. }
  50760. else {
  50761. this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryColor, 1.0);
  50762. }
  50763. }
  50764. this._uniformBuffer.updateFloat("fFovMultiplier", this._fovMultiplier);
  50765. // Textures
  50766. if (scene.texturesEnabled) {
  50767. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  50768. this._uniformBuffer.setTexture("diffuseSampler", this._diffuseTexture);
  50769. }
  50770. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  50771. if (defines.REFLECTIONBLUR && defines.TEXTURELODSUPPORT) {
  50772. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  50773. }
  50774. else if (!defines.REFLECTIONBLUR) {
  50775. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  50776. }
  50777. else {
  50778. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture._lodTextureMid || reflectionTexture);
  50779. this._uniformBuffer.setTexture("reflectionSamplerLow", reflectionTexture._lodTextureLow || reflectionTexture);
  50780. this._uniformBuffer.setTexture("reflectionSamplerHigh", reflectionTexture._lodTextureHigh || reflectionTexture);
  50781. }
  50782. if (defines.REFLECTIONFRESNEL) {
  50783. this._uniformBuffer.updateFloat3("vBackgroundCenter", this.sceneCenter.x, this.sceneCenter.y, this.sceneCenter.z);
  50784. this._uniformBuffer.updateFloat4("vReflectionControl", this._reflectionControls.x, this._reflectionControls.y, this._reflectionControls.z, this._reflectionControls.w);
  50785. }
  50786. }
  50787. }
  50788. // Clip plane
  50789. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
  50790. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindEyePosition(effect, scene);
  50791. }
  50792. if (mustRebind || !this.isFrozen) {
  50793. if (scene.lightsEnabled) {
  50794. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights, false);
  50795. }
  50796. // View
  50797. this.bindView(effect);
  50798. // Fog
  50799. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect, true);
  50800. // image processing
  50801. if (this._imageProcessingConfiguration) {
  50802. this._imageProcessingConfiguration.bind(this._activeEffect);
  50803. }
  50804. }
  50805. this._uniformBuffer.update();
  50806. this._afterBind(mesh, this._activeEffect);
  50807. };
  50808. /**
  50809. * Dispose the material.
  50810. * @param forceDisposeEffect Force disposal of the associated effect.
  50811. * @param forceDisposeTextures Force disposal of the associated textures.
  50812. */
  50813. BackgroundMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  50814. if (forceDisposeEffect === void 0) { forceDisposeEffect = false; }
  50815. if (forceDisposeTextures === void 0) { forceDisposeTextures = false; }
  50816. if (forceDisposeTextures) {
  50817. if (this.diffuseTexture) {
  50818. this.diffuseTexture.dispose();
  50819. }
  50820. if (this.reflectionTexture) {
  50821. this.reflectionTexture.dispose();
  50822. }
  50823. }
  50824. this._renderTargets.dispose();
  50825. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  50826. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  50827. }
  50828. _super.prototype.dispose.call(this, forceDisposeEffect);
  50829. };
  50830. /**
  50831. * Clones the material.
  50832. * @param name The cloned name.
  50833. * @returns The cloned material.
  50834. */
  50835. BackgroundMaterial.prototype.clone = function (name) {
  50836. var _this = this;
  50837. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new BackgroundMaterial(name, _this.getScene()); }, this);
  50838. };
  50839. /**
  50840. * Serializes the current material to its JSON representation.
  50841. * @returns The JSON representation.
  50842. */
  50843. BackgroundMaterial.prototype.serialize = function () {
  50844. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  50845. serializationObject.customType = "BABYLON.BackgroundMaterial";
  50846. return serializationObject;
  50847. };
  50848. /**
  50849. * Gets the class name of the material
  50850. * @returns "BackgroundMaterial"
  50851. */
  50852. BackgroundMaterial.prototype.getClassName = function () {
  50853. return "BackgroundMaterial";
  50854. };
  50855. /**
  50856. * Parse a JSON input to create back a background material.
  50857. * @param source The JSON data to parse
  50858. * @param scene The scene to create the parsed material in
  50859. * @param rootUrl The root url of the assets the material depends upon
  50860. * @returns the instantiated BackgroundMaterial.
  50861. */
  50862. BackgroundMaterial.Parse = function (source, scene, rootUrl) {
  50863. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new BackgroundMaterial(source.name, scene); }, source, scene, rootUrl);
  50864. };
  50865. /**
  50866. * Standard reflectance value at parallel view angle.
  50867. */
  50868. BackgroundMaterial.StandardReflectance0 = 0.05;
  50869. /**
  50870. * Standard reflectance value at grazing angle.
  50871. */
  50872. BackgroundMaterial.StandardReflectance90 = 0.5;
  50873. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50874. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  50875. ], BackgroundMaterial.prototype, "_primaryColor", void 0);
  50876. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50877. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  50878. ], BackgroundMaterial.prototype, "primaryColor", void 0);
  50879. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50880. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  50881. ], BackgroundMaterial.prototype, "__perceptualColor", void 0);
  50882. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50883. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50884. ], BackgroundMaterial.prototype, "_primaryColorShadowLevel", void 0);
  50885. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50886. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50887. ], BackgroundMaterial.prototype, "_primaryColorHighlightLevel", void 0);
  50888. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50889. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  50890. ], BackgroundMaterial.prototype, "primaryColorHighlightLevel", null);
  50891. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50892. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  50893. ], BackgroundMaterial.prototype, "_reflectionTexture", void 0);
  50894. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50895. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50896. ], BackgroundMaterial.prototype, "reflectionTexture", void 0);
  50897. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50898. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50899. ], BackgroundMaterial.prototype, "_reflectionBlur", void 0);
  50900. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50901. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50902. ], BackgroundMaterial.prototype, "reflectionBlur", void 0);
  50903. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50904. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  50905. ], BackgroundMaterial.prototype, "_diffuseTexture", void 0);
  50906. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50907. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50908. ], BackgroundMaterial.prototype, "diffuseTexture", void 0);
  50909. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50910. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50911. ], BackgroundMaterial.prototype, "shadowLights", void 0);
  50912. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50913. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50914. ], BackgroundMaterial.prototype, "_shadowLevel", void 0);
  50915. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50916. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50917. ], BackgroundMaterial.prototype, "shadowLevel", void 0);
  50918. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50919. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  50920. ], BackgroundMaterial.prototype, "_sceneCenter", void 0);
  50921. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50922. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50923. ], BackgroundMaterial.prototype, "sceneCenter", void 0);
  50924. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50925. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50926. ], BackgroundMaterial.prototype, "_opacityFresnel", void 0);
  50927. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50928. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50929. ], BackgroundMaterial.prototype, "opacityFresnel", void 0);
  50930. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50931. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50932. ], BackgroundMaterial.prototype, "_reflectionFresnel", void 0);
  50933. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50934. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50935. ], BackgroundMaterial.prototype, "reflectionFresnel", void 0);
  50936. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50937. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50938. ], BackgroundMaterial.prototype, "_reflectionFalloffDistance", void 0);
  50939. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50940. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50941. ], BackgroundMaterial.prototype, "reflectionFalloffDistance", void 0);
  50942. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50943. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50944. ], BackgroundMaterial.prototype, "_reflectionAmount", void 0);
  50945. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50946. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50947. ], BackgroundMaterial.prototype, "reflectionAmount", void 0);
  50948. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50949. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50950. ], BackgroundMaterial.prototype, "_reflectionReflectance0", void 0);
  50951. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50952. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50953. ], BackgroundMaterial.prototype, "reflectionReflectance0", void 0);
  50954. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50955. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50956. ], BackgroundMaterial.prototype, "_reflectionReflectance90", void 0);
  50957. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50958. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50959. ], BackgroundMaterial.prototype, "reflectionReflectance90", void 0);
  50960. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50961. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50962. ], BackgroundMaterial.prototype, "_useRGBColor", void 0);
  50963. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50964. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50965. ], BackgroundMaterial.prototype, "useRGBColor", void 0);
  50966. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50967. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50968. ], BackgroundMaterial.prototype, "_enableNoise", void 0);
  50969. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50970. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50971. ], BackgroundMaterial.prototype, "enableNoise", void 0);
  50972. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50973. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50974. ], BackgroundMaterial.prototype, "_maxSimultaneousLights", void 0);
  50975. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50976. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50977. ], BackgroundMaterial.prototype, "maxSimultaneousLights", void 0);
  50978. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50979. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsImageProcessingConfiguration"])()
  50980. ], BackgroundMaterial.prototype, "_imageProcessingConfiguration", void 0);
  50981. return BackgroundMaterial;
  50982. }(_Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_9__["PushMaterial"]));
  50983. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_13__["_TypeStore"].RegisteredTypes["BABYLON.BackgroundMaterial"] = BackgroundMaterial;
  50984. /***/ }),
  50985. /***/ "./Materials/Background/index.ts":
  50986. /*!***************************************!*\
  50987. !*** ./Materials/Background/index.ts ***!
  50988. \***************************************/
  50989. /*! exports provided: BackgroundMaterial */
  50990. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  50991. "use strict";
  50992. __webpack_require__.r(__webpack_exports__);
  50993. /* harmony import */ var _backgroundMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  50994. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _backgroundMaterial__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  50995. /***/ }),
  50996. /***/ "./Materials/PBR/index.ts":
  50997. /*!********************************!*\
  50998. !*** ./Materials/PBR/index.ts ***!
  50999. \********************************/
  51000. /*! exports provided: PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial */
  51001. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51002. "use strict";
  51003. __webpack_require__.r(__webpack_exports__);
  51004. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  51005. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_0__["PBRBaseMaterial"]; });
  51006. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  51007. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_1__["PBRBaseSimpleMaterial"]; });
  51008. /* harmony import */ var _pbrMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrMaterial */ "./Materials/PBR/pbrMaterial.ts");
  51009. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _pbrMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRMaterial"]; });
  51010. /* harmony import */ var _pbrMetallicRoughnessMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pbrMetallicRoughnessMaterial */ "./Materials/PBR/pbrMetallicRoughnessMaterial.ts");
  51011. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _pbrMetallicRoughnessMaterial__WEBPACK_IMPORTED_MODULE_3__["PBRMetallicRoughnessMaterial"]; });
  51012. /* harmony import */ var _pbrSpecularGlossinessMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pbrSpecularGlossinessMaterial */ "./Materials/PBR/pbrSpecularGlossinessMaterial.ts");
  51013. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _pbrSpecularGlossinessMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRSpecularGlossinessMaterial"]; });
  51014. /***/ }),
  51015. /***/ "./Materials/PBR/pbrAnisotropicConfiguration.ts":
  51016. /*!******************************************************!*\
  51017. !*** ./Materials/PBR/pbrAnisotropicConfiguration.ts ***!
  51018. \******************************************************/
  51019. /*! exports provided: PBRAnisotropicConfiguration */
  51020. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51021. "use strict";
  51022. __webpack_require__.r(__webpack_exports__);
  51023. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRAnisotropicConfiguration", function() { return PBRAnisotropicConfiguration; });
  51024. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  51025. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  51026. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  51027. /**
  51028. * Define the code related to the anisotropic parameters of the pbr material.
  51029. */
  51030. var PBRAnisotropicConfiguration = /** @class */ (function () {
  51031. /**
  51032. * Instantiate a new istance of clear coat configuration.
  51033. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  51034. */
  51035. function PBRAnisotropicConfiguration(markAllSubMeshesAsMiscDirty) {
  51036. this._isEnabled = false;
  51037. /**
  51038. * Defines if the anisotropy is enabled in the material.
  51039. */
  51040. this.isEnabled = false;
  51041. /**
  51042. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  51043. */
  51044. this.intensity = 1;
  51045. /**
  51046. * Defines if the effect is along the tangents or bitangents.
  51047. * By default, the effect is "strectching" the highlights along the tangents.
  51048. */
  51049. this.followTangents = true;
  51050. this._internalMarkAllSubMeshesAsMiscDirty = markAllSubMeshesAsMiscDirty;
  51051. }
  51052. /** @hidden */
  51053. PBRAnisotropicConfiguration.prototype._markAllSubMeshesAsMiscDirty = function () {
  51054. this._internalMarkAllSubMeshesAsMiscDirty();
  51055. };
  51056. /**
  51057. * Checks to see if a texture is used in the material.
  51058. * @param defines the list of "defines" to update.
  51059. * @param mesh the mesh we are preparing the defines for.
  51060. */
  51061. PBRAnisotropicConfiguration.prototype.prepareDefines = function (defines, mesh) {
  51062. defines.ANISOTROPIC = this._isEnabled;
  51063. if (this._isEnabled && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind)) {
  51064. defines._needUVs = true;
  51065. defines.MAINUV1 = true;
  51066. }
  51067. };
  51068. /**
  51069. * Binds the material data.
  51070. * @param uniformBuffer defines the Uniform buffer to fill in.
  51071. * @param isFrozen defines wether the material is frozen or not.
  51072. */
  51073. PBRAnisotropicConfiguration.prototype.bindForSubMesh = function (uniformBuffer, isFrozen) {
  51074. if (!uniformBuffer.useUbo || !isFrozen || !uniformBuffer.isSync) {
  51075. // Clear Coat
  51076. uniformBuffer.updateFloat("anisotropy", this.followTangents ? this.intensity : -this.intensity);
  51077. }
  51078. };
  51079. /**
  51080. * Get the current class name of the texture useful for serialization or dynamic coding.
  51081. * @returns "PBRAnisotropicConfiguration"
  51082. */
  51083. PBRAnisotropicConfiguration.prototype.getClassName = function () {
  51084. return "PBRAnisotropicConfiguration";
  51085. };
  51086. /**
  51087. * Makes a duplicate of the current configuration into another one.
  51088. * @param anisotropicConfiguration define the config where to copy the info
  51089. */
  51090. PBRAnisotropicConfiguration.prototype.copyTo = function (anisotropicConfiguration) {
  51091. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return anisotropicConfiguration; }, this);
  51092. };
  51093. /**
  51094. * Serializes this clear coat configuration.
  51095. * @returns - An object with the serialized config.
  51096. */
  51097. PBRAnisotropicConfiguration.prototype.serialize = function () {
  51098. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  51099. };
  51100. /**
  51101. * Parses a Clear Coat Configuration from a serialized object.
  51102. * @param source - Serialized object.
  51103. */
  51104. PBRAnisotropicConfiguration.prototype.parse = function (source) {
  51105. var _this = this;
  51106. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, null);
  51107. };
  51108. /**
  51109. * Add fallbacks to the effect fallbacks list.
  51110. * @param defines defines the Base texture to use.
  51111. * @param fallbacks defines the current fallback list.
  51112. * @param currentRank defines the current fallback rank.
  51113. * @returns the new fallback rank.
  51114. */
  51115. PBRAnisotropicConfiguration.AddFallbacks = function (defines, fallbacks, currentRank) {
  51116. if (defines.ANISOTROPIC) {
  51117. fallbacks.addFallback(currentRank++, "ANISOTROPIC");
  51118. }
  51119. return currentRank;
  51120. };
  51121. /**
  51122. * Add the required uniforms to the current list.
  51123. * @param uniforms defines the current uniform list.
  51124. */
  51125. PBRAnisotropicConfiguration.AddUniforms = function (uniforms) {
  51126. uniforms.push("anisotropy");
  51127. };
  51128. /**
  51129. * Add the required uniforms to the current buffer.
  51130. * @param uniformBuffer defines the current uniform buffer.
  51131. */
  51132. PBRAnisotropicConfiguration.PrepareUniformBuffer = function (uniformBuffer) {
  51133. uniformBuffer.addUniform("anisotropy", 1);
  51134. };
  51135. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51136. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51137. ], PBRAnisotropicConfiguration.prototype, "_isEnabled", void 0);
  51138. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51139. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  51140. ], PBRAnisotropicConfiguration.prototype, "isEnabled", void 0);
  51141. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51142. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51143. ], PBRAnisotropicConfiguration.prototype, "intensity", void 0);
  51144. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51145. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51146. ], PBRAnisotropicConfiguration.prototype, "followTangents", void 0);
  51147. return PBRAnisotropicConfiguration;
  51148. }());
  51149. /***/ }),
  51150. /***/ "./Materials/PBR/pbrBRDFConfiguration.ts":
  51151. /*!***********************************************!*\
  51152. !*** ./Materials/PBR/pbrBRDFConfiguration.ts ***!
  51153. \***********************************************/
  51154. /*! exports provided: PBRBRDFConfiguration */
  51155. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51156. "use strict";
  51157. __webpack_require__.r(__webpack_exports__);
  51158. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBRDFConfiguration", function() { return PBRBRDFConfiguration; });
  51159. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  51160. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  51161. /**
  51162. * Define the code related to the BRDF parameters of the pbr material.
  51163. */
  51164. var PBRBRDFConfiguration = /** @class */ (function () {
  51165. /**
  51166. * Instantiate a new istance of clear coat configuration.
  51167. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  51168. */
  51169. function PBRBRDFConfiguration(markAllSubMeshesAsMiscDirty) {
  51170. this._useEnergyConservation = true;
  51171. /**
  51172. * Defines if the material uses energy conservation.
  51173. */
  51174. this.useEnergyConservation = true;
  51175. this._useSmithVisibilityHeightCorrelated = true;
  51176. /**
  51177. * LEGACY Mode set to false
  51178. * Defines if the material uses height smith correlated visibility term.
  51179. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  51180. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  51181. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  51182. * Not relying on height correlated will also disable energy conservation.
  51183. */
  51184. this.useSmithVisibilityHeightCorrelated = true;
  51185. this._internalMarkAllSubMeshesAsMiscDirty = markAllSubMeshesAsMiscDirty;
  51186. }
  51187. /** @hidden */
  51188. PBRBRDFConfiguration.prototype._markAllSubMeshesAsMiscDirty = function () {
  51189. this._internalMarkAllSubMeshesAsMiscDirty();
  51190. };
  51191. /**
  51192. * Checks to see if a texture is used in the material.
  51193. * @param defines the list of "defines" to update.
  51194. */
  51195. PBRBRDFConfiguration.prototype.prepareDefines = function (defines) {
  51196. defines.BRDF_V_HEIGHT_CORRELATED = this._useSmithVisibilityHeightCorrelated;
  51197. defines.MS_BRDF_ENERGY_CONSERVATION = this._useEnergyConservation && this._useSmithVisibilityHeightCorrelated;
  51198. };
  51199. /**
  51200. * Get the current class name of the texture useful for serialization or dynamic coding.
  51201. * @returns "PBRClearCoatConfiguration"
  51202. */
  51203. PBRBRDFConfiguration.prototype.getClassName = function () {
  51204. return "PBRClearCoatConfiguration";
  51205. };
  51206. /**
  51207. * Makes a duplicate of the current configuration into another one.
  51208. * @param brdfConfiguration define the config where to copy the info
  51209. */
  51210. PBRBRDFConfiguration.prototype.copyTo = function (brdfConfiguration) {
  51211. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return brdfConfiguration; }, this);
  51212. };
  51213. /**
  51214. * Serializes this BRDF configuration.
  51215. * @returns - An object with the serialized config.
  51216. */
  51217. PBRBRDFConfiguration.prototype.serialize = function () {
  51218. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  51219. };
  51220. /**
  51221. * Parses a BRDF Configuration from a serialized object.
  51222. * @param source - Serialized object.
  51223. */
  51224. PBRBRDFConfiguration.prototype.parse = function (source) {
  51225. var _this = this;
  51226. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, null);
  51227. };
  51228. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51229. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51230. ], PBRBRDFConfiguration.prototype, "_useEnergyConservation", void 0);
  51231. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51232. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  51233. ], PBRBRDFConfiguration.prototype, "useEnergyConservation", void 0);
  51234. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51235. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51236. ], PBRBRDFConfiguration.prototype, "_useSmithVisibilityHeightCorrelated", void 0);
  51237. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51238. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  51239. ], PBRBRDFConfiguration.prototype, "useSmithVisibilityHeightCorrelated", void 0);
  51240. return PBRBRDFConfiguration;
  51241. }());
  51242. /***/ }),
  51243. /***/ "./Materials/PBR/pbrBaseMaterial.ts":
  51244. /*!******************************************!*\
  51245. !*** ./Materials/PBR/pbrBaseMaterial.ts ***!
  51246. \******************************************/
  51247. /*! exports provided: PBRBaseMaterial */
  51248. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51249. "use strict";
  51250. __webpack_require__.r(__webpack_exports__);
  51251. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return PBRBaseMaterial; });
  51252. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  51253. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  51254. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  51255. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  51256. /* harmony import */ var _Misc_textureTools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/textureTools */ "./Misc/textureTools.ts");
  51257. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  51258. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  51259. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  51260. /* harmony import */ var _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./pbrClearCoatConfiguration */ "./Materials/PBR/pbrClearCoatConfiguration.ts");
  51261. /* harmony import */ var _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./pbrAnisotropicConfiguration */ "./Materials/PBR/pbrAnisotropicConfiguration.ts");
  51262. /* harmony import */ var _pbrBRDFConfiguration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./pbrBRDFConfiguration */ "./Materials/PBR/pbrBRDFConfiguration.ts");
  51263. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  51264. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  51265. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Materials/materialDefines */ "./Materials/materialDefines.ts");
  51266. /* harmony import */ var _Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Materials/pushMaterial */ "./Materials/pushMaterial.ts");
  51267. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  51268. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  51269. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  51270. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  51271. /* harmony import */ var _Shaders_pbr_fragment__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../Shaders/pbr.fragment */ "./Shaders/pbr.fragment.ts");
  51272. /* harmony import */ var _Shaders_pbr_vertex__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Shaders/pbr.vertex */ "./Shaders/pbr.vertex.ts");
  51273. /**
  51274. * Manages the defines for the PBR Material.
  51275. * @hiddenChildren
  51276. */
  51277. var PBRMaterialDefines = /** @class */ (function (_super) {
  51278. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMaterialDefines, _super);
  51279. /**
  51280. * Initializes the PBR Material defines.
  51281. */
  51282. function PBRMaterialDefines() {
  51283. var _this = _super.call(this) || this;
  51284. _this.PBR = true;
  51285. _this.MAINUV1 = false;
  51286. _this.MAINUV2 = false;
  51287. _this.UV1 = false;
  51288. _this.UV2 = false;
  51289. _this.ALBEDO = false;
  51290. _this.ALBEDODIRECTUV = 0;
  51291. _this.VERTEXCOLOR = false;
  51292. _this.AMBIENT = false;
  51293. _this.AMBIENTDIRECTUV = 0;
  51294. _this.AMBIENTINGRAYSCALE = false;
  51295. _this.OPACITY = false;
  51296. _this.VERTEXALPHA = false;
  51297. _this.OPACITYDIRECTUV = 0;
  51298. _this.OPACITYRGB = false;
  51299. _this.ALPHATEST = false;
  51300. _this.DEPTHPREPASS = false;
  51301. _this.ALPHABLEND = false;
  51302. _this.ALPHAFROMALBEDO = false;
  51303. _this.ALPHATESTVALUE = "0.5";
  51304. _this.SPECULAROVERALPHA = false;
  51305. _this.RADIANCEOVERALPHA = false;
  51306. _this.ALPHAFRESNEL = false;
  51307. _this.LINEARALPHAFRESNEL = false;
  51308. _this.PREMULTIPLYALPHA = false;
  51309. _this.EMISSIVE = false;
  51310. _this.EMISSIVEDIRECTUV = 0;
  51311. _this.REFLECTIVITY = false;
  51312. _this.REFLECTIVITYDIRECTUV = 0;
  51313. _this.SPECULARTERM = false;
  51314. _this.MICROSURFACEFROMREFLECTIVITYMAP = false;
  51315. _this.MICROSURFACEAUTOMATIC = false;
  51316. _this.LODBASEDMICROSFURACE = false;
  51317. _this.MICROSURFACEMAP = false;
  51318. _this.MICROSURFACEMAPDIRECTUV = 0;
  51319. _this.METALLICWORKFLOW = false;
  51320. _this.ROUGHNESSSTOREINMETALMAPALPHA = false;
  51321. _this.ROUGHNESSSTOREINMETALMAPGREEN = false;
  51322. _this.METALLNESSSTOREINMETALMAPBLUE = false;
  51323. _this.AOSTOREINMETALMAPRED = false;
  51324. _this.ENVIRONMENTBRDF = false;
  51325. _this.NORMAL = false;
  51326. _this.TANGENT = false;
  51327. _this.BUMP = false;
  51328. _this.BUMPDIRECTUV = 0;
  51329. _this.OBJECTSPACE_NORMALMAP = false;
  51330. _this.PARALLAX = false;
  51331. _this.PARALLAXOCCLUSION = false;
  51332. _this.NORMALXYSCALE = true;
  51333. _this.LIGHTMAP = false;
  51334. _this.LIGHTMAPDIRECTUV = 0;
  51335. _this.USELIGHTMAPASSHADOWMAP = false;
  51336. _this.GAMMALIGHTMAP = false;
  51337. _this.REFLECTION = false;
  51338. _this.REFLECTIONMAP_3D = false;
  51339. _this.REFLECTIONMAP_SPHERICAL = false;
  51340. _this.REFLECTIONMAP_PLANAR = false;
  51341. _this.REFLECTIONMAP_CUBIC = false;
  51342. _this.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  51343. _this.REFLECTIONMAP_PROJECTION = false;
  51344. _this.REFLECTIONMAP_SKYBOX = false;
  51345. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  51346. _this.REFLECTIONMAP_EXPLICIT = false;
  51347. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  51348. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  51349. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  51350. _this.INVERTCUBICMAP = false;
  51351. _this.USESPHERICALFROMREFLECTIONMAP = false;
  51352. _this.USESPHERICALINVERTEX = false;
  51353. _this.REFLECTIONMAP_OPPOSITEZ = false;
  51354. _this.LODINREFLECTIONALPHA = false;
  51355. _this.GAMMAREFLECTION = false;
  51356. _this.RGBDREFLECTION = false;
  51357. _this.RADIANCEOCCLUSION = false;
  51358. _this.HORIZONOCCLUSION = false;
  51359. _this.REFRACTION = false;
  51360. _this.REFRACTIONMAP_3D = false;
  51361. _this.REFRACTIONMAP_OPPOSITEZ = false;
  51362. _this.LODINREFRACTIONALPHA = false;
  51363. _this.GAMMAREFRACTION = false;
  51364. _this.RGBDREFRACTION = false;
  51365. _this.LINKREFRACTIONTOTRANSPARENCY = false;
  51366. _this.INSTANCES = false;
  51367. _this.NUM_BONE_INFLUENCERS = 0;
  51368. _this.BonesPerMesh = 0;
  51369. _this.BONETEXTURE = false;
  51370. _this.NONUNIFORMSCALING = false;
  51371. _this.MORPHTARGETS = false;
  51372. _this.MORPHTARGETS_NORMAL = false;
  51373. _this.MORPHTARGETS_TANGENT = false;
  51374. _this.NUM_MORPH_INFLUENCERS = 0;
  51375. _this.IMAGEPROCESSING = false;
  51376. _this.VIGNETTE = false;
  51377. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  51378. _this.VIGNETTEBLENDMODEOPAQUE = false;
  51379. _this.TONEMAPPING = false;
  51380. _this.TONEMAPPING_ACES = false;
  51381. _this.CONTRAST = false;
  51382. _this.COLORCURVES = false;
  51383. _this.COLORGRADING = false;
  51384. _this.COLORGRADING3D = false;
  51385. _this.SAMPLER3DGREENDEPTH = false;
  51386. _this.SAMPLER3DBGRMAP = false;
  51387. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  51388. _this.EXPOSURE = false;
  51389. _this.USEPHYSICALLIGHTFALLOFF = false;
  51390. _this.USEGLTFLIGHTFALLOFF = false;
  51391. _this.TWOSIDEDLIGHTING = false;
  51392. _this.SHADOWFLOAT = false;
  51393. _this.CLIPPLANE = false;
  51394. _this.CLIPPLANE2 = false;
  51395. _this.CLIPPLANE3 = false;
  51396. _this.CLIPPLANE4 = false;
  51397. _this.POINTSIZE = false;
  51398. _this.FOG = false;
  51399. _this.LOGARITHMICDEPTH = false;
  51400. _this.FORCENORMALFORWARD = false;
  51401. _this.SPECULARAA = false;
  51402. _this.CLEARCOAT = false;
  51403. _this.CLEARCOAT_DEFAULTIOR = false;
  51404. _this.CLEARCOAT_TEXTURE = false;
  51405. _this.CLEARCOAT_TEXTUREDIRECTUV = 0;
  51406. _this.CLEARCOAT_BUMP = false;
  51407. _this.CLEARCOAT_BUMPDIRECTUV = 0;
  51408. _this.CLEARCOAT_TINT = false;
  51409. _this.CLEARCOAT_TINT_TEXTURE = false;
  51410. _this.CLEARCOAT_TINT_TEXTUREDIRECTUV = 0;
  51411. _this.ANISOTROPIC = false;
  51412. _this.BRDF_V_HEIGHT_CORRELATED = false;
  51413. _this.MS_BRDF_ENERGY_CONSERVATION = false;
  51414. _this.UNLIT = false;
  51415. _this.DEBUGMODE = 0;
  51416. _this.rebuild();
  51417. return _this;
  51418. }
  51419. /**
  51420. * Resets the PBR Material defines.
  51421. */
  51422. PBRMaterialDefines.prototype.reset = function () {
  51423. _super.prototype.reset.call(this);
  51424. this.ALPHATESTVALUE = "0.5";
  51425. this.PBR = true;
  51426. };
  51427. return PBRMaterialDefines;
  51428. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_13__["MaterialDefines"]));
  51429. /**
  51430. * The Physically based material base class of BJS.
  51431. *
  51432. * This offers the main features of a standard PBR material.
  51433. * For more information, please refer to the documentation :
  51434. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  51435. */
  51436. var PBRBaseMaterial = /** @class */ (function (_super) {
  51437. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRBaseMaterial, _super);
  51438. /**
  51439. * Instantiates a new PBRMaterial instance.
  51440. *
  51441. * @param name The material name
  51442. * @param scene The scene the material will be use in.
  51443. */
  51444. function PBRBaseMaterial(name, scene) {
  51445. var _this = _super.call(this, name, scene) || this;
  51446. /**
  51447. * Intensity of the direct lights e.g. the four lights available in your scene.
  51448. * This impacts both the direct diffuse and specular highlights.
  51449. */
  51450. _this._directIntensity = 1.0;
  51451. /**
  51452. * Intensity of the emissive part of the material.
  51453. * This helps controlling the emissive effect without modifying the emissive color.
  51454. */
  51455. _this._emissiveIntensity = 1.0;
  51456. /**
  51457. * Intensity of the environment e.g. how much the environment will light the object
  51458. * either through harmonics for rough material or through the refelction for shiny ones.
  51459. */
  51460. _this._environmentIntensity = 1.0;
  51461. /**
  51462. * This is a special control allowing the reduction of the specular highlights coming from the
  51463. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51464. */
  51465. _this._specularIntensity = 1.0;
  51466. /**
  51467. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51468. */
  51469. _this._lightingInfos = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Vector4"](_this._directIntensity, _this._emissiveIntensity, _this._environmentIntensity, _this._specularIntensity);
  51470. /**
  51471. * Debug Control allowing disabling the bump map on this material.
  51472. */
  51473. _this._disableBumpMap = false;
  51474. /**
  51475. * AKA Occlusion Texture Intensity in other nomenclature.
  51476. */
  51477. _this._ambientTextureStrength = 1.0;
  51478. /**
  51479. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51480. * 1 means it completely occludes it
  51481. * 0 mean it has no impact
  51482. */
  51483. _this._ambientTextureImpactOnAnalyticalLights = PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  51484. /**
  51485. * The color of a material in ambient lighting.
  51486. */
  51487. _this._ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  51488. /**
  51489. * AKA Diffuse Color in other nomenclature.
  51490. */
  51491. _this._albedoColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  51492. /**
  51493. * AKA Specular Color in other nomenclature.
  51494. */
  51495. _this._reflectivityColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  51496. /**
  51497. * The color applied when light is reflected from a material.
  51498. */
  51499. _this._reflectionColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  51500. /**
  51501. * The color applied when light is emitted from a material.
  51502. */
  51503. _this._emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  51504. /**
  51505. * AKA Glossiness in other nomenclature.
  51506. */
  51507. _this._microSurface = 0.9;
  51508. /**
  51509. * source material index of refraction (IOR)' / 'destination material IOR.
  51510. */
  51511. _this._indexOfRefraction = 0.66;
  51512. /**
  51513. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51514. */
  51515. _this._invertRefractionY = false;
  51516. /**
  51517. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51518. * Materials half opaque for instance using refraction could benefit from this control.
  51519. */
  51520. _this._linkRefractionWithTransparency = false;
  51521. /**
  51522. * Specifies that the material will use the light map as a show map.
  51523. */
  51524. _this._useLightmapAsShadowmap = false;
  51525. /**
  51526. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51527. * makes the reflect vector face the model (under horizon).
  51528. */
  51529. _this._useHorizonOcclusion = true;
  51530. /**
  51531. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51532. * too much the area relying on ambient texture to define their ambient occlusion.
  51533. */
  51534. _this._useRadianceOcclusion = true;
  51535. /**
  51536. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51537. */
  51538. _this._useAlphaFromAlbedoTexture = false;
  51539. /**
  51540. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51541. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51542. */
  51543. _this._useSpecularOverAlpha = true;
  51544. /**
  51545. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51546. */
  51547. _this._useMicroSurfaceFromReflectivityMapAlpha = false;
  51548. /**
  51549. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51550. */
  51551. _this._useRoughnessFromMetallicTextureAlpha = true;
  51552. /**
  51553. * Specifies if the metallic texture contains the roughness information in its green channel.
  51554. */
  51555. _this._useRoughnessFromMetallicTextureGreen = false;
  51556. /**
  51557. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51558. */
  51559. _this._useMetallnessFromMetallicTextureBlue = false;
  51560. /**
  51561. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51562. */
  51563. _this._useAmbientOcclusionFromMetallicTextureRed = false;
  51564. /**
  51565. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51566. */
  51567. _this._useAmbientInGrayScale = false;
  51568. /**
  51569. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51570. * The material will try to infer what glossiness each pixel should be.
  51571. */
  51572. _this._useAutoMicroSurfaceFromReflectivityMap = false;
  51573. /**
  51574. * Defines the falloff type used in this material.
  51575. * It by default is Physical.
  51576. */
  51577. _this._lightFalloff = PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL;
  51578. /**
  51579. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51580. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51581. */
  51582. _this._useRadianceOverAlpha = true;
  51583. /**
  51584. * Allows using an object space normal map (instead of tangent space).
  51585. */
  51586. _this._useObjectSpaceNormalMap = false;
  51587. /**
  51588. * Allows using the bump map in parallax mode.
  51589. */
  51590. _this._useParallax = false;
  51591. /**
  51592. * Allows using the bump map in parallax occlusion mode.
  51593. */
  51594. _this._useParallaxOcclusion = false;
  51595. /**
  51596. * Controls the scale bias of the parallax mode.
  51597. */
  51598. _this._parallaxScaleBias = 0.05;
  51599. /**
  51600. * If sets to true, disables all the lights affecting the material.
  51601. */
  51602. _this._disableLighting = false;
  51603. /**
  51604. * Number of Simultaneous lights allowed on the material.
  51605. */
  51606. _this._maxSimultaneousLights = 4;
  51607. /**
  51608. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51609. */
  51610. _this._invertNormalMapX = false;
  51611. /**
  51612. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51613. */
  51614. _this._invertNormalMapY = false;
  51615. /**
  51616. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51617. */
  51618. _this._twoSidedLighting = false;
  51619. /**
  51620. * Defines the alpha limits in alpha test mode.
  51621. */
  51622. _this._alphaCutOff = 0.4;
  51623. /**
  51624. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51625. */
  51626. _this._forceAlphaTest = false;
  51627. /**
  51628. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51629. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51630. */
  51631. _this._useAlphaFresnel = false;
  51632. /**
  51633. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51634. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51635. */
  51636. _this._useLinearAlphaFresnel = false;
  51637. /**
  51638. * The transparency mode of the material.
  51639. */
  51640. _this._transparencyMode = null;
  51641. /**
  51642. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  51643. * from cos thetav and roughness:
  51644. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  51645. */
  51646. _this._environmentBRDFTexture = null;
  51647. /**
  51648. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51649. */
  51650. _this._forceIrradianceInFragment = false;
  51651. /**
  51652. * Force normal to face away from face.
  51653. */
  51654. _this._forceNormalForward = false;
  51655. /**
  51656. * Enables specular anti aliasing in the PBR shader.
  51657. * It will both interacts on the Geometry for analytical and IBL lighting.
  51658. * It also prefilter the roughness map based on the bump values.
  51659. */
  51660. _this._enableSpecularAntiAliasing = false;
  51661. /**
  51662. * Stores the available render targets.
  51663. */
  51664. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_3__["SmartArray"](16);
  51665. /**
  51666. * Sets the global ambient color for the material used in lighting calculations.
  51667. */
  51668. _this._globalAmbientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  51669. /**
  51670. * If set to true, no lighting calculations will be applied.
  51671. */
  51672. _this._unlit = false;
  51673. _this._debugMode = 0;
  51674. /**
  51675. * @hidden
  51676. * This is reserved for the inspector.
  51677. * Defines the material debug mode.
  51678. * It helps seeing only some components of the material while troubleshooting.
  51679. */
  51680. _this.debugMode = 0;
  51681. /**
  51682. * @hidden
  51683. * This is reserved for the inspector.
  51684. * Specify from where on screen the debug mode should start.
  51685. * The value goes from -1 (full screen) to 1 (not visible)
  51686. * It helps with side by side comparison against the final render
  51687. * This defaults to -1
  51688. */
  51689. _this.debugLimit = -1;
  51690. /**
  51691. * @hidden
  51692. * This is reserved for the inspector.
  51693. * As the default viewing range might not be enough (if the ambient is really small for instance)
  51694. * You can use the factor to better multiply the final value.
  51695. */
  51696. _this.debugFactor = 1;
  51697. /**
  51698. * Defines the clear coat layer parameters for the material.
  51699. */
  51700. _this.clearCoat = new _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"](_this._markAllSubMeshesAsTexturesDirty.bind(_this));
  51701. /**
  51702. * Defines the anisotropic parameters for the material.
  51703. */
  51704. _this.anisotropy = new _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"](_this._markAllSubMeshesAsMiscDirty.bind(_this));
  51705. /**
  51706. * Defines the BRDF parameters for the material.
  51707. */
  51708. _this.brdf = new _pbrBRDFConfiguration__WEBPACK_IMPORTED_MODULE_10__["PBRBRDFConfiguration"](_this._markAllSubMeshesAsMiscDirty.bind(_this));
  51709. // Setup the default processing configuration to the scene.
  51710. _this._attachImageProcessingConfiguration(null);
  51711. _this.getRenderTargetTextures = function () {
  51712. _this._renderTargets.reset();
  51713. if (_materialFlags__WEBPACK_IMPORTED_MODULE_17__["MaterialFlags"].ReflectionTextureEnabled && _this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  51714. _this._renderTargets.push(_this._reflectionTexture);
  51715. }
  51716. if (_materialFlags__WEBPACK_IMPORTED_MODULE_17__["MaterialFlags"].RefractionTextureEnabled && _this._refractionTexture && _this._refractionTexture.isRenderTarget) {
  51717. _this._renderTargets.push(_this._refractionTexture);
  51718. }
  51719. return _this._renderTargets;
  51720. };
  51721. _this._environmentBRDFTexture = _Misc_textureTools__WEBPACK_IMPORTED_MODULE_4__["TextureTools"].GetEnvironmentBRDFTexture(scene);
  51722. return _this;
  51723. }
  51724. /**
  51725. * Attaches a new image processing configuration to the PBR Material.
  51726. * @param configuration
  51727. */
  51728. PBRBaseMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  51729. var _this = this;
  51730. if (configuration === this._imageProcessingConfiguration) {
  51731. return;
  51732. }
  51733. // Detaches observer.
  51734. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  51735. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  51736. }
  51737. // Pick the scene configuration if needed.
  51738. if (!configuration) {
  51739. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  51740. }
  51741. else {
  51742. this._imageProcessingConfiguration = configuration;
  51743. }
  51744. // Attaches observer.
  51745. if (this._imageProcessingConfiguration) {
  51746. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  51747. _this._markAllSubMeshesAsImageProcessingDirty();
  51748. });
  51749. }
  51750. };
  51751. Object.defineProperty(PBRBaseMaterial.prototype, "hasRenderTargetTextures", {
  51752. /**
  51753. * Gets a boolean indicating that current material needs to register RTT
  51754. */
  51755. get: function () {
  51756. if (_materialFlags__WEBPACK_IMPORTED_MODULE_17__["MaterialFlags"].ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  51757. return true;
  51758. }
  51759. if (_materialFlags__WEBPACK_IMPORTED_MODULE_17__["MaterialFlags"].RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) {
  51760. return true;
  51761. }
  51762. return false;
  51763. },
  51764. enumerable: true,
  51765. configurable: true
  51766. });
  51767. /**
  51768. * Gets the name of the material class.
  51769. */
  51770. PBRBaseMaterial.prototype.getClassName = function () {
  51771. return "PBRBaseMaterial";
  51772. };
  51773. Object.defineProperty(PBRBaseMaterial.prototype, "useLogarithmicDepth", {
  51774. /**
  51775. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51776. */
  51777. get: function () {
  51778. return this._useLogarithmicDepth;
  51779. },
  51780. /**
  51781. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51782. */
  51783. set: function (value) {
  51784. this._useLogarithmicDepth = value && this.getScene().getEngine().getCaps().fragmentDepthSupported;
  51785. },
  51786. enumerable: true,
  51787. configurable: true
  51788. });
  51789. Object.defineProperty(PBRBaseMaterial.prototype, "transparencyMode", {
  51790. /**
  51791. * Gets the current transparency mode.
  51792. */
  51793. get: function () {
  51794. return this._transparencyMode;
  51795. },
  51796. /**
  51797. * Sets the transparency mode of the material.
  51798. *
  51799. * | Value | Type | Description |
  51800. * | ----- | ----------------------------------- | ----------- |
  51801. * | 0 | OPAQUE | |
  51802. * | 1 | ALPHATEST | |
  51803. * | 2 | ALPHABLEND | |
  51804. * | 3 | ALPHATESTANDBLEND | |
  51805. *
  51806. */
  51807. set: function (value) {
  51808. if (this._transparencyMode === value) {
  51809. return;
  51810. }
  51811. this._transparencyMode = value;
  51812. this._forceAlphaTest = (value === PBRBaseMaterial.PBRMATERIAL_ALPHATESTANDBLEND);
  51813. this._markAllSubMeshesAsTexturesAndMiscDirty();
  51814. },
  51815. enumerable: true,
  51816. configurable: true
  51817. });
  51818. Object.defineProperty(PBRBaseMaterial.prototype, "_disableAlphaBlending", {
  51819. /**
  51820. * Returns true if alpha blending should be disabled.
  51821. */
  51822. get: function () {
  51823. return (this._linkRefractionWithTransparency ||
  51824. this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_OPAQUE ||
  51825. this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_ALPHATEST);
  51826. },
  51827. enumerable: true,
  51828. configurable: true
  51829. });
  51830. /**
  51831. * Specifies whether or not this material should be rendered in alpha blend mode.
  51832. */
  51833. PBRBaseMaterial.prototype.needAlphaBlending = function () {
  51834. if (this._disableAlphaBlending) {
  51835. return false;
  51836. }
  51837. return (this.alpha < 1.0) || (this._opacityTexture != null) || this._shouldUseAlphaFromAlbedoTexture();
  51838. };
  51839. /**
  51840. * Specifies if the mesh will require alpha blending.
  51841. * @param mesh - BJS mesh.
  51842. */
  51843. PBRBaseMaterial.prototype.needAlphaBlendingForMesh = function (mesh) {
  51844. if (this._disableAlphaBlending) {
  51845. return false;
  51846. }
  51847. return _super.prototype.needAlphaBlendingForMesh.call(this, mesh);
  51848. };
  51849. /**
  51850. * Specifies whether or not this material should be rendered in alpha test mode.
  51851. */
  51852. PBRBaseMaterial.prototype.needAlphaTesting = function () {
  51853. if (this._forceAlphaTest) {
  51854. return true;
  51855. }
  51856. if (this._linkRefractionWithTransparency) {
  51857. return false;
  51858. }
  51859. return this._albedoTexture != null && this._albedoTexture.hasAlpha && (this._transparencyMode == null || this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_ALPHATEST);
  51860. };
  51861. /**
  51862. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51863. */
  51864. PBRBaseMaterial.prototype._shouldUseAlphaFromAlbedoTexture = function () {
  51865. return this._albedoTexture != null && this._albedoTexture.hasAlpha && this._useAlphaFromAlbedoTexture && this._transparencyMode !== PBRBaseMaterial.PBRMATERIAL_OPAQUE;
  51866. };
  51867. /**
  51868. * Gets the texture used for the alpha test.
  51869. */
  51870. PBRBaseMaterial.prototype.getAlphaTestTexture = function () {
  51871. return this._albedoTexture;
  51872. };
  51873. /**
  51874. * Specifies that the submesh is ready to be used.
  51875. * @param mesh - BJS mesh.
  51876. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  51877. * @param useInstances - Specifies that instances should be used.
  51878. * @returns - boolean indicating that the submesh is ready or not.
  51879. */
  51880. PBRBaseMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  51881. if (subMesh.effect && this.isFrozen) {
  51882. if (this._wasPreviouslyReady) {
  51883. return true;
  51884. }
  51885. }
  51886. if (!subMesh._materialDefines) {
  51887. subMesh._materialDefines = new PBRMaterialDefines();
  51888. }
  51889. var defines = subMesh._materialDefines;
  51890. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  51891. if (defines._renderId === this.getScene().getRenderId()) {
  51892. return true;
  51893. }
  51894. }
  51895. var scene = this.getScene();
  51896. var engine = scene.getEngine();
  51897. if (defines._areTexturesDirty) {
  51898. if (scene.texturesEnabled) {
  51899. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_17__["MaterialFlags"].DiffuseTextureEnabled) {
  51900. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  51901. return false;
  51902. }
  51903. }
  51904. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_17__["MaterialFlags"].AmbientTextureEnabled) {
  51905. if (!this._ambientTexture.isReadyOrNotBlocking()) {
  51906. return false;
  51907. }
  51908. }
  51909. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_17__["MaterialFlags"].OpacityTextureEnabled) {
  51910. if (!this._opacityTexture.isReadyOrNotBlocking()) {
  51911. return false;
  51912. }
  51913. }
  51914. var reflectionTexture = this._getReflectionTexture();
  51915. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_17__["MaterialFlags"].ReflectionTextureEnabled) {
  51916. if (!reflectionTexture.isReadyOrNotBlocking()) {
  51917. return false;
  51918. }
  51919. }
  51920. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_17__["MaterialFlags"].LightmapTextureEnabled) {
  51921. if (!this._lightmapTexture.isReadyOrNotBlocking()) {
  51922. return false;
  51923. }
  51924. }
  51925. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_17__["MaterialFlags"].EmissiveTextureEnabled) {
  51926. if (!this._emissiveTexture.isReadyOrNotBlocking()) {
  51927. return false;
  51928. }
  51929. }
  51930. if (_materialFlags__WEBPACK_IMPORTED_MODULE_17__["MaterialFlags"].SpecularTextureEnabled) {
  51931. if (this._metallicTexture) {
  51932. if (!this._metallicTexture.isReadyOrNotBlocking()) {
  51933. return false;
  51934. }
  51935. }
  51936. else if (this._reflectivityTexture) {
  51937. if (!this._reflectivityTexture.isReadyOrNotBlocking()) {
  51938. return false;
  51939. }
  51940. }
  51941. if (this._microSurfaceTexture) {
  51942. if (!this._microSurfaceTexture.isReadyOrNotBlocking()) {
  51943. return false;
  51944. }
  51945. }
  51946. }
  51947. if (engine.getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_17__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  51948. // Bump texture cannot be not blocking.
  51949. if (!this._bumpTexture.isReady()) {
  51950. return false;
  51951. }
  51952. }
  51953. var refractionTexture = this._getRefractionTexture();
  51954. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_17__["MaterialFlags"].RefractionTextureEnabled) {
  51955. if (!refractionTexture.isReadyOrNotBlocking()) {
  51956. return false;
  51957. }
  51958. }
  51959. if (this._environmentBRDFTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_17__["MaterialFlags"].ReflectionTextureEnabled) {
  51960. // This is blocking.
  51961. if (!this._environmentBRDFTexture.isReady()) {
  51962. return false;
  51963. }
  51964. }
  51965. }
  51966. }
  51967. if (!this.clearCoat.isReadyForSubMesh(defines, scene, engine, this._disableBumpMap)) {
  51968. return false;
  51969. }
  51970. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  51971. if (!this._imageProcessingConfiguration.isReady()) {
  51972. return false;
  51973. }
  51974. }
  51975. if (!engine.getCaps().standardDerivatives && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  51976. mesh.createNormals(true);
  51977. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("PBRMaterial: Normals have been created for the mesh: " + mesh.name);
  51978. }
  51979. var previousEffect = subMesh.effect;
  51980. var effect = this._prepareEffect(mesh, defines, this.onCompiled, this.onError, useInstances);
  51981. if (effect) {
  51982. // Use previous effect while new one is compiling
  51983. if (this.allowShaderHotSwapping && previousEffect && !effect.isReady()) {
  51984. effect = previousEffect;
  51985. defines.markAsUnprocessed();
  51986. }
  51987. else {
  51988. scene.resetCachedMaterial();
  51989. subMesh.setEffect(effect, defines);
  51990. this.buildUniformLayout();
  51991. }
  51992. }
  51993. if (!subMesh.effect || !subMesh.effect.isReady()) {
  51994. return false;
  51995. }
  51996. defines._renderId = scene.getRenderId();
  51997. this._wasPreviouslyReady = true;
  51998. return true;
  51999. };
  52000. /**
  52001. * Specifies if the material uses metallic roughness workflow.
  52002. * @returns boolean specifiying if the material uses metallic roughness workflow.
  52003. */
  52004. PBRBaseMaterial.prototype.isMetallicWorkflow = function () {
  52005. if (this._metallic != null || this._roughness != null || this._metallicTexture) {
  52006. return true;
  52007. }
  52008. return false;
  52009. };
  52010. PBRBaseMaterial.prototype._prepareEffect = function (mesh, defines, onCompiled, onError, useInstances, useClipPlane) {
  52011. if (onCompiled === void 0) { onCompiled = null; }
  52012. if (onError === void 0) { onError = null; }
  52013. if (useInstances === void 0) { useInstances = null; }
  52014. if (useClipPlane === void 0) { useClipPlane = null; }
  52015. this._prepareDefines(mesh, defines, useInstances, useClipPlane);
  52016. if (!defines.isDirty) {
  52017. return null;
  52018. }
  52019. defines.markAsProcessed();
  52020. var scene = this.getScene();
  52021. var engine = scene.getEngine();
  52022. // Fallbacks
  52023. var fallbacks = new _Materials_effect__WEBPACK_IMPORTED_MODULE_12__["EffectFallbacks"]();
  52024. var fallbackRank = 0;
  52025. if (defines.USESPHERICALINVERTEX) {
  52026. fallbacks.addFallback(fallbackRank++, "USESPHERICALINVERTEX");
  52027. }
  52028. if (defines.FOG) {
  52029. fallbacks.addFallback(fallbackRank, "FOG");
  52030. }
  52031. if (defines.SPECULARAA) {
  52032. fallbacks.addFallback(fallbackRank, "SPECULARAA");
  52033. }
  52034. if (defines.POINTSIZE) {
  52035. fallbacks.addFallback(fallbackRank, "POINTSIZE");
  52036. }
  52037. if (defines.LOGARITHMICDEPTH) {
  52038. fallbacks.addFallback(fallbackRank, "LOGARITHMICDEPTH");
  52039. }
  52040. if (defines.PARALLAX) {
  52041. fallbacks.addFallback(fallbackRank, "PARALLAX");
  52042. }
  52043. if (defines.PARALLAXOCCLUSION) {
  52044. fallbacks.addFallback(fallbackRank++, "PARALLAXOCCLUSION");
  52045. }
  52046. fallbackRank = _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].AddFallbacks(defines, fallbacks, fallbackRank);
  52047. fallbackRank = _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"].AddFallbacks(defines, fallbacks, fallbackRank);
  52048. if (defines.ENVIRONMENTBRDF) {
  52049. fallbacks.addFallback(fallbackRank++, "ENVIRONMENTBRDF");
  52050. }
  52051. if (defines.TANGENT) {
  52052. fallbacks.addFallback(fallbackRank++, "TANGENT");
  52053. }
  52054. if (defines.BUMP) {
  52055. fallbacks.addFallback(fallbackRank++, "BUMP");
  52056. }
  52057. fallbackRank = _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_15__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights, fallbackRank++);
  52058. if (defines.SPECULARTERM) {
  52059. fallbacks.addFallback(fallbackRank++, "SPECULARTERM");
  52060. }
  52061. if (defines.USESPHERICALFROMREFLECTIONMAP) {
  52062. fallbacks.addFallback(fallbackRank++, "USESPHERICALFROMREFLECTIONMAP");
  52063. }
  52064. if (defines.LIGHTMAP) {
  52065. fallbacks.addFallback(fallbackRank++, "LIGHTMAP");
  52066. }
  52067. if (defines.NORMAL) {
  52068. fallbacks.addFallback(fallbackRank++, "NORMAL");
  52069. }
  52070. if (defines.AMBIENT) {
  52071. fallbacks.addFallback(fallbackRank++, "AMBIENT");
  52072. }
  52073. if (defines.EMISSIVE) {
  52074. fallbacks.addFallback(fallbackRank++, "EMISSIVE");
  52075. }
  52076. if (defines.VERTEXCOLOR) {
  52077. fallbacks.addFallback(fallbackRank++, "VERTEXCOLOR");
  52078. }
  52079. if (defines.NUM_BONE_INFLUENCERS > 0) {
  52080. fallbacks.addCPUSkinningFallback(fallbackRank++, mesh);
  52081. }
  52082. if (defines.MORPHTARGETS) {
  52083. fallbacks.addFallback(fallbackRank++, "MORPHTARGETS");
  52084. }
  52085. //Attributes
  52086. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind];
  52087. if (defines.NORMAL) {
  52088. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  52089. }
  52090. if (defines.TANGENT) {
  52091. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind);
  52092. }
  52093. if (defines.UV1) {
  52094. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  52095. }
  52096. if (defines.UV2) {
  52097. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV2Kind);
  52098. }
  52099. if (defines.VERTEXCOLOR) {
  52100. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].ColorKind);
  52101. }
  52102. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_15__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  52103. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_15__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  52104. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_15__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, defines);
  52105. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vAlbedoColor", "vReflectivityColor", "vEmissiveColor", "vReflectionColor",
  52106. "vFogInfos", "vFogColor", "pointSize",
  52107. "vAlbedoInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vReflectionPosition", "vReflectionSize", "vEmissiveInfos", "vReflectivityInfos",
  52108. "vMicroSurfaceSamplerInfos", "vBumpInfos", "vLightmapInfos", "vRefractionInfos",
  52109. "mBones",
  52110. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "albedoMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "reflectivityMatrix", "normalMatrix", "microSurfaceSamplerMatrix", "bumpMatrix", "lightmapMatrix", "refractionMatrix",
  52111. "vLightingIntensity",
  52112. "logarithmicDepthConstant",
  52113. "vSphericalX", "vSphericalY", "vSphericalZ",
  52114. "vSphericalXX", "vSphericalYY", "vSphericalZZ",
  52115. "vSphericalXY", "vSphericalYZ", "vSphericalZX",
  52116. "vReflectionMicrosurfaceInfos", "vRefractionMicrosurfaceInfos",
  52117. "vTangentSpaceParams", "boneTextureWidth",
  52118. "vDebugMode"
  52119. ];
  52120. var samplers = ["albedoSampler", "reflectivitySampler", "ambientSampler", "emissiveSampler",
  52121. "bumpSampler", "lightmapSampler", "opacitySampler",
  52122. "refractionSampler", "refractionSamplerLow", "refractionSamplerHigh",
  52123. "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh",
  52124. "microSurfaceSampler", "environmentBrdfSampler", "boneSampler"];
  52125. var uniformBuffers = ["Material", "Scene"];
  52126. _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"].AddUniforms(uniforms);
  52127. _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"].AddSamplers(samplers);
  52128. _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].AddUniforms(uniforms);
  52129. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__["ImageProcessingConfiguration"]) {
  52130. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  52131. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  52132. }
  52133. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_15__["MaterialHelper"].PrepareUniformsAndSamplersList({
  52134. uniformsNames: uniforms,
  52135. uniformBuffersNames: uniformBuffers,
  52136. samplers: samplers,
  52137. defines: defines,
  52138. maxSimultaneousLights: this._maxSimultaneousLights
  52139. });
  52140. var join = defines.toString();
  52141. return engine.createEffect("pbr", {
  52142. attributes: attribs,
  52143. uniformsNames: uniforms,
  52144. uniformBuffersNames: uniformBuffers,
  52145. samplers: samplers,
  52146. defines: join,
  52147. fallbacks: fallbacks,
  52148. onCompiled: onCompiled,
  52149. onError: onError,
  52150. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS }
  52151. }, engine);
  52152. };
  52153. PBRBaseMaterial.prototype._prepareDefines = function (mesh, defines, useInstances, useClipPlane) {
  52154. if (useInstances === void 0) { useInstances = null; }
  52155. if (useClipPlane === void 0) { useClipPlane = null; }
  52156. var scene = this.getScene();
  52157. var engine = scene.getEngine();
  52158. // Lights
  52159. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_15__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, true, this._maxSimultaneousLights, this._disableLighting);
  52160. defines._needNormals = true;
  52161. // Textures
  52162. defines.METALLICWORKFLOW = this.isMetallicWorkflow();
  52163. if (defines._areTexturesDirty) {
  52164. defines._needUVs = false;
  52165. if (scene.texturesEnabled) {
  52166. if (scene.getEngine().getCaps().textureLOD) {
  52167. defines.LODBASEDMICROSFURACE = true;
  52168. }
  52169. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_17__["MaterialFlags"].DiffuseTextureEnabled) {
  52170. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_15__["MaterialHelper"].PrepareDefinesForMergedUV(this._albedoTexture, defines, "ALBEDO");
  52171. }
  52172. else {
  52173. defines.ALBEDO = false;
  52174. }
  52175. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_17__["MaterialFlags"].AmbientTextureEnabled) {
  52176. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_15__["MaterialHelper"].PrepareDefinesForMergedUV(this._ambientTexture, defines, "AMBIENT");
  52177. defines.AMBIENTINGRAYSCALE = this._useAmbientInGrayScale;
  52178. }
  52179. else {
  52180. defines.AMBIENT = false;
  52181. }
  52182. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_17__["MaterialFlags"].OpacityTextureEnabled) {
  52183. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_15__["MaterialHelper"].PrepareDefinesForMergedUV(this._opacityTexture, defines, "OPACITY");
  52184. defines.OPACITYRGB = this._opacityTexture.getAlphaFromRGB;
  52185. }
  52186. else {
  52187. defines.OPACITY = false;
  52188. }
  52189. var reflectionTexture = this._getReflectionTexture();
  52190. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_17__["MaterialFlags"].ReflectionTextureEnabled) {
  52191. defines.REFLECTION = true;
  52192. defines.GAMMAREFLECTION = reflectionTexture.gammaSpace;
  52193. defines.RGBDREFLECTION = reflectionTexture.isRGBD;
  52194. defines.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !reflectionTexture.invertZ : reflectionTexture.invertZ;
  52195. defines.LODINREFLECTIONALPHA = reflectionTexture.lodLevelInAlpha;
  52196. if (reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_16__["Texture"].INVCUBIC_MODE) {
  52197. defines.INVERTCUBICMAP = true;
  52198. }
  52199. defines.REFLECTIONMAP_3D = reflectionTexture.isCube;
  52200. defines.REFLECTIONMAP_CUBIC = false;
  52201. defines.REFLECTIONMAP_EXPLICIT = false;
  52202. defines.REFLECTIONMAP_PLANAR = false;
  52203. defines.REFLECTIONMAP_PROJECTION = false;
  52204. defines.REFLECTIONMAP_SKYBOX = false;
  52205. defines.REFLECTIONMAP_SPHERICAL = false;
  52206. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  52207. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  52208. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  52209. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  52210. switch (reflectionTexture.coordinatesMode) {
  52211. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_16__["Texture"].EXPLICIT_MODE:
  52212. defines.REFLECTIONMAP_EXPLICIT = true;
  52213. break;
  52214. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_16__["Texture"].PLANAR_MODE:
  52215. defines.REFLECTIONMAP_PLANAR = true;
  52216. break;
  52217. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_16__["Texture"].PROJECTION_MODE:
  52218. defines.REFLECTIONMAP_PROJECTION = true;
  52219. break;
  52220. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_16__["Texture"].SKYBOX_MODE:
  52221. defines.REFLECTIONMAP_SKYBOX = true;
  52222. break;
  52223. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_16__["Texture"].SPHERICAL_MODE:
  52224. defines.REFLECTIONMAP_SPHERICAL = true;
  52225. break;
  52226. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_16__["Texture"].EQUIRECTANGULAR_MODE:
  52227. defines.REFLECTIONMAP_EQUIRECTANGULAR = true;
  52228. break;
  52229. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_16__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  52230. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = true;
  52231. break;
  52232. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_16__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  52233. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = true;
  52234. break;
  52235. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_16__["Texture"].CUBIC_MODE:
  52236. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_16__["Texture"].INVCUBIC_MODE:
  52237. default:
  52238. defines.REFLECTIONMAP_CUBIC = true;
  52239. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = reflectionTexture.boundingBoxSize ? true : false;
  52240. break;
  52241. }
  52242. if (reflectionTexture.coordinatesMode !== _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_16__["Texture"].SKYBOX_MODE) {
  52243. if (reflectionTexture.sphericalPolynomial) {
  52244. defines.USESPHERICALFROMREFLECTIONMAP = true;
  52245. if (this._forceIrradianceInFragment || scene.getEngine().getCaps().maxVaryingVectors <= 8) {
  52246. defines.USESPHERICALINVERTEX = false;
  52247. }
  52248. else {
  52249. defines.USESPHERICALINVERTEX = true;
  52250. }
  52251. }
  52252. }
  52253. else {
  52254. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !reflectionTexture.getReflectionTextureMatrix().isIdentity();
  52255. }
  52256. }
  52257. else {
  52258. defines.REFLECTION = false;
  52259. defines.REFLECTIONMAP_3D = false;
  52260. defines.REFLECTIONMAP_SPHERICAL = false;
  52261. defines.REFLECTIONMAP_PLANAR = false;
  52262. defines.REFLECTIONMAP_CUBIC = false;
  52263. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  52264. defines.REFLECTIONMAP_PROJECTION = false;
  52265. defines.REFLECTIONMAP_SKYBOX = false;
  52266. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  52267. defines.REFLECTIONMAP_EXPLICIT = false;
  52268. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  52269. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  52270. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  52271. defines.INVERTCUBICMAP = false;
  52272. defines.USESPHERICALFROMREFLECTIONMAP = false;
  52273. defines.USESPHERICALINVERTEX = false;
  52274. defines.REFLECTIONMAP_OPPOSITEZ = false;
  52275. defines.LODINREFLECTIONALPHA = false;
  52276. defines.GAMMAREFLECTION = false;
  52277. defines.RGBDREFLECTION = false;
  52278. }
  52279. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_17__["MaterialFlags"].LightmapTextureEnabled) {
  52280. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_15__["MaterialHelper"].PrepareDefinesForMergedUV(this._lightmapTexture, defines, "LIGHTMAP");
  52281. defines.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap;
  52282. defines.GAMMALIGHTMAP = this._lightmapTexture.gammaSpace;
  52283. }
  52284. else {
  52285. defines.LIGHTMAP = false;
  52286. }
  52287. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_17__["MaterialFlags"].EmissiveTextureEnabled) {
  52288. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_15__["MaterialHelper"].PrepareDefinesForMergedUV(this._emissiveTexture, defines, "EMISSIVE");
  52289. }
  52290. else {
  52291. defines.EMISSIVE = false;
  52292. }
  52293. if (_materialFlags__WEBPACK_IMPORTED_MODULE_17__["MaterialFlags"].SpecularTextureEnabled) {
  52294. if (this._metallicTexture) {
  52295. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_15__["MaterialHelper"].PrepareDefinesForMergedUV(this._metallicTexture, defines, "REFLECTIVITY");
  52296. defines.ROUGHNESSSTOREINMETALMAPALPHA = this._useRoughnessFromMetallicTextureAlpha;
  52297. defines.ROUGHNESSSTOREINMETALMAPGREEN = !this._useRoughnessFromMetallicTextureAlpha && this._useRoughnessFromMetallicTextureGreen;
  52298. defines.METALLNESSSTOREINMETALMAPBLUE = this._useMetallnessFromMetallicTextureBlue;
  52299. defines.AOSTOREINMETALMAPRED = this._useAmbientOcclusionFromMetallicTextureRed;
  52300. }
  52301. else if (this._reflectivityTexture) {
  52302. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_15__["MaterialHelper"].PrepareDefinesForMergedUV(this._reflectivityTexture, defines, "REFLECTIVITY");
  52303. defines.MICROSURFACEFROMREFLECTIVITYMAP = this._useMicroSurfaceFromReflectivityMapAlpha;
  52304. defines.MICROSURFACEAUTOMATIC = this._useAutoMicroSurfaceFromReflectivityMap;
  52305. }
  52306. else {
  52307. defines.REFLECTIVITY = false;
  52308. }
  52309. if (this._microSurfaceTexture) {
  52310. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_15__["MaterialHelper"].PrepareDefinesForMergedUV(this._microSurfaceTexture, defines, "MICROSURFACEMAP");
  52311. }
  52312. else {
  52313. defines.MICROSURFACEMAP = false;
  52314. }
  52315. }
  52316. else {
  52317. defines.REFLECTIVITY = false;
  52318. defines.MICROSURFACEMAP = false;
  52319. }
  52320. if (scene.getEngine().getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_17__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  52321. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_15__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "BUMP");
  52322. if (this._useParallax && this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_17__["MaterialFlags"].DiffuseTextureEnabled) {
  52323. defines.PARALLAX = true;
  52324. defines.PARALLAXOCCLUSION = !!this._useParallaxOcclusion;
  52325. }
  52326. else {
  52327. defines.PARALLAX = false;
  52328. }
  52329. defines.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap;
  52330. }
  52331. else {
  52332. defines.BUMP = false;
  52333. }
  52334. var refractionTexture = this._getRefractionTexture();
  52335. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_17__["MaterialFlags"].RefractionTextureEnabled) {
  52336. defines.REFRACTION = true;
  52337. defines.REFRACTIONMAP_3D = refractionTexture.isCube;
  52338. defines.GAMMAREFRACTION = refractionTexture.gammaSpace;
  52339. defines.RGBDREFRACTION = refractionTexture.isRGBD;
  52340. defines.REFRACTIONMAP_OPPOSITEZ = refractionTexture.invertZ;
  52341. defines.LODINREFRACTIONALPHA = refractionTexture.lodLevelInAlpha;
  52342. if (this._linkRefractionWithTransparency) {
  52343. defines.LINKREFRACTIONTOTRANSPARENCY = true;
  52344. }
  52345. }
  52346. else {
  52347. defines.REFRACTION = false;
  52348. }
  52349. if (this._environmentBRDFTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_17__["MaterialFlags"].ReflectionTextureEnabled) {
  52350. defines.ENVIRONMENTBRDF = true;
  52351. }
  52352. else {
  52353. defines.ENVIRONMENTBRDF = false;
  52354. }
  52355. if (this._shouldUseAlphaFromAlbedoTexture()) {
  52356. defines.ALPHAFROMALBEDO = true;
  52357. }
  52358. else {
  52359. defines.ALPHAFROMALBEDO = false;
  52360. }
  52361. }
  52362. defines.SPECULAROVERALPHA = this._useSpecularOverAlpha;
  52363. if (this._lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_STANDARD) {
  52364. defines.USEPHYSICALLIGHTFALLOFF = false;
  52365. defines.USEGLTFLIGHTFALLOFF = false;
  52366. }
  52367. else if (this._lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_GLTF) {
  52368. defines.USEPHYSICALLIGHTFALLOFF = false;
  52369. defines.USEGLTFLIGHTFALLOFF = true;
  52370. }
  52371. else {
  52372. defines.USEPHYSICALLIGHTFALLOFF = true;
  52373. defines.USEGLTFLIGHTFALLOFF = false;
  52374. }
  52375. defines.RADIANCEOVERALPHA = this._useRadianceOverAlpha;
  52376. if (!this.backFaceCulling && this._twoSidedLighting) {
  52377. defines.TWOSIDEDLIGHTING = true;
  52378. }
  52379. else {
  52380. defines.TWOSIDEDLIGHTING = false;
  52381. }
  52382. defines.ALPHATESTVALUE = "" + this._alphaCutOff + (this._alphaCutOff % 1 === 0 ? "." : "");
  52383. defines.PREMULTIPLYALPHA = (this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_PREMULTIPLIED || this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF);
  52384. defines.ALPHABLEND = this.needAlphaBlendingForMesh(mesh);
  52385. defines.ALPHAFRESNEL = this._useAlphaFresnel || this._useLinearAlphaFresnel;
  52386. defines.LINEARALPHAFRESNEL = this._useLinearAlphaFresnel;
  52387. defines.SPECULARAA = scene.getEngine().getCaps().standardDerivatives && this._enableSpecularAntiAliasing;
  52388. }
  52389. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  52390. this._imageProcessingConfiguration.prepareDefines(defines);
  52391. }
  52392. defines.FORCENORMALFORWARD = this._forceNormalForward;
  52393. defines.RADIANCEOCCLUSION = this._useRadianceOcclusion;
  52394. defines.HORIZONOCCLUSION = this._useHorizonOcclusion;
  52395. // Misc.
  52396. if (defines._areMiscDirty) {
  52397. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_15__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh) || this._forceAlphaTest, defines);
  52398. defines.UNLIT = this._unlit || ((this.pointsCloud || this.wireframe) && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind));
  52399. defines.DEBUGMODE = this._debugMode;
  52400. }
  52401. // External config
  52402. this.clearCoat.prepareDefines(defines, scene);
  52403. this.anisotropy.prepareDefines(defines, mesh);
  52404. this.brdf.prepareDefines(defines);
  52405. // Values that need to be evaluated on every frame
  52406. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_15__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, useClipPlane);
  52407. // Attribs
  52408. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_15__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true, true, this._transparencyMode !== PBRBaseMaterial.PBRMATERIAL_OPAQUE);
  52409. };
  52410. /**
  52411. * Force shader compilation
  52412. */
  52413. PBRBaseMaterial.prototype.forceCompilation = function (mesh, onCompiled, options) {
  52414. var _this = this;
  52415. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ clipPlane: false }, options);
  52416. var defines = new PBRMaterialDefines();
  52417. var effect = this._prepareEffect(mesh, defines, undefined, undefined, undefined, localOptions.clipPlane);
  52418. if (effect.isReady()) {
  52419. if (onCompiled) {
  52420. onCompiled(this);
  52421. }
  52422. }
  52423. else {
  52424. effect.onCompileObservable.add(function () {
  52425. if (onCompiled) {
  52426. onCompiled(_this);
  52427. }
  52428. });
  52429. }
  52430. };
  52431. /**
  52432. * Initializes the uniform buffer layout for the shader.
  52433. */
  52434. PBRBaseMaterial.prototype.buildUniformLayout = function () {
  52435. // Order is important !
  52436. this._uniformBuffer.addUniform("vAlbedoInfos", 2);
  52437. this._uniformBuffer.addUniform("vAmbientInfos", 4);
  52438. this._uniformBuffer.addUniform("vOpacityInfos", 2);
  52439. this._uniformBuffer.addUniform("vEmissiveInfos", 2);
  52440. this._uniformBuffer.addUniform("vLightmapInfos", 2);
  52441. this._uniformBuffer.addUniform("vReflectivityInfos", 3);
  52442. this._uniformBuffer.addUniform("vMicroSurfaceSamplerInfos", 2);
  52443. this._uniformBuffer.addUniform("vRefractionInfos", 4);
  52444. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  52445. this._uniformBuffer.addUniform("vReflectionPosition", 3);
  52446. this._uniformBuffer.addUniform("vReflectionSize", 3);
  52447. this._uniformBuffer.addUniform("vBumpInfos", 3);
  52448. this._uniformBuffer.addUniform("albedoMatrix", 16);
  52449. this._uniformBuffer.addUniform("ambientMatrix", 16);
  52450. this._uniformBuffer.addUniform("opacityMatrix", 16);
  52451. this._uniformBuffer.addUniform("emissiveMatrix", 16);
  52452. this._uniformBuffer.addUniform("lightmapMatrix", 16);
  52453. this._uniformBuffer.addUniform("reflectivityMatrix", 16);
  52454. this._uniformBuffer.addUniform("microSurfaceSamplerMatrix", 16);
  52455. this._uniformBuffer.addUniform("bumpMatrix", 16);
  52456. this._uniformBuffer.addUniform("vTangentSpaceParams", 2);
  52457. this._uniformBuffer.addUniform("refractionMatrix", 16);
  52458. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  52459. this._uniformBuffer.addUniform("vReflectionColor", 3);
  52460. this._uniformBuffer.addUniform("vAlbedoColor", 4);
  52461. this._uniformBuffer.addUniform("vLightingIntensity", 4);
  52462. this._uniformBuffer.addUniform("vRefractionMicrosurfaceInfos", 3);
  52463. this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos", 3);
  52464. this._uniformBuffer.addUniform("vReflectivityColor", 4);
  52465. this._uniformBuffer.addUniform("vEmissiveColor", 3);
  52466. this._uniformBuffer.addUniform("pointSize", 1);
  52467. _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"].PrepareUniformBuffer(this._uniformBuffer);
  52468. _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].PrepareUniformBuffer(this._uniformBuffer);
  52469. this._uniformBuffer.create();
  52470. };
  52471. /**
  52472. * Unbinds the textures.
  52473. */
  52474. PBRBaseMaterial.prototype.unbind = function () {
  52475. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  52476. this._uniformBuffer.setTexture("reflectionSampler", null);
  52477. }
  52478. if (this._refractionTexture && this._refractionTexture.isRenderTarget) {
  52479. this._uniformBuffer.setTexture("refractionSampler", null);
  52480. }
  52481. _super.prototype.unbind.call(this);
  52482. };
  52483. /**
  52484. * Binds the submesh data.
  52485. * @param world - The world matrix.
  52486. * @param mesh - The BJS mesh.
  52487. * @param subMesh - A submesh of the BJS mesh.
  52488. */
  52489. PBRBaseMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  52490. var scene = this.getScene();
  52491. var defines = subMesh._materialDefines;
  52492. if (!defines) {
  52493. return;
  52494. }
  52495. var effect = subMesh.effect;
  52496. if (!effect) {
  52497. return;
  52498. }
  52499. this._activeEffect = effect;
  52500. // Matrices
  52501. this.bindOnlyWorldMatrix(world);
  52502. // Normal Matrix
  52503. if (defines.OBJECTSPACE_NORMALMAP) {
  52504. world.toNormalMatrix(this._normalMatrix);
  52505. this.bindOnlyNormalMatrix(this._normalMatrix);
  52506. }
  52507. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  52508. // Bones
  52509. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_15__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
  52510. var reflectionTexture = null;
  52511. if (mustRebind) {
  52512. var engine = scene.getEngine();
  52513. this._uniformBuffer.bindToEffect(effect, "Material");
  52514. this.bindViewProjection(effect);
  52515. reflectionTexture = this._getReflectionTexture();
  52516. var refractionTexture = this._getRefractionTexture();
  52517. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  52518. // Texture uniforms
  52519. if (scene.texturesEnabled) {
  52520. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_17__["MaterialFlags"].DiffuseTextureEnabled) {
  52521. this._uniformBuffer.updateFloat2("vAlbedoInfos", this._albedoTexture.coordinatesIndex, this._albedoTexture.level);
  52522. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_15__["MaterialHelper"].BindTextureMatrix(this._albedoTexture, this._uniformBuffer, "albedo");
  52523. }
  52524. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_17__["MaterialFlags"].AmbientTextureEnabled) {
  52525. this._uniformBuffer.updateFloat4("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level, this._ambientTextureStrength, this._ambientTextureImpactOnAnalyticalLights);
  52526. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_15__["MaterialHelper"].BindTextureMatrix(this._ambientTexture, this._uniformBuffer, "ambient");
  52527. }
  52528. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_17__["MaterialFlags"].OpacityTextureEnabled) {
  52529. this._uniformBuffer.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level);
  52530. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_15__["MaterialHelper"].BindTextureMatrix(this._opacityTexture, this._uniformBuffer, "opacity");
  52531. }
  52532. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_17__["MaterialFlags"].ReflectionTextureEnabled) {
  52533. this._uniformBuffer.updateMatrix("reflectionMatrix", reflectionTexture.getReflectionTextureMatrix());
  52534. this._uniformBuffer.updateFloat2("vReflectionInfos", reflectionTexture.level, 0);
  52535. if (reflectionTexture.boundingBoxSize) {
  52536. var cubeTexture = reflectionTexture;
  52537. this._uniformBuffer.updateVector3("vReflectionPosition", cubeTexture.boundingBoxPosition);
  52538. this._uniformBuffer.updateVector3("vReflectionSize", cubeTexture.boundingBoxSize);
  52539. }
  52540. var polynomials = reflectionTexture.sphericalPolynomial;
  52541. if (defines.USESPHERICALFROMREFLECTIONMAP && polynomials) {
  52542. this._activeEffect.setFloat3("vSphericalX", polynomials.x.x, polynomials.x.y, polynomials.x.z);
  52543. this._activeEffect.setFloat3("vSphericalY", polynomials.y.x, polynomials.y.y, polynomials.y.z);
  52544. this._activeEffect.setFloat3("vSphericalZ", polynomials.z.x, polynomials.z.y, polynomials.z.z);
  52545. this._activeEffect.setFloat3("vSphericalXX_ZZ", polynomials.xx.x - polynomials.zz.x, polynomials.xx.y - polynomials.zz.y, polynomials.xx.z - polynomials.zz.z);
  52546. this._activeEffect.setFloat3("vSphericalYY_ZZ", polynomials.yy.x - polynomials.zz.x, polynomials.yy.y - polynomials.zz.y, polynomials.yy.z - polynomials.zz.z);
  52547. this._activeEffect.setFloat3("vSphericalZZ", polynomials.zz.x, polynomials.zz.y, polynomials.zz.z);
  52548. this._activeEffect.setFloat3("vSphericalXY", polynomials.xy.x, polynomials.xy.y, polynomials.xy.z);
  52549. this._activeEffect.setFloat3("vSphericalYZ", polynomials.yz.x, polynomials.yz.y, polynomials.yz.z);
  52550. this._activeEffect.setFloat3("vSphericalZX", polynomials.zx.x, polynomials.zx.y, polynomials.zx.z);
  52551. }
  52552. this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos", reflectionTexture.getSize().width, reflectionTexture.lodGenerationScale, reflectionTexture.lodGenerationOffset);
  52553. }
  52554. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_17__["MaterialFlags"].EmissiveTextureEnabled) {
  52555. this._uniformBuffer.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level);
  52556. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_15__["MaterialHelper"].BindTextureMatrix(this._emissiveTexture, this._uniformBuffer, "emissive");
  52557. }
  52558. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_17__["MaterialFlags"].LightmapTextureEnabled) {
  52559. this._uniformBuffer.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level);
  52560. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_15__["MaterialHelper"].BindTextureMatrix(this._lightmapTexture, this._uniformBuffer, "lightmap");
  52561. }
  52562. if (_materialFlags__WEBPACK_IMPORTED_MODULE_17__["MaterialFlags"].SpecularTextureEnabled) {
  52563. if (this._metallicTexture) {
  52564. this._uniformBuffer.updateFloat3("vReflectivityInfos", this._metallicTexture.coordinatesIndex, this._metallicTexture.level, this._ambientTextureStrength);
  52565. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_15__["MaterialHelper"].BindTextureMatrix(this._metallicTexture, this._uniformBuffer, "reflectivity");
  52566. }
  52567. else if (this._reflectivityTexture) {
  52568. this._uniformBuffer.updateFloat3("vReflectivityInfos", this._reflectivityTexture.coordinatesIndex, this._reflectivityTexture.level, 1.0);
  52569. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_15__["MaterialHelper"].BindTextureMatrix(this._reflectivityTexture, this._uniformBuffer, "reflectivity");
  52570. }
  52571. if (this._microSurfaceTexture) {
  52572. this._uniformBuffer.updateFloat2("vMicroSurfaceSamplerInfos", this._microSurfaceTexture.coordinatesIndex, this._microSurfaceTexture.level);
  52573. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_15__["MaterialHelper"].BindTextureMatrix(this._microSurfaceTexture, this._uniformBuffer, "microSurfaceSampler");
  52574. }
  52575. }
  52576. if (this._bumpTexture && engine.getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_17__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  52577. this._uniformBuffer.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level, this._parallaxScaleBias);
  52578. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_15__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, this._uniformBuffer, "bump");
  52579. if (scene._mirroredCameraPosition) {
  52580. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
  52581. }
  52582. else {
  52583. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1.0 : 1.0, this._invertNormalMapY ? -1.0 : 1.0);
  52584. }
  52585. }
  52586. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_17__["MaterialFlags"].RefractionTextureEnabled) {
  52587. this._uniformBuffer.updateMatrix("refractionMatrix", refractionTexture.getReflectionTextureMatrix());
  52588. var depth = 1.0;
  52589. if (!refractionTexture.isCube) {
  52590. if (refractionTexture.depth) {
  52591. depth = refractionTexture.depth;
  52592. }
  52593. }
  52594. this._uniformBuffer.updateFloat4("vRefractionInfos", refractionTexture.level, this._indexOfRefraction, depth, this._invertRefractionY ? -1 : 1);
  52595. this._uniformBuffer.updateFloat3("vRefractionMicrosurfaceInfos", refractionTexture.getSize().width, refractionTexture.lodGenerationScale, refractionTexture.lodGenerationOffset);
  52596. }
  52597. }
  52598. // Point size
  52599. if (this.pointsCloud) {
  52600. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  52601. }
  52602. // Colors
  52603. if (defines.METALLICWORKFLOW) {
  52604. _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0].r = (this._metallic === undefined || this._metallic === null) ? 1 : this._metallic;
  52605. _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0].g = (this._roughness === undefined || this._roughness === null) ? 1 : this._roughness;
  52606. this._uniformBuffer.updateColor4("vReflectivityColor", _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0], 0);
  52607. }
  52608. else {
  52609. this._uniformBuffer.updateColor4("vReflectivityColor", this._reflectivityColor, this._microSurface);
  52610. }
  52611. this._uniformBuffer.updateColor3("vEmissiveColor", _materialFlags__WEBPACK_IMPORTED_MODULE_17__["MaterialFlags"].EmissiveTextureEnabled ? this._emissiveColor : _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"].BlackReadOnly);
  52612. this._uniformBuffer.updateColor3("vReflectionColor", this._reflectionColor);
  52613. this._uniformBuffer.updateColor4("vAlbedoColor", this._albedoColor, this.alpha * mesh.visibility);
  52614. // Misc
  52615. this._lightingInfos.x = this._directIntensity;
  52616. this._lightingInfos.y = this._emissiveIntensity;
  52617. this._lightingInfos.z = this._environmentIntensity;
  52618. this._lightingInfos.w = this._specularIntensity;
  52619. this._uniformBuffer.updateVector4("vLightingIntensity", this._lightingInfos);
  52620. }
  52621. // Textures
  52622. if (scene.texturesEnabled) {
  52623. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_17__["MaterialFlags"].DiffuseTextureEnabled) {
  52624. this._uniformBuffer.setTexture("albedoSampler", this._albedoTexture);
  52625. }
  52626. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_17__["MaterialFlags"].AmbientTextureEnabled) {
  52627. this._uniformBuffer.setTexture("ambientSampler", this._ambientTexture);
  52628. }
  52629. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_17__["MaterialFlags"].OpacityTextureEnabled) {
  52630. this._uniformBuffer.setTexture("opacitySampler", this._opacityTexture);
  52631. }
  52632. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_17__["MaterialFlags"].ReflectionTextureEnabled) {
  52633. if (defines.LODBASEDMICROSFURACE) {
  52634. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  52635. }
  52636. else {
  52637. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture._lodTextureMid || reflectionTexture);
  52638. this._uniformBuffer.setTexture("reflectionSamplerLow", reflectionTexture._lodTextureLow || reflectionTexture);
  52639. this._uniformBuffer.setTexture("reflectionSamplerHigh", reflectionTexture._lodTextureHigh || reflectionTexture);
  52640. }
  52641. }
  52642. if (defines.ENVIRONMENTBRDF) {
  52643. this._uniformBuffer.setTexture("environmentBrdfSampler", this._environmentBRDFTexture);
  52644. }
  52645. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_17__["MaterialFlags"].RefractionTextureEnabled) {
  52646. if (defines.LODBASEDMICROSFURACE) {
  52647. this._uniformBuffer.setTexture("refractionSampler", refractionTexture);
  52648. }
  52649. else {
  52650. this._uniformBuffer.setTexture("refractionSampler", refractionTexture._lodTextureMid || refractionTexture);
  52651. this._uniformBuffer.setTexture("refractionSamplerLow", refractionTexture._lodTextureLow || refractionTexture);
  52652. this._uniformBuffer.setTexture("refractionSamplerHigh", refractionTexture._lodTextureHigh || refractionTexture);
  52653. }
  52654. }
  52655. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_17__["MaterialFlags"].EmissiveTextureEnabled) {
  52656. this._uniformBuffer.setTexture("emissiveSampler", this._emissiveTexture);
  52657. }
  52658. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_17__["MaterialFlags"].LightmapTextureEnabled) {
  52659. this._uniformBuffer.setTexture("lightmapSampler", this._lightmapTexture);
  52660. }
  52661. if (_materialFlags__WEBPACK_IMPORTED_MODULE_17__["MaterialFlags"].SpecularTextureEnabled) {
  52662. if (this._metallicTexture) {
  52663. this._uniformBuffer.setTexture("reflectivitySampler", this._metallicTexture);
  52664. }
  52665. else if (this._reflectivityTexture) {
  52666. this._uniformBuffer.setTexture("reflectivitySampler", this._reflectivityTexture);
  52667. }
  52668. if (this._microSurfaceTexture) {
  52669. this._uniformBuffer.setTexture("microSurfaceSampler", this._microSurfaceTexture);
  52670. }
  52671. }
  52672. if (this._bumpTexture && engine.getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_17__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  52673. this._uniformBuffer.setTexture("bumpSampler", this._bumpTexture);
  52674. }
  52675. }
  52676. this.clearCoat.bindForSubMesh(this._uniformBuffer, scene, engine, this._disableBumpMap, this.isFrozen, this._invertNormalMapX, this._invertNormalMapY);
  52677. this.anisotropy.bindForSubMesh(this._uniformBuffer, this.isFrozen);
  52678. // Clip plane
  52679. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_15__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
  52680. // Colors
  52681. scene.ambientColor.multiplyToRef(this._ambientColor, this._globalAmbientColor);
  52682. var eyePosition = scene._forcedViewPosition ? scene._forcedViewPosition : (scene._mirroredCameraPosition ? scene._mirroredCameraPosition : scene.activeCamera.globalPosition);
  52683. var invertNormal = (scene.useRightHandedSystem === (scene._mirroredCameraPosition != null));
  52684. effect.setFloat4("vEyePosition", eyePosition.x, eyePosition.y, eyePosition.z, invertNormal ? -1 : 1);
  52685. effect.setColor3("vAmbientColor", this._globalAmbientColor);
  52686. effect.setFloat2("vDebugMode", this.debugLimit, this.debugFactor);
  52687. }
  52688. if (mustRebind || !this.isFrozen) {
  52689. // Lights
  52690. if (scene.lightsEnabled && !this._disableLighting) {
  52691. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_15__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights, this._lightFalloff !== PBRBaseMaterial.LIGHTFALLOFF_STANDARD);
  52692. }
  52693. // View
  52694. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].FOGMODE_NONE || reflectionTexture) {
  52695. this.bindView(effect);
  52696. }
  52697. // Fog
  52698. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_15__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect, true);
  52699. // Morph targets
  52700. if (defines.NUM_MORPH_INFLUENCERS) {
  52701. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_15__["MaterialHelper"].BindMorphTargetParameters(mesh, this._activeEffect);
  52702. }
  52703. // image processing
  52704. this._imageProcessingConfiguration.bind(this._activeEffect);
  52705. // Log. depth
  52706. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_15__["MaterialHelper"].BindLogDepth(defines, this._activeEffect, scene);
  52707. }
  52708. this._uniformBuffer.update();
  52709. this._afterBind(mesh, this._activeEffect);
  52710. };
  52711. /**
  52712. * Returns the animatable textures.
  52713. * @returns - Array of animatable textures.
  52714. */
  52715. PBRBaseMaterial.prototype.getAnimatables = function () {
  52716. var results = [];
  52717. if (this._albedoTexture && this._albedoTexture.animations && this._albedoTexture.animations.length > 0) {
  52718. results.push(this._albedoTexture);
  52719. }
  52720. if (this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0) {
  52721. results.push(this._ambientTexture);
  52722. }
  52723. if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
  52724. results.push(this._opacityTexture);
  52725. }
  52726. if (this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0) {
  52727. results.push(this._reflectionTexture);
  52728. }
  52729. if (this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0) {
  52730. results.push(this._emissiveTexture);
  52731. }
  52732. if (this._metallicTexture && this._metallicTexture.animations && this._metallicTexture.animations.length > 0) {
  52733. results.push(this._metallicTexture);
  52734. }
  52735. else if (this._reflectivityTexture && this._reflectivityTexture.animations && this._reflectivityTexture.animations.length > 0) {
  52736. results.push(this._reflectivityTexture);
  52737. }
  52738. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  52739. results.push(this._bumpTexture);
  52740. }
  52741. if (this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0) {
  52742. results.push(this._lightmapTexture);
  52743. }
  52744. if (this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0) {
  52745. results.push(this._refractionTexture);
  52746. }
  52747. this.clearCoat.getAnimatables(results);
  52748. return results;
  52749. };
  52750. /**
  52751. * Returns the texture used for reflections.
  52752. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  52753. */
  52754. PBRBaseMaterial.prototype._getReflectionTexture = function () {
  52755. if (this._reflectionTexture) {
  52756. return this._reflectionTexture;
  52757. }
  52758. return this.getScene().environmentTexture;
  52759. };
  52760. /**
  52761. * Returns the texture used for refraction or null if none is used.
  52762. * @returns - Refection texture if present. If no refraction texture and refraction
  52763. * is linked with transparency, returns environment texture. Otherwise, returns null.
  52764. */
  52765. PBRBaseMaterial.prototype._getRefractionTexture = function () {
  52766. if (this._refractionTexture) {
  52767. return this._refractionTexture;
  52768. }
  52769. if (this._linkRefractionWithTransparency) {
  52770. return this.getScene().environmentTexture;
  52771. }
  52772. return null;
  52773. };
  52774. /**
  52775. * Returns an array of the actively used textures.
  52776. * @returns - Array of BaseTextures
  52777. */
  52778. PBRBaseMaterial.prototype.getActiveTextures = function () {
  52779. var activeTextures = _super.prototype.getActiveTextures.call(this);
  52780. if (this._albedoTexture) {
  52781. activeTextures.push(this._albedoTexture);
  52782. }
  52783. if (this._ambientTexture) {
  52784. activeTextures.push(this._ambientTexture);
  52785. }
  52786. if (this._opacityTexture) {
  52787. activeTextures.push(this._opacityTexture);
  52788. }
  52789. if (this._reflectionTexture) {
  52790. activeTextures.push(this._reflectionTexture);
  52791. }
  52792. if (this._emissiveTexture) {
  52793. activeTextures.push(this._emissiveTexture);
  52794. }
  52795. if (this._reflectivityTexture) {
  52796. activeTextures.push(this._reflectivityTexture);
  52797. }
  52798. if (this._metallicTexture) {
  52799. activeTextures.push(this._metallicTexture);
  52800. }
  52801. if (this._microSurfaceTexture) {
  52802. activeTextures.push(this._microSurfaceTexture);
  52803. }
  52804. if (this._bumpTexture) {
  52805. activeTextures.push(this._bumpTexture);
  52806. }
  52807. if (this._lightmapTexture) {
  52808. activeTextures.push(this._lightmapTexture);
  52809. }
  52810. if (this._refractionTexture) {
  52811. activeTextures.push(this._refractionTexture);
  52812. }
  52813. this.clearCoat.getActiveTextures(activeTextures);
  52814. return activeTextures;
  52815. };
  52816. /**
  52817. * Checks to see if a texture is used in the material.
  52818. * @param texture - Base texture to use.
  52819. * @returns - Boolean specifying if a texture is used in the material.
  52820. */
  52821. PBRBaseMaterial.prototype.hasTexture = function (texture) {
  52822. if (_super.prototype.hasTexture.call(this, texture)) {
  52823. return true;
  52824. }
  52825. if (this._albedoTexture === texture) {
  52826. return true;
  52827. }
  52828. if (this._ambientTexture === texture) {
  52829. return true;
  52830. }
  52831. if (this._opacityTexture === texture) {
  52832. return true;
  52833. }
  52834. if (this._reflectionTexture === texture) {
  52835. return true;
  52836. }
  52837. if (this._reflectivityTexture === texture) {
  52838. return true;
  52839. }
  52840. if (this._metallicTexture === texture) {
  52841. return true;
  52842. }
  52843. if (this._microSurfaceTexture === texture) {
  52844. return true;
  52845. }
  52846. if (this._bumpTexture === texture) {
  52847. return true;
  52848. }
  52849. if (this._lightmapTexture === texture) {
  52850. return true;
  52851. }
  52852. return this.clearCoat.hasTexture(texture);
  52853. };
  52854. /**
  52855. * Disposes the resources of the material.
  52856. * @param forceDisposeEffect - Forces the disposal of effects.
  52857. * @param forceDisposeTextures - Forces the disposal of all textures.
  52858. */
  52859. PBRBaseMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  52860. if (forceDisposeTextures) {
  52861. if (this._albedoTexture) {
  52862. this._albedoTexture.dispose();
  52863. }
  52864. if (this._ambientTexture) {
  52865. this._ambientTexture.dispose();
  52866. }
  52867. if (this._opacityTexture) {
  52868. this._opacityTexture.dispose();
  52869. }
  52870. if (this._reflectionTexture) {
  52871. this._reflectionTexture.dispose();
  52872. }
  52873. if (this._environmentBRDFTexture && this.getScene()._environmentBRDFTexture !== this._environmentBRDFTexture) {
  52874. this._environmentBRDFTexture.dispose();
  52875. }
  52876. if (this._emissiveTexture) {
  52877. this._emissiveTexture.dispose();
  52878. }
  52879. if (this._metallicTexture) {
  52880. this._metallicTexture.dispose();
  52881. }
  52882. if (this._reflectivityTexture) {
  52883. this._reflectivityTexture.dispose();
  52884. }
  52885. if (this._bumpTexture) {
  52886. this._bumpTexture.dispose();
  52887. }
  52888. if (this._lightmapTexture) {
  52889. this._lightmapTexture.dispose();
  52890. }
  52891. if (this._refractionTexture) {
  52892. this._refractionTexture.dispose();
  52893. }
  52894. }
  52895. this.clearCoat.dispose(forceDisposeTextures);
  52896. this._renderTargets.dispose();
  52897. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  52898. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  52899. }
  52900. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  52901. };
  52902. /**
  52903. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52904. */
  52905. PBRBaseMaterial.PBRMATERIAL_OPAQUE = 0;
  52906. /**
  52907. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52908. */
  52909. PBRBaseMaterial.PBRMATERIAL_ALPHATEST = 1;
  52910. /**
  52911. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52912. */
  52913. PBRBaseMaterial.PBRMATERIAL_ALPHABLEND = 2;
  52914. /**
  52915. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52916. * They are also discarded below the alpha cutoff threshold to improve performances.
  52917. */
  52918. PBRBaseMaterial.PBRMATERIAL_ALPHATESTANDBLEND = 3;
  52919. /**
  52920. * Defines the default value of how much AO map is occluding the analytical lights
  52921. * (point spot...).
  52922. */
  52923. PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = 0;
  52924. /**
  52925. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  52926. */
  52927. PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL = 0;
  52928. /**
  52929. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  52930. * to enhance interoperability with other engines.
  52931. */
  52932. PBRBaseMaterial.LIGHTFALLOFF_GLTF = 1;
  52933. /**
  52934. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  52935. * to enhance interoperability with other materials.
  52936. */
  52937. PBRBaseMaterial.LIGHTFALLOFF_STANDARD = 2;
  52938. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52939. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsImageProcessingConfiguration"])()
  52940. ], PBRBaseMaterial.prototype, "_imageProcessingConfiguration", void 0);
  52941. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52942. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  52943. ], PBRBaseMaterial.prototype, "debugMode", void 0);
  52944. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52945. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52946. ], PBRBaseMaterial.prototype, "useLogarithmicDepth", null);
  52947. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52948. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52949. ], PBRBaseMaterial.prototype, "transparencyMode", null);
  52950. return PBRBaseMaterial;
  52951. }(_Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_14__["PushMaterial"]));
  52952. /***/ }),
  52953. /***/ "./Materials/PBR/pbrBaseSimpleMaterial.ts":
  52954. /*!************************************************!*\
  52955. !*** ./Materials/PBR/pbrBaseSimpleMaterial.ts ***!
  52956. \************************************************/
  52957. /*! exports provided: PBRBaseSimpleMaterial */
  52958. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52959. "use strict";
  52960. __webpack_require__.r(__webpack_exports__);
  52961. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return PBRBaseSimpleMaterial; });
  52962. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  52963. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  52964. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  52965. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  52966. /**
  52967. * The Physically based simple base material of BJS.
  52968. *
  52969. * This enables better naming and convention enforcements on top of the pbrMaterial.
  52970. * It is used as the base class for both the specGloss and metalRough conventions.
  52971. */
  52972. var PBRBaseSimpleMaterial = /** @class */ (function (_super) {
  52973. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRBaseSimpleMaterial, _super);
  52974. /**
  52975. * Instantiates a new PBRMaterial instance.
  52976. *
  52977. * @param name The material name
  52978. * @param scene The scene the material will be use in.
  52979. */
  52980. function PBRBaseSimpleMaterial(name, scene) {
  52981. var _this = _super.call(this, name, scene) || this;
  52982. /**
  52983. * Number of Simultaneous lights allowed on the material.
  52984. */
  52985. _this.maxSimultaneousLights = 4;
  52986. /**
  52987. * If sets to true, disables all the lights affecting the material.
  52988. */
  52989. _this.disableLighting = false;
  52990. /**
  52991. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52992. */
  52993. _this.invertNormalMapX = false;
  52994. /**
  52995. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52996. */
  52997. _this.invertNormalMapY = false;
  52998. /**
  52999. * Emissivie color used to self-illuminate the model.
  53000. */
  53001. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0, 0, 0);
  53002. /**
  53003. * Occlusion Channel Strenght.
  53004. */
  53005. _this.occlusionStrength = 1.0;
  53006. /**
  53007. * If true, the light map contains occlusion information instead of lighting info.
  53008. */
  53009. _this.useLightmapAsShadowmap = false;
  53010. _this._useAlphaFromAlbedoTexture = true;
  53011. _this._useAmbientInGrayScale = true;
  53012. return _this;
  53013. }
  53014. Object.defineProperty(PBRBaseSimpleMaterial.prototype, "doubleSided", {
  53015. /**
  53016. * Gets the current double sided mode.
  53017. */
  53018. get: function () {
  53019. return this._twoSidedLighting;
  53020. },
  53021. /**
  53022. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53023. */
  53024. set: function (value) {
  53025. if (this._twoSidedLighting === value) {
  53026. return;
  53027. }
  53028. this._twoSidedLighting = value;
  53029. this.backFaceCulling = !value;
  53030. this._markAllSubMeshesAsTexturesDirty();
  53031. },
  53032. enumerable: true,
  53033. configurable: true
  53034. });
  53035. PBRBaseSimpleMaterial.prototype.getClassName = function () {
  53036. return "PBRBaseSimpleMaterial";
  53037. };
  53038. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53039. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53040. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  53041. ], PBRBaseSimpleMaterial.prototype, "maxSimultaneousLights", void 0);
  53042. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53043. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53044. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  53045. ], PBRBaseSimpleMaterial.prototype, "disableLighting", void 0);
  53046. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53047. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53048. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectionTexture")
  53049. ], PBRBaseSimpleMaterial.prototype, "environmentTexture", void 0);
  53050. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53051. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53052. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53053. ], PBRBaseSimpleMaterial.prototype, "invertNormalMapX", void 0);
  53054. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53055. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53056. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53057. ], PBRBaseSimpleMaterial.prototype, "invertNormalMapY", void 0);
  53058. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53059. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53060. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_bumpTexture")
  53061. ], PBRBaseSimpleMaterial.prototype, "normalTexture", void 0);
  53062. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53063. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive"),
  53064. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53065. ], PBRBaseSimpleMaterial.prototype, "emissiveColor", void 0);
  53066. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53067. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53068. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53069. ], PBRBaseSimpleMaterial.prototype, "emissiveTexture", void 0);
  53070. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53071. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53072. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_ambientTextureStrength")
  53073. ], PBRBaseSimpleMaterial.prototype, "occlusionStrength", void 0);
  53074. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53075. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53076. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_ambientTexture")
  53077. ], PBRBaseSimpleMaterial.prototype, "occlusionTexture", void 0);
  53078. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53079. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53080. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_alphaCutOff")
  53081. ], PBRBaseSimpleMaterial.prototype, "alphaCutOff", void 0);
  53082. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53083. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53084. ], PBRBaseSimpleMaterial.prototype, "doubleSided", null);
  53085. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53086. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53087. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", null)
  53088. ], PBRBaseSimpleMaterial.prototype, "lightmapTexture", void 0);
  53089. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53090. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53091. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53092. ], PBRBaseSimpleMaterial.prototype, "useLightmapAsShadowmap", void 0);
  53093. return PBRBaseSimpleMaterial;
  53094. }(_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_3__["PBRBaseMaterial"]));
  53095. /***/ }),
  53096. /***/ "./Materials/PBR/pbrClearCoatConfiguration.ts":
  53097. /*!****************************************************!*\
  53098. !*** ./Materials/PBR/pbrClearCoatConfiguration.ts ***!
  53099. \****************************************************/
  53100. /*! exports provided: PBRClearCoatConfiguration */
  53101. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53102. "use strict";
  53103. __webpack_require__.r(__webpack_exports__);
  53104. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRClearCoatConfiguration", function() { return PBRClearCoatConfiguration; });
  53105. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53106. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  53107. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  53108. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  53109. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  53110. /**
  53111. * Define the code related to the clear coat parameters of the pbr material.
  53112. */
  53113. var PBRClearCoatConfiguration = /** @class */ (function () {
  53114. /**
  53115. * Instantiate a new istance of clear coat configuration.
  53116. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53117. */
  53118. function PBRClearCoatConfiguration(markAllSubMeshesAsTexturesDirty) {
  53119. this._isEnabled = false;
  53120. /**
  53121. * Defines if the clear coat is enabled in the material.
  53122. */
  53123. this.isEnabled = false;
  53124. /**
  53125. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  53126. */
  53127. this.intensity = 1;
  53128. /**
  53129. * Defines the clear coat layer roughness.
  53130. */
  53131. this.roughness = 0;
  53132. this._indiceOfRefraction = PBRClearCoatConfiguration._DefaultIndiceOfRefraction;
  53133. /**
  53134. * Defines the indice of refraction of the clear coat.
  53135. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53136. * The default fits with a polyurethane material.
  53137. * Changing the default value is more performance intensive.
  53138. */
  53139. this.indiceOfRefraction = PBRClearCoatConfiguration._DefaultIndiceOfRefraction;
  53140. this._texture = null;
  53141. /**
  53142. * Stores the clear coat values in a texture.
  53143. */
  53144. this.texture = null;
  53145. this._bumpTexture = null;
  53146. /**
  53147. * Define the clear coat specific bump texture.
  53148. */
  53149. this.bumpTexture = null;
  53150. this._isTintEnabled = false;
  53151. /**
  53152. * Defines if the clear coat tint is enabled in the material.
  53153. */
  53154. this.isTintEnabled = false;
  53155. /**
  53156. * Defines if the clear coat tint is enabled in the material.
  53157. * This is only use if tint is enabled
  53158. */
  53159. this.tintColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].White();
  53160. /**
  53161. * Defines if the distance at which the tint color should be found in the
  53162. * clear coat media.
  53163. * This is only use if tint is enabled
  53164. */
  53165. this.tintColorAtDistance = 1;
  53166. /**
  53167. * Defines the clear coat layer thickness.
  53168. * This is only use if tint is enabled
  53169. */
  53170. this.tintThickness = 1;
  53171. this._tintTexture = null;
  53172. /**
  53173. * Stores the clear tint values in a texture.
  53174. * rgb is tint
  53175. * a is a thickness factor
  53176. */
  53177. this.tintTexture = null;
  53178. this._internalMarkAllSubMeshesAsTexturesDirty = markAllSubMeshesAsTexturesDirty;
  53179. }
  53180. /** @hidden */
  53181. PBRClearCoatConfiguration.prototype._markAllSubMeshesAsTexturesDirty = function () {
  53182. this._internalMarkAllSubMeshesAsTexturesDirty();
  53183. };
  53184. /**
  53185. * Specifies that the submesh is ready to be used.
  53186. * @param defines the list of "defines" to update.
  53187. * @param scene defines the scene the material belongs to.
  53188. * @param engine defines the engine the material belongs to.
  53189. * @param disableBumpMap defines wether the material disables bump or not.
  53190. * @returns - boolean indicating that the submesh is ready or not.
  53191. */
  53192. PBRClearCoatConfiguration.prototype.isReadyForSubMesh = function (defines, scene, engine, disableBumpMap) {
  53193. if (defines._areTexturesDirty) {
  53194. if (scene.texturesEnabled) {
  53195. if (this._texture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled) {
  53196. if (!this._texture.isReadyOrNotBlocking()) {
  53197. return false;
  53198. }
  53199. }
  53200. if (engine.getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatBumpTextureEnabled && !disableBumpMap) {
  53201. // Bump texture cannot be not blocking.
  53202. if (!this._bumpTexture.isReady()) {
  53203. return false;
  53204. }
  53205. }
  53206. if (this._isTintEnabled && this._tintTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTintTextureEnabled) {
  53207. if (!this._tintTexture.isReadyOrNotBlocking()) {
  53208. return false;
  53209. }
  53210. }
  53211. }
  53212. }
  53213. return true;
  53214. };
  53215. /**
  53216. * Checks to see if a texture is used in the material.
  53217. * @param defines the list of "defines" to update.
  53218. * @param scene defines the scene to the material belongs to.
  53219. */
  53220. PBRClearCoatConfiguration.prototype.prepareDefines = function (defines, scene) {
  53221. if (this._isEnabled) {
  53222. defines.CLEARCOAT = true;
  53223. if (defines._areTexturesDirty) {
  53224. if (scene.texturesEnabled) {
  53225. if (this._texture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled) {
  53226. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForMergedUV(this._texture, defines, "CLEARCOAT_TEXTURE");
  53227. }
  53228. else {
  53229. defines.CLEARCOAT_TEXTURE = false;
  53230. }
  53231. if (this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatBumpTextureEnabled) {
  53232. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "CLEARCOAT_BUMP");
  53233. }
  53234. else {
  53235. defines.CLEARCOAT_BUMP = false;
  53236. }
  53237. defines.CLEARCOAT_DEFAULTIOR = this._indiceOfRefraction === PBRClearCoatConfiguration._DefaultIndiceOfRefraction;
  53238. if (this._isTintEnabled) {
  53239. defines.CLEARCOAT_TINT = true;
  53240. if (this._tintTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTintTextureEnabled) {
  53241. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForMergedUV(this._tintTexture, defines, "CLEARCOAT_TINT_TEXTURE");
  53242. }
  53243. else {
  53244. defines.CLEARCOAT_TINT_TEXTURE = false;
  53245. }
  53246. }
  53247. else {
  53248. defines.CLEARCOAT_TINT = false;
  53249. defines.CLEARCOAT_TINT_TEXTURE = false;
  53250. }
  53251. }
  53252. }
  53253. }
  53254. else {
  53255. defines.CLEARCOAT = false;
  53256. defines.CLEARCOAT_TEXTURE = false;
  53257. defines.CLEARCOAT_BUMP = false;
  53258. defines.CLEARCOAT_TINT = false;
  53259. defines.CLEARCOAT_TINT_TEXTURE = false;
  53260. }
  53261. };
  53262. /**
  53263. * Binds the material data.
  53264. * @param uniformBuffer defines the Uniform buffer to fill in.
  53265. * @param scene defines the scene the material belongs to.
  53266. * @param engine defines the engine the material belongs to.
  53267. * @param disableBumpMap defines wether the material disables bump or not.
  53268. * @param isFrozen defines wether the material is frozen or not.
  53269. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53270. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53271. */
  53272. PBRClearCoatConfiguration.prototype.bindForSubMesh = function (uniformBuffer, scene, engine, disableBumpMap, isFrozen, invertNormalMapX, invertNormalMapY) {
  53273. if (!uniformBuffer.useUbo || !isFrozen || !uniformBuffer.isSync) {
  53274. if (this._texture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled) {
  53275. uniformBuffer.updateFloat2("vClearCoatInfos", this._texture.coordinatesIndex, this._texture.level);
  53276. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindTextureMatrix(this._texture, uniformBuffer, "clearCoat");
  53277. }
  53278. if (this._bumpTexture && engine.getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled && !disableBumpMap) {
  53279. uniformBuffer.updateFloat2("vClearCoatBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level);
  53280. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, uniformBuffer, "clearCoatBump");
  53281. if (scene._mirroredCameraPosition) {
  53282. uniformBuffer.updateFloat2("vClearCoatTangentSpaceParams", invertNormalMapX ? 1.0 : -1.0, invertNormalMapY ? 1.0 : -1.0);
  53283. }
  53284. else {
  53285. uniformBuffer.updateFloat2("vClearCoatTangentSpaceParams", invertNormalMapX ? -1.0 : 1.0, invertNormalMapY ? -1.0 : 1.0);
  53286. }
  53287. }
  53288. if (this._tintTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTintTextureEnabled) {
  53289. uniformBuffer.updateFloat2("vClearCoatTintInfos", this._tintTexture.coordinatesIndex, this._tintTexture.level);
  53290. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindTextureMatrix(this._tintTexture, uniformBuffer, "clearCoatTint");
  53291. }
  53292. // Clear Coat General params
  53293. uniformBuffer.updateFloat2("vClearCoatParams", this.intensity, this.roughness);
  53294. // Clear Coat Refraction params
  53295. var a = 1 - this._indiceOfRefraction;
  53296. var b = 1 + this._indiceOfRefraction;
  53297. var f0 = Math.pow((-a / b), 2); // Schlicks approx: (ior1 - ior2) / (ior1 + ior2) where ior2 for air is close to vacuum = 1.
  53298. var eta = 1 / this._indiceOfRefraction;
  53299. uniformBuffer.updateFloat4("vClearCoatRefractionParams", f0, eta, a, b);
  53300. if (this._isTintEnabled) {
  53301. uniformBuffer.updateFloat4("vClearCoatTintParams", this.tintColor.r, this.tintColor.g, this.tintColor.b, Math.max(0.00001, this.tintThickness));
  53302. uniformBuffer.updateFloat("clearCoatColorAtDistance", Math.max(0.00001, this.tintColorAtDistance));
  53303. }
  53304. }
  53305. // Textures
  53306. if (scene.texturesEnabled) {
  53307. if (this._texture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled) {
  53308. uniformBuffer.setTexture("clearCoatSampler", this._texture);
  53309. }
  53310. if (this._bumpTexture && engine.getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatBumpTextureEnabled && !disableBumpMap) {
  53311. uniformBuffer.setTexture("clearCoatBumpSampler", this._bumpTexture);
  53312. }
  53313. if (this._isTintEnabled && this._tintTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTintTextureEnabled) {
  53314. uniformBuffer.setTexture("clearCoatTintSampler", this._tintTexture);
  53315. }
  53316. }
  53317. };
  53318. /**
  53319. * Checks to see if a texture is used in the material.
  53320. * @param texture - Base texture to use.
  53321. * @returns - Boolean specifying if a texture is used in the material.
  53322. */
  53323. PBRClearCoatConfiguration.prototype.hasTexture = function (texture) {
  53324. if (this._texture === texture) {
  53325. return true;
  53326. }
  53327. if (this._bumpTexture === texture) {
  53328. return true;
  53329. }
  53330. if (this._tintTexture === texture) {
  53331. return true;
  53332. }
  53333. return false;
  53334. };
  53335. /**
  53336. * Returns an array of the actively used textures.
  53337. * @param activeTextures Array of BaseTextures
  53338. */
  53339. PBRClearCoatConfiguration.prototype.getActiveTextures = function (activeTextures) {
  53340. if (this._texture) {
  53341. activeTextures.push(this._texture);
  53342. }
  53343. if (this._bumpTexture) {
  53344. activeTextures.push(this._bumpTexture);
  53345. }
  53346. if (this._tintTexture) {
  53347. activeTextures.push(this._tintTexture);
  53348. }
  53349. };
  53350. /**
  53351. * Returns the animatable textures.
  53352. * @param animatables Array of animatable textures.
  53353. */
  53354. PBRClearCoatConfiguration.prototype.getAnimatables = function (animatables) {
  53355. if (this._texture && this._texture.animations && this._texture.animations.length > 0) {
  53356. animatables.push(this._texture);
  53357. }
  53358. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  53359. animatables.push(this._bumpTexture);
  53360. }
  53361. if (this._tintTexture && this._tintTexture.animations && this._tintTexture.animations.length > 0) {
  53362. animatables.push(this._tintTexture);
  53363. }
  53364. };
  53365. /**
  53366. * Disposes the resources of the material.
  53367. * @param forceDisposeTextures - Forces the disposal of all textures.
  53368. */
  53369. PBRClearCoatConfiguration.prototype.dispose = function (forceDisposeTextures) {
  53370. if (forceDisposeTextures) {
  53371. if (this._texture) {
  53372. this._texture.dispose();
  53373. }
  53374. if (this._bumpTexture) {
  53375. this._bumpTexture.dispose();
  53376. }
  53377. if (this._tintTexture) {
  53378. this._tintTexture.dispose();
  53379. }
  53380. }
  53381. };
  53382. /**
  53383. * Get the current class name of the texture useful for serialization or dynamic coding.
  53384. * @returns "PBRClearCoatConfiguration"
  53385. */
  53386. PBRClearCoatConfiguration.prototype.getClassName = function () {
  53387. return "PBRClearCoatConfiguration";
  53388. };
  53389. /**
  53390. * Makes a duplicate of the current configuration into another one.
  53391. * @param clearCoatConfiguration define the config where to copy the info
  53392. */
  53393. PBRClearCoatConfiguration.prototype.copyTo = function (clearCoatConfiguration) {
  53394. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return clearCoatConfiguration; }, this);
  53395. };
  53396. /**
  53397. * Serializes this clear coat configuration.
  53398. * @returns - An object with the serialized config.
  53399. */
  53400. PBRClearCoatConfiguration.prototype.serialize = function () {
  53401. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  53402. };
  53403. /**
  53404. * Parses a Clear Coat Configuration from a serialized object.
  53405. * @param source - Serialized object.
  53406. */
  53407. PBRClearCoatConfiguration.prototype.parse = function (source) {
  53408. var _this = this;
  53409. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, null);
  53410. };
  53411. /**
  53412. * Add fallbacks to the effect fallbacks list.
  53413. * @param defines defines the Base texture to use.
  53414. * @param fallbacks defines the current fallback list.
  53415. * @param currentRank defines the current fallback rank.
  53416. * @returns the new fallback rank.
  53417. */
  53418. PBRClearCoatConfiguration.AddFallbacks = function (defines, fallbacks, currentRank) {
  53419. if (defines.CLEARCOAT_BUMP) {
  53420. fallbacks.addFallback(currentRank++, "CLEARCOAT_BUMP");
  53421. }
  53422. if (defines.CLEARCOAT_TINT) {
  53423. fallbacks.addFallback(currentRank++, "CLEARCOAT_TINT");
  53424. }
  53425. if (defines.CLEARCOAT) {
  53426. fallbacks.addFallback(currentRank++, "CLEARCOAT");
  53427. }
  53428. return currentRank;
  53429. };
  53430. /**
  53431. * Add the required uniforms to the current list.
  53432. * @param uniforms defines the current uniform list.
  53433. */
  53434. PBRClearCoatConfiguration.AddUniforms = function (uniforms) {
  53435. uniforms.push("vClearCoatTangentSpaceParams", "vClearCoatParams", "vClearCoatRefractionParams", "vClearCoatTintParams", "clearCoatColorAtDistance", "clearCoatMatrix", "clearCoatBumpMatrix", "clearCoatTintMatrix", "vClearCoatInfos", "vClearCoatBumpInfos", "vClearCoatTintInfos");
  53436. };
  53437. /**
  53438. * Add the required samplers to the current list.
  53439. * @param samplers defines the current sampler list.
  53440. */
  53441. PBRClearCoatConfiguration.AddSamplers = function (samplers) {
  53442. samplers.push("clearCoatSampler", "clearCoatBumpSampler", "clearCoatTintSampler");
  53443. };
  53444. /**
  53445. * Add the required uniforms to the current buffer.
  53446. * @param uniformBuffer defines the current uniform buffer.
  53447. */
  53448. PBRClearCoatConfiguration.PrepareUniformBuffer = function (uniformBuffer) {
  53449. uniformBuffer.addUniform("vClearCoatParams", 2);
  53450. uniformBuffer.addUniform("vClearCoatRefractionParams", 4);
  53451. uniformBuffer.addUniform("vClearCoatInfos", 2);
  53452. uniformBuffer.addUniform("clearCoatMatrix", 16);
  53453. uniformBuffer.addUniform("vClearCoatBumpInfos", 2);
  53454. uniformBuffer.addUniform("vClearCoatTangentSpaceParams", 2);
  53455. uniformBuffer.addUniform("clearCoatBumpMatrix", 16);
  53456. uniformBuffer.addUniform("vClearCoatTintParams", 4);
  53457. uniformBuffer.addUniform("clearCoatColorAtDistance", 1);
  53458. uniformBuffer.addUniform("vClearCoatTintInfos", 2);
  53459. uniformBuffer.addUniform("clearCoatTintMatrix", 16);
  53460. };
  53461. /**
  53462. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53463. * The default fits with a polyurethane material.
  53464. */
  53465. PBRClearCoatConfiguration._DefaultIndiceOfRefraction = 1.5;
  53466. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53467. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53468. ], PBRClearCoatConfiguration.prototype, "_isEnabled", void 0);
  53469. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53470. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53471. ], PBRClearCoatConfiguration.prototype, "isEnabled", void 0);
  53472. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53473. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53474. ], PBRClearCoatConfiguration.prototype, "intensity", void 0);
  53475. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53476. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53477. ], PBRClearCoatConfiguration.prototype, "roughness", void 0);
  53478. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53479. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53480. ], PBRClearCoatConfiguration.prototype, "_indiceOfRefraction", void 0);
  53481. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53482. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53483. ], PBRClearCoatConfiguration.prototype, "indiceOfRefraction", void 0);
  53484. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53485. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  53486. ], PBRClearCoatConfiguration.prototype, "_texture", void 0);
  53487. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53488. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53489. ], PBRClearCoatConfiguration.prototype, "texture", void 0);
  53490. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53491. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  53492. ], PBRClearCoatConfiguration.prototype, "_bumpTexture", void 0);
  53493. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53494. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53495. ], PBRClearCoatConfiguration.prototype, "bumpTexture", void 0);
  53496. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53497. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53498. ], PBRClearCoatConfiguration.prototype, "_isTintEnabled", void 0);
  53499. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53500. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53501. ], PBRClearCoatConfiguration.prototype, "isTintEnabled", void 0);
  53502. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53503. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53504. ], PBRClearCoatConfiguration.prototype, "tintColor", void 0);
  53505. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53506. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53507. ], PBRClearCoatConfiguration.prototype, "tintColorAtDistance", void 0);
  53508. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53509. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53510. ], PBRClearCoatConfiguration.prototype, "tintThickness", void 0);
  53511. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53512. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  53513. ], PBRClearCoatConfiguration.prototype, "_tintTexture", void 0);
  53514. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53515. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53516. ], PBRClearCoatConfiguration.prototype, "tintTexture", void 0);
  53517. return PBRClearCoatConfiguration;
  53518. }());
  53519. /***/ }),
  53520. /***/ "./Materials/PBR/pbrMaterial.ts":
  53521. /*!**************************************!*\
  53522. !*** ./Materials/PBR/pbrMaterial.ts ***!
  53523. \**************************************/
  53524. /*! exports provided: PBRMaterial */
  53525. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53526. "use strict";
  53527. __webpack_require__.r(__webpack_exports__);
  53528. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return PBRMaterial; });
  53529. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53530. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  53531. /* harmony import */ var _Misc_textureTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/textureTools */ "./Misc/textureTools.ts");
  53532. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  53533. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  53534. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  53535. /**
  53536. * The Physically based material of BJS.
  53537. *
  53538. * This offers the main features of a standard PBR material.
  53539. * For more information, please refer to the documentation :
  53540. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  53541. */
  53542. var PBRMaterial = /** @class */ (function (_super) {
  53543. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMaterial, _super);
  53544. /**
  53545. * Instantiates a new PBRMaterial instance.
  53546. *
  53547. * @param name The material name
  53548. * @param scene The scene the material will be use in.
  53549. */
  53550. function PBRMaterial(name, scene) {
  53551. var _this = _super.call(this, name, scene) || this;
  53552. /**
  53553. * Intensity of the direct lights e.g. the four lights available in your scene.
  53554. * This impacts both the direct diffuse and specular highlights.
  53555. */
  53556. _this.directIntensity = 1.0;
  53557. /**
  53558. * Intensity of the emissive part of the material.
  53559. * This helps controlling the emissive effect without modifying the emissive color.
  53560. */
  53561. _this.emissiveIntensity = 1.0;
  53562. /**
  53563. * Intensity of the environment e.g. how much the environment will light the object
  53564. * either through harmonics for rough material or through the refelction for shiny ones.
  53565. */
  53566. _this.environmentIntensity = 1.0;
  53567. /**
  53568. * This is a special control allowing the reduction of the specular highlights coming from the
  53569. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53570. */
  53571. _this.specularIntensity = 1.0;
  53572. /**
  53573. * Debug Control allowing disabling the bump map on this material.
  53574. */
  53575. _this.disableBumpMap = false;
  53576. /**
  53577. * AKA Occlusion Texture Intensity in other nomenclature.
  53578. */
  53579. _this.ambientTextureStrength = 1.0;
  53580. /**
  53581. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53582. * 1 means it completely occludes it
  53583. * 0 mean it has no impact
  53584. */
  53585. _this.ambientTextureImpactOnAnalyticalLights = PBRMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  53586. /**
  53587. * The color of a material in ambient lighting.
  53588. */
  53589. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0, 0, 0);
  53590. /**
  53591. * AKA Diffuse Color in other nomenclature.
  53592. */
  53593. _this.albedoColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  53594. /**
  53595. * AKA Specular Color in other nomenclature.
  53596. */
  53597. _this.reflectivityColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  53598. /**
  53599. * The color reflected from the material.
  53600. */
  53601. _this.reflectionColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1.0, 1.0, 1.0);
  53602. /**
  53603. * The color emitted from the material.
  53604. */
  53605. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0, 0, 0);
  53606. /**
  53607. * AKA Glossiness in other nomenclature.
  53608. */
  53609. _this.microSurface = 1.0;
  53610. /**
  53611. * source material index of refraction (IOR)' / 'destination material IOR.
  53612. */
  53613. _this.indexOfRefraction = 0.66;
  53614. /**
  53615. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  53616. */
  53617. _this.invertRefractionY = false;
  53618. /**
  53619. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  53620. * Materials half opaque for instance using refraction could benefit from this control.
  53621. */
  53622. _this.linkRefractionWithTransparency = false;
  53623. /**
  53624. * If true, the light map contains occlusion information instead of lighting info.
  53625. */
  53626. _this.useLightmapAsShadowmap = false;
  53627. /**
  53628. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53629. */
  53630. _this.useAlphaFromAlbedoTexture = false;
  53631. /**
  53632. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53633. */
  53634. _this.forceAlphaTest = false;
  53635. /**
  53636. * Defines the alpha limits in alpha test mode.
  53637. */
  53638. _this.alphaCutOff = 0.4;
  53639. /**
  53640. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  53641. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53642. */
  53643. _this.useSpecularOverAlpha = true;
  53644. /**
  53645. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53646. */
  53647. _this.useMicroSurfaceFromReflectivityMapAlpha = false;
  53648. /**
  53649. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53650. */
  53651. _this.useRoughnessFromMetallicTextureAlpha = true;
  53652. /**
  53653. * Specifies if the metallic texture contains the roughness information in its green channel.
  53654. */
  53655. _this.useRoughnessFromMetallicTextureGreen = false;
  53656. /**
  53657. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53658. */
  53659. _this.useMetallnessFromMetallicTextureBlue = false;
  53660. /**
  53661. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53662. */
  53663. _this.useAmbientOcclusionFromMetallicTextureRed = false;
  53664. /**
  53665. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53666. */
  53667. _this.useAmbientInGrayScale = false;
  53668. /**
  53669. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53670. * The material will try to infer what glossiness each pixel should be.
  53671. */
  53672. _this.useAutoMicroSurfaceFromReflectivityMap = false;
  53673. /**
  53674. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53675. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53676. */
  53677. _this.useRadianceOverAlpha = true;
  53678. /**
  53679. * Allows using an object space normal map (instead of tangent space).
  53680. */
  53681. _this.useObjectSpaceNormalMap = false;
  53682. /**
  53683. * Allows using the bump map in parallax mode.
  53684. */
  53685. _this.useParallax = false;
  53686. /**
  53687. * Allows using the bump map in parallax occlusion mode.
  53688. */
  53689. _this.useParallaxOcclusion = false;
  53690. /**
  53691. * Controls the scale bias of the parallax mode.
  53692. */
  53693. _this.parallaxScaleBias = 0.05;
  53694. /**
  53695. * If sets to true, disables all the lights affecting the material.
  53696. */
  53697. _this.disableLighting = false;
  53698. /**
  53699. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53700. */
  53701. _this.forceIrradianceInFragment = false;
  53702. /**
  53703. * Number of Simultaneous lights allowed on the material.
  53704. */
  53705. _this.maxSimultaneousLights = 4;
  53706. /**
  53707. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53708. */
  53709. _this.invertNormalMapX = false;
  53710. /**
  53711. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53712. */
  53713. _this.invertNormalMapY = false;
  53714. /**
  53715. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53716. */
  53717. _this.twoSidedLighting = false;
  53718. /**
  53719. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53720. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53721. */
  53722. _this.useAlphaFresnel = false;
  53723. /**
  53724. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53725. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53726. */
  53727. _this.useLinearAlphaFresnel = false;
  53728. /**
  53729. * Let user defines the brdf lookup texture used for IBL.
  53730. * A default 8bit version is embedded but you could point at :
  53731. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  53732. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  53733. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  53734. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  53735. */
  53736. _this.environmentBRDFTexture = null;
  53737. /**
  53738. * Force normal to face away from face.
  53739. */
  53740. _this.forceNormalForward = false;
  53741. /**
  53742. * Enables specular anti aliasing in the PBR shader.
  53743. * It will both interacts on the Geometry for analytical and IBL lighting.
  53744. * It also prefilter the roughness map based on the bump values.
  53745. */
  53746. _this.enableSpecularAntiAliasing = false;
  53747. /**
  53748. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53749. * makes the reflect vector face the model (under horizon).
  53750. */
  53751. _this.useHorizonOcclusion = true;
  53752. /**
  53753. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53754. * too much the area relying on ambient texture to define their ambient occlusion.
  53755. */
  53756. _this.useRadianceOcclusion = true;
  53757. /**
  53758. * If set to true, no lighting calculations will be applied.
  53759. */
  53760. _this.unlit = false;
  53761. _this._environmentBRDFTexture = _Misc_textureTools__WEBPACK_IMPORTED_MODULE_2__["TextureTools"].GetEnvironmentBRDFTexture(scene);
  53762. return _this;
  53763. }
  53764. Object.defineProperty(PBRMaterial.prototype, "usePhysicalLightFalloff", {
  53765. /**
  53766. * BJS is using an harcoded light falloff based on a manually sets up range.
  53767. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53768. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53769. */
  53770. get: function () {
  53771. return this._lightFalloff === _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_PHYSICAL;
  53772. },
  53773. /**
  53774. * BJS is using an harcoded light falloff based on a manually sets up range.
  53775. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53776. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53777. */
  53778. set: function (value) {
  53779. if (value !== this.usePhysicalLightFalloff) {
  53780. // Ensure the effect will be rebuilt.
  53781. this._markAllSubMeshesAsTexturesDirty();
  53782. if (value) {
  53783. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_PHYSICAL;
  53784. }
  53785. else {
  53786. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_STANDARD;
  53787. }
  53788. }
  53789. },
  53790. enumerable: true,
  53791. configurable: true
  53792. });
  53793. Object.defineProperty(PBRMaterial.prototype, "useGLTFLightFalloff", {
  53794. /**
  53795. * In order to support the falloff compatibility with gltf, a special mode has been added
  53796. * to reproduce the gltf light falloff.
  53797. */
  53798. get: function () {
  53799. return this._lightFalloff === _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_GLTF;
  53800. },
  53801. /**
  53802. * In order to support the falloff compatibility with gltf, a special mode has been added
  53803. * to reproduce the gltf light falloff.
  53804. */
  53805. set: function (value) {
  53806. if (value !== this.useGLTFLightFalloff) {
  53807. // Ensure the effect will be rebuilt.
  53808. this._markAllSubMeshesAsTexturesDirty();
  53809. if (value) {
  53810. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_GLTF;
  53811. }
  53812. else {
  53813. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_STANDARD;
  53814. }
  53815. }
  53816. },
  53817. enumerable: true,
  53818. configurable: true
  53819. });
  53820. Object.defineProperty(PBRMaterial.prototype, "imageProcessingConfiguration", {
  53821. /**
  53822. * Gets the image processing configuration used either in this material.
  53823. */
  53824. get: function () {
  53825. return this._imageProcessingConfiguration;
  53826. },
  53827. /**
  53828. * Sets the Default image processing configuration used either in the this material.
  53829. *
  53830. * If sets to null, the scene one is in use.
  53831. */
  53832. set: function (value) {
  53833. this._attachImageProcessingConfiguration(value);
  53834. // Ensure the effect will be rebuilt.
  53835. this._markAllSubMeshesAsTexturesDirty();
  53836. },
  53837. enumerable: true,
  53838. configurable: true
  53839. });
  53840. Object.defineProperty(PBRMaterial.prototype, "cameraColorCurvesEnabled", {
  53841. /**
  53842. * Gets wether the color curves effect is enabled.
  53843. */
  53844. get: function () {
  53845. return this.imageProcessingConfiguration.colorCurvesEnabled;
  53846. },
  53847. /**
  53848. * Sets wether the color curves effect is enabled.
  53849. */
  53850. set: function (value) {
  53851. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  53852. },
  53853. enumerable: true,
  53854. configurable: true
  53855. });
  53856. Object.defineProperty(PBRMaterial.prototype, "cameraColorGradingEnabled", {
  53857. /**
  53858. * Gets wether the color grading effect is enabled.
  53859. */
  53860. get: function () {
  53861. return this.imageProcessingConfiguration.colorGradingEnabled;
  53862. },
  53863. /**
  53864. * Gets wether the color grading effect is enabled.
  53865. */
  53866. set: function (value) {
  53867. this.imageProcessingConfiguration.colorGradingEnabled = value;
  53868. },
  53869. enumerable: true,
  53870. configurable: true
  53871. });
  53872. Object.defineProperty(PBRMaterial.prototype, "cameraToneMappingEnabled", {
  53873. /**
  53874. * Gets wether tonemapping is enabled or not.
  53875. */
  53876. get: function () {
  53877. return this._imageProcessingConfiguration.toneMappingEnabled;
  53878. },
  53879. /**
  53880. * Sets wether tonemapping is enabled or not
  53881. */
  53882. set: function (value) {
  53883. this._imageProcessingConfiguration.toneMappingEnabled = value;
  53884. },
  53885. enumerable: true,
  53886. configurable: true
  53887. });
  53888. Object.defineProperty(PBRMaterial.prototype, "cameraExposure", {
  53889. /**
  53890. * The camera exposure used on this material.
  53891. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53892. * This corresponds to a photographic exposure.
  53893. */
  53894. get: function () {
  53895. return this._imageProcessingConfiguration.exposure;
  53896. },
  53897. /**
  53898. * The camera exposure used on this material.
  53899. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53900. * This corresponds to a photographic exposure.
  53901. */
  53902. set: function (value) {
  53903. this._imageProcessingConfiguration.exposure = value;
  53904. },
  53905. enumerable: true,
  53906. configurable: true
  53907. });
  53908. Object.defineProperty(PBRMaterial.prototype, "cameraContrast", {
  53909. /**
  53910. * Gets The camera contrast used on this material.
  53911. */
  53912. get: function () {
  53913. return this._imageProcessingConfiguration.contrast;
  53914. },
  53915. /**
  53916. * Sets The camera contrast used on this material.
  53917. */
  53918. set: function (value) {
  53919. this._imageProcessingConfiguration.contrast = value;
  53920. },
  53921. enumerable: true,
  53922. configurable: true
  53923. });
  53924. Object.defineProperty(PBRMaterial.prototype, "cameraColorGradingTexture", {
  53925. /**
  53926. * Gets the Color Grading 2D Lookup Texture.
  53927. */
  53928. get: function () {
  53929. return this._imageProcessingConfiguration.colorGradingTexture;
  53930. },
  53931. /**
  53932. * Sets the Color Grading 2D Lookup Texture.
  53933. */
  53934. set: function (value) {
  53935. this._imageProcessingConfiguration.colorGradingTexture = value;
  53936. },
  53937. enumerable: true,
  53938. configurable: true
  53939. });
  53940. Object.defineProperty(PBRMaterial.prototype, "cameraColorCurves", {
  53941. /**
  53942. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53943. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53944. * 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;
  53945. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53946. */
  53947. get: function () {
  53948. return this._imageProcessingConfiguration.colorCurves;
  53949. },
  53950. /**
  53951. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53952. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53953. * 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;
  53954. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53955. */
  53956. set: function (value) {
  53957. this._imageProcessingConfiguration.colorCurves = value;
  53958. },
  53959. enumerable: true,
  53960. configurable: true
  53961. });
  53962. /**
  53963. * Returns the name of this material class.
  53964. */
  53965. PBRMaterial.prototype.getClassName = function () {
  53966. return "PBRMaterial";
  53967. };
  53968. /**
  53969. * Makes a duplicate of the current material.
  53970. * @param name - name to use for the new material.
  53971. */
  53972. PBRMaterial.prototype.clone = function (name) {
  53973. var _this = this;
  53974. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRMaterial(name, _this.getScene()); }, this);
  53975. clone.id = name;
  53976. clone.name = name;
  53977. this.clearCoat.copyTo(clone.clearCoat);
  53978. this.anisotropy.copyTo(clone.anisotropy);
  53979. this.brdf.copyTo(clone.brdf);
  53980. return clone;
  53981. };
  53982. /**
  53983. * Serializes this PBR Material.
  53984. * @returns - An object with the serialized material.
  53985. */
  53986. PBRMaterial.prototype.serialize = function () {
  53987. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  53988. serializationObject.customType = "BABYLON.PBRMaterial";
  53989. serializationObject.clearCoat = this.clearCoat.serialize();
  53990. serializationObject.anisotropy = this.anisotropy.serialize();
  53991. serializationObject.brdf = this.brdf.serialize();
  53992. return serializationObject;
  53993. };
  53994. // Statics
  53995. /**
  53996. * Parses a PBR Material from a serialized object.
  53997. * @param source - Serialized object.
  53998. * @param scene - BJS scene instance.
  53999. * @param rootUrl - url for the scene object
  54000. * @returns - PBRMaterial
  54001. */
  54002. PBRMaterial.Parse = function (source, scene, rootUrl) {
  54003. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRMaterial(source.name, scene); }, source, scene, rootUrl);
  54004. if (source.clearCoat) {
  54005. material.clearCoat.parse(source.clearCoat);
  54006. }
  54007. if (source.anisotropy) {
  54008. material.anisotropy.parse(source.anisotropy);
  54009. }
  54010. if (source.brdf) {
  54011. material.brdf.parse(source.brdf);
  54012. }
  54013. return material;
  54014. };
  54015. /**
  54016. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  54017. */
  54018. PBRMaterial.PBRMATERIAL_OPAQUE = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_OPAQUE;
  54019. /**
  54020. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  54021. */
  54022. PBRMaterial.PBRMATERIAL_ALPHATEST = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHATEST;
  54023. /**
  54024. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54025. */
  54026. PBRMaterial.PBRMATERIAL_ALPHABLEND = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHABLEND;
  54027. /**
  54028. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54029. * They are also discarded below the alpha cutoff threshold to improve performances.
  54030. */
  54031. PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHATESTANDBLEND;
  54032. /**
  54033. * Defines the default value of how much AO map is occluding the analytical lights
  54034. * (point spot...).
  54035. */
  54036. PBRMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  54037. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54038. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54039. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54040. ], PBRMaterial.prototype, "directIntensity", void 0);
  54041. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54042. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54043. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54044. ], PBRMaterial.prototype, "emissiveIntensity", void 0);
  54045. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54046. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54047. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54048. ], PBRMaterial.prototype, "environmentIntensity", void 0);
  54049. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54050. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54051. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54052. ], PBRMaterial.prototype, "specularIntensity", void 0);
  54053. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54054. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54055. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54056. ], PBRMaterial.prototype, "disableBumpMap", void 0);
  54057. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54058. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54059. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54060. ], PBRMaterial.prototype, "albedoTexture", void 0);
  54061. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54062. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54063. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54064. ], PBRMaterial.prototype, "ambientTexture", void 0);
  54065. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54066. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54067. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54068. ], PBRMaterial.prototype, "ambientTextureStrength", void 0);
  54069. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54070. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54071. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54072. ], PBRMaterial.prototype, "ambientTextureImpactOnAnalyticalLights", void 0);
  54073. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54074. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54075. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  54076. ], PBRMaterial.prototype, "opacityTexture", void 0);
  54077. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54078. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54079. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54080. ], PBRMaterial.prototype, "reflectionTexture", void 0);
  54081. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54082. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54083. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54084. ], PBRMaterial.prototype, "emissiveTexture", void 0);
  54085. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54086. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54087. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54088. ], PBRMaterial.prototype, "reflectivityTexture", void 0);
  54089. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54090. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54091. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54092. ], PBRMaterial.prototype, "metallicTexture", void 0);
  54093. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54094. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54095. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54096. ], PBRMaterial.prototype, "metallic", void 0);
  54097. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54098. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54099. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54100. ], PBRMaterial.prototype, "roughness", void 0);
  54101. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54102. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54103. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54104. ], PBRMaterial.prototype, "microSurfaceTexture", void 0);
  54105. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54106. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54107. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54108. ], PBRMaterial.prototype, "bumpTexture", void 0);
  54109. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54110. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54111. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", null)
  54112. ], PBRMaterial.prototype, "lightmapTexture", void 0);
  54113. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54114. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54115. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54116. ], PBRMaterial.prototype, "refractionTexture", void 0);
  54117. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54118. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("ambient"),
  54119. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54120. ], PBRMaterial.prototype, "ambientColor", void 0);
  54121. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54122. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("albedo"),
  54123. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54124. ], PBRMaterial.prototype, "albedoColor", void 0);
  54125. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54126. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("reflectivity"),
  54127. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54128. ], PBRMaterial.prototype, "reflectivityColor", void 0);
  54129. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54130. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("reflection"),
  54131. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54132. ], PBRMaterial.prototype, "reflectionColor", void 0);
  54133. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54134. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive"),
  54135. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54136. ], PBRMaterial.prototype, "emissiveColor", void 0);
  54137. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54138. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54139. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54140. ], PBRMaterial.prototype, "microSurface", void 0);
  54141. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54142. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54143. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54144. ], PBRMaterial.prototype, "indexOfRefraction", void 0);
  54145. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54146. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54147. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54148. ], PBRMaterial.prototype, "invertRefractionY", void 0);
  54149. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54150. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54151. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54152. ], PBRMaterial.prototype, "linkRefractionWithTransparency", void 0);
  54153. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54154. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54155. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54156. ], PBRMaterial.prototype, "useLightmapAsShadowmap", void 0);
  54157. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54158. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54159. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  54160. ], PBRMaterial.prototype, "useAlphaFromAlbedoTexture", void 0);
  54161. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54162. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54163. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  54164. ], PBRMaterial.prototype, "forceAlphaTest", void 0);
  54165. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54166. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54167. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  54168. ], PBRMaterial.prototype, "alphaCutOff", void 0);
  54169. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54170. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54171. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54172. ], PBRMaterial.prototype, "useSpecularOverAlpha", void 0);
  54173. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54174. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54175. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54176. ], PBRMaterial.prototype, "useMicroSurfaceFromReflectivityMapAlpha", void 0);
  54177. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54178. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54179. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54180. ], PBRMaterial.prototype, "useRoughnessFromMetallicTextureAlpha", void 0);
  54181. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54182. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54183. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54184. ], PBRMaterial.prototype, "useRoughnessFromMetallicTextureGreen", void 0);
  54185. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54186. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54187. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54188. ], PBRMaterial.prototype, "useMetallnessFromMetallicTextureBlue", void 0);
  54189. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54190. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54191. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54192. ], PBRMaterial.prototype, "useAmbientOcclusionFromMetallicTextureRed", void 0);
  54193. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54194. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54195. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54196. ], PBRMaterial.prototype, "useAmbientInGrayScale", void 0);
  54197. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54198. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54199. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54200. ], PBRMaterial.prototype, "useAutoMicroSurfaceFromReflectivityMap", void 0);
  54201. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54202. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54203. ], PBRMaterial.prototype, "usePhysicalLightFalloff", null);
  54204. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54205. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54206. ], PBRMaterial.prototype, "useGLTFLightFalloff", null);
  54207. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54208. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54209. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54210. ], PBRMaterial.prototype, "useRadianceOverAlpha", void 0);
  54211. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54212. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54213. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54214. ], PBRMaterial.prototype, "useObjectSpaceNormalMap", void 0);
  54215. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54216. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54217. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54218. ], PBRMaterial.prototype, "useParallax", void 0);
  54219. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54220. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54221. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54222. ], PBRMaterial.prototype, "useParallaxOcclusion", void 0);
  54223. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54224. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54225. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54226. ], PBRMaterial.prototype, "parallaxScaleBias", void 0);
  54227. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54228. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54229. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  54230. ], PBRMaterial.prototype, "disableLighting", void 0);
  54231. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54232. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54233. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54234. ], PBRMaterial.prototype, "forceIrradianceInFragment", void 0);
  54235. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54236. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54237. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  54238. ], PBRMaterial.prototype, "maxSimultaneousLights", void 0);
  54239. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54240. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54241. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54242. ], PBRMaterial.prototype, "invertNormalMapX", void 0);
  54243. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54244. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54245. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54246. ], PBRMaterial.prototype, "invertNormalMapY", void 0);
  54247. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54248. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54249. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54250. ], PBRMaterial.prototype, "twoSidedLighting", void 0);
  54251. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54252. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54253. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54254. ], PBRMaterial.prototype, "useAlphaFresnel", void 0);
  54255. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54256. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54257. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54258. ], PBRMaterial.prototype, "useLinearAlphaFresnel", void 0);
  54259. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54260. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54261. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54262. ], PBRMaterial.prototype, "environmentBRDFTexture", void 0);
  54263. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54264. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54265. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54266. ], PBRMaterial.prototype, "forceNormalForward", void 0);
  54267. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54268. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54269. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54270. ], PBRMaterial.prototype, "enableSpecularAntiAliasing", void 0);
  54271. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54272. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54273. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54274. ], PBRMaterial.prototype, "useHorizonOcclusion", void 0);
  54275. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54276. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54277. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54278. ], PBRMaterial.prototype, "useRadianceOcclusion", void 0);
  54279. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54280. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54281. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  54282. ], PBRMaterial.prototype, "unlit", void 0);
  54283. return PBRMaterial;
  54284. }(_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"]));
  54285. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.PBRMaterial"] = PBRMaterial;
  54286. /***/ }),
  54287. /***/ "./Materials/PBR/pbrMetallicRoughnessMaterial.ts":
  54288. /*!*******************************************************!*\
  54289. !*** ./Materials/PBR/pbrMetallicRoughnessMaterial.ts ***!
  54290. \*******************************************************/
  54291. /*! exports provided: PBRMetallicRoughnessMaterial */
  54292. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54293. "use strict";
  54294. __webpack_require__.r(__webpack_exports__);
  54295. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return PBRMetallicRoughnessMaterial; });
  54296. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  54297. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  54298. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  54299. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  54300. /**
  54301. * The PBR material of BJS following the metal roughness convention.
  54302. *
  54303. * This fits to the PBR convention in the GLTF definition:
  54304. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  54305. */
  54306. var PBRMetallicRoughnessMaterial = /** @class */ (function (_super) {
  54307. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMetallicRoughnessMaterial, _super);
  54308. /**
  54309. * Instantiates a new PBRMetalRoughnessMaterial instance.
  54310. *
  54311. * @param name The material name
  54312. * @param scene The scene the material will be use in.
  54313. */
  54314. function PBRMetallicRoughnessMaterial(name, scene) {
  54315. var _this = _super.call(this, name, scene) || this;
  54316. _this._useRoughnessFromMetallicTextureAlpha = false;
  54317. _this._useRoughnessFromMetallicTextureGreen = true;
  54318. _this._useMetallnessFromMetallicTextureBlue = true;
  54319. _this.metallic = 1.0;
  54320. _this.roughness = 1.0;
  54321. return _this;
  54322. }
  54323. /**
  54324. * Return the currrent class name of the material.
  54325. */
  54326. PBRMetallicRoughnessMaterial.prototype.getClassName = function () {
  54327. return "PBRMetallicRoughnessMaterial";
  54328. };
  54329. /**
  54330. * Makes a duplicate of the current material.
  54331. * @param name - name to use for the new material.
  54332. */
  54333. PBRMetallicRoughnessMaterial.prototype.clone = function (name) {
  54334. var _this = this;
  54335. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRMetallicRoughnessMaterial(name, _this.getScene()); }, this);
  54336. clone.id = name;
  54337. clone.name = name;
  54338. this.clearCoat.copyTo(clone.clearCoat);
  54339. this.anisotropy.copyTo(clone.anisotropy);
  54340. this.brdf.copyTo(clone.brdf);
  54341. return clone;
  54342. };
  54343. /**
  54344. * Serialize the material to a parsable JSON object.
  54345. */
  54346. PBRMetallicRoughnessMaterial.prototype.serialize = function () {
  54347. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  54348. serializationObject.customType = "BABYLON.PBRMetallicRoughnessMaterial";
  54349. serializationObject.clearCoat = this.clearCoat.serialize();
  54350. serializationObject.anisotropy = this.anisotropy.serialize();
  54351. serializationObject.brdf = this.brdf.serialize();
  54352. return serializationObject;
  54353. };
  54354. /**
  54355. * Parses a JSON object correponding to the serialize function.
  54356. */
  54357. PBRMetallicRoughnessMaterial.Parse = function (source, scene, rootUrl) {
  54358. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRMetallicRoughnessMaterial(source.name, scene); }, source, scene, rootUrl);
  54359. if (source.clearCoat) {
  54360. material.clearCoat.parse(source.clearCoat);
  54361. }
  54362. if (source.anisotropy) {
  54363. material.anisotropy.parse(source.anisotropy);
  54364. }
  54365. if (source.brdf) {
  54366. material.brdf.parse(source.brdf);
  54367. }
  54368. return material;
  54369. };
  54370. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54371. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])(),
  54372. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoColor")
  54373. ], PBRMetallicRoughnessMaterial.prototype, "baseColor", void 0);
  54374. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54375. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54376. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")
  54377. ], PBRMetallicRoughnessMaterial.prototype, "baseTexture", void 0);
  54378. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54379. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54380. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54381. ], PBRMetallicRoughnessMaterial.prototype, "metallic", void 0);
  54382. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54383. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54384. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54385. ], PBRMetallicRoughnessMaterial.prototype, "roughness", void 0);
  54386. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54387. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54388. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_metallicTexture")
  54389. ], PBRMetallicRoughnessMaterial.prototype, "metallicRoughnessTexture", void 0);
  54390. return PBRMetallicRoughnessMaterial;
  54391. }(_pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRBaseSimpleMaterial"]));
  54392. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.PBRMetallicRoughnessMaterial"] = PBRMetallicRoughnessMaterial;
  54393. /***/ }),
  54394. /***/ "./Materials/PBR/pbrSpecularGlossinessMaterial.ts":
  54395. /*!********************************************************!*\
  54396. !*** ./Materials/PBR/pbrSpecularGlossinessMaterial.ts ***!
  54397. \********************************************************/
  54398. /*! exports provided: PBRSpecularGlossinessMaterial */
  54399. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54400. "use strict";
  54401. __webpack_require__.r(__webpack_exports__);
  54402. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return PBRSpecularGlossinessMaterial; });
  54403. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  54404. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  54405. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  54406. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  54407. /**
  54408. * The PBR material of BJS following the specular glossiness convention.
  54409. *
  54410. * This fits to the PBR convention in the GLTF definition:
  54411. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  54412. */
  54413. var PBRSpecularGlossinessMaterial = /** @class */ (function (_super) {
  54414. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRSpecularGlossinessMaterial, _super);
  54415. /**
  54416. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  54417. *
  54418. * @param name The material name
  54419. * @param scene The scene the material will be use in.
  54420. */
  54421. function PBRSpecularGlossinessMaterial(name, scene) {
  54422. var _this = _super.call(this, name, scene) || this;
  54423. _this._useMicroSurfaceFromReflectivityMapAlpha = true;
  54424. return _this;
  54425. }
  54426. /**
  54427. * Return the currrent class name of the material.
  54428. */
  54429. PBRSpecularGlossinessMaterial.prototype.getClassName = function () {
  54430. return "PBRSpecularGlossinessMaterial";
  54431. };
  54432. /**
  54433. * Makes a duplicate of the current material.
  54434. * @param name - name to use for the new material.
  54435. */
  54436. PBRSpecularGlossinessMaterial.prototype.clone = function (name) {
  54437. var _this = this;
  54438. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRSpecularGlossinessMaterial(name, _this.getScene()); }, this);
  54439. clone.id = name;
  54440. clone.name = name;
  54441. this.clearCoat.copyTo(clone.clearCoat);
  54442. this.anisotropy.copyTo(clone.anisotropy);
  54443. this.brdf.copyTo(clone.brdf);
  54444. return clone;
  54445. };
  54446. /**
  54447. * Serialize the material to a parsable JSON object.
  54448. */
  54449. PBRSpecularGlossinessMaterial.prototype.serialize = function () {
  54450. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  54451. serializationObject.customType = "BABYLON.PBRSpecularGlossinessMaterial";
  54452. serializationObject.clearCoat = this.clearCoat.serialize();
  54453. serializationObject.anisotropy = this.anisotropy.serialize();
  54454. serializationObject.brdf = this.brdf.serialize();
  54455. return serializationObject;
  54456. };
  54457. /**
  54458. * Parses a JSON object correponding to the serialize function.
  54459. */
  54460. PBRSpecularGlossinessMaterial.Parse = function (source, scene, rootUrl) {
  54461. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRSpecularGlossinessMaterial(source.name, scene); }, source, scene, rootUrl);
  54462. if (source.clearCoat) {
  54463. material.clearCoat.parse(source.clearCoat);
  54464. }
  54465. if (source.anisotropy) {
  54466. material.anisotropy.parse(source.anisotropy);
  54467. }
  54468. if (source.brdf) {
  54469. material.brdf.parse(source.brdf);
  54470. }
  54471. return material;
  54472. };
  54473. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54474. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("diffuse"),
  54475. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoColor")
  54476. ], PBRSpecularGlossinessMaterial.prototype, "diffuseColor", void 0);
  54477. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54478. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54479. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")
  54480. ], PBRSpecularGlossinessMaterial.prototype, "diffuseTexture", void 0);
  54481. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54482. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("specular"),
  54483. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectivityColor")
  54484. ], PBRSpecularGlossinessMaterial.prototype, "specularColor", void 0);
  54485. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54486. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54487. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_microSurface")
  54488. ], PBRSpecularGlossinessMaterial.prototype, "glossiness", void 0);
  54489. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54490. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54491. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectivityTexture")
  54492. ], PBRSpecularGlossinessMaterial.prototype, "specularGlossinessTexture", void 0);
  54493. return PBRSpecularGlossinessMaterial;
  54494. }(_pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRBaseSimpleMaterial"]));
  54495. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.PBRSpecularGlossinessMaterial"] = PBRSpecularGlossinessMaterial;
  54496. /***/ }),
  54497. /***/ "./Materials/Textures/Loaders/ddsTextureLoader.ts":
  54498. /*!********************************************************!*\
  54499. !*** ./Materials/Textures/Loaders/ddsTextureLoader.ts ***!
  54500. \********************************************************/
  54501. /*! exports provided: _DDSTextureLoader */
  54502. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54503. "use strict";
  54504. __webpack_require__.r(__webpack_exports__);
  54505. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _DDSTextureLoader; });
  54506. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  54507. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  54508. /* harmony import */ var _Misc_dds__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/dds */ "./Misc/dds.ts");
  54509. /**
  54510. * Implementation of the DDS Texture Loader.
  54511. * @hidden
  54512. */
  54513. var _DDSTextureLoader = /** @class */ (function () {
  54514. function _DDSTextureLoader() {
  54515. /**
  54516. * Defines wether the loader supports cascade loading the different faces.
  54517. */
  54518. this.supportCascades = true;
  54519. }
  54520. /**
  54521. * This returns if the loader support the current file information.
  54522. * @param extension defines the file extension of the file being loaded
  54523. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54524. * @param fallback defines the fallback internal texture if any
  54525. * @param isBase64 defines whether the texture is encoded as a base64
  54526. * @param isBuffer defines whether the texture data are stored as a buffer
  54527. * @returns true if the loader can load the specified file
  54528. */
  54529. _DDSTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  54530. return extension.indexOf(".dds") === 0;
  54531. };
  54532. /**
  54533. * Transform the url before loading if required.
  54534. * @param rootUrl the url of the texture
  54535. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54536. * @returns the transformed texture
  54537. */
  54538. _DDSTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  54539. return rootUrl;
  54540. };
  54541. /**
  54542. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54543. * @param rootUrl the url of the texture
  54544. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54545. * @returns the fallback texture
  54546. */
  54547. _DDSTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  54548. return null;
  54549. };
  54550. /**
  54551. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54552. * @param data contains the texture data
  54553. * @param texture defines the BabylonJS internal texture
  54554. * @param createPolynomials will be true if polynomials have been requested
  54555. * @param onLoad defines the callback to trigger once the texture is ready
  54556. * @param onError defines the callback to trigger in case of error
  54557. */
  54558. _DDSTextureLoader.prototype.loadCubeData = function (imgs, texture, createPolynomials, onLoad, onError) {
  54559. var engine = texture.getEngine();
  54560. var info;
  54561. var loadMipmap = false;
  54562. if (Array.isArray(imgs)) {
  54563. for (var index = 0; index < imgs.length; index++) {
  54564. var data_1 = imgs[index];
  54565. info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data_1);
  54566. texture.width = info.width;
  54567. texture.height = info.height;
  54568. loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps;
  54569. engine._unpackFlipY(info.isCompressed);
  54570. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(engine, texture, data_1, info, loadMipmap, 6, -1, index);
  54571. if (!info.isFourCC && info.mipmapCount === 1) {
  54572. engine.generateMipMapsForCubemap(texture);
  54573. }
  54574. }
  54575. }
  54576. else {
  54577. var data = imgs;
  54578. info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data);
  54579. texture.width = info.width;
  54580. texture.height = info.height;
  54581. if (createPolynomials) {
  54582. info.sphericalPolynomial = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__["SphericalPolynomial"]();
  54583. }
  54584. loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps;
  54585. engine._unpackFlipY(info.isCompressed);
  54586. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(engine, texture, data, info, loadMipmap, 6);
  54587. if (!info.isFourCC && info.mipmapCount === 1) {
  54588. engine.generateMipMapsForCubemap(texture);
  54589. }
  54590. }
  54591. engine._setCubeMapTextureParams(loadMipmap);
  54592. texture.isReady = true;
  54593. if (onLoad) {
  54594. onLoad({ isDDS: true, width: texture.width, info: info, data: imgs, texture: texture });
  54595. }
  54596. };
  54597. /**
  54598. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54599. * @param data contains the texture data
  54600. * @param texture defines the BabylonJS internal texture
  54601. * @param callback defines the method to call once ready to upload
  54602. */
  54603. _DDSTextureLoader.prototype.loadData = function (data, texture, callback) {
  54604. var info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data);
  54605. var loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps && ((info.width >> (info.mipmapCount - 1)) === 1);
  54606. callback(info.width, info.height, loadMipmap, info.isFourCC, function () {
  54607. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(texture.getEngine(), texture, data, info, loadMipmap, 1);
  54608. });
  54609. };
  54610. return _DDSTextureLoader;
  54611. }());
  54612. // Register the loader.
  54613. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _DDSTextureLoader());
  54614. /***/ }),
  54615. /***/ "./Materials/Textures/Loaders/envTextureLoader.ts":
  54616. /*!********************************************************!*\
  54617. !*** ./Materials/Textures/Loaders/envTextureLoader.ts ***!
  54618. \********************************************************/
  54619. /*! exports provided: _ENVTextureLoader */
  54620. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54621. "use strict";
  54622. __webpack_require__.r(__webpack_exports__);
  54623. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _ENVTextureLoader; });
  54624. /* harmony import */ var _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  54625. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  54626. /**
  54627. * Implementation of the ENV Texture Loader.
  54628. * @hidden
  54629. */
  54630. var _ENVTextureLoader = /** @class */ (function () {
  54631. function _ENVTextureLoader() {
  54632. /**
  54633. * Defines wether the loader supports cascade loading the different faces.
  54634. */
  54635. this.supportCascades = false;
  54636. }
  54637. /**
  54638. * This returns if the loader support the current file information.
  54639. * @param extension defines the file extension of the file being loaded
  54640. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54641. * @param fallback defines the fallback internal texture if any
  54642. * @param isBase64 defines whether the texture is encoded as a base64
  54643. * @param isBuffer defines whether the texture data are stored as a buffer
  54644. * @returns true if the loader can load the specified file
  54645. */
  54646. _ENVTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  54647. return extension.indexOf(".env") === 0;
  54648. };
  54649. /**
  54650. * Transform the url before loading if required.
  54651. * @param rootUrl the url of the texture
  54652. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54653. * @returns the transformed texture
  54654. */
  54655. _ENVTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  54656. return rootUrl;
  54657. };
  54658. /**
  54659. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54660. * @param rootUrl the url of the texture
  54661. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54662. * @returns the fallback texture
  54663. */
  54664. _ENVTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  54665. return null;
  54666. };
  54667. /**
  54668. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54669. * @param data contains the texture data
  54670. * @param texture defines the BabylonJS internal texture
  54671. * @param createPolynomials will be true if polynomials have been requested
  54672. * @param onLoad defines the callback to trigger once the texture is ready
  54673. * @param onError defines the callback to trigger in case of error
  54674. */
  54675. _ENVTextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  54676. if (Array.isArray(data)) {
  54677. return;
  54678. }
  54679. data = data;
  54680. var info = _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].GetEnvInfo(data);
  54681. if (info) {
  54682. texture.width = info.width;
  54683. texture.height = info.width;
  54684. _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].UploadEnvSpherical(texture, info);
  54685. _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].UploadEnvLevelsAsync(texture, data, info).then(function () {
  54686. texture.isReady = true;
  54687. if (onLoad) {
  54688. onLoad();
  54689. }
  54690. });
  54691. }
  54692. else if (onError) {
  54693. onError("Can not parse the environment file", null);
  54694. }
  54695. };
  54696. /**
  54697. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54698. * @param data contains the texture data
  54699. * @param texture defines the BabylonJS internal texture
  54700. * @param callback defines the method to call once ready to upload
  54701. */
  54702. _ENVTextureLoader.prototype.loadData = function (data, texture, callback) {
  54703. throw ".env not supported in 2d.";
  54704. };
  54705. return _ENVTextureLoader;
  54706. }());
  54707. // Register the loader.
  54708. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _ENVTextureLoader());
  54709. /***/ }),
  54710. /***/ "./Materials/Textures/Loaders/index.ts":
  54711. /*!*********************************************!*\
  54712. !*** ./Materials/Textures/Loaders/index.ts ***!
  54713. \*********************************************/
  54714. /*! exports provided: _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader */
  54715. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54716. "use strict";
  54717. __webpack_require__.r(__webpack_exports__);
  54718. /* harmony import */ var _ddsTextureLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ddsTextureLoader */ "./Materials/Textures/Loaders/ddsTextureLoader.ts");
  54719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _ddsTextureLoader__WEBPACK_IMPORTED_MODULE_0__["_DDSTextureLoader"]; });
  54720. /* harmony import */ var _envTextureLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./envTextureLoader */ "./Materials/Textures/Loaders/envTextureLoader.ts");
  54721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _envTextureLoader__WEBPACK_IMPORTED_MODULE_1__["_ENVTextureLoader"]; });
  54722. /* harmony import */ var _ktxTextureLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ktxTextureLoader */ "./Materials/Textures/Loaders/ktxTextureLoader.ts");
  54723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _ktxTextureLoader__WEBPACK_IMPORTED_MODULE_2__["_KTXTextureLoader"]; });
  54724. /* harmony import */ var _tgaTextureLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./tgaTextureLoader */ "./Materials/Textures/Loaders/tgaTextureLoader.ts");
  54725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _tgaTextureLoader__WEBPACK_IMPORTED_MODULE_3__["_TGATextureLoader"]; });
  54726. /***/ }),
  54727. /***/ "./Materials/Textures/Loaders/ktxTextureLoader.ts":
  54728. /*!********************************************************!*\
  54729. !*** ./Materials/Textures/Loaders/ktxTextureLoader.ts ***!
  54730. \********************************************************/
  54731. /*! exports provided: _KTXTextureLoader */
  54732. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54733. "use strict";
  54734. __webpack_require__.r(__webpack_exports__);
  54735. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _KTXTextureLoader; });
  54736. /* harmony import */ var _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/khronosTextureContainer */ "./Misc/khronosTextureContainer.ts");
  54737. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  54738. /**
  54739. * Implementation of the KTX Texture Loader.
  54740. * @hidden
  54741. */
  54742. var _KTXTextureLoader = /** @class */ (function () {
  54743. function _KTXTextureLoader() {
  54744. /**
  54745. * Defines wether the loader supports cascade loading the different faces.
  54746. */
  54747. this.supportCascades = false;
  54748. }
  54749. /**
  54750. * This returns if the loader support the current file information.
  54751. * @param extension defines the file extension of the file being loaded
  54752. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54753. * @param fallback defines the fallback internal texture if any
  54754. * @param isBase64 defines whether the texture is encoded as a base64
  54755. * @param isBuffer defines whether the texture data are stored as a buffer
  54756. * @returns true if the loader can load the specified file
  54757. */
  54758. _KTXTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  54759. if (textureFormatInUse && !isBase64 && !fallback && !isBuffer) {
  54760. return true;
  54761. }
  54762. return false;
  54763. };
  54764. /**
  54765. * Transform the url before loading if required.
  54766. * @param rootUrl the url of the texture
  54767. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54768. * @returns the transformed texture
  54769. */
  54770. _KTXTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  54771. var lastDot = rootUrl.lastIndexOf('.');
  54772. if (lastDot != -1 && rootUrl.substring(lastDot + 1) == "ktx") {
  54773. // Already transformed
  54774. return rootUrl;
  54775. }
  54776. return (lastDot > -1 ? rootUrl.substring(0, lastDot) : rootUrl) + textureFormatInUse;
  54777. };
  54778. /**
  54779. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54780. * @param rootUrl the url of the texture
  54781. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54782. * @returns the fallback texture
  54783. */
  54784. _KTXTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  54785. // remove the format appended to the rootUrl in the original createCubeTexture call.
  54786. var exp = new RegExp("" + textureFormatInUse + "$");
  54787. return rootUrl.replace(exp, "");
  54788. };
  54789. /**
  54790. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54791. * @param data contains the texture data
  54792. * @param texture defines the BabylonJS internal texture
  54793. * @param createPolynomials will be true if polynomials have been requested
  54794. * @param onLoad defines the callback to trigger once the texture is ready
  54795. * @param onError defines the callback to trigger in case of error
  54796. */
  54797. _KTXTextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  54798. if (Array.isArray(data)) {
  54799. return;
  54800. }
  54801. // Need to invert vScale as invertY via UNPACK_FLIP_Y_WEBGL is not supported by compressed texture
  54802. texture._invertVScale = !texture.invertY;
  54803. var engine = texture.getEngine();
  54804. var ktx = new _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"](data, 6);
  54805. var loadMipmap = ktx.numberOfMipmapLevels > 1 && texture.generateMipMaps;
  54806. engine._unpackFlipY(true);
  54807. ktx.uploadLevels(texture, texture.generateMipMaps);
  54808. texture.width = ktx.pixelWidth;
  54809. texture.height = ktx.pixelHeight;
  54810. engine._setCubeMapTextureParams(loadMipmap);
  54811. texture.isReady = true;
  54812. };
  54813. /**
  54814. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54815. * @param data contains the texture data
  54816. * @param texture defines the BabylonJS internal texture
  54817. * @param callback defines the method to call once ready to upload
  54818. */
  54819. _KTXTextureLoader.prototype.loadData = function (data, texture, callback) {
  54820. // Need to invert vScale as invertY via UNPACK_FLIP_Y_WEBGL is not supported by compressed texture
  54821. texture._invertVScale = !texture.invertY;
  54822. var ktx = new _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"](data, 1);
  54823. callback(ktx.pixelWidth, ktx.pixelHeight, false, true, function () {
  54824. ktx.uploadLevels(texture, texture.generateMipMaps);
  54825. }, ktx.isInvalid);
  54826. };
  54827. return _KTXTextureLoader;
  54828. }());
  54829. // Register the loader.
  54830. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.unshift(new _KTXTextureLoader());
  54831. /***/ }),
  54832. /***/ "./Materials/Textures/Loaders/tgaTextureLoader.ts":
  54833. /*!********************************************************!*\
  54834. !*** ./Materials/Textures/Loaders/tgaTextureLoader.ts ***!
  54835. \********************************************************/
  54836. /*! exports provided: _TGATextureLoader */
  54837. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54838. "use strict";
  54839. __webpack_require__.r(__webpack_exports__);
  54840. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _TGATextureLoader; });
  54841. /* harmony import */ var _Misc_tga__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/tga */ "./Misc/tga.ts");
  54842. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  54843. /**
  54844. * Implementation of the TGA Texture Loader.
  54845. * @hidden
  54846. */
  54847. var _TGATextureLoader = /** @class */ (function () {
  54848. function _TGATextureLoader() {
  54849. /**
  54850. * Defines wether the loader supports cascade loading the different faces.
  54851. */
  54852. this.supportCascades = false;
  54853. }
  54854. /**
  54855. * This returns if the loader support the current file information.
  54856. * @param extension defines the file extension of the file being loaded
  54857. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54858. * @param fallback defines the fallback internal texture if any
  54859. * @param isBase64 defines whether the texture is encoded as a base64
  54860. * @param isBuffer defines whether the texture data are stored as a buffer
  54861. * @returns true if the loader can load the specified file
  54862. */
  54863. _TGATextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  54864. return extension.indexOf(".tga") === 0;
  54865. };
  54866. /**
  54867. * Transform the url before loading if required.
  54868. * @param rootUrl the url of the texture
  54869. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54870. * @returns the transformed texture
  54871. */
  54872. _TGATextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  54873. return rootUrl;
  54874. };
  54875. /**
  54876. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54877. * @param rootUrl the url of the texture
  54878. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54879. * @returns the fallback texture
  54880. */
  54881. _TGATextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  54882. return null;
  54883. };
  54884. /**
  54885. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54886. * @param data contains the texture data
  54887. * @param texture defines the BabylonJS internal texture
  54888. * @param createPolynomials will be true if polynomials have been requested
  54889. * @param onLoad defines the callback to trigger once the texture is ready
  54890. * @param onError defines the callback to trigger in case of error
  54891. */
  54892. _TGATextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  54893. throw ".env not supported in Cube.";
  54894. };
  54895. /**
  54896. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54897. * @param data contains the texture data
  54898. * @param texture defines the BabylonJS internal texture
  54899. * @param callback defines the method to call once ready to upload
  54900. */
  54901. _TGATextureLoader.prototype.loadData = function (data, texture, callback) {
  54902. var uintData = new Uint8Array(data);
  54903. var header = _Misc_tga__WEBPACK_IMPORTED_MODULE_0__["TGATools"].GetTGAHeader(uintData);
  54904. callback(header.width, header.height, texture.generateMipMaps, false, function () {
  54905. _Misc_tga__WEBPACK_IMPORTED_MODULE_0__["TGATools"].UploadContent(texture, uintData);
  54906. });
  54907. };
  54908. return _TGATextureLoader;
  54909. }());
  54910. // Register the loader.
  54911. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _TGATextureLoader());
  54912. /***/ }),
  54913. /***/ "./Materials/Textures/Procedurals/customProceduralTexture.ts":
  54914. /*!*******************************************************************!*\
  54915. !*** ./Materials/Textures/Procedurals/customProceduralTexture.ts ***!
  54916. \*******************************************************************/
  54917. /*! exports provided: CustomProceduralTexture */
  54918. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54919. "use strict";
  54920. __webpack_require__.r(__webpack_exports__);
  54921. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return CustomProceduralTexture; });
  54922. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  54923. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/tools */ "./Misc/tools.ts");
  54924. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  54925. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  54926. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  54927. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  54928. /**
  54929. * 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.
  54930. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54931. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54932. */
  54933. var CustomProceduralTexture = /** @class */ (function (_super) {
  54934. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CustomProceduralTexture, _super);
  54935. /**
  54936. * Instantiates a new Custom Procedural Texture.
  54937. * 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.
  54938. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54939. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54940. * @param name Define the name of the texture
  54941. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54942. * @param size Define the size of the texture to create
  54943. * @param scene Define the scene the texture belongs to
  54944. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54945. * @param generateMipMaps Define if the texture should creates mip maps or not
  54946. */
  54947. function CustomProceduralTexture(name, texturePath, size, scene, fallbackTexture, generateMipMaps) {
  54948. var _this = _super.call(this, name, size, null, scene, fallbackTexture, generateMipMaps) || this;
  54949. _this._animate = true;
  54950. _this._time = 0;
  54951. _this._texturePath = texturePath;
  54952. //Try to load json
  54953. _this._loadJson(texturePath);
  54954. _this.refreshRate = 1;
  54955. return _this;
  54956. }
  54957. CustomProceduralTexture.prototype._loadJson = function (jsonUrl) {
  54958. var _this = this;
  54959. var noConfigFile = function () {
  54960. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Log("No config file found in " + jsonUrl + " trying to use ShadersStore or DOM element");
  54961. try {
  54962. _this.setFragment(_this._texturePath);
  54963. }
  54964. catch (ex) {
  54965. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Error("No json or ShaderStore or DOM element found for CustomProceduralTexture");
  54966. }
  54967. };
  54968. var configFileUrl = jsonUrl + "/config.json";
  54969. var xhr = new XMLHttpRequest();
  54970. xhr.open("GET", configFileUrl, true);
  54971. xhr.addEventListener("load", function () {
  54972. if (xhr.status === 200 || (xhr.responseText && xhr.responseText.length > 0)) {
  54973. try {
  54974. _this._config = JSON.parse(xhr.response);
  54975. _this.updateShaderUniforms();
  54976. _this.updateTextures();
  54977. _this.setFragment(_this._texturePath + "/custom");
  54978. _this._animate = _this._config.animate;
  54979. _this.refreshRate = _this._config.refreshrate;
  54980. }
  54981. catch (ex) {
  54982. noConfigFile();
  54983. }
  54984. }
  54985. else {
  54986. noConfigFile();
  54987. }
  54988. }, false);
  54989. xhr.addEventListener("error", function () {
  54990. noConfigFile();
  54991. }, false);
  54992. try {
  54993. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].UseCustomRequestHeaders) {
  54994. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].InjectCustomRequestHeaders(xhr);
  54995. }
  54996. xhr.send();
  54997. }
  54998. catch (ex) {
  54999. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Error("CustomProceduralTexture: Error on XHR send request.");
  55000. }
  55001. };
  55002. /**
  55003. * Is the texture ready to be used ? (rendered at least once)
  55004. * @returns true if ready, otherwise, false.
  55005. */
  55006. CustomProceduralTexture.prototype.isReady = function () {
  55007. if (!_super.prototype.isReady.call(this)) {
  55008. return false;
  55009. }
  55010. for (var name in this._textures) {
  55011. var texture = this._textures[name];
  55012. if (!texture.isReady()) {
  55013. return false;
  55014. }
  55015. }
  55016. return true;
  55017. };
  55018. /**
  55019. * Render the texture to its associated render target.
  55020. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  55021. */
  55022. CustomProceduralTexture.prototype.render = function (useCameraPostProcess) {
  55023. var scene = this.getScene();
  55024. if (this._animate && scene) {
  55025. this._time += scene.getAnimationRatio() * 0.03;
  55026. this.updateShaderUniforms();
  55027. }
  55028. _super.prototype.render.call(this, useCameraPostProcess);
  55029. };
  55030. /**
  55031. * Update the list of dependant textures samplers in the shader.
  55032. */
  55033. CustomProceduralTexture.prototype.updateTextures = function () {
  55034. for (var i = 0; i < this._config.sampler2Ds.length; i++) {
  55035. 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()));
  55036. }
  55037. };
  55038. /**
  55039. * Update the uniform values of the procedural texture in the shader.
  55040. */
  55041. CustomProceduralTexture.prototype.updateShaderUniforms = function () {
  55042. if (this._config) {
  55043. for (var j = 0; j < this._config.uniforms.length; j++) {
  55044. var uniform = this._config.uniforms[j];
  55045. switch (uniform.type) {
  55046. case "float":
  55047. this.setFloat(uniform.name, uniform.value);
  55048. break;
  55049. case "color3":
  55050. this.setColor3(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](uniform.r, uniform.g, uniform.b));
  55051. break;
  55052. case "color4":
  55053. this.setColor4(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](uniform.r, uniform.g, uniform.b, uniform.a));
  55054. break;
  55055. case "vector2":
  55056. this.setVector2(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](uniform.x, uniform.y));
  55057. break;
  55058. case "vector3":
  55059. this.setVector3(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](uniform.x, uniform.y, uniform.z));
  55060. break;
  55061. }
  55062. }
  55063. }
  55064. this.setFloat("time", this._time);
  55065. };
  55066. Object.defineProperty(CustomProceduralTexture.prototype, "animate", {
  55067. /**
  55068. * Define if the texture animates or not.
  55069. */
  55070. get: function () {
  55071. return this._animate;
  55072. },
  55073. set: function (value) {
  55074. this._animate = value;
  55075. },
  55076. enumerable: true,
  55077. configurable: true
  55078. });
  55079. return CustomProceduralTexture;
  55080. }(_proceduralTexture__WEBPACK_IMPORTED_MODULE_5__["ProceduralTexture"]));
  55081. /***/ }),
  55082. /***/ "./Materials/Textures/Procedurals/index.ts":
  55083. /*!*************************************************!*\
  55084. !*** ./Materials/Textures/Procedurals/index.ts ***!
  55085. \*************************************************/
  55086. /*! exports provided: CustomProceduralTexture, NoiseProceduralTexture, ProceduralTexture, ProceduralTextureSceneComponent */
  55087. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55088. "use strict";
  55089. __webpack_require__.r(__webpack_exports__);
  55090. /* harmony import */ var _customProceduralTexture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./customProceduralTexture */ "./Materials/Textures/Procedurals/customProceduralTexture.ts");
  55091. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _customProceduralTexture__WEBPACK_IMPORTED_MODULE_0__["CustomProceduralTexture"]; });
  55092. /* harmony import */ var _noiseProceduralTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./noiseProceduralTexture */ "./Materials/Textures/Procedurals/noiseProceduralTexture.ts");
  55093. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _noiseProceduralTexture__WEBPACK_IMPORTED_MODULE_1__["NoiseProceduralTexture"]; });
  55094. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  55095. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__["ProceduralTexture"]; });
  55096. /* harmony import */ var _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./proceduralTextureSceneComponent */ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts");
  55097. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_3__["ProceduralTextureSceneComponent"]; });
  55098. /***/ }),
  55099. /***/ "./Materials/Textures/Procedurals/noiseProceduralTexture.ts":
  55100. /*!******************************************************************!*\
  55101. !*** ./Materials/Textures/Procedurals/noiseProceduralTexture.ts ***!
  55102. \******************************************************************/
  55103. /*! exports provided: NoiseProceduralTexture */
  55104. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55105. "use strict";
  55106. __webpack_require__.r(__webpack_exports__);
  55107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return NoiseProceduralTexture; });
  55108. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55109. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  55110. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  55111. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  55112. /* harmony import */ var _Shaders_noise_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Shaders/noise.fragment */ "./Shaders/noise.fragment.ts");
  55113. /**
  55114. * Class used to generate noise procedural textures
  55115. */
  55116. var NoiseProceduralTexture = /** @class */ (function (_super) {
  55117. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](NoiseProceduralTexture, _super);
  55118. /**
  55119. * Creates a new NoiseProceduralTexture
  55120. * @param name defines the name fo the texture
  55121. * @param size defines the size of the texture (default is 256)
  55122. * @param scene defines the hosting scene
  55123. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  55124. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  55125. */
  55126. function NoiseProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  55127. if (size === void 0) { size = 256; }
  55128. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__["EngineStore"].LastCreatedScene; }
  55129. var _this = _super.call(this, name, size, "noise", scene, fallbackTexture, generateMipMaps) || this;
  55130. _this._time = 0;
  55131. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  55132. _this.brightness = 0.2;
  55133. /** Defines the number of octaves to process */
  55134. _this.octaves = 3;
  55135. /** Defines the level of persistence (0.8 by default) */
  55136. _this.persistence = 0.8;
  55137. /** Gets or sets animation speed factor (default is 1) */
  55138. _this.animationSpeedFactor = 1;
  55139. _this.autoClear = false;
  55140. _this._updateShaderUniforms();
  55141. return _this;
  55142. }
  55143. NoiseProceduralTexture.prototype._updateShaderUniforms = function () {
  55144. var scene = this.getScene();
  55145. if (!scene) {
  55146. return;
  55147. }
  55148. this._time += scene.getAnimationRatio() * this.animationSpeedFactor * 0.01;
  55149. this.setFloat("brightness", this.brightness);
  55150. this.setFloat("persistence", this.persistence);
  55151. this.setFloat("timeScale", this._time);
  55152. };
  55153. NoiseProceduralTexture.prototype._getDefines = function () {
  55154. return "#define OCTAVES " + (this.octaves | 0);
  55155. };
  55156. /** Generate the current state of the procedural texture */
  55157. NoiseProceduralTexture.prototype.render = function (useCameraPostProcess) {
  55158. this._updateShaderUniforms();
  55159. _super.prototype.render.call(this, useCameraPostProcess);
  55160. };
  55161. /**
  55162. * Serializes this noise procedural texture
  55163. * @returns a serialized noise procedural texture object
  55164. */
  55165. NoiseProceduralTexture.prototype.serialize = function () {
  55166. var serializationObject = {};
  55167. serializationObject.customType = "BABYLON.NoiseProceduralTexture";
  55168. serializationObject.brightness = this.brightness;
  55169. serializationObject.octaves = this.octaves;
  55170. serializationObject.persistence = this.persistence;
  55171. serializationObject.animationSpeedFactor = this.animationSpeedFactor;
  55172. serializationObject.size = this.getSize().width;
  55173. serializationObject.generateMipMaps = this._generateMipMaps;
  55174. return serializationObject;
  55175. };
  55176. /**
  55177. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  55178. * @param parsedTexture defines parsed texture data
  55179. * @param scene defines the current scene
  55180. * @param rootUrl defines the root URL containing noise procedural texture information
  55181. * @returns a parsed NoiseProceduralTexture
  55182. */
  55183. NoiseProceduralTexture.Parse = function (parsedTexture, scene) {
  55184. var texture = new NoiseProceduralTexture(parsedTexture.name, parsedTexture.size, scene, undefined, parsedTexture.generateMipMaps);
  55185. texture.brightness = parsedTexture.brightness;
  55186. texture.octaves = parsedTexture.octaves;
  55187. texture.persistence = parsedTexture.persistence;
  55188. texture.animationSpeedFactor = parsedTexture.animationSpeedFactor;
  55189. return texture;
  55190. };
  55191. return NoiseProceduralTexture;
  55192. }(_proceduralTexture__WEBPACK_IMPORTED_MODULE_2__["ProceduralTexture"]));
  55193. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.NoiseProceduralTexture"] = NoiseProceduralTexture;
  55194. /***/ }),
  55195. /***/ "./Materials/Textures/Procedurals/proceduralTexture.ts":
  55196. /*!*************************************************************!*\
  55197. !*** ./Materials/Textures/Procedurals/proceduralTexture.ts ***!
  55198. \*************************************************************/
  55199. /*! exports provided: ProceduralTexture */
  55200. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55201. "use strict";
  55202. __webpack_require__.r(__webpack_exports__);
  55203. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return ProceduralTexture; });
  55204. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55205. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  55206. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/observable */ "./Misc/observable.ts");
  55207. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Meshes/buffer */ "./Meshes/buffer.ts");
  55208. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../sceneComponent */ "./sceneComponent.ts");
  55209. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/material */ "./Materials/material.ts");
  55210. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  55211. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  55212. /* harmony import */ var _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./proceduralTextureSceneComponent */ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts");
  55213. /* harmony import */ var _Shaders_procedural_vertex__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../Shaders/procedural.vertex */ "./Shaders/procedural.vertex.ts");
  55214. /**
  55215. * 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.
  55216. * This is the base class of any Procedural texture and contains most of the shareable code.
  55217. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  55218. */
  55219. var ProceduralTexture = /** @class */ (function (_super) {
  55220. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ProceduralTexture, _super);
  55221. /**
  55222. * Instantiates a new procedural texture.
  55223. * 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.
  55224. * This is the base class of any Procedural texture and contains most of the shareable code.
  55225. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  55226. * @param name Define the name of the texture
  55227. * @param size Define the size of the texture to create
  55228. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  55229. * @param scene Define the scene the texture belongs to
  55230. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  55231. * @param generateMipMaps Define if the texture should creates mip maps or not
  55232. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  55233. */
  55234. function ProceduralTexture(name, size, fragment, scene, fallbackTexture, generateMipMaps, isCube) {
  55235. if (fallbackTexture === void 0) { fallbackTexture = null; }
  55236. if (generateMipMaps === void 0) { generateMipMaps = true; }
  55237. if (isCube === void 0) { isCube = false; }
  55238. var _this = _super.call(this, null, scene, !generateMipMaps) || this;
  55239. _this.isCube = isCube;
  55240. /**
  55241. * Define if the texture is enabled or not (disabled texture will not render)
  55242. */
  55243. _this.isEnabled = true;
  55244. /**
  55245. * Define if the texture must be cleared before rendering (default is true)
  55246. */
  55247. _this.autoClear = true;
  55248. /**
  55249. * Event raised when the texture is generated
  55250. */
  55251. _this.onGeneratedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  55252. /** @hidden */
  55253. _this._textures = {};
  55254. _this._currentRefreshId = -1;
  55255. _this._refreshRate = 1;
  55256. _this._vertexBuffers = {};
  55257. _this._uniforms = new Array();
  55258. _this._samplers = new Array();
  55259. _this._floats = {};
  55260. _this._ints = {};
  55261. _this._floatsArrays = {};
  55262. _this._colors3 = {};
  55263. _this._colors4 = {};
  55264. _this._vectors2 = {};
  55265. _this._vectors3 = {};
  55266. _this._matrices = {};
  55267. _this._fallbackTextureUsed = false;
  55268. _this._cachedDefines = "";
  55269. _this._contentUpdateId = -1;
  55270. scene = _this.getScene();
  55271. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_PROCEDURALTEXTURE);
  55272. if (!component) {
  55273. component = new _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_8__["ProceduralTextureSceneComponent"](scene);
  55274. scene._addComponent(component);
  55275. }
  55276. scene.proceduralTextures.push(_this);
  55277. _this._engine = scene.getEngine();
  55278. _this.name = name;
  55279. _this.isRenderTarget = true;
  55280. _this._size = size;
  55281. _this._generateMipMaps = generateMipMaps;
  55282. _this.setFragment(fragment);
  55283. _this._fallbackTexture = fallbackTexture;
  55284. if (isCube) {
  55285. _this._texture = _this._engine.createRenderTargetCubeTexture(size, { generateMipMaps: generateMipMaps, generateDepthBuffer: false, generateStencilBuffer: false });
  55286. _this.setFloat("face", 0);
  55287. }
  55288. else {
  55289. _this._texture = _this._engine.createRenderTargetTexture(size, { generateMipMaps: generateMipMaps, generateDepthBuffer: false, generateStencilBuffer: false });
  55290. }
  55291. // VBO
  55292. var vertices = [];
  55293. vertices.push(1, 1);
  55294. vertices.push(-1, 1);
  55295. vertices.push(-1, -1);
  55296. vertices.push(1, -1);
  55297. _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);
  55298. _this._createIndexBuffer();
  55299. return _this;
  55300. }
  55301. /**
  55302. * The effect that is created when initializing the post process.
  55303. * @returns The created effect corrisponding the the postprocess.
  55304. */
  55305. ProceduralTexture.prototype.getEffect = function () {
  55306. return this._effect;
  55307. };
  55308. /**
  55309. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  55310. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  55311. */
  55312. ProceduralTexture.prototype.getContent = function () {
  55313. if (this._contentData && this._currentRefreshId == this._contentUpdateId) {
  55314. return this._contentData;
  55315. }
  55316. this._contentData = this.readPixels(0, 0, this._contentData);
  55317. this._contentUpdateId = this._currentRefreshId;
  55318. return this._contentData;
  55319. };
  55320. ProceduralTexture.prototype._createIndexBuffer = function () {
  55321. var engine = this._engine;
  55322. // Indices
  55323. var indices = [];
  55324. indices.push(0);
  55325. indices.push(1);
  55326. indices.push(2);
  55327. indices.push(0);
  55328. indices.push(2);
  55329. indices.push(3);
  55330. this._indexBuffer = engine.createIndexBuffer(indices);
  55331. };
  55332. /** @hidden */
  55333. ProceduralTexture.prototype._rebuild = function () {
  55334. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  55335. if (vb) {
  55336. vb._rebuild();
  55337. }
  55338. this._createIndexBuffer();
  55339. if (this.refreshRate === _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"].REFRESHRATE_RENDER_ONCE) {
  55340. this.refreshRate = _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"].REFRESHRATE_RENDER_ONCE;
  55341. }
  55342. };
  55343. /**
  55344. * Resets the texture in order to recreate its associated resources.
  55345. * This can be called in case of context loss
  55346. */
  55347. ProceduralTexture.prototype.reset = function () {
  55348. if (this._effect === undefined) {
  55349. return;
  55350. }
  55351. var engine = this._engine;
  55352. engine._releaseEffect(this._effect);
  55353. };
  55354. ProceduralTexture.prototype._getDefines = function () {
  55355. return "";
  55356. };
  55357. /**
  55358. * Is the texture ready to be used ? (rendered at least once)
  55359. * @returns true if ready, otherwise, false.
  55360. */
  55361. ProceduralTexture.prototype.isReady = function () {
  55362. var _this = this;
  55363. var engine = this._engine;
  55364. var shaders;
  55365. if (!this._fragment) {
  55366. return false;
  55367. }
  55368. if (this._fallbackTextureUsed) {
  55369. return true;
  55370. }
  55371. var defines = this._getDefines();
  55372. if (this._effect && defines === this._cachedDefines && this._effect.isReady()) {
  55373. return true;
  55374. }
  55375. if (this._fragment.fragmentElement !== undefined) {
  55376. shaders = { vertex: "procedural", fragmentElement: this._fragment.fragmentElement };
  55377. }
  55378. else {
  55379. shaders = { vertex: "procedural", fragment: this._fragment };
  55380. }
  55381. this._cachedDefines = defines;
  55382. this._effect = engine.createEffect(shaders, [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], this._uniforms, this._samplers, defines, undefined, undefined, function () {
  55383. _this.releaseInternalTexture();
  55384. if (_this._fallbackTexture) {
  55385. _this._texture = _this._fallbackTexture._texture;
  55386. if (_this._texture) {
  55387. _this._texture.incrementReferences();
  55388. }
  55389. }
  55390. _this._fallbackTextureUsed = true;
  55391. });
  55392. return this._effect.isReady();
  55393. };
  55394. /**
  55395. * Resets the refresh counter of the texture and start bak from scratch.
  55396. * Could be useful to regenerate the texture if it is setup to render only once.
  55397. */
  55398. ProceduralTexture.prototype.resetRefreshCounter = function () {
  55399. this._currentRefreshId = -1;
  55400. };
  55401. /**
  55402. * Set the fragment shader to use in order to render the texture.
  55403. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  55404. */
  55405. ProceduralTexture.prototype.setFragment = function (fragment) {
  55406. this._fragment = fragment;
  55407. };
  55408. Object.defineProperty(ProceduralTexture.prototype, "refreshRate", {
  55409. /**
  55410. * Define the refresh rate of the texture or the rendering frequency.
  55411. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  55412. */
  55413. get: function () {
  55414. return this._refreshRate;
  55415. },
  55416. set: function (value) {
  55417. this._refreshRate = value;
  55418. this.resetRefreshCounter();
  55419. },
  55420. enumerable: true,
  55421. configurable: true
  55422. });
  55423. /** @hidden */
  55424. ProceduralTexture.prototype._shouldRender = function () {
  55425. if (!this.isEnabled || !this.isReady() || !this._texture) {
  55426. if (this._texture) {
  55427. this._texture.isReady = false;
  55428. }
  55429. return false;
  55430. }
  55431. if (this._fallbackTextureUsed) {
  55432. return false;
  55433. }
  55434. if (this._currentRefreshId === -1) { // At least render once
  55435. this._currentRefreshId = 1;
  55436. return true;
  55437. }
  55438. if (this.refreshRate === this._currentRefreshId) {
  55439. this._currentRefreshId = 1;
  55440. return true;
  55441. }
  55442. this._currentRefreshId++;
  55443. return false;
  55444. };
  55445. /**
  55446. * Get the size the texture is rendering at.
  55447. * @returns the size (texture is always squared)
  55448. */
  55449. ProceduralTexture.prototype.getRenderSize = function () {
  55450. return this._size;
  55451. };
  55452. /**
  55453. * Resize the texture to new value.
  55454. * @param size Define the new size the texture should have
  55455. * @param generateMipMaps Define whether the new texture should create mip maps
  55456. */
  55457. ProceduralTexture.prototype.resize = function (size, generateMipMaps) {
  55458. if (this._fallbackTextureUsed) {
  55459. return;
  55460. }
  55461. this.releaseInternalTexture();
  55462. this._texture = this._engine.createRenderTargetTexture(size, generateMipMaps);
  55463. // Update properties
  55464. this._size = size;
  55465. this._generateMipMaps = generateMipMaps;
  55466. };
  55467. ProceduralTexture.prototype._checkUniform = function (uniformName) {
  55468. if (this._uniforms.indexOf(uniformName) === -1) {
  55469. this._uniforms.push(uniformName);
  55470. }
  55471. };
  55472. /**
  55473. * Set a texture in the shader program used to render.
  55474. * @param name Define the name of the uniform samplers as defined in the shader
  55475. * @param texture Define the texture to bind to this sampler
  55476. * @return the texture itself allowing "fluent" like uniform updates
  55477. */
  55478. ProceduralTexture.prototype.setTexture = function (name, texture) {
  55479. if (this._samplers.indexOf(name) === -1) {
  55480. this._samplers.push(name);
  55481. }
  55482. this._textures[name] = texture;
  55483. return this;
  55484. };
  55485. /**
  55486. * Set a float in the shader.
  55487. * @param name Define the name of the uniform as defined in the shader
  55488. * @param value Define the value to give to the uniform
  55489. * @return the texture itself allowing "fluent" like uniform updates
  55490. */
  55491. ProceduralTexture.prototype.setFloat = function (name, value) {
  55492. this._checkUniform(name);
  55493. this._floats[name] = value;
  55494. return this;
  55495. };
  55496. /**
  55497. * Set a int in the shader.
  55498. * @param name Define the name of the uniform as defined in the shader
  55499. * @param value Define the value to give to the uniform
  55500. * @return the texture itself allowing "fluent" like uniform updates
  55501. */
  55502. ProceduralTexture.prototype.setInt = function (name, value) {
  55503. this._checkUniform(name);
  55504. this._ints[name] = value;
  55505. return this;
  55506. };
  55507. /**
  55508. * Set an array of floats in the shader.
  55509. * @param name Define the name of the uniform as defined in the shader
  55510. * @param value Define the value to give to the uniform
  55511. * @return the texture itself allowing "fluent" like uniform updates
  55512. */
  55513. ProceduralTexture.prototype.setFloats = function (name, value) {
  55514. this._checkUniform(name);
  55515. this._floatsArrays[name] = value;
  55516. return this;
  55517. };
  55518. /**
  55519. * Set a vec3 in the shader from a Color3.
  55520. * @param name Define the name of the uniform as defined in the shader
  55521. * @param value Define the value to give to the uniform
  55522. * @return the texture itself allowing "fluent" like uniform updates
  55523. */
  55524. ProceduralTexture.prototype.setColor3 = function (name, value) {
  55525. this._checkUniform(name);
  55526. this._colors3[name] = value;
  55527. return this;
  55528. };
  55529. /**
  55530. * Set a vec4 in the shader from a Color4.
  55531. * @param name Define the name of the uniform as defined in the shader
  55532. * @param value Define the value to give to the uniform
  55533. * @return the texture itself allowing "fluent" like uniform updates
  55534. */
  55535. ProceduralTexture.prototype.setColor4 = function (name, value) {
  55536. this._checkUniform(name);
  55537. this._colors4[name] = value;
  55538. return this;
  55539. };
  55540. /**
  55541. * Set a vec2 in the shader from a Vector2.
  55542. * @param name Define the name of the uniform as defined in the shader
  55543. * @param value Define the value to give to the uniform
  55544. * @return the texture itself allowing "fluent" like uniform updates
  55545. */
  55546. ProceduralTexture.prototype.setVector2 = function (name, value) {
  55547. this._checkUniform(name);
  55548. this._vectors2[name] = value;
  55549. return this;
  55550. };
  55551. /**
  55552. * Set a vec3 in the shader from a Vector3.
  55553. * @param name Define the name of the uniform as defined in the shader
  55554. * @param value Define the value to give to the uniform
  55555. * @return the texture itself allowing "fluent" like uniform updates
  55556. */
  55557. ProceduralTexture.prototype.setVector3 = function (name, value) {
  55558. this._checkUniform(name);
  55559. this._vectors3[name] = value;
  55560. return this;
  55561. };
  55562. /**
  55563. * Set a mat4 in the shader from a MAtrix.
  55564. * @param name Define the name of the uniform as defined in the shader
  55565. * @param value Define the value to give to the uniform
  55566. * @return the texture itself allowing "fluent" like uniform updates
  55567. */
  55568. ProceduralTexture.prototype.setMatrix = function (name, value) {
  55569. this._checkUniform(name);
  55570. this._matrices[name] = value;
  55571. return this;
  55572. };
  55573. /**
  55574. * Render the texture to its associated render target.
  55575. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  55576. */
  55577. ProceduralTexture.prototype.render = function (useCameraPostProcess) {
  55578. var scene = this.getScene();
  55579. if (!scene) {
  55580. return;
  55581. }
  55582. var engine = this._engine;
  55583. // Render
  55584. engine.enableEffect(this._effect);
  55585. engine.setState(false);
  55586. // Texture
  55587. for (var name in this._textures) {
  55588. this._effect.setTexture(name, this._textures[name]);
  55589. }
  55590. // Float
  55591. for (name in this._ints) {
  55592. this._effect.setInt(name, this._ints[name]);
  55593. }
  55594. // Float
  55595. for (name in this._floats) {
  55596. this._effect.setFloat(name, this._floats[name]);
  55597. }
  55598. // Floats
  55599. for (name in this._floatsArrays) {
  55600. this._effect.setArray(name, this._floatsArrays[name]);
  55601. }
  55602. // Color3
  55603. for (name in this._colors3) {
  55604. this._effect.setColor3(name, this._colors3[name]);
  55605. }
  55606. // Color4
  55607. for (name in this._colors4) {
  55608. var color = this._colors4[name];
  55609. this._effect.setFloat4(name, color.r, color.g, color.b, color.a);
  55610. }
  55611. // Vector2
  55612. for (name in this._vectors2) {
  55613. this._effect.setVector2(name, this._vectors2[name]);
  55614. }
  55615. // Vector3
  55616. for (name in this._vectors3) {
  55617. this._effect.setVector3(name, this._vectors3[name]);
  55618. }
  55619. // Matrix
  55620. for (name in this._matrices) {
  55621. this._effect.setMatrix(name, this._matrices[name]);
  55622. }
  55623. if (!this._texture) {
  55624. return;
  55625. }
  55626. if (this.isCube) {
  55627. for (var face = 0; face < 6; face++) {
  55628. engine.bindFramebuffer(this._texture, face, undefined, undefined, true);
  55629. // VBOs
  55630. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  55631. this._effect.setFloat("face", face);
  55632. // Clear
  55633. if (this.autoClear) {
  55634. engine.clear(scene.clearColor, true, false, false);
  55635. }
  55636. // Draw order
  55637. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, 6);
  55638. // Mipmaps
  55639. if (face === 5) {
  55640. engine.generateMipMapsForCubemap(this._texture);
  55641. }
  55642. }
  55643. }
  55644. else {
  55645. engine.bindFramebuffer(this._texture, 0, undefined, undefined, true);
  55646. // VBOs
  55647. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  55648. // Clear
  55649. if (this.autoClear) {
  55650. engine.clear(scene.clearColor, true, false, false);
  55651. }
  55652. // Draw order
  55653. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, 6);
  55654. }
  55655. // Unbind
  55656. engine.unBindFramebuffer(this._texture, this.isCube);
  55657. if (this.onGenerated) {
  55658. this.onGenerated();
  55659. }
  55660. this.onGeneratedObservable.notifyObservers(this);
  55661. };
  55662. /**
  55663. * Clone the texture.
  55664. * @returns the cloned texture
  55665. */
  55666. ProceduralTexture.prototype.clone = function () {
  55667. var textureSize = this.getSize();
  55668. var newTexture = new ProceduralTexture(this.name, textureSize.width, this._fragment, this.getScene(), this._fallbackTexture, this._generateMipMaps);
  55669. // Base texture
  55670. newTexture.hasAlpha = this.hasAlpha;
  55671. newTexture.level = this.level;
  55672. // RenderTarget Texture
  55673. newTexture.coordinatesMode = this.coordinatesMode;
  55674. return newTexture;
  55675. };
  55676. /**
  55677. * Dispose the texture and release its asoociated resources.
  55678. */
  55679. ProceduralTexture.prototype.dispose = function () {
  55680. var scene = this.getScene();
  55681. if (!scene) {
  55682. return;
  55683. }
  55684. var index = scene.proceduralTextures.indexOf(this);
  55685. if (index >= 0) {
  55686. scene.proceduralTextures.splice(index, 1);
  55687. }
  55688. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  55689. if (vertexBuffer) {
  55690. vertexBuffer.dispose();
  55691. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = null;
  55692. }
  55693. if (this._indexBuffer && this._engine._releaseBuffer(this._indexBuffer)) {
  55694. this._indexBuffer = null;
  55695. }
  55696. _super.prototype.dispose.call(this);
  55697. };
  55698. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55699. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55700. ], ProceduralTexture.prototype, "isEnabled", void 0);
  55701. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55702. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55703. ], ProceduralTexture.prototype, "autoClear", void 0);
  55704. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55705. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55706. ], ProceduralTexture.prototype, "_generateMipMaps", void 0);
  55707. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55708. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55709. ], ProceduralTexture.prototype, "_size", void 0);
  55710. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55711. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55712. ], ProceduralTexture.prototype, "refreshRate", null);
  55713. return ProceduralTexture;
  55714. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"]));
  55715. /***/ }),
  55716. /***/ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts":
  55717. /*!***************************************************************************!*\
  55718. !*** ./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts ***!
  55719. \***************************************************************************/
  55720. /*! exports provided: ProceduralTextureSceneComponent */
  55721. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55722. "use strict";
  55723. __webpack_require__.r(__webpack_exports__);
  55724. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return ProceduralTextureSceneComponent; });
  55725. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/tools */ "./Misc/tools.ts");
  55726. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../sceneComponent */ "./sceneComponent.ts");
  55727. /**
  55728. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  55729. * in a given scene.
  55730. */
  55731. var ProceduralTextureSceneComponent = /** @class */ (function () {
  55732. /**
  55733. * Creates a new instance of the component for the given scene
  55734. * @param scene Defines the scene to register the component in
  55735. */
  55736. function ProceduralTextureSceneComponent(scene) {
  55737. /**
  55738. * The component name helpfull to identify the component in the list of scene components.
  55739. */
  55740. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_PROCEDURALTEXTURE;
  55741. this.scene = scene;
  55742. this.scene.proceduralTextures = new Array();
  55743. scene.layers = new Array();
  55744. }
  55745. /**
  55746. * Registers the component in a given scene
  55747. */
  55748. ProceduralTextureSceneComponent.prototype.register = function () {
  55749. this.scene._beforeClearStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECLEAR_PROCEDURALTEXTURE, this, this._beforeClear);
  55750. };
  55751. /**
  55752. * Rebuilds the elements related to this component in case of
  55753. * context lost for instance.
  55754. */
  55755. ProceduralTextureSceneComponent.prototype.rebuild = function () {
  55756. // Nothing to do here.
  55757. };
  55758. /**
  55759. * Disposes the component and the associated ressources.
  55760. */
  55761. ProceduralTextureSceneComponent.prototype.dispose = function () {
  55762. // Nothing to do here.
  55763. };
  55764. ProceduralTextureSceneComponent.prototype._beforeClear = function () {
  55765. if (this.scene.proceduralTexturesEnabled) {
  55766. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
  55767. for (var proceduralIndex = 0; proceduralIndex < this.scene.proceduralTextures.length; proceduralIndex++) {
  55768. var proceduralTexture = this.scene.proceduralTextures[proceduralIndex];
  55769. if (proceduralTexture._shouldRender()) {
  55770. proceduralTexture.render();
  55771. }
  55772. }
  55773. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
  55774. }
  55775. };
  55776. return ProceduralTextureSceneComponent;
  55777. }());
  55778. /***/ }),
  55779. /***/ "./Materials/Textures/baseTexture.ts":
  55780. /*!*******************************************!*\
  55781. !*** ./Materials/Textures/baseTexture.ts ***!
  55782. \*******************************************/
  55783. /*! exports provided: BaseTexture */
  55784. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55785. "use strict";
  55786. __webpack_require__.r(__webpack_exports__);
  55787. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return BaseTexture; });
  55788. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55789. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  55790. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  55791. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  55792. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  55793. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  55794. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  55795. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  55796. /**
  55797. * Base class of all the textures in babylon.
  55798. * It groups all the common properties the materials, post process, lights... might need
  55799. * in order to make a correct use of the texture.
  55800. */
  55801. var BaseTexture = /** @class */ (function () {
  55802. /**
  55803. * Instantiates a new BaseTexture.
  55804. * Base class of all the textures in babylon.
  55805. * It groups all the common properties the materials, post process, lights... might need
  55806. * in order to make a correct use of the texture.
  55807. * @param scene Define the scene the texture blongs to
  55808. */
  55809. function BaseTexture(scene) {
  55810. /**
  55811. * Gets or sets an object used to store user defined information.
  55812. */
  55813. this.metadata = null;
  55814. /**
  55815. * For internal use only. Please do not use.
  55816. */
  55817. this.reservedDataStore = null;
  55818. this._hasAlpha = false;
  55819. /**
  55820. * Defines if the alpha value should be determined via the rgb values.
  55821. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  55822. */
  55823. this.getAlphaFromRGB = false;
  55824. /**
  55825. * Intensity or strength of the texture.
  55826. * It is commonly used by materials to fine tune the intensity of the texture
  55827. */
  55828. this.level = 1;
  55829. /**
  55830. * Define the UV chanel to use starting from 0 and defaulting to 0.
  55831. * This is part of the texture as textures usually maps to one uv set.
  55832. */
  55833. this.coordinatesIndex = 0;
  55834. this._coordinatesMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_EXPLICIT_MODE;
  55835. /**
  55836. * | Value | Type | Description |
  55837. * | ----- | ------------------ | ----------- |
  55838. * | 0 | CLAMP_ADDRESSMODE | |
  55839. * | 1 | WRAP_ADDRESSMODE | |
  55840. * | 2 | MIRROR_ADDRESSMODE | |
  55841. */
  55842. this.wrapU = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  55843. /**
  55844. * | Value | Type | Description |
  55845. * | ----- | ------------------ | ----------- |
  55846. * | 0 | CLAMP_ADDRESSMODE | |
  55847. * | 1 | WRAP_ADDRESSMODE | |
  55848. * | 2 | MIRROR_ADDRESSMODE | |
  55849. */
  55850. this.wrapV = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  55851. /**
  55852. * | Value | Type | Description |
  55853. * | ----- | ------------------ | ----------- |
  55854. * | 0 | CLAMP_ADDRESSMODE | |
  55855. * | 1 | WRAP_ADDRESSMODE | |
  55856. * | 2 | MIRROR_ADDRESSMODE | |
  55857. */
  55858. this.wrapR = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  55859. /**
  55860. * With compliant hardware and browser (supporting anisotropic filtering)
  55861. * this defines the level of anisotropic filtering in the texture.
  55862. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  55863. */
  55864. this.anisotropicFilteringLevel = BaseTexture.DEFAULT_ANISOTROPIC_FILTERING_LEVEL;
  55865. /**
  55866. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  55867. * HDR texture are usually stored in linear space.
  55868. * This only impacts the PBR and Background materials
  55869. */
  55870. this.gammaSpace = true;
  55871. /**
  55872. * Is Z inverted in the texture (useful in a cube texture).
  55873. */
  55874. this.invertZ = false;
  55875. /**
  55876. * @hidden
  55877. */
  55878. this.lodLevelInAlpha = false;
  55879. /**
  55880. * Define if the texture is a render target.
  55881. */
  55882. this.isRenderTarget = false;
  55883. /**
  55884. * Define the list of animation attached to the texture.
  55885. */
  55886. this.animations = new Array();
  55887. /**
  55888. * An event triggered when the texture is disposed.
  55889. */
  55890. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  55891. /**
  55892. * Define the current state of the loading sequence when in delayed load mode.
  55893. */
  55894. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NONE;
  55895. this._cachedSize = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"].Zero();
  55896. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__["EngineStore"].LastCreatedScene;
  55897. if (this._scene) {
  55898. this.uniqueId = this._scene.getUniqueId();
  55899. this._scene.addTexture(this);
  55900. }
  55901. this._uid = null;
  55902. }
  55903. Object.defineProperty(BaseTexture.prototype, "hasAlpha", {
  55904. get: function () {
  55905. return this._hasAlpha;
  55906. },
  55907. /**
  55908. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  55909. */
  55910. set: function (value) {
  55911. if (this._hasAlpha === value) {
  55912. return;
  55913. }
  55914. this._hasAlpha = value;
  55915. if (this._scene) {
  55916. this._scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag | _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_MiscDirtyFlag);
  55917. }
  55918. },
  55919. enumerable: true,
  55920. configurable: true
  55921. });
  55922. Object.defineProperty(BaseTexture.prototype, "coordinatesMode", {
  55923. get: function () {
  55924. return this._coordinatesMode;
  55925. },
  55926. /**
  55927. * How a texture is mapped.
  55928. *
  55929. * | Value | Type | Description |
  55930. * | ----- | ----------------------------------- | ----------- |
  55931. * | 0 | EXPLICIT_MODE | |
  55932. * | 1 | SPHERICAL_MODE | |
  55933. * | 2 | PLANAR_MODE | |
  55934. * | 3 | CUBIC_MODE | |
  55935. * | 4 | PROJECTION_MODE | |
  55936. * | 5 | SKYBOX_MODE | |
  55937. * | 6 | INVCUBIC_MODE | |
  55938. * | 7 | EQUIRECTANGULAR_MODE | |
  55939. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  55940. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  55941. */
  55942. set: function (value) {
  55943. if (this._coordinatesMode === value) {
  55944. return;
  55945. }
  55946. this._coordinatesMode = value;
  55947. if (this._scene) {
  55948. this._scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag);
  55949. }
  55950. },
  55951. enumerable: true,
  55952. configurable: true
  55953. });
  55954. Object.defineProperty(BaseTexture.prototype, "isCube", {
  55955. /**
  55956. * Define if the texture is a cube texture or if false a 2d texture.
  55957. */
  55958. get: function () {
  55959. if (!this._texture) {
  55960. return false;
  55961. }
  55962. return this._texture.isCube;
  55963. },
  55964. set: function (value) {
  55965. if (!this._texture) {
  55966. return;
  55967. }
  55968. this._texture.isCube = value;
  55969. },
  55970. enumerable: true,
  55971. configurable: true
  55972. });
  55973. Object.defineProperty(BaseTexture.prototype, "is3D", {
  55974. /**
  55975. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  55976. */
  55977. get: function () {
  55978. if (!this._texture) {
  55979. return false;
  55980. }
  55981. return this._texture.is3D;
  55982. },
  55983. set: function (value) {
  55984. if (!this._texture) {
  55985. return;
  55986. }
  55987. this._texture.is3D = value;
  55988. },
  55989. enumerable: true,
  55990. configurable: true
  55991. });
  55992. Object.defineProperty(BaseTexture.prototype, "isRGBD", {
  55993. /**
  55994. * Gets whether or not the texture contains RGBD data.
  55995. */
  55996. get: function () {
  55997. return this._texture != null && this._texture._isRGBD;
  55998. },
  55999. enumerable: true,
  56000. configurable: true
  56001. });
  56002. Object.defineProperty(BaseTexture.prototype, "noMipmap", {
  56003. /**
  56004. * Are mip maps generated for this texture or not.
  56005. */
  56006. get: function () {
  56007. return false;
  56008. },
  56009. enumerable: true,
  56010. configurable: true
  56011. });
  56012. Object.defineProperty(BaseTexture.prototype, "lodGenerationOffset", {
  56013. /**
  56014. * With prefiltered texture, defined the offset used during the prefiltering steps.
  56015. */
  56016. get: function () {
  56017. if (this._texture) {
  56018. return this._texture._lodGenerationOffset;
  56019. }
  56020. return 0.0;
  56021. },
  56022. set: function (value) {
  56023. if (this._texture) {
  56024. this._texture._lodGenerationOffset = value;
  56025. }
  56026. },
  56027. enumerable: true,
  56028. configurable: true
  56029. });
  56030. Object.defineProperty(BaseTexture.prototype, "lodGenerationScale", {
  56031. /**
  56032. * With prefiltered texture, defined the scale used during the prefiltering steps.
  56033. */
  56034. get: function () {
  56035. if (this._texture) {
  56036. return this._texture._lodGenerationScale;
  56037. }
  56038. return 0.0;
  56039. },
  56040. set: function (value) {
  56041. if (this._texture) {
  56042. this._texture._lodGenerationScale = value;
  56043. }
  56044. },
  56045. enumerable: true,
  56046. configurable: true
  56047. });
  56048. Object.defineProperty(BaseTexture.prototype, "uid", {
  56049. /**
  56050. * Define the unique id of the texture in the scene.
  56051. */
  56052. get: function () {
  56053. if (!this._uid) {
  56054. this._uid = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].RandomId();
  56055. }
  56056. return this._uid;
  56057. },
  56058. enumerable: true,
  56059. configurable: true
  56060. });
  56061. /**
  56062. * Return a string representation of the texture.
  56063. * @returns the texture as a string
  56064. */
  56065. BaseTexture.prototype.toString = function () {
  56066. return this.name;
  56067. };
  56068. /**
  56069. * Get the class name of the texture.
  56070. * @returns "BaseTexture"
  56071. */
  56072. BaseTexture.prototype.getClassName = function () {
  56073. return "BaseTexture";
  56074. };
  56075. Object.defineProperty(BaseTexture.prototype, "onDispose", {
  56076. /**
  56077. * Callback triggered when the texture has been disposed.
  56078. * Kept for back compatibility, you can use the onDisposeObservable instead.
  56079. */
  56080. set: function (callback) {
  56081. if (this._onDisposeObserver) {
  56082. this.onDisposeObservable.remove(this._onDisposeObserver);
  56083. }
  56084. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  56085. },
  56086. enumerable: true,
  56087. configurable: true
  56088. });
  56089. Object.defineProperty(BaseTexture.prototype, "isBlocking", {
  56090. /**
  56091. * Define if the texture is preventinga material to render or not.
  56092. * If not and the texture is not ready, the engine will use a default black texture instead.
  56093. */
  56094. get: function () {
  56095. return true;
  56096. },
  56097. enumerable: true,
  56098. configurable: true
  56099. });
  56100. /**
  56101. * Get the scene the texture belongs to.
  56102. * @returns the scene or null if undefined
  56103. */
  56104. BaseTexture.prototype.getScene = function () {
  56105. return this._scene;
  56106. };
  56107. /**
  56108. * Get the texture transform matrix used to offset tile the texture for istance.
  56109. * @returns the transformation matrix
  56110. */
  56111. BaseTexture.prototype.getTextureMatrix = function () {
  56112. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].IdentityReadOnly;
  56113. };
  56114. /**
  56115. * Get the texture reflection matrix used to rotate/transform the reflection.
  56116. * @returns the reflection matrix
  56117. */
  56118. BaseTexture.prototype.getReflectionTextureMatrix = function () {
  56119. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].IdentityReadOnly;
  56120. };
  56121. /**
  56122. * Get the underlying lower level texture from Babylon.
  56123. * @returns the insternal texture
  56124. */
  56125. BaseTexture.prototype.getInternalTexture = function () {
  56126. return this._texture;
  56127. };
  56128. /**
  56129. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  56130. * @returns true if ready or not blocking
  56131. */
  56132. BaseTexture.prototype.isReadyOrNotBlocking = function () {
  56133. return !this.isBlocking || this.isReady();
  56134. };
  56135. /**
  56136. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  56137. * @returns true if fully ready
  56138. */
  56139. BaseTexture.prototype.isReady = function () {
  56140. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  56141. this.delayLoad();
  56142. return false;
  56143. }
  56144. if (this._texture) {
  56145. return this._texture.isReady;
  56146. }
  56147. return false;
  56148. };
  56149. /**
  56150. * Get the size of the texture.
  56151. * @returns the texture size.
  56152. */
  56153. BaseTexture.prototype.getSize = function () {
  56154. if (this._texture) {
  56155. if (this._texture.width) {
  56156. this._cachedSize.width = this._texture.width;
  56157. this._cachedSize.height = this._texture.height;
  56158. return this._cachedSize;
  56159. }
  56160. if (this._texture._size) {
  56161. this._cachedSize.width = this._texture._size;
  56162. this._cachedSize.height = this._texture._size;
  56163. return this._cachedSize;
  56164. }
  56165. }
  56166. return this._cachedSize;
  56167. };
  56168. /**
  56169. * Get the base size of the texture.
  56170. * It can be different from the size if the texture has been resized for POT for instance
  56171. * @returns the base size
  56172. */
  56173. BaseTexture.prototype.getBaseSize = function () {
  56174. if (!this.isReady() || !this._texture) {
  56175. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"].Zero();
  56176. }
  56177. if (this._texture._size) {
  56178. return new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"](this._texture._size, this._texture._size);
  56179. }
  56180. return new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"](this._texture.baseWidth, this._texture.baseHeight);
  56181. };
  56182. /**
  56183. * Update the sampling mode of the texture.
  56184. * Default is Trilinear mode.
  56185. *
  56186. * | Value | Type | Description |
  56187. * | ----- | ------------------ | ----------- |
  56188. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  56189. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  56190. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  56191. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  56192. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  56193. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  56194. * | 7 | NEAREST_LINEAR | |
  56195. * | 8 | NEAREST_NEAREST | |
  56196. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  56197. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  56198. * | 11 | LINEAR_LINEAR | |
  56199. * | 12 | LINEAR_NEAREST | |
  56200. *
  56201. * > _mag_: magnification filter (close to the viewer)
  56202. * > _min_: minification filter (far from the viewer)
  56203. * > _mip_: filter used between mip map levels
  56204. *@param samplingMode Define the new sampling mode of the texture
  56205. */
  56206. BaseTexture.prototype.updateSamplingMode = function (samplingMode) {
  56207. if (!this._texture) {
  56208. return;
  56209. }
  56210. var scene = this.getScene();
  56211. if (!scene) {
  56212. return;
  56213. }
  56214. scene.getEngine().updateTextureSamplingMode(samplingMode, this._texture);
  56215. };
  56216. /**
  56217. * Scales the texture if is `canRescale()`
  56218. * @param ratio the resize factor we want to use to rescale
  56219. */
  56220. BaseTexture.prototype.scale = function (ratio) {
  56221. };
  56222. Object.defineProperty(BaseTexture.prototype, "canRescale", {
  56223. /**
  56224. * Get if the texture can rescale.
  56225. */
  56226. get: function () {
  56227. return false;
  56228. },
  56229. enumerable: true,
  56230. configurable: true
  56231. });
  56232. /** @hidden */
  56233. BaseTexture.prototype._getFromCache = function (url, noMipmap, sampling, invertY) {
  56234. if (!this._scene) {
  56235. return null;
  56236. }
  56237. var texturesCache = this._scene.getEngine().getLoadedTexturesCache();
  56238. for (var index = 0; index < texturesCache.length; index++) {
  56239. var texturesCacheEntry = texturesCache[index];
  56240. if (invertY === undefined || invertY === texturesCacheEntry.invertY) {
  56241. if (texturesCacheEntry.url === url && texturesCacheEntry.generateMipMaps === !noMipmap) {
  56242. if (!sampling || sampling === texturesCacheEntry.samplingMode) {
  56243. texturesCacheEntry.incrementReferences();
  56244. return texturesCacheEntry;
  56245. }
  56246. }
  56247. }
  56248. }
  56249. return null;
  56250. };
  56251. /** @hidden */
  56252. BaseTexture.prototype._rebuild = function () {
  56253. };
  56254. /**
  56255. * Triggers the load sequence in delayed load mode.
  56256. */
  56257. BaseTexture.prototype.delayLoad = function () {
  56258. };
  56259. /**
  56260. * Clones the texture.
  56261. * @returns the cloned texture
  56262. */
  56263. BaseTexture.prototype.clone = function () {
  56264. return null;
  56265. };
  56266. Object.defineProperty(BaseTexture.prototype, "textureType", {
  56267. /**
  56268. * Get the texture underlying type (INT, FLOAT...)
  56269. */
  56270. get: function () {
  56271. if (!this._texture) {
  56272. return _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  56273. }
  56274. return (this._texture.type !== undefined) ? this._texture.type : _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  56275. },
  56276. enumerable: true,
  56277. configurable: true
  56278. });
  56279. Object.defineProperty(BaseTexture.prototype, "textureFormat", {
  56280. /**
  56281. * Get the texture underlying format (RGB, RGBA...)
  56282. */
  56283. get: function () {
  56284. if (!this._texture) {
  56285. return _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA;
  56286. }
  56287. return (this._texture.format !== undefined) ? this._texture.format : _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA;
  56288. },
  56289. enumerable: true,
  56290. configurable: true
  56291. });
  56292. /**
  56293. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  56294. * This will returns an RGBA array buffer containing either in values (0-255) or
  56295. * float values (0-1) depending of the underlying buffer type.
  56296. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  56297. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  56298. * @param buffer defines a user defined buffer to fill with data (can be null)
  56299. * @returns The Array buffer containing the pixels data.
  56300. */
  56301. BaseTexture.prototype.readPixels = function (faceIndex, level, buffer) {
  56302. if (faceIndex === void 0) { faceIndex = 0; }
  56303. if (level === void 0) { level = 0; }
  56304. if (buffer === void 0) { buffer = null; }
  56305. if (!this._texture) {
  56306. return null;
  56307. }
  56308. var size = this.getSize();
  56309. var width = size.width;
  56310. var height = size.height;
  56311. var scene = this.getScene();
  56312. if (!scene) {
  56313. return null;
  56314. }
  56315. var engine = scene.getEngine();
  56316. if (level != 0) {
  56317. width = width / Math.pow(2, level);
  56318. height = height / Math.pow(2, level);
  56319. width = Math.round(width);
  56320. height = Math.round(height);
  56321. }
  56322. if (this._texture.isCube) {
  56323. return engine._readTexturePixels(this._texture, width, height, faceIndex, level, buffer);
  56324. }
  56325. return engine._readTexturePixels(this._texture, width, height, -1, level, buffer);
  56326. };
  56327. /**
  56328. * Release and destroy the underlying lower level texture aka internalTexture.
  56329. */
  56330. BaseTexture.prototype.releaseInternalTexture = function () {
  56331. if (this._texture) {
  56332. this._texture.dispose();
  56333. this._texture = null;
  56334. }
  56335. };
  56336. Object.defineProperty(BaseTexture.prototype, "sphericalPolynomial", {
  56337. /**
  56338. * Get the polynomial representation of the texture data.
  56339. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  56340. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  56341. */
  56342. get: function () {
  56343. if (!this._texture || !_Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__["CubeMapToSphericalPolynomialTools"] || !this.isReady()) {
  56344. return null;
  56345. }
  56346. if (!this._texture._sphericalPolynomial) {
  56347. this._texture._sphericalPolynomial =
  56348. _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapTextureToSphericalPolynomial(this);
  56349. }
  56350. return this._texture._sphericalPolynomial;
  56351. },
  56352. set: function (value) {
  56353. if (this._texture) {
  56354. this._texture._sphericalPolynomial = value;
  56355. }
  56356. },
  56357. enumerable: true,
  56358. configurable: true
  56359. });
  56360. Object.defineProperty(BaseTexture.prototype, "_lodTextureHigh", {
  56361. /** @hidden */
  56362. get: function () {
  56363. if (this._texture) {
  56364. return this._texture._lodTextureHigh;
  56365. }
  56366. return null;
  56367. },
  56368. enumerable: true,
  56369. configurable: true
  56370. });
  56371. Object.defineProperty(BaseTexture.prototype, "_lodTextureMid", {
  56372. /** @hidden */
  56373. get: function () {
  56374. if (this._texture) {
  56375. return this._texture._lodTextureMid;
  56376. }
  56377. return null;
  56378. },
  56379. enumerable: true,
  56380. configurable: true
  56381. });
  56382. Object.defineProperty(BaseTexture.prototype, "_lodTextureLow", {
  56383. /** @hidden */
  56384. get: function () {
  56385. if (this._texture) {
  56386. return this._texture._lodTextureLow;
  56387. }
  56388. return null;
  56389. },
  56390. enumerable: true,
  56391. configurable: true
  56392. });
  56393. /**
  56394. * Dispose the texture and release its associated resources.
  56395. */
  56396. BaseTexture.prototype.dispose = function () {
  56397. if (!this._scene) {
  56398. return;
  56399. }
  56400. // Animations
  56401. this._scene.stopAnimation(this);
  56402. // Remove from scene
  56403. this._scene._removePendingData(this);
  56404. var index = this._scene.textures.indexOf(this);
  56405. if (index >= 0) {
  56406. this._scene.textures.splice(index, 1);
  56407. }
  56408. this._scene.onTextureRemovedObservable.notifyObservers(this);
  56409. if (this._texture === undefined) {
  56410. return;
  56411. }
  56412. // Release
  56413. this.releaseInternalTexture();
  56414. // Callback
  56415. this.onDisposeObservable.notifyObservers(this);
  56416. this.onDisposeObservable.clear();
  56417. };
  56418. /**
  56419. * Serialize the texture into a JSON representation that can be parsed later on.
  56420. * @returns the JSON representation of the texture
  56421. */
  56422. BaseTexture.prototype.serialize = function () {
  56423. if (!this.name) {
  56424. return null;
  56425. }
  56426. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  56427. // Animations
  56428. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  56429. return serializationObject;
  56430. };
  56431. /**
  56432. * Helper function to be called back once a list of texture contains only ready textures.
  56433. * @param textures Define the list of textures to wait for
  56434. * @param callback Define the callback triggered once the entire list will be ready
  56435. */
  56436. BaseTexture.WhenAllReady = function (textures, callback) {
  56437. var numRemaining = textures.length;
  56438. if (numRemaining === 0) {
  56439. callback();
  56440. return;
  56441. }
  56442. var _loop_1 = function () {
  56443. texture = textures[i];
  56444. if (texture.isReady()) {
  56445. if (--numRemaining === 0) {
  56446. callback();
  56447. }
  56448. }
  56449. else {
  56450. onLoadObservable = texture.onLoadObservable;
  56451. var onLoadCallback_1 = function () {
  56452. onLoadObservable.removeCallback(onLoadCallback_1);
  56453. if (--numRemaining === 0) {
  56454. callback();
  56455. }
  56456. };
  56457. onLoadObservable.add(onLoadCallback_1);
  56458. }
  56459. };
  56460. var texture, onLoadObservable;
  56461. for (var i = 0; i < textures.length; i++) {
  56462. _loop_1();
  56463. }
  56464. };
  56465. /**
  56466. * Default anisotropic filtering level for the application.
  56467. * It is set to 4 as a good tradeoff between perf and quality.
  56468. */
  56469. BaseTexture.DEFAULT_ANISOTROPIC_FILTERING_LEVEL = 4;
  56470. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56471. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56472. ], BaseTexture.prototype, "uniqueId", void 0);
  56473. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56474. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56475. ], BaseTexture.prototype, "name", void 0);
  56476. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56477. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56478. ], BaseTexture.prototype, "metadata", void 0);
  56479. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56480. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("hasAlpha")
  56481. ], BaseTexture.prototype, "_hasAlpha", void 0);
  56482. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56483. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56484. ], BaseTexture.prototype, "getAlphaFromRGB", void 0);
  56485. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56486. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56487. ], BaseTexture.prototype, "level", void 0);
  56488. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56489. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56490. ], BaseTexture.prototype, "coordinatesIndex", void 0);
  56491. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56492. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("coordinatesMode")
  56493. ], BaseTexture.prototype, "_coordinatesMode", void 0);
  56494. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56495. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56496. ], BaseTexture.prototype, "wrapU", void 0);
  56497. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56498. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56499. ], BaseTexture.prototype, "wrapV", void 0);
  56500. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56501. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56502. ], BaseTexture.prototype, "wrapR", void 0);
  56503. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56504. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56505. ], BaseTexture.prototype, "anisotropicFilteringLevel", void 0);
  56506. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56507. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56508. ], BaseTexture.prototype, "isCube", null);
  56509. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56510. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56511. ], BaseTexture.prototype, "is3D", null);
  56512. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56513. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56514. ], BaseTexture.prototype, "gammaSpace", void 0);
  56515. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56516. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56517. ], BaseTexture.prototype, "invertZ", void 0);
  56518. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56519. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56520. ], BaseTexture.prototype, "lodLevelInAlpha", void 0);
  56521. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56522. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56523. ], BaseTexture.prototype, "lodGenerationOffset", null);
  56524. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56525. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56526. ], BaseTexture.prototype, "lodGenerationScale", null);
  56527. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56528. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56529. ], BaseTexture.prototype, "isRenderTarget", void 0);
  56530. return BaseTexture;
  56531. }());
  56532. /***/ }),
  56533. /***/ "./Materials/Textures/colorGradingTexture.ts":
  56534. /*!***************************************************!*\
  56535. !*** ./Materials/Textures/colorGradingTexture.ts ***!
  56536. \***************************************************/
  56537. /*! exports provided: ColorGradingTexture */
  56538. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56539. "use strict";
  56540. __webpack_require__.r(__webpack_exports__);
  56541. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return ColorGradingTexture; });
  56542. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56543. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  56544. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  56545. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  56546. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  56547. /**
  56548. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  56549. * It can help converting any input color in a desired output one. This can then be used to create effects
  56550. * from sepia, black and white to sixties or futuristic rendering...
  56551. *
  56552. * The only supported format is currently 3dl.
  56553. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  56554. */
  56555. var ColorGradingTexture = /** @class */ (function (_super) {
  56556. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorGradingTexture, _super);
  56557. /**
  56558. * Instantiates a ColorGradingTexture from the following parameters.
  56559. *
  56560. * @param url The location of the color gradind data (currently only supporting 3dl)
  56561. * @param scene The scene the texture will be used in
  56562. */
  56563. function ColorGradingTexture(url, scene) {
  56564. var _this = _super.call(this, scene) || this;
  56565. if (!url) {
  56566. return _this;
  56567. }
  56568. _this._engine = scene.getEngine();
  56569. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  56570. _this.name = url;
  56571. _this.url = url;
  56572. _this.hasAlpha = false;
  56573. _this.isCube = false;
  56574. _this.is3D = _this._engine.webGLVersion > 1;
  56575. _this.wrapU = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  56576. _this.wrapV = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  56577. _this.wrapR = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  56578. _this.anisotropicFilteringLevel = 1;
  56579. _this._texture = _this._getFromCache(url, true);
  56580. if (!_this._texture) {
  56581. if (!scene.useDelayedTextureLoading) {
  56582. _this.loadTexture();
  56583. }
  56584. else {
  56585. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_NOTLOADED;
  56586. }
  56587. }
  56588. return _this;
  56589. }
  56590. /**
  56591. * Returns the texture matrix used in most of the material.
  56592. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  56593. */
  56594. ColorGradingTexture.prototype.getTextureMatrix = function () {
  56595. return this._textureMatrix;
  56596. };
  56597. /**
  56598. * Occurs when the file being loaded is a .3dl LUT file.
  56599. */
  56600. ColorGradingTexture.prototype.load3dlTexture = function () {
  56601. var engine = this._engine;
  56602. var texture;
  56603. if (engine.webGLVersion === 1) {
  56604. 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);
  56605. }
  56606. else {
  56607. 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);
  56608. }
  56609. this._texture = texture;
  56610. var callback = function (text) {
  56611. if (typeof text !== "string") {
  56612. return;
  56613. }
  56614. var data = null;
  56615. var tempData = null;
  56616. var line;
  56617. var lines = text.split('\n');
  56618. var size = 0, pixelIndexW = 0, pixelIndexH = 0, pixelIndexSlice = 0;
  56619. var maxColor = 0;
  56620. for (var i = 0; i < lines.length; i++) {
  56621. line = lines[i];
  56622. if (!ColorGradingTexture._noneEmptyLineRegex.test(line)) {
  56623. continue;
  56624. }
  56625. if (line.indexOf('#') === 0) {
  56626. continue;
  56627. }
  56628. var words = line.split(" ");
  56629. if (size === 0) {
  56630. // Number of space + one
  56631. size = words.length;
  56632. data = new Uint8Array(size * size * size * 4); // volume texture of side size and rgb 8
  56633. tempData = new Float32Array(size * size * size * 4);
  56634. continue;
  56635. }
  56636. if (size != 0) {
  56637. var r = Math.max(parseInt(words[0]), 0);
  56638. var g = Math.max(parseInt(words[1]), 0);
  56639. var b = Math.max(parseInt(words[2]), 0);
  56640. maxColor = Math.max(r, maxColor);
  56641. maxColor = Math.max(g, maxColor);
  56642. maxColor = Math.max(b, maxColor);
  56643. var pixelStorageIndex = (pixelIndexW + pixelIndexSlice * size + pixelIndexH * size * size) * 4;
  56644. if (tempData) {
  56645. tempData[pixelStorageIndex + 0] = r;
  56646. tempData[pixelStorageIndex + 1] = g;
  56647. tempData[pixelStorageIndex + 2] = b;
  56648. }
  56649. // Keep for reference in case of back compat problems.
  56650. // pixelIndexSlice++;
  56651. // if (pixelIndexSlice % size == 0) {
  56652. // pixelIndexH++;
  56653. // pixelIndexSlice = 0;
  56654. // if (pixelIndexH % size == 0) {
  56655. // pixelIndexW++;
  56656. // pixelIndexH = 0;
  56657. // }
  56658. // }
  56659. pixelIndexH++;
  56660. if (pixelIndexH % size == 0) {
  56661. pixelIndexSlice++;
  56662. pixelIndexH = 0;
  56663. if (pixelIndexSlice % size == 0) {
  56664. pixelIndexW++;
  56665. pixelIndexSlice = 0;
  56666. }
  56667. }
  56668. }
  56669. }
  56670. if (tempData && data) {
  56671. for (var i = 0; i < tempData.length; i++) {
  56672. if (i > 0 && (i + 1) % 4 === 0) {
  56673. data[i] = 255;
  56674. }
  56675. else {
  56676. var value = tempData[i];
  56677. data[i] = (value / maxColor * 255);
  56678. }
  56679. }
  56680. }
  56681. if (texture.is3D) {
  56682. texture.updateSize(size, size, size);
  56683. engine.updateRawTexture3D(texture, data, _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA, false);
  56684. }
  56685. else {
  56686. texture.updateSize(size * size, size);
  56687. engine.updateRawTexture(texture, data, _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA, false);
  56688. }
  56689. };
  56690. var scene = this.getScene();
  56691. if (scene) {
  56692. scene._loadFile(this.url, callback);
  56693. }
  56694. else {
  56695. this._engine._loadFile(this.url, callback);
  56696. }
  56697. return this._texture;
  56698. };
  56699. /**
  56700. * Starts the loading process of the texture.
  56701. */
  56702. ColorGradingTexture.prototype.loadTexture = function () {
  56703. if (this.url && this.url.toLocaleLowerCase().indexOf(".3dl") == (this.url.length - 4)) {
  56704. this.load3dlTexture();
  56705. }
  56706. };
  56707. /**
  56708. * Clones the color gradind texture.
  56709. */
  56710. ColorGradingTexture.prototype.clone = function () {
  56711. var newTexture = new ColorGradingTexture(this.url, this.getScene());
  56712. // Base texture
  56713. newTexture.level = this.level;
  56714. return newTexture;
  56715. };
  56716. /**
  56717. * Called during delayed load for textures.
  56718. */
  56719. ColorGradingTexture.prototype.delayLoad = function () {
  56720. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  56721. return;
  56722. }
  56723. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_LOADED;
  56724. this._texture = this._getFromCache(this.url, true);
  56725. if (!this._texture) {
  56726. this.loadTexture();
  56727. }
  56728. };
  56729. /**
  56730. * Parses a color grading texture serialized by Babylon.
  56731. * @param parsedTexture The texture information being parsedTexture
  56732. * @param scene The scene to load the texture in
  56733. * @param rootUrl The root url of the data assets to load
  56734. * @return A color gradind texture
  56735. */
  56736. ColorGradingTexture.Parse = function (parsedTexture, scene) {
  56737. var texture = null;
  56738. if (parsedTexture.name && !parsedTexture.isRenderTarget) {
  56739. texture = new ColorGradingTexture(parsedTexture.name, scene);
  56740. texture.name = parsedTexture.name;
  56741. texture.level = parsedTexture.level;
  56742. }
  56743. return texture;
  56744. };
  56745. /**
  56746. * Serializes the LUT texture to json format.
  56747. */
  56748. ColorGradingTexture.prototype.serialize = function () {
  56749. if (!this.name) {
  56750. return null;
  56751. }
  56752. var serializationObject = {};
  56753. serializationObject.name = this.name;
  56754. serializationObject.level = this.level;
  56755. serializationObject.customType = "BABYLON.ColorGradingTexture";
  56756. return serializationObject;
  56757. };
  56758. /**
  56759. * Empty line regex stored for GC.
  56760. */
  56761. ColorGradingTexture._noneEmptyLineRegex = /\S+/;
  56762. return ColorGradingTexture;
  56763. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_2__["BaseTexture"]));
  56764. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.ColorGradingTexture"] = ColorGradingTexture;
  56765. /***/ }),
  56766. /***/ "./Materials/Textures/cubeTexture.ts":
  56767. /*!*******************************************!*\
  56768. !*** ./Materials/Textures/cubeTexture.ts ***!
  56769. \*******************************************/
  56770. /*! exports provided: CubeTexture */
  56771. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56772. "use strict";
  56773. __webpack_require__.r(__webpack_exports__);
  56774. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return CubeTexture; });
  56775. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56776. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  56777. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  56778. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  56779. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  56780. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  56781. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  56782. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  56783. /**
  56784. * Class for creating a cube texture
  56785. */
  56786. var CubeTexture = /** @class */ (function (_super) {
  56787. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubeTexture, _super);
  56788. /**
  56789. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  56790. * as prefiltered data.
  56791. * @param rootUrl defines the url of the texture or the root name of the six images
  56792. * @param scene defines the scene the texture is attached to
  56793. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  56794. * @param noMipmap defines if mipmaps should be created or not
  56795. * @param files defines the six files to load for the different faces
  56796. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  56797. * @param onError defines a callback triggered in case of error during load
  56798. * @param format defines the internal format to use for the texture once loaded
  56799. * @param prefiltered defines whether or not the texture is created from prefiltered data
  56800. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  56801. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  56802. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56803. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56804. * @return the cube texture
  56805. */
  56806. function CubeTexture(rootUrl, scene, extensions, noMipmap, files, onLoad, onError, format, prefiltered, forcedExtension, createPolynomials, lodScale, lodOffset) {
  56807. if (extensions === void 0) { extensions = null; }
  56808. if (noMipmap === void 0) { noMipmap = false; }
  56809. if (files === void 0) { files = null; }
  56810. if (onLoad === void 0) { onLoad = null; }
  56811. if (onError === void 0) { onError = null; }
  56812. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  56813. if (prefiltered === void 0) { prefiltered = false; }
  56814. if (forcedExtension === void 0) { forcedExtension = null; }
  56815. if (createPolynomials === void 0) { createPolynomials = false; }
  56816. if (lodScale === void 0) { lodScale = 0.8; }
  56817. if (lodOffset === void 0) { lodOffset = 0; }
  56818. var _this = _super.call(this, scene) || this;
  56819. /**
  56820. * Gets or sets the center of the bounding box associated with the cube texture.
  56821. * It must define where the camera used to render the texture was set
  56822. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  56823. */
  56824. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  56825. _this._rotationY = 0;
  56826. /** @hidden */
  56827. _this._prefiltered = false;
  56828. _this.name = rootUrl;
  56829. _this.url = rootUrl;
  56830. _this._noMipmap = noMipmap;
  56831. _this.hasAlpha = false;
  56832. _this._format = format;
  56833. _this.isCube = true;
  56834. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  56835. _this._createPolynomials = createPolynomials;
  56836. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CUBIC_MODE;
  56837. if (!rootUrl && !files) {
  56838. return _this;
  56839. }
  56840. var lastDot = rootUrl.lastIndexOf(".");
  56841. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? rootUrl.substring(lastDot).toLowerCase() : "");
  56842. var isDDS = (extension === ".dds");
  56843. var isEnv = (extension === ".env");
  56844. if (isEnv) {
  56845. _this.gammaSpace = false;
  56846. _this._prefiltered = false;
  56847. }
  56848. else {
  56849. _this._prefiltered = prefiltered;
  56850. if (prefiltered) {
  56851. _this.gammaSpace = false;
  56852. }
  56853. }
  56854. _this._texture = _this._getFromCache(rootUrl, noMipmap);
  56855. if (!files) {
  56856. if (!isEnv && !isDDS && !extensions) {
  56857. extensions = ["_px.jpg", "_py.jpg", "_pz.jpg", "_nx.jpg", "_ny.jpg", "_nz.jpg"];
  56858. }
  56859. files = [];
  56860. if (extensions) {
  56861. for (var index = 0; index < extensions.length; index++) {
  56862. files.push(rootUrl + extensions[index]);
  56863. }
  56864. }
  56865. }
  56866. _this._files = files;
  56867. if (!_this._texture) {
  56868. if (!scene.useDelayedTextureLoading) {
  56869. if (prefiltered) {
  56870. _this._texture = scene.getEngine().createPrefilteredCubeTexture(rootUrl, scene, lodScale, lodOffset, onLoad, onError, format, forcedExtension, _this._createPolynomials);
  56871. }
  56872. else {
  56873. _this._texture = scene.getEngine().createCubeTexture(rootUrl, scene, files, noMipmap, onLoad, onError, _this._format, forcedExtension, false, lodScale, lodOffset);
  56874. }
  56875. }
  56876. else {
  56877. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  56878. }
  56879. }
  56880. else if (onLoad) {
  56881. if (_this._texture.isReady) {
  56882. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetImmediate(function () { return onLoad(); });
  56883. }
  56884. else {
  56885. _this._texture.onLoadedObservable.add(onLoad);
  56886. }
  56887. }
  56888. return _this;
  56889. }
  56890. Object.defineProperty(CubeTexture.prototype, "boundingBoxSize", {
  56891. /**
  56892. * Returns the bounding box size
  56893. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  56894. */
  56895. get: function () {
  56896. return this._boundingBoxSize;
  56897. },
  56898. /**
  56899. * Gets or sets the size of the bounding box associated with the cube texture
  56900. * When defined, the cubemap will switch to local mode
  56901. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  56902. * @example https://www.babylonjs-playground.com/#RNASML
  56903. */
  56904. set: function (value) {
  56905. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  56906. return;
  56907. }
  56908. this._boundingBoxSize = value;
  56909. var scene = this.getScene();
  56910. if (scene) {
  56911. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  56912. }
  56913. },
  56914. enumerable: true,
  56915. configurable: true
  56916. });
  56917. Object.defineProperty(CubeTexture.prototype, "rotationY", {
  56918. /**
  56919. * Gets texture matrix rotation angle around Y axis radians.
  56920. */
  56921. get: function () {
  56922. return this._rotationY;
  56923. },
  56924. /**
  56925. * Sets texture matrix rotation angle around Y axis in radians.
  56926. */
  56927. set: function (value) {
  56928. this._rotationY = value;
  56929. this.setReflectionTextureMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationY(this._rotationY));
  56930. },
  56931. enumerable: true,
  56932. configurable: true
  56933. });
  56934. Object.defineProperty(CubeTexture.prototype, "noMipmap", {
  56935. /**
  56936. * Are mip maps generated for this texture or not.
  56937. */
  56938. get: function () {
  56939. return this._noMipmap;
  56940. },
  56941. enumerable: true,
  56942. configurable: true
  56943. });
  56944. /**
  56945. * Creates a cube texture from an array of image urls
  56946. * @param files defines an array of image urls
  56947. * @param scene defines the hosting scene
  56948. * @param noMipmap specifies if mip maps are not used
  56949. * @returns a cube texture
  56950. */
  56951. CubeTexture.CreateFromImages = function (files, scene, noMipmap) {
  56952. var rootUrlKey = "";
  56953. files.forEach(function (url) { return rootUrlKey += url; });
  56954. return new CubeTexture(rootUrlKey, scene, null, noMipmap, files);
  56955. };
  56956. /**
  56957. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  56958. * @param url defines the url of the prefiltered texture
  56959. * @param scene defines the scene the texture is attached to
  56960. * @param forcedExtension defines the extension of the file if different from the url
  56961. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  56962. * @return the prefiltered texture
  56963. */
  56964. CubeTexture.CreateFromPrefilteredData = function (url, scene, forcedExtension, createPolynomials) {
  56965. if (forcedExtension === void 0) { forcedExtension = null; }
  56966. if (createPolynomials === void 0) { createPolynomials = true; }
  56967. return new CubeTexture(url, scene, null, false, null, null, null, undefined, true, forcedExtension, createPolynomials);
  56968. };
  56969. /**
  56970. * Get the current class name of the texture useful for serialization or dynamic coding.
  56971. * @returns "CubeTexture"
  56972. */
  56973. CubeTexture.prototype.getClassName = function () {
  56974. return "CubeTexture";
  56975. };
  56976. /**
  56977. * Update the url (and optional buffer) of this texture if url was null during construction.
  56978. * @param url the url of the texture
  56979. * @param forcedExtension defines the extension to use
  56980. * @param onLoad callback called when the texture is loaded (defaults to null)
  56981. */
  56982. CubeTexture.prototype.updateURL = function (url, forcedExtension, onLoad) {
  56983. if (this.url) {
  56984. this.releaseInternalTexture();
  56985. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  56986. }
  56987. this.url = url;
  56988. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  56989. this._prefiltered = false;
  56990. if (onLoad) {
  56991. this._delayedOnLoad = onLoad;
  56992. }
  56993. this.delayLoad(forcedExtension);
  56994. };
  56995. /**
  56996. * Delays loading of the cube texture
  56997. * @param forcedExtension defines the extension to use
  56998. */
  56999. CubeTexture.prototype.delayLoad = function (forcedExtension) {
  57000. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  57001. return;
  57002. }
  57003. var scene = this.getScene();
  57004. if (!scene) {
  57005. return;
  57006. }
  57007. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  57008. this._texture = this._getFromCache(this.url, this._noMipmap);
  57009. if (!this._texture) {
  57010. if (this._prefiltered) {
  57011. this._texture = scene.getEngine().createPrefilteredCubeTexture(this.url, scene, this.lodGenerationScale, this.lodGenerationOffset, this._delayedOnLoad, undefined, this._format, undefined, this._createPolynomials);
  57012. }
  57013. else {
  57014. this._texture = scene.getEngine().createCubeTexture(this.url, scene, this._files, this._noMipmap, this._delayedOnLoad, undefined, this._format, forcedExtension);
  57015. }
  57016. }
  57017. };
  57018. /**
  57019. * Returns the reflection texture matrix
  57020. * @returns the reflection texture matrix
  57021. */
  57022. CubeTexture.prototype.getReflectionTextureMatrix = function () {
  57023. return this._textureMatrix;
  57024. };
  57025. /**
  57026. * Sets the reflection texture matrix
  57027. * @param value Reflection texture matrix
  57028. */
  57029. CubeTexture.prototype.setReflectionTextureMatrix = function (value) {
  57030. var _this = this;
  57031. if (value.updateFlag === this._textureMatrix.updateFlag) {
  57032. return;
  57033. }
  57034. if (value.isIdentity() !== this._textureMatrix.isIdentity()) {
  57035. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) { return mat.getActiveTextures().indexOf(_this) !== -1; });
  57036. }
  57037. this._textureMatrix = value;
  57038. };
  57039. /**
  57040. * Parses text to create a cube texture
  57041. * @param parsedTexture define the serialized text to read from
  57042. * @param scene defines the hosting scene
  57043. * @param rootUrl defines the root url of the cube texture
  57044. * @returns a cube texture
  57045. */
  57046. CubeTexture.Parse = function (parsedTexture, scene, rootUrl) {
  57047. var texture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () {
  57048. var prefiltered = false;
  57049. if (parsedTexture.prefiltered) {
  57050. prefiltered = parsedTexture.prefiltered;
  57051. }
  57052. return new CubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.extensions, false, null, null, null, undefined, prefiltered);
  57053. }, parsedTexture, scene);
  57054. // Local Cubemaps
  57055. if (parsedTexture.boundingBoxPosition) {
  57056. texture.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedTexture.boundingBoxPosition);
  57057. }
  57058. if (parsedTexture.boundingBoxSize) {
  57059. texture.boundingBoxSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedTexture.boundingBoxSize);
  57060. }
  57061. // Animations
  57062. if (parsedTexture.animations) {
  57063. for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
  57064. var parsedAnimation = parsedTexture.animations[animationIndex];
  57065. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].GetClass("BABYLON.Animation");
  57066. if (internalClass) {
  57067. texture.animations.push(internalClass.Parse(parsedAnimation));
  57068. }
  57069. }
  57070. }
  57071. return texture;
  57072. };
  57073. /**
  57074. * Makes a clone, or deep copy, of the cube texture
  57075. * @returns a new cube texture
  57076. */
  57077. CubeTexture.prototype.clone = function () {
  57078. var _this = this;
  57079. var scene = this.getScene();
  57080. var uniqueId = 0;
  57081. var newCubeTexture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  57082. if (!scene) {
  57083. return _this;
  57084. }
  57085. var cubeTexture = new CubeTexture(_this.url, scene, _this._extensions, _this._noMipmap, _this._files);
  57086. uniqueId = cubeTexture.uniqueId;
  57087. return cubeTexture;
  57088. }, this);
  57089. newCubeTexture.uniqueId = uniqueId;
  57090. return newCubeTexture;
  57091. };
  57092. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57093. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("rotationY")
  57094. ], CubeTexture.prototype, "rotationY", null);
  57095. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57096. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("textureMatrix")
  57097. ], CubeTexture.prototype, "_textureMatrix", void 0);
  57098. return CubeTexture;
  57099. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_4__["BaseTexture"]));
  57100. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"]._CubeTextureParser = CubeTexture.Parse;
  57101. // Some exporters relies on Tools.Instantiate
  57102. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].RegisteredTypes["BABYLON.CubeTexture"] = CubeTexture;
  57103. /***/ }),
  57104. /***/ "./Materials/Textures/dynamicTexture.ts":
  57105. /*!**********************************************!*\
  57106. !*** ./Materials/Textures/dynamicTexture.ts ***!
  57107. \**********************************************/
  57108. /*! exports provided: DynamicTexture */
  57109. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57110. "use strict";
  57111. __webpack_require__.r(__webpack_exports__);
  57112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return DynamicTexture; });
  57113. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57114. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  57115. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  57116. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57117. /**
  57118. * A class extending Texture allowing drawing on a texture
  57119. * @see http://doc.babylonjs.com/how_to/dynamictexture
  57120. */
  57121. var DynamicTexture = /** @class */ (function (_super) {
  57122. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DynamicTexture, _super);
  57123. /**
  57124. * Creates a DynamicTexture
  57125. * @param name defines the name of the texture
  57126. * @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
  57127. * @param scene defines the scene where you want the texture
  57128. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  57129. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57130. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  57131. */
  57132. function DynamicTexture(name, options, scene, generateMipMaps, samplingMode, format) {
  57133. if (scene === void 0) { scene = null; }
  57134. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  57135. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA; }
  57136. var _this = _super.call(this, null, scene, !generateMipMaps, undefined, samplingMode, undefined, undefined, undefined, undefined, format) || this;
  57137. _this.name = name;
  57138. _this._engine = _this.getScene().getEngine();
  57139. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  57140. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  57141. _this._generateMipMaps = generateMipMaps;
  57142. if (options.getContext) {
  57143. _this._canvas = options;
  57144. _this._texture = _this._engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
  57145. }
  57146. else {
  57147. _this._canvas = document.createElement("canvas");
  57148. if (options.width || options.width === 0) {
  57149. _this._texture = _this._engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
  57150. }
  57151. else {
  57152. _this._texture = _this._engine.createDynamicTexture(options, options, generateMipMaps, samplingMode);
  57153. }
  57154. }
  57155. var textureSize = _this.getSize();
  57156. _this._canvas.width = textureSize.width;
  57157. _this._canvas.height = textureSize.height;
  57158. _this._context = _this._canvas.getContext("2d");
  57159. return _this;
  57160. }
  57161. /**
  57162. * Get the current class name of the texture useful for serialization or dynamic coding.
  57163. * @returns "DynamicTexture"
  57164. */
  57165. DynamicTexture.prototype.getClassName = function () {
  57166. return "DynamicTexture";
  57167. };
  57168. Object.defineProperty(DynamicTexture.prototype, "canRescale", {
  57169. /**
  57170. * Gets the current state of canRescale
  57171. */
  57172. get: function () {
  57173. return true;
  57174. },
  57175. enumerable: true,
  57176. configurable: true
  57177. });
  57178. DynamicTexture.prototype._recreate = function (textureSize) {
  57179. this._canvas.width = textureSize.width;
  57180. this._canvas.height = textureSize.height;
  57181. this.releaseInternalTexture();
  57182. this._texture = this._engine.createDynamicTexture(textureSize.width, textureSize.height, this._generateMipMaps, this.samplingMode);
  57183. };
  57184. /**
  57185. * Scales the texture
  57186. * @param ratio the scale factor to apply to both width and height
  57187. */
  57188. DynamicTexture.prototype.scale = function (ratio) {
  57189. var textureSize = this.getSize();
  57190. textureSize.width *= ratio;
  57191. textureSize.height *= ratio;
  57192. this._recreate(textureSize);
  57193. };
  57194. /**
  57195. * Resizes the texture
  57196. * @param width the new width
  57197. * @param height the new height
  57198. */
  57199. DynamicTexture.prototype.scaleTo = function (width, height) {
  57200. var textureSize = this.getSize();
  57201. textureSize.width = width;
  57202. textureSize.height = height;
  57203. this._recreate(textureSize);
  57204. };
  57205. /**
  57206. * Gets the context of the canvas used by the texture
  57207. * @returns the canvas context of the dynamic texture
  57208. */
  57209. DynamicTexture.prototype.getContext = function () {
  57210. return this._context;
  57211. };
  57212. /**
  57213. * Clears the texture
  57214. */
  57215. DynamicTexture.prototype.clear = function () {
  57216. var size = this.getSize();
  57217. this._context.fillRect(0, 0, size.width, size.height);
  57218. };
  57219. /**
  57220. * Updates the texture
  57221. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  57222. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  57223. */
  57224. DynamicTexture.prototype.update = function (invertY, premulAlpha) {
  57225. if (premulAlpha === void 0) { premulAlpha = false; }
  57226. this._engine.updateDynamicTexture(this._texture, this._canvas, invertY === undefined ? true : invertY, premulAlpha, this._format || undefined);
  57227. };
  57228. /**
  57229. * Draws text onto the texture
  57230. * @param text defines the text to be drawn
  57231. * @param x defines the placement of the text from the left
  57232. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  57233. * @param font defines the font to be used with font-style, font-size, font-name
  57234. * @param color defines the color used for the text
  57235. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  57236. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  57237. * @param update defines whether texture is immediately update (default is true)
  57238. */
  57239. DynamicTexture.prototype.drawText = function (text, x, y, font, color, clearColor, invertY, update) {
  57240. if (update === void 0) { update = true; }
  57241. var size = this.getSize();
  57242. if (clearColor) {
  57243. this._context.fillStyle = clearColor;
  57244. this._context.fillRect(0, 0, size.width, size.height);
  57245. }
  57246. this._context.font = font;
  57247. if (x === null || x === undefined) {
  57248. var textSize = this._context.measureText(text);
  57249. x = (size.width - textSize.width) / 2;
  57250. }
  57251. if (y === null || y === undefined) {
  57252. var fontSize = parseInt((font.replace(/\D/g, '')));
  57253. y = (size.height / 2) + (fontSize / 3.65);
  57254. }
  57255. this._context.fillStyle = color;
  57256. this._context.fillText(text, x, y);
  57257. if (update) {
  57258. this.update(invertY);
  57259. }
  57260. };
  57261. /**
  57262. * Clones the texture
  57263. * @returns the clone of the texture.
  57264. */
  57265. DynamicTexture.prototype.clone = function () {
  57266. var scene = this.getScene();
  57267. if (!scene) {
  57268. return this;
  57269. }
  57270. var textureSize = this.getSize();
  57271. var newTexture = new DynamicTexture(this.name, textureSize, scene, this._generateMipMaps);
  57272. // Base texture
  57273. newTexture.hasAlpha = this.hasAlpha;
  57274. newTexture.level = this.level;
  57275. // Dynamic Texture
  57276. newTexture.wrapU = this.wrapU;
  57277. newTexture.wrapV = this.wrapV;
  57278. return newTexture;
  57279. };
  57280. /**
  57281. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  57282. * @returns a serialized dynamic texture object
  57283. */
  57284. DynamicTexture.prototype.serialize = function () {
  57285. var scene = this.getScene();
  57286. if (scene && !scene.isReady()) {
  57287. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("The scene must be ready before serializing the dynamic texture");
  57288. }
  57289. var serializationObject = _super.prototype.serialize.call(this);
  57290. serializationObject.base64String = this._canvas.toDataURL();
  57291. serializationObject.invertY = this._invertY;
  57292. serializationObject.samplingMode = this.samplingMode;
  57293. return serializationObject;
  57294. };
  57295. /** @hidden */
  57296. DynamicTexture.prototype._rebuild = function () {
  57297. this.update();
  57298. };
  57299. return DynamicTexture;
  57300. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]));
  57301. /***/ }),
  57302. /***/ "./Materials/Textures/hdrCubeTexture.ts":
  57303. /*!**********************************************!*\
  57304. !*** ./Materials/Textures/hdrCubeTexture.ts ***!
  57305. \**********************************************/
  57306. /*! exports provided: HDRCubeTexture */
  57307. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57308. "use strict";
  57309. __webpack_require__.r(__webpack_exports__);
  57310. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return HDRCubeTexture; });
  57311. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57312. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  57313. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  57314. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  57315. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  57316. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57317. /* harmony import */ var _Misc_HighDynamicRange_hdr__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/hdr */ "./Misc/HighDynamicRange/hdr.ts");
  57318. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  57319. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  57320. /**
  57321. * This represents a texture coming from an HDR input.
  57322. *
  57323. * The only supported format is currently panorama picture stored in RGBE format.
  57324. * Example of such files can be found on HDRLib: http://hdrlib.com/
  57325. */
  57326. var HDRCubeTexture = /** @class */ (function (_super) {
  57327. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HDRCubeTexture, _super);
  57328. /**
  57329. * Instantiates an HDRTexture from the following parameters.
  57330. *
  57331. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  57332. * @param scene The scene the texture will be used in
  57333. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  57334. * @param noMipmap Forces to not generate the mipmap if true
  57335. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  57336. * @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)
  57337. * @param reserved Reserved flag for internal use.
  57338. */
  57339. function HDRCubeTexture(url, scene, size, noMipmap, generateHarmonics, gammaSpace, reserved, onLoad, onError) {
  57340. if (noMipmap === void 0) { noMipmap = false; }
  57341. if (generateHarmonics === void 0) { generateHarmonics = true; }
  57342. if (gammaSpace === void 0) { gammaSpace = false; }
  57343. if (reserved === void 0) { reserved = false; }
  57344. if (onLoad === void 0) { onLoad = null; }
  57345. if (onError === void 0) { onError = null; }
  57346. var _this = _super.call(this, scene) || this;
  57347. _this._generateHarmonics = true;
  57348. _this._onLoad = null;
  57349. _this._onError = null;
  57350. /**
  57351. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  57352. */
  57353. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CUBIC_MODE;
  57354. _this._isBlocking = true;
  57355. _this._rotationY = 0;
  57356. /**
  57357. * Gets or sets the center of the bounding box associated with the cube texture
  57358. * It must define where the camera used to render the texture was set
  57359. */
  57360. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  57361. if (!url) {
  57362. return _this;
  57363. }
  57364. _this.name = url;
  57365. _this.url = url;
  57366. _this.hasAlpha = false;
  57367. _this.isCube = true;
  57368. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  57369. _this._onLoad = onLoad;
  57370. _this._onError = onError;
  57371. _this.gammaSpace = gammaSpace;
  57372. _this._noMipmap = noMipmap;
  57373. _this._size = size;
  57374. _this._texture = _this._getFromCache(url, _this._noMipmap);
  57375. if (!_this._texture) {
  57376. if (!scene.useDelayedTextureLoading) {
  57377. _this.loadTexture();
  57378. }
  57379. else {
  57380. _this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED;
  57381. }
  57382. }
  57383. return _this;
  57384. }
  57385. Object.defineProperty(HDRCubeTexture.prototype, "isBlocking", {
  57386. /**
  57387. * Gets wether or not the texture is blocking during loading.
  57388. */
  57389. get: function () {
  57390. return this._isBlocking;
  57391. },
  57392. /**
  57393. * Sets wether or not the texture is blocking during loading.
  57394. */
  57395. set: function (value) {
  57396. this._isBlocking = value;
  57397. },
  57398. enumerable: true,
  57399. configurable: true
  57400. });
  57401. Object.defineProperty(HDRCubeTexture.prototype, "rotationY", {
  57402. /**
  57403. * Gets texture matrix rotation angle around Y axis radians.
  57404. */
  57405. get: function () {
  57406. return this._rotationY;
  57407. },
  57408. /**
  57409. * Sets texture matrix rotation angle around Y axis in radians.
  57410. */
  57411. set: function (value) {
  57412. this._rotationY = value;
  57413. this.setReflectionTextureMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationY(this._rotationY));
  57414. },
  57415. enumerable: true,
  57416. configurable: true
  57417. });
  57418. Object.defineProperty(HDRCubeTexture.prototype, "boundingBoxSize", {
  57419. get: function () {
  57420. return this._boundingBoxSize;
  57421. },
  57422. /**
  57423. * Gets or sets the size of the bounding box associated with the cube texture
  57424. * When defined, the cubemap will switch to local mode
  57425. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57426. * @example https://www.babylonjs-playground.com/#RNASML
  57427. */
  57428. set: function (value) {
  57429. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  57430. return;
  57431. }
  57432. this._boundingBoxSize = value;
  57433. var scene = this.getScene();
  57434. if (scene) {
  57435. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TextureDirtyFlag);
  57436. }
  57437. },
  57438. enumerable: true,
  57439. configurable: true
  57440. });
  57441. /**
  57442. * Get the current class name of the texture useful for serialization or dynamic coding.
  57443. * @returns "HDRCubeTexture"
  57444. */
  57445. HDRCubeTexture.prototype.getClassName = function () {
  57446. return "HDRCubeTexture";
  57447. };
  57448. /**
  57449. * Occurs when the file is raw .hdr file.
  57450. */
  57451. HDRCubeTexture.prototype.loadTexture = function () {
  57452. var _this = this;
  57453. var callback = function (buffer) {
  57454. _this.lodGenerationOffset = 0.0;
  57455. _this.lodGenerationScale = 0.8;
  57456. var scene = _this.getScene();
  57457. if (!scene) {
  57458. return null;
  57459. }
  57460. // Extract the raw linear data.
  57461. var data = _Misc_HighDynamicRange_hdr__WEBPACK_IMPORTED_MODULE_6__["HDRTools"].GetCubeMapTextureData(buffer, _this._size);
  57462. // Generate harmonics if needed.
  57463. if (_this._generateHarmonics) {
  57464. var sphericalPolynomial = _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_7__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapToSphericalPolynomial(data);
  57465. _this.sphericalPolynomial = sphericalPolynomial;
  57466. }
  57467. var results = [];
  57468. var byteArray = null;
  57469. // Push each faces.
  57470. for (var j = 0; j < 6; j++) {
  57471. // Create uintarray fallback.
  57472. if (!scene.getEngine().getCaps().textureFloat) {
  57473. // 3 channels of 1 bytes per pixel in bytes.
  57474. var byteBuffer = new ArrayBuffer(_this._size * _this._size * 3);
  57475. byteArray = new Uint8Array(byteBuffer);
  57476. }
  57477. var dataFace = (data[HDRCubeTexture._facesMapping[j]]);
  57478. // If special cases.
  57479. if (_this.gammaSpace || byteArray) {
  57480. for (var i = 0; i < _this._size * _this._size; i++) {
  57481. // Put in gamma space if requested.
  57482. if (_this.gammaSpace) {
  57483. dataFace[(i * 3) + 0] = Math.pow(dataFace[(i * 3) + 0], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  57484. dataFace[(i * 3) + 1] = Math.pow(dataFace[(i * 3) + 1], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  57485. dataFace[(i * 3) + 2] = Math.pow(dataFace[(i * 3) + 2], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  57486. }
  57487. // Convert to int texture for fallback.
  57488. if (byteArray) {
  57489. var r = Math.max(dataFace[(i * 3) + 0] * 255, 0);
  57490. var g = Math.max(dataFace[(i * 3) + 1] * 255, 0);
  57491. var b = Math.max(dataFace[(i * 3) + 2] * 255, 0);
  57492. // May use luminance instead if the result is not accurate.
  57493. var max = Math.max(Math.max(r, g), b);
  57494. if (max > 255) {
  57495. var scale = 255 / max;
  57496. r *= scale;
  57497. g *= scale;
  57498. b *= scale;
  57499. }
  57500. byteArray[(i * 3) + 0] = r;
  57501. byteArray[(i * 3) + 1] = g;
  57502. byteArray[(i * 3) + 2] = b;
  57503. }
  57504. }
  57505. }
  57506. if (byteArray) {
  57507. results.push(byteArray);
  57508. }
  57509. else {
  57510. results.push(dataFace);
  57511. }
  57512. }
  57513. return results;
  57514. };
  57515. var scene = this.getScene();
  57516. if (scene) {
  57517. 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);
  57518. }
  57519. };
  57520. HDRCubeTexture.prototype.clone = function () {
  57521. var scene = this.getScene();
  57522. if (!scene) {
  57523. return this;
  57524. }
  57525. var newTexture = new HDRCubeTexture(this.url, scene, this._size, this._noMipmap, this._generateHarmonics, this.gammaSpace);
  57526. // Base texture
  57527. newTexture.level = this.level;
  57528. newTexture.wrapU = this.wrapU;
  57529. newTexture.wrapV = this.wrapV;
  57530. newTexture.coordinatesIndex = this.coordinatesIndex;
  57531. newTexture.coordinatesMode = this.coordinatesMode;
  57532. return newTexture;
  57533. };
  57534. // Methods
  57535. HDRCubeTexture.prototype.delayLoad = function () {
  57536. if (this.delayLoadState !== _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED) {
  57537. return;
  57538. }
  57539. this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_LOADED;
  57540. this._texture = this._getFromCache(this.url, this._noMipmap);
  57541. if (!this._texture) {
  57542. this.loadTexture();
  57543. }
  57544. };
  57545. /**
  57546. * Get the texture reflection matrix used to rotate/transform the reflection.
  57547. * @returns the reflection matrix
  57548. */
  57549. HDRCubeTexture.prototype.getReflectionTextureMatrix = function () {
  57550. return this._textureMatrix;
  57551. };
  57552. /**
  57553. * Set the texture reflection matrix used to rotate/transform the reflection.
  57554. * @param value Define the reflection matrix to set
  57555. */
  57556. HDRCubeTexture.prototype.setReflectionTextureMatrix = function (value) {
  57557. var _this = this;
  57558. this._textureMatrix = value;
  57559. if (value.updateFlag === this._textureMatrix.updateFlag) {
  57560. return;
  57561. }
  57562. if (value.isIdentity() !== this._textureMatrix.isIdentity()) {
  57563. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) { return mat.getActiveTextures().indexOf(_this) !== -1; });
  57564. }
  57565. };
  57566. /**
  57567. * Parses a JSON representation of an HDR Texture in order to create the texture
  57568. * @param parsedTexture Define the JSON representation
  57569. * @param scene Define the scene the texture should be created in
  57570. * @param rootUrl Define the root url in case we need to load relative dependencies
  57571. * @returns the newly created texture after parsing
  57572. */
  57573. HDRCubeTexture.Parse = function (parsedTexture, scene, rootUrl) {
  57574. var texture = null;
  57575. if (parsedTexture.name && !parsedTexture.isRenderTarget) {
  57576. texture = new HDRCubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.size, parsedTexture.noMipmap, parsedTexture.generateHarmonics, parsedTexture.useInGammaSpace);
  57577. texture.name = parsedTexture.name;
  57578. texture.hasAlpha = parsedTexture.hasAlpha;
  57579. texture.level = parsedTexture.level;
  57580. texture.coordinatesMode = parsedTexture.coordinatesMode;
  57581. texture.isBlocking = parsedTexture.isBlocking;
  57582. }
  57583. if (texture) {
  57584. if (parsedTexture.boundingBoxPosition) {
  57585. texture.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(parsedTexture.boundingBoxPosition);
  57586. }
  57587. if (parsedTexture.boundingBoxSize) {
  57588. texture.boundingBoxSize = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(parsedTexture.boundingBoxSize);
  57589. }
  57590. if (parsedTexture.rotationY) {
  57591. texture.rotationY = parsedTexture.rotationY;
  57592. }
  57593. }
  57594. return texture;
  57595. };
  57596. HDRCubeTexture.prototype.serialize = function () {
  57597. if (!this.name) {
  57598. return null;
  57599. }
  57600. var serializationObject = {};
  57601. serializationObject.name = this.name;
  57602. serializationObject.hasAlpha = this.hasAlpha;
  57603. serializationObject.isCube = true;
  57604. serializationObject.level = this.level;
  57605. serializationObject.size = this._size;
  57606. serializationObject.coordinatesMode = this.coordinatesMode;
  57607. serializationObject.useInGammaSpace = this.gammaSpace;
  57608. serializationObject.generateHarmonics = this._generateHarmonics;
  57609. serializationObject.customType = "BABYLON.HDRCubeTexture";
  57610. serializationObject.noMipmap = this._noMipmap;
  57611. serializationObject.isBlocking = this._isBlocking;
  57612. serializationObject.rotationY = this._rotationY;
  57613. return serializationObject;
  57614. };
  57615. HDRCubeTexture._facesMapping = [
  57616. "right",
  57617. "left",
  57618. "up",
  57619. "down",
  57620. "front",
  57621. "back"
  57622. ];
  57623. return HDRCubeTexture;
  57624. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_3__["BaseTexture"]));
  57625. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].RegisteredTypes["BABYLON.HDRCubeTexture"] = HDRCubeTexture;
  57626. /***/ }),
  57627. /***/ "./Materials/Textures/index.ts":
  57628. /*!*************************************!*\
  57629. !*** ./Materials/Textures/index.ts ***!
  57630. \*************************************/
  57631. /*! exports provided: BaseTexture, CubeTexture, DynamicTexture, InternalTexture, MirrorTexture, RawTexture, RenderTargetTexture, Texture, ColorGradingTexture, HDRCubeTexture, DummyInternalTextureTracker, MultiRenderTarget, RawCubeTexture, RawTexture3D, RefractionTexture, VideoTexture, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTexture, ProceduralTextureSceneComponent */
  57632. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57633. "use strict";
  57634. __webpack_require__.r(__webpack_exports__);
  57635. /* harmony import */ var _baseTexture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./baseTexture */ "./Materials/Textures/baseTexture.ts");
  57636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _baseTexture__WEBPACK_IMPORTED_MODULE_0__["BaseTexture"]; });
  57637. /* harmony import */ var _colorGradingTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./colorGradingTexture */ "./Materials/Textures/colorGradingTexture.ts");
  57638. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _colorGradingTexture__WEBPACK_IMPORTED_MODULE_1__["ColorGradingTexture"]; });
  57639. /* harmony import */ var _cubeTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  57640. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _cubeTexture__WEBPACK_IMPORTED_MODULE_2__["CubeTexture"]; });
  57641. /* harmony import */ var _dynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  57642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _dynamicTexture__WEBPACK_IMPORTED_MODULE_3__["DynamicTexture"]; });
  57643. /* harmony import */ var _hdrCubeTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  57644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _hdrCubeTexture__WEBPACK_IMPORTED_MODULE_4__["HDRCubeTexture"]; });
  57645. /* harmony import */ var _internalTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./internalTexture */ "./Materials/Textures/internalTexture.ts");
  57646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _internalTexture__WEBPACK_IMPORTED_MODULE_5__["InternalTexture"]; });
  57647. /* harmony import */ var _internalTextureTracker__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./internalTextureTracker */ "./Materials/Textures/internalTextureTracker.ts");
  57648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _internalTextureTracker__WEBPACK_IMPORTED_MODULE_6__["DummyInternalTextureTracker"]; });
  57649. /* harmony import */ var _Loaders_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Loaders/index */ "./Materials/Textures/Loaders/index.ts");
  57650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_DDSTextureLoader"]; });
  57651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_ENVTextureLoader"]; });
  57652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_KTXTextureLoader"]; });
  57653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_TGATextureLoader"]; });
  57654. /* harmony import */ var _mirrorTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./mirrorTexture */ "./Materials/Textures/mirrorTexture.ts");
  57655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _mirrorTexture__WEBPACK_IMPORTED_MODULE_8__["MirrorTexture"]; });
  57656. /* harmony import */ var _multiRenderTarget__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./multiRenderTarget */ "./Materials/Textures/multiRenderTarget.ts");
  57657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _multiRenderTarget__WEBPACK_IMPORTED_MODULE_9__["MultiRenderTarget"]; });
  57658. /* harmony import */ var _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Procedurals/index */ "./Materials/Textures/Procedurals/index.ts");
  57659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["CustomProceduralTexture"]; });
  57660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["NoiseProceduralTexture"]; });
  57661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["ProceduralTexture"]; });
  57662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["ProceduralTextureSceneComponent"]; });
  57663. /* harmony import */ var _rawCubeTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./rawCubeTexture */ "./Materials/Textures/rawCubeTexture.ts");
  57664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _rawCubeTexture__WEBPACK_IMPORTED_MODULE_11__["RawCubeTexture"]; });
  57665. /* harmony import */ var _rawTexture__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./rawTexture */ "./Materials/Textures/rawTexture.ts");
  57666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _rawTexture__WEBPACK_IMPORTED_MODULE_12__["RawTexture"]; });
  57667. /* harmony import */ var _rawTexture3D__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./rawTexture3D */ "./Materials/Textures/rawTexture3D.ts");
  57668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _rawTexture3D__WEBPACK_IMPORTED_MODULE_13__["RawTexture3D"]; });
  57669. /* harmony import */ var _refractionTexture__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./refractionTexture */ "./Materials/Textures/refractionTexture.ts");
  57670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _refractionTexture__WEBPACK_IMPORTED_MODULE_14__["RefractionTexture"]; });
  57671. /* harmony import */ var _renderTargetTexture__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  57672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _renderTargetTexture__WEBPACK_IMPORTED_MODULE_15__["RenderTargetTexture"]; });
  57673. /* harmony import */ var _texture__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./texture */ "./Materials/Textures/texture.ts");
  57674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _texture__WEBPACK_IMPORTED_MODULE_16__["Texture"]; });
  57675. /* harmony import */ var _videoTexture__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./videoTexture */ "./Materials/Textures/videoTexture.ts");
  57676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _videoTexture__WEBPACK_IMPORTED_MODULE_17__["VideoTexture"]; });
  57677. /***/ }),
  57678. /***/ "./Materials/Textures/internalTexture.ts":
  57679. /*!***********************************************!*\
  57680. !*** ./Materials/Textures/internalTexture.ts ***!
  57681. \***********************************************/
  57682. /*! exports provided: InternalTexture */
  57683. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57684. "use strict";
  57685. __webpack_require__.r(__webpack_exports__);
  57686. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return InternalTexture; });
  57687. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  57688. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  57689. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57690. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/devTools */ "./Misc/devTools.ts");
  57691. /**
  57692. * Class used to store data associated with WebGL texture data for the engine
  57693. * This class should not be used directly
  57694. */
  57695. var InternalTexture = /** @class */ (function () {
  57696. /**
  57697. * Creates a new InternalTexture
  57698. * @param engine defines the engine to use
  57699. * @param dataSource defines the type of data that will be used
  57700. * @param delayAllocation if the texture allocation should be delayed (default: false)
  57701. */
  57702. function InternalTexture(engine, dataSource, delayAllocation) {
  57703. if (delayAllocation === void 0) { delayAllocation = false; }
  57704. /**
  57705. * Observable called when the texture is loaded
  57706. */
  57707. this.onLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  57708. /**
  57709. * Gets or set the previous tracker in the list
  57710. */
  57711. this.previous = null;
  57712. /**
  57713. * Gets or set the next tracker in the list
  57714. */
  57715. this.next = null;
  57716. // Private
  57717. /** @hidden */
  57718. this._invertVScale = false;
  57719. /** @hidden */
  57720. this._initialSlot = -1;
  57721. /** @hidden */
  57722. this._designatedSlot = -1;
  57723. /** @hidden */
  57724. this._dataSource = InternalTexture.DATASOURCE_UNKNOWN;
  57725. /** @hidden */
  57726. this._comparisonFunction = 0;
  57727. /** @hidden */
  57728. this._sphericalPolynomial = null;
  57729. /** @hidden */
  57730. this._lodGenerationScale = 0;
  57731. /** @hidden */
  57732. this._lodGenerationOffset = 0;
  57733. /** @hidden */
  57734. this._isRGBD = false;
  57735. /** @hidden */
  57736. this._references = 1;
  57737. this._engine = engine;
  57738. this._dataSource = dataSource;
  57739. if (!delayAllocation) {
  57740. this._webGLTexture = engine._createTexture();
  57741. }
  57742. }
  57743. /**
  57744. * Gets the Engine the texture belongs to.
  57745. * @returns The babylon engine
  57746. */
  57747. InternalTexture.prototype.getEngine = function () {
  57748. return this._engine;
  57749. };
  57750. Object.defineProperty(InternalTexture.prototype, "dataSource", {
  57751. /**
  57752. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  57753. */
  57754. get: function () {
  57755. return this._dataSource;
  57756. },
  57757. enumerable: true,
  57758. configurable: true
  57759. });
  57760. /**
  57761. * Increments the number of references (ie. the number of Texture that point to it)
  57762. */
  57763. InternalTexture.prototype.incrementReferences = function () {
  57764. this._references++;
  57765. };
  57766. /**
  57767. * Change the size of the texture (not the size of the content)
  57768. * @param width defines the new width
  57769. * @param height defines the new height
  57770. * @param depth defines the new depth (1 by default)
  57771. */
  57772. InternalTexture.prototype.updateSize = function (width, height, depth) {
  57773. if (depth === void 0) { depth = 1; }
  57774. this.width = width;
  57775. this.height = height;
  57776. this.depth = depth;
  57777. this.baseWidth = width;
  57778. this.baseHeight = height;
  57779. this.baseDepth = depth;
  57780. this._size = width * height * depth;
  57781. };
  57782. /** @hidden */
  57783. InternalTexture.prototype._rebuild = function () {
  57784. var _this = this;
  57785. var proxy;
  57786. this.isReady = false;
  57787. this._cachedCoordinatesMode = null;
  57788. this._cachedWrapU = null;
  57789. this._cachedWrapV = null;
  57790. this._cachedAnisotropicFilteringLevel = null;
  57791. switch (this._dataSource) {
  57792. case InternalTexture.DATASOURCE_TEMP:
  57793. return;
  57794. case InternalTexture.DATASOURCE_URL:
  57795. proxy = this._engine.createTexture(this.url, !this.generateMipMaps, this.invertY, null, this.samplingMode, function () {
  57796. proxy._swapAndDie(_this);
  57797. _this.isReady = true;
  57798. }, null, this._buffer, undefined, this.format);
  57799. return;
  57800. case InternalTexture.DATASOURCE_RAW:
  57801. proxy = this._engine.createRawTexture(this._bufferView, this.baseWidth, this.baseHeight, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  57802. proxy._swapAndDie(this);
  57803. this.isReady = true;
  57804. return;
  57805. case InternalTexture.DATASOURCE_RAW3D:
  57806. proxy = this._engine.createRawTexture3D(this._bufferView, this.baseWidth, this.baseHeight, this.baseDepth, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  57807. proxy._swapAndDie(this);
  57808. this.isReady = true;
  57809. return;
  57810. case InternalTexture.DATASOURCE_DYNAMIC:
  57811. proxy = this._engine.createDynamicTexture(this.baseWidth, this.baseHeight, this.generateMipMaps, this.samplingMode);
  57812. proxy._swapAndDie(this);
  57813. this._engine.updateDynamicTexture(this, this._engine.getRenderingCanvas(), this.invertY, undefined, undefined, true);
  57814. // The engine will make sure to update content so no need to flag it as isReady = true
  57815. return;
  57816. case InternalTexture.DATASOURCE_RENDERTARGET:
  57817. var options = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_1__["RenderTargetCreationOptions"]();
  57818. options.generateDepthBuffer = this._generateDepthBuffer;
  57819. options.generateMipMaps = this.generateMipMaps;
  57820. options.generateStencilBuffer = this._generateStencilBuffer;
  57821. options.samplingMode = this.samplingMode;
  57822. options.type = this.type;
  57823. if (this.isCube) {
  57824. proxy = this._engine.createRenderTargetCubeTexture(this.width, options);
  57825. }
  57826. else {
  57827. var size = {
  57828. width: this.width,
  57829. height: this.height
  57830. };
  57831. proxy = this._engine.createRenderTargetTexture(size, options);
  57832. }
  57833. proxy._swapAndDie(this);
  57834. this.isReady = true;
  57835. return;
  57836. case InternalTexture.DATASOURCE_DEPTHTEXTURE:
  57837. var depthTextureOptions = {
  57838. bilinearFiltering: this.samplingMode !== _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE,
  57839. comparisonFunction: this._comparisonFunction,
  57840. generateStencil: this._generateStencilBuffer,
  57841. isCube: this.isCube
  57842. };
  57843. proxy = this._engine.createDepthStencilTexture({ width: this.width, height: this.height }, depthTextureOptions);
  57844. proxy._swapAndDie(this);
  57845. this.isReady = true;
  57846. return;
  57847. case InternalTexture.DATASOURCE_CUBE:
  57848. proxy = this._engine.createCubeTexture(this.url, null, this._files, !this.generateMipMaps, function () {
  57849. proxy._swapAndDie(_this);
  57850. _this.isReady = true;
  57851. }, null, this.format, this._extension);
  57852. return;
  57853. case InternalTexture.DATASOURCE_CUBERAW:
  57854. proxy = this._engine.createRawCubeTexture(this._bufferViewArray, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  57855. proxy._swapAndDie(this);
  57856. this.isReady = true;
  57857. return;
  57858. case InternalTexture.DATASOURCE_CUBERAW_RGBD:
  57859. proxy = this._engine.createRawCubeTexture(null, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  57860. InternalTexture._UpdateRGBDAsync(proxy, this._bufferViewArrayArray, this._sphericalPolynomial, this._lodGenerationScale, this._lodGenerationOffset).then(function () {
  57861. proxy._swapAndDie(_this);
  57862. _this.isReady = true;
  57863. });
  57864. return;
  57865. case InternalTexture.DATASOURCE_CUBEPREFILTERED:
  57866. proxy = this._engine.createPrefilteredCubeTexture(this.url, null, this._lodGenerationScale, this._lodGenerationOffset, function (proxy) {
  57867. if (proxy) {
  57868. proxy._swapAndDie(_this);
  57869. }
  57870. _this.isReady = true;
  57871. }, null, this.format, this._extension);
  57872. proxy._sphericalPolynomial = this._sphericalPolynomial;
  57873. return;
  57874. }
  57875. };
  57876. /** @hidden */
  57877. InternalTexture.prototype._swapAndDie = function (target) {
  57878. target._webGLTexture = this._webGLTexture;
  57879. if (this._framebuffer) {
  57880. target._framebuffer = this._framebuffer;
  57881. }
  57882. if (this._depthStencilBuffer) {
  57883. target._depthStencilBuffer = this._depthStencilBuffer;
  57884. }
  57885. if (this._lodTextureHigh) {
  57886. if (target._lodTextureHigh) {
  57887. target._lodTextureHigh.dispose();
  57888. }
  57889. target._lodTextureHigh = this._lodTextureHigh;
  57890. }
  57891. if (this._lodTextureMid) {
  57892. if (target._lodTextureMid) {
  57893. target._lodTextureMid.dispose();
  57894. }
  57895. target._lodTextureMid = this._lodTextureMid;
  57896. }
  57897. if (this._lodTextureLow) {
  57898. if (target._lodTextureLow) {
  57899. target._lodTextureLow.dispose();
  57900. }
  57901. target._lodTextureLow = this._lodTextureLow;
  57902. }
  57903. var cache = this._engine.getLoadedTexturesCache();
  57904. var index = cache.indexOf(this);
  57905. if (index !== -1) {
  57906. cache.splice(index, 1);
  57907. }
  57908. };
  57909. /**
  57910. * Dispose the current allocated resources
  57911. */
  57912. InternalTexture.prototype.dispose = function () {
  57913. if (!this._webGLTexture) {
  57914. return;
  57915. }
  57916. this._references--;
  57917. if (this._references === 0) {
  57918. this._engine._releaseTexture(this);
  57919. this._webGLTexture = null;
  57920. this.previous = null;
  57921. this.next = null;
  57922. }
  57923. };
  57924. /** hidden */
  57925. InternalTexture._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  57926. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__["_DevTools"].WarnImport("environmentTextureTools");
  57927. };
  57928. /**
  57929. * The source of the texture data is unknown
  57930. */
  57931. InternalTexture.DATASOURCE_UNKNOWN = 0;
  57932. /**
  57933. * Texture data comes from an URL
  57934. */
  57935. InternalTexture.DATASOURCE_URL = 1;
  57936. /**
  57937. * Texture data is only used for temporary storage
  57938. */
  57939. InternalTexture.DATASOURCE_TEMP = 2;
  57940. /**
  57941. * Texture data comes from raw data (ArrayBuffer)
  57942. */
  57943. InternalTexture.DATASOURCE_RAW = 3;
  57944. /**
  57945. * Texture content is dynamic (video or dynamic texture)
  57946. */
  57947. InternalTexture.DATASOURCE_DYNAMIC = 4;
  57948. /**
  57949. * Texture content is generated by rendering to it
  57950. */
  57951. InternalTexture.DATASOURCE_RENDERTARGET = 5;
  57952. /**
  57953. * Texture content is part of a multi render target process
  57954. */
  57955. InternalTexture.DATASOURCE_MULTIRENDERTARGET = 6;
  57956. /**
  57957. * Texture data comes from a cube data file
  57958. */
  57959. InternalTexture.DATASOURCE_CUBE = 7;
  57960. /**
  57961. * Texture data comes from a raw cube data
  57962. */
  57963. InternalTexture.DATASOURCE_CUBERAW = 8;
  57964. /**
  57965. * Texture data come from a prefiltered cube data file
  57966. */
  57967. InternalTexture.DATASOURCE_CUBEPREFILTERED = 9;
  57968. /**
  57969. * Texture content is raw 3D data
  57970. */
  57971. InternalTexture.DATASOURCE_RAW3D = 10;
  57972. /**
  57973. * Texture content is a depth texture
  57974. */
  57975. InternalTexture.DATASOURCE_DEPTHTEXTURE = 11;
  57976. /**
  57977. * Texture data comes from a raw cube data encoded with RGBD
  57978. */
  57979. InternalTexture.DATASOURCE_CUBERAW_RGBD = 12;
  57980. return InternalTexture;
  57981. }());
  57982. /***/ }),
  57983. /***/ "./Materials/Textures/internalTextureTracker.ts":
  57984. /*!******************************************************!*\
  57985. !*** ./Materials/Textures/internalTextureTracker.ts ***!
  57986. \******************************************************/
  57987. /*! exports provided: DummyInternalTextureTracker */
  57988. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57989. "use strict";
  57990. __webpack_require__.r(__webpack_exports__);
  57991. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return DummyInternalTextureTracker; });
  57992. /**
  57993. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  57994. */
  57995. var DummyInternalTextureTracker = /** @class */ (function () {
  57996. function DummyInternalTextureTracker() {
  57997. /**
  57998. * Gets or set the previous tracker in the list
  57999. */
  58000. this.previous = null;
  58001. /**
  58002. * Gets or set the next tracker in the list
  58003. */
  58004. this.next = null;
  58005. }
  58006. return DummyInternalTextureTracker;
  58007. }());
  58008. /***/ }),
  58009. /***/ "./Materials/Textures/mirrorTexture.ts":
  58010. /*!*********************************************!*\
  58011. !*** ./Materials/Textures/mirrorTexture.ts ***!
  58012. \*********************************************/
  58013. /*! exports provided: MirrorTexture */
  58014. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58015. "use strict";
  58016. __webpack_require__.r(__webpack_exports__);
  58017. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return MirrorTexture; });
  58018. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58019. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  58020. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  58021. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  58022. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  58023. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  58024. /**
  58025. * Mirror texture can be used to simulate the view from a mirror in a scene.
  58026. * It will dynamically be rendered every frame to adapt to the camera point of view.
  58027. * You can then easily use it as a reflectionTexture on a flat surface.
  58028. * In case the surface is not a plane, please consider relying on reflection probes.
  58029. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  58030. */
  58031. var MirrorTexture = /** @class */ (function (_super) {
  58032. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MirrorTexture, _super);
  58033. /**
  58034. * Instantiates a Mirror Texture.
  58035. * Mirror texture can be used to simulate the view from a mirror in a scene.
  58036. * It will dynamically be rendered every frame to adapt to the camera point of view.
  58037. * You can then easily use it as a reflectionTexture on a flat surface.
  58038. * In case the surface is not a plane, please consider relying on reflection probes.
  58039. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  58040. * @param name
  58041. * @param size
  58042. * @param scene
  58043. * @param generateMipMaps
  58044. * @param type
  58045. * @param samplingMode
  58046. * @param generateDepthBuffer
  58047. */
  58048. function MirrorTexture(name, size, scene, generateMipMaps, type, samplingMode, generateDepthBuffer) {
  58049. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  58050. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE; }
  58051. if (generateDepthBuffer === void 0) { generateDepthBuffer = true; }
  58052. var _this = _super.call(this, name, size, scene, generateMipMaps, true, type, false, samplingMode, generateDepthBuffer) || this;
  58053. _this.scene = scene;
  58054. /**
  58055. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  58056. * 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.
  58057. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  58058. */
  58059. _this.mirrorPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Plane"](0, 1, 0, 1);
  58060. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  58061. _this._mirrorMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  58062. _this._adaptiveBlurKernel = 0;
  58063. _this._blurKernelX = 0;
  58064. _this._blurKernelY = 0;
  58065. _this._blurRatio = 1.0;
  58066. _this.ignoreCameraViewport = true;
  58067. _this._updateGammaSpace();
  58068. _this._imageProcessingConfigChangeObserver = scene.imageProcessingConfiguration.onUpdateParameters.add(function () {
  58069. _this._updateGammaSpace;
  58070. });
  58071. _this.onBeforeRenderObservable.add(function () {
  58072. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ReflectionToRef(_this.mirrorPlane, _this._mirrorMatrix);
  58073. _this._savedViewMatrix = scene.getViewMatrix();
  58074. _this._mirrorMatrix.multiplyToRef(_this._savedViewMatrix, _this._transformMatrix);
  58075. scene.setTransformMatrix(_this._transformMatrix, scene.getProjectionMatrix());
  58076. scene.clipPlane = _this.mirrorPlane;
  58077. scene.getEngine().cullBackFaces = false;
  58078. scene._mirroredCameraPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(scene.activeCamera.globalPosition, _this._mirrorMatrix);
  58079. });
  58080. _this.onAfterRenderObservable.add(function () {
  58081. scene.setTransformMatrix(_this._savedViewMatrix, scene.getProjectionMatrix());
  58082. scene.getEngine().cullBackFaces = true;
  58083. scene._mirroredCameraPosition = null;
  58084. delete scene.clipPlane;
  58085. });
  58086. return _this;
  58087. }
  58088. Object.defineProperty(MirrorTexture.prototype, "blurRatio", {
  58089. get: function () {
  58090. return this._blurRatio;
  58091. },
  58092. /**
  58093. * Define the blur ratio used to blur the reflection if needed.
  58094. */
  58095. set: function (value) {
  58096. if (this._blurRatio === value) {
  58097. return;
  58098. }
  58099. this._blurRatio = value;
  58100. this._preparePostProcesses();
  58101. },
  58102. enumerable: true,
  58103. configurable: true
  58104. });
  58105. Object.defineProperty(MirrorTexture.prototype, "adaptiveBlurKernel", {
  58106. /**
  58107. * Define the adaptive blur kernel used to blur the reflection if needed.
  58108. * This will autocompute the closest best match for the `blurKernel`
  58109. */
  58110. set: function (value) {
  58111. this._adaptiveBlurKernel = value;
  58112. this._autoComputeBlurKernel();
  58113. },
  58114. enumerable: true,
  58115. configurable: true
  58116. });
  58117. Object.defineProperty(MirrorTexture.prototype, "blurKernel", {
  58118. /**
  58119. * Define the blur kernel used to blur the reflection if needed.
  58120. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  58121. */
  58122. set: function (value) {
  58123. this.blurKernelX = value;
  58124. this.blurKernelY = value;
  58125. },
  58126. enumerable: true,
  58127. configurable: true
  58128. });
  58129. Object.defineProperty(MirrorTexture.prototype, "blurKernelX", {
  58130. get: function () {
  58131. return this._blurKernelX;
  58132. },
  58133. /**
  58134. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  58135. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  58136. */
  58137. set: function (value) {
  58138. if (this._blurKernelX === value) {
  58139. return;
  58140. }
  58141. this._blurKernelX = value;
  58142. this._preparePostProcesses();
  58143. },
  58144. enumerable: true,
  58145. configurable: true
  58146. });
  58147. Object.defineProperty(MirrorTexture.prototype, "blurKernelY", {
  58148. get: function () {
  58149. return this._blurKernelY;
  58150. },
  58151. /**
  58152. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  58153. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  58154. */
  58155. set: function (value) {
  58156. if (this._blurKernelY === value) {
  58157. return;
  58158. }
  58159. this._blurKernelY = value;
  58160. this._preparePostProcesses();
  58161. },
  58162. enumerable: true,
  58163. configurable: true
  58164. });
  58165. MirrorTexture.prototype._autoComputeBlurKernel = function () {
  58166. var engine = this.getScene().getEngine();
  58167. var dw = this.getRenderWidth() / engine.getRenderWidth();
  58168. var dh = this.getRenderHeight() / engine.getRenderHeight();
  58169. this.blurKernelX = this._adaptiveBlurKernel * dw;
  58170. this.blurKernelY = this._adaptiveBlurKernel * dh;
  58171. };
  58172. MirrorTexture.prototype._onRatioRescale = function () {
  58173. if (this._sizeRatio) {
  58174. this.resize(this._initialSizeParameter);
  58175. if (!this._adaptiveBlurKernel) {
  58176. this._preparePostProcesses();
  58177. }
  58178. }
  58179. if (this._adaptiveBlurKernel) {
  58180. this._autoComputeBlurKernel();
  58181. }
  58182. };
  58183. MirrorTexture.prototype._updateGammaSpace = function () {
  58184. this.gammaSpace = !this.scene.imageProcessingConfiguration.isEnabled || !this.scene.imageProcessingConfiguration.applyByPostProcess;
  58185. };
  58186. MirrorTexture.prototype._preparePostProcesses = function () {
  58187. this.clearPostProcesses(true);
  58188. if (this._blurKernelX && this._blurKernelY) {
  58189. var engine = this.getScene().getEngine();
  58190. var textureType = engine.getCaps().textureFloatRender ? _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_FLOAT : _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_HALF_FLOAT;
  58191. 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);
  58192. this._blurX.autoClear = false;
  58193. if (this._blurRatio === 1 && this.samples < 2 && this._texture) {
  58194. this._blurX.inputTexture = this._texture;
  58195. }
  58196. else {
  58197. this._blurX.alwaysForcePOT = true;
  58198. }
  58199. 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);
  58200. this._blurY.autoClear = false;
  58201. this._blurY.alwaysForcePOT = this._blurRatio !== 1;
  58202. this.addPostProcess(this._blurX);
  58203. this.addPostProcess(this._blurY);
  58204. }
  58205. else {
  58206. if (this._blurY) {
  58207. this.removePostProcess(this._blurY);
  58208. this._blurY.dispose();
  58209. this._blurY = null;
  58210. }
  58211. if (this._blurX) {
  58212. this.removePostProcess(this._blurX);
  58213. this._blurX.dispose();
  58214. this._blurX = null;
  58215. }
  58216. }
  58217. };
  58218. /**
  58219. * Clone the mirror texture.
  58220. * @returns the cloned texture
  58221. */
  58222. MirrorTexture.prototype.clone = function () {
  58223. var scene = this.getScene();
  58224. if (!scene) {
  58225. return this;
  58226. }
  58227. var textureSize = this.getSize();
  58228. var newTexture = new MirrorTexture(this.name, textureSize.width, scene, this._renderTargetOptions.generateMipMaps, this._renderTargetOptions.type, this._renderTargetOptions.samplingMode, this._renderTargetOptions.generateDepthBuffer);
  58229. // Base texture
  58230. newTexture.hasAlpha = this.hasAlpha;
  58231. newTexture.level = this.level;
  58232. // Mirror Texture
  58233. newTexture.mirrorPlane = this.mirrorPlane.clone();
  58234. if (this.renderList) {
  58235. newTexture.renderList = this.renderList.slice(0);
  58236. }
  58237. return newTexture;
  58238. };
  58239. /**
  58240. * Serialize the texture to a JSON representation you could use in Parse later on
  58241. * @returns the serialized JSON representation
  58242. */
  58243. MirrorTexture.prototype.serialize = function () {
  58244. if (!this.name) {
  58245. return null;
  58246. }
  58247. var serializationObject = _super.prototype.serialize.call(this);
  58248. serializationObject.mirrorPlane = this.mirrorPlane.asArray();
  58249. return serializationObject;
  58250. };
  58251. /**
  58252. * Dispose the texture and release its associated resources.
  58253. */
  58254. MirrorTexture.prototype.dispose = function () {
  58255. _super.prototype.dispose.call(this);
  58256. this.scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigChangeObserver);
  58257. };
  58258. return MirrorTexture;
  58259. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__["RenderTargetTexture"]));
  58260. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]._CreateMirror = function (name, renderTargetSize, scene, generateMipMaps) {
  58261. return new MirrorTexture(name, renderTargetSize, scene, generateMipMaps);
  58262. };
  58263. /***/ }),
  58264. /***/ "./Materials/Textures/multiRenderTarget.ts":
  58265. /*!*************************************************!*\
  58266. !*** ./Materials/Textures/multiRenderTarget.ts ***!
  58267. \*************************************************/
  58268. /*! exports provided: MultiRenderTarget */
  58269. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58270. "use strict";
  58271. __webpack_require__.r(__webpack_exports__);
  58272. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return MultiRenderTarget; });
  58273. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58274. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  58275. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  58276. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  58277. /**
  58278. * A multi render target, like a render target provides the ability to render to a texture.
  58279. * Unlike the render target, it can render to several draw buffers in one draw.
  58280. * This is specially interesting in deferred rendering or for any effects requiring more than
  58281. * just one color from a single pass.
  58282. */
  58283. var MultiRenderTarget = /** @class */ (function (_super) {
  58284. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiRenderTarget, _super);
  58285. /**
  58286. * Instantiate a new multi render target texture.
  58287. * A multi render target, like a render target provides the ability to render to a texture.
  58288. * Unlike the render target, it can render to several draw buffers in one draw.
  58289. * This is specially interesting in deferred rendering or for any effects requiring more than
  58290. * just one color from a single pass.
  58291. * @param name Define the name of the texture
  58292. * @param size Define the size of the buffers to render to
  58293. * @param count Define the number of target we are rendering into
  58294. * @param scene Define the scene the texture belongs to
  58295. * @param options Define the options used to create the multi render target
  58296. */
  58297. function MultiRenderTarget(name, size, count, scene, options) {
  58298. var _this = this;
  58299. var generateMipMaps = options && options.generateMipMaps ? options.generateMipMaps : false;
  58300. var generateDepthTexture = options && options.generateDepthTexture ? options.generateDepthTexture : false;
  58301. var doNotChangeAspectRatio = !options || options.doNotChangeAspectRatio === undefined ? true : options.doNotChangeAspectRatio;
  58302. _this = _super.call(this, name, size, scene, generateMipMaps, doNotChangeAspectRatio) || this;
  58303. _this._engine = scene.getEngine();
  58304. if (!_this.isSupported) {
  58305. _this.dispose();
  58306. return;
  58307. }
  58308. var types = [];
  58309. var samplingModes = [];
  58310. for (var i = 0; i < count; i++) {
  58311. if (options && options.types && options.types[i] !== undefined) {
  58312. types.push(options.types[i]);
  58313. }
  58314. else {
  58315. types.push(options && options.defaultType ? options.defaultType : _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  58316. }
  58317. if (options && options.samplingModes && options.samplingModes[i] !== undefined) {
  58318. samplingModes.push(options.samplingModes[i]);
  58319. }
  58320. else {
  58321. samplingModes.push(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE);
  58322. }
  58323. }
  58324. var generateDepthBuffer = !options || options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  58325. var generateStencilBuffer = !options || options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;
  58326. _this._size = size;
  58327. _this._multiRenderTargetOptions = {
  58328. samplingModes: samplingModes,
  58329. generateMipMaps: generateMipMaps,
  58330. generateDepthBuffer: generateDepthBuffer,
  58331. generateStencilBuffer: generateStencilBuffer,
  58332. generateDepthTexture: generateDepthTexture,
  58333. types: types,
  58334. textureCount: count
  58335. };
  58336. _this._createInternalTextures();
  58337. _this._createTextures();
  58338. return _this;
  58339. }
  58340. Object.defineProperty(MultiRenderTarget.prototype, "isSupported", {
  58341. /**
  58342. * Get if draw buffers are currently supported by the used hardware and browser.
  58343. */
  58344. get: function () {
  58345. return this._engine.webGLVersion > 1 || this._engine.getCaps().drawBuffersExtension;
  58346. },
  58347. enumerable: true,
  58348. configurable: true
  58349. });
  58350. Object.defineProperty(MultiRenderTarget.prototype, "textures", {
  58351. /**
  58352. * Get the list of textures generated by the multi render target.
  58353. */
  58354. get: function () {
  58355. return this._textures;
  58356. },
  58357. enumerable: true,
  58358. configurable: true
  58359. });
  58360. Object.defineProperty(MultiRenderTarget.prototype, "depthTexture", {
  58361. /**
  58362. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  58363. */
  58364. get: function () {
  58365. return this._textures[this._textures.length - 1];
  58366. },
  58367. enumerable: true,
  58368. configurable: true
  58369. });
  58370. Object.defineProperty(MultiRenderTarget.prototype, "wrapU", {
  58371. /**
  58372. * Set the wrapping mode on U of all the textures we are rendering to.
  58373. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  58374. */
  58375. set: function (wrap) {
  58376. if (this._textures) {
  58377. for (var i = 0; i < this._textures.length; i++) {
  58378. this._textures[i].wrapU = wrap;
  58379. }
  58380. }
  58381. },
  58382. enumerable: true,
  58383. configurable: true
  58384. });
  58385. Object.defineProperty(MultiRenderTarget.prototype, "wrapV", {
  58386. /**
  58387. * Set the wrapping mode on V of all the textures we are rendering to.
  58388. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  58389. */
  58390. set: function (wrap) {
  58391. if (this._textures) {
  58392. for (var i = 0; i < this._textures.length; i++) {
  58393. this._textures[i].wrapV = wrap;
  58394. }
  58395. }
  58396. },
  58397. enumerable: true,
  58398. configurable: true
  58399. });
  58400. /** @hidden */
  58401. MultiRenderTarget.prototype._rebuild = function () {
  58402. this.releaseInternalTextures();
  58403. this._createInternalTextures();
  58404. for (var i = 0; i < this._internalTextures.length; i++) {
  58405. var texture = this._textures[i];
  58406. texture._texture = this._internalTextures[i];
  58407. }
  58408. // Keeps references to frame buffer and stencil/depth buffer
  58409. this._texture = this._internalTextures[0];
  58410. };
  58411. MultiRenderTarget.prototype._createInternalTextures = function () {
  58412. this._internalTextures = this._engine.createMultipleRenderTarget(this._size, this._multiRenderTargetOptions);
  58413. };
  58414. MultiRenderTarget.prototype._createTextures = function () {
  58415. this._textures = [];
  58416. for (var i = 0; i < this._internalTextures.length; i++) {
  58417. var texture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](null, this.getScene());
  58418. texture._texture = this._internalTextures[i];
  58419. this._textures.push(texture);
  58420. }
  58421. // Keeps references to frame buffer and stencil/depth buffer
  58422. this._texture = this._internalTextures[0];
  58423. };
  58424. Object.defineProperty(MultiRenderTarget.prototype, "samples", {
  58425. /**
  58426. * Define the number of samples used if MSAA is enabled.
  58427. */
  58428. get: function () {
  58429. return this._samples;
  58430. },
  58431. set: function (value) {
  58432. if (this._samples === value) {
  58433. return;
  58434. }
  58435. this._samples = this._engine.updateMultipleRenderTargetTextureSampleCount(this._internalTextures, value);
  58436. },
  58437. enumerable: true,
  58438. configurable: true
  58439. });
  58440. /**
  58441. * Resize all the textures in the multi render target.
  58442. * Be carrefull as it will recreate all the data in the new texture.
  58443. * @param size Define the new size
  58444. */
  58445. MultiRenderTarget.prototype.resize = function (size) {
  58446. this.releaseInternalTextures();
  58447. this._internalTextures = this._engine.createMultipleRenderTarget(size, this._multiRenderTargetOptions);
  58448. this._createInternalTextures();
  58449. };
  58450. MultiRenderTarget.prototype.unbindFrameBuffer = function (engine, faceIndex) {
  58451. var _this = this;
  58452. engine.unBindMultiColorAttachmentFramebuffer(this._internalTextures, this.isCube, function () {
  58453. _this.onAfterRenderObservable.notifyObservers(faceIndex);
  58454. });
  58455. };
  58456. /**
  58457. * Dispose the render targets and their associated resources
  58458. */
  58459. MultiRenderTarget.prototype.dispose = function () {
  58460. this.releaseInternalTextures();
  58461. _super.prototype.dispose.call(this);
  58462. };
  58463. /**
  58464. * Release all the underlying texture used as draw buffers.
  58465. */
  58466. MultiRenderTarget.prototype.releaseInternalTextures = function () {
  58467. if (!this._internalTextures) {
  58468. return;
  58469. }
  58470. for (var i = this._internalTextures.length - 1; i >= 0; i--) {
  58471. if (this._internalTextures[i] !== undefined) {
  58472. this._internalTextures[i].dispose();
  58473. this._internalTextures.splice(i, 1);
  58474. }
  58475. }
  58476. };
  58477. return MultiRenderTarget;
  58478. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__["RenderTargetTexture"]));
  58479. /***/ }),
  58480. /***/ "./Materials/Textures/rawCubeTexture.ts":
  58481. /*!**********************************************!*\
  58482. !*** ./Materials/Textures/rawCubeTexture.ts ***!
  58483. \**********************************************/
  58484. /*! exports provided: RawCubeTexture */
  58485. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58486. "use strict";
  58487. __webpack_require__.r(__webpack_exports__);
  58488. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return RawCubeTexture; });
  58489. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58490. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  58491. /* harmony import */ var _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  58492. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  58493. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  58494. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  58495. /**
  58496. * Raw cube texture where the raw buffers are passed in
  58497. */
  58498. var RawCubeTexture = /** @class */ (function (_super) {
  58499. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawCubeTexture, _super);
  58500. /**
  58501. * Creates a cube texture where the raw buffers are passed in.
  58502. * @param scene defines the scene the texture is attached to
  58503. * @param data defines the array of data to use to create each face
  58504. * @param size defines the size of the textures
  58505. * @param format defines the format of the data
  58506. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  58507. * @param generateMipMaps defines if the engine should generate the mip levels
  58508. * @param invertY defines if data must be stored with Y axis inverted
  58509. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  58510. * @param compression defines the compression used (null by default)
  58511. */
  58512. function RawCubeTexture(scene, data, size, format, type, generateMipMaps, invertY, samplingMode, compression) {
  58513. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTUREFORMAT_RGBA; }
  58514. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  58515. if (generateMipMaps === void 0) { generateMipMaps = false; }
  58516. if (invertY === void 0) { invertY = false; }
  58517. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  58518. if (compression === void 0) { compression = null; }
  58519. var _this = _super.call(this, "", scene) || this;
  58520. _this._texture = scene.getEngine().createRawCubeTexture(data, size, format, type, generateMipMaps, invertY, samplingMode, compression);
  58521. return _this;
  58522. }
  58523. /**
  58524. * Updates the raw cube texture.
  58525. * @param data defines the data to store
  58526. * @param format defines the data format
  58527. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  58528. * @param invertY defines if data must be stored with Y axis inverted
  58529. * @param compression defines the compression used (null by default)
  58530. * @param level defines which level of the texture to update
  58531. */
  58532. RawCubeTexture.prototype.update = function (data, format, type, invertY, compression) {
  58533. if (compression === void 0) { compression = null; }
  58534. this._texture.getEngine().updateRawCubeTexture(this._texture, data, format, type, invertY, compression);
  58535. };
  58536. /**
  58537. * Updates a raw cube texture with RGBD encoded data.
  58538. * @param data defines the array of data [mipmap][face] to use to create each face
  58539. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  58540. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  58541. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  58542. * @returns a promsie that resolves when the operation is complete
  58543. */
  58544. RawCubeTexture.prototype.updateRGBDAsync = function (data, sphericalPolynomial, lodScale, lodOffset) {
  58545. if (sphericalPolynomial === void 0) { sphericalPolynomial = null; }
  58546. if (lodScale === void 0) { lodScale = 0.8; }
  58547. if (lodOffset === void 0) { lodOffset = 0; }
  58548. return RawCubeTexture._UpdateRGBDAsync(this._texture, data, sphericalPolynomial, lodScale, lodOffset);
  58549. };
  58550. /**
  58551. * Clones the raw cube texture.
  58552. * @return a new cube texture
  58553. */
  58554. RawCubeTexture.prototype.clone = function () {
  58555. var _this = this;
  58556. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  58557. var scene = _this.getScene();
  58558. var internalTexture = _this._texture;
  58559. var texture = new RawCubeTexture(scene, internalTexture._bufferViewArray, internalTexture.width, internalTexture.format, internalTexture.type, internalTexture.generateMipMaps, internalTexture.invertY, internalTexture.samplingMode, internalTexture._compression);
  58560. if (internalTexture.dataSource === _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_CUBERAW_RGBD) {
  58561. texture.updateRGBDAsync(internalTexture._bufferViewArrayArray, internalTexture._sphericalPolynomial, internalTexture._lodGenerationScale, internalTexture._lodGenerationOffset);
  58562. }
  58563. return texture;
  58564. }, this);
  58565. };
  58566. /** @hidden */
  58567. RawCubeTexture._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  58568. internalTexture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_CUBERAW_RGBD;
  58569. internalTexture._bufferViewArrayArray = data;
  58570. internalTexture._lodGenerationScale = lodScale;
  58571. internalTexture._lodGenerationOffset = lodOffset;
  58572. internalTexture._sphericalPolynomial = sphericalPolynomial;
  58573. return _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_2__["EnvironmentTextureTools"].UploadLevelsAsync(internalTexture, data).then(function () {
  58574. internalTexture.isReady = true;
  58575. });
  58576. };
  58577. return RawCubeTexture;
  58578. }(_Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_4__["CubeTexture"]));
  58579. /***/ }),
  58580. /***/ "./Materials/Textures/rawTexture.ts":
  58581. /*!******************************************!*\
  58582. !*** ./Materials/Textures/rawTexture.ts ***!
  58583. \******************************************/
  58584. /*! exports provided: RawTexture */
  58585. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58586. "use strict";
  58587. __webpack_require__.r(__webpack_exports__);
  58588. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return RawTexture; });
  58589. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58590. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  58591. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  58592. /**
  58593. * Raw texture can help creating a texture directly from an array of data.
  58594. * This can be super useful if you either get the data from an uncompressed source or
  58595. * if you wish to create your texture pixel by pixel.
  58596. */
  58597. var RawTexture = /** @class */ (function (_super) {
  58598. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawTexture, _super);
  58599. /**
  58600. * Instantiates a new RawTexture.
  58601. * Raw texture can help creating a texture directly from an array of data.
  58602. * This can be super useful if you either get the data from an uncompressed source or
  58603. * if you wish to create your texture pixel by pixel.
  58604. * @param data define the array of data to use to create the texture
  58605. * @param width define the width of the texture
  58606. * @param height define the height of the texture
  58607. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  58608. * @param scene define the scene the texture belongs to
  58609. * @param generateMipMaps define whether mip maps should be generated or not
  58610. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  58611. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  58612. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  58613. */
  58614. function RawTexture(data, width, height,
  58615. /**
  58616. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  58617. */
  58618. format, scene, generateMipMaps, invertY, samplingMode, type) {
  58619. if (generateMipMaps === void 0) { generateMipMaps = true; }
  58620. if (invertY === void 0) { invertY = false; }
  58621. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  58622. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  58623. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  58624. _this.format = format;
  58625. _this._engine = scene.getEngine();
  58626. _this._texture = scene.getEngine().createRawTexture(data, width, height, format, generateMipMaps, invertY, samplingMode, null, type);
  58627. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].CLAMP_ADDRESSMODE;
  58628. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].CLAMP_ADDRESSMODE;
  58629. return _this;
  58630. }
  58631. /**
  58632. * Updates the texture underlying data.
  58633. * @param data Define the new data of the texture
  58634. */
  58635. RawTexture.prototype.update = function (data) {
  58636. this._engine.updateRawTexture(this._texture, data, this._texture.format, this._texture.invertY, undefined, this._texture.type);
  58637. };
  58638. /**
  58639. * Creates a luminance texture from some data.
  58640. * @param data Define the texture data
  58641. * @param width Define the width of the texture
  58642. * @param height Define the height of the texture
  58643. * @param scene Define the scene the texture belongs to
  58644. * @param generateMipMaps Define whether or not to create mip maps for the texture
  58645. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  58646. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  58647. * @returns the luminance texture
  58648. */
  58649. RawTexture.CreateLuminanceTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  58650. if (generateMipMaps === void 0) { generateMipMaps = true; }
  58651. if (invertY === void 0) { invertY = false; }
  58652. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  58653. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE, scene, generateMipMaps, invertY, samplingMode);
  58654. };
  58655. /**
  58656. * Creates a luminance alpha texture from some data.
  58657. * @param data Define the texture data
  58658. * @param width Define the width of the texture
  58659. * @param height Define the height of the texture
  58660. * @param scene Define the scene the texture belongs to
  58661. * @param generateMipMaps Define whether or not to create mip maps for the texture
  58662. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  58663. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  58664. * @returns the luminance alpha texture
  58665. */
  58666. RawTexture.CreateLuminanceAlphaTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  58667. if (generateMipMaps === void 0) { generateMipMaps = true; }
  58668. if (invertY === void 0) { invertY = false; }
  58669. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  58670. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE_ALPHA, scene, generateMipMaps, invertY, samplingMode);
  58671. };
  58672. /**
  58673. * Creates an alpha texture from some data.
  58674. * @param data Define the texture data
  58675. * @param width Define the width of the texture
  58676. * @param height Define the height of the texture
  58677. * @param scene Define the scene the texture belongs to
  58678. * @param generateMipMaps Define whether or not to create mip maps for the texture
  58679. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  58680. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  58681. * @returns the alpha texture
  58682. */
  58683. RawTexture.CreateAlphaTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  58684. if (generateMipMaps === void 0) { generateMipMaps = true; }
  58685. if (invertY === void 0) { invertY = false; }
  58686. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  58687. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_ALPHA, scene, generateMipMaps, invertY, samplingMode);
  58688. };
  58689. /**
  58690. * Creates a RGB texture from some data.
  58691. * @param data Define the texture data
  58692. * @param width Define the width of the texture
  58693. * @param height Define the height of the texture
  58694. * @param scene Define the scene the texture belongs to
  58695. * @param generateMipMaps Define whether or not to create mip maps for the texture
  58696. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  58697. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  58698. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  58699. * @returns the RGB alpha texture
  58700. */
  58701. RawTexture.CreateRGBTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  58702. if (generateMipMaps === void 0) { generateMipMaps = true; }
  58703. if (invertY === void 0) { invertY = false; }
  58704. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  58705. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  58706. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGB, scene, generateMipMaps, invertY, samplingMode, type);
  58707. };
  58708. /**
  58709. * Creates a RGBA texture from some data.
  58710. * @param data Define the texture data
  58711. * @param width Define the width of the texture
  58712. * @param height Define the height of the texture
  58713. * @param scene Define the scene the texture belongs to
  58714. * @param generateMipMaps Define whether or not to create mip maps for the texture
  58715. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  58716. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  58717. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  58718. * @returns the RGBA texture
  58719. */
  58720. RawTexture.CreateRGBATexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  58721. if (generateMipMaps === void 0) { generateMipMaps = true; }
  58722. if (invertY === void 0) { invertY = false; }
  58723. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  58724. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  58725. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA, scene, generateMipMaps, invertY, samplingMode, type);
  58726. };
  58727. /**
  58728. * Creates a R texture from some data.
  58729. * @param data Define the texture data
  58730. * @param width Define the width of the texture
  58731. * @param height Define the height of the texture
  58732. * @param scene Define the scene the texture belongs to
  58733. * @param generateMipMaps Define whether or not to create mip maps for the texture
  58734. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  58735. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  58736. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  58737. * @returns the R texture
  58738. */
  58739. RawTexture.CreateRTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  58740. if (generateMipMaps === void 0) { generateMipMaps = true; }
  58741. if (invertY === void 0) { invertY = false; }
  58742. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE; }
  58743. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT; }
  58744. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_R, scene, generateMipMaps, invertY, samplingMode, type);
  58745. };
  58746. return RawTexture;
  58747. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"]));
  58748. /***/ }),
  58749. /***/ "./Materials/Textures/rawTexture3D.ts":
  58750. /*!********************************************!*\
  58751. !*** ./Materials/Textures/rawTexture3D.ts ***!
  58752. \********************************************/
  58753. /*! exports provided: RawTexture3D */
  58754. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58755. "use strict";
  58756. __webpack_require__.r(__webpack_exports__);
  58757. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return RawTexture3D; });
  58758. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58759. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  58760. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  58761. /**
  58762. * Class used to store 3D textures containing user data
  58763. */
  58764. var RawTexture3D = /** @class */ (function (_super) {
  58765. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawTexture3D, _super);
  58766. /**
  58767. * Create a new RawTexture3D
  58768. * @param data defines the data of the texture
  58769. * @param width defines the width of the texture
  58770. * @param height defines the height of the texture
  58771. * @param depth defines the depth of the texture
  58772. * @param format defines the texture format to use
  58773. * @param scene defines the hosting scene
  58774. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58775. * @param invertY defines if texture must be stored with Y axis inverted
  58776. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58777. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58778. */
  58779. function RawTexture3D(data, width, height, depth,
  58780. /** Gets or sets the texture format to use */
  58781. format, scene, generateMipMaps, invertY, samplingMode, textureType) {
  58782. if (generateMipMaps === void 0) { generateMipMaps = true; }
  58783. if (invertY === void 0) { invertY = false; }
  58784. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE; }
  58785. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  58786. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  58787. _this.format = format;
  58788. _this._engine = scene.getEngine();
  58789. _this._texture = scene.getEngine().createRawTexture3D(data, width, height, depth, format, generateMipMaps, invertY, samplingMode, undefined, textureType);
  58790. _this.is3D = true;
  58791. return _this;
  58792. }
  58793. /**
  58794. * Update the texture with new data
  58795. * @param data defines the data to store in the texture
  58796. */
  58797. RawTexture3D.prototype.update = function (data) {
  58798. if (!this._texture) {
  58799. return;
  58800. }
  58801. this._engine.updateRawTexture3D(this._texture, data, this._texture.format, this._texture.invertY, undefined, this._texture.type);
  58802. };
  58803. return RawTexture3D;
  58804. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"]));
  58805. /***/ }),
  58806. /***/ "./Materials/Textures/refractionTexture.ts":
  58807. /*!*************************************************!*\
  58808. !*** ./Materials/Textures/refractionTexture.ts ***!
  58809. \*************************************************/
  58810. /*! exports provided: RefractionTexture */
  58811. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58812. "use strict";
  58813. __webpack_require__.r(__webpack_exports__);
  58814. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return RefractionTexture; });
  58815. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58816. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  58817. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  58818. /**
  58819. * Creates a refraction texture used by refraction channel of the standard material.
  58820. * It is like a mirror but to see through a material.
  58821. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58822. */
  58823. var RefractionTexture = /** @class */ (function (_super) {
  58824. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RefractionTexture, _super);
  58825. /**
  58826. * Creates a refraction texture used by refraction channel of the standard material.
  58827. * It is like a mirror but to see through a material.
  58828. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58829. * @param name Define the texture name
  58830. * @param size Define the size of the underlying texture
  58831. * @param scene Define the scene the refraction belongs to
  58832. * @param generateMipMaps Define if we need to generate mips level for the refraction
  58833. */
  58834. function RefractionTexture(name, size, scene, generateMipMaps) {
  58835. var _this = _super.call(this, name, size, scene, generateMipMaps, true) || this;
  58836. /**
  58837. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  58838. * 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.
  58839. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58840. */
  58841. _this.refractionPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Plane"](0, 1, 0, 1);
  58842. /**
  58843. * Define how deep under the surface we should see.
  58844. */
  58845. _this.depth = 2.0;
  58846. _this.onBeforeRenderObservable.add(function () {
  58847. scene.clipPlane = _this.refractionPlane;
  58848. });
  58849. _this.onAfterRenderObservable.add(function () {
  58850. delete scene.clipPlane;
  58851. });
  58852. return _this;
  58853. }
  58854. /**
  58855. * Clone the refraction texture.
  58856. * @returns the cloned texture
  58857. */
  58858. RefractionTexture.prototype.clone = function () {
  58859. var scene = this.getScene();
  58860. if (!scene) {
  58861. return this;
  58862. }
  58863. var textureSize = this.getSize();
  58864. var newTexture = new RefractionTexture(this.name, textureSize.width, scene, this._generateMipMaps);
  58865. // Base texture
  58866. newTexture.hasAlpha = this.hasAlpha;
  58867. newTexture.level = this.level;
  58868. // Refraction Texture
  58869. newTexture.refractionPlane = this.refractionPlane.clone();
  58870. if (this.renderList) {
  58871. newTexture.renderList = this.renderList.slice(0);
  58872. }
  58873. newTexture.depth = this.depth;
  58874. return newTexture;
  58875. };
  58876. /**
  58877. * Serialize the texture to a JSON representation you could use in Parse later on
  58878. * @returns the serialized JSON representation
  58879. */
  58880. RefractionTexture.prototype.serialize = function () {
  58881. if (!this.name) {
  58882. return null;
  58883. }
  58884. var serializationObject = _super.prototype.serialize.call(this);
  58885. serializationObject.mirrorPlane = this.refractionPlane.asArray();
  58886. serializationObject.depth = this.depth;
  58887. return serializationObject;
  58888. };
  58889. return RefractionTexture;
  58890. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__["RenderTargetTexture"]));
  58891. /***/ }),
  58892. /***/ "./Materials/Textures/renderTargetCreationOptions.ts":
  58893. /*!***********************************************************!*\
  58894. !*** ./Materials/Textures/renderTargetCreationOptions.ts ***!
  58895. \***********************************************************/
  58896. /*! exports provided: RenderTargetCreationOptions */
  58897. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58898. "use strict";
  58899. __webpack_require__.r(__webpack_exports__);
  58900. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetCreationOptions", function() { return RenderTargetCreationOptions; });
  58901. /**
  58902. * Define options used to create a render target texture
  58903. */
  58904. var RenderTargetCreationOptions = /** @class */ (function () {
  58905. function RenderTargetCreationOptions() {
  58906. }
  58907. return RenderTargetCreationOptions;
  58908. }());
  58909. /***/ }),
  58910. /***/ "./Materials/Textures/renderTargetTexture.ts":
  58911. /*!***************************************************!*\
  58912. !*** ./Materials/Textures/renderTargetTexture.ts ***!
  58913. \***************************************************/
  58914. /*! exports provided: RenderTargetTexture */
  58915. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58916. "use strict";
  58917. __webpack_require__.r(__webpack_exports__);
  58918. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return RenderTargetTexture; });
  58919. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58920. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  58921. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  58922. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  58923. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  58924. /* harmony import */ var _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../PostProcesses/postProcessManager */ "./PostProcesses/postProcessManager.ts");
  58925. /* harmony import */ var _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Rendering/renderingManager */ "./Rendering/renderingManager.ts");
  58926. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  58927. /**
  58928. * This Helps creating a texture that will be created from a camera in your scene.
  58929. * It is basically a dynamic texture that could be used to create special effects for instance.
  58930. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  58931. */
  58932. var RenderTargetTexture = /** @class */ (function (_super) {
  58933. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RenderTargetTexture, _super);
  58934. /**
  58935. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  58936. * or used a shadow, depth texture...
  58937. * @param name The friendly name of the texture
  58938. * @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)
  58939. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  58940. * @param generateMipMaps True if mip maps need to be generated after render.
  58941. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  58942. * @param type The type of the buffer in the RTT (int, half float, float...)
  58943. * @param isCube True if a cube texture needs to be created
  58944. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  58945. * @param generateDepthBuffer True to generate a depth buffer
  58946. * @param generateStencilBuffer True to generate a stencil buffer
  58947. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  58948. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  58949. * @param delayAllocation if the texture allocation should be delayed (default: false)
  58950. */
  58951. function RenderTargetTexture(name, size, scene, generateMipMaps, doNotChangeAspectRatio, type, isCube, samplingMode, generateDepthBuffer, generateStencilBuffer, isMulti, format, delayAllocation) {
  58952. if (doNotChangeAspectRatio === void 0) { doNotChangeAspectRatio = true; }
  58953. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  58954. if (isCube === void 0) { isCube = false; }
  58955. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  58956. if (generateDepthBuffer === void 0) { generateDepthBuffer = true; }
  58957. if (generateStencilBuffer === void 0) { generateStencilBuffer = false; }
  58958. if (isMulti === void 0) { isMulti = false; }
  58959. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA; }
  58960. if (delayAllocation === void 0) { delayAllocation = false; }
  58961. var _this = _super.call(this, null, scene, !generateMipMaps) || this;
  58962. _this.isCube = isCube;
  58963. /**
  58964. * Define if particles should be rendered in your texture.
  58965. */
  58966. _this.renderParticles = true;
  58967. /**
  58968. * Define if sprites should be rendered in your texture.
  58969. */
  58970. _this.renderSprites = false;
  58971. /**
  58972. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  58973. */
  58974. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].PROJECTION_MODE;
  58975. /**
  58976. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  58977. */
  58978. _this.ignoreCameraViewport = false;
  58979. /**
  58980. * An event triggered when the texture is unbind.
  58981. */
  58982. _this.onBeforeBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  58983. /**
  58984. * An event triggered when the texture is unbind.
  58985. */
  58986. _this.onAfterUnbindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  58987. /**
  58988. * An event triggered before rendering the texture
  58989. */
  58990. _this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  58991. /**
  58992. * An event triggered after rendering the texture
  58993. */
  58994. _this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  58995. /**
  58996. * An event triggered after the texture clear
  58997. */
  58998. _this.onClearObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  58999. _this._currentRefreshId = -1;
  59000. _this._refreshRate = 1;
  59001. _this._samples = 1;
  59002. /**
  59003. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  59004. * It must define where the camera used to render the texture is set
  59005. */
  59006. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  59007. scene = _this.getScene();
  59008. if (!scene) {
  59009. return _this;
  59010. }
  59011. _this.renderList = new Array();
  59012. _this._engine = scene.getEngine();
  59013. _this.name = name;
  59014. _this.isRenderTarget = true;
  59015. _this._initialSizeParameter = size;
  59016. _this._processSizeParameter(size);
  59017. _this._resizeObserver = _this.getScene().getEngine().onResizeObservable.add(function () {
  59018. });
  59019. _this._generateMipMaps = generateMipMaps ? true : false;
  59020. _this._doNotChangeAspectRatio = doNotChangeAspectRatio;
  59021. // Rendering groups
  59022. _this._renderingManager = new _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_6__["RenderingManager"](scene);
  59023. _this._renderingManager._useSceneAutoClearSetup = true;
  59024. if (isMulti) {
  59025. return _this;
  59026. }
  59027. _this._renderTargetOptions = {
  59028. generateMipMaps: generateMipMaps,
  59029. type: type,
  59030. format: format,
  59031. samplingMode: samplingMode,
  59032. generateDepthBuffer: generateDepthBuffer,
  59033. generateStencilBuffer: generateStencilBuffer
  59034. };
  59035. if (samplingMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].NEAREST_SAMPLINGMODE) {
  59036. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  59037. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  59038. }
  59039. if (!delayAllocation) {
  59040. if (isCube) {
  59041. _this._texture = scene.getEngine().createRenderTargetCubeTexture(_this.getRenderSize(), _this._renderTargetOptions);
  59042. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].INVCUBIC_MODE;
  59043. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  59044. }
  59045. else {
  59046. _this._texture = scene.getEngine().createRenderTargetTexture(_this._size, _this._renderTargetOptions);
  59047. }
  59048. }
  59049. return _this;
  59050. }
  59051. Object.defineProperty(RenderTargetTexture.prototype, "renderList", {
  59052. /**
  59053. * Use this list to define the list of mesh you want to render.
  59054. */
  59055. get: function () {
  59056. return this._renderList;
  59057. },
  59058. set: function (value) {
  59059. this._renderList = value;
  59060. if (this._renderList) {
  59061. this._hookArray(this._renderList);
  59062. }
  59063. },
  59064. enumerable: true,
  59065. configurable: true
  59066. });
  59067. RenderTargetTexture.prototype._hookArray = function (array) {
  59068. var _this = this;
  59069. var oldPush = array.push;
  59070. array.push = function () {
  59071. var items = [];
  59072. for (var _i = 0; _i < arguments.length; _i++) {
  59073. items[_i] = arguments[_i];
  59074. }
  59075. var wasEmpty = array.length === 0;
  59076. var result = oldPush.apply(array, items);
  59077. if (wasEmpty) {
  59078. _this.getScene().meshes.forEach(function (mesh) {
  59079. mesh._markSubMeshesAsLightDirty();
  59080. });
  59081. }
  59082. return result;
  59083. };
  59084. var oldSplice = array.splice;
  59085. array.splice = function (index, deleteCount) {
  59086. var deleted = oldSplice.apply(array, [index, deleteCount]);
  59087. if (array.length === 0) {
  59088. _this.getScene().meshes.forEach(function (mesh) {
  59089. mesh._markSubMeshesAsLightDirty();
  59090. });
  59091. }
  59092. return deleted;
  59093. };
  59094. };
  59095. Object.defineProperty(RenderTargetTexture.prototype, "onAfterUnbind", {
  59096. /**
  59097. * Set a after unbind callback in the texture.
  59098. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  59099. */
  59100. set: function (callback) {
  59101. if (this._onAfterUnbindObserver) {
  59102. this.onAfterUnbindObservable.remove(this._onAfterUnbindObserver);
  59103. }
  59104. this._onAfterUnbindObserver = this.onAfterUnbindObservable.add(callback);
  59105. },
  59106. enumerable: true,
  59107. configurable: true
  59108. });
  59109. Object.defineProperty(RenderTargetTexture.prototype, "onBeforeRender", {
  59110. /**
  59111. * Set a before render callback in the texture.
  59112. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  59113. */
  59114. set: function (callback) {
  59115. if (this._onBeforeRenderObserver) {
  59116. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  59117. }
  59118. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  59119. },
  59120. enumerable: true,
  59121. configurable: true
  59122. });
  59123. Object.defineProperty(RenderTargetTexture.prototype, "onAfterRender", {
  59124. /**
  59125. * Set a after render callback in the texture.
  59126. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  59127. */
  59128. set: function (callback) {
  59129. if (this._onAfterRenderObserver) {
  59130. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  59131. }
  59132. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  59133. },
  59134. enumerable: true,
  59135. configurable: true
  59136. });
  59137. Object.defineProperty(RenderTargetTexture.prototype, "onClear", {
  59138. /**
  59139. * Set a clear callback in the texture.
  59140. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  59141. */
  59142. set: function (callback) {
  59143. if (this._onClearObserver) {
  59144. this.onClearObservable.remove(this._onClearObserver);
  59145. }
  59146. this._onClearObserver = this.onClearObservable.add(callback);
  59147. },
  59148. enumerable: true,
  59149. configurable: true
  59150. });
  59151. Object.defineProperty(RenderTargetTexture.prototype, "renderTargetOptions", {
  59152. /**
  59153. * Gets render target creation options that were used.
  59154. */
  59155. get: function () {
  59156. return this._renderTargetOptions;
  59157. },
  59158. enumerable: true,
  59159. configurable: true
  59160. });
  59161. RenderTargetTexture.prototype._onRatioRescale = function () {
  59162. if (this._sizeRatio) {
  59163. this.resize(this._initialSizeParameter);
  59164. }
  59165. };
  59166. Object.defineProperty(RenderTargetTexture.prototype, "boundingBoxSize", {
  59167. get: function () {
  59168. return this._boundingBoxSize;
  59169. },
  59170. /**
  59171. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  59172. * When defined, the cubemap will switch to local mode
  59173. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  59174. * @example https://www.babylonjs-playground.com/#RNASML
  59175. */
  59176. set: function (value) {
  59177. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  59178. return;
  59179. }
  59180. this._boundingBoxSize = value;
  59181. var scene = this.getScene();
  59182. if (scene) {
  59183. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag);
  59184. }
  59185. },
  59186. enumerable: true,
  59187. configurable: true
  59188. });
  59189. /**
  59190. * Creates a depth stencil texture.
  59191. * This is only available in WebGL 2 or with the depth texture extension available.
  59192. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  59193. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  59194. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  59195. */
  59196. RenderTargetTexture.prototype.createDepthStencilTexture = function (comparisonFunction, bilinearFiltering, generateStencil) {
  59197. if (comparisonFunction === void 0) { comparisonFunction = 0; }
  59198. if (bilinearFiltering === void 0) { bilinearFiltering = true; }
  59199. if (generateStencil === void 0) { generateStencil = false; }
  59200. if (!this.getScene()) {
  59201. return;
  59202. }
  59203. var engine = this.getScene().getEngine();
  59204. this.depthStencilTexture = engine.createDepthStencilTexture(this._size, {
  59205. bilinearFiltering: bilinearFiltering,
  59206. comparisonFunction: comparisonFunction,
  59207. generateStencil: generateStencil,
  59208. isCube: this.isCube
  59209. });
  59210. engine.setFrameBufferDepthStencilTexture(this);
  59211. };
  59212. RenderTargetTexture.prototype._processSizeParameter = function (size) {
  59213. if (size.ratio) {
  59214. this._sizeRatio = size.ratio;
  59215. this._size = {
  59216. width: this._bestReflectionRenderTargetDimension(this._engine.getRenderWidth(), this._sizeRatio),
  59217. height: this._bestReflectionRenderTargetDimension(this._engine.getRenderHeight(), this._sizeRatio)
  59218. };
  59219. }
  59220. else {
  59221. this._size = size;
  59222. }
  59223. };
  59224. Object.defineProperty(RenderTargetTexture.prototype, "samples", {
  59225. /**
  59226. * Define the number of samples to use in case of MSAA.
  59227. * It defaults to one meaning no MSAA has been enabled.
  59228. */
  59229. get: function () {
  59230. return this._samples;
  59231. },
  59232. set: function (value) {
  59233. if (this._samples === value) {
  59234. return;
  59235. }
  59236. var scene = this.getScene();
  59237. if (!scene) {
  59238. return;
  59239. }
  59240. this._samples = scene.getEngine().updateRenderTargetTextureSampleCount(this._texture, value);
  59241. },
  59242. enumerable: true,
  59243. configurable: true
  59244. });
  59245. /**
  59246. * Resets the refresh counter of the texture and start bak from scratch.
  59247. * Could be useful to regenerate the texture if it is setup to render only once.
  59248. */
  59249. RenderTargetTexture.prototype.resetRefreshCounter = function () {
  59250. this._currentRefreshId = -1;
  59251. };
  59252. Object.defineProperty(RenderTargetTexture.prototype, "refreshRate", {
  59253. /**
  59254. * Define the refresh rate of the texture or the rendering frequency.
  59255. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  59256. */
  59257. get: function () {
  59258. return this._refreshRate;
  59259. },
  59260. set: function (value) {
  59261. this._refreshRate = value;
  59262. this.resetRefreshCounter();
  59263. },
  59264. enumerable: true,
  59265. configurable: true
  59266. });
  59267. /**
  59268. * Adds a post process to the render target rendering passes.
  59269. * @param postProcess define the post process to add
  59270. */
  59271. RenderTargetTexture.prototype.addPostProcess = function (postProcess) {
  59272. if (!this._postProcessManager) {
  59273. var scene = this.getScene();
  59274. if (!scene) {
  59275. return;
  59276. }
  59277. this._postProcessManager = new _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_5__["PostProcessManager"](scene);
  59278. this._postProcesses = new Array();
  59279. }
  59280. this._postProcesses.push(postProcess);
  59281. this._postProcesses[0].autoClear = false;
  59282. };
  59283. /**
  59284. * Clear all the post processes attached to the render target
  59285. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  59286. */
  59287. RenderTargetTexture.prototype.clearPostProcesses = function (dispose) {
  59288. if (dispose === void 0) { dispose = false; }
  59289. if (!this._postProcesses) {
  59290. return;
  59291. }
  59292. if (dispose) {
  59293. for (var _i = 0, _a = this._postProcesses; _i < _a.length; _i++) {
  59294. var postProcess = _a[_i];
  59295. postProcess.dispose();
  59296. }
  59297. }
  59298. this._postProcesses = [];
  59299. };
  59300. /**
  59301. * Remove one of the post process from the list of attached post processes to the texture
  59302. * @param postProcess define the post process to remove from the list
  59303. */
  59304. RenderTargetTexture.prototype.removePostProcess = function (postProcess) {
  59305. if (!this._postProcesses) {
  59306. return;
  59307. }
  59308. var index = this._postProcesses.indexOf(postProcess);
  59309. if (index === -1) {
  59310. return;
  59311. }
  59312. this._postProcesses.splice(index, 1);
  59313. if (this._postProcesses.length > 0) {
  59314. this._postProcesses[0].autoClear = false;
  59315. }
  59316. };
  59317. /** @hidden */
  59318. RenderTargetTexture.prototype._shouldRender = function () {
  59319. if (this._currentRefreshId === -1) { // At least render once
  59320. this._currentRefreshId = 1;
  59321. return true;
  59322. }
  59323. if (this.refreshRate === this._currentRefreshId) {
  59324. this._currentRefreshId = 1;
  59325. return true;
  59326. }
  59327. this._currentRefreshId++;
  59328. return false;
  59329. };
  59330. /**
  59331. * Gets the actual render size of the texture.
  59332. * @returns the width of the render size
  59333. */
  59334. RenderTargetTexture.prototype.getRenderSize = function () {
  59335. return this.getRenderWidth();
  59336. };
  59337. /**
  59338. * Gets the actual render width of the texture.
  59339. * @returns the width of the render size
  59340. */
  59341. RenderTargetTexture.prototype.getRenderWidth = function () {
  59342. if (this._size.width) {
  59343. return this._size.width;
  59344. }
  59345. return this._size;
  59346. };
  59347. /**
  59348. * Gets the actual render height of the texture.
  59349. * @returns the height of the render size
  59350. */
  59351. RenderTargetTexture.prototype.getRenderHeight = function () {
  59352. if (this._size.width) {
  59353. return this._size.height;
  59354. }
  59355. return this._size;
  59356. };
  59357. Object.defineProperty(RenderTargetTexture.prototype, "canRescale", {
  59358. /**
  59359. * Get if the texture can be rescaled or not.
  59360. */
  59361. get: function () {
  59362. return true;
  59363. },
  59364. enumerable: true,
  59365. configurable: true
  59366. });
  59367. /**
  59368. * Resize the texture using a ratio.
  59369. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  59370. */
  59371. RenderTargetTexture.prototype.scale = function (ratio) {
  59372. var newSize = this.getRenderSize() * ratio;
  59373. this.resize(newSize);
  59374. };
  59375. /**
  59376. * Get the texture reflection matrix used to rotate/transform the reflection.
  59377. * @returns the reflection matrix
  59378. */
  59379. RenderTargetTexture.prototype.getReflectionTextureMatrix = function () {
  59380. if (this.isCube) {
  59381. return this._textureMatrix;
  59382. }
  59383. return _super.prototype.getReflectionTextureMatrix.call(this);
  59384. };
  59385. /**
  59386. * Resize the texture to a new desired size.
  59387. * Be carrefull as it will recreate all the data in the new texture.
  59388. * @param size Define the new size. It can be:
  59389. * - a number for squared texture,
  59390. * - an object containing { width: number, height: number }
  59391. * - or an object containing a ratio { ratio: number }
  59392. */
  59393. RenderTargetTexture.prototype.resize = function (size) {
  59394. this.releaseInternalTexture();
  59395. var scene = this.getScene();
  59396. if (!scene) {
  59397. return;
  59398. }
  59399. this._processSizeParameter(size);
  59400. if (this.isCube) {
  59401. this._texture = scene.getEngine().createRenderTargetCubeTexture(this.getRenderSize(), this._renderTargetOptions);
  59402. }
  59403. else {
  59404. this._texture = scene.getEngine().createRenderTargetTexture(this._size, this._renderTargetOptions);
  59405. }
  59406. };
  59407. /**
  59408. * Renders all the objects from the render list into the texture.
  59409. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  59410. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  59411. */
  59412. RenderTargetTexture.prototype.render = function (useCameraPostProcess, dumpForDebug) {
  59413. if (useCameraPostProcess === void 0) { useCameraPostProcess = false; }
  59414. if (dumpForDebug === void 0) { dumpForDebug = false; }
  59415. var scene = this.getScene();
  59416. if (!scene) {
  59417. return;
  59418. }
  59419. var engine = scene.getEngine();
  59420. if (this.useCameraPostProcesses !== undefined) {
  59421. useCameraPostProcess = this.useCameraPostProcesses;
  59422. }
  59423. if (this._waitingRenderList) {
  59424. this.renderList = [];
  59425. for (var index = 0; index < this._waitingRenderList.length; index++) {
  59426. var id = this._waitingRenderList[index];
  59427. var mesh_1 = scene.getMeshByID(id);
  59428. if (mesh_1) {
  59429. this.renderList.push(mesh_1);
  59430. }
  59431. }
  59432. delete this._waitingRenderList;
  59433. }
  59434. // Is predicate defined?
  59435. if (this.renderListPredicate) {
  59436. if (this.renderList) {
  59437. this.renderList.length = 0; // Clear previous renderList
  59438. }
  59439. else {
  59440. this.renderList = [];
  59441. }
  59442. var scene = this.getScene();
  59443. if (!scene) {
  59444. return;
  59445. }
  59446. var sceneMeshes = scene.meshes;
  59447. for (var index = 0; index < sceneMeshes.length; index++) {
  59448. var mesh = sceneMeshes[index];
  59449. if (this.renderListPredicate(mesh)) {
  59450. this.renderList.push(mesh);
  59451. }
  59452. }
  59453. }
  59454. this.onBeforeBindObservable.notifyObservers(this);
  59455. // Set custom projection.
  59456. // Needs to be before binding to prevent changing the aspect ratio.
  59457. var camera;
  59458. if (this.activeCamera) {
  59459. camera = this.activeCamera;
  59460. engine.setViewport(this.activeCamera.viewport, this.getRenderWidth(), this.getRenderHeight());
  59461. if (this.activeCamera !== scene.activeCamera) {
  59462. scene.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(true));
  59463. }
  59464. }
  59465. else {
  59466. camera = scene.activeCamera;
  59467. if (camera) {
  59468. engine.setViewport(camera.viewport, this.getRenderWidth(), this.getRenderHeight());
  59469. }
  59470. }
  59471. // Prepare renderingManager
  59472. this._renderingManager.reset();
  59473. var currentRenderList = this.renderList ? this.renderList : scene.getActiveMeshes().data;
  59474. var currentRenderListLength = this.renderList ? this.renderList.length : scene.getActiveMeshes().length;
  59475. var sceneRenderId = scene.getRenderId();
  59476. for (var meshIndex = 0; meshIndex < currentRenderListLength; meshIndex++) {
  59477. var mesh = currentRenderList[meshIndex];
  59478. if (mesh) {
  59479. if (!mesh.isReady(this.refreshRate === 0)) {
  59480. this.resetRefreshCounter();
  59481. continue;
  59482. }
  59483. mesh._preActivateForIntermediateRendering(sceneRenderId);
  59484. var isMasked = void 0;
  59485. if (!this.renderList && camera) {
  59486. isMasked = ((mesh.layerMask & camera.layerMask) === 0);
  59487. }
  59488. else {
  59489. isMasked = false;
  59490. }
  59491. if (mesh.isEnabled() && mesh.isVisible && mesh.subMeshes && !isMasked) {
  59492. mesh._activate(sceneRenderId);
  59493. for (var subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  59494. var subMesh = mesh.subMeshes[subIndex];
  59495. scene._activeIndices.addCount(subMesh.indexCount, false);
  59496. this._renderingManager.dispatch(subMesh, mesh);
  59497. }
  59498. }
  59499. }
  59500. }
  59501. for (var particleIndex = 0; particleIndex < scene.particleSystems.length; particleIndex++) {
  59502. var particleSystem = scene.particleSystems[particleIndex];
  59503. var emitter = particleSystem.emitter;
  59504. if (!particleSystem.isStarted() || !emitter || !emitter.position || !emitter.isEnabled()) {
  59505. continue;
  59506. }
  59507. if (currentRenderList.indexOf(emitter) >= 0) {
  59508. this._renderingManager.dispatchParticles(particleSystem);
  59509. }
  59510. }
  59511. if (this.isCube) {
  59512. for (var face = 0; face < 6; face++) {
  59513. this.renderToTarget(face, currentRenderList, useCameraPostProcess, dumpForDebug);
  59514. scene.incrementRenderId();
  59515. scene.resetCachedMaterial();
  59516. }
  59517. }
  59518. else {
  59519. this.renderToTarget(0, currentRenderList, useCameraPostProcess, dumpForDebug);
  59520. }
  59521. this.onAfterUnbindObservable.notifyObservers(this);
  59522. if (scene.activeCamera) {
  59523. if (this.activeCamera && this.activeCamera !== scene.activeCamera) {
  59524. scene.setTransformMatrix(scene.activeCamera.getViewMatrix(), scene.activeCamera.getProjectionMatrix(true));
  59525. }
  59526. engine.setViewport(scene.activeCamera.viewport);
  59527. }
  59528. scene.resetCachedMaterial();
  59529. };
  59530. RenderTargetTexture.prototype._bestReflectionRenderTargetDimension = function (renderDimension, scale) {
  59531. var minimum = 128;
  59532. var x = renderDimension * scale;
  59533. var curved = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].NearestPOT(x + (minimum * minimum / (minimum + x)));
  59534. // Ensure we don't exceed the render dimension (while staying POT)
  59535. return Math.min(_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].FloorPOT(renderDimension), curved);
  59536. };
  59537. RenderTargetTexture.prototype.unbindFrameBuffer = function (engine, faceIndex) {
  59538. var _this = this;
  59539. if (!this._texture) {
  59540. return;
  59541. }
  59542. engine.unBindFramebuffer(this._texture, this.isCube, function () {
  59543. _this.onAfterRenderObservable.notifyObservers(faceIndex);
  59544. });
  59545. };
  59546. RenderTargetTexture.prototype.renderToTarget = function (faceIndex, currentRenderList, useCameraPostProcess, dumpForDebug) {
  59547. var scene = this.getScene();
  59548. if (!scene) {
  59549. return;
  59550. }
  59551. var engine = scene.getEngine();
  59552. if (!this._texture) {
  59553. return;
  59554. }
  59555. // Bind
  59556. if (this._postProcessManager) {
  59557. this._postProcessManager._prepareFrame(this._texture, this._postProcesses);
  59558. }
  59559. else if (!useCameraPostProcess || !scene.postProcessManager._prepareFrame(this._texture)) {
  59560. if (this._texture) {
  59561. engine.bindFramebuffer(this._texture, this.isCube ? faceIndex : undefined, undefined, undefined, this.ignoreCameraViewport, this.depthStencilTexture ? this.depthStencilTexture : undefined);
  59562. }
  59563. }
  59564. this.onBeforeRenderObservable.notifyObservers(faceIndex);
  59565. // Clear
  59566. if (this.onClearObservable.hasObservers()) {
  59567. this.onClearObservable.notifyObservers(engine);
  59568. }
  59569. else {
  59570. engine.clear(this.clearColor || scene.clearColor, true, true, true);
  59571. }
  59572. if (!this._doNotChangeAspectRatio) {
  59573. scene.updateTransformMatrix(true);
  59574. }
  59575. // Before Camera Draw
  59576. for (var _i = 0, _a = scene._beforeRenderTargetDrawStage; _i < _a.length; _i++) {
  59577. var step = _a[_i];
  59578. step.action(this);
  59579. }
  59580. // Render
  59581. this._renderingManager.render(this.customRenderFunction, currentRenderList, this.renderParticles, this.renderSprites);
  59582. // After Camera Draw
  59583. for (var _b = 0, _c = scene._afterRenderTargetDrawStage; _b < _c.length; _b++) {
  59584. var step = _c[_b];
  59585. step.action(this);
  59586. }
  59587. if (this._postProcessManager) {
  59588. this._postProcessManager._finalizeFrame(false, this._texture, faceIndex, this._postProcesses, this.ignoreCameraViewport);
  59589. }
  59590. else if (useCameraPostProcess) {
  59591. scene.postProcessManager._finalizeFrame(false, this._texture, faceIndex);
  59592. }
  59593. if (!this._doNotChangeAspectRatio) {
  59594. scene.updateTransformMatrix(true);
  59595. }
  59596. // Dump ?
  59597. if (dumpForDebug) {
  59598. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].DumpFramebuffer(this.getRenderWidth(), this.getRenderHeight(), engine);
  59599. }
  59600. // Unbind
  59601. if (!this.isCube || faceIndex === 5) {
  59602. if (this.isCube) {
  59603. if (faceIndex === 5) {
  59604. engine.generateMipMapsForCubemap(this._texture);
  59605. }
  59606. }
  59607. this.unbindFrameBuffer(engine, faceIndex);
  59608. }
  59609. else {
  59610. this.onAfterRenderObservable.notifyObservers(faceIndex);
  59611. }
  59612. };
  59613. /**
  59614. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  59615. * This allowed control for front to back rendering or reversly depending of the special needs.
  59616. *
  59617. * @param renderingGroupId The rendering group id corresponding to its index
  59618. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  59619. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  59620. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  59621. */
  59622. RenderTargetTexture.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  59623. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  59624. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  59625. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  59626. this._renderingManager.setRenderingOrder(renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn);
  59627. };
  59628. /**
  59629. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  59630. *
  59631. * @param renderingGroupId The rendering group id corresponding to its index
  59632. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  59633. */
  59634. RenderTargetTexture.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil) {
  59635. this._renderingManager.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil);
  59636. this._renderingManager._useSceneAutoClearSetup = false;
  59637. };
  59638. /**
  59639. * Clones the texture.
  59640. * @returns the cloned texture
  59641. */
  59642. RenderTargetTexture.prototype.clone = function () {
  59643. var textureSize = this.getSize();
  59644. 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);
  59645. // Base texture
  59646. newTexture.hasAlpha = this.hasAlpha;
  59647. newTexture.level = this.level;
  59648. // RenderTarget Texture
  59649. newTexture.coordinatesMode = this.coordinatesMode;
  59650. if (this.renderList) {
  59651. newTexture.renderList = this.renderList.slice(0);
  59652. }
  59653. return newTexture;
  59654. };
  59655. /**
  59656. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  59657. * @returns The JSON representation of the texture
  59658. */
  59659. RenderTargetTexture.prototype.serialize = function () {
  59660. if (!this.name) {
  59661. return null;
  59662. }
  59663. var serializationObject = _super.prototype.serialize.call(this);
  59664. serializationObject.renderTargetSize = this.getRenderSize();
  59665. serializationObject.renderList = [];
  59666. if (this.renderList) {
  59667. for (var index = 0; index < this.renderList.length; index++) {
  59668. serializationObject.renderList.push(this.renderList[index].id);
  59669. }
  59670. }
  59671. return serializationObject;
  59672. };
  59673. /**
  59674. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  59675. */
  59676. RenderTargetTexture.prototype.disposeFramebufferObjects = function () {
  59677. var objBuffer = this.getInternalTexture();
  59678. var scene = this.getScene();
  59679. if (objBuffer && scene) {
  59680. scene.getEngine()._releaseFramebufferObjects(objBuffer);
  59681. }
  59682. };
  59683. /**
  59684. * Dispose the texture and release its associated resources.
  59685. */
  59686. RenderTargetTexture.prototype.dispose = function () {
  59687. if (this._postProcessManager) {
  59688. this._postProcessManager.dispose();
  59689. this._postProcessManager = null;
  59690. }
  59691. this.clearPostProcesses(true);
  59692. if (this._resizeObserver) {
  59693. this.getScene().getEngine().onResizeObservable.remove(this._resizeObserver);
  59694. this._resizeObserver = null;
  59695. }
  59696. this.renderList = null;
  59697. // Remove from custom render targets
  59698. var scene = this.getScene();
  59699. if (!scene) {
  59700. return;
  59701. }
  59702. var index = scene.customRenderTargets.indexOf(this);
  59703. if (index >= 0) {
  59704. scene.customRenderTargets.splice(index, 1);
  59705. }
  59706. for (var _i = 0, _a = scene.cameras; _i < _a.length; _i++) {
  59707. var camera = _a[_i];
  59708. index = camera.customRenderTargets.indexOf(this);
  59709. if (index >= 0) {
  59710. camera.customRenderTargets.splice(index, 1);
  59711. }
  59712. }
  59713. _super.prototype.dispose.call(this);
  59714. };
  59715. /** @hidden */
  59716. RenderTargetTexture.prototype._rebuild = function () {
  59717. if (this.refreshRate === RenderTargetTexture.REFRESHRATE_RENDER_ONCE) {
  59718. this.refreshRate = RenderTargetTexture.REFRESHRATE_RENDER_ONCE;
  59719. }
  59720. if (this._postProcessManager) {
  59721. this._postProcessManager._rebuild();
  59722. }
  59723. };
  59724. /**
  59725. * Clear the info related to rendering groups preventing retention point in material dispose.
  59726. */
  59727. RenderTargetTexture.prototype.freeRenderingGroups = function () {
  59728. if (this._renderingManager) {
  59729. this._renderingManager.freeRenderingGroups();
  59730. }
  59731. };
  59732. /**
  59733. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  59734. */
  59735. RenderTargetTexture.REFRESHRATE_RENDER_ONCE = 0;
  59736. /**
  59737. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  59738. */
  59739. RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYFRAME = 1;
  59740. /**
  59741. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  59742. * the central point of your effect and can save a lot of performances.
  59743. */
  59744. RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYTWOFRAMES = 2;
  59745. return RenderTargetTexture;
  59746. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]));
  59747. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]._CreateRenderTargetTexture = function (name, renderTargetSize, scene, generateMipMaps) {
  59748. return new RenderTargetTexture(name, renderTargetSize, scene, generateMipMaps);
  59749. };
  59750. /***/ }),
  59751. /***/ "./Materials/Textures/texture.ts":
  59752. /*!***************************************!*\
  59753. !*** ./Materials/Textures/texture.ts ***!
  59754. \***************************************/
  59755. /*! exports provided: Texture */
  59756. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59757. "use strict";
  59758. __webpack_require__.r(__webpack_exports__);
  59759. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return Texture; });
  59760. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  59761. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  59762. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  59763. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  59764. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  59765. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  59766. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  59767. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  59768. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Misc/devTools */ "./Misc/devTools.ts");
  59769. /**
  59770. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  59771. * @see http://doc.babylonjs.com/babylon101/materials#texture
  59772. */
  59773. var Texture = /** @class */ (function (_super) {
  59774. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Texture, _super);
  59775. /**
  59776. * Instantiates a new texture.
  59777. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  59778. * @see http://doc.babylonjs.com/babylon101/materials#texture
  59779. * @param url define the url of the picture to load as a texture
  59780. * @param scene define the scene the texture will belong to
  59781. * @param noMipmap define if the texture will require mip maps or not
  59782. * @param invertY define if the texture needs to be inverted on the y axis during loading
  59783. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  59784. * @param onLoad define a callback triggered when the texture has been loaded
  59785. * @param onError define a callback triggered when an error occurred during the loading session
  59786. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  59787. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  59788. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  59789. */
  59790. function Texture(url, scene, noMipmap, invertY, samplingMode, onLoad, onError, buffer, deleteBuffer, format) {
  59791. if (noMipmap === void 0) { noMipmap = false; }
  59792. if (invertY === void 0) { invertY = true; }
  59793. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  59794. if (onLoad === void 0) { onLoad = null; }
  59795. if (onError === void 0) { onError = null; }
  59796. if (buffer === void 0) { buffer = null; }
  59797. if (deleteBuffer === void 0) { deleteBuffer = false; }
  59798. var _this = _super.call(this, scene) || this;
  59799. /**
  59800. * Define an offset on the texture to offset the u coordinates of the UVs
  59801. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  59802. */
  59803. _this.uOffset = 0;
  59804. /**
  59805. * Define an offset on the texture to offset the v coordinates of the UVs
  59806. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  59807. */
  59808. _this.vOffset = 0;
  59809. /**
  59810. * Define an offset on the texture to scale the u coordinates of the UVs
  59811. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  59812. */
  59813. _this.uScale = 1.0;
  59814. /**
  59815. * Define an offset on the texture to scale the v coordinates of the UVs
  59816. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  59817. */
  59818. _this.vScale = 1.0;
  59819. /**
  59820. * Define an offset on the texture to rotate around the u coordinates of the UVs
  59821. * @see http://doc.babylonjs.com/how_to/more_materials
  59822. */
  59823. _this.uAng = 0;
  59824. /**
  59825. * Define an offset on the texture to rotate around the v coordinates of the UVs
  59826. * @see http://doc.babylonjs.com/how_to/more_materials
  59827. */
  59828. _this.vAng = 0;
  59829. /**
  59830. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  59831. * @see http://doc.babylonjs.com/how_to/more_materials
  59832. */
  59833. _this.wAng = 0;
  59834. /**
  59835. * Defines the center of rotation (U)
  59836. */
  59837. _this.uRotationCenter = 0.5;
  59838. /**
  59839. * Defines the center of rotation (V)
  59840. */
  59841. _this.vRotationCenter = 0.5;
  59842. /**
  59843. * Defines the center of rotation (W)
  59844. */
  59845. _this.wRotationCenter = 0.5;
  59846. /** @hidden */
  59847. _this._initialSamplingMode = Texture.BILINEAR_SAMPLINGMODE;
  59848. /**
  59849. * Observable triggered once the texture has been loaded.
  59850. */
  59851. _this.onLoadObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  59852. _this._isBlocking = true;
  59853. _this.name = url || "";
  59854. _this.url = url;
  59855. _this._noMipmap = noMipmap;
  59856. _this._invertY = invertY;
  59857. _this._initialSamplingMode = samplingMode;
  59858. _this._buffer = buffer;
  59859. _this._deleteBuffer = deleteBuffer;
  59860. if (format) {
  59861. _this._format = format;
  59862. }
  59863. scene = _this.getScene();
  59864. if (!scene) {
  59865. return _this;
  59866. }
  59867. scene.getEngine().onBeforeTextureInitObservable.notifyObservers(_this);
  59868. var load = function () {
  59869. if (_this._texture && _this._texture._invertVScale) {
  59870. _this.vScale = -1;
  59871. }
  59872. if (_this.onLoadObservable.hasObservers()) {
  59873. _this.onLoadObservable.notifyObservers(_this);
  59874. }
  59875. if (onLoad) {
  59876. onLoad();
  59877. }
  59878. if (!_this.isBlocking && scene) {
  59879. scene.resetCachedMaterial();
  59880. }
  59881. };
  59882. if (!_this.url) {
  59883. _this._delayedOnLoad = load;
  59884. _this._delayedOnError = onError;
  59885. return _this;
  59886. }
  59887. _this._texture = _this._getFromCache(_this.url, noMipmap, samplingMode, invertY);
  59888. if (!_this._texture) {
  59889. if (!scene.useDelayedTextureLoading) {
  59890. _this._texture = scene.getEngine().createTexture(_this.url, noMipmap, invertY, scene, samplingMode, load, onError, _this._buffer, undefined, _this._format);
  59891. if (deleteBuffer) {
  59892. delete _this._buffer;
  59893. }
  59894. }
  59895. else {
  59896. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  59897. _this._delayedOnLoad = load;
  59898. _this._delayedOnError = onError;
  59899. }
  59900. }
  59901. else {
  59902. if (_this._texture.isReady) {
  59903. _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].SetImmediate(function () { return load(); });
  59904. }
  59905. else {
  59906. _this._texture.onLoadedObservable.add(load);
  59907. }
  59908. }
  59909. return _this;
  59910. }
  59911. Object.defineProperty(Texture.prototype, "noMipmap", {
  59912. /**
  59913. * Are mip maps generated for this texture or not.
  59914. */
  59915. get: function () {
  59916. return this._noMipmap;
  59917. },
  59918. enumerable: true,
  59919. configurable: true
  59920. });
  59921. Object.defineProperty(Texture.prototype, "isBlocking", {
  59922. get: function () {
  59923. return this._isBlocking;
  59924. },
  59925. /**
  59926. * Is the texture preventing material to render while loading.
  59927. * If false, a default texture will be used instead of the loading one during the preparation step.
  59928. */
  59929. set: function (value) {
  59930. this._isBlocking = value;
  59931. },
  59932. enumerable: true,
  59933. configurable: true
  59934. });
  59935. Object.defineProperty(Texture.prototype, "samplingMode", {
  59936. /**
  59937. * Get the current sampling mode associated with the texture.
  59938. */
  59939. get: function () {
  59940. if (!this._texture) {
  59941. return this._initialSamplingMode;
  59942. }
  59943. return this._texture.samplingMode;
  59944. },
  59945. enumerable: true,
  59946. configurable: true
  59947. });
  59948. Object.defineProperty(Texture.prototype, "invertY", {
  59949. /**
  59950. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  59951. */
  59952. get: function () {
  59953. return this._invertY;
  59954. },
  59955. enumerable: true,
  59956. configurable: true
  59957. });
  59958. /**
  59959. * Update the url (and optional buffer) of this texture if url was null during construction.
  59960. * @param url the url of the texture
  59961. * @param buffer the buffer of the texture (defaults to null)
  59962. * @param onLoad callback called when the texture is loaded (defaults to null)
  59963. */
  59964. Texture.prototype.updateURL = function (url, buffer, onLoad) {
  59965. if (buffer === void 0) { buffer = null; }
  59966. if (this.url) {
  59967. this.releaseInternalTexture();
  59968. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  59969. }
  59970. this.url = url;
  59971. this._buffer = buffer;
  59972. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  59973. if (onLoad) {
  59974. this._delayedOnLoad = onLoad;
  59975. }
  59976. this.delayLoad();
  59977. };
  59978. /**
  59979. * Finish the loading sequence of a texture flagged as delayed load.
  59980. * @hidden
  59981. */
  59982. Texture.prototype.delayLoad = function () {
  59983. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  59984. return;
  59985. }
  59986. var scene = this.getScene();
  59987. if (!scene) {
  59988. return;
  59989. }
  59990. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  59991. this._texture = this._getFromCache(this.url, this._noMipmap, this.samplingMode, this._invertY);
  59992. if (!this._texture) {
  59993. this._texture = scene.getEngine().createTexture(this.url, this._noMipmap, this._invertY, scene, this.samplingMode, this._delayedOnLoad, this._delayedOnError, this._buffer, null, this._format);
  59994. if (this._deleteBuffer) {
  59995. delete this._buffer;
  59996. }
  59997. }
  59998. else {
  59999. if (this._delayedOnLoad) {
  60000. if (this._texture.isReady) {
  60001. _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].SetImmediate(this._delayedOnLoad);
  60002. }
  60003. else {
  60004. this._texture.onLoadedObservable.add(this._delayedOnLoad);
  60005. }
  60006. }
  60007. }
  60008. this._delayedOnLoad = null;
  60009. this._delayedOnError = null;
  60010. };
  60011. Texture.prototype._prepareRowForTextureGeneration = function (x, y, z, t) {
  60012. x *= this.uScale;
  60013. y *= this.vScale;
  60014. x -= this.uRotationCenter * this.uScale;
  60015. y -= this.vRotationCenter * this.vScale;
  60016. z -= this.wRotationCenter;
  60017. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesFromFloatsToRef(x, y, z, this._rowGenerationMatrix, t);
  60018. t.x += this.uRotationCenter * this.uScale + this.uOffset;
  60019. t.y += this.vRotationCenter * this.vScale + this.vOffset;
  60020. t.z += this.wRotationCenter;
  60021. };
  60022. /**
  60023. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  60024. * @returns the transform matrix of the texture.
  60025. */
  60026. Texture.prototype.getTextureMatrix = function () {
  60027. var _this = this;
  60028. if (this.uOffset === this._cachedUOffset &&
  60029. this.vOffset === this._cachedVOffset &&
  60030. this.uScale === this._cachedUScale &&
  60031. this.vScale === this._cachedVScale &&
  60032. this.uAng === this._cachedUAng &&
  60033. this.vAng === this._cachedVAng &&
  60034. this.wAng === this._cachedWAng) {
  60035. return this._cachedTextureMatrix;
  60036. }
  60037. this._cachedUOffset = this.uOffset;
  60038. this._cachedVOffset = this.vOffset;
  60039. this._cachedUScale = this.uScale;
  60040. this._cachedVScale = this.vScale;
  60041. this._cachedUAng = this.uAng;
  60042. this._cachedVAng = this.vAng;
  60043. this._cachedWAng = this.wAng;
  60044. if (!this._cachedTextureMatrix) {
  60045. this._cachedTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  60046. this._rowGenerationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  60047. this._t0 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  60048. this._t1 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  60049. this._t2 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  60050. }
  60051. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationYawPitchRollToRef(this.vAng, this.uAng, this.wAng, this._rowGenerationMatrix);
  60052. this._prepareRowForTextureGeneration(0, 0, 0, this._t0);
  60053. this._prepareRowForTextureGeneration(1.0, 0, 0, this._t1);
  60054. this._prepareRowForTextureGeneration(0, 1.0, 0, this._t2);
  60055. this._t1.subtractInPlace(this._t0);
  60056. this._t2.subtractInPlace(this._t0);
  60057. _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);
  60058. var scene = this.getScene();
  60059. if (!scene) {
  60060. return this._cachedTextureMatrix;
  60061. }
  60062. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) {
  60063. return mat.hasTexture(_this);
  60064. });
  60065. return this._cachedTextureMatrix;
  60066. };
  60067. /**
  60068. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  60069. * @returns The reflection texture transform
  60070. */
  60071. Texture.prototype.getReflectionTextureMatrix = function () {
  60072. var _this = this;
  60073. var scene = this.getScene();
  60074. if (!scene) {
  60075. return this._cachedTextureMatrix;
  60076. }
  60077. if (this.uOffset === this._cachedUOffset &&
  60078. this.vOffset === this._cachedVOffset &&
  60079. this.uScale === this._cachedUScale &&
  60080. this.vScale === this._cachedVScale &&
  60081. this.coordinatesMode === this._cachedCoordinatesMode) {
  60082. if (this.coordinatesMode === Texture.PROJECTION_MODE) {
  60083. if (this._cachedProjectionMatrixId === scene.getProjectionMatrix().updateFlag) {
  60084. return this._cachedTextureMatrix;
  60085. }
  60086. }
  60087. else {
  60088. return this._cachedTextureMatrix;
  60089. }
  60090. }
  60091. if (!this._cachedTextureMatrix) {
  60092. this._cachedTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  60093. }
  60094. if (!this._projectionModeMatrix) {
  60095. this._projectionModeMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  60096. }
  60097. this._cachedUOffset = this.uOffset;
  60098. this._cachedVOffset = this.vOffset;
  60099. this._cachedUScale = this.uScale;
  60100. this._cachedVScale = this.vScale;
  60101. this._cachedCoordinatesMode = this.coordinatesMode;
  60102. switch (this.coordinatesMode) {
  60103. case Texture.PLANAR_MODE:
  60104. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].IdentityToRef(this._cachedTextureMatrix);
  60105. this._cachedTextureMatrix[0] = this.uScale;
  60106. this._cachedTextureMatrix[5] = this.vScale;
  60107. this._cachedTextureMatrix[12] = this.uOffset;
  60108. this._cachedTextureMatrix[13] = this.vOffset;
  60109. break;
  60110. case Texture.PROJECTION_MODE:
  60111. _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);
  60112. var projectionMatrix = scene.getProjectionMatrix();
  60113. this._cachedProjectionMatrixId = projectionMatrix.updateFlag;
  60114. projectionMatrix.multiplyToRef(this._projectionModeMatrix, this._cachedTextureMatrix);
  60115. break;
  60116. default:
  60117. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].IdentityToRef(this._cachedTextureMatrix);
  60118. break;
  60119. }
  60120. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) {
  60121. return (mat.getActiveTextures().indexOf(_this) !== -1);
  60122. });
  60123. return this._cachedTextureMatrix;
  60124. };
  60125. /**
  60126. * Clones the texture.
  60127. * @returns the cloned texture
  60128. */
  60129. Texture.prototype.clone = function () {
  60130. var _this = this;
  60131. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  60132. return new Texture(_this._texture ? _this._texture.url : null, _this.getScene(), _this._noMipmap, _this._invertY, _this.samplingMode);
  60133. }, this);
  60134. };
  60135. /**
  60136. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  60137. * @returns The JSON representation of the texture
  60138. */
  60139. Texture.prototype.serialize = function () {
  60140. var serializationObject = _super.prototype.serialize.call(this);
  60141. if (typeof this._buffer === "string" && this._buffer.substr(0, 5) === "data:") {
  60142. serializationObject.base64String = this._buffer;
  60143. serializationObject.name = serializationObject.name.replace("data:", "");
  60144. }
  60145. serializationObject.invertY = this._invertY;
  60146. serializationObject.samplingMode = this.samplingMode;
  60147. return serializationObject;
  60148. };
  60149. /**
  60150. * Get the current class name of the texture useful for serialization or dynamic coding.
  60151. * @returns "Texture"
  60152. */
  60153. Texture.prototype.getClassName = function () {
  60154. return "Texture";
  60155. };
  60156. /**
  60157. * Dispose the texture and release its associated resources.
  60158. */
  60159. Texture.prototype.dispose = function () {
  60160. _super.prototype.dispose.call(this);
  60161. this.onLoadObservable.clear();
  60162. this._delayedOnLoad = null;
  60163. this._delayedOnError = null;
  60164. };
  60165. /**
  60166. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  60167. * @param parsedTexture Define the JSON representation of the texture
  60168. * @param scene Define the scene the parsed texture should be instantiated in
  60169. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  60170. * @returns The parsed texture if successful
  60171. */
  60172. Texture.Parse = function (parsedTexture, scene, rootUrl) {
  60173. if (parsedTexture.customType) {
  60174. var customTexture = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Instantiate(parsedTexture.customType);
  60175. // Update Sampling Mode
  60176. var parsedCustomTexture = customTexture.Parse(parsedTexture, scene, rootUrl);
  60177. if (parsedTexture.samplingMode && parsedCustomTexture.updateSamplingMode && parsedCustomTexture._samplingMode) {
  60178. if (parsedCustomTexture._samplingMode !== parsedTexture.samplingMode) {
  60179. parsedCustomTexture.updateSamplingMode(parsedTexture.samplingMode);
  60180. }
  60181. }
  60182. return parsedCustomTexture;
  60183. }
  60184. if (parsedTexture.isCube && !parsedTexture.isRenderTarget) {
  60185. return Texture._CubeTextureParser(parsedTexture, scene, rootUrl);
  60186. }
  60187. if (!parsedTexture.name && !parsedTexture.isRenderTarget) {
  60188. return null;
  60189. }
  60190. var texture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () {
  60191. var generateMipMaps = true;
  60192. if (parsedTexture.noMipmap) {
  60193. generateMipMaps = false;
  60194. }
  60195. if (parsedTexture.mirrorPlane) {
  60196. var mirrorTexture = Texture._CreateMirror(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
  60197. mirrorTexture._waitingRenderList = parsedTexture.renderList;
  60198. mirrorTexture.mirrorPlane = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Plane"].FromArray(parsedTexture.mirrorPlane);
  60199. return mirrorTexture;
  60200. }
  60201. else if (parsedTexture.isRenderTarget) {
  60202. var renderTargetTexture = null;
  60203. if (parsedTexture.isCube) {
  60204. // Search for an existing reflection probe (which contains a cube render target texture)
  60205. if (scene.reflectionProbes) {
  60206. for (var index = 0; index < scene.reflectionProbes.length; index++) {
  60207. var probe = scene.reflectionProbes[index];
  60208. if (probe.name === parsedTexture.name) {
  60209. return probe.cubeTexture;
  60210. }
  60211. }
  60212. }
  60213. }
  60214. else {
  60215. renderTargetTexture = Texture._CreateRenderTargetTexture(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
  60216. renderTargetTexture._waitingRenderList = parsedTexture.renderList;
  60217. }
  60218. return renderTargetTexture;
  60219. }
  60220. else {
  60221. var texture;
  60222. if (parsedTexture.base64String) {
  60223. texture = Texture.CreateFromBase64String(parsedTexture.base64String, parsedTexture.name, scene, !generateMipMaps);
  60224. }
  60225. else {
  60226. var url = rootUrl + parsedTexture.name;
  60227. if (Texture.UseSerializedUrlIfAny && parsedTexture.url) {
  60228. url = parsedTexture.url;
  60229. }
  60230. texture = new Texture(url, scene, !generateMipMaps, parsedTexture.invertY);
  60231. }
  60232. return texture;
  60233. }
  60234. }, parsedTexture, scene);
  60235. // Update Sampling Mode
  60236. if (parsedTexture.samplingMode) {
  60237. var sampling = parsedTexture.samplingMode;
  60238. if (texture && texture.samplingMode !== sampling) {
  60239. texture.updateSamplingMode(sampling);
  60240. }
  60241. }
  60242. // Animations
  60243. if (texture && parsedTexture.animations) {
  60244. for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
  60245. var parsedAnimation = parsedTexture.animations[animationIndex];
  60246. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].GetClass("BABYLON.Animation");
  60247. if (internalClass) {
  60248. texture.animations.push(internalClass.Parse(parsedAnimation));
  60249. }
  60250. }
  60251. }
  60252. return texture;
  60253. };
  60254. /**
  60255. * Creates a texture from its base 64 representation.
  60256. * @param data Define the base64 payload without the data: prefix
  60257. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  60258. * @param scene Define the scene the texture should belong to
  60259. * @param noMipmap Forces the texture to not create mip map information if true
  60260. * @param invertY define if the texture needs to be inverted on the y axis during loading
  60261. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  60262. * @param onLoad define a callback triggered when the texture has been loaded
  60263. * @param onError define a callback triggered when an error occurred during the loading session
  60264. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  60265. * @returns the created texture
  60266. */
  60267. Texture.CreateFromBase64String = function (data, name, scene, noMipmap, invertY, samplingMode, onLoad, onError, format) {
  60268. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  60269. if (onLoad === void 0) { onLoad = null; }
  60270. if (onError === void 0) { onError = null; }
  60271. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  60272. return new Texture("data:" + name, scene, noMipmap, invertY, samplingMode, onLoad, onError, data, false, format);
  60273. };
  60274. /**
  60275. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  60276. * @param data Define the base64 payload without the data: prefix
  60277. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  60278. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  60279. * @param scene Define the scene the texture should belong to
  60280. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  60281. * @param noMipmap Forces the texture to not create mip map information if true
  60282. * @param invertY define if the texture needs to be inverted on the y axis during loading
  60283. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  60284. * @param onLoad define a callback triggered when the texture has been loaded
  60285. * @param onError define a callback triggered when an error occurred during the loading session
  60286. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  60287. * @returns the created texture
  60288. */
  60289. Texture.LoadFromDataString = function (name, buffer, scene, deleteBuffer, noMipmap, invertY, samplingMode, onLoad, onError, format) {
  60290. if (deleteBuffer === void 0) { deleteBuffer = false; }
  60291. if (noMipmap === void 0) { noMipmap = false; }
  60292. if (invertY === void 0) { invertY = true; }
  60293. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  60294. if (onLoad === void 0) { onLoad = null; }
  60295. if (onError === void 0) { onError = null; }
  60296. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  60297. if (name.substr(0, 5) !== "data:") {
  60298. name = "data:" + name;
  60299. }
  60300. return new Texture(name, scene, noMipmap, invertY, samplingMode, onLoad, onError, buffer, deleteBuffer, format);
  60301. };
  60302. /** @hidden */
  60303. Texture._CubeTextureParser = function (jsonTexture, scene, rootUrl) {
  60304. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("CubeTexture");
  60305. };
  60306. /** @hidden */
  60307. Texture._CreateMirror = function (name, renderTargetSize, scene, generateMipMaps) {
  60308. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("MirrorTexture");
  60309. };
  60310. /** @hidden */
  60311. Texture._CreateRenderTargetTexture = function (name, renderTargetSize, scene, generateMipMaps) {
  60312. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("RenderTargetTexture");
  60313. };
  60314. /** nearest is mag = nearest and min = nearest and mip = linear */
  60315. Texture.NEAREST_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  60316. /** nearest is mag = nearest and min = nearest and mip = linear */
  60317. 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
  60318. /** Bilinear is mag = linear and min = linear and mip = nearest */
  60319. Texture.BILINEAR_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE;
  60320. /** Bilinear is mag = linear and min = linear and mip = nearest */
  60321. 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
  60322. /** Trilinear is mag = linear and min = linear and mip = linear */
  60323. Texture.TRILINEAR_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  60324. /** Trilinear is mag = linear and min = linear and mip = linear */
  60325. 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
  60326. /** mag = nearest and min = nearest and mip = nearest */
  60327. Texture.NEAREST_NEAREST_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_NEAREST_MIPNEAREST;
  60328. /** mag = nearest and min = linear and mip = nearest */
  60329. Texture.NEAREST_LINEAR_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR_MIPNEAREST;
  60330. /** mag = nearest and min = linear and mip = linear */
  60331. Texture.NEAREST_LINEAR_MIPLINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR_MIPLINEAR;
  60332. /** mag = nearest and min = linear and mip = none */
  60333. Texture.NEAREST_LINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR;
  60334. /** mag = nearest and min = nearest and mip = none */
  60335. Texture.NEAREST_NEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_NEAREST;
  60336. /** mag = linear and min = nearest and mip = nearest */
  60337. Texture.LINEAR_NEAREST_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST_MIPNEAREST;
  60338. /** mag = linear and min = nearest and mip = linear */
  60339. Texture.LINEAR_NEAREST_MIPLINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST_MIPLINEAR;
  60340. /** mag = linear and min = linear and mip = none */
  60341. Texture.LINEAR_LINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_LINEAR;
  60342. /** mag = linear and min = nearest and mip = none */
  60343. Texture.LINEAR_NEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST;
  60344. /** Explicit coordinates mode */
  60345. Texture.EXPLICIT_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_EXPLICIT_MODE;
  60346. /** Spherical coordinates mode */
  60347. Texture.SPHERICAL_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_SPHERICAL_MODE;
  60348. /** Planar coordinates mode */
  60349. Texture.PLANAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_PLANAR_MODE;
  60350. /** Cubic coordinates mode */
  60351. Texture.CUBIC_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_CUBIC_MODE;
  60352. /** Projection coordinates mode */
  60353. Texture.PROJECTION_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_PROJECTION_MODE;
  60354. /** Inverse Cubic coordinates mode */
  60355. Texture.SKYBOX_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_SKYBOX_MODE;
  60356. /** Inverse Cubic coordinates mode */
  60357. Texture.INVCUBIC_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_INVCUBIC_MODE;
  60358. /** Equirectangular coordinates mode */
  60359. Texture.EQUIRECTANGULAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_EQUIRECTANGULAR_MODE;
  60360. /** Equirectangular Fixed coordinates mode */
  60361. Texture.FIXED_EQUIRECTANGULAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MODE;
  60362. /** Equirectangular Fixed Mirrored coordinates mode */
  60363. Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE;
  60364. /** Texture is not repeating outside of 0..1 UVs */
  60365. Texture.CLAMP_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  60366. /** Texture is repeating outside of 0..1 UVs */
  60367. Texture.WRAP_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  60368. /** Texture is repeating and mirrored */
  60369. Texture.MIRROR_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_MIRROR_ADDRESSMODE;
  60370. /**
  60371. * 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
  60372. */
  60373. Texture.UseSerializedUrlIfAny = false;
  60374. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60375. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60376. ], Texture.prototype, "url", void 0);
  60377. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60378. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60379. ], Texture.prototype, "uOffset", void 0);
  60380. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60381. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60382. ], Texture.prototype, "vOffset", void 0);
  60383. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60384. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60385. ], Texture.prototype, "uScale", void 0);
  60386. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60387. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60388. ], Texture.prototype, "vScale", void 0);
  60389. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60390. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60391. ], Texture.prototype, "uAng", void 0);
  60392. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60393. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60394. ], Texture.prototype, "vAng", void 0);
  60395. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60396. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60397. ], Texture.prototype, "wAng", void 0);
  60398. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60399. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60400. ], Texture.prototype, "uRotationCenter", void 0);
  60401. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60402. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60403. ], Texture.prototype, "vRotationCenter", void 0);
  60404. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60405. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60406. ], Texture.prototype, "wRotationCenter", void 0);
  60407. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60408. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60409. ], Texture.prototype, "isBlocking", null);
  60410. return Texture;
  60411. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]));
  60412. // References the dependencies.
  60413. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._TextureParser = Texture.Parse;
  60414. /***/ }),
  60415. /***/ "./Materials/Textures/videoTexture.ts":
  60416. /*!********************************************!*\
  60417. !*** ./Materials/Textures/videoTexture.ts ***!
  60418. \********************************************/
  60419. /*! exports provided: VideoTexture */
  60420. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60421. "use strict";
  60422. __webpack_require__.r(__webpack_exports__);
  60423. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return VideoTexture; });
  60424. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  60425. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  60426. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  60427. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  60428. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  60429. /**
  60430. * If you want to display a video in your scene, this is the special texture for that.
  60431. * This special texture works similar to other textures, with the exception of a few parameters.
  60432. * @see https://doc.babylonjs.com/how_to/video_texture
  60433. */
  60434. var VideoTexture = /** @class */ (function (_super) {
  60435. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VideoTexture, _super);
  60436. /**
  60437. * Creates a video texture.
  60438. * If you want to display a video in your scene, this is the special texture for that.
  60439. * This special texture works similar to other textures, with the exception of a few parameters.
  60440. * @see https://doc.babylonjs.com/how_to/video_texture
  60441. * @param name optional name, will detect from video source, if not defined
  60442. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  60443. * @param scene is obviously the current scene.
  60444. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  60445. * @param invertY is false by default but can be used to invert video on Y axis
  60446. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  60447. * @param settings allows finer control over video usage
  60448. */
  60449. function VideoTexture(name, src, scene, generateMipMaps, invertY, samplingMode, settings) {
  60450. if (generateMipMaps === void 0) { generateMipMaps = false; }
  60451. if (invertY === void 0) { invertY = false; }
  60452. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  60453. if (settings === void 0) { settings = {
  60454. autoPlay: true,
  60455. loop: true,
  60456. autoUpdateTexture: true,
  60457. }; }
  60458. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  60459. _this._onUserActionRequestedObservable = null;
  60460. _this._stillImageCaptured = false;
  60461. _this._displayingPosterTexture = false;
  60462. _this._createInternalTexture = function () {
  60463. if (_this._texture != null) {
  60464. if (_this._displayingPosterTexture) {
  60465. _this._texture.dispose();
  60466. _this._displayingPosterTexture = false;
  60467. }
  60468. else {
  60469. return;
  60470. }
  60471. }
  60472. if (!_this._engine.needPOTTextures ||
  60473. (_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].IsExponentOfTwo(_this.video.videoWidth) && _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].IsExponentOfTwo(_this.video.videoHeight))) {
  60474. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  60475. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  60476. }
  60477. else {
  60478. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  60479. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  60480. _this._generateMipMaps = false;
  60481. }
  60482. _this._texture = _this._engine.createDynamicTexture(_this.video.videoWidth, _this.video.videoHeight, _this._generateMipMaps, _this.samplingMode);
  60483. if (!_this.video.autoplay && !_this._settings.poster) {
  60484. var oldHandler_1 = _this.video.onplaying;
  60485. var error_1 = false;
  60486. var oldMuted_1 = _this.video.muted;
  60487. _this.video.muted = true;
  60488. _this.video.onplaying = function () {
  60489. _this.video.muted = oldMuted_1;
  60490. _this.video.onplaying = oldHandler_1;
  60491. _this._texture.isReady = true;
  60492. _this._updateInternalTexture();
  60493. if (!error_1) {
  60494. _this.video.pause();
  60495. }
  60496. if (_this.onLoadObservable.hasObservers()) {
  60497. _this.onLoadObservable.notifyObservers(_this);
  60498. }
  60499. };
  60500. var playing = _this.video.play();
  60501. if (playing) {
  60502. playing.then(function () {
  60503. // Everything is good.
  60504. })
  60505. .catch(function () {
  60506. error_1 = true;
  60507. // On Chrome for instance, new policies might prevent playing without user interaction.
  60508. if (_this._onUserActionRequestedObservable && _this._onUserActionRequestedObservable.hasObservers()) {
  60509. _this._onUserActionRequestedObservable.notifyObservers(_this);
  60510. }
  60511. });
  60512. }
  60513. else {
  60514. _this.video.onplaying = oldHandler_1;
  60515. _this._texture.isReady = true;
  60516. _this._updateInternalTexture();
  60517. if (_this.onLoadObservable.hasObservers()) {
  60518. _this.onLoadObservable.notifyObservers(_this);
  60519. }
  60520. }
  60521. }
  60522. else {
  60523. _this._texture.isReady = true;
  60524. _this._updateInternalTexture();
  60525. if (_this.onLoadObservable.hasObservers()) {
  60526. _this.onLoadObservable.notifyObservers(_this);
  60527. }
  60528. }
  60529. };
  60530. _this.reset = function () {
  60531. if (_this._texture == null) {
  60532. return;
  60533. }
  60534. if (!_this._displayingPosterTexture) {
  60535. _this._texture.dispose();
  60536. _this._texture = null;
  60537. }
  60538. };
  60539. _this._updateInternalTexture = function () {
  60540. if (_this._texture == null || !_this._texture.isReady) {
  60541. return;
  60542. }
  60543. if (_this.video.readyState < _this.video.HAVE_CURRENT_DATA) {
  60544. return;
  60545. }
  60546. if (_this._displayingPosterTexture) {
  60547. return;
  60548. }
  60549. _this._engine.updateVideoTexture(_this._texture, _this.video, _this._invertY);
  60550. };
  60551. _this._engine = _this.getScene().getEngine();
  60552. _this._generateMipMaps = generateMipMaps;
  60553. _this._initialSamplingMode = samplingMode;
  60554. _this.autoUpdateTexture = settings.autoUpdateTexture;
  60555. _this.name = name || _this._getName(src);
  60556. _this.video = _this._getVideo(src);
  60557. _this._settings = settings;
  60558. if (settings.poster) {
  60559. _this.video.poster = settings.poster;
  60560. }
  60561. if (settings.autoPlay !== undefined) {
  60562. _this.video.autoplay = settings.autoPlay;
  60563. }
  60564. if (settings.loop !== undefined) {
  60565. _this.video.loop = settings.loop;
  60566. }
  60567. _this.video.setAttribute("playsinline", "");
  60568. _this.video.addEventListener("paused", _this._updateInternalTexture);
  60569. _this.video.addEventListener("seeked", _this._updateInternalTexture);
  60570. _this.video.addEventListener("emptied", _this.reset);
  60571. _this._createInternalTextureOnEvent = (settings.poster && !settings.autoPlay) ? "play" : "canplay";
  60572. _this.video.addEventListener(_this._createInternalTextureOnEvent, _this._createInternalTexture);
  60573. var videoHasEnoughData = (_this.video.readyState >= _this.video.HAVE_CURRENT_DATA);
  60574. if (settings.poster &&
  60575. (!settings.autoPlay || !videoHasEnoughData)) {
  60576. _this._texture = _this._engine.createTexture(settings.poster, false, true, scene);
  60577. _this._displayingPosterTexture = true;
  60578. }
  60579. else if (videoHasEnoughData) {
  60580. _this._createInternalTexture();
  60581. }
  60582. return _this;
  60583. }
  60584. Object.defineProperty(VideoTexture.prototype, "onUserActionRequestedObservable", {
  60585. /**
  60586. * Event triggerd when a dom action is required by the user to play the video.
  60587. * This happens due to recent changes in browser policies preventing video to auto start.
  60588. */
  60589. get: function () {
  60590. if (!this._onUserActionRequestedObservable) {
  60591. this._onUserActionRequestedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  60592. }
  60593. return this._onUserActionRequestedObservable;
  60594. },
  60595. enumerable: true,
  60596. configurable: true
  60597. });
  60598. VideoTexture.prototype._getName = function (src) {
  60599. if (src instanceof HTMLVideoElement) {
  60600. return src.currentSrc;
  60601. }
  60602. if (typeof src === "object") {
  60603. return src.toString();
  60604. }
  60605. return src;
  60606. };
  60607. VideoTexture.prototype._getVideo = function (src) {
  60608. if (src instanceof HTMLVideoElement) {
  60609. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src.currentSrc, src);
  60610. return src;
  60611. }
  60612. var video = document.createElement("video");
  60613. if (typeof src === "string") {
  60614. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src, video);
  60615. video.src = src;
  60616. }
  60617. else {
  60618. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src[0], video);
  60619. src.forEach(function (url) {
  60620. var source = document.createElement("source");
  60621. source.src = url;
  60622. video.appendChild(source);
  60623. });
  60624. }
  60625. return video;
  60626. };
  60627. /**
  60628. * @hidden Internal method to initiate `update`.
  60629. */
  60630. VideoTexture.prototype._rebuild = function () {
  60631. this.update();
  60632. };
  60633. /**
  60634. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  60635. */
  60636. VideoTexture.prototype.update = function () {
  60637. if (!this.autoUpdateTexture) {
  60638. // Expecting user to call `updateTexture` manually
  60639. return;
  60640. }
  60641. this.updateTexture(true);
  60642. };
  60643. /**
  60644. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  60645. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  60646. */
  60647. VideoTexture.prototype.updateTexture = function (isVisible) {
  60648. if (!isVisible) {
  60649. return;
  60650. }
  60651. if (this.video.paused && this._stillImageCaptured) {
  60652. return;
  60653. }
  60654. this._stillImageCaptured = true;
  60655. this._updateInternalTexture();
  60656. };
  60657. /**
  60658. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  60659. * @param url New url.
  60660. */
  60661. VideoTexture.prototype.updateURL = function (url) {
  60662. this.video.src = url;
  60663. };
  60664. /**
  60665. * Dispose the texture and release its associated resources.
  60666. */
  60667. VideoTexture.prototype.dispose = function () {
  60668. _super.prototype.dispose.call(this);
  60669. if (this._onUserActionRequestedObservable) {
  60670. this._onUserActionRequestedObservable.clear();
  60671. this._onUserActionRequestedObservable = null;
  60672. }
  60673. this.video.removeEventListener(this._createInternalTextureOnEvent, this._createInternalTexture);
  60674. this.video.removeEventListener("paused", this._updateInternalTexture);
  60675. this.video.removeEventListener("seeked", this._updateInternalTexture);
  60676. this.video.removeEventListener("emptied", this.reset);
  60677. this.video.pause();
  60678. };
  60679. /**
  60680. * Creates a video texture straight from a stream.
  60681. * @param scene Define the scene the texture should be created in
  60682. * @param stream Define the stream the texture should be created from
  60683. * @returns The created video texture as a promise
  60684. */
  60685. VideoTexture.CreateFromStreamAsync = function (scene, stream) {
  60686. var video = document.createElement("video");
  60687. video.setAttribute('autoplay', '');
  60688. video.setAttribute('muted', 'true');
  60689. video.setAttribute('playsinline', '');
  60690. video.muted = true;
  60691. if (video.mozSrcObject !== undefined) {
  60692. // hack for Firefox < 19
  60693. video.mozSrcObject = stream;
  60694. }
  60695. else {
  60696. if (typeof video.srcObject == "object") {
  60697. video.srcObject = stream;
  60698. }
  60699. else {
  60700. window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL;
  60701. video.src = (window.URL && window.URL.createObjectURL(stream));
  60702. }
  60703. }
  60704. return new Promise(function (resolve) {
  60705. var onPlaying = function () {
  60706. resolve(new VideoTexture("video", video, scene, true, true));
  60707. video.removeEventListener("playing", onPlaying);
  60708. };
  60709. video.addEventListener("playing", onPlaying);
  60710. video.play();
  60711. });
  60712. };
  60713. /**
  60714. * Creates a video texture straight from your WebCam video feed.
  60715. * @param scene Define the scene the texture should be created in
  60716. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  60717. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  60718. * @returns The created video texture as a promise
  60719. */
  60720. VideoTexture.CreateFromWebCamAsync = function (scene, constraints, audioConstaints) {
  60721. var _this = this;
  60722. if (audioConstaints === void 0) { audioConstaints = false; }
  60723. var constraintsDeviceId;
  60724. if (constraints && constraints.deviceId) {
  60725. constraintsDeviceId = {
  60726. exact: constraints.deviceId,
  60727. };
  60728. }
  60729. if (navigator.mediaDevices) {
  60730. return navigator.mediaDevices.getUserMedia({
  60731. video: constraints,
  60732. audio: audioConstaints
  60733. })
  60734. .then(function (stream) {
  60735. return _this.CreateFromStreamAsync(scene, stream);
  60736. });
  60737. }
  60738. else {
  60739. navigator.getUserMedia =
  60740. navigator.getUserMedia ||
  60741. navigator.webkitGetUserMedia ||
  60742. navigator.mozGetUserMedia ||
  60743. navigator.msGetUserMedia;
  60744. if (navigator.getUserMedia) {
  60745. navigator.getUserMedia({
  60746. video: {
  60747. deviceId: constraintsDeviceId,
  60748. width: {
  60749. min: (constraints && constraints.minWidth) || 256,
  60750. max: (constraints && constraints.maxWidth) || 640,
  60751. },
  60752. height: {
  60753. min: (constraints && constraints.minHeight) || 256,
  60754. max: (constraints && constraints.maxHeight) || 480,
  60755. },
  60756. },
  60757. audio: audioConstaints
  60758. }, function (stream) {
  60759. return _this.CreateFromStreamAsync(scene, stream);
  60760. }, function (e) {
  60761. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error(e.name);
  60762. });
  60763. }
  60764. }
  60765. return Promise.reject("No support for userMedia on this device");
  60766. };
  60767. /**
  60768. * Creates a video texture straight from your WebCam video feed.
  60769. * @param scene Define the scene the texture should be created in
  60770. * @param onReady Define a callback to triggered once the texture will be ready
  60771. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  60772. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  60773. */
  60774. VideoTexture.CreateFromWebCam = function (scene, onReady, constraints, audioConstaints) {
  60775. if (audioConstaints === void 0) { audioConstaints = false; }
  60776. this.CreateFromWebCamAsync(scene, constraints, audioConstaints)
  60777. .then(function (videoTexture) {
  60778. if (onReady) {
  60779. onReady(videoTexture);
  60780. }
  60781. })
  60782. .catch(function (err) {
  60783. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error(err.name);
  60784. });
  60785. };
  60786. return VideoTexture;
  60787. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]));
  60788. /***/ }),
  60789. /***/ "./Materials/colorCurves.ts":
  60790. /*!**********************************!*\
  60791. !*** ./Materials/colorCurves.ts ***!
  60792. \**********************************/
  60793. /*! exports provided: ColorCurves */
  60794. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60795. "use strict";
  60796. __webpack_require__.r(__webpack_exports__);
  60797. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return ColorCurves; });
  60798. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  60799. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  60800. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  60801. /**
  60802. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60803. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60804. * 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;
  60805. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60806. */
  60807. var ColorCurves = /** @class */ (function () {
  60808. function ColorCurves() {
  60809. this._dirty = true;
  60810. this._tempColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  60811. this._globalCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  60812. this._highlightsCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  60813. this._midtonesCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  60814. this._shadowsCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  60815. this._positiveCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  60816. this._negativeCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  60817. this._globalHue = 30;
  60818. this._globalDensity = 0;
  60819. this._globalSaturation = 0;
  60820. this._globalExposure = 0;
  60821. this._highlightsHue = 30;
  60822. this._highlightsDensity = 0;
  60823. this._highlightsSaturation = 0;
  60824. this._highlightsExposure = 0;
  60825. this._midtonesHue = 30;
  60826. this._midtonesDensity = 0;
  60827. this._midtonesSaturation = 0;
  60828. this._midtonesExposure = 0;
  60829. this._shadowsHue = 30;
  60830. this._shadowsDensity = 0;
  60831. this._shadowsSaturation = 0;
  60832. this._shadowsExposure = 0;
  60833. }
  60834. Object.defineProperty(ColorCurves.prototype, "globalHue", {
  60835. /**
  60836. * Gets the global Hue value.
  60837. * 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).
  60838. */
  60839. get: function () {
  60840. return this._globalHue;
  60841. },
  60842. /**
  60843. * Sets the global Hue value.
  60844. * 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).
  60845. */
  60846. set: function (value) {
  60847. this._globalHue = value;
  60848. this._dirty = true;
  60849. },
  60850. enumerable: true,
  60851. configurable: true
  60852. });
  60853. Object.defineProperty(ColorCurves.prototype, "globalDensity", {
  60854. /**
  60855. * Gets the global Density value.
  60856. * 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.
  60857. * Values less than zero provide a filter of opposite hue.
  60858. */
  60859. get: function () {
  60860. return this._globalDensity;
  60861. },
  60862. /**
  60863. * Sets the global Density value.
  60864. * 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.
  60865. * Values less than zero provide a filter of opposite hue.
  60866. */
  60867. set: function (value) {
  60868. this._globalDensity = value;
  60869. this._dirty = true;
  60870. },
  60871. enumerable: true,
  60872. configurable: true
  60873. });
  60874. Object.defineProperty(ColorCurves.prototype, "globalSaturation", {
  60875. /**
  60876. * Gets the global Saturation value.
  60877. * 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.
  60878. */
  60879. get: function () {
  60880. return this._globalSaturation;
  60881. },
  60882. /**
  60883. * Sets the global Saturation value.
  60884. * 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.
  60885. */
  60886. set: function (value) {
  60887. this._globalSaturation = value;
  60888. this._dirty = true;
  60889. },
  60890. enumerable: true,
  60891. configurable: true
  60892. });
  60893. Object.defineProperty(ColorCurves.prototype, "globalExposure", {
  60894. /**
  60895. * Gets the global Exposure value.
  60896. * 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.
  60897. */
  60898. get: function () {
  60899. return this._globalExposure;
  60900. },
  60901. /**
  60902. * Sets the global Exposure value.
  60903. * 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.
  60904. */
  60905. set: function (value) {
  60906. this._globalExposure = value;
  60907. this._dirty = true;
  60908. },
  60909. enumerable: true,
  60910. configurable: true
  60911. });
  60912. Object.defineProperty(ColorCurves.prototype, "highlightsHue", {
  60913. /**
  60914. * Gets the highlights Hue value.
  60915. * 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).
  60916. */
  60917. get: function () {
  60918. return this._highlightsHue;
  60919. },
  60920. /**
  60921. * Sets the highlights Hue value.
  60922. * 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).
  60923. */
  60924. set: function (value) {
  60925. this._highlightsHue = value;
  60926. this._dirty = true;
  60927. },
  60928. enumerable: true,
  60929. configurable: true
  60930. });
  60931. Object.defineProperty(ColorCurves.prototype, "highlightsDensity", {
  60932. /**
  60933. * Gets the highlights Density value.
  60934. * 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.
  60935. * Values less than zero provide a filter of opposite hue.
  60936. */
  60937. get: function () {
  60938. return this._highlightsDensity;
  60939. },
  60940. /**
  60941. * Sets the highlights Density value.
  60942. * 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.
  60943. * Values less than zero provide a filter of opposite hue.
  60944. */
  60945. set: function (value) {
  60946. this._highlightsDensity = value;
  60947. this._dirty = true;
  60948. },
  60949. enumerable: true,
  60950. configurable: true
  60951. });
  60952. Object.defineProperty(ColorCurves.prototype, "highlightsSaturation", {
  60953. /**
  60954. * Gets the highlights Saturation value.
  60955. * 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.
  60956. */
  60957. get: function () {
  60958. return this._highlightsSaturation;
  60959. },
  60960. /**
  60961. * Sets the highlights Saturation value.
  60962. * 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.
  60963. */
  60964. set: function (value) {
  60965. this._highlightsSaturation = value;
  60966. this._dirty = true;
  60967. },
  60968. enumerable: true,
  60969. configurable: true
  60970. });
  60971. Object.defineProperty(ColorCurves.prototype, "highlightsExposure", {
  60972. /**
  60973. * Gets the highlights Exposure value.
  60974. * 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.
  60975. */
  60976. get: function () {
  60977. return this._highlightsExposure;
  60978. },
  60979. /**
  60980. * Sets the highlights Exposure value.
  60981. * 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.
  60982. */
  60983. set: function (value) {
  60984. this._highlightsExposure = value;
  60985. this._dirty = true;
  60986. },
  60987. enumerable: true,
  60988. configurable: true
  60989. });
  60990. Object.defineProperty(ColorCurves.prototype, "midtonesHue", {
  60991. /**
  60992. * Gets the midtones Hue value.
  60993. * 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).
  60994. */
  60995. get: function () {
  60996. return this._midtonesHue;
  60997. },
  60998. /**
  60999. * Sets the midtones Hue value.
  61000. * 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).
  61001. */
  61002. set: function (value) {
  61003. this._midtonesHue = value;
  61004. this._dirty = true;
  61005. },
  61006. enumerable: true,
  61007. configurable: true
  61008. });
  61009. Object.defineProperty(ColorCurves.prototype, "midtonesDensity", {
  61010. /**
  61011. * Gets the midtones Density value.
  61012. * 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.
  61013. * Values less than zero provide a filter of opposite hue.
  61014. */
  61015. get: function () {
  61016. return this._midtonesDensity;
  61017. },
  61018. /**
  61019. * Sets the midtones Density value.
  61020. * 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.
  61021. * Values less than zero provide a filter of opposite hue.
  61022. */
  61023. set: function (value) {
  61024. this._midtonesDensity = value;
  61025. this._dirty = true;
  61026. },
  61027. enumerable: true,
  61028. configurable: true
  61029. });
  61030. Object.defineProperty(ColorCurves.prototype, "midtonesSaturation", {
  61031. /**
  61032. * Gets the midtones Saturation value.
  61033. * 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.
  61034. */
  61035. get: function () {
  61036. return this._midtonesSaturation;
  61037. },
  61038. /**
  61039. * Sets the midtones Saturation value.
  61040. * 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.
  61041. */
  61042. set: function (value) {
  61043. this._midtonesSaturation = value;
  61044. this._dirty = true;
  61045. },
  61046. enumerable: true,
  61047. configurable: true
  61048. });
  61049. Object.defineProperty(ColorCurves.prototype, "midtonesExposure", {
  61050. /**
  61051. * Gets the midtones Exposure value.
  61052. * 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.
  61053. */
  61054. get: function () {
  61055. return this._midtonesExposure;
  61056. },
  61057. /**
  61058. * Sets the midtones Exposure value.
  61059. * 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.
  61060. */
  61061. set: function (value) {
  61062. this._midtonesExposure = value;
  61063. this._dirty = true;
  61064. },
  61065. enumerable: true,
  61066. configurable: true
  61067. });
  61068. Object.defineProperty(ColorCurves.prototype, "shadowsHue", {
  61069. /**
  61070. * Gets the shadows Hue value.
  61071. * 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).
  61072. */
  61073. get: function () {
  61074. return this._shadowsHue;
  61075. },
  61076. /**
  61077. * Sets the shadows Hue value.
  61078. * 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).
  61079. */
  61080. set: function (value) {
  61081. this._shadowsHue = value;
  61082. this._dirty = true;
  61083. },
  61084. enumerable: true,
  61085. configurable: true
  61086. });
  61087. Object.defineProperty(ColorCurves.prototype, "shadowsDensity", {
  61088. /**
  61089. * Gets the shadows Density value.
  61090. * 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.
  61091. * Values less than zero provide a filter of opposite hue.
  61092. */
  61093. get: function () {
  61094. return this._shadowsDensity;
  61095. },
  61096. /**
  61097. * Sets the shadows Density value.
  61098. * 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.
  61099. * Values less than zero provide a filter of opposite hue.
  61100. */
  61101. set: function (value) {
  61102. this._shadowsDensity = value;
  61103. this._dirty = true;
  61104. },
  61105. enumerable: true,
  61106. configurable: true
  61107. });
  61108. Object.defineProperty(ColorCurves.prototype, "shadowsSaturation", {
  61109. /**
  61110. * Gets the shadows Saturation value.
  61111. * 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.
  61112. */
  61113. get: function () {
  61114. return this._shadowsSaturation;
  61115. },
  61116. /**
  61117. * Sets the shadows Saturation value.
  61118. * 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.
  61119. */
  61120. set: function (value) {
  61121. this._shadowsSaturation = value;
  61122. this._dirty = true;
  61123. },
  61124. enumerable: true,
  61125. configurable: true
  61126. });
  61127. Object.defineProperty(ColorCurves.prototype, "shadowsExposure", {
  61128. /**
  61129. * Gets the shadows Exposure value.
  61130. * 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.
  61131. */
  61132. get: function () {
  61133. return this._shadowsExposure;
  61134. },
  61135. /**
  61136. * Sets the shadows Exposure value.
  61137. * 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.
  61138. */
  61139. set: function (value) {
  61140. this._shadowsExposure = value;
  61141. this._dirty = true;
  61142. },
  61143. enumerable: true,
  61144. configurable: true
  61145. });
  61146. /**
  61147. * Returns the class name
  61148. * @returns The class name
  61149. */
  61150. ColorCurves.prototype.getClassName = function () {
  61151. return "ColorCurves";
  61152. };
  61153. /**
  61154. * Binds the color curves to the shader.
  61155. * @param colorCurves The color curve to bind
  61156. * @param effect The effect to bind to
  61157. * @param positiveUniform The positive uniform shader parameter
  61158. * @param neutralUniform The neutral uniform shader parameter
  61159. * @param negativeUniform The negative uniform shader parameter
  61160. */
  61161. ColorCurves.Bind = function (colorCurves, effect, positiveUniform, neutralUniform, negativeUniform) {
  61162. if (positiveUniform === void 0) { positiveUniform = "vCameraColorCurvePositive"; }
  61163. if (neutralUniform === void 0) { neutralUniform = "vCameraColorCurveNeutral"; }
  61164. if (negativeUniform === void 0) { negativeUniform = "vCameraColorCurveNegative"; }
  61165. if (colorCurves._dirty) {
  61166. colorCurves._dirty = false;
  61167. // Fill in global info.
  61168. colorCurves.getColorGradingDataToRef(colorCurves._globalHue, colorCurves._globalDensity, colorCurves._globalSaturation, colorCurves._globalExposure, colorCurves._globalCurve);
  61169. // Compute highlights info.
  61170. colorCurves.getColorGradingDataToRef(colorCurves._highlightsHue, colorCurves._highlightsDensity, colorCurves._highlightsSaturation, colorCurves._highlightsExposure, colorCurves._tempColor);
  61171. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._highlightsCurve);
  61172. // Compute midtones info.
  61173. colorCurves.getColorGradingDataToRef(colorCurves._midtonesHue, colorCurves._midtonesDensity, colorCurves._midtonesSaturation, colorCurves._midtonesExposure, colorCurves._tempColor);
  61174. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._midtonesCurve);
  61175. // Compute shadows info.
  61176. colorCurves.getColorGradingDataToRef(colorCurves._shadowsHue, colorCurves._shadowsDensity, colorCurves._shadowsSaturation, colorCurves._shadowsExposure, colorCurves._tempColor);
  61177. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._shadowsCurve);
  61178. // Compute deltas (neutral is midtones).
  61179. colorCurves._highlightsCurve.subtractToRef(colorCurves._midtonesCurve, colorCurves._positiveCurve);
  61180. colorCurves._midtonesCurve.subtractToRef(colorCurves._shadowsCurve, colorCurves._negativeCurve);
  61181. }
  61182. if (effect) {
  61183. effect.setFloat4(positiveUniform, colorCurves._positiveCurve.r, colorCurves._positiveCurve.g, colorCurves._positiveCurve.b, colorCurves._positiveCurve.a);
  61184. effect.setFloat4(neutralUniform, colorCurves._midtonesCurve.r, colorCurves._midtonesCurve.g, colorCurves._midtonesCurve.b, colorCurves._midtonesCurve.a);
  61185. effect.setFloat4(negativeUniform, colorCurves._negativeCurve.r, colorCurves._negativeCurve.g, colorCurves._negativeCurve.b, colorCurves._negativeCurve.a);
  61186. }
  61187. };
  61188. /**
  61189. * Prepare the list of uniforms associated with the ColorCurves effects.
  61190. * @param uniformsList The list of uniforms used in the effect
  61191. */
  61192. ColorCurves.PrepareUniforms = function (uniformsList) {
  61193. uniformsList.push("vCameraColorCurveNeutral", "vCameraColorCurvePositive", "vCameraColorCurveNegative");
  61194. };
  61195. /**
  61196. * Returns color grading data based on a hue, density, saturation and exposure value.
  61197. * @param filterHue The hue of the color filter.
  61198. * @param filterDensity The density of the color filter.
  61199. * @param saturation The saturation.
  61200. * @param exposure The exposure.
  61201. * @param result The result data container.
  61202. */
  61203. ColorCurves.prototype.getColorGradingDataToRef = function (hue, density, saturation, exposure, result) {
  61204. if (hue == null) {
  61205. return;
  61206. }
  61207. hue = ColorCurves.clamp(hue, 0, 360);
  61208. density = ColorCurves.clamp(density, -100, 100);
  61209. saturation = ColorCurves.clamp(saturation, -100, 100);
  61210. exposure = ColorCurves.clamp(exposure, -100, 100);
  61211. // Remap the slider/config filter density with non-linear mapping and also scale by half
  61212. // so that the maximum filter density is only 50% control. This provides fine control
  61213. // for small values and reasonable range.
  61214. density = ColorCurves.applyColorGradingSliderNonlinear(density);
  61215. density *= 0.5;
  61216. exposure = ColorCurves.applyColorGradingSliderNonlinear(exposure);
  61217. if (density < 0) {
  61218. density *= -1;
  61219. hue = (hue + 180) % 360;
  61220. }
  61221. ColorCurves.fromHSBToRef(hue, density, 50 + 0.25 * exposure, result);
  61222. result.scaleToRef(2, result);
  61223. result.a = 1 + 0.01 * saturation;
  61224. };
  61225. /**
  61226. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  61227. * @param value The input slider value in range [-100,100].
  61228. * @returns Adjusted value.
  61229. */
  61230. ColorCurves.applyColorGradingSliderNonlinear = function (value) {
  61231. value /= 100;
  61232. var x = Math.abs(value);
  61233. x = Math.pow(x, 2);
  61234. if (value < 0) {
  61235. x *= -1;
  61236. }
  61237. x *= 100;
  61238. return x;
  61239. };
  61240. /**
  61241. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  61242. * @param hue The hue (H) input.
  61243. * @param saturation The saturation (S) input.
  61244. * @param brightness The brightness (B) input.
  61245. * @result An RGBA color represented as Vector4.
  61246. */
  61247. ColorCurves.fromHSBToRef = function (hue, saturation, brightness, result) {
  61248. var h = ColorCurves.clamp(hue, 0, 360);
  61249. var s = ColorCurves.clamp(saturation / 100, 0, 1);
  61250. var v = ColorCurves.clamp(brightness / 100, 0, 1);
  61251. if (s === 0) {
  61252. result.r = v;
  61253. result.g = v;
  61254. result.b = v;
  61255. }
  61256. else {
  61257. // sector 0 to 5
  61258. h /= 60;
  61259. var i = Math.floor(h);
  61260. // fractional part of h
  61261. var f = h - i;
  61262. var p = v * (1 - s);
  61263. var q = v * (1 - s * f);
  61264. var t = v * (1 - s * (1 - f));
  61265. switch (i) {
  61266. case 0:
  61267. result.r = v;
  61268. result.g = t;
  61269. result.b = p;
  61270. break;
  61271. case 1:
  61272. result.r = q;
  61273. result.g = v;
  61274. result.b = p;
  61275. break;
  61276. case 2:
  61277. result.r = p;
  61278. result.g = v;
  61279. result.b = t;
  61280. break;
  61281. case 3:
  61282. result.r = p;
  61283. result.g = q;
  61284. result.b = v;
  61285. break;
  61286. case 4:
  61287. result.r = t;
  61288. result.g = p;
  61289. result.b = v;
  61290. break;
  61291. default: // case 5:
  61292. result.r = v;
  61293. result.g = p;
  61294. result.b = q;
  61295. break;
  61296. }
  61297. }
  61298. result.a = 1;
  61299. };
  61300. /**
  61301. * Returns a value clamped between min and max
  61302. * @param value The value to clamp
  61303. * @param min The minimum of value
  61304. * @param max The maximum of value
  61305. * @returns The clamped value.
  61306. */
  61307. ColorCurves.clamp = function (value, min, max) {
  61308. return Math.min(Math.max(value, min), max);
  61309. };
  61310. /**
  61311. * Clones the current color curve instance.
  61312. * @return The cloned curves
  61313. */
  61314. ColorCurves.prototype.clone = function () {
  61315. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new ColorCurves(); }, this);
  61316. };
  61317. /**
  61318. * Serializes the current color curve instance to a json representation.
  61319. * @return a JSON representation
  61320. */
  61321. ColorCurves.prototype.serialize = function () {
  61322. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  61323. };
  61324. /**
  61325. * Parses the color curve from a json representation.
  61326. * @param source the JSON source to parse
  61327. * @return The parsed curves
  61328. */
  61329. ColorCurves.Parse = function (source) {
  61330. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ColorCurves(); }, source, null, null);
  61331. };
  61332. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61333. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61334. ], ColorCurves.prototype, "_globalHue", void 0);
  61335. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61336. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61337. ], ColorCurves.prototype, "_globalDensity", void 0);
  61338. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61339. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61340. ], ColorCurves.prototype, "_globalSaturation", void 0);
  61341. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61342. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61343. ], ColorCurves.prototype, "_globalExposure", void 0);
  61344. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61345. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61346. ], ColorCurves.prototype, "_highlightsHue", void 0);
  61347. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61348. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61349. ], ColorCurves.prototype, "_highlightsDensity", void 0);
  61350. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61351. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61352. ], ColorCurves.prototype, "_highlightsSaturation", void 0);
  61353. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61354. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61355. ], ColorCurves.prototype, "_highlightsExposure", void 0);
  61356. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61357. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61358. ], ColorCurves.prototype, "_midtonesHue", void 0);
  61359. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61360. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61361. ], ColorCurves.prototype, "_midtonesDensity", void 0);
  61362. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61363. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61364. ], ColorCurves.prototype, "_midtonesSaturation", void 0);
  61365. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61366. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61367. ], ColorCurves.prototype, "_midtonesExposure", void 0);
  61368. return ColorCurves;
  61369. }());
  61370. // References the dependencies.
  61371. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._ColorCurvesParser = ColorCurves.Parse;
  61372. /***/ }),
  61373. /***/ "./Materials/effect.ts":
  61374. /*!*****************************!*\
  61375. !*** ./Materials/effect.ts ***!
  61376. \*****************************/
  61377. /*! exports provided: EffectFallbacks, EffectCreationOptions, Effect */
  61378. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  61379. "use strict";
  61380. __webpack_require__.r(__webpack_exports__);
  61381. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return EffectFallbacks; });
  61382. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return EffectCreationOptions; });
  61383. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return Effect; });
  61384. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  61385. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  61386. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  61387. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  61388. /**
  61389. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  61390. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  61391. */
  61392. var EffectFallbacks = /** @class */ (function () {
  61393. function EffectFallbacks() {
  61394. this._defines = {};
  61395. this._currentRank = 32;
  61396. this._maxRank = -1;
  61397. }
  61398. /**
  61399. * Removes the fallback from the bound mesh.
  61400. */
  61401. EffectFallbacks.prototype.unBindMesh = function () {
  61402. this._mesh = null;
  61403. };
  61404. /**
  61405. * Adds a fallback on the specified property.
  61406. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  61407. * @param define The name of the define in the shader
  61408. */
  61409. EffectFallbacks.prototype.addFallback = function (rank, define) {
  61410. if (!this._defines[rank]) {
  61411. if (rank < this._currentRank) {
  61412. this._currentRank = rank;
  61413. }
  61414. if (rank > this._maxRank) {
  61415. this._maxRank = rank;
  61416. }
  61417. this._defines[rank] = new Array();
  61418. }
  61419. this._defines[rank].push(define);
  61420. };
  61421. /**
  61422. * Sets the mesh to use CPU skinning when needing to fallback.
  61423. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  61424. * @param mesh The mesh to use the fallbacks.
  61425. */
  61426. EffectFallbacks.prototype.addCPUSkinningFallback = function (rank, mesh) {
  61427. this._mesh = mesh;
  61428. if (rank < this._currentRank) {
  61429. this._currentRank = rank;
  61430. }
  61431. if (rank > this._maxRank) {
  61432. this._maxRank = rank;
  61433. }
  61434. };
  61435. Object.defineProperty(EffectFallbacks.prototype, "isMoreFallbacks", {
  61436. /**
  61437. * Checks to see if more fallbacks are still availible.
  61438. */
  61439. get: function () {
  61440. return this._currentRank <= this._maxRank;
  61441. },
  61442. enumerable: true,
  61443. configurable: true
  61444. });
  61445. /**
  61446. * Removes the defines that shoould be removed when falling back.
  61447. * @param currentDefines defines the current define statements for the shader.
  61448. * @param effect defines the current effect we try to compile
  61449. * @returns The resulting defines with defines of the current rank removed.
  61450. */
  61451. EffectFallbacks.prototype.reduce = function (currentDefines, effect) {
  61452. // First we try to switch to CPU skinning
  61453. if (this._mesh && this._mesh.computeBonesUsingShaders && this._mesh.numBoneInfluencers > 0 && this._mesh.material) {
  61454. this._mesh.computeBonesUsingShaders = false;
  61455. currentDefines = currentDefines.replace("#define NUM_BONE_INFLUENCERS " + this._mesh.numBoneInfluencers, "#define NUM_BONE_INFLUENCERS 0");
  61456. effect._bonesComputationForcedToCPU = true;
  61457. var scene = this._mesh.getScene();
  61458. for (var index = 0; index < scene.meshes.length; index++) {
  61459. var otherMesh = scene.meshes[index];
  61460. if (!otherMesh.material) {
  61461. continue;
  61462. }
  61463. if (!otherMesh.computeBonesUsingShaders || otherMesh.numBoneInfluencers === 0) {
  61464. continue;
  61465. }
  61466. if (otherMesh.material.getEffect() === effect) {
  61467. otherMesh.computeBonesUsingShaders = false;
  61468. }
  61469. else if (otherMesh.subMeshes) {
  61470. for (var _i = 0, _a = otherMesh.subMeshes; _i < _a.length; _i++) {
  61471. var subMesh = _a[_i];
  61472. var subMeshEffect = subMesh.effect;
  61473. if (subMeshEffect === effect) {
  61474. otherMesh.computeBonesUsingShaders = false;
  61475. break;
  61476. }
  61477. }
  61478. }
  61479. }
  61480. }
  61481. else {
  61482. var currentFallbacks = this._defines[this._currentRank];
  61483. if (currentFallbacks) {
  61484. for (var index = 0; index < currentFallbacks.length; index++) {
  61485. currentDefines = currentDefines.replace("#define " + currentFallbacks[index], "");
  61486. }
  61487. }
  61488. this._currentRank++;
  61489. }
  61490. return currentDefines;
  61491. };
  61492. return EffectFallbacks;
  61493. }());
  61494. /**
  61495. * Options to be used when creating an effect.
  61496. */
  61497. var EffectCreationOptions = /** @class */ (function () {
  61498. function EffectCreationOptions() {
  61499. }
  61500. return EffectCreationOptions;
  61501. }());
  61502. /**
  61503. * Effect containing vertex and fragment shader that can be executed on an object.
  61504. */
  61505. var Effect = /** @class */ (function () {
  61506. /**
  61507. * Instantiates an effect.
  61508. * An effect can be used to create/manage/execute vertex and fragment shaders.
  61509. * @param baseName Name of the effect.
  61510. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  61511. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  61512. * @param samplers List of sampler variables that will be passed to the shader.
  61513. * @param engine Engine to be used to render the effect
  61514. * @param defines Define statements to be added to the shader.
  61515. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  61516. * @param onCompiled Callback that will be called when the shader is compiled.
  61517. * @param onError Callback that will be called if an error occurs during shader compilation.
  61518. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  61519. */
  61520. function Effect(baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, engine, defines, fallbacks, onCompiled, onError, indexParameters) {
  61521. if (samplers === void 0) { samplers = null; }
  61522. if (defines === void 0) { defines = null; }
  61523. if (fallbacks === void 0) { fallbacks = null; }
  61524. if (onCompiled === void 0) { onCompiled = null; }
  61525. if (onError === void 0) { onError = null; }
  61526. var _this = this;
  61527. /**
  61528. * Unique ID of the effect.
  61529. */
  61530. this.uniqueId = 0;
  61531. /**
  61532. * Observable that will be called when the shader is compiled.
  61533. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  61534. */
  61535. this.onCompileObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  61536. /**
  61537. * Observable that will be called if an error occurs during shader compilation.
  61538. */
  61539. this.onErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  61540. /** @hidden */
  61541. this._bonesComputationForcedToCPU = false;
  61542. this._uniformBuffersNames = {};
  61543. this._isReady = false;
  61544. this._compilationError = "";
  61545. this.name = baseName;
  61546. if (attributesNamesOrOptions.attributes) {
  61547. var options = attributesNamesOrOptions;
  61548. this._engine = uniformsNamesOrEngine;
  61549. this._attributesNames = options.attributes;
  61550. this._uniformsNames = options.uniformsNames.concat(options.samplers);
  61551. this._samplers = options.samplers.slice();
  61552. this.defines = options.defines;
  61553. this.onError = options.onError;
  61554. this.onCompiled = options.onCompiled;
  61555. this._fallbacks = options.fallbacks;
  61556. this._indexParameters = options.indexParameters;
  61557. this._transformFeedbackVaryings = options.transformFeedbackVaryings;
  61558. if (options.uniformBuffersNames) {
  61559. for (var i = 0; i < options.uniformBuffersNames.length; i++) {
  61560. this._uniformBuffersNames[options.uniformBuffersNames[i]] = i;
  61561. }
  61562. }
  61563. }
  61564. else {
  61565. this._engine = engine;
  61566. this.defines = defines;
  61567. this._uniformsNames = uniformsNamesOrEngine.concat(samplers);
  61568. this._samplers = samplers ? samplers.slice() : [];
  61569. this._attributesNames = attributesNamesOrOptions;
  61570. this.onError = onError;
  61571. this.onCompiled = onCompiled;
  61572. this._indexParameters = indexParameters;
  61573. this._fallbacks = fallbacks;
  61574. }
  61575. this.uniqueId = Effect._uniqueIdSeed++;
  61576. var vertexSource;
  61577. var fragmentSource;
  61578. if (baseName.vertexElement) {
  61579. vertexSource = document.getElementById(baseName.vertexElement);
  61580. if (!vertexSource) {
  61581. vertexSource = baseName.vertexElement;
  61582. }
  61583. }
  61584. else {
  61585. vertexSource = baseName.vertex || baseName;
  61586. }
  61587. if (baseName.fragmentElement) {
  61588. fragmentSource = document.getElementById(baseName.fragmentElement);
  61589. if (!fragmentSource) {
  61590. fragmentSource = baseName.fragmentElement;
  61591. }
  61592. }
  61593. else {
  61594. fragmentSource = baseName.fragment || baseName;
  61595. }
  61596. this._loadVertexShader(vertexSource, function (vertexCode) {
  61597. _this._processIncludes(vertexCode, function (vertexCodeWithIncludes) {
  61598. _this._processShaderConversion(vertexCodeWithIncludes, false, function (migratedVertexCode) {
  61599. _this._loadFragmentShader(fragmentSource, function (fragmentCode) {
  61600. _this._processIncludes(fragmentCode, function (fragmentCodeWithIncludes) {
  61601. _this._processShaderConversion(fragmentCodeWithIncludes, true, function (migratedFragmentCode) {
  61602. if (baseName) {
  61603. var vertex = baseName.vertexElement || baseName.vertex || baseName;
  61604. var fragment = baseName.fragmentElement || baseName.fragment || baseName;
  61605. _this._vertexSourceCode = "#define SHADER_NAME vertex:" + vertex + "\n" + migratedVertexCode;
  61606. _this._fragmentSourceCode = "#define SHADER_NAME fragment:" + fragment + "\n" + migratedFragmentCode;
  61607. }
  61608. else {
  61609. _this._vertexSourceCode = migratedVertexCode;
  61610. _this._fragmentSourceCode = migratedFragmentCode;
  61611. }
  61612. _this._prepareEffect();
  61613. });
  61614. });
  61615. });
  61616. });
  61617. });
  61618. });
  61619. }
  61620. Object.defineProperty(Effect.prototype, "onBindObservable", {
  61621. /**
  61622. * Observable that will be called when effect is bound.
  61623. */
  61624. get: function () {
  61625. if (!this._onBindObservable) {
  61626. this._onBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  61627. }
  61628. return this._onBindObservable;
  61629. },
  61630. enumerable: true,
  61631. configurable: true
  61632. });
  61633. Object.defineProperty(Effect.prototype, "key", {
  61634. /**
  61635. * Unique key for this effect
  61636. */
  61637. get: function () {
  61638. return this._key;
  61639. },
  61640. enumerable: true,
  61641. configurable: true
  61642. });
  61643. /**
  61644. * If the effect has been compiled and prepared.
  61645. * @returns if the effect is compiled and prepared.
  61646. */
  61647. Effect.prototype.isReady = function () {
  61648. if (!this._isReady && this._program && this._program.isParallelCompiled) {
  61649. return this._engine._isProgramCompiled(this._program);
  61650. }
  61651. return this._isReady;
  61652. };
  61653. /**
  61654. * The engine the effect was initialized with.
  61655. * @returns the engine.
  61656. */
  61657. Effect.prototype.getEngine = function () {
  61658. return this._engine;
  61659. };
  61660. /**
  61661. * The compiled webGL program for the effect
  61662. * @returns the webGL program.
  61663. */
  61664. Effect.prototype.getProgram = function () {
  61665. return this._program;
  61666. };
  61667. /**
  61668. * The set of names of attribute variables for the shader.
  61669. * @returns An array of attribute names.
  61670. */
  61671. Effect.prototype.getAttributesNames = function () {
  61672. return this._attributesNames;
  61673. };
  61674. /**
  61675. * Returns the attribute at the given index.
  61676. * @param index The index of the attribute.
  61677. * @returns The location of the attribute.
  61678. */
  61679. Effect.prototype.getAttributeLocation = function (index) {
  61680. return this._attributes[index];
  61681. };
  61682. /**
  61683. * Returns the attribute based on the name of the variable.
  61684. * @param name of the attribute to look up.
  61685. * @returns the attribute location.
  61686. */
  61687. Effect.prototype.getAttributeLocationByName = function (name) {
  61688. var index = this._attributesNames.indexOf(name);
  61689. return this._attributes[index];
  61690. };
  61691. /**
  61692. * The number of attributes.
  61693. * @returns the numnber of attributes.
  61694. */
  61695. Effect.prototype.getAttributesCount = function () {
  61696. return this._attributes.length;
  61697. };
  61698. /**
  61699. * Gets the index of a uniform variable.
  61700. * @param uniformName of the uniform to look up.
  61701. * @returns the index.
  61702. */
  61703. Effect.prototype.getUniformIndex = function (uniformName) {
  61704. return this._uniformsNames.indexOf(uniformName);
  61705. };
  61706. /**
  61707. * Returns the attribute based on the name of the variable.
  61708. * @param uniformName of the uniform to look up.
  61709. * @returns the location of the uniform.
  61710. */
  61711. Effect.prototype.getUniform = function (uniformName) {
  61712. return this._uniforms[this._uniformsNames.indexOf(uniformName)];
  61713. };
  61714. /**
  61715. * Returns an array of sampler variable names
  61716. * @returns The array of sampler variable neames.
  61717. */
  61718. Effect.prototype.getSamplers = function () {
  61719. return this._samplers;
  61720. };
  61721. /**
  61722. * The error from the last compilation.
  61723. * @returns the error string.
  61724. */
  61725. Effect.prototype.getCompilationError = function () {
  61726. return this._compilationError;
  61727. };
  61728. /**
  61729. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  61730. * @param func The callback to be used.
  61731. */
  61732. Effect.prototype.executeWhenCompiled = function (func) {
  61733. var _this = this;
  61734. if (this.isReady()) {
  61735. func(this);
  61736. return;
  61737. }
  61738. this.onCompileObservable.add(function (effect) {
  61739. func(effect);
  61740. });
  61741. if (!this._program || this._program.isParallelCompiled) {
  61742. setTimeout(function () {
  61743. _this._checkIsReady();
  61744. }, 16);
  61745. }
  61746. };
  61747. Effect.prototype._checkIsReady = function () {
  61748. var _this = this;
  61749. if (this.isReady()) {
  61750. return;
  61751. }
  61752. setTimeout(function () {
  61753. _this._checkIsReady();
  61754. }, 16);
  61755. };
  61756. /** @hidden */
  61757. Effect.prototype._loadVertexShader = function (vertex, callback) {
  61758. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  61759. // DOM element ?
  61760. if (vertex instanceof HTMLElement) {
  61761. var vertexCode = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].GetDOMTextContent(vertex);
  61762. callback(vertexCode);
  61763. return;
  61764. }
  61765. }
  61766. // Base64 encoded ?
  61767. if (vertex.substr(0, 7) === "base64:") {
  61768. var vertexBinary = window.atob(vertex.substr(7));
  61769. callback(vertexBinary);
  61770. return;
  61771. }
  61772. // Is in local store ?
  61773. if (Effect.ShadersStore[vertex + "VertexShader"]) {
  61774. callback(Effect.ShadersStore[vertex + "VertexShader"]);
  61775. return;
  61776. }
  61777. var vertexShaderUrl;
  61778. if (vertex[0] === "." || vertex[0] === "/" || vertex.indexOf("http") > -1) {
  61779. vertexShaderUrl = vertex;
  61780. }
  61781. else {
  61782. vertexShaderUrl = Effect.ShadersRepository + vertex;
  61783. }
  61784. // Vertex shader
  61785. this._engine._loadFile(vertexShaderUrl + ".vertex.fx", callback);
  61786. };
  61787. /** @hidden */
  61788. Effect.prototype._loadFragmentShader = function (fragment, callback) {
  61789. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  61790. // DOM element ?
  61791. if (fragment instanceof HTMLElement) {
  61792. var fragmentCode = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].GetDOMTextContent(fragment);
  61793. callback(fragmentCode);
  61794. return;
  61795. }
  61796. }
  61797. // Base64 encoded ?
  61798. if (fragment.substr(0, 7) === "base64:") {
  61799. var fragmentBinary = window.atob(fragment.substr(7));
  61800. callback(fragmentBinary);
  61801. return;
  61802. }
  61803. // Is in local store ?
  61804. if (Effect.ShadersStore[fragment + "PixelShader"]) {
  61805. callback(Effect.ShadersStore[fragment + "PixelShader"]);
  61806. return;
  61807. }
  61808. if (Effect.ShadersStore[fragment + "FragmentShader"]) {
  61809. callback(Effect.ShadersStore[fragment + "FragmentShader"]);
  61810. return;
  61811. }
  61812. var fragmentShaderUrl;
  61813. if (fragment[0] === "." || fragment[0] === "/" || fragment.indexOf("http") > -1) {
  61814. fragmentShaderUrl = fragment;
  61815. }
  61816. else {
  61817. fragmentShaderUrl = Effect.ShadersRepository + fragment;
  61818. }
  61819. // Fragment shader
  61820. this._engine._loadFile(fragmentShaderUrl + ".fragment.fx", callback);
  61821. };
  61822. /** @hidden */
  61823. Effect.prototype._dumpShadersSource = function (vertexCode, fragmentCode, defines) {
  61824. // Rebuild shaders source code
  61825. var shaderVersion = (this._engine.webGLVersion > 1) ? "#version 300 es\n#define WEBGL2 \n" : "";
  61826. var prefix = shaderVersion + (defines ? defines + "\n" : "");
  61827. vertexCode = prefix + vertexCode;
  61828. fragmentCode = prefix + fragmentCode;
  61829. // Number lines of shaders source code
  61830. var i = 2;
  61831. var regex = /\n/gm;
  61832. var formattedVertexCode = "\n1\t" + vertexCode.replace(regex, function () { return "\n" + (i++) + "\t"; });
  61833. i = 2;
  61834. var formattedFragmentCode = "\n1\t" + fragmentCode.replace(regex, function () { return "\n" + (i++) + "\t"; });
  61835. // Dump shaders name and formatted source code
  61836. if (this.name.vertexElement) {
  61837. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name.vertexElement + formattedVertexCode);
  61838. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name.fragmentElement + formattedFragmentCode);
  61839. }
  61840. else if (this.name.vertex) {
  61841. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name.vertex + formattedVertexCode);
  61842. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name.fragment + formattedFragmentCode);
  61843. }
  61844. else {
  61845. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name + formattedVertexCode);
  61846. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name + formattedFragmentCode);
  61847. }
  61848. };
  61849. Effect.prototype._processShaderConversion = function (sourceCode, isFragment, callback) {
  61850. var preparedSourceCode = this._processPrecision(sourceCode);
  61851. if (this._engine.webGLVersion == 1) {
  61852. callback(preparedSourceCode);
  61853. return;
  61854. }
  61855. // Already converted
  61856. if (preparedSourceCode.indexOf("#version 3") !== -1) {
  61857. callback(preparedSourceCode.replace("#version 300 es", ""));
  61858. return;
  61859. }
  61860. var hasDrawBuffersExtension = preparedSourceCode.search(/#extension.+GL_EXT_draw_buffers.+require/) !== -1;
  61861. // Remove extensions
  61862. // #extension GL_OES_standard_derivatives : enable
  61863. // #extension GL_EXT_shader_texture_lod : enable
  61864. // #extension GL_EXT_frag_depth : enable
  61865. // #extension GL_EXT_draw_buffers : require
  61866. var regex = /#extension.+(GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g;
  61867. var result = preparedSourceCode.replace(regex, "");
  61868. // Migrate to GLSL v300
  61869. result = result.replace(/varying(?![\n\r])\s/g, isFragment ? "in " : "out ");
  61870. result = result.replace(/attribute[ \t]/g, "in ");
  61871. result = result.replace(/[ \t]attribute/g, " in");
  61872. result = result.replace(/texture2D\s*\(/g, "texture(");
  61873. if (isFragment) {
  61874. result = result.replace(/texture2DLodEXT\s*\(/g, "textureLod(");
  61875. result = result.replace(/textureCubeLodEXT\s*\(/g, "textureLod(");
  61876. result = result.replace(/textureCube\s*\(/g, "texture(");
  61877. result = result.replace(/gl_FragDepthEXT/g, "gl_FragDepth");
  61878. result = result.replace(/gl_FragColor/g, "glFragColor");
  61879. result = result.replace(/gl_FragData/g, "glFragData");
  61880. result = result.replace(/void\s+?main\s*\(/g, (hasDrawBuffersExtension ? "" : "out vec4 glFragColor;\n") + "void main(");
  61881. }
  61882. callback(result);
  61883. };
  61884. Effect.prototype._processIncludes = function (sourceCode, callback) {
  61885. var _this = this;
  61886. var regex = /#include<(.+)>(\((.*)\))*(\[(.*)\])*/g;
  61887. var match = regex.exec(sourceCode);
  61888. var returnValue = new String(sourceCode);
  61889. while (match != null) {
  61890. var includeFile = match[1];
  61891. // Uniform declaration
  61892. if (includeFile.indexOf("__decl__") !== -1) {
  61893. includeFile = includeFile.replace(/__decl__/, "");
  61894. if (this._engine.supportsUniformBuffers) {
  61895. includeFile = includeFile.replace(/Vertex/, "Ubo");
  61896. includeFile = includeFile.replace(/Fragment/, "Ubo");
  61897. }
  61898. includeFile = includeFile + "Declaration";
  61899. }
  61900. if (Effect.IncludesShadersStore[includeFile]) {
  61901. // Substitution
  61902. var includeContent = Effect.IncludesShadersStore[includeFile];
  61903. if (match[2]) {
  61904. var splits = match[3].split(",");
  61905. for (var index = 0; index < splits.length; index += 2) {
  61906. var source = new RegExp(splits[index], "g");
  61907. var dest = splits[index + 1];
  61908. includeContent = includeContent.replace(source, dest);
  61909. }
  61910. }
  61911. if (match[4]) {
  61912. var indexString = match[5];
  61913. if (indexString.indexOf("..") !== -1) {
  61914. var indexSplits = indexString.split("..");
  61915. var minIndex = parseInt(indexSplits[0]);
  61916. var maxIndex = parseInt(indexSplits[1]);
  61917. var sourceIncludeContent = includeContent.slice(0);
  61918. includeContent = "";
  61919. if (isNaN(maxIndex)) {
  61920. maxIndex = this._indexParameters[indexSplits[1]];
  61921. }
  61922. for (var i = minIndex; i < maxIndex; i++) {
  61923. if (!this._engine.supportsUniformBuffers) {
  61924. // Ubo replacement
  61925. sourceIncludeContent = sourceIncludeContent.replace(/light\{X\}.(\w*)/g, function (str, p1) {
  61926. return p1 + "{X}";
  61927. });
  61928. }
  61929. includeContent += sourceIncludeContent.replace(/\{X\}/g, i.toString()) + "\n";
  61930. }
  61931. }
  61932. else {
  61933. if (!this._engine.supportsUniformBuffers) {
  61934. // Ubo replacement
  61935. includeContent = includeContent.replace(/light\{X\}.(\w*)/g, function (str, p1) {
  61936. return p1 + "{X}";
  61937. });
  61938. }
  61939. includeContent = includeContent.replace(/\{X\}/g, indexString);
  61940. }
  61941. }
  61942. // Replace
  61943. returnValue = returnValue.replace(match[0], includeContent);
  61944. }
  61945. else {
  61946. var includeShaderUrl = Effect.ShadersRepository + "ShadersInclude/" + includeFile + ".fx";
  61947. this._engine._loadFile(includeShaderUrl, function (fileContent) {
  61948. Effect.IncludesShadersStore[includeFile] = fileContent;
  61949. _this._processIncludes(returnValue, callback);
  61950. });
  61951. return;
  61952. }
  61953. match = regex.exec(sourceCode);
  61954. }
  61955. callback(returnValue);
  61956. };
  61957. Effect.prototype._processPrecision = function (source) {
  61958. if (source.indexOf("precision highp float") === -1) {
  61959. if (!this._engine.getCaps().highPrecisionShaderSupported) {
  61960. source = "precision mediump float;\n" + source;
  61961. }
  61962. else {
  61963. source = "precision highp float;\n" + source;
  61964. }
  61965. }
  61966. else {
  61967. if (!this._engine.getCaps().highPrecisionShaderSupported) { // Moving highp to mediump
  61968. source = source.replace("precision highp float", "precision mediump float");
  61969. }
  61970. }
  61971. return source;
  61972. };
  61973. /**
  61974. * Recompiles the webGL program
  61975. * @param vertexSourceCode The source code for the vertex shader.
  61976. * @param fragmentSourceCode The source code for the fragment shader.
  61977. * @param onCompiled Callback called when completed.
  61978. * @param onError Callback called on error.
  61979. * @hidden
  61980. */
  61981. Effect.prototype._rebuildProgram = function (vertexSourceCode, fragmentSourceCode, onCompiled, onError) {
  61982. var _this = this;
  61983. this._isReady = false;
  61984. this._vertexSourceCodeOverride = vertexSourceCode;
  61985. this._fragmentSourceCodeOverride = fragmentSourceCode;
  61986. this.onError = function (effect, error) {
  61987. if (onError) {
  61988. onError(error);
  61989. }
  61990. };
  61991. this.onCompiled = function () {
  61992. var scenes = _this.getEngine().scenes;
  61993. for (var i = 0; i < scenes.length; i++) {
  61994. scenes[i].markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_AllDirtyFlag);
  61995. }
  61996. if (onCompiled) {
  61997. onCompiled(_this._program);
  61998. }
  61999. };
  62000. this._fallbacks = null;
  62001. this._prepareEffect();
  62002. };
  62003. /**
  62004. * Gets the uniform locations of the the specified variable names
  62005. * @param names THe names of the variables to lookup.
  62006. * @returns Array of locations in the same order as variable names.
  62007. */
  62008. Effect.prototype.getSpecificUniformLocations = function (names) {
  62009. var engine = this._engine;
  62010. return engine.getUniforms(this._program, names);
  62011. };
  62012. /**
  62013. * Prepares the effect
  62014. * @hidden
  62015. */
  62016. Effect.prototype._prepareEffect = function () {
  62017. var _this = this;
  62018. var attributesNames = this._attributesNames;
  62019. var defines = this.defines;
  62020. var fallbacks = this._fallbacks;
  62021. this._valueCache = {};
  62022. var previousProgram = this._program;
  62023. try {
  62024. var engine_1 = this._engine;
  62025. if (this._vertexSourceCodeOverride && this._fragmentSourceCodeOverride) {
  62026. this._program = engine_1.createRawShaderProgram(this._vertexSourceCodeOverride, this._fragmentSourceCodeOverride, undefined, this._transformFeedbackVaryings);
  62027. }
  62028. else {
  62029. this._program = engine_1.createShaderProgram(this._vertexSourceCode, this._fragmentSourceCode, defines, undefined, this._transformFeedbackVaryings);
  62030. }
  62031. this._program.__SPECTOR_rebuildProgram = this._rebuildProgram.bind(this);
  62032. engine_1._executeWhenProgramIsCompiled(this._program, function () {
  62033. if (engine_1.supportsUniformBuffers) {
  62034. for (var name in _this._uniformBuffersNames) {
  62035. _this.bindUniformBlock(name, _this._uniformBuffersNames[name]);
  62036. }
  62037. }
  62038. _this._uniforms = engine_1.getUniforms(_this._program, _this._uniformsNames);
  62039. _this._attributes = engine_1.getAttributes(_this._program, attributesNames);
  62040. var index;
  62041. for (index = 0; index < _this._samplers.length; index++) {
  62042. var sampler = _this.getUniform(_this._samplers[index]);
  62043. if (sampler == null) {
  62044. _this._samplers.splice(index, 1);
  62045. index--;
  62046. }
  62047. }
  62048. engine_1.bindSamplers(_this);
  62049. _this._compilationError = "";
  62050. _this._isReady = true;
  62051. if (_this.onCompiled) {
  62052. _this.onCompiled(_this);
  62053. }
  62054. _this.onCompileObservable.notifyObservers(_this);
  62055. _this.onCompileObservable.clear();
  62056. // Unbind mesh reference in fallbacks
  62057. if (_this._fallbacks) {
  62058. _this._fallbacks.unBindMesh();
  62059. }
  62060. if (previousProgram) {
  62061. _this.getEngine()._deleteProgram(previousProgram);
  62062. }
  62063. });
  62064. if (this._program.isParallelCompiled) {
  62065. this._checkIsReady();
  62066. }
  62067. }
  62068. catch (e) {
  62069. this._compilationError = e.message;
  62070. // Let's go through fallbacks then
  62071. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Unable to compile effect:");
  62072. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Uniforms: " + this._uniformsNames.map(function (uniform) {
  62073. return " " + uniform;
  62074. }));
  62075. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Attributes: " + attributesNames.map(function (attribute) {
  62076. return " " + attribute;
  62077. }));
  62078. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Error: " + this._compilationError);
  62079. if (previousProgram) {
  62080. this._program = previousProgram;
  62081. this._isReady = true;
  62082. if (this.onError) {
  62083. this.onError(this, this._compilationError);
  62084. }
  62085. this.onErrorObservable.notifyObservers(this);
  62086. }
  62087. if (fallbacks && fallbacks.isMoreFallbacks) {
  62088. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Trying next fallback.");
  62089. this.defines = fallbacks.reduce(this.defines, this);
  62090. this._prepareEffect();
  62091. }
  62092. else { // Sorry we did everything we can
  62093. if (this.onError) {
  62094. this.onError(this, this._compilationError);
  62095. }
  62096. this.onErrorObservable.notifyObservers(this);
  62097. this.onErrorObservable.clear();
  62098. // Unbind mesh reference in fallbacks
  62099. if (this._fallbacks) {
  62100. this._fallbacks.unBindMesh();
  62101. }
  62102. }
  62103. }
  62104. };
  62105. Object.defineProperty(Effect.prototype, "isSupported", {
  62106. /**
  62107. * Checks if the effect is supported. (Must be called after compilation)
  62108. */
  62109. get: function () {
  62110. return this._compilationError === "";
  62111. },
  62112. enumerable: true,
  62113. configurable: true
  62114. });
  62115. /**
  62116. * Binds a texture to the engine to be used as output of the shader.
  62117. * @param channel Name of the output variable.
  62118. * @param texture Texture to bind.
  62119. * @hidden
  62120. */
  62121. Effect.prototype._bindTexture = function (channel, texture) {
  62122. this._engine._bindTexture(this._samplers.indexOf(channel), texture);
  62123. };
  62124. /**
  62125. * Sets a texture on the engine to be used in the shader.
  62126. * @param channel Name of the sampler variable.
  62127. * @param texture Texture to set.
  62128. */
  62129. Effect.prototype.setTexture = function (channel, texture) {
  62130. this._engine.setTexture(this._samplers.indexOf(channel), this.getUniform(channel), texture);
  62131. };
  62132. /**
  62133. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  62134. * @param channel Name of the sampler variable.
  62135. * @param texture Texture to set.
  62136. */
  62137. Effect.prototype.setDepthStencilTexture = function (channel, texture) {
  62138. this._engine.setDepthStencilTexture(this._samplers.indexOf(channel), this.getUniform(channel), texture);
  62139. };
  62140. /**
  62141. * Sets an array of textures on the engine to be used in the shader.
  62142. * @param channel Name of the variable.
  62143. * @param textures Textures to set.
  62144. */
  62145. Effect.prototype.setTextureArray = function (channel, textures) {
  62146. if (this._samplers.indexOf(channel + "Ex") === -1) {
  62147. var initialPos = this._samplers.indexOf(channel);
  62148. for (var index = 1; index < textures.length; index++) {
  62149. this._samplers.splice(initialPos + index, 0, channel + "Ex");
  62150. }
  62151. }
  62152. this._engine.setTextureArray(this._samplers.indexOf(channel), this.getUniform(channel), textures);
  62153. };
  62154. /**
  62155. * 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)
  62156. * @param channel Name of the sampler variable.
  62157. * @param postProcess Post process to get the input texture from.
  62158. */
  62159. Effect.prototype.setTextureFromPostProcess = function (channel, postProcess) {
  62160. this._engine.setTextureFromPostProcess(this._samplers.indexOf(channel), postProcess);
  62161. };
  62162. /**
  62163. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  62164. * 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)
  62165. * @param channel Name of the sampler variable.
  62166. * @param postProcess Post process to get the output texture from.
  62167. */
  62168. Effect.prototype.setTextureFromPostProcessOutput = function (channel, postProcess) {
  62169. this._engine.setTextureFromPostProcessOutput(this._samplers.indexOf(channel), postProcess);
  62170. };
  62171. /** @hidden */
  62172. Effect.prototype._cacheMatrix = function (uniformName, matrix) {
  62173. var cache = this._valueCache[uniformName];
  62174. var flag = matrix.updateFlag;
  62175. if (cache !== undefined && cache === flag) {
  62176. return false;
  62177. }
  62178. this._valueCache[uniformName] = flag;
  62179. return true;
  62180. };
  62181. /** @hidden */
  62182. Effect.prototype._cacheFloat2 = function (uniformName, x, y) {
  62183. var cache = this._valueCache[uniformName];
  62184. if (!cache) {
  62185. cache = [x, y];
  62186. this._valueCache[uniformName] = cache;
  62187. return true;
  62188. }
  62189. var changed = false;
  62190. if (cache[0] !== x) {
  62191. cache[0] = x;
  62192. changed = true;
  62193. }
  62194. if (cache[1] !== y) {
  62195. cache[1] = y;
  62196. changed = true;
  62197. }
  62198. return changed;
  62199. };
  62200. /** @hidden */
  62201. Effect.prototype._cacheFloat3 = function (uniformName, x, y, z) {
  62202. var cache = this._valueCache[uniformName];
  62203. if (!cache) {
  62204. cache = [x, y, z];
  62205. this._valueCache[uniformName] = cache;
  62206. return true;
  62207. }
  62208. var changed = false;
  62209. if (cache[0] !== x) {
  62210. cache[0] = x;
  62211. changed = true;
  62212. }
  62213. if (cache[1] !== y) {
  62214. cache[1] = y;
  62215. changed = true;
  62216. }
  62217. if (cache[2] !== z) {
  62218. cache[2] = z;
  62219. changed = true;
  62220. }
  62221. return changed;
  62222. };
  62223. /** @hidden */
  62224. Effect.prototype._cacheFloat4 = function (uniformName, x, y, z, w) {
  62225. var cache = this._valueCache[uniformName];
  62226. if (!cache) {
  62227. cache = [x, y, z, w];
  62228. this._valueCache[uniformName] = cache;
  62229. return true;
  62230. }
  62231. var changed = false;
  62232. if (cache[0] !== x) {
  62233. cache[0] = x;
  62234. changed = true;
  62235. }
  62236. if (cache[1] !== y) {
  62237. cache[1] = y;
  62238. changed = true;
  62239. }
  62240. if (cache[2] !== z) {
  62241. cache[2] = z;
  62242. changed = true;
  62243. }
  62244. if (cache[3] !== w) {
  62245. cache[3] = w;
  62246. changed = true;
  62247. }
  62248. return changed;
  62249. };
  62250. /**
  62251. * Binds a buffer to a uniform.
  62252. * @param buffer Buffer to bind.
  62253. * @param name Name of the uniform variable to bind to.
  62254. */
  62255. Effect.prototype.bindUniformBuffer = function (buffer, name) {
  62256. var bufferName = this._uniformBuffersNames[name];
  62257. if (bufferName === undefined || Effect._baseCache[bufferName] === buffer) {
  62258. return;
  62259. }
  62260. Effect._baseCache[bufferName] = buffer;
  62261. this._engine.bindUniformBufferBase(buffer, bufferName);
  62262. };
  62263. /**
  62264. * Binds block to a uniform.
  62265. * @param blockName Name of the block to bind.
  62266. * @param index Index to bind.
  62267. */
  62268. Effect.prototype.bindUniformBlock = function (blockName, index) {
  62269. this._engine.bindUniformBlock(this._program, blockName, index);
  62270. };
  62271. /**
  62272. * Sets an interger value on a uniform variable.
  62273. * @param uniformName Name of the variable.
  62274. * @param value Value to be set.
  62275. * @returns this effect.
  62276. */
  62277. Effect.prototype.setInt = function (uniformName, value) {
  62278. var cache = this._valueCache[uniformName];
  62279. if (cache !== undefined && cache === value) {
  62280. return this;
  62281. }
  62282. this._valueCache[uniformName] = value;
  62283. this._engine.setInt(this.getUniform(uniformName), value);
  62284. return this;
  62285. };
  62286. /**
  62287. * Sets an int array on a uniform variable.
  62288. * @param uniformName Name of the variable.
  62289. * @param array array to be set.
  62290. * @returns this effect.
  62291. */
  62292. Effect.prototype.setIntArray = function (uniformName, array) {
  62293. this._valueCache[uniformName] = null;
  62294. this._engine.setIntArray(this.getUniform(uniformName), array);
  62295. return this;
  62296. };
  62297. /**
  62298. * 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)
  62299. * @param uniformName Name of the variable.
  62300. * @param array array to be set.
  62301. * @returns this effect.
  62302. */
  62303. Effect.prototype.setIntArray2 = function (uniformName, array) {
  62304. this._valueCache[uniformName] = null;
  62305. this._engine.setIntArray2(this.getUniform(uniformName), array);
  62306. return this;
  62307. };
  62308. /**
  62309. * 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)
  62310. * @param uniformName Name of the variable.
  62311. * @param array array to be set.
  62312. * @returns this effect.
  62313. */
  62314. Effect.prototype.setIntArray3 = function (uniformName, array) {
  62315. this._valueCache[uniformName] = null;
  62316. this._engine.setIntArray3(this.getUniform(uniformName), array);
  62317. return this;
  62318. };
  62319. /**
  62320. * 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)
  62321. * @param uniformName Name of the variable.
  62322. * @param array array to be set.
  62323. * @returns this effect.
  62324. */
  62325. Effect.prototype.setIntArray4 = function (uniformName, array) {
  62326. this._valueCache[uniformName] = null;
  62327. this._engine.setIntArray4(this.getUniform(uniformName), array);
  62328. return this;
  62329. };
  62330. /**
  62331. * Sets an float array on a uniform variable.
  62332. * @param uniformName Name of the variable.
  62333. * @param array array to be set.
  62334. * @returns this effect.
  62335. */
  62336. Effect.prototype.setFloatArray = function (uniformName, array) {
  62337. this._valueCache[uniformName] = null;
  62338. this._engine.setFloatArray(this.getUniform(uniformName), array);
  62339. return this;
  62340. };
  62341. /**
  62342. * 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)
  62343. * @param uniformName Name of the variable.
  62344. * @param array array to be set.
  62345. * @returns this effect.
  62346. */
  62347. Effect.prototype.setFloatArray2 = function (uniformName, array) {
  62348. this._valueCache[uniformName] = null;
  62349. this._engine.setFloatArray2(this.getUniform(uniformName), array);
  62350. return this;
  62351. };
  62352. /**
  62353. * 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)
  62354. * @param uniformName Name of the variable.
  62355. * @param array array to be set.
  62356. * @returns this effect.
  62357. */
  62358. Effect.prototype.setFloatArray3 = function (uniformName, array) {
  62359. this._valueCache[uniformName] = null;
  62360. this._engine.setFloatArray3(this.getUniform(uniformName), array);
  62361. return this;
  62362. };
  62363. /**
  62364. * 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)
  62365. * @param uniformName Name of the variable.
  62366. * @param array array to be set.
  62367. * @returns this effect.
  62368. */
  62369. Effect.prototype.setFloatArray4 = function (uniformName, array) {
  62370. this._valueCache[uniformName] = null;
  62371. this._engine.setFloatArray4(this.getUniform(uniformName), array);
  62372. return this;
  62373. };
  62374. /**
  62375. * Sets an array on a uniform variable.
  62376. * @param uniformName Name of the variable.
  62377. * @param array array to be set.
  62378. * @returns this effect.
  62379. */
  62380. Effect.prototype.setArray = function (uniformName, array) {
  62381. this._valueCache[uniformName] = null;
  62382. this._engine.setArray(this.getUniform(uniformName), array);
  62383. return this;
  62384. };
  62385. /**
  62386. * 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)
  62387. * @param uniformName Name of the variable.
  62388. * @param array array to be set.
  62389. * @returns this effect.
  62390. */
  62391. Effect.prototype.setArray2 = function (uniformName, array) {
  62392. this._valueCache[uniformName] = null;
  62393. this._engine.setArray2(this.getUniform(uniformName), array);
  62394. return this;
  62395. };
  62396. /**
  62397. * 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)
  62398. * @param uniformName Name of the variable.
  62399. * @param array array to be set.
  62400. * @returns this effect.
  62401. */
  62402. Effect.prototype.setArray3 = function (uniformName, array) {
  62403. this._valueCache[uniformName] = null;
  62404. this._engine.setArray3(this.getUniform(uniformName), array);
  62405. return this;
  62406. };
  62407. /**
  62408. * 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)
  62409. * @param uniformName Name of the variable.
  62410. * @param array array to be set.
  62411. * @returns this effect.
  62412. */
  62413. Effect.prototype.setArray4 = function (uniformName, array) {
  62414. this._valueCache[uniformName] = null;
  62415. this._engine.setArray4(this.getUniform(uniformName), array);
  62416. return this;
  62417. };
  62418. /**
  62419. * Sets matrices on a uniform variable.
  62420. * @param uniformName Name of the variable.
  62421. * @param matrices matrices to be set.
  62422. * @returns this effect.
  62423. */
  62424. Effect.prototype.setMatrices = function (uniformName, matrices) {
  62425. if (!matrices) {
  62426. return this;
  62427. }
  62428. this._valueCache[uniformName] = null;
  62429. this._engine.setMatrices(this.getUniform(uniformName), matrices);
  62430. return this;
  62431. };
  62432. /**
  62433. * Sets matrix on a uniform variable.
  62434. * @param uniformName Name of the variable.
  62435. * @param matrix matrix to be set.
  62436. * @returns this effect.
  62437. */
  62438. Effect.prototype.setMatrix = function (uniformName, matrix) {
  62439. if (this._cacheMatrix(uniformName, matrix)) {
  62440. this._engine.setMatrix(this.getUniform(uniformName), matrix);
  62441. }
  62442. return this;
  62443. };
  62444. /**
  62445. * 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)
  62446. * @param uniformName Name of the variable.
  62447. * @param matrix matrix to be set.
  62448. * @returns this effect.
  62449. */
  62450. Effect.prototype.setMatrix3x3 = function (uniformName, matrix) {
  62451. this._valueCache[uniformName] = null;
  62452. this._engine.setMatrix3x3(this.getUniform(uniformName), matrix);
  62453. return this;
  62454. };
  62455. /**
  62456. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  62457. * @param uniformName Name of the variable.
  62458. * @param matrix matrix to be set.
  62459. * @returns this effect.
  62460. */
  62461. Effect.prototype.setMatrix2x2 = function (uniformName, matrix) {
  62462. this._valueCache[uniformName] = null;
  62463. this._engine.setMatrix2x2(this.getUniform(uniformName), matrix);
  62464. return this;
  62465. };
  62466. /**
  62467. * Sets a float on a uniform variable.
  62468. * @param uniformName Name of the variable.
  62469. * @param value value to be set.
  62470. * @returns this effect.
  62471. */
  62472. Effect.prototype.setFloat = function (uniformName, value) {
  62473. var cache = this._valueCache[uniformName];
  62474. if (cache !== undefined && cache === value) {
  62475. return this;
  62476. }
  62477. this._valueCache[uniformName] = value;
  62478. this._engine.setFloat(this.getUniform(uniformName), value);
  62479. return this;
  62480. };
  62481. /**
  62482. * Sets a boolean on a uniform variable.
  62483. * @param uniformName Name of the variable.
  62484. * @param bool value to be set.
  62485. * @returns this effect.
  62486. */
  62487. Effect.prototype.setBool = function (uniformName, bool) {
  62488. var cache = this._valueCache[uniformName];
  62489. if (cache !== undefined && cache === bool) {
  62490. return this;
  62491. }
  62492. this._valueCache[uniformName] = bool;
  62493. this._engine.setBool(this.getUniform(uniformName), bool ? 1 : 0);
  62494. return this;
  62495. };
  62496. /**
  62497. * Sets a Vector2 on a uniform variable.
  62498. * @param uniformName Name of the variable.
  62499. * @param vector2 vector2 to be set.
  62500. * @returns this effect.
  62501. */
  62502. Effect.prototype.setVector2 = function (uniformName, vector2) {
  62503. if (this._cacheFloat2(uniformName, vector2.x, vector2.y)) {
  62504. this._engine.setFloat2(this.getUniform(uniformName), vector2.x, vector2.y);
  62505. }
  62506. return this;
  62507. };
  62508. /**
  62509. * Sets a float2 on a uniform variable.
  62510. * @param uniformName Name of the variable.
  62511. * @param x First float in float2.
  62512. * @param y Second float in float2.
  62513. * @returns this effect.
  62514. */
  62515. Effect.prototype.setFloat2 = function (uniformName, x, y) {
  62516. if (this._cacheFloat2(uniformName, x, y)) {
  62517. this._engine.setFloat2(this.getUniform(uniformName), x, y);
  62518. }
  62519. return this;
  62520. };
  62521. /**
  62522. * Sets a Vector3 on a uniform variable.
  62523. * @param uniformName Name of the variable.
  62524. * @param vector3 Value to be set.
  62525. * @returns this effect.
  62526. */
  62527. Effect.prototype.setVector3 = function (uniformName, vector3) {
  62528. if (this._cacheFloat3(uniformName, vector3.x, vector3.y, vector3.z)) {
  62529. this._engine.setFloat3(this.getUniform(uniformName), vector3.x, vector3.y, vector3.z);
  62530. }
  62531. return this;
  62532. };
  62533. /**
  62534. * Sets a float3 on a uniform variable.
  62535. * @param uniformName Name of the variable.
  62536. * @param x First float in float3.
  62537. * @param y Second float in float3.
  62538. * @param z Third float in float3.
  62539. * @returns this effect.
  62540. */
  62541. Effect.prototype.setFloat3 = function (uniformName, x, y, z) {
  62542. if (this._cacheFloat3(uniformName, x, y, z)) {
  62543. this._engine.setFloat3(this.getUniform(uniformName), x, y, z);
  62544. }
  62545. return this;
  62546. };
  62547. /**
  62548. * Sets a Vector4 on a uniform variable.
  62549. * @param uniformName Name of the variable.
  62550. * @param vector4 Value to be set.
  62551. * @returns this effect.
  62552. */
  62553. Effect.prototype.setVector4 = function (uniformName, vector4) {
  62554. if (this._cacheFloat4(uniformName, vector4.x, vector4.y, vector4.z, vector4.w)) {
  62555. this._engine.setFloat4(this.getUniform(uniformName), vector4.x, vector4.y, vector4.z, vector4.w);
  62556. }
  62557. return this;
  62558. };
  62559. /**
  62560. * Sets a float4 on a uniform variable.
  62561. * @param uniformName Name of the variable.
  62562. * @param x First float in float4.
  62563. * @param y Second float in float4.
  62564. * @param z Third float in float4.
  62565. * @param w Fourth float in float4.
  62566. * @returns this effect.
  62567. */
  62568. Effect.prototype.setFloat4 = function (uniformName, x, y, z, w) {
  62569. if (this._cacheFloat4(uniformName, x, y, z, w)) {
  62570. this._engine.setFloat4(this.getUniform(uniformName), x, y, z, w);
  62571. }
  62572. return this;
  62573. };
  62574. /**
  62575. * Sets a Color3 on a uniform variable.
  62576. * @param uniformName Name of the variable.
  62577. * @param color3 Value to be set.
  62578. * @returns this effect.
  62579. */
  62580. Effect.prototype.setColor3 = function (uniformName, color3) {
  62581. if (this._cacheFloat3(uniformName, color3.r, color3.g, color3.b)) {
  62582. this._engine.setColor3(this.getUniform(uniformName), color3);
  62583. }
  62584. return this;
  62585. };
  62586. /**
  62587. * Sets a Color4 on a uniform variable.
  62588. * @param uniformName Name of the variable.
  62589. * @param color3 Value to be set.
  62590. * @param alpha Alpha value to be set.
  62591. * @returns this effect.
  62592. */
  62593. Effect.prototype.setColor4 = function (uniformName, color3, alpha) {
  62594. if (this._cacheFloat4(uniformName, color3.r, color3.g, color3.b, alpha)) {
  62595. this._engine.setColor4(this.getUniform(uniformName), color3, alpha);
  62596. }
  62597. return this;
  62598. };
  62599. /**
  62600. * Sets a Color4 on a uniform variable
  62601. * @param uniformName defines the name of the variable
  62602. * @param color4 defines the value to be set
  62603. * @returns this effect.
  62604. */
  62605. Effect.prototype.setDirectColor4 = function (uniformName, color4) {
  62606. if (this._cacheFloat4(uniformName, color4.r, color4.g, color4.b, color4.a)) {
  62607. this._engine.setDirectColor4(this.getUniform(uniformName), color4);
  62608. }
  62609. return this;
  62610. };
  62611. /**
  62612. * This function will add a new shader to the shader store
  62613. * @param name the name of the shader
  62614. * @param pixelShader optional pixel shader content
  62615. * @param vertexShader optional vertex shader content
  62616. */
  62617. Effect.RegisterShader = function (name, pixelShader, vertexShader) {
  62618. if (pixelShader) {
  62619. Effect.ShadersStore[name + "PixelShader"] = pixelShader;
  62620. }
  62621. if (vertexShader) {
  62622. Effect.ShadersStore[name + "VertexShader"] = vertexShader;
  62623. }
  62624. };
  62625. /**
  62626. * Resets the cache of effects.
  62627. */
  62628. Effect.ResetCache = function () {
  62629. Effect._baseCache = {};
  62630. };
  62631. /**
  62632. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  62633. */
  62634. Effect.ShadersRepository = "src/Shaders/";
  62635. Effect._uniqueIdSeed = 0;
  62636. Effect._baseCache = {};
  62637. /**
  62638. * Store of each shader (The can be looked up using effect.key)
  62639. */
  62640. Effect.ShadersStore = {};
  62641. /**
  62642. * Store of each included file for a shader (The can be looked up using effect.key)
  62643. */
  62644. Effect.IncludesShadersStore = {};
  62645. return Effect;
  62646. }());
  62647. /***/ }),
  62648. /***/ "./Materials/fresnelParameters.ts":
  62649. /*!****************************************!*\
  62650. !*** ./Materials/fresnelParameters.ts ***!
  62651. \****************************************/
  62652. /*! exports provided: FresnelParameters */
  62653. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  62654. "use strict";
  62655. __webpack_require__.r(__webpack_exports__);
  62656. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return FresnelParameters; });
  62657. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  62658. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  62659. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  62660. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  62661. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  62662. /**
  62663. * This represents all the required information to add a fresnel effect on a material:
  62664. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  62665. */
  62666. var FresnelParameters = /** @class */ (function () {
  62667. function FresnelParameters() {
  62668. this._isEnabled = true;
  62669. /**
  62670. * Define the color used on edges (grazing angle)
  62671. */
  62672. this.leftColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].White();
  62673. /**
  62674. * Define the color used on center
  62675. */
  62676. this.rightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  62677. /**
  62678. * Define bias applied to computed fresnel term
  62679. */
  62680. this.bias = 0;
  62681. /**
  62682. * Defined the power exponent applied to fresnel term
  62683. */
  62684. this.power = 1;
  62685. }
  62686. Object.defineProperty(FresnelParameters.prototype, "isEnabled", {
  62687. /**
  62688. * Define if the fresnel effect is enable or not.
  62689. */
  62690. get: function () {
  62691. return this._isEnabled;
  62692. },
  62693. set: function (value) {
  62694. if (this._isEnabled === value) {
  62695. return;
  62696. }
  62697. this._isEnabled = value;
  62698. _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);
  62699. },
  62700. enumerable: true,
  62701. configurable: true
  62702. });
  62703. /**
  62704. * Clones the current fresnel and its valuues
  62705. * @returns a clone fresnel configuration
  62706. */
  62707. FresnelParameters.prototype.clone = function () {
  62708. var newFresnelParameters = new FresnelParameters();
  62709. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newFresnelParameters);
  62710. return newFresnelParameters;
  62711. };
  62712. /**
  62713. * Serializes the current fresnel parameters to a JSON representation.
  62714. * @return the JSON serialization
  62715. */
  62716. FresnelParameters.prototype.serialize = function () {
  62717. var serializationObject = {};
  62718. serializationObject.isEnabled = this.isEnabled;
  62719. serializationObject.leftColor = this.leftColor.asArray();
  62720. serializationObject.rightColor = this.rightColor.asArray();
  62721. serializationObject.bias = this.bias;
  62722. serializationObject.power = this.power;
  62723. return serializationObject;
  62724. };
  62725. /**
  62726. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  62727. * @param parsedFresnelParameters Define the JSON representation
  62728. * @returns the parsed parameters
  62729. */
  62730. FresnelParameters.Parse = function (parsedFresnelParameters) {
  62731. var fresnelParameters = new FresnelParameters();
  62732. fresnelParameters.isEnabled = parsedFresnelParameters.isEnabled;
  62733. fresnelParameters.leftColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(parsedFresnelParameters.leftColor);
  62734. fresnelParameters.rightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(parsedFresnelParameters.rightColor);
  62735. fresnelParameters.bias = parsedFresnelParameters.bias;
  62736. fresnelParameters.power = parsedFresnelParameters.power || 1.0;
  62737. return fresnelParameters;
  62738. };
  62739. return FresnelParameters;
  62740. }());
  62741. // References the dependencies.
  62742. _Misc_decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"]._FresnelParametersParser = FresnelParameters.Parse;
  62743. /***/ }),
  62744. /***/ "./Materials/imageProcessingConfiguration.ts":
  62745. /*!***************************************************!*\
  62746. !*** ./Materials/imageProcessingConfiguration.ts ***!
  62747. \***************************************************/
  62748. /*! exports provided: ImageProcessingConfigurationDefines, ImageProcessingConfiguration */
  62749. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  62750. "use strict";
  62751. __webpack_require__.r(__webpack_exports__);
  62752. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return ImageProcessingConfigurationDefines; });
  62753. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return ImageProcessingConfiguration; });
  62754. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  62755. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  62756. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  62757. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  62758. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  62759. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/materialDefines */ "./Materials/materialDefines.ts");
  62760. /* harmony import */ var _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/colorCurves */ "./Materials/colorCurves.ts");
  62761. /**
  62762. * @hidden
  62763. */
  62764. var ImageProcessingConfigurationDefines = /** @class */ (function (_super) {
  62765. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageProcessingConfigurationDefines, _super);
  62766. function ImageProcessingConfigurationDefines() {
  62767. var _this = _super.call(this) || this;
  62768. _this.IMAGEPROCESSING = false;
  62769. _this.VIGNETTE = false;
  62770. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  62771. _this.VIGNETTEBLENDMODEOPAQUE = false;
  62772. _this.TONEMAPPING = false;
  62773. _this.TONEMAPPING_ACES = false;
  62774. _this.CONTRAST = false;
  62775. _this.COLORCURVES = false;
  62776. _this.COLORGRADING = false;
  62777. _this.COLORGRADING3D = false;
  62778. _this.SAMPLER3DGREENDEPTH = false;
  62779. _this.SAMPLER3DBGRMAP = false;
  62780. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  62781. _this.EXPOSURE = false;
  62782. _this.rebuild();
  62783. return _this;
  62784. }
  62785. return ImageProcessingConfigurationDefines;
  62786. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_5__["MaterialDefines"]));
  62787. /**
  62788. * This groups together the common properties used for image processing either in direct forward pass
  62789. * or through post processing effect depending on the use of the image processing pipeline in your scene
  62790. * or not.
  62791. */
  62792. var ImageProcessingConfiguration = /** @class */ (function () {
  62793. function ImageProcessingConfiguration() {
  62794. /**
  62795. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  62796. */
  62797. this.colorCurves = new _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"]();
  62798. this._colorCurvesEnabled = false;
  62799. this._colorGradingEnabled = false;
  62800. this._colorGradingWithGreenDepth = true;
  62801. this._colorGradingBGR = true;
  62802. /** @hidden */
  62803. this._exposure = 1.0;
  62804. this._toneMappingEnabled = false;
  62805. this._toneMappingType = ImageProcessingConfiguration.TONEMAPPING_STANDARD;
  62806. this._contrast = 1.0;
  62807. /**
  62808. * Vignette stretch size.
  62809. */
  62810. this.vignetteStretch = 0;
  62811. /**
  62812. * Vignette centre X Offset.
  62813. */
  62814. this.vignetteCentreX = 0;
  62815. /**
  62816. * Vignette centre Y Offset.
  62817. */
  62818. this.vignetteCentreY = 0;
  62819. /**
  62820. * Vignette weight or intensity of the vignette effect.
  62821. */
  62822. this.vignetteWeight = 1.5;
  62823. /**
  62824. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  62825. * if vignetteEnabled is set to true.
  62826. */
  62827. this.vignetteColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"](0, 0, 0, 0);
  62828. /**
  62829. * Camera field of view used by the Vignette effect.
  62830. */
  62831. this.vignetteCameraFov = 0.5;
  62832. this._vignetteBlendMode = ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;
  62833. this._vignetteEnabled = false;
  62834. this._applyByPostProcess = false;
  62835. this._isEnabled = true;
  62836. /**
  62837. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  62838. */
  62839. this.onUpdateParameters = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  62840. }
  62841. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorCurvesEnabled", {
  62842. /**
  62843. * Gets wether the color curves effect is enabled.
  62844. */
  62845. get: function () {
  62846. return this._colorCurvesEnabled;
  62847. },
  62848. /**
  62849. * Sets wether the color curves effect is enabled.
  62850. */
  62851. set: function (value) {
  62852. if (this._colorCurvesEnabled === value) {
  62853. return;
  62854. }
  62855. this._colorCurvesEnabled = value;
  62856. this._updateParameters();
  62857. },
  62858. enumerable: true,
  62859. configurable: true
  62860. });
  62861. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingTexture", {
  62862. /**
  62863. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  62864. */
  62865. get: function () {
  62866. return this._colorGradingTexture;
  62867. },
  62868. /**
  62869. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  62870. */
  62871. set: function (value) {
  62872. if (this._colorGradingTexture === value) {
  62873. return;
  62874. }
  62875. this._colorGradingTexture = value;
  62876. this._updateParameters();
  62877. },
  62878. enumerable: true,
  62879. configurable: true
  62880. });
  62881. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingEnabled", {
  62882. /**
  62883. * Gets wether the color grading effect is enabled.
  62884. */
  62885. get: function () {
  62886. return this._colorGradingEnabled;
  62887. },
  62888. /**
  62889. * Sets wether the color grading effect is enabled.
  62890. */
  62891. set: function (value) {
  62892. if (this._colorGradingEnabled === value) {
  62893. return;
  62894. }
  62895. this._colorGradingEnabled = value;
  62896. this._updateParameters();
  62897. },
  62898. enumerable: true,
  62899. configurable: true
  62900. });
  62901. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingWithGreenDepth", {
  62902. /**
  62903. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  62904. */
  62905. get: function () {
  62906. return this._colorGradingWithGreenDepth;
  62907. },
  62908. /**
  62909. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  62910. */
  62911. set: function (value) {
  62912. if (this._colorGradingWithGreenDepth === value) {
  62913. return;
  62914. }
  62915. this._colorGradingWithGreenDepth = value;
  62916. this._updateParameters();
  62917. },
  62918. enumerable: true,
  62919. configurable: true
  62920. });
  62921. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingBGR", {
  62922. /**
  62923. * Gets wether the color grading texture contains BGR values.
  62924. */
  62925. get: function () {
  62926. return this._colorGradingBGR;
  62927. },
  62928. /**
  62929. * Sets wether the color grading texture contains BGR values.
  62930. */
  62931. set: function (value) {
  62932. if (this._colorGradingBGR === value) {
  62933. return;
  62934. }
  62935. this._colorGradingBGR = value;
  62936. this._updateParameters();
  62937. },
  62938. enumerable: true,
  62939. configurable: true
  62940. });
  62941. Object.defineProperty(ImageProcessingConfiguration.prototype, "exposure", {
  62942. /**
  62943. * Gets the Exposure used in the effect.
  62944. */
  62945. get: function () {
  62946. return this._exposure;
  62947. },
  62948. /**
  62949. * Sets the Exposure used in the effect.
  62950. */
  62951. set: function (value) {
  62952. if (this._exposure === value) {
  62953. return;
  62954. }
  62955. this._exposure = value;
  62956. this._updateParameters();
  62957. },
  62958. enumerable: true,
  62959. configurable: true
  62960. });
  62961. Object.defineProperty(ImageProcessingConfiguration.prototype, "toneMappingEnabled", {
  62962. /**
  62963. * Gets wether the tone mapping effect is enabled.
  62964. */
  62965. get: function () {
  62966. return this._toneMappingEnabled;
  62967. },
  62968. /**
  62969. * Sets wether the tone mapping effect is enabled.
  62970. */
  62971. set: function (value) {
  62972. if (this._toneMappingEnabled === value) {
  62973. return;
  62974. }
  62975. this._toneMappingEnabled = value;
  62976. this._updateParameters();
  62977. },
  62978. enumerable: true,
  62979. configurable: true
  62980. });
  62981. Object.defineProperty(ImageProcessingConfiguration.prototype, "toneMappingType", {
  62982. /**
  62983. * Gets the type of tone mapping effect.
  62984. */
  62985. get: function () {
  62986. return this._toneMappingType;
  62987. },
  62988. /**
  62989. * Sets the type of tone mapping effect used in BabylonJS.
  62990. */
  62991. set: function (value) {
  62992. if (this._toneMappingType === value) {
  62993. return;
  62994. }
  62995. this._toneMappingType = value;
  62996. this._updateParameters();
  62997. },
  62998. enumerable: true,
  62999. configurable: true
  63000. });
  63001. Object.defineProperty(ImageProcessingConfiguration.prototype, "contrast", {
  63002. /**
  63003. * Gets the contrast used in the effect.
  63004. */
  63005. get: function () {
  63006. return this._contrast;
  63007. },
  63008. /**
  63009. * Sets the contrast used in the effect.
  63010. */
  63011. set: function (value) {
  63012. if (this._contrast === value) {
  63013. return;
  63014. }
  63015. this._contrast = value;
  63016. this._updateParameters();
  63017. },
  63018. enumerable: true,
  63019. configurable: true
  63020. });
  63021. Object.defineProperty(ImageProcessingConfiguration.prototype, "vignetteBlendMode", {
  63022. /**
  63023. * Gets the vignette blend mode allowing different kind of effect.
  63024. */
  63025. get: function () {
  63026. return this._vignetteBlendMode;
  63027. },
  63028. /**
  63029. * Sets the vignette blend mode allowing different kind of effect.
  63030. */
  63031. set: function (value) {
  63032. if (this._vignetteBlendMode === value) {
  63033. return;
  63034. }
  63035. this._vignetteBlendMode = value;
  63036. this._updateParameters();
  63037. },
  63038. enumerable: true,
  63039. configurable: true
  63040. });
  63041. Object.defineProperty(ImageProcessingConfiguration.prototype, "vignetteEnabled", {
  63042. /**
  63043. * Gets wether the vignette effect is enabled.
  63044. */
  63045. get: function () {
  63046. return this._vignetteEnabled;
  63047. },
  63048. /**
  63049. * Sets wether the vignette effect is enabled.
  63050. */
  63051. set: function (value) {
  63052. if (this._vignetteEnabled === value) {
  63053. return;
  63054. }
  63055. this._vignetteEnabled = value;
  63056. this._updateParameters();
  63057. },
  63058. enumerable: true,
  63059. configurable: true
  63060. });
  63061. Object.defineProperty(ImageProcessingConfiguration.prototype, "applyByPostProcess", {
  63062. /**
  63063. * Gets wether the image processing is applied through a post process or not.
  63064. */
  63065. get: function () {
  63066. return this._applyByPostProcess;
  63067. },
  63068. /**
  63069. * Sets wether the image processing is applied through a post process or not.
  63070. */
  63071. set: function (value) {
  63072. if (this._applyByPostProcess === value) {
  63073. return;
  63074. }
  63075. this._applyByPostProcess = value;
  63076. this._updateParameters();
  63077. },
  63078. enumerable: true,
  63079. configurable: true
  63080. });
  63081. Object.defineProperty(ImageProcessingConfiguration.prototype, "isEnabled", {
  63082. /**
  63083. * Gets wether the image processing is enabled or not.
  63084. */
  63085. get: function () {
  63086. return this._isEnabled;
  63087. },
  63088. /**
  63089. * Sets wether the image processing is enabled or not.
  63090. */
  63091. set: function (value) {
  63092. if (this._isEnabled === value) {
  63093. return;
  63094. }
  63095. this._isEnabled = value;
  63096. this._updateParameters();
  63097. },
  63098. enumerable: true,
  63099. configurable: true
  63100. });
  63101. /**
  63102. * Method called each time the image processing information changes requires to recompile the effect.
  63103. */
  63104. ImageProcessingConfiguration.prototype._updateParameters = function () {
  63105. this.onUpdateParameters.notifyObservers(this);
  63106. };
  63107. /**
  63108. * Gets the current class name.
  63109. * @return "ImageProcessingConfiguration"
  63110. */
  63111. ImageProcessingConfiguration.prototype.getClassName = function () {
  63112. return "ImageProcessingConfiguration";
  63113. };
  63114. /**
  63115. * Prepare the list of uniforms associated with the Image Processing effects.
  63116. * @param uniforms The list of uniforms used in the effect
  63117. * @param defines the list of defines currently in use
  63118. */
  63119. ImageProcessingConfiguration.PrepareUniforms = function (uniforms, defines) {
  63120. if (defines.EXPOSURE) {
  63121. uniforms.push("exposureLinear");
  63122. }
  63123. if (defines.CONTRAST) {
  63124. uniforms.push("contrast");
  63125. }
  63126. if (defines.COLORGRADING) {
  63127. uniforms.push("colorTransformSettings");
  63128. }
  63129. if (defines.VIGNETTE) {
  63130. uniforms.push("vInverseScreenSize");
  63131. uniforms.push("vignetteSettings1");
  63132. uniforms.push("vignetteSettings2");
  63133. }
  63134. if (defines.COLORCURVES) {
  63135. _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"].PrepareUniforms(uniforms);
  63136. }
  63137. };
  63138. /**
  63139. * Prepare the list of samplers associated with the Image Processing effects.
  63140. * @param samplersList The list of uniforms used in the effect
  63141. * @param defines the list of defines currently in use
  63142. */
  63143. ImageProcessingConfiguration.PrepareSamplers = function (samplersList, defines) {
  63144. if (defines.COLORGRADING) {
  63145. samplersList.push("txColorTransform");
  63146. }
  63147. };
  63148. /**
  63149. * Prepare the list of defines associated to the shader.
  63150. * @param defines the list of defines to complete
  63151. * @param forPostProcess Define if we are currently in post process mode or not
  63152. */
  63153. ImageProcessingConfiguration.prototype.prepareDefines = function (defines, forPostProcess) {
  63154. if (forPostProcess === void 0) { forPostProcess = false; }
  63155. if (forPostProcess !== this.applyByPostProcess || !this._isEnabled) {
  63156. defines.VIGNETTE = false;
  63157. defines.TONEMAPPING = false;
  63158. defines.TONEMAPPING_ACES = false;
  63159. defines.CONTRAST = false;
  63160. defines.EXPOSURE = false;
  63161. defines.COLORCURVES = false;
  63162. defines.COLORGRADING = false;
  63163. defines.COLORGRADING3D = false;
  63164. defines.IMAGEPROCESSING = false;
  63165. defines.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess && this._isEnabled;
  63166. return;
  63167. }
  63168. defines.VIGNETTE = this.vignetteEnabled;
  63169. defines.VIGNETTEBLENDMODEMULTIPLY = (this.vignetteBlendMode === ImageProcessingConfiguration._VIGNETTEMODE_MULTIPLY);
  63170. defines.VIGNETTEBLENDMODEOPAQUE = !defines.VIGNETTEBLENDMODEMULTIPLY;
  63171. defines.TONEMAPPING = this.toneMappingEnabled;
  63172. switch (this._toneMappingType) {
  63173. case ImageProcessingConfiguration.TONEMAPPING_ACES:
  63174. defines.TONEMAPPING_ACES = true;
  63175. break;
  63176. default:
  63177. defines.TONEMAPPING_ACES = false;
  63178. break;
  63179. }
  63180. defines.CONTRAST = (this.contrast !== 1.0);
  63181. defines.EXPOSURE = (this.exposure !== 1.0);
  63182. defines.COLORCURVES = (this.colorCurvesEnabled && !!this.colorCurves);
  63183. defines.COLORGRADING = (this.colorGradingEnabled && !!this.colorGradingTexture);
  63184. if (defines.COLORGRADING) {
  63185. defines.COLORGRADING3D = this.colorGradingTexture.is3D;
  63186. }
  63187. else {
  63188. defines.COLORGRADING3D = false;
  63189. }
  63190. defines.SAMPLER3DGREENDEPTH = this.colorGradingWithGreenDepth;
  63191. defines.SAMPLER3DBGRMAP = this.colorGradingBGR;
  63192. defines.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess;
  63193. defines.IMAGEPROCESSING = defines.VIGNETTE || defines.TONEMAPPING || defines.CONTRAST || defines.EXPOSURE || defines.COLORCURVES || defines.COLORGRADING;
  63194. };
  63195. /**
  63196. * Returns true if all the image processing information are ready.
  63197. * @returns True if ready, otherwise, false
  63198. */
  63199. ImageProcessingConfiguration.prototype.isReady = function () {
  63200. // Color Grading texure can not be none blocking.
  63201. return !this.colorGradingEnabled || !this.colorGradingTexture || this.colorGradingTexture.isReady();
  63202. };
  63203. /**
  63204. * Binds the image processing to the shader.
  63205. * @param effect The effect to bind to
  63206. * @param aspectRatio Define the current aspect ratio of the effect
  63207. */
  63208. ImageProcessingConfiguration.prototype.bind = function (effect, aspectRatio) {
  63209. if (aspectRatio === void 0) { aspectRatio = 1; }
  63210. // Color Curves
  63211. if (this._colorCurvesEnabled && this.colorCurves) {
  63212. _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"].Bind(this.colorCurves, effect);
  63213. }
  63214. // Vignette
  63215. if (this._vignetteEnabled) {
  63216. var inverseWidth = 1 / effect.getEngine().getRenderWidth();
  63217. var inverseHeight = 1 / effect.getEngine().getRenderHeight();
  63218. effect.setFloat2("vInverseScreenSize", inverseWidth, inverseHeight);
  63219. var vignetteScaleY = Math.tan(this.vignetteCameraFov * 0.5);
  63220. var vignetteScaleX = vignetteScaleY * aspectRatio;
  63221. var vignetteScaleGeometricMean = Math.sqrt(vignetteScaleX * vignetteScaleY);
  63222. vignetteScaleX = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Mix(vignetteScaleX, vignetteScaleGeometricMean, this.vignetteStretch);
  63223. vignetteScaleY = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Mix(vignetteScaleY, vignetteScaleGeometricMean, this.vignetteStretch);
  63224. effect.setFloat4("vignetteSettings1", vignetteScaleX, vignetteScaleY, -vignetteScaleX * this.vignetteCentreX, -vignetteScaleY * this.vignetteCentreY);
  63225. var vignettePower = -2.0 * this.vignetteWeight;
  63226. effect.setFloat4("vignetteSettings2", this.vignetteColor.r, this.vignetteColor.g, this.vignetteColor.b, vignettePower);
  63227. }
  63228. // Exposure
  63229. effect.setFloat("exposureLinear", this.exposure);
  63230. // Contrast
  63231. effect.setFloat("contrast", this.contrast);
  63232. // Color transform settings
  63233. if (this.colorGradingTexture) {
  63234. effect.setTexture("txColorTransform", this.colorGradingTexture);
  63235. var textureSize = this.colorGradingTexture.getSize().height;
  63236. effect.setFloat4("colorTransformSettings", (textureSize - 1) / textureSize, // textureScale
  63237. 0.5 / textureSize, // textureOffset
  63238. textureSize, // textureSize
  63239. this.colorGradingTexture.level // weight
  63240. );
  63241. }
  63242. };
  63243. /**
  63244. * Clones the current image processing instance.
  63245. * @return The cloned image processing
  63246. */
  63247. ImageProcessingConfiguration.prototype.clone = function () {
  63248. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new ImageProcessingConfiguration(); }, this);
  63249. };
  63250. /**
  63251. * Serializes the current image processing instance to a json representation.
  63252. * @return a JSON representation
  63253. */
  63254. ImageProcessingConfiguration.prototype.serialize = function () {
  63255. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  63256. };
  63257. /**
  63258. * Parses the image processing from a json representation.
  63259. * @param source the JSON source to parse
  63260. * @return The parsed image processing
  63261. */
  63262. ImageProcessingConfiguration.Parse = function (source) {
  63263. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ImageProcessingConfiguration(); }, source, null, null);
  63264. };
  63265. Object.defineProperty(ImageProcessingConfiguration, "VIGNETTEMODE_MULTIPLY", {
  63266. /**
  63267. * Used to apply the vignette as a mix with the pixel color.
  63268. */
  63269. get: function () {
  63270. return this._VIGNETTEMODE_MULTIPLY;
  63271. },
  63272. enumerable: true,
  63273. configurable: true
  63274. });
  63275. Object.defineProperty(ImageProcessingConfiguration, "VIGNETTEMODE_OPAQUE", {
  63276. /**
  63277. * Used to apply the vignette as a replacement of the pixel color.
  63278. */
  63279. get: function () {
  63280. return this._VIGNETTEMODE_OPAQUE;
  63281. },
  63282. enumerable: true,
  63283. configurable: true
  63284. });
  63285. /**
  63286. * Default tone mapping applied in BabylonJS.
  63287. */
  63288. ImageProcessingConfiguration.TONEMAPPING_STANDARD = 0;
  63289. /**
  63290. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  63291. * to other engines rendering to increase portability.
  63292. */
  63293. ImageProcessingConfiguration.TONEMAPPING_ACES = 1;
  63294. // Static constants associated to the image processing.
  63295. ImageProcessingConfiguration._VIGNETTEMODE_MULTIPLY = 0;
  63296. ImageProcessingConfiguration._VIGNETTEMODE_OPAQUE = 1;
  63297. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63298. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColorCurves"])()
  63299. ], ImageProcessingConfiguration.prototype, "colorCurves", void 0);
  63300. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63301. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63302. ], ImageProcessingConfiguration.prototype, "_colorCurvesEnabled", void 0);
  63303. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63304. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("colorGradingTexture")
  63305. ], ImageProcessingConfiguration.prototype, "_colorGradingTexture", void 0);
  63306. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63307. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63308. ], ImageProcessingConfiguration.prototype, "_colorGradingEnabled", void 0);
  63309. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63310. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63311. ], ImageProcessingConfiguration.prototype, "_colorGradingWithGreenDepth", void 0);
  63312. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63313. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63314. ], ImageProcessingConfiguration.prototype, "_colorGradingBGR", void 0);
  63315. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63316. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63317. ], ImageProcessingConfiguration.prototype, "_exposure", void 0);
  63318. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63319. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63320. ], ImageProcessingConfiguration.prototype, "_toneMappingEnabled", void 0);
  63321. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63322. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63323. ], ImageProcessingConfiguration.prototype, "_toneMappingType", void 0);
  63324. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63325. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63326. ], ImageProcessingConfiguration.prototype, "_contrast", void 0);
  63327. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63328. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63329. ], ImageProcessingConfiguration.prototype, "vignetteStretch", void 0);
  63330. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63331. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63332. ], ImageProcessingConfiguration.prototype, "vignetteCentreX", void 0);
  63333. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63334. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63335. ], ImageProcessingConfiguration.prototype, "vignetteCentreY", void 0);
  63336. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63337. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63338. ], ImageProcessingConfiguration.prototype, "vignetteWeight", void 0);
  63339. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63340. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  63341. ], ImageProcessingConfiguration.prototype, "vignetteColor", void 0);
  63342. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63343. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63344. ], ImageProcessingConfiguration.prototype, "vignetteCameraFov", void 0);
  63345. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63346. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63347. ], ImageProcessingConfiguration.prototype, "_vignetteBlendMode", void 0);
  63348. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63349. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63350. ], ImageProcessingConfiguration.prototype, "_vignetteEnabled", void 0);
  63351. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63352. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63353. ], ImageProcessingConfiguration.prototype, "_applyByPostProcess", void 0);
  63354. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63355. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63356. ], ImageProcessingConfiguration.prototype, "_isEnabled", void 0);
  63357. return ImageProcessingConfiguration;
  63358. }());
  63359. // References the dependencies.
  63360. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._ImageProcessingConfigurationParser = ImageProcessingConfiguration.Parse;
  63361. /***/ }),
  63362. /***/ "./Materials/index.ts":
  63363. /*!****************************!*\
  63364. !*** ./Materials/index.ts ***!
  63365. \****************************/
  63366. /*! exports provided: ColorCurves, EffectFallbacks, EffectCreationOptions, Effect, FresnelParameters, ImageProcessingConfigurationDefines, ImageProcessingConfiguration, Material, MaterialDefines, MaterialHelper, MultiMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, DynamicTexture, InternalTexture, MirrorTexture, RawTexture, RenderTargetTexture, Texture, UniformBuffer, MaterialFlags, BackgroundMaterial, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, HDRCubeTexture, DummyInternalTextureTracker, MultiRenderTarget, RawCubeTexture, RawTexture3D, RefractionTexture, VideoTexture, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTexture, ProceduralTextureSceneComponent */
  63367. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  63368. "use strict";
  63369. __webpack_require__.r(__webpack_exports__);
  63370. /* harmony import */ var _Background_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Background/index */ "./Materials/Background/index.ts");
  63371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _Background_index__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  63372. /* harmony import */ var _colorCurves__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./colorCurves */ "./Materials/colorCurves.ts");
  63373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _colorCurves__WEBPACK_IMPORTED_MODULE_1__["ColorCurves"]; });
  63374. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  63375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["EffectFallbacks"]; });
  63376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["EffectCreationOptions"]; });
  63377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["Effect"]; });
  63378. /* harmony import */ var _fresnelParameters__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./fresnelParameters */ "./Materials/fresnelParameters.ts");
  63379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _fresnelParameters__WEBPACK_IMPORTED_MODULE_3__["FresnelParameters"]; });
  63380. /* harmony import */ var _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  63381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__["ImageProcessingConfigurationDefines"]; });
  63382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__["ImageProcessingConfiguration"]; });
  63383. /* harmony import */ var _material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./material */ "./Materials/material.ts");
  63384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _material__WEBPACK_IMPORTED_MODULE_5__["Material"]; });
  63385. /* harmony import */ var _materialDefines__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./materialDefines */ "./Materials/materialDefines.ts");
  63386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _materialDefines__WEBPACK_IMPORTED_MODULE_6__["MaterialDefines"]; });
  63387. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  63388. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"]; });
  63389. /* harmony import */ var _multiMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./multiMaterial */ "./Materials/multiMaterial.ts");
  63390. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _multiMaterial__WEBPACK_IMPORTED_MODULE_8__["MultiMaterial"]; });
  63391. /* harmony import */ var _PBR_index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./PBR/index */ "./Materials/PBR/index.ts");
  63392. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRBaseMaterial"]; });
  63393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRBaseSimpleMaterial"]; });
  63394. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRMaterial"]; });
  63395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRMetallicRoughnessMaterial"]; });
  63396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRSpecularGlossinessMaterial"]; });
  63397. /* harmony import */ var _pushMaterial__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./pushMaterial */ "./Materials/pushMaterial.ts");
  63398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _pushMaterial__WEBPACK_IMPORTED_MODULE_10__["PushMaterial"]; });
  63399. /* harmony import */ var _shaderMaterial__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./shaderMaterial */ "./Materials/shaderMaterial.ts");
  63400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _shaderMaterial__WEBPACK_IMPORTED_MODULE_11__["ShaderMaterial"]; });
  63401. /* harmony import */ var _standardMaterial__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./standardMaterial */ "./Materials/standardMaterial.ts");
  63402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterialDefines"]; });
  63403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]; });
  63404. /* harmony import */ var _Textures_index__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Textures/index */ "./Materials/Textures/index.ts");
  63405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["BaseTexture"]; });
  63406. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["CubeTexture"]; });
  63407. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["DynamicTexture"]; });
  63408. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["InternalTexture"]; });
  63409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["MirrorTexture"]; });
  63410. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawTexture"]; });
  63411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RenderTargetTexture"]; });
  63412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["Texture"]; });
  63413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ColorGradingTexture"]; });
  63414. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["HDRCubeTexture"]; });
  63415. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["DummyInternalTextureTracker"]; });
  63416. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["MultiRenderTarget"]; });
  63417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawCubeTexture"]; });
  63418. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawTexture3D"]; });
  63419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RefractionTexture"]; });
  63420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["VideoTexture"]; });
  63421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_DDSTextureLoader"]; });
  63422. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_ENVTextureLoader"]; });
  63423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_KTXTextureLoader"]; });
  63424. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_TGATextureLoader"]; });
  63425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["CustomProceduralTexture"]; });
  63426. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["NoiseProceduralTexture"]; });
  63427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ProceduralTexture"]; });
  63428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ProceduralTextureSceneComponent"]; });
  63429. /* harmony import */ var _uniformBuffer__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./uniformBuffer */ "./Materials/uniformBuffer.ts");
  63430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _uniformBuffer__WEBPACK_IMPORTED_MODULE_14__["UniformBuffer"]; });
  63431. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./materialFlags */ "./Materials/materialFlags.ts");
  63432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _materialFlags__WEBPACK_IMPORTED_MODULE_15__["MaterialFlags"]; });
  63433. /***/ }),
  63434. /***/ "./Materials/material.ts":
  63435. /*!*******************************!*\
  63436. !*** ./Materials/material.ts ***!
  63437. \*******************************/
  63438. /*! exports provided: Material */
  63439. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  63440. "use strict";
  63441. __webpack_require__.r(__webpack_exports__);
  63442. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return Material; });
  63443. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  63444. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  63445. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  63446. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  63447. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  63448. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  63449. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  63450. /* harmony import */ var _uniformBuffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./uniformBuffer */ "./Materials/uniformBuffer.ts");
  63451. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  63452. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  63453. /**
  63454. * Base class for the main features of a material in Babylon.js
  63455. */
  63456. var Material = /** @class */ (function () {
  63457. /**
  63458. * Creates a material instance
  63459. * @param name defines the name of the material
  63460. * @param scene defines the scene to reference
  63461. * @param doNotAdd specifies if the material should be added to the scene
  63462. */
  63463. function Material(name, scene, doNotAdd) {
  63464. /**
  63465. * Gets or sets user defined metadata
  63466. */
  63467. this.metadata = null;
  63468. /**
  63469. * For internal use only. Please do not use.
  63470. */
  63471. this.reservedDataStore = null;
  63472. /**
  63473. * Specifies if the ready state should be checked on each call
  63474. */
  63475. this.checkReadyOnEveryCall = false;
  63476. /**
  63477. * Specifies if the ready state should be checked once
  63478. */
  63479. this.checkReadyOnlyOnce = false;
  63480. /**
  63481. * The state of the material
  63482. */
  63483. this.state = "";
  63484. /**
  63485. * The alpha value of the material
  63486. */
  63487. this._alpha = 1.0;
  63488. /**
  63489. * Specifies if back face culling is enabled
  63490. */
  63491. this._backFaceCulling = true;
  63492. /**
  63493. * Specifies if the material should be serialized
  63494. */
  63495. this.doNotSerialize = false;
  63496. /**
  63497. * @hidden
  63498. */
  63499. this._storeEffectOnSubMeshes = false;
  63500. /**
  63501. * An event triggered when the material is disposed
  63502. */
  63503. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  63504. /**
  63505. * Stores the value of the alpha mode
  63506. */
  63507. this._alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE;
  63508. /**
  63509. * Stores the state of the need depth pre-pass value
  63510. */
  63511. this._needDepthPrePass = false;
  63512. /**
  63513. * Specifies if depth writing should be disabled
  63514. */
  63515. this.disableDepthWrite = false;
  63516. /**
  63517. * Specifies if depth writing should be forced
  63518. */
  63519. this.forceDepthWrite = false;
  63520. /**
  63521. * Specifies if there should be a separate pass for culling
  63522. */
  63523. this.separateCullingPass = false;
  63524. /**
  63525. * Stores the state specifing if fog should be enabled
  63526. */
  63527. this._fogEnabled = true;
  63528. /**
  63529. * Stores the size of points
  63530. */
  63531. this.pointSize = 1.0;
  63532. /**
  63533. * Stores the z offset value
  63534. */
  63535. this.zOffset = 0;
  63536. /**
  63537. * @hidden
  63538. * Specifies if the material was previously ready
  63539. */
  63540. this._wasPreviouslyReady = false;
  63541. /**
  63542. * Stores the fill mode state
  63543. */
  63544. this._fillMode = Material.TriangleFillMode;
  63545. /** @hidden */
  63546. this._indexInSceneMaterialArray = -1;
  63547. this.name = name;
  63548. this.id = name || _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].RandomId();
  63549. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  63550. this.uniqueId = this._scene.getUniqueId();
  63551. if (this._scene.useRightHandedSystem) {
  63552. this.sideOrientation = Material.ClockWiseSideOrientation;
  63553. }
  63554. else {
  63555. this.sideOrientation = Material.CounterClockWiseSideOrientation;
  63556. }
  63557. this._uniformBuffer = new _uniformBuffer__WEBPACK_IMPORTED_MODULE_7__["UniformBuffer"](this._scene.getEngine());
  63558. this._useUBO = this.getScene().getEngine().supportsUniformBuffers;
  63559. if (!doNotAdd) {
  63560. this._scene.addMaterial(this);
  63561. }
  63562. if (this._scene.useMaterialMeshMap) {
  63563. this.meshMap = {};
  63564. }
  63565. }
  63566. Object.defineProperty(Material.prototype, "alpha", {
  63567. /**
  63568. * Gets the alpha value of the material
  63569. */
  63570. get: function () {
  63571. return this._alpha;
  63572. },
  63573. /**
  63574. * Sets the alpha value of the material
  63575. */
  63576. set: function (value) {
  63577. if (this._alpha === value) {
  63578. return;
  63579. }
  63580. this._alpha = value;
  63581. this.markAsDirty(Material.MiscDirtyFlag);
  63582. },
  63583. enumerable: true,
  63584. configurable: true
  63585. });
  63586. Object.defineProperty(Material.prototype, "backFaceCulling", {
  63587. /**
  63588. * Gets the back-face culling state
  63589. */
  63590. get: function () {
  63591. return this._backFaceCulling;
  63592. },
  63593. /**
  63594. * Sets the back-face culling state
  63595. */
  63596. set: function (value) {
  63597. if (this._backFaceCulling === value) {
  63598. return;
  63599. }
  63600. this._backFaceCulling = value;
  63601. this.markAsDirty(Material.TextureDirtyFlag);
  63602. },
  63603. enumerable: true,
  63604. configurable: true
  63605. });
  63606. Object.defineProperty(Material.prototype, "hasRenderTargetTextures", {
  63607. /**
  63608. * Gets a boolean indicating that current material needs to register RTT
  63609. */
  63610. get: function () {
  63611. return false;
  63612. },
  63613. enumerable: true,
  63614. configurable: true
  63615. });
  63616. Object.defineProperty(Material.prototype, "onDispose", {
  63617. /**
  63618. * Called during a dispose event
  63619. */
  63620. set: function (callback) {
  63621. if (this._onDisposeObserver) {
  63622. this.onDisposeObservable.remove(this._onDisposeObserver);
  63623. }
  63624. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  63625. },
  63626. enumerable: true,
  63627. configurable: true
  63628. });
  63629. Object.defineProperty(Material.prototype, "onBindObservable", {
  63630. /**
  63631. * An event triggered when the material is bound
  63632. */
  63633. get: function () {
  63634. if (!this._onBindObservable) {
  63635. this._onBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  63636. }
  63637. return this._onBindObservable;
  63638. },
  63639. enumerable: true,
  63640. configurable: true
  63641. });
  63642. Object.defineProperty(Material.prototype, "onBind", {
  63643. /**
  63644. * Called during a bind event
  63645. */
  63646. set: function (callback) {
  63647. if (this._onBindObserver) {
  63648. this.onBindObservable.remove(this._onBindObserver);
  63649. }
  63650. this._onBindObserver = this.onBindObservable.add(callback);
  63651. },
  63652. enumerable: true,
  63653. configurable: true
  63654. });
  63655. Object.defineProperty(Material.prototype, "onUnBindObservable", {
  63656. /**
  63657. * An event triggered when the material is unbound
  63658. */
  63659. get: function () {
  63660. if (!this._onUnBindObservable) {
  63661. this._onUnBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  63662. }
  63663. return this._onUnBindObservable;
  63664. },
  63665. enumerable: true,
  63666. configurable: true
  63667. });
  63668. Object.defineProperty(Material.prototype, "alphaMode", {
  63669. /**
  63670. * Gets the value of the alpha mode
  63671. */
  63672. get: function () {
  63673. return this._alphaMode;
  63674. },
  63675. /**
  63676. * Sets the value of the alpha mode.
  63677. *
  63678. * | Value | Type | Description |
  63679. * | --- | --- | --- |
  63680. * | 0 | ALPHA_DISABLE | |
  63681. * | 1 | ALPHA_ADD | |
  63682. * | 2 | ALPHA_COMBINE | |
  63683. * | 3 | ALPHA_SUBTRACT | |
  63684. * | 4 | ALPHA_MULTIPLY | |
  63685. * | 5 | ALPHA_MAXIMIZED | |
  63686. * | 6 | ALPHA_ONEONE | |
  63687. * | 7 | ALPHA_PREMULTIPLIED | |
  63688. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  63689. * | 9 | ALPHA_INTERPOLATE | |
  63690. * | 10 | ALPHA_SCREENMODE | |
  63691. *
  63692. */
  63693. set: function (value) {
  63694. if (this._alphaMode === value) {
  63695. return;
  63696. }
  63697. this._alphaMode = value;
  63698. this.markAsDirty(Material.TextureDirtyFlag);
  63699. },
  63700. enumerable: true,
  63701. configurable: true
  63702. });
  63703. Object.defineProperty(Material.prototype, "needDepthPrePass", {
  63704. /**
  63705. * Gets the depth pre-pass value
  63706. */
  63707. get: function () {
  63708. return this._needDepthPrePass;
  63709. },
  63710. /**
  63711. * Sets the need depth pre-pass value
  63712. */
  63713. set: function (value) {
  63714. if (this._needDepthPrePass === value) {
  63715. return;
  63716. }
  63717. this._needDepthPrePass = value;
  63718. if (this._needDepthPrePass) {
  63719. this.checkReadyOnEveryCall = true;
  63720. }
  63721. },
  63722. enumerable: true,
  63723. configurable: true
  63724. });
  63725. Object.defineProperty(Material.prototype, "fogEnabled", {
  63726. /**
  63727. * Gets the value of the fog enabled state
  63728. */
  63729. get: function () {
  63730. return this._fogEnabled;
  63731. },
  63732. /**
  63733. * Sets the state for enabling fog
  63734. */
  63735. set: function (value) {
  63736. if (this._fogEnabled === value) {
  63737. return;
  63738. }
  63739. this._fogEnabled = value;
  63740. this.markAsDirty(Material.MiscDirtyFlag);
  63741. },
  63742. enumerable: true,
  63743. configurable: true
  63744. });
  63745. Object.defineProperty(Material.prototype, "wireframe", {
  63746. /**
  63747. * Gets a value specifying if wireframe mode is enabled
  63748. */
  63749. get: function () {
  63750. switch (this._fillMode) {
  63751. case Material.WireFrameFillMode:
  63752. case Material.LineListDrawMode:
  63753. case Material.LineLoopDrawMode:
  63754. case Material.LineStripDrawMode:
  63755. return true;
  63756. }
  63757. return this._scene.forceWireframe;
  63758. },
  63759. /**
  63760. * Sets the state of wireframe mode
  63761. */
  63762. set: function (value) {
  63763. this.fillMode = (value ? Material.WireFrameFillMode : Material.TriangleFillMode);
  63764. },
  63765. enumerable: true,
  63766. configurable: true
  63767. });
  63768. Object.defineProperty(Material.prototype, "pointsCloud", {
  63769. /**
  63770. * Gets the value specifying if point clouds are enabled
  63771. */
  63772. get: function () {
  63773. switch (this._fillMode) {
  63774. case Material.PointFillMode:
  63775. case Material.PointListDrawMode:
  63776. return true;
  63777. }
  63778. return this._scene.forcePointsCloud;
  63779. },
  63780. /**
  63781. * Sets the state of point cloud mode
  63782. */
  63783. set: function (value) {
  63784. this.fillMode = (value ? Material.PointFillMode : Material.TriangleFillMode);
  63785. },
  63786. enumerable: true,
  63787. configurable: true
  63788. });
  63789. Object.defineProperty(Material.prototype, "fillMode", {
  63790. /**
  63791. * Gets the material fill mode
  63792. */
  63793. get: function () {
  63794. return this._fillMode;
  63795. },
  63796. /**
  63797. * Sets the material fill mode
  63798. */
  63799. set: function (value) {
  63800. if (this._fillMode === value) {
  63801. return;
  63802. }
  63803. this._fillMode = value;
  63804. this.markAsDirty(Material.MiscDirtyFlag);
  63805. },
  63806. enumerable: true,
  63807. configurable: true
  63808. });
  63809. /**
  63810. * Returns a string representation of the current material
  63811. * @param fullDetails defines a boolean indicating which levels of logging is desired
  63812. * @returns a string with material information
  63813. */
  63814. Material.prototype.toString = function (fullDetails) {
  63815. var ret = "Name: " + this.name;
  63816. if (fullDetails) {
  63817. }
  63818. return ret;
  63819. };
  63820. /**
  63821. * Gets the class name of the material
  63822. * @returns a string with the class name of the material
  63823. */
  63824. Material.prototype.getClassName = function () {
  63825. return "Material";
  63826. };
  63827. Object.defineProperty(Material.prototype, "isFrozen", {
  63828. /**
  63829. * Specifies if updates for the material been locked
  63830. */
  63831. get: function () {
  63832. return this.checkReadyOnlyOnce;
  63833. },
  63834. enumerable: true,
  63835. configurable: true
  63836. });
  63837. /**
  63838. * Locks updates for the material
  63839. */
  63840. Material.prototype.freeze = function () {
  63841. this.checkReadyOnlyOnce = true;
  63842. };
  63843. /**
  63844. * Unlocks updates for the material
  63845. */
  63846. Material.prototype.unfreeze = function () {
  63847. this.checkReadyOnlyOnce = false;
  63848. };
  63849. /**
  63850. * Specifies if the material is ready to be used
  63851. * @param mesh defines the mesh to check
  63852. * @param useInstances specifies if instances should be used
  63853. * @returns a boolean indicating if the material is ready to be used
  63854. */
  63855. Material.prototype.isReady = function (mesh, useInstances) {
  63856. return true;
  63857. };
  63858. /**
  63859. * Specifies that the submesh is ready to be used
  63860. * @param mesh defines the mesh to check
  63861. * @param subMesh defines which submesh to check
  63862. * @param useInstances specifies that instances should be used
  63863. * @returns a boolean indicating that the submesh is ready or not
  63864. */
  63865. Material.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  63866. return false;
  63867. };
  63868. /**
  63869. * Returns the material effect
  63870. * @returns the effect associated with the material
  63871. */
  63872. Material.prototype.getEffect = function () {
  63873. return this._effect;
  63874. };
  63875. /**
  63876. * Returns the current scene
  63877. * @returns a Scene
  63878. */
  63879. Material.prototype.getScene = function () {
  63880. return this._scene;
  63881. };
  63882. /**
  63883. * Specifies if the material will require alpha blending
  63884. * @returns a boolean specifying if alpha blending is needed
  63885. */
  63886. Material.prototype.needAlphaBlending = function () {
  63887. return (this.alpha < 1.0);
  63888. };
  63889. /**
  63890. * Specifies if the mesh will require alpha blending
  63891. * @param mesh defines the mesh to check
  63892. * @returns a boolean specifying if alpha blending is needed for the mesh
  63893. */
  63894. Material.prototype.needAlphaBlendingForMesh = function (mesh) {
  63895. return this.needAlphaBlending() || (mesh.visibility < 1.0) || mesh.hasVertexAlpha;
  63896. };
  63897. /**
  63898. * Specifies if this material should be rendered in alpha test mode
  63899. * @returns a boolean specifying if an alpha test is needed.
  63900. */
  63901. Material.prototype.needAlphaTesting = function () {
  63902. return false;
  63903. };
  63904. /**
  63905. * Gets the texture used for the alpha test
  63906. * @returns the texture to use for alpha testing
  63907. */
  63908. Material.prototype.getAlphaTestTexture = function () {
  63909. return null;
  63910. };
  63911. /**
  63912. * Marks the material to indicate that it needs to be re-calculated
  63913. */
  63914. Material.prototype.markDirty = function () {
  63915. this._wasPreviouslyReady = false;
  63916. };
  63917. /** @hidden */
  63918. Material.prototype._preBind = function (effect, overrideOrientation) {
  63919. if (overrideOrientation === void 0) { overrideOrientation = null; }
  63920. var engine = this._scene.getEngine();
  63921. var orientation = (overrideOrientation == null) ? this.sideOrientation : overrideOrientation;
  63922. var reverse = orientation === Material.ClockWiseSideOrientation;
  63923. engine.enableEffect(effect ? effect : this._effect);
  63924. engine.setState(this.backFaceCulling, this.zOffset, false, reverse);
  63925. return reverse;
  63926. };
  63927. /**
  63928. * Binds the material to the mesh
  63929. * @param world defines the world transformation matrix
  63930. * @param mesh defines the mesh to bind the material to
  63931. */
  63932. Material.prototype.bind = function (world, mesh) {
  63933. };
  63934. /**
  63935. * Binds the submesh to the material
  63936. * @param world defines the world transformation matrix
  63937. * @param mesh defines the mesh containing the submesh
  63938. * @param subMesh defines the submesh to bind the material to
  63939. */
  63940. Material.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  63941. };
  63942. /**
  63943. * Binds the world matrix to the material
  63944. * @param world defines the world transformation matrix
  63945. */
  63946. Material.prototype.bindOnlyWorldMatrix = function (world) {
  63947. };
  63948. /**
  63949. * Binds the scene's uniform buffer to the effect.
  63950. * @param effect defines the effect to bind to the scene uniform buffer
  63951. * @param sceneUbo defines the uniform buffer storing scene data
  63952. */
  63953. Material.prototype.bindSceneUniformBuffer = function (effect, sceneUbo) {
  63954. sceneUbo.bindToEffect(effect, "Scene");
  63955. };
  63956. /**
  63957. * Binds the view matrix to the effect
  63958. * @param effect defines the effect to bind the view matrix to
  63959. */
  63960. Material.prototype.bindView = function (effect) {
  63961. if (!this._useUBO) {
  63962. effect.setMatrix("view", this.getScene().getViewMatrix());
  63963. }
  63964. else {
  63965. this.bindSceneUniformBuffer(effect, this.getScene().getSceneUniformBuffer());
  63966. }
  63967. };
  63968. /**
  63969. * Binds the view projection matrix to the effect
  63970. * @param effect defines the effect to bind the view projection matrix to
  63971. */
  63972. Material.prototype.bindViewProjection = function (effect) {
  63973. if (!this._useUBO) {
  63974. effect.setMatrix("viewProjection", this.getScene().getTransformMatrix());
  63975. }
  63976. else {
  63977. this.bindSceneUniformBuffer(effect, this.getScene().getSceneUniformBuffer());
  63978. }
  63979. };
  63980. /**
  63981. * Specifies if material alpha testing should be turned on for the mesh
  63982. * @param mesh defines the mesh to check
  63983. */
  63984. Material.prototype._shouldTurnAlphaTestOn = function (mesh) {
  63985. return (!this.needAlphaBlendingForMesh(mesh) && this.needAlphaTesting());
  63986. };
  63987. /**
  63988. * Processes to execute after binding the material to a mesh
  63989. * @param mesh defines the rendered mesh
  63990. */
  63991. Material.prototype._afterBind = function (mesh) {
  63992. this._scene._cachedMaterial = this;
  63993. if (mesh) {
  63994. this._scene._cachedVisibility = mesh.visibility;
  63995. }
  63996. else {
  63997. this._scene._cachedVisibility = 1;
  63998. }
  63999. if (this._onBindObservable && mesh) {
  64000. this._onBindObservable.notifyObservers(mesh);
  64001. }
  64002. if (this.disableDepthWrite) {
  64003. var engine = this._scene.getEngine();
  64004. this._cachedDepthWriteState = engine.getDepthWrite();
  64005. engine.setDepthWrite(false);
  64006. }
  64007. };
  64008. /**
  64009. * Unbinds the material from the mesh
  64010. */
  64011. Material.prototype.unbind = function () {
  64012. if (this._onUnBindObservable) {
  64013. this._onUnBindObservable.notifyObservers(this);
  64014. }
  64015. if (this.disableDepthWrite) {
  64016. var engine = this._scene.getEngine();
  64017. engine.setDepthWrite(this._cachedDepthWriteState);
  64018. }
  64019. };
  64020. /**
  64021. * Gets the active textures from the material
  64022. * @returns an array of textures
  64023. */
  64024. Material.prototype.getActiveTextures = function () {
  64025. return [];
  64026. };
  64027. /**
  64028. * Specifies if the material uses a texture
  64029. * @param texture defines the texture to check against the material
  64030. * @returns a boolean specifying if the material uses the texture
  64031. */
  64032. Material.prototype.hasTexture = function (texture) {
  64033. return false;
  64034. };
  64035. /**
  64036. * Makes a duplicate of the material, and gives it a new name
  64037. * @param name defines the new name for the duplicated material
  64038. * @returns the cloned material
  64039. */
  64040. Material.prototype.clone = function (name) {
  64041. return null;
  64042. };
  64043. /**
  64044. * Gets the meshes bound to the material
  64045. * @returns an array of meshes bound to the material
  64046. */
  64047. Material.prototype.getBindedMeshes = function () {
  64048. var _this = this;
  64049. if (this.meshMap) {
  64050. var result = new Array();
  64051. for (var meshId in this.meshMap) {
  64052. var mesh = this.meshMap[meshId];
  64053. if (mesh) {
  64054. result.push(mesh);
  64055. }
  64056. }
  64057. return result;
  64058. }
  64059. else {
  64060. var meshes = this._scene.meshes;
  64061. return meshes.filter(function (mesh) { return mesh.material === _this; });
  64062. }
  64063. };
  64064. /**
  64065. * Force shader compilation
  64066. * @param mesh defines the mesh associated with this material
  64067. * @param onCompiled defines a function to execute once the material is compiled
  64068. * @param options defines the options to configure the compilation
  64069. */
  64070. Material.prototype.forceCompilation = function (mesh, onCompiled, options) {
  64071. var _this = this;
  64072. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ clipPlane: false }, options);
  64073. var subMesh = new _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_6__["BaseSubMesh"]();
  64074. var scene = this.getScene();
  64075. var checkReady = function () {
  64076. if (!_this._scene || !_this._scene.getEngine()) {
  64077. return;
  64078. }
  64079. if (subMesh._materialDefines) {
  64080. subMesh._materialDefines._renderId = -1;
  64081. }
  64082. var clipPlaneState = scene.clipPlane;
  64083. if (localOptions.clipPlane) {
  64084. scene.clipPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Plane"](0, 0, 0, 1);
  64085. }
  64086. if (_this._storeEffectOnSubMeshes) {
  64087. if (_this.isReadyForSubMesh(mesh, subMesh)) {
  64088. if (onCompiled) {
  64089. onCompiled(_this);
  64090. }
  64091. }
  64092. else {
  64093. setTimeout(checkReady, 16);
  64094. }
  64095. }
  64096. else {
  64097. if (_this.isReady()) {
  64098. if (onCompiled) {
  64099. onCompiled(_this);
  64100. }
  64101. }
  64102. else {
  64103. setTimeout(checkReady, 16);
  64104. }
  64105. }
  64106. if (localOptions.clipPlane) {
  64107. scene.clipPlane = clipPlaneState;
  64108. }
  64109. };
  64110. checkReady();
  64111. };
  64112. /**
  64113. * Force shader compilation
  64114. * @param mesh defines the mesh that will use this material
  64115. * @param options defines additional options for compiling the shaders
  64116. * @returns a promise that resolves when the compilation completes
  64117. */
  64118. Material.prototype.forceCompilationAsync = function (mesh, options) {
  64119. var _this = this;
  64120. return new Promise(function (resolve) {
  64121. _this.forceCompilation(mesh, function () {
  64122. resolve();
  64123. }, options);
  64124. });
  64125. };
  64126. /**
  64127. * Marks a define in the material to indicate that it needs to be re-computed
  64128. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  64129. */
  64130. Material.prototype.markAsDirty = function (flag) {
  64131. if (this.getScene().blockMaterialDirtyMechanism) {
  64132. return;
  64133. }
  64134. Material._DirtyCallbackArray.length = 0;
  64135. if (flag & Material.TextureDirtyFlag) {
  64136. Material._DirtyCallbackArray.push(Material._TextureDirtyCallBack);
  64137. }
  64138. if (flag & Material.LightDirtyFlag) {
  64139. Material._DirtyCallbackArray.push(Material._LightsDirtyCallBack);
  64140. }
  64141. if (flag & Material.FresnelDirtyFlag) {
  64142. Material._DirtyCallbackArray.push(Material._FresnelDirtyCallBack);
  64143. }
  64144. if (flag & Material.AttributesDirtyFlag) {
  64145. Material._DirtyCallbackArray.push(Material._AttributeDirtyCallBack);
  64146. }
  64147. if (flag & Material.MiscDirtyFlag) {
  64148. Material._DirtyCallbackArray.push(Material._MiscDirtyCallBack);
  64149. }
  64150. if (Material._DirtyCallbackArray.length) {
  64151. this._markAllSubMeshesAsDirty(Material._RunDirtyCallBacks);
  64152. }
  64153. this.getScene().resetCachedMaterial();
  64154. };
  64155. /**
  64156. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  64157. * @param func defines a function which checks material defines against the submeshes
  64158. */
  64159. Material.prototype._markAllSubMeshesAsDirty = function (func) {
  64160. if (this.getScene().blockMaterialDirtyMechanism) {
  64161. return;
  64162. }
  64163. var meshes = this.getScene().meshes;
  64164. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  64165. var mesh = meshes_1[_i];
  64166. if (!mesh.subMeshes) {
  64167. continue;
  64168. }
  64169. for (var _a = 0, _b = mesh.subMeshes; _a < _b.length; _a++) {
  64170. var subMesh = _b[_a];
  64171. if (subMesh.getMaterial() !== this) {
  64172. continue;
  64173. }
  64174. if (!subMesh._materialDefines) {
  64175. continue;
  64176. }
  64177. func(subMesh._materialDefines);
  64178. }
  64179. }
  64180. };
  64181. /**
  64182. * Indicates that image processing needs to be re-calculated for all submeshes
  64183. */
  64184. Material.prototype._markAllSubMeshesAsImageProcessingDirty = function () {
  64185. this._markAllSubMeshesAsDirty(Material._ImageProcessingDirtyCallBack);
  64186. };
  64187. /**
  64188. * Indicates that textures need to be re-calculated for all submeshes
  64189. */
  64190. Material.prototype._markAllSubMeshesAsTexturesDirty = function () {
  64191. this._markAllSubMeshesAsDirty(Material._TextureDirtyCallBack);
  64192. };
  64193. /**
  64194. * Indicates that fresnel needs to be re-calculated for all submeshes
  64195. */
  64196. Material.prototype._markAllSubMeshesAsFresnelDirty = function () {
  64197. this._markAllSubMeshesAsDirty(Material._FresnelDirtyCallBack);
  64198. };
  64199. /**
  64200. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  64201. */
  64202. Material.prototype._markAllSubMeshesAsFresnelAndMiscDirty = function () {
  64203. this._markAllSubMeshesAsDirty(Material._FresnelAndMiscDirtyCallBack);
  64204. };
  64205. /**
  64206. * Indicates that lights need to be re-calculated for all submeshes
  64207. */
  64208. Material.prototype._markAllSubMeshesAsLightsDirty = function () {
  64209. this._markAllSubMeshesAsDirty(Material._LightsDirtyCallBack);
  64210. };
  64211. /**
  64212. * Indicates that attributes need to be re-calculated for all submeshes
  64213. */
  64214. Material.prototype._markAllSubMeshesAsAttributesDirty = function () {
  64215. this._markAllSubMeshesAsDirty(Material._AttributeDirtyCallBack);
  64216. };
  64217. /**
  64218. * Indicates that misc needs to be re-calculated for all submeshes
  64219. */
  64220. Material.prototype._markAllSubMeshesAsMiscDirty = function () {
  64221. this._markAllSubMeshesAsDirty(Material._MiscDirtyCallBack);
  64222. };
  64223. /**
  64224. * Indicates that textures and misc need to be re-calculated for all submeshes
  64225. */
  64226. Material.prototype._markAllSubMeshesAsTexturesAndMiscDirty = function () {
  64227. this._markAllSubMeshesAsDirty(Material._TextureAndMiscDirtyCallBack);
  64228. };
  64229. /**
  64230. * Disposes the material
  64231. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  64232. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  64233. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  64234. */
  64235. Material.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, notBoundToMesh) {
  64236. var scene = this.getScene();
  64237. // Animations
  64238. scene.stopAnimation(this);
  64239. scene.freeProcessedMaterials();
  64240. // Remove from scene
  64241. scene.removeMaterial(this);
  64242. if (notBoundToMesh !== true) {
  64243. // Remove from meshes
  64244. if (this.meshMap) {
  64245. for (var meshId in this.meshMap) {
  64246. var mesh = this.meshMap[meshId];
  64247. if (mesh) {
  64248. mesh.material = null; // will set the entry in the map to undefined
  64249. this.releaseVertexArrayObject(mesh, forceDisposeEffect);
  64250. }
  64251. }
  64252. }
  64253. else {
  64254. var meshes = scene.meshes;
  64255. for (var _i = 0, meshes_2 = meshes; _i < meshes_2.length; _i++) {
  64256. var mesh = meshes_2[_i];
  64257. if (mesh.material === this) {
  64258. mesh.material = null;
  64259. this.releaseVertexArrayObject(mesh, forceDisposeEffect);
  64260. }
  64261. }
  64262. }
  64263. }
  64264. this._uniformBuffer.dispose();
  64265. // Shader are kept in cache for further use but we can get rid of this by using forceDisposeEffect
  64266. if (forceDisposeEffect && this._effect) {
  64267. if (!this._storeEffectOnSubMeshes) {
  64268. scene.getEngine()._releaseEffect(this._effect);
  64269. }
  64270. this._effect = null;
  64271. }
  64272. // Callback
  64273. this.onDisposeObservable.notifyObservers(this);
  64274. this.onDisposeObservable.clear();
  64275. if (this._onBindObservable) {
  64276. this._onBindObservable.clear();
  64277. }
  64278. if (this._onUnBindObservable) {
  64279. this._onUnBindObservable.clear();
  64280. }
  64281. };
  64282. /** @hidden */
  64283. Material.prototype.releaseVertexArrayObject = function (mesh, forceDisposeEffect) {
  64284. if (mesh.geometry) {
  64285. var geometry = (mesh.geometry);
  64286. var scene = this.getScene();
  64287. if (this._storeEffectOnSubMeshes) {
  64288. for (var _i = 0, _a = mesh.subMeshes; _i < _a.length; _i++) {
  64289. var subMesh = _a[_i];
  64290. geometry._releaseVertexArrayObject(subMesh._materialEffect);
  64291. if (forceDisposeEffect && subMesh._materialEffect) {
  64292. scene.getEngine()._releaseEffect(subMesh._materialEffect);
  64293. }
  64294. }
  64295. }
  64296. else {
  64297. geometry._releaseVertexArrayObject(this._effect);
  64298. }
  64299. }
  64300. };
  64301. /**
  64302. * Serializes this material
  64303. * @returns the serialized material object
  64304. */
  64305. Material.prototype.serialize = function () {
  64306. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  64307. };
  64308. /**
  64309. * Creates a material from parsed material data
  64310. * @param parsedMaterial defines parsed material data
  64311. * @param scene defines the hosting scene
  64312. * @param rootUrl defines the root URL to use to load textures
  64313. * @returns a new material
  64314. */
  64315. Material.Parse = function (parsedMaterial, scene, rootUrl) {
  64316. if (!parsedMaterial.customType) {
  64317. parsedMaterial.customType = "BABYLON.StandardMaterial";
  64318. }
  64319. else if (parsedMaterial.customType === "BABYLON.PBRMaterial" && parsedMaterial.overloadedAlbedo) {
  64320. parsedMaterial.customType = "BABYLON.LegacyPBRMaterial";
  64321. if (!BABYLON.LegacyPBRMaterial) {
  64322. _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.");
  64323. return;
  64324. }
  64325. }
  64326. var materialType = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].Instantiate(parsedMaterial.customType);
  64327. return materialType.Parse(parsedMaterial, scene, rootUrl);
  64328. };
  64329. /**
  64330. * Returns the triangle fill mode
  64331. */
  64332. Material.TriangleFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleFillMode;
  64333. /**
  64334. * Returns the wireframe mode
  64335. */
  64336. Material.WireFrameFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_WireFrameFillMode;
  64337. /**
  64338. * Returns the point fill mode
  64339. */
  64340. Material.PointFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_PointFillMode;
  64341. /**
  64342. * Returns the point list draw mode
  64343. */
  64344. Material.PointListDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_PointListDrawMode;
  64345. /**
  64346. * Returns the line list draw mode
  64347. */
  64348. Material.LineListDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineListDrawMode;
  64349. /**
  64350. * Returns the line loop draw mode
  64351. */
  64352. Material.LineLoopDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineLoopDrawMode;
  64353. /**
  64354. * Returns the line strip draw mode
  64355. */
  64356. Material.LineStripDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineStripDrawMode;
  64357. /**
  64358. * Returns the triangle strip draw mode
  64359. */
  64360. Material.TriangleStripDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleStripDrawMode;
  64361. /**
  64362. * Returns the triangle fan draw mode
  64363. */
  64364. Material.TriangleFanDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleFanDrawMode;
  64365. /**
  64366. * Stores the clock-wise side orientation
  64367. */
  64368. Material.ClockWiseSideOrientation = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_ClockWiseSideOrientation;
  64369. /**
  64370. * Stores the counter clock-wise side orientation
  64371. */
  64372. Material.CounterClockWiseSideOrientation = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_CounterClockWiseSideOrientation;
  64373. /**
  64374. * The dirty texture flag value
  64375. */
  64376. Material.TextureDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TextureDirtyFlag;
  64377. /**
  64378. * The dirty light flag value
  64379. */
  64380. Material.LightDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LightDirtyFlag;
  64381. /**
  64382. * The dirty fresnel flag value
  64383. */
  64384. Material.FresnelDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_FresnelDirtyFlag;
  64385. /**
  64386. * The dirty attribute flag value
  64387. */
  64388. Material.AttributesDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_AttributesDirtyFlag;
  64389. /**
  64390. * The dirty misc flag value
  64391. */
  64392. Material.MiscDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_MiscDirtyFlag;
  64393. /**
  64394. * The all dirty flag value
  64395. */
  64396. Material.AllDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_AllDirtyFlag;
  64397. Material._ImageProcessingDirtyCallBack = function (defines) { return defines.markAsImageProcessingDirty(); };
  64398. Material._TextureDirtyCallBack = function (defines) { return defines.markAsTexturesDirty(); };
  64399. Material._FresnelDirtyCallBack = function (defines) { return defines.markAsFresnelDirty(); };
  64400. Material._MiscDirtyCallBack = function (defines) { return defines.markAsMiscDirty(); };
  64401. Material._LightsDirtyCallBack = function (defines) { return defines.markAsLightDirty(); };
  64402. Material._AttributeDirtyCallBack = function (defines) { return defines.markAsAttributesDirty(); };
  64403. Material._FresnelAndMiscDirtyCallBack = function (defines) {
  64404. Material._FresnelDirtyCallBack(defines);
  64405. Material._MiscDirtyCallBack(defines);
  64406. };
  64407. Material._TextureAndMiscDirtyCallBack = function (defines) {
  64408. Material._TextureDirtyCallBack(defines);
  64409. Material._MiscDirtyCallBack(defines);
  64410. };
  64411. Material._DirtyCallbackArray = [];
  64412. Material._RunDirtyCallBacks = function (defines) {
  64413. for (var _i = 0, _a = Material._DirtyCallbackArray; _i < _a.length; _i++) {
  64414. var cb = _a[_i];
  64415. cb(defines);
  64416. }
  64417. };
  64418. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64419. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64420. ], Material.prototype, "id", void 0);
  64421. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64422. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64423. ], Material.prototype, "uniqueId", void 0);
  64424. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64425. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64426. ], Material.prototype, "name", void 0);
  64427. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64428. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64429. ], Material.prototype, "checkReadyOnEveryCall", void 0);
  64430. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64431. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64432. ], Material.prototype, "checkReadyOnlyOnce", void 0);
  64433. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64434. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64435. ], Material.prototype, "state", void 0);
  64436. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64437. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("alpha")
  64438. ], Material.prototype, "_alpha", void 0);
  64439. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64440. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("backFaceCulling")
  64441. ], Material.prototype, "_backFaceCulling", void 0);
  64442. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64443. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64444. ], Material.prototype, "sideOrientation", void 0);
  64445. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64446. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("alphaMode")
  64447. ], Material.prototype, "_alphaMode", void 0);
  64448. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64449. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64450. ], Material.prototype, "_needDepthPrePass", void 0);
  64451. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64452. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64453. ], Material.prototype, "disableDepthWrite", void 0);
  64454. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64455. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64456. ], Material.prototype, "forceDepthWrite", void 0);
  64457. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64458. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64459. ], Material.prototype, "separateCullingPass", void 0);
  64460. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64461. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("fogEnabled")
  64462. ], Material.prototype, "_fogEnabled", void 0);
  64463. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64464. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64465. ], Material.prototype, "pointSize", void 0);
  64466. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64467. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64468. ], Material.prototype, "zOffset", void 0);
  64469. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64470. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64471. ], Material.prototype, "wireframe", null);
  64472. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64473. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64474. ], Material.prototype, "pointsCloud", null);
  64475. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  64476. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  64477. ], Material.prototype, "fillMode", null);
  64478. return Material;
  64479. }());
  64480. /***/ }),
  64481. /***/ "./Materials/materialDefines.ts":
  64482. /*!**************************************!*\
  64483. !*** ./Materials/materialDefines.ts ***!
  64484. \**************************************/
  64485. /*! exports provided: MaterialDefines */
  64486. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  64487. "use strict";
  64488. __webpack_require__.r(__webpack_exports__);
  64489. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return MaterialDefines; });
  64490. /**
  64491. * Manages the defines for the Material
  64492. */
  64493. var MaterialDefines = /** @class */ (function () {
  64494. function MaterialDefines() {
  64495. this._isDirty = true;
  64496. /** @hidden */
  64497. this._areLightsDirty = true;
  64498. /** @hidden */
  64499. this._areAttributesDirty = true;
  64500. /** @hidden */
  64501. this._areTexturesDirty = true;
  64502. /** @hidden */
  64503. this._areFresnelDirty = true;
  64504. /** @hidden */
  64505. this._areMiscDirty = true;
  64506. /** @hidden */
  64507. this._areImageProcessingDirty = true;
  64508. /** @hidden */
  64509. this._normals = false;
  64510. /** @hidden */
  64511. this._uvs = false;
  64512. /** @hidden */
  64513. this._needNormals = false;
  64514. /** @hidden */
  64515. this._needUVs = false;
  64516. }
  64517. Object.defineProperty(MaterialDefines.prototype, "isDirty", {
  64518. /**
  64519. * Specifies if the material needs to be re-calculated
  64520. */
  64521. get: function () {
  64522. return this._isDirty;
  64523. },
  64524. enumerable: true,
  64525. configurable: true
  64526. });
  64527. /**
  64528. * Marks the material to indicate that it has been re-calculated
  64529. */
  64530. MaterialDefines.prototype.markAsProcessed = function () {
  64531. this._isDirty = false;
  64532. this._areAttributesDirty = false;
  64533. this._areTexturesDirty = false;
  64534. this._areFresnelDirty = false;
  64535. this._areLightsDirty = false;
  64536. this._areMiscDirty = false;
  64537. this._areImageProcessingDirty = false;
  64538. };
  64539. /**
  64540. * Marks the material to indicate that it needs to be re-calculated
  64541. */
  64542. MaterialDefines.prototype.markAsUnprocessed = function () {
  64543. this._isDirty = true;
  64544. };
  64545. /**
  64546. * Marks the material to indicate all of its defines need to be re-calculated
  64547. */
  64548. MaterialDefines.prototype.markAllAsDirty = function () {
  64549. this._areTexturesDirty = true;
  64550. this._areAttributesDirty = true;
  64551. this._areLightsDirty = true;
  64552. this._areFresnelDirty = true;
  64553. this._areMiscDirty = true;
  64554. this._areImageProcessingDirty = true;
  64555. this._isDirty = true;
  64556. };
  64557. /**
  64558. * Marks the material to indicate that image processing needs to be re-calculated
  64559. */
  64560. MaterialDefines.prototype.markAsImageProcessingDirty = function () {
  64561. this._areImageProcessingDirty = true;
  64562. this._isDirty = true;
  64563. };
  64564. /**
  64565. * Marks the material to indicate the lights need to be re-calculated
  64566. */
  64567. MaterialDefines.prototype.markAsLightDirty = function () {
  64568. this._areLightsDirty = true;
  64569. this._isDirty = true;
  64570. };
  64571. /**
  64572. * Marks the attribute state as changed
  64573. */
  64574. MaterialDefines.prototype.markAsAttributesDirty = function () {
  64575. this._areAttributesDirty = true;
  64576. this._isDirty = true;
  64577. };
  64578. /**
  64579. * Marks the texture state as changed
  64580. */
  64581. MaterialDefines.prototype.markAsTexturesDirty = function () {
  64582. this._areTexturesDirty = true;
  64583. this._isDirty = true;
  64584. };
  64585. /**
  64586. * Marks the fresnel state as changed
  64587. */
  64588. MaterialDefines.prototype.markAsFresnelDirty = function () {
  64589. this._areFresnelDirty = true;
  64590. this._isDirty = true;
  64591. };
  64592. /**
  64593. * Marks the misc state as changed
  64594. */
  64595. MaterialDefines.prototype.markAsMiscDirty = function () {
  64596. this._areMiscDirty = true;
  64597. this._isDirty = true;
  64598. };
  64599. /**
  64600. * Rebuilds the material defines
  64601. */
  64602. MaterialDefines.prototype.rebuild = function () {
  64603. if (this._keys) {
  64604. delete this._keys;
  64605. }
  64606. this._keys = [];
  64607. for (var _i = 0, _a = Object.keys(this); _i < _a.length; _i++) {
  64608. var key = _a[_i];
  64609. if (key[0] === "_") {
  64610. continue;
  64611. }
  64612. this._keys.push(key);
  64613. }
  64614. };
  64615. /**
  64616. * Specifies if two material defines are equal
  64617. * @param other - A material define instance to compare to
  64618. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  64619. */
  64620. MaterialDefines.prototype.isEqual = function (other) {
  64621. if (this._keys.length !== other._keys.length) {
  64622. return false;
  64623. }
  64624. for (var index = 0; index < this._keys.length; index++) {
  64625. var prop = this._keys[index];
  64626. if (this[prop] !== other[prop]) {
  64627. return false;
  64628. }
  64629. }
  64630. return true;
  64631. };
  64632. /**
  64633. * Clones this instance's defines to another instance
  64634. * @param other - material defines to clone values to
  64635. */
  64636. MaterialDefines.prototype.cloneTo = function (other) {
  64637. if (this._keys.length !== other._keys.length) {
  64638. other._keys = this._keys.slice(0);
  64639. }
  64640. for (var index = 0; index < this._keys.length; index++) {
  64641. var prop = this._keys[index];
  64642. other[prop] = this[prop];
  64643. }
  64644. };
  64645. /**
  64646. * Resets the material define values
  64647. */
  64648. MaterialDefines.prototype.reset = function () {
  64649. for (var index = 0; index < this._keys.length; index++) {
  64650. var prop = this._keys[index];
  64651. var type = typeof this[prop];
  64652. switch (type) {
  64653. case "number":
  64654. this[prop] = 0;
  64655. break;
  64656. case "string":
  64657. this[prop] = "";
  64658. break;
  64659. default:
  64660. this[prop] = false;
  64661. break;
  64662. }
  64663. }
  64664. };
  64665. /**
  64666. * Converts the material define values to a string
  64667. * @returns - String of material define information
  64668. */
  64669. MaterialDefines.prototype.toString = function () {
  64670. var result = "";
  64671. for (var index = 0; index < this._keys.length; index++) {
  64672. var prop = this._keys[index];
  64673. var value = this[prop];
  64674. var type = typeof value;
  64675. switch (type) {
  64676. case "number":
  64677. case "string":
  64678. result += "#define " + prop + " " + value + "\n";
  64679. break;
  64680. default:
  64681. if (value) {
  64682. result += "#define " + prop + "\n";
  64683. }
  64684. break;
  64685. }
  64686. }
  64687. return result;
  64688. };
  64689. return MaterialDefines;
  64690. }());
  64691. /***/ }),
  64692. /***/ "./Materials/materialFlags.ts":
  64693. /*!************************************!*\
  64694. !*** ./Materials/materialFlags.ts ***!
  64695. \************************************/
  64696. /*! exports provided: MaterialFlags */
  64697. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  64698. "use strict";
  64699. __webpack_require__.r(__webpack_exports__);
  64700. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return MaterialFlags; });
  64701. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  64702. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  64703. /**
  64704. * This groups all the flags used to control the materials channel.
  64705. */
  64706. var MaterialFlags = /** @class */ (function () {
  64707. function MaterialFlags() {
  64708. }
  64709. Object.defineProperty(MaterialFlags, "DiffuseTextureEnabled", {
  64710. /**
  64711. * Are diffuse textures enabled in the application.
  64712. */
  64713. get: function () {
  64714. return this._DiffuseTextureEnabled;
  64715. },
  64716. set: function (value) {
  64717. if (this._DiffuseTextureEnabled === value) {
  64718. return;
  64719. }
  64720. this._DiffuseTextureEnabled = value;
  64721. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  64722. },
  64723. enumerable: true,
  64724. configurable: true
  64725. });
  64726. Object.defineProperty(MaterialFlags, "AmbientTextureEnabled", {
  64727. /**
  64728. * Are ambient textures enabled in the application.
  64729. */
  64730. get: function () {
  64731. return this._AmbientTextureEnabled;
  64732. },
  64733. set: function (value) {
  64734. if (this._AmbientTextureEnabled === value) {
  64735. return;
  64736. }
  64737. this._AmbientTextureEnabled = value;
  64738. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  64739. },
  64740. enumerable: true,
  64741. configurable: true
  64742. });
  64743. Object.defineProperty(MaterialFlags, "OpacityTextureEnabled", {
  64744. /**
  64745. * Are opacity textures enabled in the application.
  64746. */
  64747. get: function () {
  64748. return this._OpacityTextureEnabled;
  64749. },
  64750. set: function (value) {
  64751. if (this._OpacityTextureEnabled === value) {
  64752. return;
  64753. }
  64754. this._OpacityTextureEnabled = value;
  64755. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  64756. },
  64757. enumerable: true,
  64758. configurable: true
  64759. });
  64760. Object.defineProperty(MaterialFlags, "ReflectionTextureEnabled", {
  64761. /**
  64762. * Are reflection textures enabled in the application.
  64763. */
  64764. get: function () {
  64765. return this._ReflectionTextureEnabled;
  64766. },
  64767. set: function (value) {
  64768. if (this._ReflectionTextureEnabled === value) {
  64769. return;
  64770. }
  64771. this._ReflectionTextureEnabled = value;
  64772. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  64773. },
  64774. enumerable: true,
  64775. configurable: true
  64776. });
  64777. Object.defineProperty(MaterialFlags, "EmissiveTextureEnabled", {
  64778. /**
  64779. * Are emissive textures enabled in the application.
  64780. */
  64781. get: function () {
  64782. return this._EmissiveTextureEnabled;
  64783. },
  64784. set: function (value) {
  64785. if (this._EmissiveTextureEnabled === value) {
  64786. return;
  64787. }
  64788. this._EmissiveTextureEnabled = value;
  64789. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  64790. },
  64791. enumerable: true,
  64792. configurable: true
  64793. });
  64794. Object.defineProperty(MaterialFlags, "SpecularTextureEnabled", {
  64795. /**
  64796. * Are specular textures enabled in the application.
  64797. */
  64798. get: function () {
  64799. return this._SpecularTextureEnabled;
  64800. },
  64801. set: function (value) {
  64802. if (this._SpecularTextureEnabled === value) {
  64803. return;
  64804. }
  64805. this._SpecularTextureEnabled = value;
  64806. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  64807. },
  64808. enumerable: true,
  64809. configurable: true
  64810. });
  64811. Object.defineProperty(MaterialFlags, "BumpTextureEnabled", {
  64812. /**
  64813. * Are bump textures enabled in the application.
  64814. */
  64815. get: function () {
  64816. return this._BumpTextureEnabled;
  64817. },
  64818. set: function (value) {
  64819. if (this._BumpTextureEnabled === value) {
  64820. return;
  64821. }
  64822. this._BumpTextureEnabled = value;
  64823. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  64824. },
  64825. enumerable: true,
  64826. configurable: true
  64827. });
  64828. Object.defineProperty(MaterialFlags, "LightmapTextureEnabled", {
  64829. /**
  64830. * Are lightmap textures enabled in the application.
  64831. */
  64832. get: function () {
  64833. return this._LightmapTextureEnabled;
  64834. },
  64835. set: function (value) {
  64836. if (this._LightmapTextureEnabled === value) {
  64837. return;
  64838. }
  64839. this._LightmapTextureEnabled = value;
  64840. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  64841. },
  64842. enumerable: true,
  64843. configurable: true
  64844. });
  64845. Object.defineProperty(MaterialFlags, "RefractionTextureEnabled", {
  64846. /**
  64847. * Are refraction textures enabled in the application.
  64848. */
  64849. get: function () {
  64850. return this._RefractionTextureEnabled;
  64851. },
  64852. set: function (value) {
  64853. if (this._RefractionTextureEnabled === value) {
  64854. return;
  64855. }
  64856. this._RefractionTextureEnabled = value;
  64857. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  64858. },
  64859. enumerable: true,
  64860. configurable: true
  64861. });
  64862. Object.defineProperty(MaterialFlags, "ColorGradingTextureEnabled", {
  64863. /**
  64864. * Are color grading textures enabled in the application.
  64865. */
  64866. get: function () {
  64867. return this._ColorGradingTextureEnabled;
  64868. },
  64869. set: function (value) {
  64870. if (this._ColorGradingTextureEnabled === value) {
  64871. return;
  64872. }
  64873. this._ColorGradingTextureEnabled = value;
  64874. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  64875. },
  64876. enumerable: true,
  64877. configurable: true
  64878. });
  64879. Object.defineProperty(MaterialFlags, "FresnelEnabled", {
  64880. /**
  64881. * Are fresnels enabled in the application.
  64882. */
  64883. get: function () {
  64884. return this._FresnelEnabled;
  64885. },
  64886. set: function (value) {
  64887. if (this._FresnelEnabled === value) {
  64888. return;
  64889. }
  64890. this._FresnelEnabled = value;
  64891. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_FresnelDirtyFlag);
  64892. },
  64893. enumerable: true,
  64894. configurable: true
  64895. });
  64896. Object.defineProperty(MaterialFlags, "ClearCoatTextureEnabled", {
  64897. /**
  64898. * Are clear coat textures enabled in the application.
  64899. */
  64900. get: function () {
  64901. return this._ClearCoatTextureEnabled;
  64902. },
  64903. set: function (value) {
  64904. if (this._ClearCoatTextureEnabled === value) {
  64905. return;
  64906. }
  64907. this._ClearCoatTextureEnabled = value;
  64908. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  64909. },
  64910. enumerable: true,
  64911. configurable: true
  64912. });
  64913. Object.defineProperty(MaterialFlags, "ClearCoatBumpTextureEnabled", {
  64914. /**
  64915. * Are clear coat bump textures enabled in the application.
  64916. */
  64917. get: function () {
  64918. return this._ClearCoatBumpTextureEnabled;
  64919. },
  64920. set: function (value) {
  64921. if (this._ClearCoatBumpTextureEnabled === value) {
  64922. return;
  64923. }
  64924. this._ClearCoatBumpTextureEnabled = value;
  64925. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  64926. },
  64927. enumerable: true,
  64928. configurable: true
  64929. });
  64930. Object.defineProperty(MaterialFlags, "ClearCoatTintTextureEnabled", {
  64931. /**
  64932. * Are clear coat tint textures enabled in the application.
  64933. */
  64934. get: function () {
  64935. return this._ClearCoatTintTextureEnabled;
  64936. },
  64937. set: function (value) {
  64938. if (this._ClearCoatTintTextureEnabled === value) {
  64939. return;
  64940. }
  64941. this._ClearCoatTintTextureEnabled = value;
  64942. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  64943. },
  64944. enumerable: true,
  64945. configurable: true
  64946. });
  64947. // Flags used to enable or disable a type of texture for all Standard Materials
  64948. MaterialFlags._DiffuseTextureEnabled = true;
  64949. MaterialFlags._AmbientTextureEnabled = true;
  64950. MaterialFlags._OpacityTextureEnabled = true;
  64951. MaterialFlags._ReflectionTextureEnabled = true;
  64952. MaterialFlags._EmissiveTextureEnabled = true;
  64953. MaterialFlags._SpecularTextureEnabled = true;
  64954. MaterialFlags._BumpTextureEnabled = true;
  64955. MaterialFlags._LightmapTextureEnabled = true;
  64956. MaterialFlags._RefractionTextureEnabled = true;
  64957. MaterialFlags._ColorGradingTextureEnabled = true;
  64958. MaterialFlags._FresnelEnabled = true;
  64959. MaterialFlags._ClearCoatTextureEnabled = true;
  64960. MaterialFlags._ClearCoatBumpTextureEnabled = true;
  64961. MaterialFlags._ClearCoatTintTextureEnabled = true;
  64962. return MaterialFlags;
  64963. }());
  64964. /***/ }),
  64965. /***/ "./Materials/materialHelper.ts":
  64966. /*!*************************************!*\
  64967. !*** ./Materials/materialHelper.ts ***!
  64968. \*************************************/
  64969. /*! exports provided: MaterialHelper */
  64970. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  64971. "use strict";
  64972. __webpack_require__.r(__webpack_exports__);
  64973. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return MaterialHelper; });
  64974. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  64975. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  64976. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  64977. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  64978. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  64979. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Lights/light */ "./Lights/light.ts");
  64980. /**
  64981. * "Static Class" containing the most commonly used helper while dealing with material for
  64982. * rendering purpose.
  64983. *
  64984. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  64985. *
  64986. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  64987. */
  64988. var MaterialHelper = /** @class */ (function () {
  64989. function MaterialHelper() {
  64990. }
  64991. /**
  64992. * Bind the current view position to an effect.
  64993. * @param effect The effect to be bound
  64994. * @param scene The scene the eyes position is used from
  64995. */
  64996. MaterialHelper.BindEyePosition = function (effect, scene) {
  64997. if (scene._forcedViewPosition) {
  64998. effect.setVector3("vEyePosition", scene._forcedViewPosition);
  64999. return;
  65000. }
  65001. effect.setVector3("vEyePosition", scene._mirroredCameraPosition ? scene._mirroredCameraPosition : scene.activeCamera.globalPosition);
  65002. };
  65003. /**
  65004. * Helps preparing the defines values about the UVs in used in the effect.
  65005. * UVs are shared as much as we can accross channels in the shaders.
  65006. * @param texture The texture we are preparing the UVs for
  65007. * @param defines The defines to update
  65008. * @param key The channel key "diffuse", "specular"... used in the shader
  65009. */
  65010. MaterialHelper.PrepareDefinesForMergedUV = function (texture, defines, key) {
  65011. defines._needUVs = true;
  65012. defines[key] = true;
  65013. if (texture.getTextureMatrix().isIdentityAs3x2()) {
  65014. defines[key + "DIRECTUV"] = texture.coordinatesIndex + 1;
  65015. if (texture.coordinatesIndex === 0) {
  65016. defines["MAINUV1"] = true;
  65017. }
  65018. else {
  65019. defines["MAINUV2"] = true;
  65020. }
  65021. }
  65022. else {
  65023. defines[key + "DIRECTUV"] = 0;
  65024. }
  65025. };
  65026. /**
  65027. * Binds a texture matrix value to its corrsponding uniform
  65028. * @param texture The texture to bind the matrix for
  65029. * @param uniformBuffer The uniform buffer receivin the data
  65030. * @param key The channel key "diffuse", "specular"... used in the shader
  65031. */
  65032. MaterialHelper.BindTextureMatrix = function (texture, uniformBuffer, key) {
  65033. var matrix = texture.getTextureMatrix();
  65034. if (!matrix.isIdentityAs3x2()) {
  65035. uniformBuffer.updateMatrix(key + "Matrix", matrix);
  65036. }
  65037. };
  65038. /**
  65039. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  65040. * @param mesh defines the current mesh
  65041. * @param scene defines the current scene
  65042. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  65043. * @param pointsCloud defines if point cloud rendering has to be turned on
  65044. * @param fogEnabled defines if fog has to be turned on
  65045. * @param alphaTest defines if alpha testing has to be turned on
  65046. * @param defines defines the current list of defines
  65047. */
  65048. MaterialHelper.PrepareDefinesForMisc = function (mesh, scene, useLogarithmicDepth, pointsCloud, fogEnabled, alphaTest, defines) {
  65049. if (defines._areMiscDirty) {
  65050. defines["LOGARITHMICDEPTH"] = useLogarithmicDepth;
  65051. defines["POINTSIZE"] = pointsCloud;
  65052. defines["FOG"] = (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE && fogEnabled);
  65053. defines["NONUNIFORMSCALING"] = mesh.nonUniformScaling;
  65054. defines["ALPHATEST"] = alphaTest;
  65055. }
  65056. };
  65057. /**
  65058. * Helper used to prepare the list of defines associated with frame values for shader compilation
  65059. * @param scene defines the current scene
  65060. * @param engine defines the current engine
  65061. * @param defines specifies the list of active defines
  65062. * @param useInstances defines if instances have to be turned on
  65063. * @param useClipPlane defines if clip plane have to be turned on
  65064. */
  65065. MaterialHelper.PrepareDefinesForFrameBoundValues = function (scene, engine, defines, useInstances, useClipPlane) {
  65066. if (useClipPlane === void 0) { useClipPlane = null; }
  65067. var changed = false;
  65068. var useClipPlane1 = false;
  65069. var useClipPlane2 = false;
  65070. var useClipPlane3 = false;
  65071. var useClipPlane4 = false;
  65072. useClipPlane1 = useClipPlane == null ? (scene.clipPlane !== undefined && scene.clipPlane !== null) : useClipPlane;
  65073. useClipPlane2 = useClipPlane == null ? (scene.clipPlane2 !== undefined && scene.clipPlane2 !== null) : useClipPlane;
  65074. useClipPlane3 = useClipPlane == null ? (scene.clipPlane3 !== undefined && scene.clipPlane3 !== null) : useClipPlane;
  65075. useClipPlane4 = useClipPlane == null ? (scene.clipPlane4 !== undefined && scene.clipPlane4 !== null) : useClipPlane;
  65076. if (defines["CLIPPLANE"] !== useClipPlane1) {
  65077. defines["CLIPPLANE"] = useClipPlane1;
  65078. changed = true;
  65079. }
  65080. if (defines["CLIPPLANE2"] !== useClipPlane2) {
  65081. defines["CLIPPLANE2"] = useClipPlane2;
  65082. changed = true;
  65083. }
  65084. if (defines["CLIPPLANE3"] !== useClipPlane3) {
  65085. defines["CLIPPLANE3"] = useClipPlane3;
  65086. changed = true;
  65087. }
  65088. if (defines["CLIPPLANE4"] !== useClipPlane4) {
  65089. defines["CLIPPLANE4"] = useClipPlane4;
  65090. changed = true;
  65091. }
  65092. if (defines["DEPTHPREPASS"] !== !engine.getColorWrite()) {
  65093. defines["DEPTHPREPASS"] = !defines["DEPTHPREPASS"];
  65094. changed = true;
  65095. }
  65096. if (defines["INSTANCES"] !== useInstances) {
  65097. defines["INSTANCES"] = useInstances;
  65098. changed = true;
  65099. }
  65100. if (changed) {
  65101. defines.markAsUnprocessed();
  65102. }
  65103. };
  65104. /**
  65105. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  65106. * @param mesh The mesh containing the geometry data we will draw
  65107. * @param defines The defines to update
  65108. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  65109. * @param useBones Precise whether bones should be used or not (override mesh info)
  65110. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  65111. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  65112. * @returns false if defines are considered not dirty and have not been checked
  65113. */
  65114. MaterialHelper.PrepareDefinesForAttributes = function (mesh, defines, useVertexColor, useBones, useMorphTargets, useVertexAlpha) {
  65115. if (useMorphTargets === void 0) { useMorphTargets = false; }
  65116. if (useVertexAlpha === void 0) { useVertexAlpha = true; }
  65117. if (!defines._areAttributesDirty && defines._needNormals === defines._normals && defines._needUVs === defines._uvs) {
  65118. return false;
  65119. }
  65120. defines._normals = defines._needNormals;
  65121. defines._uvs = defines._needUVs;
  65122. defines["NORMAL"] = (defines._needNormals && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind));
  65123. if (defines._needNormals && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].TangentKind)) {
  65124. defines["TANGENT"] = true;
  65125. }
  65126. if (defines._needUVs) {
  65127. defines["UV1"] = mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  65128. defines["UV2"] = mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind);
  65129. }
  65130. else {
  65131. defines["UV1"] = false;
  65132. defines["UV2"] = false;
  65133. }
  65134. if (useVertexColor) {
  65135. var hasVertexColors = mesh.useVertexColors && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  65136. defines["VERTEXCOLOR"] = hasVertexColors;
  65137. defines["VERTEXALPHA"] = mesh.hasVertexAlpha && hasVertexColors && useVertexAlpha;
  65138. }
  65139. if (useBones) {
  65140. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  65141. defines["NUM_BONE_INFLUENCERS"] = mesh.numBoneInfluencers;
  65142. var materialSupportsBoneTexture = defines["BONETEXTURE"] !== undefined;
  65143. if (mesh.skeleton.isUsingTextureForMatrices && materialSupportsBoneTexture) {
  65144. defines["BONETEXTURE"] = true;
  65145. }
  65146. else {
  65147. defines["BonesPerMesh"] = (mesh.skeleton.bones.length + 1);
  65148. defines["BONETEXTURE"] = materialSupportsBoneTexture ? false : undefined;
  65149. }
  65150. }
  65151. else {
  65152. defines["NUM_BONE_INFLUENCERS"] = 0;
  65153. defines["BonesPerMesh"] = 0;
  65154. }
  65155. }
  65156. if (useMorphTargets) {
  65157. var manager = mesh.morphTargetManager;
  65158. if (manager) {
  65159. defines["MORPHTARGETS_TANGENT"] = manager.supportsTangents && defines["TANGENT"];
  65160. defines["MORPHTARGETS_NORMAL"] = manager.supportsNormals && defines["NORMAL"];
  65161. defines["MORPHTARGETS"] = (manager.numInfluencers > 0);
  65162. defines["NUM_MORPH_INFLUENCERS"] = manager.numInfluencers;
  65163. }
  65164. else {
  65165. defines["MORPHTARGETS_TANGENT"] = false;
  65166. defines["MORPHTARGETS_NORMAL"] = false;
  65167. defines["MORPHTARGETS"] = false;
  65168. defines["NUM_MORPH_INFLUENCERS"] = 0;
  65169. }
  65170. }
  65171. return true;
  65172. };
  65173. /**
  65174. * Prepares the defines related to the light information passed in parameter
  65175. * @param scene The scene we are intending to draw
  65176. * @param mesh The mesh the effect is compiling for
  65177. * @param defines The defines to update
  65178. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  65179. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  65180. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  65181. * @returns true if normals will be required for the rest of the effect
  65182. */
  65183. MaterialHelper.PrepareDefinesForLights = function (scene, mesh, defines, specularSupported, maxSimultaneousLights, disableLighting) {
  65184. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  65185. if (disableLighting === void 0) { disableLighting = false; }
  65186. if (!defines._areLightsDirty) {
  65187. return defines._needNormals;
  65188. }
  65189. var lightIndex = 0;
  65190. var needNormals = false;
  65191. var needRebuild = false;
  65192. var lightmapMode = false;
  65193. var shadowEnabled = false;
  65194. var specularEnabled = false;
  65195. if (scene.lightsEnabled && !disableLighting) {
  65196. for (var _i = 0, _a = mesh._lightSources; _i < _a.length; _i++) {
  65197. var light = _a[_i];
  65198. needNormals = true;
  65199. if (defines["LIGHT" + lightIndex] === undefined) {
  65200. needRebuild = true;
  65201. }
  65202. defines["LIGHT" + lightIndex] = true;
  65203. defines["SPOTLIGHT" + lightIndex] = false;
  65204. defines["HEMILIGHT" + lightIndex] = false;
  65205. defines["POINTLIGHT" + lightIndex] = false;
  65206. defines["DIRLIGHT" + lightIndex] = false;
  65207. light.prepareLightSpecificDefines(defines, lightIndex);
  65208. // FallOff.
  65209. defines["LIGHT_FALLOFF_PHYSICAL" + lightIndex] = false;
  65210. defines["LIGHT_FALLOFF_GLTF" + lightIndex] = false;
  65211. defines["LIGHT_FALLOFF_STANDARD" + lightIndex] = false;
  65212. switch (light.falloffType) {
  65213. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_GLTF:
  65214. defines["LIGHT_FALLOFF_GLTF" + lightIndex] = true;
  65215. break;
  65216. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_PHYSICAL:
  65217. defines["LIGHT_FALLOFF_PHYSICAL" + lightIndex] = true;
  65218. break;
  65219. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_STANDARD:
  65220. defines["LIGHT_FALLOFF_STANDARD" + lightIndex] = true;
  65221. break;
  65222. }
  65223. // Specular
  65224. if (specularSupported && !light.specular.equalsFloats(0, 0, 0)) {
  65225. specularEnabled = true;
  65226. }
  65227. // Shadows
  65228. defines["SHADOW" + lightIndex] = false;
  65229. defines["SHADOWPCF" + lightIndex] = false;
  65230. defines["SHADOWPCSS" + lightIndex] = false;
  65231. defines["SHADOWPOISSON" + lightIndex] = false;
  65232. defines["SHADOWESM" + lightIndex] = false;
  65233. defines["SHADOWCUBE" + lightIndex] = false;
  65234. defines["SHADOWLOWQUALITY" + lightIndex] = false;
  65235. defines["SHADOWMEDIUMQUALITY" + lightIndex] = false;
  65236. if (mesh && mesh.receiveShadows && scene.shadowsEnabled && light.shadowEnabled) {
  65237. var shadowGenerator = light.getShadowGenerator();
  65238. if (shadowGenerator) {
  65239. var shadowMap = shadowGenerator.getShadowMap();
  65240. if (shadowMap) {
  65241. if (shadowMap.renderList && shadowMap.renderList.length > 0) {
  65242. shadowEnabled = true;
  65243. shadowGenerator.prepareDefines(defines, lightIndex);
  65244. }
  65245. }
  65246. }
  65247. }
  65248. if (light.lightmapMode != _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].LIGHTMAP_DEFAULT) {
  65249. lightmapMode = true;
  65250. defines["LIGHTMAPEXCLUDED" + lightIndex] = true;
  65251. defines["LIGHTMAPNOSPECULAR" + lightIndex] = (light.lightmapMode == _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].LIGHTMAP_SHADOWSONLY);
  65252. }
  65253. else {
  65254. defines["LIGHTMAPEXCLUDED" + lightIndex] = false;
  65255. defines["LIGHTMAPNOSPECULAR" + lightIndex] = false;
  65256. }
  65257. lightIndex++;
  65258. if (lightIndex === maxSimultaneousLights) {
  65259. break;
  65260. }
  65261. }
  65262. }
  65263. defines["SPECULARTERM"] = specularEnabled;
  65264. defines["SHADOWS"] = shadowEnabled;
  65265. // Resetting all other lights if any
  65266. for (var index = lightIndex; index < maxSimultaneousLights; index++) {
  65267. if (defines["LIGHT" + index] !== undefined) {
  65268. defines["LIGHT" + index] = false;
  65269. defines["HEMILIGHT" + index] = false;
  65270. defines["POINTLIGHT" + index] = false;
  65271. defines["DIRLIGHT" + index] = false;
  65272. defines["SPOTLIGHT" + index] = false;
  65273. defines["SHADOW" + index] = false;
  65274. defines["SHADOWPCF" + index] = false;
  65275. defines["SHADOWPCSS" + index] = false;
  65276. defines["SHADOWPOISSON" + index] = false;
  65277. defines["SHADOWESM" + index] = false;
  65278. defines["SHADOWCUBE" + index] = false;
  65279. defines["SHADOWLOWQUALITY" + index] = false;
  65280. defines["SHADOWMEDIUMQUALITY" + index] = false;
  65281. }
  65282. }
  65283. var caps = scene.getEngine().getCaps();
  65284. if (defines["SHADOWFLOAT"] === undefined) {
  65285. needRebuild = true;
  65286. }
  65287. defines["SHADOWFLOAT"] = shadowEnabled &&
  65288. ((caps.textureFloatRender && caps.textureFloatLinearFiltering) ||
  65289. (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering));
  65290. defines["LIGHTMAPEXCLUDED"] = lightmapMode;
  65291. if (needRebuild) {
  65292. defines.rebuild();
  65293. }
  65294. return needNormals;
  65295. };
  65296. /**
  65297. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  65298. * that won t be acctive due to defines being turned off.
  65299. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  65300. * @param samplersList The samplers list
  65301. * @param defines The defines helping in the list generation
  65302. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  65303. */
  65304. MaterialHelper.PrepareUniformsAndSamplersList = function (uniformsListOrOptions, samplersList, defines, maxSimultaneousLights) {
  65305. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  65306. var uniformsList;
  65307. var uniformBuffersList = null;
  65308. if (uniformsListOrOptions.uniformsNames) {
  65309. var options = uniformsListOrOptions;
  65310. uniformsList = options.uniformsNames;
  65311. uniformBuffersList = options.uniformBuffersNames;
  65312. samplersList = options.samplers;
  65313. defines = options.defines;
  65314. maxSimultaneousLights = options.maxSimultaneousLights;
  65315. }
  65316. else {
  65317. uniformsList = uniformsListOrOptions;
  65318. if (!samplersList) {
  65319. samplersList = [];
  65320. }
  65321. }
  65322. for (var lightIndex = 0; lightIndex < maxSimultaneousLights; lightIndex++) {
  65323. if (!defines["LIGHT" + lightIndex]) {
  65324. break;
  65325. }
  65326. uniformsList.push("vLightData" + lightIndex, "vLightDiffuse" + lightIndex, "vLightSpecular" + lightIndex, "vLightDirection" + lightIndex, "vLightFalloff" + lightIndex, "vLightGround" + lightIndex, "lightMatrix" + lightIndex, "shadowsInfo" + lightIndex, "depthValues" + lightIndex);
  65327. if (uniformBuffersList) {
  65328. uniformBuffersList.push("Light" + lightIndex);
  65329. }
  65330. samplersList.push("shadowSampler" + lightIndex);
  65331. samplersList.push("depthSampler" + lightIndex);
  65332. if (defines["PROJECTEDLIGHTTEXTURE" + lightIndex]) {
  65333. samplersList.push("projectionLightSampler" + lightIndex);
  65334. uniformsList.push("textureProjectionMatrix" + lightIndex);
  65335. }
  65336. }
  65337. if (defines["NUM_MORPH_INFLUENCERS"]) {
  65338. uniformsList.push("morphTargetInfluences");
  65339. }
  65340. };
  65341. /**
  65342. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  65343. * @param defines The defines to update while falling back
  65344. * @param fallbacks The authorized effect fallbacks
  65345. * @param maxSimultaneousLights The maximum number of lights allowed
  65346. * @param rank the current rank of the Effect
  65347. * @returns The newly affected rank
  65348. */
  65349. MaterialHelper.HandleFallbacksForShadows = function (defines, fallbacks, maxSimultaneousLights, rank) {
  65350. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  65351. if (rank === void 0) { rank = 0; }
  65352. var lightFallbackRank = 0;
  65353. for (var lightIndex = 0; lightIndex < maxSimultaneousLights; lightIndex++) {
  65354. if (!defines["LIGHT" + lightIndex]) {
  65355. break;
  65356. }
  65357. if (lightIndex > 0) {
  65358. lightFallbackRank = rank + lightIndex;
  65359. fallbacks.addFallback(lightFallbackRank, "LIGHT" + lightIndex);
  65360. }
  65361. if (!defines["SHADOWS"]) {
  65362. if (defines["SHADOW" + lightIndex]) {
  65363. fallbacks.addFallback(rank, "SHADOW" + lightIndex);
  65364. }
  65365. if (defines["SHADOWPCF" + lightIndex]) {
  65366. fallbacks.addFallback(rank, "SHADOWPCF" + lightIndex);
  65367. }
  65368. if (defines["SHADOWPCSS" + lightIndex]) {
  65369. fallbacks.addFallback(rank, "SHADOWPCSS" + lightIndex);
  65370. }
  65371. if (defines["SHADOWPOISSON" + lightIndex]) {
  65372. fallbacks.addFallback(rank, "SHADOWPOISSON" + lightIndex);
  65373. }
  65374. if (defines["SHADOWESM" + lightIndex]) {
  65375. fallbacks.addFallback(rank, "SHADOWESM" + lightIndex);
  65376. }
  65377. }
  65378. }
  65379. return lightFallbackRank++;
  65380. };
  65381. /**
  65382. * Prepares the list of attributes required for morph targets according to the effect defines.
  65383. * @param attribs The current list of supported attribs
  65384. * @param mesh The mesh to prepare the morph targets attributes for
  65385. * @param defines The current Defines of the effect
  65386. */
  65387. MaterialHelper.PrepareAttributesForMorphTargets = function (attribs, mesh, defines) {
  65388. var influencers = defines["NUM_MORPH_INFLUENCERS"];
  65389. if (influencers > 0 && _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedEngine) {
  65390. var maxAttributesCount = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedEngine.getCaps().maxVertexAttribs;
  65391. var manager = mesh.morphTargetManager;
  65392. var normal = manager && manager.supportsNormals && defines["NORMAL"];
  65393. var tangent = manager && manager.supportsTangents && defines["TANGENT"];
  65394. for (var index = 0; index < influencers; index++) {
  65395. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind + index);
  65396. if (normal) {
  65397. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind + index);
  65398. }
  65399. if (tangent) {
  65400. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].TangentKind + index);
  65401. }
  65402. if (attribs.length > maxAttributesCount) {
  65403. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Cannot add more vertex attributes for mesh " + mesh.name);
  65404. }
  65405. }
  65406. }
  65407. };
  65408. /**
  65409. * Prepares the list of attributes required for bones according to the effect defines.
  65410. * @param attribs The current list of supported attribs
  65411. * @param mesh The mesh to prepare the bones attributes for
  65412. * @param defines The current Defines of the effect
  65413. * @param fallbacks The current efffect fallback strategy
  65414. */
  65415. MaterialHelper.PrepareAttributesForBones = function (attribs, mesh, defines, fallbacks) {
  65416. if (defines["NUM_BONE_INFLUENCERS"] > 0) {
  65417. fallbacks.addCPUSkinningFallback(0, mesh);
  65418. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesKind);
  65419. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsKind);
  65420. if (defines["NUM_BONE_INFLUENCERS"] > 4) {
  65421. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesExtraKind);
  65422. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsExtraKind);
  65423. }
  65424. }
  65425. };
  65426. /**
  65427. * Prepares the list of attributes required for instances according to the effect defines.
  65428. * @param attribs The current list of supported attribs
  65429. * @param defines The current Defines of the effect
  65430. */
  65431. MaterialHelper.PrepareAttributesForInstances = function (attribs, defines) {
  65432. if (defines["INSTANCES"]) {
  65433. attribs.push("world0");
  65434. attribs.push("world1");
  65435. attribs.push("world2");
  65436. attribs.push("world3");
  65437. }
  65438. };
  65439. /**
  65440. * Binds the light shadow information to the effect for the given mesh.
  65441. * @param light The light containing the generator
  65442. * @param scene The scene the lights belongs to
  65443. * @param mesh The mesh we are binding the information to render
  65444. * @param lightIndex The light index in the effect used to render the mesh
  65445. * @param effect The effect we are binding the data to
  65446. */
  65447. MaterialHelper.BindLightShadow = function (light, mesh, lightIndex, effect) {
  65448. if (light.shadowEnabled && mesh.receiveShadows) {
  65449. var shadowGenerator = light.getShadowGenerator();
  65450. if (shadowGenerator) {
  65451. shadowGenerator.bindShadowLight(lightIndex, effect);
  65452. }
  65453. }
  65454. };
  65455. /**
  65456. * Binds the light information to the effect.
  65457. * @param light The light containing the generator
  65458. * @param effect The effect we are binding the data to
  65459. * @param lightIndex The light index in the effect used to render
  65460. */
  65461. MaterialHelper.BindLightProperties = function (light, effect, lightIndex) {
  65462. light.transferToEffect(effect, lightIndex + "");
  65463. };
  65464. /**
  65465. * Binds the lights information from the scene to the effect for the given mesh.
  65466. * @param scene The scene the lights belongs to
  65467. * @param mesh The mesh we are binding the information to render
  65468. * @param effect The effect we are binding the data to
  65469. * @param defines The generated defines for the effect
  65470. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  65471. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  65472. */
  65473. MaterialHelper.BindLights = function (scene, mesh, effect, defines, maxSimultaneousLights, usePhysicalLightFalloff) {
  65474. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  65475. if (usePhysicalLightFalloff === void 0) { usePhysicalLightFalloff = false; }
  65476. var len = Math.min(mesh._lightSources.length, maxSimultaneousLights);
  65477. for (var i = 0; i < len; i++) {
  65478. var light = mesh._lightSources[i];
  65479. var iAsString = i.toString();
  65480. var scaledIntensity = light.getScaledIntensity();
  65481. light._uniformBuffer.bindToEffect(effect, "Light" + i);
  65482. MaterialHelper.BindLightProperties(light, effect, i);
  65483. light.diffuse.scaleToRef(scaledIntensity, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[0]);
  65484. light._uniformBuffer.updateColor4("vLightDiffuse", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[0], usePhysicalLightFalloff ? light.radius : light.range, iAsString);
  65485. if (defines["SPECULARTERM"]) {
  65486. light.specular.scaleToRef(scaledIntensity, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[1]);
  65487. light._uniformBuffer.updateColor3("vLightSpecular", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[1], iAsString);
  65488. }
  65489. // Shadows
  65490. if (scene.shadowsEnabled) {
  65491. this.BindLightShadow(light, mesh, iAsString, effect);
  65492. }
  65493. light._uniformBuffer.update();
  65494. }
  65495. };
  65496. /**
  65497. * Binds the fog information from the scene to the effect for the given mesh.
  65498. * @param scene The scene the lights belongs to
  65499. * @param mesh The mesh we are binding the information to render
  65500. * @param effect The effect we are binding the data to
  65501. * @param linearSpace Defines if the fog effect is applied in linear space
  65502. */
  65503. MaterialHelper.BindFogParameters = function (scene, mesh, effect, linearSpace) {
  65504. if (linearSpace === void 0) { linearSpace = false; }
  65505. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE) {
  65506. effect.setFloat4("vFogInfos", scene.fogMode, scene.fogStart, scene.fogEnd, scene.fogDensity);
  65507. // Convert fog color to linear space if used in a linear space computed shader.
  65508. if (linearSpace) {
  65509. scene.fogColor.toLinearSpaceToRef(this._tempFogColor);
  65510. effect.setColor3("vFogColor", this._tempFogColor);
  65511. }
  65512. else {
  65513. effect.setColor3("vFogColor", scene.fogColor);
  65514. }
  65515. }
  65516. };
  65517. /**
  65518. * Binds the bones information from the mesh to the effect.
  65519. * @param mesh The mesh we are binding the information to render
  65520. * @param effect The effect we are binding the data to
  65521. */
  65522. MaterialHelper.BindBonesParameters = function (mesh, effect) {
  65523. if (!effect || !mesh) {
  65524. return;
  65525. }
  65526. if (mesh.computeBonesUsingShaders && effect._bonesComputationForcedToCPU) {
  65527. mesh.computeBonesUsingShaders = false;
  65528. }
  65529. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  65530. var skeleton = mesh.skeleton;
  65531. if (skeleton.isUsingTextureForMatrices && effect.getUniformIndex("boneTextureWidth") > -1) {
  65532. var boneTexture = skeleton.getTransformMatrixTexture();
  65533. effect.setTexture("boneSampler", boneTexture);
  65534. effect.setFloat("boneTextureWidth", 4.0 * (skeleton.bones.length + 1));
  65535. }
  65536. else {
  65537. var matrices = skeleton.getTransformMatrices(mesh);
  65538. if (matrices) {
  65539. effect.setMatrices("mBones", matrices);
  65540. }
  65541. }
  65542. }
  65543. };
  65544. /**
  65545. * Binds the morph targets information from the mesh to the effect.
  65546. * @param abstractMesh The mesh we are binding the information to render
  65547. * @param effect The effect we are binding the data to
  65548. */
  65549. MaterialHelper.BindMorphTargetParameters = function (abstractMesh, effect) {
  65550. var manager = abstractMesh.morphTargetManager;
  65551. if (!abstractMesh || !manager) {
  65552. return;
  65553. }
  65554. effect.setFloatArray("morphTargetInfluences", manager.influences);
  65555. };
  65556. /**
  65557. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  65558. * @param defines The generated defines used in the effect
  65559. * @param effect The effect we are binding the data to
  65560. * @param scene The scene we are willing to render with logarithmic scale for
  65561. */
  65562. MaterialHelper.BindLogDepth = function (defines, effect, scene) {
  65563. if (defines["LOGARITHMICDEPTH"]) {
  65564. effect.setFloat("logarithmicDepthConstant", 2.0 / (Math.log(scene.activeCamera.maxZ + 1.0) / Math.LN2));
  65565. }
  65566. };
  65567. /**
  65568. * Binds the clip plane information from the scene to the effect.
  65569. * @param scene The scene the clip plane information are extracted from
  65570. * @param effect The effect we are binding the data to
  65571. */
  65572. MaterialHelper.BindClipPlane = function (effect, scene) {
  65573. if (scene.clipPlane) {
  65574. var clipPlane = scene.clipPlane;
  65575. effect.setFloat4("vClipPlane", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  65576. }
  65577. if (scene.clipPlane2) {
  65578. var clipPlane = scene.clipPlane2;
  65579. effect.setFloat4("vClipPlane2", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  65580. }
  65581. if (scene.clipPlane3) {
  65582. var clipPlane = scene.clipPlane3;
  65583. effect.setFloat4("vClipPlane3", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  65584. }
  65585. if (scene.clipPlane4) {
  65586. var clipPlane = scene.clipPlane4;
  65587. effect.setFloat4("vClipPlane4", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  65588. }
  65589. };
  65590. MaterialHelper._tempFogColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  65591. return MaterialHelper;
  65592. }());
  65593. /***/ }),
  65594. /***/ "./Materials/multiMaterial.ts":
  65595. /*!************************************!*\
  65596. !*** ./Materials/multiMaterial.ts ***!
  65597. \************************************/
  65598. /*! exports provided: MultiMaterial */
  65599. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  65600. "use strict";
  65601. __webpack_require__.r(__webpack_exports__);
  65602. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return MultiMaterial; });
  65603. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  65604. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  65605. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  65606. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  65607. /**
  65608. * A multi-material is used to apply different materials to different parts of the same object without the need of
  65609. * separate meshes. This can be use to improve performances.
  65610. * @see http://doc.babylonjs.com/how_to/multi_materials
  65611. */
  65612. var MultiMaterial = /** @class */ (function (_super) {
  65613. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiMaterial, _super);
  65614. /**
  65615. * Instantiates a new Multi Material
  65616. * A multi-material is used to apply different materials to different parts of the same object without the need of
  65617. * separate meshes. This can be use to improve performances.
  65618. * @see http://doc.babylonjs.com/how_to/multi_materials
  65619. * @param name Define the name in the scene
  65620. * @param scene Define the scene the material belongs to
  65621. */
  65622. function MultiMaterial(name, scene) {
  65623. var _this = _super.call(this, name, scene, true) || this;
  65624. scene.multiMaterials.push(_this);
  65625. _this.subMaterials = new Array();
  65626. _this._storeEffectOnSubMeshes = true; // multimaterial is considered like a push material
  65627. return _this;
  65628. }
  65629. Object.defineProperty(MultiMaterial.prototype, "subMaterials", {
  65630. /**
  65631. * Gets or Sets the list of Materials used within the multi material.
  65632. * They need to be ordered according to the submeshes order in the associated mesh
  65633. */
  65634. get: function () {
  65635. return this._subMaterials;
  65636. },
  65637. set: function (value) {
  65638. this._subMaterials = value;
  65639. this._hookArray(value);
  65640. },
  65641. enumerable: true,
  65642. configurable: true
  65643. });
  65644. /**
  65645. * Function used to align with Node.getChildren()
  65646. * @returns the list of Materials used within the multi material
  65647. */
  65648. MultiMaterial.prototype.getChildren = function () {
  65649. return this.subMaterials;
  65650. };
  65651. MultiMaterial.prototype._hookArray = function (array) {
  65652. var _this = this;
  65653. var oldPush = array.push;
  65654. array.push = function () {
  65655. var items = [];
  65656. for (var _i = 0; _i < arguments.length; _i++) {
  65657. items[_i] = arguments[_i];
  65658. }
  65659. var result = oldPush.apply(array, items);
  65660. _this._markAllSubMeshesAsTexturesDirty();
  65661. return result;
  65662. };
  65663. var oldSplice = array.splice;
  65664. array.splice = function (index, deleteCount) {
  65665. var deleted = oldSplice.apply(array, [index, deleteCount]);
  65666. _this._markAllSubMeshesAsTexturesDirty();
  65667. return deleted;
  65668. };
  65669. };
  65670. /**
  65671. * Get one of the submaterial by its index in the submaterials array
  65672. * @param index The index to look the sub material at
  65673. * @returns The Material if the index has been defined
  65674. */
  65675. MultiMaterial.prototype.getSubMaterial = function (index) {
  65676. if (index < 0 || index >= this.subMaterials.length) {
  65677. return this.getScene().defaultMaterial;
  65678. }
  65679. return this.subMaterials[index];
  65680. };
  65681. /**
  65682. * Get the list of active textures for the whole sub materials list.
  65683. * @returns All the textures that will be used during the rendering
  65684. */
  65685. MultiMaterial.prototype.getActiveTextures = function () {
  65686. var _a;
  65687. return (_a = _super.prototype.getActiveTextures.call(this)).concat.apply(_a, this.subMaterials.map(function (subMaterial) {
  65688. if (subMaterial) {
  65689. return subMaterial.getActiveTextures();
  65690. }
  65691. else {
  65692. return [];
  65693. }
  65694. }));
  65695. };
  65696. /**
  65697. * Gets the current class name of the material e.g. "MultiMaterial"
  65698. * Mainly use in serialization.
  65699. * @returns the class name
  65700. */
  65701. MultiMaterial.prototype.getClassName = function () {
  65702. return "MultiMaterial";
  65703. };
  65704. /**
  65705. * Checks if the material is ready to render the requested sub mesh
  65706. * @param mesh Define the mesh the submesh belongs to
  65707. * @param subMesh Define the sub mesh to look readyness for
  65708. * @param useInstances Define whether or not the material is used with instances
  65709. * @returns true if ready, otherwise false
  65710. */
  65711. MultiMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  65712. for (var index = 0; index < this.subMaterials.length; index++) {
  65713. var subMaterial = this.subMaterials[index];
  65714. if (subMaterial) {
  65715. if (subMaterial._storeEffectOnSubMeshes) {
  65716. if (!subMaterial.isReadyForSubMesh(mesh, subMesh, useInstances)) {
  65717. return false;
  65718. }
  65719. continue;
  65720. }
  65721. if (!subMaterial.isReady(mesh)) {
  65722. return false;
  65723. }
  65724. }
  65725. }
  65726. return true;
  65727. };
  65728. /**
  65729. * Clones the current material and its related sub materials
  65730. * @param name Define the name of the newly cloned material
  65731. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  65732. * @returns the cloned material
  65733. */
  65734. MultiMaterial.prototype.clone = function (name, cloneChildren) {
  65735. var newMultiMaterial = new MultiMaterial(name, this.getScene());
  65736. for (var index = 0; index < this.subMaterials.length; index++) {
  65737. var subMaterial = null;
  65738. var current = this.subMaterials[index];
  65739. if (cloneChildren && current) {
  65740. subMaterial = current.clone(name + "-" + current.name);
  65741. }
  65742. else {
  65743. subMaterial = this.subMaterials[index];
  65744. }
  65745. newMultiMaterial.subMaterials.push(subMaterial);
  65746. }
  65747. return newMultiMaterial;
  65748. };
  65749. /**
  65750. * Serializes the materials into a JSON representation.
  65751. * @returns the JSON representation
  65752. */
  65753. MultiMaterial.prototype.serialize = function () {
  65754. var serializationObject = {};
  65755. serializationObject.name = this.name;
  65756. serializationObject.id = this.id;
  65757. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"]) {
  65758. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].GetTags(this);
  65759. }
  65760. serializationObject.materials = [];
  65761. for (var matIndex = 0; matIndex < this.subMaterials.length; matIndex++) {
  65762. var subMat = this.subMaterials[matIndex];
  65763. if (subMat) {
  65764. serializationObject.materials.push(subMat.id);
  65765. }
  65766. else {
  65767. serializationObject.materials.push(null);
  65768. }
  65769. }
  65770. return serializationObject;
  65771. };
  65772. /**
  65773. * Dispose the material and release its associated resources
  65774. * @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)
  65775. * @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)
  65776. * @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)
  65777. */
  65778. MultiMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, forceDisposeChildren) {
  65779. var scene = this.getScene();
  65780. if (!scene) {
  65781. return;
  65782. }
  65783. if (forceDisposeChildren) {
  65784. for (var index = 0; index < this.subMaterials.length; index++) {
  65785. var subMaterial = this.subMaterials[index];
  65786. if (subMaterial) {
  65787. subMaterial.dispose(forceDisposeEffect, forceDisposeTextures);
  65788. }
  65789. }
  65790. }
  65791. var index = scene.multiMaterials.indexOf(this);
  65792. if (index >= 0) {
  65793. scene.multiMaterials.splice(index, 1);
  65794. }
  65795. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  65796. };
  65797. /**
  65798. * Creates a MultiMaterial from parsed MultiMaterial data.
  65799. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  65800. * @param scene defines the hosting scene
  65801. * @returns a new MultiMaterial
  65802. */
  65803. MultiMaterial.ParseMultiMaterial = function (parsedMultiMaterial, scene) {
  65804. var multiMaterial = new MultiMaterial(parsedMultiMaterial.name, scene);
  65805. multiMaterial.id = parsedMultiMaterial.id;
  65806. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"]) {
  65807. _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].AddTagsTo(multiMaterial, parsedMultiMaterial.tags);
  65808. }
  65809. for (var matIndex = 0; matIndex < parsedMultiMaterial.materials.length; matIndex++) {
  65810. var subMatId = parsedMultiMaterial.materials[matIndex];
  65811. if (subMatId) {
  65812. multiMaterial.subMaterials.push(scene.getMaterialByID(subMatId));
  65813. }
  65814. else {
  65815. multiMaterial.subMaterials.push(null);
  65816. }
  65817. }
  65818. return multiMaterial;
  65819. };
  65820. return MultiMaterial;
  65821. }(_Materials_material__WEBPACK_IMPORTED_MODULE_1__["Material"]));
  65822. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.MultiMaterial"] = MultiMaterial;
  65823. /***/ }),
  65824. /***/ "./Materials/pushMaterial.ts":
  65825. /*!***********************************!*\
  65826. !*** ./Materials/pushMaterial.ts ***!
  65827. \***********************************/
  65828. /*! exports provided: PushMaterial */
  65829. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  65830. "use strict";
  65831. __webpack_require__.r(__webpack_exports__);
  65832. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return PushMaterial; });
  65833. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  65834. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  65835. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  65836. /**
  65837. * Base class of materials working in push mode in babylon JS
  65838. * @hidden
  65839. */
  65840. var PushMaterial = /** @class */ (function (_super) {
  65841. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PushMaterial, _super);
  65842. function PushMaterial(name, scene) {
  65843. var _this = _super.call(this, name, scene) || this;
  65844. _this._normalMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  65845. /**
  65846. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  65847. * This means that the material can keep using a previous shader while a new one is being compiled.
  65848. * This is mostly used when shader parallel compilation is supported (true by default)
  65849. */
  65850. _this.allowShaderHotSwapping = true;
  65851. _this._storeEffectOnSubMeshes = true;
  65852. return _this;
  65853. }
  65854. PushMaterial.prototype.getEffect = function () {
  65855. return this._activeEffect;
  65856. };
  65857. PushMaterial.prototype.isReady = function (mesh, useInstances) {
  65858. if (!mesh) {
  65859. return false;
  65860. }
  65861. if (!mesh.subMeshes || mesh.subMeshes.length === 0) {
  65862. return true;
  65863. }
  65864. return this.isReadyForSubMesh(mesh, mesh.subMeshes[0], useInstances);
  65865. };
  65866. /**
  65867. * Binds the given world matrix to the active effect
  65868. *
  65869. * @param world the matrix to bind
  65870. */
  65871. PushMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  65872. this._activeEffect.setMatrix("world", world);
  65873. };
  65874. /**
  65875. * Binds the given normal matrix to the active effect
  65876. *
  65877. * @param normalMatrix the matrix to bind
  65878. */
  65879. PushMaterial.prototype.bindOnlyNormalMatrix = function (normalMatrix) {
  65880. this._activeEffect.setMatrix("normalMatrix", normalMatrix);
  65881. };
  65882. PushMaterial.prototype.bind = function (world, mesh) {
  65883. if (!mesh) {
  65884. return;
  65885. }
  65886. this.bindForSubMesh(world, mesh, mesh.subMeshes[0]);
  65887. };
  65888. PushMaterial.prototype._afterBind = function (mesh, effect) {
  65889. if (effect === void 0) { effect = null; }
  65890. _super.prototype._afterBind.call(this, mesh);
  65891. this.getScene()._cachedEffect = effect;
  65892. };
  65893. PushMaterial.prototype._mustRebind = function (scene, effect, visibility) {
  65894. if (visibility === void 0) { visibility = 1; }
  65895. return scene.isCachedMaterialInvalid(this, effect, visibility);
  65896. };
  65897. return PushMaterial;
  65898. }(_Materials_material__WEBPACK_IMPORTED_MODULE_2__["Material"]));
  65899. /***/ }),
  65900. /***/ "./Materials/shaderMaterial.ts":
  65901. /*!*************************************!*\
  65902. !*** ./Materials/shaderMaterial.ts ***!
  65903. \*************************************/
  65904. /*! exports provided: ShaderMaterial */
  65905. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  65906. "use strict";
  65907. __webpack_require__.r(__webpack_exports__);
  65908. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return ShaderMaterial; });
  65909. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  65910. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  65911. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  65912. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  65913. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  65914. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  65915. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  65916. /* harmony import */ var _material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./material */ "./Materials/material.ts");
  65917. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  65918. /**
  65919. * 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.
  65920. *
  65921. * This returned material effects how the mesh will look based on the code in the shaders.
  65922. *
  65923. * @see http://doc.babylonjs.com/how_to/shader_material
  65924. */
  65925. var ShaderMaterial = /** @class */ (function (_super) {
  65926. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShaderMaterial, _super);
  65927. /**
  65928. * Instantiate a new shader material.
  65929. * 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.
  65930. * This returned material effects how the mesh will look based on the code in the shaders.
  65931. * @see http://doc.babylonjs.com/how_to/shader_material
  65932. * @param name Define the name of the material in the scene
  65933. * @param scene Define the scene the material belongs to
  65934. * @param shaderPath Defines the route to the shader code in one of three ways:
  65935. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  65936. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  65937. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  65938. * @param options Define the options used to create the shader
  65939. */
  65940. function ShaderMaterial(name, scene, shaderPath, options) {
  65941. if (options === void 0) { options = {}; }
  65942. var _this = _super.call(this, name, scene) || this;
  65943. _this._textures = {};
  65944. _this._textureArrays = {};
  65945. _this._floats = {};
  65946. _this._ints = {};
  65947. _this._floatsArrays = {};
  65948. _this._colors3 = {};
  65949. _this._colors3Arrays = {};
  65950. _this._colors4 = {};
  65951. _this._vectors2 = {};
  65952. _this._vectors3 = {};
  65953. _this._vectors4 = {};
  65954. _this._matrices = {};
  65955. _this._matrices3x3 = {};
  65956. _this._matrices2x2 = {};
  65957. _this._vectors2Arrays = {};
  65958. _this._vectors3Arrays = {};
  65959. _this._cachedWorldViewMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  65960. _this._shaderPath = shaderPath;
  65961. _this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ needAlphaBlending: false, needAlphaTesting: false, attributes: ["position", "normal", "uv"], uniforms: ["worldViewProjection"], uniformBuffers: [], samplers: [], defines: [] }, options);
  65962. return _this;
  65963. }
  65964. /**
  65965. * Gets the current class name of the material e.g. "ShaderMaterial"
  65966. * Mainly use in serialization.
  65967. * @returns the class name
  65968. */
  65969. ShaderMaterial.prototype.getClassName = function () {
  65970. return "ShaderMaterial";
  65971. };
  65972. /**
  65973. * Specifies if the material will require alpha blending
  65974. * @returns a boolean specifying if alpha blending is needed
  65975. */
  65976. ShaderMaterial.prototype.needAlphaBlending = function () {
  65977. return (this.alpha < 1.0) || this._options.needAlphaBlending;
  65978. };
  65979. /**
  65980. * Specifies if this material should be rendered in alpha test mode
  65981. * @returns a boolean specifying if an alpha test is needed.
  65982. */
  65983. ShaderMaterial.prototype.needAlphaTesting = function () {
  65984. return this._options.needAlphaTesting;
  65985. };
  65986. ShaderMaterial.prototype._checkUniform = function (uniformName) {
  65987. if (this._options.uniforms.indexOf(uniformName) === -1) {
  65988. this._options.uniforms.push(uniformName);
  65989. }
  65990. };
  65991. /**
  65992. * Set a texture in the shader.
  65993. * @param name Define the name of the uniform samplers as defined in the shader
  65994. * @param texture Define the texture to bind to this sampler
  65995. * @return the material itself allowing "fluent" like uniform updates
  65996. */
  65997. ShaderMaterial.prototype.setTexture = function (name, texture) {
  65998. if (this._options.samplers.indexOf(name) === -1) {
  65999. this._options.samplers.push(name);
  66000. }
  66001. this._textures[name] = texture;
  66002. return this;
  66003. };
  66004. /**
  66005. * Set a texture array in the shader.
  66006. * @param name Define the name of the uniform sampler array as defined in the shader
  66007. * @param textures Define the list of textures to bind to this sampler
  66008. * @return the material itself allowing "fluent" like uniform updates
  66009. */
  66010. ShaderMaterial.prototype.setTextureArray = function (name, textures) {
  66011. if (this._options.samplers.indexOf(name) === -1) {
  66012. this._options.samplers.push(name);
  66013. }
  66014. this._checkUniform(name);
  66015. this._textureArrays[name] = textures;
  66016. return this;
  66017. };
  66018. /**
  66019. * Set a float in the shader.
  66020. * @param name Define the name of the uniform as defined in the shader
  66021. * @param value Define the value to give to the uniform
  66022. * @return the material itself allowing "fluent" like uniform updates
  66023. */
  66024. ShaderMaterial.prototype.setFloat = function (name, value) {
  66025. this._checkUniform(name);
  66026. this._floats[name] = value;
  66027. return this;
  66028. };
  66029. /**
  66030. * Set a int in the shader.
  66031. * @param name Define the name of the uniform as defined in the shader
  66032. * @param value Define the value to give to the uniform
  66033. * @return the material itself allowing "fluent" like uniform updates
  66034. */
  66035. ShaderMaterial.prototype.setInt = function (name, value) {
  66036. this._checkUniform(name);
  66037. this._ints[name] = value;
  66038. return this;
  66039. };
  66040. /**
  66041. * Set an array of floats in the shader.
  66042. * @param name Define the name of the uniform as defined in the shader
  66043. * @param value Define the value to give to the uniform
  66044. * @return the material itself allowing "fluent" like uniform updates
  66045. */
  66046. ShaderMaterial.prototype.setFloats = function (name, value) {
  66047. this._checkUniform(name);
  66048. this._floatsArrays[name] = value;
  66049. return this;
  66050. };
  66051. /**
  66052. * Set a vec3 in the shader from a Color3.
  66053. * @param name Define the name of the uniform as defined in the shader
  66054. * @param value Define the value to give to the uniform
  66055. * @return the material itself allowing "fluent" like uniform updates
  66056. */
  66057. ShaderMaterial.prototype.setColor3 = function (name, value) {
  66058. this._checkUniform(name);
  66059. this._colors3[name] = value;
  66060. return this;
  66061. };
  66062. /**
  66063. * Set a vec3 array in the shader from a Color3 array.
  66064. * @param name Define the name of the uniform as defined in the shader
  66065. * @param value Define the value to give to the uniform
  66066. * @return the material itself allowing "fluent" like uniform updates
  66067. */
  66068. ShaderMaterial.prototype.setColor3Array = function (name, value) {
  66069. this._checkUniform(name);
  66070. this._colors3Arrays[name] = value.reduce(function (arr, color) {
  66071. color.toArray(arr, arr.length);
  66072. return arr;
  66073. }, []);
  66074. return this;
  66075. };
  66076. /**
  66077. * Set a vec4 in the shader from a Color4.
  66078. * @param name Define the name of the uniform as defined in the shader
  66079. * @param value Define the value to give to the uniform
  66080. * @return the material itself allowing "fluent" like uniform updates
  66081. */
  66082. ShaderMaterial.prototype.setColor4 = function (name, value) {
  66083. this._checkUniform(name);
  66084. this._colors4[name] = value;
  66085. return this;
  66086. };
  66087. /**
  66088. * Set a vec2 in the shader from a Vector2.
  66089. * @param name Define the name of the uniform as defined in the shader
  66090. * @param value Define the value to give to the uniform
  66091. * @return the material itself allowing "fluent" like uniform updates
  66092. */
  66093. ShaderMaterial.prototype.setVector2 = function (name, value) {
  66094. this._checkUniform(name);
  66095. this._vectors2[name] = value;
  66096. return this;
  66097. };
  66098. /**
  66099. * Set a vec3 in the shader from a Vector3.
  66100. * @param name Define the name of the uniform as defined in the shader
  66101. * @param value Define the value to give to the uniform
  66102. * @return the material itself allowing "fluent" like uniform updates
  66103. */
  66104. ShaderMaterial.prototype.setVector3 = function (name, value) {
  66105. this._checkUniform(name);
  66106. this._vectors3[name] = value;
  66107. return this;
  66108. };
  66109. /**
  66110. * Set a vec4 in the shader from a Vector4.
  66111. * @param name Define the name of the uniform as defined in the shader
  66112. * @param value Define the value to give to the uniform
  66113. * @return the material itself allowing "fluent" like uniform updates
  66114. */
  66115. ShaderMaterial.prototype.setVector4 = function (name, value) {
  66116. this._checkUniform(name);
  66117. this._vectors4[name] = value;
  66118. return this;
  66119. };
  66120. /**
  66121. * Set a mat4 in the shader from a Matrix.
  66122. * @param name Define the name of the uniform as defined in the shader
  66123. * @param value Define the value to give to the uniform
  66124. * @return the material itself allowing "fluent" like uniform updates
  66125. */
  66126. ShaderMaterial.prototype.setMatrix = function (name, value) {
  66127. this._checkUniform(name);
  66128. this._matrices[name] = value;
  66129. return this;
  66130. };
  66131. /**
  66132. * Set a mat3 in the shader from a Float32Array.
  66133. * @param name Define the name of the uniform as defined in the shader
  66134. * @param value Define the value to give to the uniform
  66135. * @return the material itself allowing "fluent" like uniform updates
  66136. */
  66137. ShaderMaterial.prototype.setMatrix3x3 = function (name, value) {
  66138. this._checkUniform(name);
  66139. this._matrices3x3[name] = value;
  66140. return this;
  66141. };
  66142. /**
  66143. * Set a mat2 in the shader from a Float32Array.
  66144. * @param name Define the name of the uniform as defined in the shader
  66145. * @param value Define the value to give to the uniform
  66146. * @return the material itself allowing "fluent" like uniform updates
  66147. */
  66148. ShaderMaterial.prototype.setMatrix2x2 = function (name, value) {
  66149. this._checkUniform(name);
  66150. this._matrices2x2[name] = value;
  66151. return this;
  66152. };
  66153. /**
  66154. * Set a vec2 array in the shader from a number array.
  66155. * @param name Define the name of the uniform as defined in the shader
  66156. * @param value Define the value to give to the uniform
  66157. * @return the material itself allowing "fluent" like uniform updates
  66158. */
  66159. ShaderMaterial.prototype.setArray2 = function (name, value) {
  66160. this._checkUniform(name);
  66161. this._vectors2Arrays[name] = value;
  66162. return this;
  66163. };
  66164. /**
  66165. * Set a vec3 array in the shader from a number array.
  66166. * @param name Define the name of the uniform as defined in the shader
  66167. * @param value Define the value to give to the uniform
  66168. * @return the material itself allowing "fluent" like uniform updates
  66169. */
  66170. ShaderMaterial.prototype.setArray3 = function (name, value) {
  66171. this._checkUniform(name);
  66172. this._vectors3Arrays[name] = value;
  66173. return this;
  66174. };
  66175. ShaderMaterial.prototype._checkCache = function (mesh, useInstances) {
  66176. if (!mesh) {
  66177. return true;
  66178. }
  66179. if (this._effect && (this._effect.defines.indexOf("#define INSTANCES") !== -1) !== useInstances) {
  66180. return false;
  66181. }
  66182. return false;
  66183. };
  66184. /**
  66185. * Checks if the material is ready to render the requested mesh
  66186. * @param mesh Define the mesh to render
  66187. * @param useInstances Define whether or not the material is used with instances
  66188. * @returns true if ready, otherwise false
  66189. */
  66190. ShaderMaterial.prototype.isReady = function (mesh, useInstances) {
  66191. var scene = this.getScene();
  66192. var engine = scene.getEngine();
  66193. if (!this.checkReadyOnEveryCall) {
  66194. if (this._renderId === scene.getRenderId()) {
  66195. if (this._checkCache(mesh, useInstances)) {
  66196. return true;
  66197. }
  66198. }
  66199. }
  66200. // Instances
  66201. var defines = [];
  66202. var attribs = [];
  66203. var fallbacks = new _effect__WEBPACK_IMPORTED_MODULE_6__["EffectFallbacks"]();
  66204. for (var index = 0; index < this._options.defines.length; index++) {
  66205. defines.push(this._options.defines[index]);
  66206. }
  66207. for (var index = 0; index < this._options.attributes.length; index++) {
  66208. attribs.push(this._options.attributes[index]);
  66209. }
  66210. if (mesh && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind)) {
  66211. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind);
  66212. defines.push("#define VERTEXCOLOR");
  66213. }
  66214. if (useInstances) {
  66215. defines.push("#define INSTANCES");
  66216. _materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  66217. }
  66218. // Bones
  66219. if (mesh && mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  66220. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind);
  66221. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsKind);
  66222. if (mesh.numBoneInfluencers > 4) {
  66223. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesExtraKind);
  66224. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsExtraKind);
  66225. }
  66226. var skeleton = mesh.skeleton;
  66227. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  66228. fallbacks.addCPUSkinningFallback(0, mesh);
  66229. if (skeleton.isUsingTextureForMatrices) {
  66230. defines.push("#define BONETEXTURE");
  66231. if (this._options.uniforms.indexOf("boneTextureWidth") === -1) {
  66232. this._options.uniforms.push("boneTextureWidth");
  66233. }
  66234. if (this._options.samplers.indexOf("boneSampler") === -1) {
  66235. this._options.samplers.push("boneSampler");
  66236. }
  66237. }
  66238. else {
  66239. defines.push("#define BonesPerMesh " + (skeleton.bones.length + 1));
  66240. if (this._options.uniforms.indexOf("mBones") === -1) {
  66241. this._options.uniforms.push("mBones");
  66242. }
  66243. }
  66244. }
  66245. else {
  66246. defines.push("#define NUM_BONE_INFLUENCERS 0");
  66247. }
  66248. // Textures
  66249. for (var name in this._textures) {
  66250. if (!this._textures[name].isReady()) {
  66251. return false;
  66252. }
  66253. }
  66254. // Alpha test
  66255. if (mesh && this._shouldTurnAlphaTestOn(mesh)) {
  66256. defines.push("#define ALPHATEST");
  66257. }
  66258. var previousEffect = this._effect;
  66259. var join = defines.join("\n");
  66260. this._effect = engine.createEffect(this._shaderPath, {
  66261. attributes: attribs,
  66262. uniformsNames: this._options.uniforms,
  66263. uniformBuffersNames: this._options.uniformBuffers,
  66264. samplers: this._options.samplers,
  66265. defines: join,
  66266. fallbacks: fallbacks,
  66267. onCompiled: this.onCompiled,
  66268. onError: this.onError
  66269. }, engine);
  66270. if (!this._effect.isReady()) {
  66271. return false;
  66272. }
  66273. if (previousEffect !== this._effect) {
  66274. scene.resetCachedMaterial();
  66275. }
  66276. this._renderId = scene.getRenderId();
  66277. return true;
  66278. };
  66279. /**
  66280. * Binds the world matrix to the material
  66281. * @param world defines the world transformation matrix
  66282. */
  66283. ShaderMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  66284. var scene = this.getScene();
  66285. if (!this._effect) {
  66286. return;
  66287. }
  66288. if (this._options.uniforms.indexOf("world") !== -1) {
  66289. this._effect.setMatrix("world", world);
  66290. }
  66291. if (this._options.uniforms.indexOf("worldView") !== -1) {
  66292. world.multiplyToRef(scene.getViewMatrix(), this._cachedWorldViewMatrix);
  66293. this._effect.setMatrix("worldView", this._cachedWorldViewMatrix);
  66294. }
  66295. if (this._options.uniforms.indexOf("worldViewProjection") !== -1) {
  66296. this._effect.setMatrix("worldViewProjection", world.multiply(scene.getTransformMatrix()));
  66297. }
  66298. };
  66299. /**
  66300. * Binds the material to the mesh
  66301. * @param world defines the world transformation matrix
  66302. * @param mesh defines the mesh to bind the material to
  66303. */
  66304. ShaderMaterial.prototype.bind = function (world, mesh) {
  66305. // Std values
  66306. this.bindOnlyWorldMatrix(world);
  66307. if (this._effect && this.getScene().getCachedMaterial() !== this) {
  66308. if (this._options.uniforms.indexOf("view") !== -1) {
  66309. this._effect.setMatrix("view", this.getScene().getViewMatrix());
  66310. }
  66311. if (this._options.uniforms.indexOf("projection") !== -1) {
  66312. this._effect.setMatrix("projection", this.getScene().getProjectionMatrix());
  66313. }
  66314. if (this._options.uniforms.indexOf("viewProjection") !== -1) {
  66315. this._effect.setMatrix("viewProjection", this.getScene().getTransformMatrix());
  66316. }
  66317. // Bones
  66318. _materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindBonesParameters(mesh, this._effect);
  66319. var name;
  66320. // Texture
  66321. for (name in this._textures) {
  66322. this._effect.setTexture(name, this._textures[name]);
  66323. }
  66324. // Texture arrays
  66325. for (name in this._textureArrays) {
  66326. this._effect.setTextureArray(name, this._textureArrays[name]);
  66327. }
  66328. // Int
  66329. for (name in this._ints) {
  66330. this._effect.setInt(name, this._ints[name]);
  66331. }
  66332. // Float
  66333. for (name in this._floats) {
  66334. this._effect.setFloat(name, this._floats[name]);
  66335. }
  66336. // Floats
  66337. for (name in this._floatsArrays) {
  66338. this._effect.setArray(name, this._floatsArrays[name]);
  66339. }
  66340. // Color3
  66341. for (name in this._colors3) {
  66342. this._effect.setColor3(name, this._colors3[name]);
  66343. }
  66344. for (name in this._colors3Arrays) {
  66345. this._effect.setArray3(name, this._colors3Arrays[name]);
  66346. }
  66347. // Color4
  66348. for (name in this._colors4) {
  66349. var color = this._colors4[name];
  66350. this._effect.setFloat4(name, color.r, color.g, color.b, color.a);
  66351. }
  66352. // Vector2
  66353. for (name in this._vectors2) {
  66354. this._effect.setVector2(name, this._vectors2[name]);
  66355. }
  66356. // Vector3
  66357. for (name in this._vectors3) {
  66358. this._effect.setVector3(name, this._vectors3[name]);
  66359. }
  66360. // Vector4
  66361. for (name in this._vectors4) {
  66362. this._effect.setVector4(name, this._vectors4[name]);
  66363. }
  66364. // Matrix
  66365. for (name in this._matrices) {
  66366. this._effect.setMatrix(name, this._matrices[name]);
  66367. }
  66368. // Matrix 3x3
  66369. for (name in this._matrices3x3) {
  66370. this._effect.setMatrix3x3(name, this._matrices3x3[name]);
  66371. }
  66372. // Matrix 2x2
  66373. for (name in this._matrices2x2) {
  66374. this._effect.setMatrix2x2(name, this._matrices2x2[name]);
  66375. }
  66376. // Vector2Array
  66377. for (name in this._vectors2Arrays) {
  66378. this._effect.setArray2(name, this._vectors2Arrays[name]);
  66379. }
  66380. // Vector3Array
  66381. for (name in this._vectors3Arrays) {
  66382. this._effect.setArray3(name, this._vectors3Arrays[name]);
  66383. }
  66384. }
  66385. this._afterBind(mesh);
  66386. };
  66387. /**
  66388. * Gets the active textures from the material
  66389. * @returns an array of textures
  66390. */
  66391. ShaderMaterial.prototype.getActiveTextures = function () {
  66392. var activeTextures = _super.prototype.getActiveTextures.call(this);
  66393. for (var name in this._textures) {
  66394. activeTextures.push(this._textures[name]);
  66395. }
  66396. for (var name in this._textureArrays) {
  66397. var array = this._textureArrays[name];
  66398. for (var index = 0; index < array.length; index++) {
  66399. activeTextures.push(array[index]);
  66400. }
  66401. }
  66402. return activeTextures;
  66403. };
  66404. /**
  66405. * Specifies if the material uses a texture
  66406. * @param texture defines the texture to check against the material
  66407. * @returns a boolean specifying if the material uses the texture
  66408. */
  66409. ShaderMaterial.prototype.hasTexture = function (texture) {
  66410. if (_super.prototype.hasTexture.call(this, texture)) {
  66411. return true;
  66412. }
  66413. for (var name in this._textures) {
  66414. if (this._textures[name] === texture) {
  66415. return true;
  66416. }
  66417. }
  66418. for (var name in this._textureArrays) {
  66419. var array = this._textureArrays[name];
  66420. for (var index = 0; index < array.length; index++) {
  66421. if (array[index] === texture) {
  66422. return true;
  66423. }
  66424. }
  66425. }
  66426. return false;
  66427. };
  66428. /**
  66429. * Makes a duplicate of the material, and gives it a new name
  66430. * @param name defines the new name for the duplicated material
  66431. * @returns the cloned material
  66432. */
  66433. ShaderMaterial.prototype.clone = function (name) {
  66434. var newShaderMaterial = new ShaderMaterial(name, this.getScene(), this._shaderPath, this._options);
  66435. return newShaderMaterial;
  66436. };
  66437. /**
  66438. * Disposes the material
  66439. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  66440. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  66441. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  66442. */
  66443. ShaderMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, notBoundToMesh) {
  66444. if (forceDisposeTextures) {
  66445. var name;
  66446. for (name in this._textures) {
  66447. this._textures[name].dispose();
  66448. }
  66449. for (name in this._textureArrays) {
  66450. var array = this._textureArrays[name];
  66451. for (var index = 0; index < array.length; index++) {
  66452. array[index].dispose();
  66453. }
  66454. }
  66455. }
  66456. this._textures = {};
  66457. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures, notBoundToMesh);
  66458. };
  66459. /**
  66460. * Serializes this material in a JSON representation
  66461. * @returns the serialized material object
  66462. */
  66463. ShaderMaterial.prototype.serialize = function () {
  66464. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  66465. serializationObject.customType = "ShaderMaterial";
  66466. serializationObject.options = this._options;
  66467. serializationObject.shaderPath = this._shaderPath;
  66468. var name;
  66469. // Texture
  66470. serializationObject.textures = {};
  66471. for (name in this._textures) {
  66472. serializationObject.textures[name] = this._textures[name].serialize();
  66473. }
  66474. // Texture arrays
  66475. serializationObject.textureArrays = {};
  66476. for (name in this._textureArrays) {
  66477. serializationObject.textureArrays[name] = [];
  66478. var array = this._textureArrays[name];
  66479. for (var index = 0; index < array.length; index++) {
  66480. serializationObject.textureArrays[name].push(array[index].serialize());
  66481. }
  66482. }
  66483. // Float
  66484. serializationObject.floats = {};
  66485. for (name in this._floats) {
  66486. serializationObject.floats[name] = this._floats[name];
  66487. }
  66488. // Float s
  66489. serializationObject.FloatArrays = {};
  66490. for (name in this._floatsArrays) {
  66491. serializationObject.FloatArrays[name] = this._floatsArrays[name];
  66492. }
  66493. // Color3
  66494. serializationObject.colors3 = {};
  66495. for (name in this._colors3) {
  66496. serializationObject.colors3[name] = this._colors3[name].asArray();
  66497. }
  66498. // Color3 array
  66499. serializationObject.colors3Arrays = {};
  66500. for (name in this._colors3Arrays) {
  66501. serializationObject.colors3Arrays[name] = this._colors3Arrays[name];
  66502. }
  66503. // Color4
  66504. serializationObject.colors4 = {};
  66505. for (name in this._colors4) {
  66506. serializationObject.colors4[name] = this._colors4[name].asArray();
  66507. }
  66508. // Vector2
  66509. serializationObject.vectors2 = {};
  66510. for (name in this._vectors2) {
  66511. serializationObject.vectors2[name] = this._vectors2[name].asArray();
  66512. }
  66513. // Vector3
  66514. serializationObject.vectors3 = {};
  66515. for (name in this._vectors3) {
  66516. serializationObject.vectors3[name] = this._vectors3[name].asArray();
  66517. }
  66518. // Vector4
  66519. serializationObject.vectors4 = {};
  66520. for (name in this._vectors4) {
  66521. serializationObject.vectors4[name] = this._vectors4[name].asArray();
  66522. }
  66523. // Matrix
  66524. serializationObject.matrices = {};
  66525. for (name in this._matrices) {
  66526. serializationObject.matrices[name] = this._matrices[name].asArray();
  66527. }
  66528. // Matrix 3x3
  66529. serializationObject.matrices3x3 = {};
  66530. for (name in this._matrices3x3) {
  66531. serializationObject.matrices3x3[name] = this._matrices3x3[name];
  66532. }
  66533. // Matrix 2x2
  66534. serializationObject.matrices2x2 = {};
  66535. for (name in this._matrices2x2) {
  66536. serializationObject.matrices2x2[name] = this._matrices2x2[name];
  66537. }
  66538. // Vector2Array
  66539. serializationObject.vectors2Arrays = {};
  66540. for (name in this._vectors2Arrays) {
  66541. serializationObject.vectors2Arrays[name] = this._vectors2Arrays[name];
  66542. }
  66543. // Vector3Array
  66544. serializationObject.vectors3Arrays = {};
  66545. for (name in this._vectors3Arrays) {
  66546. serializationObject.vectors3Arrays[name] = this._vectors3Arrays[name];
  66547. }
  66548. return serializationObject;
  66549. };
  66550. /**
  66551. * Creates a shader material from parsed shader material data
  66552. * @param source defines the JSON represnetation of the material
  66553. * @param scene defines the hosting scene
  66554. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66555. * @returns a new material
  66556. */
  66557. ShaderMaterial.Parse = function (source, scene, rootUrl) {
  66558. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ShaderMaterial(source.name, scene, source.shaderPath, source.options); }, source, scene, rootUrl);
  66559. var name;
  66560. // Texture
  66561. for (name in source.textures) {
  66562. material.setTexture(name, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].Parse(source.textures[name], scene, rootUrl));
  66563. }
  66564. // Texture arrays
  66565. for (name in source.textureArrays) {
  66566. var array = source.textureArrays[name];
  66567. var textureArray = new Array();
  66568. for (var index = 0; index < array.length; index++) {
  66569. textureArray.push(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].Parse(array[index], scene, rootUrl));
  66570. }
  66571. material.setTextureArray(name, textureArray);
  66572. }
  66573. // Float
  66574. for (name in source.floats) {
  66575. material.setFloat(name, source.floats[name]);
  66576. }
  66577. // Float s
  66578. for (name in source.floatsArrays) {
  66579. material.setFloats(name, source.floatsArrays[name]);
  66580. }
  66581. // Color3
  66582. for (name in source.colors3) {
  66583. material.setColor3(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(source.colors3[name]));
  66584. }
  66585. // Color3 arrays
  66586. for (name in source.colors3Arrays) {
  66587. var colors = source.colors3Arrays[name].reduce(function (arr, num, i) {
  66588. if (i % 3 === 0) {
  66589. arr.push([num]);
  66590. }
  66591. else {
  66592. arr[arr.length - 1].push(num);
  66593. }
  66594. return arr;
  66595. }, []).map(function (color) { return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(color); });
  66596. material.setColor3Array(name, colors);
  66597. }
  66598. // Color4
  66599. for (name in source.colors4) {
  66600. material.setColor4(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"].FromArray(source.colors4[name]));
  66601. }
  66602. // Vector2
  66603. for (name in source.vectors2) {
  66604. material.setVector2(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"].FromArray(source.vectors2[name]));
  66605. }
  66606. // Vector3
  66607. for (name in source.vectors3) {
  66608. material.setVector3(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(source.vectors3[name]));
  66609. }
  66610. // Vector4
  66611. for (name in source.vectors4) {
  66612. material.setVector4(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector4"].FromArray(source.vectors4[name]));
  66613. }
  66614. // Matrix
  66615. for (name in source.matrices) {
  66616. material.setMatrix(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(source.matrices[name]));
  66617. }
  66618. // Matrix 3x3
  66619. for (name in source.matrices3x3) {
  66620. material.setMatrix3x3(name, source.matrices3x3[name]);
  66621. }
  66622. // Matrix 2x2
  66623. for (name in source.matrices2x2) {
  66624. material.setMatrix2x2(name, source.matrices2x2[name]);
  66625. }
  66626. // Vector2Array
  66627. for (name in source.vectors2Arrays) {
  66628. material.setArray2(name, source.vectors2Arrays[name]);
  66629. }
  66630. // Vector3Array
  66631. for (name in source.vectors3Arrays) {
  66632. material.setArray3(name, source.vectors3Arrays[name]);
  66633. }
  66634. return material;
  66635. };
  66636. return ShaderMaterial;
  66637. }(_material__WEBPACK_IMPORTED_MODULE_7__["Material"]));
  66638. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].RegisteredTypes["BABYLON.ShaderMaterial"] = ShaderMaterial;
  66639. /***/ }),
  66640. /***/ "./Materials/standardMaterial.ts":
  66641. /*!***************************************!*\
  66642. !*** ./Materials/standardMaterial.ts ***!
  66643. \***************************************/
  66644. /*! exports provided: StandardMaterialDefines, StandardMaterial */
  66645. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  66646. "use strict";
  66647. __webpack_require__.r(__webpack_exports__);
  66648. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return StandardMaterialDefines; });
  66649. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return StandardMaterial; });
  66650. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  66651. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  66652. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  66653. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  66654. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  66655. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  66656. /* harmony import */ var _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  66657. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  66658. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/materialDefines */ "./Materials/materialDefines.ts");
  66659. /* harmony import */ var _pushMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./pushMaterial */ "./Materials/pushMaterial.ts");
  66660. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  66661. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  66662. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  66663. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./materialFlags */ "./Materials/materialFlags.ts");
  66664. /* harmony import */ var _Shaders_default_fragment__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/default.fragment */ "./Shaders/default.fragment.ts");
  66665. /* harmony import */ var _Shaders_default_vertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Shaders/default.vertex */ "./Shaders/default.vertex.ts");
  66666. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  66667. /** @hidden */
  66668. var StandardMaterialDefines = /** @class */ (function (_super) {
  66669. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardMaterialDefines, _super);
  66670. function StandardMaterialDefines() {
  66671. var _this = _super.call(this) || this;
  66672. _this.MAINUV1 = false;
  66673. _this.MAINUV2 = false;
  66674. _this.DIFFUSE = false;
  66675. _this.DIFFUSEDIRECTUV = 0;
  66676. _this.AMBIENT = false;
  66677. _this.AMBIENTDIRECTUV = 0;
  66678. _this.OPACITY = false;
  66679. _this.OPACITYDIRECTUV = 0;
  66680. _this.OPACITYRGB = false;
  66681. _this.REFLECTION = false;
  66682. _this.EMISSIVE = false;
  66683. _this.EMISSIVEDIRECTUV = 0;
  66684. _this.SPECULAR = false;
  66685. _this.SPECULARDIRECTUV = 0;
  66686. _this.BUMP = false;
  66687. _this.BUMPDIRECTUV = 0;
  66688. _this.PARALLAX = false;
  66689. _this.PARALLAXOCCLUSION = false;
  66690. _this.SPECULAROVERALPHA = false;
  66691. _this.CLIPPLANE = false;
  66692. _this.CLIPPLANE2 = false;
  66693. _this.CLIPPLANE3 = false;
  66694. _this.CLIPPLANE4 = false;
  66695. _this.ALPHATEST = false;
  66696. _this.DEPTHPREPASS = false;
  66697. _this.ALPHAFROMDIFFUSE = false;
  66698. _this.POINTSIZE = false;
  66699. _this.FOG = false;
  66700. _this.SPECULARTERM = false;
  66701. _this.DIFFUSEFRESNEL = false;
  66702. _this.OPACITYFRESNEL = false;
  66703. _this.REFLECTIONFRESNEL = false;
  66704. _this.REFRACTIONFRESNEL = false;
  66705. _this.EMISSIVEFRESNEL = false;
  66706. _this.FRESNEL = false;
  66707. _this.NORMAL = false;
  66708. _this.UV1 = false;
  66709. _this.UV2 = false;
  66710. _this.VERTEXCOLOR = false;
  66711. _this.VERTEXALPHA = false;
  66712. _this.NUM_BONE_INFLUENCERS = 0;
  66713. _this.BonesPerMesh = 0;
  66714. _this.BONETEXTURE = false;
  66715. _this.INSTANCES = false;
  66716. _this.GLOSSINESS = false;
  66717. _this.ROUGHNESS = false;
  66718. _this.EMISSIVEASILLUMINATION = false;
  66719. _this.LINKEMISSIVEWITHDIFFUSE = false;
  66720. _this.REFLECTIONFRESNELFROMSPECULAR = false;
  66721. _this.LIGHTMAP = false;
  66722. _this.LIGHTMAPDIRECTUV = 0;
  66723. _this.OBJECTSPACE_NORMALMAP = false;
  66724. _this.USELIGHTMAPASSHADOWMAP = false;
  66725. _this.REFLECTIONMAP_3D = false;
  66726. _this.REFLECTIONMAP_SPHERICAL = false;
  66727. _this.REFLECTIONMAP_PLANAR = false;
  66728. _this.REFLECTIONMAP_CUBIC = false;
  66729. _this.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  66730. _this.REFLECTIONMAP_PROJECTION = false;
  66731. _this.REFLECTIONMAP_SKYBOX = false;
  66732. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  66733. _this.REFLECTIONMAP_EXPLICIT = false;
  66734. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  66735. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  66736. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  66737. _this.INVERTCUBICMAP = false;
  66738. _this.LOGARITHMICDEPTH = false;
  66739. _this.REFRACTION = false;
  66740. _this.REFRACTIONMAP_3D = false;
  66741. _this.REFLECTIONOVERALPHA = false;
  66742. _this.TWOSIDEDLIGHTING = false;
  66743. _this.SHADOWFLOAT = false;
  66744. _this.MORPHTARGETS = false;
  66745. _this.MORPHTARGETS_NORMAL = false;
  66746. _this.MORPHTARGETS_TANGENT = false;
  66747. _this.NUM_MORPH_INFLUENCERS = 0;
  66748. _this.NONUNIFORMSCALING = false; // https://playground.babylonjs.com#V6DWIH
  66749. _this.PREMULTIPLYALPHA = false; // https://playground.babylonjs.com#LNVJJ7
  66750. _this.IMAGEPROCESSING = false;
  66751. _this.VIGNETTE = false;
  66752. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  66753. _this.VIGNETTEBLENDMODEOPAQUE = false;
  66754. _this.TONEMAPPING = false;
  66755. _this.TONEMAPPING_ACES = false;
  66756. _this.CONTRAST = false;
  66757. _this.COLORCURVES = false;
  66758. _this.COLORGRADING = false;
  66759. _this.COLORGRADING3D = false;
  66760. _this.SAMPLER3DGREENDEPTH = false;
  66761. _this.SAMPLER3DBGRMAP = false;
  66762. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  66763. /**
  66764. * If the reflection texture on this material is in linear color space
  66765. * @hidden
  66766. */
  66767. _this.IS_REFLECTION_LINEAR = false;
  66768. /**
  66769. * If the refraction texture on this material is in linear color space
  66770. * @hidden
  66771. */
  66772. _this.IS_REFRACTION_LINEAR = false;
  66773. _this.EXPOSURE = false;
  66774. _this.rebuild();
  66775. return _this;
  66776. }
  66777. StandardMaterialDefines.prototype.setReflectionMode = function (modeToEnable) {
  66778. var modes = [
  66779. "REFLECTIONMAP_CUBIC", "REFLECTIONMAP_EXPLICIT", "REFLECTIONMAP_PLANAR",
  66780. "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_SKYBOX",
  66781. "REFLECTIONMAP_SPHERICAL", "REFLECTIONMAP_EQUIRECTANGULAR", "REFLECTIONMAP_EQUIRECTANGULAR_FIXED",
  66782. "REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"
  66783. ];
  66784. for (var _i = 0, modes_1 = modes; _i < modes_1.length; _i++) {
  66785. var mode = modes_1[_i];
  66786. this[mode] = (mode === modeToEnable);
  66787. }
  66788. };
  66789. return StandardMaterialDefines;
  66790. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__["MaterialDefines"]));
  66791. /**
  66792. * This is the default material used in Babylon. It is the best trade off between quality
  66793. * and performances.
  66794. * @see http://doc.babylonjs.com/babylon101/materials
  66795. */
  66796. var StandardMaterial = /** @class */ (function (_super) {
  66797. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardMaterial, _super);
  66798. /**
  66799. * Instantiates a new standard material.
  66800. * This is the default material used in Babylon. It is the best trade off between quality
  66801. * and performances.
  66802. * @see http://doc.babylonjs.com/babylon101/materials
  66803. * @param name Define the name of the material in the scene
  66804. * @param scene Define the scene the material belong to
  66805. */
  66806. function StandardMaterial(name, scene) {
  66807. var _this = _super.call(this, name, scene) || this;
  66808. /**
  66809. * The color of the material lit by the environmental background lighting.
  66810. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  66811. */
  66812. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  66813. /**
  66814. * The basic color of the material as viewed under a light.
  66815. */
  66816. _this.diffuseColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  66817. /**
  66818. * Define how the color and intensity of the highlight given by the light in the material.
  66819. */
  66820. _this.specularColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  66821. /**
  66822. * Define the color of the material as if self lit.
  66823. * This will be mixed in the final result even in the absence of light.
  66824. */
  66825. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  66826. /**
  66827. * Defines how sharp are the highlights in the material.
  66828. * The bigger the value the sharper giving a more glossy feeling to the result.
  66829. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  66830. */
  66831. _this.specularPower = 64;
  66832. _this._useAlphaFromDiffuseTexture = false;
  66833. _this._useEmissiveAsIllumination = false;
  66834. _this._linkEmissiveWithDiffuse = false;
  66835. _this._useSpecularOverAlpha = false;
  66836. _this._useReflectionOverAlpha = false;
  66837. _this._disableLighting = false;
  66838. _this._useObjectSpaceNormalMap = false;
  66839. _this._useParallax = false;
  66840. _this._useParallaxOcclusion = false;
  66841. /**
  66842. * 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.
  66843. */
  66844. _this.parallaxScaleBias = 0.05;
  66845. _this._roughness = 0;
  66846. /**
  66847. * In case of refraction, define the value of the indice of refraction.
  66848. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  66849. */
  66850. _this.indexOfRefraction = 0.98;
  66851. /**
  66852. * Invert the refraction texture alongside the y axis.
  66853. * It can be useful with procedural textures or probe for instance.
  66854. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  66855. */
  66856. _this.invertRefractionY = true;
  66857. /**
  66858. * Defines the alpha limits in alpha test mode.
  66859. */
  66860. _this.alphaCutOff = 0.4;
  66861. _this._useLightmapAsShadowmap = false;
  66862. _this._useReflectionFresnelFromSpecular = false;
  66863. _this._useGlossinessFromSpecularMapAlpha = false;
  66864. _this._maxSimultaneousLights = 4;
  66865. _this._invertNormalMapX = false;
  66866. _this._invertNormalMapY = false;
  66867. _this._twoSidedLighting = false;
  66868. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](16);
  66869. _this._worldViewProjectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  66870. _this._globalAmbientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  66871. // Setup the default processing configuration to the scene.
  66872. _this._attachImageProcessingConfiguration(null);
  66873. _this.getRenderTargetTextures = function () {
  66874. _this._renderTargets.reset();
  66875. if (StandardMaterial.ReflectionTextureEnabled && _this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  66876. _this._renderTargets.push(_this._reflectionTexture);
  66877. }
  66878. if (StandardMaterial.RefractionTextureEnabled && _this._refractionTexture && _this._refractionTexture.isRenderTarget) {
  66879. _this._renderTargets.push(_this._refractionTexture);
  66880. }
  66881. return _this._renderTargets;
  66882. };
  66883. return _this;
  66884. }
  66885. Object.defineProperty(StandardMaterial.prototype, "imageProcessingConfiguration", {
  66886. /**
  66887. * Gets the image processing configuration used either in this material.
  66888. */
  66889. get: function () {
  66890. return this._imageProcessingConfiguration;
  66891. },
  66892. /**
  66893. * Sets the Default image processing configuration used either in the this material.
  66894. *
  66895. * If sets to null, the scene one is in use.
  66896. */
  66897. set: function (value) {
  66898. this._attachImageProcessingConfiguration(value);
  66899. // Ensure the effect will be rebuilt.
  66900. this._markAllSubMeshesAsTexturesDirty();
  66901. },
  66902. enumerable: true,
  66903. configurable: true
  66904. });
  66905. /**
  66906. * Attaches a new image processing configuration to the Standard Material.
  66907. * @param configuration
  66908. */
  66909. StandardMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  66910. var _this = this;
  66911. if (configuration === this._imageProcessingConfiguration) {
  66912. return;
  66913. }
  66914. // Detaches observer.
  66915. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  66916. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  66917. }
  66918. // Pick the scene configuration if needed.
  66919. if (!configuration) {
  66920. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  66921. }
  66922. else {
  66923. this._imageProcessingConfiguration = configuration;
  66924. }
  66925. // Attaches observer.
  66926. if (this._imageProcessingConfiguration) {
  66927. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  66928. _this._markAllSubMeshesAsImageProcessingDirty();
  66929. });
  66930. }
  66931. };
  66932. Object.defineProperty(StandardMaterial.prototype, "cameraColorCurvesEnabled", {
  66933. /**
  66934. * Gets wether the color curves effect is enabled.
  66935. */
  66936. get: function () {
  66937. return this.imageProcessingConfiguration.colorCurvesEnabled;
  66938. },
  66939. /**
  66940. * Sets wether the color curves effect is enabled.
  66941. */
  66942. set: function (value) {
  66943. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  66944. },
  66945. enumerable: true,
  66946. configurable: true
  66947. });
  66948. Object.defineProperty(StandardMaterial.prototype, "cameraColorGradingEnabled", {
  66949. /**
  66950. * Gets wether the color grading effect is enabled.
  66951. */
  66952. get: function () {
  66953. return this.imageProcessingConfiguration.colorGradingEnabled;
  66954. },
  66955. /**
  66956. * Gets wether the color grading effect is enabled.
  66957. */
  66958. set: function (value) {
  66959. this.imageProcessingConfiguration.colorGradingEnabled = value;
  66960. },
  66961. enumerable: true,
  66962. configurable: true
  66963. });
  66964. Object.defineProperty(StandardMaterial.prototype, "cameraToneMappingEnabled", {
  66965. /**
  66966. * Gets wether tonemapping is enabled or not.
  66967. */
  66968. get: function () {
  66969. return this._imageProcessingConfiguration.toneMappingEnabled;
  66970. },
  66971. /**
  66972. * Sets wether tonemapping is enabled or not
  66973. */
  66974. set: function (value) {
  66975. this._imageProcessingConfiguration.toneMappingEnabled = value;
  66976. },
  66977. enumerable: true,
  66978. configurable: true
  66979. });
  66980. Object.defineProperty(StandardMaterial.prototype, "cameraExposure", {
  66981. /**
  66982. * The camera exposure used on this material.
  66983. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  66984. * This corresponds to a photographic exposure.
  66985. */
  66986. get: function () {
  66987. return this._imageProcessingConfiguration.exposure;
  66988. },
  66989. /**
  66990. * The camera exposure used on this material.
  66991. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  66992. * This corresponds to a photographic exposure.
  66993. */
  66994. set: function (value) {
  66995. this._imageProcessingConfiguration.exposure = value;
  66996. },
  66997. enumerable: true,
  66998. configurable: true
  66999. });
  67000. Object.defineProperty(StandardMaterial.prototype, "cameraContrast", {
  67001. /**
  67002. * Gets The camera contrast used on this material.
  67003. */
  67004. get: function () {
  67005. return this._imageProcessingConfiguration.contrast;
  67006. },
  67007. /**
  67008. * Sets The camera contrast used on this material.
  67009. */
  67010. set: function (value) {
  67011. this._imageProcessingConfiguration.contrast = value;
  67012. },
  67013. enumerable: true,
  67014. configurable: true
  67015. });
  67016. Object.defineProperty(StandardMaterial.prototype, "cameraColorGradingTexture", {
  67017. /**
  67018. * Gets the Color Grading 2D Lookup Texture.
  67019. */
  67020. get: function () {
  67021. return this._imageProcessingConfiguration.colorGradingTexture;
  67022. },
  67023. /**
  67024. * Sets the Color Grading 2D Lookup Texture.
  67025. */
  67026. set: function (value) {
  67027. this._imageProcessingConfiguration.colorGradingTexture = value;
  67028. },
  67029. enumerable: true,
  67030. configurable: true
  67031. });
  67032. Object.defineProperty(StandardMaterial.prototype, "cameraColorCurves", {
  67033. /**
  67034. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  67035. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  67036. * 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;
  67037. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  67038. */
  67039. get: function () {
  67040. return this._imageProcessingConfiguration.colorCurves;
  67041. },
  67042. /**
  67043. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  67044. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  67045. * 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;
  67046. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  67047. */
  67048. set: function (value) {
  67049. this._imageProcessingConfiguration.colorCurves = value;
  67050. },
  67051. enumerable: true,
  67052. configurable: true
  67053. });
  67054. Object.defineProperty(StandardMaterial.prototype, "hasRenderTargetTextures", {
  67055. /**
  67056. * Gets a boolean indicating that current material needs to register RTT
  67057. */
  67058. get: function () {
  67059. if (StandardMaterial.ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  67060. return true;
  67061. }
  67062. if (StandardMaterial.RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) {
  67063. return true;
  67064. }
  67065. return false;
  67066. },
  67067. enumerable: true,
  67068. configurable: true
  67069. });
  67070. /**
  67071. * Gets the current class name of the material e.g. "StandardMaterial"
  67072. * Mainly use in serialization.
  67073. * @returns the class name
  67074. */
  67075. StandardMaterial.prototype.getClassName = function () {
  67076. return "StandardMaterial";
  67077. };
  67078. Object.defineProperty(StandardMaterial.prototype, "useLogarithmicDepth", {
  67079. /**
  67080. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  67081. * You can try switching to logarithmic depth.
  67082. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  67083. */
  67084. get: function () {
  67085. return this._useLogarithmicDepth;
  67086. },
  67087. set: function (value) {
  67088. this._useLogarithmicDepth = value && this.getScene().getEngine().getCaps().fragmentDepthSupported;
  67089. this._markAllSubMeshesAsMiscDirty();
  67090. },
  67091. enumerable: true,
  67092. configurable: true
  67093. });
  67094. /**
  67095. * Specifies if the material will require alpha blending
  67096. * @returns a boolean specifying if alpha blending is needed
  67097. */
  67098. StandardMaterial.prototype.needAlphaBlending = function () {
  67099. return (this.alpha < 1.0) || (this._opacityTexture != null) || this._shouldUseAlphaFromDiffuseTexture() || this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled;
  67100. };
  67101. /**
  67102. * Specifies if this material should be rendered in alpha test mode
  67103. * @returns a boolean specifying if an alpha test is needed.
  67104. */
  67105. StandardMaterial.prototype.needAlphaTesting = function () {
  67106. return this._diffuseTexture != null && this._diffuseTexture.hasAlpha;
  67107. };
  67108. StandardMaterial.prototype._shouldUseAlphaFromDiffuseTexture = function () {
  67109. return this._diffuseTexture != null && this._diffuseTexture.hasAlpha && this._useAlphaFromDiffuseTexture;
  67110. };
  67111. /**
  67112. * Get the texture used for alpha test purpose.
  67113. * @returns the diffuse texture in case of the standard material.
  67114. */
  67115. StandardMaterial.prototype.getAlphaTestTexture = function () {
  67116. return this._diffuseTexture;
  67117. };
  67118. /**
  67119. * Get if the submesh is ready to be used and all its information available.
  67120. * Child classes can use it to update shaders
  67121. * @param mesh defines the mesh to check
  67122. * @param subMesh defines which submesh to check
  67123. * @param useInstances specifies that instances should be used
  67124. * @returns a boolean indicating that the submesh is ready or not
  67125. */
  67126. StandardMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  67127. if (useInstances === void 0) { useInstances = false; }
  67128. if (subMesh.effect && this.isFrozen) {
  67129. if (this._wasPreviouslyReady) {
  67130. return true;
  67131. }
  67132. }
  67133. if (!subMesh._materialDefines) {
  67134. subMesh._materialDefines = new StandardMaterialDefines();
  67135. }
  67136. var scene = this.getScene();
  67137. var defines = subMesh._materialDefines;
  67138. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  67139. if (defines._renderId === scene.getRenderId()) {
  67140. return true;
  67141. }
  67142. }
  67143. var engine = scene.getEngine();
  67144. // Lights
  67145. defines._needNormals = _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, true, this._maxSimultaneousLights, this._disableLighting);
  67146. // Textures
  67147. if (defines._areTexturesDirty) {
  67148. defines._needUVs = false;
  67149. defines.MAINUV1 = false;
  67150. defines.MAINUV2 = false;
  67151. if (scene.texturesEnabled) {
  67152. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  67153. if (!this._diffuseTexture.isReadyOrNotBlocking()) {
  67154. return false;
  67155. }
  67156. else {
  67157. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._diffuseTexture, defines, "DIFFUSE");
  67158. }
  67159. }
  67160. else {
  67161. defines.DIFFUSE = false;
  67162. }
  67163. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  67164. if (!this._ambientTexture.isReadyOrNotBlocking()) {
  67165. return false;
  67166. }
  67167. else {
  67168. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._ambientTexture, defines, "AMBIENT");
  67169. }
  67170. }
  67171. else {
  67172. defines.AMBIENT = false;
  67173. }
  67174. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  67175. if (!this._opacityTexture.isReadyOrNotBlocking()) {
  67176. return false;
  67177. }
  67178. else {
  67179. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._opacityTexture, defines, "OPACITY");
  67180. defines.OPACITYRGB = this._opacityTexture.getAlphaFromRGB;
  67181. }
  67182. }
  67183. else {
  67184. defines.OPACITY = false;
  67185. }
  67186. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  67187. if (!this._reflectionTexture.isReadyOrNotBlocking()) {
  67188. return false;
  67189. }
  67190. else {
  67191. defines._needNormals = true;
  67192. defines.REFLECTION = true;
  67193. defines.ROUGHNESS = (this._roughness > 0);
  67194. defines.REFLECTIONOVERALPHA = this._useReflectionOverAlpha;
  67195. defines.INVERTCUBICMAP = (this._reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE);
  67196. defines.REFLECTIONMAP_3D = this._reflectionTexture.isCube;
  67197. switch (this._reflectionTexture.coordinatesMode) {
  67198. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EXPLICIT_MODE:
  67199. defines.setReflectionMode("REFLECTIONMAP_EXPLICIT");
  67200. break;
  67201. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PLANAR_MODE:
  67202. defines.setReflectionMode("REFLECTIONMAP_PLANAR");
  67203. break;
  67204. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PROJECTION_MODE:
  67205. defines.setReflectionMode("REFLECTIONMAP_PROJECTION");
  67206. break;
  67207. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SKYBOX_MODE:
  67208. defines.setReflectionMode("REFLECTIONMAP_SKYBOX");
  67209. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !this._reflectionTexture.getReflectionTextureMatrix().isIdentity();
  67210. break;
  67211. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SPHERICAL_MODE:
  67212. defines.setReflectionMode("REFLECTIONMAP_SPHERICAL");
  67213. break;
  67214. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EQUIRECTANGULAR_MODE:
  67215. defines.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");
  67216. break;
  67217. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  67218. defines.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");
  67219. break;
  67220. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  67221. defines.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED");
  67222. break;
  67223. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].CUBIC_MODE:
  67224. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE:
  67225. default:
  67226. defines.setReflectionMode("REFLECTIONMAP_CUBIC");
  67227. break;
  67228. }
  67229. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = this._reflectionTexture.boundingBoxSize ? true : false;
  67230. }
  67231. }
  67232. else {
  67233. defines.REFLECTION = false;
  67234. }
  67235. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  67236. if (!this._emissiveTexture.isReadyOrNotBlocking()) {
  67237. return false;
  67238. }
  67239. else {
  67240. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._emissiveTexture, defines, "EMISSIVE");
  67241. }
  67242. }
  67243. else {
  67244. defines.EMISSIVE = false;
  67245. }
  67246. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  67247. if (!this._lightmapTexture.isReadyOrNotBlocking()) {
  67248. return false;
  67249. }
  67250. else {
  67251. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._lightmapTexture, defines, "LIGHTMAP");
  67252. defines.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap;
  67253. }
  67254. }
  67255. else {
  67256. defines.LIGHTMAP = false;
  67257. }
  67258. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  67259. if (!this._specularTexture.isReadyOrNotBlocking()) {
  67260. return false;
  67261. }
  67262. else {
  67263. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._specularTexture, defines, "SPECULAR");
  67264. defines.GLOSSINESS = this._useGlossinessFromSpecularMapAlpha;
  67265. }
  67266. }
  67267. else {
  67268. defines.SPECULAR = false;
  67269. }
  67270. if (scene.getEngine().getCaps().standardDerivatives && this._bumpTexture && StandardMaterial.BumpTextureEnabled) {
  67271. // Bump texure can not be not blocking.
  67272. if (!this._bumpTexture.isReady()) {
  67273. return false;
  67274. }
  67275. else {
  67276. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "BUMP");
  67277. defines.PARALLAX = this._useParallax;
  67278. defines.PARALLAXOCCLUSION = this._useParallaxOcclusion;
  67279. }
  67280. defines.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap;
  67281. }
  67282. else {
  67283. defines.BUMP = false;
  67284. }
  67285. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  67286. if (!this._refractionTexture.isReadyOrNotBlocking()) {
  67287. return false;
  67288. }
  67289. else {
  67290. defines._needUVs = true;
  67291. defines.REFRACTION = true;
  67292. defines.REFRACTIONMAP_3D = this._refractionTexture.isCube;
  67293. }
  67294. }
  67295. else {
  67296. defines.REFRACTION = false;
  67297. }
  67298. defines.TWOSIDEDLIGHTING = !this._backFaceCulling && this._twoSidedLighting;
  67299. }
  67300. else {
  67301. defines.DIFFUSE = false;
  67302. defines.AMBIENT = false;
  67303. defines.OPACITY = false;
  67304. defines.REFLECTION = false;
  67305. defines.EMISSIVE = false;
  67306. defines.LIGHTMAP = false;
  67307. defines.BUMP = false;
  67308. defines.REFRACTION = false;
  67309. }
  67310. defines.ALPHAFROMDIFFUSE = this._shouldUseAlphaFromDiffuseTexture();
  67311. defines.EMISSIVEASILLUMINATION = this._useEmissiveAsIllumination;
  67312. defines.LINKEMISSIVEWITHDIFFUSE = this._linkEmissiveWithDiffuse;
  67313. defines.SPECULAROVERALPHA = this._useSpecularOverAlpha;
  67314. 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);
  67315. }
  67316. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  67317. if (!this._imageProcessingConfiguration.isReady()) {
  67318. return false;
  67319. }
  67320. this._imageProcessingConfiguration.prepareDefines(defines);
  67321. defines.IS_REFLECTION_LINEAR = (this.reflectionTexture != null && !this.reflectionTexture.gammaSpace);
  67322. defines.IS_REFRACTION_LINEAR = (this.refractionTexture != null && !this.refractionTexture.gammaSpace);
  67323. }
  67324. if (defines._areFresnelDirty) {
  67325. if (StandardMaterial.FresnelEnabled) {
  67326. // Fresnel
  67327. if (this._diffuseFresnelParameters || this._opacityFresnelParameters ||
  67328. this._emissiveFresnelParameters || this._refractionFresnelParameters ||
  67329. this._reflectionFresnelParameters) {
  67330. defines.DIFFUSEFRESNEL = (this._diffuseFresnelParameters && this._diffuseFresnelParameters.isEnabled);
  67331. defines.OPACITYFRESNEL = (this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled);
  67332. defines.REFLECTIONFRESNEL = (this._reflectionFresnelParameters && this._reflectionFresnelParameters.isEnabled);
  67333. defines.REFLECTIONFRESNELFROMSPECULAR = this._useReflectionFresnelFromSpecular;
  67334. defines.REFRACTIONFRESNEL = (this._refractionFresnelParameters && this._refractionFresnelParameters.isEnabled);
  67335. defines.EMISSIVEFRESNEL = (this._emissiveFresnelParameters && this._emissiveFresnelParameters.isEnabled);
  67336. defines._needNormals = true;
  67337. defines.FRESNEL = true;
  67338. }
  67339. }
  67340. else {
  67341. defines.FRESNEL = false;
  67342. }
  67343. }
  67344. // Misc.
  67345. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  67346. // Attribs
  67347. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true, true);
  67348. // Values that need to be evaluated on every frame
  67349. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
  67350. // Get correct effect
  67351. if (defines.isDirty) {
  67352. defines.markAsProcessed();
  67353. // Fallbacks
  67354. var fallbacks = new _effect__WEBPACK_IMPORTED_MODULE_7__["EffectFallbacks"]();
  67355. if (defines.REFLECTION) {
  67356. fallbacks.addFallback(0, "REFLECTION");
  67357. }
  67358. if (defines.SPECULAR) {
  67359. fallbacks.addFallback(0, "SPECULAR");
  67360. }
  67361. if (defines.BUMP) {
  67362. fallbacks.addFallback(0, "BUMP");
  67363. }
  67364. if (defines.PARALLAX) {
  67365. fallbacks.addFallback(1, "PARALLAX");
  67366. }
  67367. if (defines.PARALLAXOCCLUSION) {
  67368. fallbacks.addFallback(0, "PARALLAXOCCLUSION");
  67369. }
  67370. if (defines.SPECULAROVERALPHA) {
  67371. fallbacks.addFallback(0, "SPECULAROVERALPHA");
  67372. }
  67373. if (defines.FOG) {
  67374. fallbacks.addFallback(1, "FOG");
  67375. }
  67376. if (defines.POINTSIZE) {
  67377. fallbacks.addFallback(0, "POINTSIZE");
  67378. }
  67379. if (defines.LOGARITHMICDEPTH) {
  67380. fallbacks.addFallback(0, "LOGARITHMICDEPTH");
  67381. }
  67382. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights);
  67383. if (defines.SPECULARTERM) {
  67384. fallbacks.addFallback(0, "SPECULARTERM");
  67385. }
  67386. if (defines.DIFFUSEFRESNEL) {
  67387. fallbacks.addFallback(1, "DIFFUSEFRESNEL");
  67388. }
  67389. if (defines.OPACITYFRESNEL) {
  67390. fallbacks.addFallback(2, "OPACITYFRESNEL");
  67391. }
  67392. if (defines.REFLECTIONFRESNEL) {
  67393. fallbacks.addFallback(3, "REFLECTIONFRESNEL");
  67394. }
  67395. if (defines.EMISSIVEFRESNEL) {
  67396. fallbacks.addFallback(4, "EMISSIVEFRESNEL");
  67397. }
  67398. if (defines.FRESNEL) {
  67399. fallbacks.addFallback(4, "FRESNEL");
  67400. }
  67401. //Attributes
  67402. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind];
  67403. if (defines.NORMAL) {
  67404. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  67405. }
  67406. if (defines.UV1) {
  67407. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UVKind);
  67408. }
  67409. if (defines.UV2) {
  67410. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UV2Kind);
  67411. }
  67412. if (defines.VERTEXCOLOR) {
  67413. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind);
  67414. }
  67415. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  67416. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  67417. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, defines);
  67418. var shaderName = "default";
  67419. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vDiffuseColor", "vSpecularColor", "vEmissiveColor",
  67420. "vFogInfos", "vFogColor", "pointSize",
  67421. "vDiffuseInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vEmissiveInfos", "vSpecularInfos", "vBumpInfos", "vLightmapInfos", "vRefractionInfos",
  67422. "mBones",
  67423. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "diffuseMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "specularMatrix", "bumpMatrix", "normalMatrix", "lightmapMatrix", "refractionMatrix",
  67424. "diffuseLeftColor", "diffuseRightColor", "opacityParts", "reflectionLeftColor", "reflectionRightColor", "emissiveLeftColor", "emissiveRightColor", "refractionLeftColor", "refractionRightColor",
  67425. "vReflectionPosition", "vReflectionSize",
  67426. "logarithmicDepthConstant", "vTangentSpaceParams", "alphaCutOff", "boneTextureWidth"
  67427. ];
  67428. var samplers = ["diffuseSampler", "ambientSampler", "opacitySampler", "reflectionCubeSampler",
  67429. "reflection2DSampler", "emissiveSampler", "specularSampler", "bumpSampler", "lightmapSampler",
  67430. "refractionCubeSampler", "refraction2DSampler", "boneSampler"];
  67431. var uniformBuffers = ["Material", "Scene"];
  67432. if (_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"]) {
  67433. _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  67434. _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  67435. }
  67436. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareUniformsAndSamplersList({
  67437. uniformsNames: uniforms,
  67438. uniformBuffersNames: uniformBuffers,
  67439. samplers: samplers,
  67440. defines: defines,
  67441. maxSimultaneousLights: this._maxSimultaneousLights
  67442. });
  67443. if (this.customShaderNameResolve) {
  67444. shaderName = this.customShaderNameResolve(shaderName, uniforms, uniformBuffers, samplers, defines);
  67445. }
  67446. var join = defines.toString();
  67447. var previousEffect = subMesh.effect;
  67448. var effect = scene.getEngine().createEffect(shaderName, {
  67449. attributes: attribs,
  67450. uniformsNames: uniforms,
  67451. uniformBuffersNames: uniformBuffers,
  67452. samplers: samplers,
  67453. defines: join,
  67454. fallbacks: fallbacks,
  67455. onCompiled: this.onCompiled,
  67456. onError: this.onError,
  67457. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS }
  67458. }, engine);
  67459. if (effect) {
  67460. // Use previous effect while new one is compiling
  67461. if (this.allowShaderHotSwapping && previousEffect && !effect.isReady()) {
  67462. effect = previousEffect;
  67463. defines.markAsUnprocessed();
  67464. }
  67465. else {
  67466. scene.resetCachedMaterial();
  67467. subMesh.setEffect(effect, defines);
  67468. this.buildUniformLayout();
  67469. }
  67470. }
  67471. }
  67472. if (!subMesh.effect || !subMesh.effect.isReady()) {
  67473. return false;
  67474. }
  67475. defines._renderId = scene.getRenderId();
  67476. this._wasPreviouslyReady = true;
  67477. return true;
  67478. };
  67479. /**
  67480. * Builds the material UBO layouts.
  67481. * Used internally during the effect preparation.
  67482. */
  67483. StandardMaterial.prototype.buildUniformLayout = function () {
  67484. // Order is important !
  67485. this._uniformBuffer.addUniform("diffuseLeftColor", 4);
  67486. this._uniformBuffer.addUniform("diffuseRightColor", 4);
  67487. this._uniformBuffer.addUniform("opacityParts", 4);
  67488. this._uniformBuffer.addUniform("reflectionLeftColor", 4);
  67489. this._uniformBuffer.addUniform("reflectionRightColor", 4);
  67490. this._uniformBuffer.addUniform("refractionLeftColor", 4);
  67491. this._uniformBuffer.addUniform("refractionRightColor", 4);
  67492. this._uniformBuffer.addUniform("emissiveLeftColor", 4);
  67493. this._uniformBuffer.addUniform("emissiveRightColor", 4);
  67494. this._uniformBuffer.addUniform("vDiffuseInfos", 2);
  67495. this._uniformBuffer.addUniform("vAmbientInfos", 2);
  67496. this._uniformBuffer.addUniform("vOpacityInfos", 2);
  67497. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  67498. this._uniformBuffer.addUniform("vReflectionPosition", 3);
  67499. this._uniformBuffer.addUniform("vReflectionSize", 3);
  67500. this._uniformBuffer.addUniform("vEmissiveInfos", 2);
  67501. this._uniformBuffer.addUniform("vLightmapInfos", 2);
  67502. this._uniformBuffer.addUniform("vSpecularInfos", 2);
  67503. this._uniformBuffer.addUniform("vBumpInfos", 3);
  67504. this._uniformBuffer.addUniform("diffuseMatrix", 16);
  67505. this._uniformBuffer.addUniform("ambientMatrix", 16);
  67506. this._uniformBuffer.addUniform("opacityMatrix", 16);
  67507. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  67508. this._uniformBuffer.addUniform("emissiveMatrix", 16);
  67509. this._uniformBuffer.addUniform("lightmapMatrix", 16);
  67510. this._uniformBuffer.addUniform("specularMatrix", 16);
  67511. this._uniformBuffer.addUniform("bumpMatrix", 16);
  67512. this._uniformBuffer.addUniform("vTangentSpaceParams", 2);
  67513. this._uniformBuffer.addUniform("refractionMatrix", 16);
  67514. this._uniformBuffer.addUniform("vRefractionInfos", 4);
  67515. this._uniformBuffer.addUniform("vSpecularColor", 4);
  67516. this._uniformBuffer.addUniform("vEmissiveColor", 3);
  67517. this._uniformBuffer.addUniform("vDiffuseColor", 4);
  67518. this._uniformBuffer.addUniform("pointSize", 1);
  67519. this._uniformBuffer.create();
  67520. };
  67521. /**
  67522. * Unbinds the material from the mesh
  67523. */
  67524. StandardMaterial.prototype.unbind = function () {
  67525. if (this._activeEffect) {
  67526. var needFlag = false;
  67527. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  67528. this._activeEffect.setTexture("reflection2DSampler", null);
  67529. needFlag = true;
  67530. }
  67531. if (this._refractionTexture && this._refractionTexture.isRenderTarget) {
  67532. this._activeEffect.setTexture("refraction2DSampler", null);
  67533. needFlag = true;
  67534. }
  67535. if (needFlag) {
  67536. this._markAllSubMeshesAsTexturesDirty();
  67537. }
  67538. }
  67539. _super.prototype.unbind.call(this);
  67540. };
  67541. /**
  67542. * Binds the submesh to this material by preparing the effect and shader to draw
  67543. * @param world defines the world transformation matrix
  67544. * @param mesh defines the mesh containing the submesh
  67545. * @param subMesh defines the submesh to bind the material to
  67546. */
  67547. StandardMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  67548. var scene = this.getScene();
  67549. var defines = subMesh._materialDefines;
  67550. if (!defines) {
  67551. return;
  67552. }
  67553. var effect = subMesh.effect;
  67554. if (!effect) {
  67555. return;
  67556. }
  67557. this._activeEffect = effect;
  67558. // Matrices
  67559. this.bindOnlyWorldMatrix(world);
  67560. // Normal Matrix
  67561. if (defines.OBJECTSPACE_NORMALMAP) {
  67562. world.toNormalMatrix(this._normalMatrix);
  67563. this.bindOnlyNormalMatrix(this._normalMatrix);
  67564. }
  67565. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  67566. // Bones
  67567. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindBonesParameters(mesh, effect);
  67568. if (mustRebind) {
  67569. this._uniformBuffer.bindToEffect(effect, "Material");
  67570. this.bindViewProjection(effect);
  67571. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  67572. if (StandardMaterial.FresnelEnabled && defines.FRESNEL) {
  67573. // Fresnel
  67574. if (this.diffuseFresnelParameters && this.diffuseFresnelParameters.isEnabled) {
  67575. this._uniformBuffer.updateColor4("diffuseLeftColor", this.diffuseFresnelParameters.leftColor, this.diffuseFresnelParameters.power);
  67576. this._uniformBuffer.updateColor4("diffuseRightColor", this.diffuseFresnelParameters.rightColor, this.diffuseFresnelParameters.bias);
  67577. }
  67578. if (this.opacityFresnelParameters && this.opacityFresnelParameters.isEnabled) {
  67579. 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);
  67580. }
  67581. if (this.reflectionFresnelParameters && this.reflectionFresnelParameters.isEnabled) {
  67582. this._uniformBuffer.updateColor4("reflectionLeftColor", this.reflectionFresnelParameters.leftColor, this.reflectionFresnelParameters.power);
  67583. this._uniformBuffer.updateColor4("reflectionRightColor", this.reflectionFresnelParameters.rightColor, this.reflectionFresnelParameters.bias);
  67584. }
  67585. if (this.refractionFresnelParameters && this.refractionFresnelParameters.isEnabled) {
  67586. this._uniformBuffer.updateColor4("refractionLeftColor", this.refractionFresnelParameters.leftColor, this.refractionFresnelParameters.power);
  67587. this._uniformBuffer.updateColor4("refractionRightColor", this.refractionFresnelParameters.rightColor, this.refractionFresnelParameters.bias);
  67588. }
  67589. if (this.emissiveFresnelParameters && this.emissiveFresnelParameters.isEnabled) {
  67590. this._uniformBuffer.updateColor4("emissiveLeftColor", this.emissiveFresnelParameters.leftColor, this.emissiveFresnelParameters.power);
  67591. this._uniformBuffer.updateColor4("emissiveRightColor", this.emissiveFresnelParameters.rightColor, this.emissiveFresnelParameters.bias);
  67592. }
  67593. }
  67594. // Textures
  67595. if (scene.texturesEnabled) {
  67596. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  67597. this._uniformBuffer.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
  67598. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._diffuseTexture, this._uniformBuffer, "diffuse");
  67599. if (this._diffuseTexture.hasAlpha) {
  67600. effect.setFloat("alphaCutOff", this.alphaCutOff);
  67601. }
  67602. }
  67603. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  67604. this._uniformBuffer.updateFloat2("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level);
  67605. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._ambientTexture, this._uniformBuffer, "ambient");
  67606. }
  67607. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  67608. this._uniformBuffer.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level);
  67609. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._opacityTexture, this._uniformBuffer, "opacity");
  67610. }
  67611. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  67612. this._uniformBuffer.updateFloat2("vReflectionInfos", this._reflectionTexture.level, this.roughness);
  67613. this._uniformBuffer.updateMatrix("reflectionMatrix", this._reflectionTexture.getReflectionTextureMatrix());
  67614. if (this._reflectionTexture.boundingBoxSize) {
  67615. var cubeTexture = this._reflectionTexture;
  67616. this._uniformBuffer.updateVector3("vReflectionPosition", cubeTexture.boundingBoxPosition);
  67617. this._uniformBuffer.updateVector3("vReflectionSize", cubeTexture.boundingBoxSize);
  67618. }
  67619. }
  67620. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  67621. this._uniformBuffer.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level);
  67622. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._emissiveTexture, this._uniformBuffer, "emissive");
  67623. }
  67624. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  67625. this._uniformBuffer.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level);
  67626. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._lightmapTexture, this._uniformBuffer, "lightmap");
  67627. }
  67628. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  67629. this._uniformBuffer.updateFloat2("vSpecularInfos", this._specularTexture.coordinatesIndex, this._specularTexture.level);
  67630. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._specularTexture, this._uniformBuffer, "specular");
  67631. }
  67632. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial.BumpTextureEnabled) {
  67633. this._uniformBuffer.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, 1.0 / this._bumpTexture.level, this.parallaxScaleBias);
  67634. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, this._uniformBuffer, "bump");
  67635. if (scene._mirroredCameraPosition) {
  67636. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
  67637. }
  67638. else {
  67639. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1.0 : 1.0, this._invertNormalMapY ? -1.0 : 1.0);
  67640. }
  67641. }
  67642. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  67643. var depth = 1.0;
  67644. if (!this._refractionTexture.isCube) {
  67645. this._uniformBuffer.updateMatrix("refractionMatrix", this._refractionTexture.getReflectionTextureMatrix());
  67646. if (this._refractionTexture.depth) {
  67647. depth = this._refractionTexture.depth;
  67648. }
  67649. }
  67650. this._uniformBuffer.updateFloat4("vRefractionInfos", this._refractionTexture.level, this.indexOfRefraction, depth, this.invertRefractionY ? -1 : 1);
  67651. }
  67652. }
  67653. // Point size
  67654. if (this.pointsCloud) {
  67655. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  67656. }
  67657. if (defines.SPECULARTERM) {
  67658. this._uniformBuffer.updateColor4("vSpecularColor", this.specularColor, this.specularPower);
  67659. }
  67660. this._uniformBuffer.updateColor3("vEmissiveColor", StandardMaterial.EmissiveTextureEnabled ? this.emissiveColor : _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].BlackReadOnly);
  67661. // Diffuse
  67662. this._uniformBuffer.updateColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
  67663. }
  67664. // Textures
  67665. if (scene.texturesEnabled) {
  67666. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  67667. effect.setTexture("diffuseSampler", this._diffuseTexture);
  67668. }
  67669. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  67670. effect.setTexture("ambientSampler", this._ambientTexture);
  67671. }
  67672. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  67673. effect.setTexture("opacitySampler", this._opacityTexture);
  67674. }
  67675. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  67676. if (this._reflectionTexture.isCube) {
  67677. effect.setTexture("reflectionCubeSampler", this._reflectionTexture);
  67678. }
  67679. else {
  67680. effect.setTexture("reflection2DSampler", this._reflectionTexture);
  67681. }
  67682. }
  67683. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  67684. effect.setTexture("emissiveSampler", this._emissiveTexture);
  67685. }
  67686. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  67687. effect.setTexture("lightmapSampler", this._lightmapTexture);
  67688. }
  67689. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  67690. effect.setTexture("specularSampler", this._specularTexture);
  67691. }
  67692. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial.BumpTextureEnabled) {
  67693. effect.setTexture("bumpSampler", this._bumpTexture);
  67694. }
  67695. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  67696. var depth = 1.0;
  67697. if (this._refractionTexture.isCube) {
  67698. effect.setTexture("refractionCubeSampler", this._refractionTexture);
  67699. }
  67700. else {
  67701. effect.setTexture("refraction2DSampler", this._refractionTexture);
  67702. }
  67703. }
  67704. }
  67705. // Clip plane
  67706. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindClipPlane(effect, scene);
  67707. // Colors
  67708. scene.ambientColor.multiplyToRef(this.ambientColor, this._globalAmbientColor);
  67709. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindEyePosition(effect, scene);
  67710. effect.setColor3("vAmbientColor", this._globalAmbientColor);
  67711. }
  67712. if (mustRebind || !this.isFrozen) {
  67713. // Lights
  67714. if (scene.lightsEnabled && !this._disableLighting) {
  67715. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindLights(scene, mesh, effect, defines, this._maxSimultaneousLights);
  67716. }
  67717. // View
  67718. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].FOGMODE_NONE || this._reflectionTexture || this._refractionTexture) {
  67719. this.bindView(effect);
  67720. }
  67721. // Fog
  67722. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindFogParameters(scene, mesh, effect);
  67723. // Morph targets
  67724. if (defines.NUM_MORPH_INFLUENCERS) {
  67725. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindMorphTargetParameters(mesh, effect);
  67726. }
  67727. // Log. depth
  67728. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindLogDepth(defines, effect, scene);
  67729. // image processing
  67730. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  67731. this._imageProcessingConfiguration.bind(this._activeEffect);
  67732. }
  67733. }
  67734. this._uniformBuffer.update();
  67735. this._afterBind(mesh, this._activeEffect);
  67736. };
  67737. /**
  67738. * Get the list of animatables in the material.
  67739. * @returns the list of animatables object used in the material
  67740. */
  67741. StandardMaterial.prototype.getAnimatables = function () {
  67742. var results = [];
  67743. if (this._diffuseTexture && this._diffuseTexture.animations && this._diffuseTexture.animations.length > 0) {
  67744. results.push(this._diffuseTexture);
  67745. }
  67746. if (this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0) {
  67747. results.push(this._ambientTexture);
  67748. }
  67749. if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
  67750. results.push(this._opacityTexture);
  67751. }
  67752. if (this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0) {
  67753. results.push(this._reflectionTexture);
  67754. }
  67755. if (this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0) {
  67756. results.push(this._emissiveTexture);
  67757. }
  67758. if (this._specularTexture && this._specularTexture.animations && this._specularTexture.animations.length > 0) {
  67759. results.push(this._specularTexture);
  67760. }
  67761. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  67762. results.push(this._bumpTexture);
  67763. }
  67764. if (this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0) {
  67765. results.push(this._lightmapTexture);
  67766. }
  67767. if (this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0) {
  67768. results.push(this._refractionTexture);
  67769. }
  67770. return results;
  67771. };
  67772. /**
  67773. * Gets the active textures from the material
  67774. * @returns an array of textures
  67775. */
  67776. StandardMaterial.prototype.getActiveTextures = function () {
  67777. var activeTextures = _super.prototype.getActiveTextures.call(this);
  67778. if (this._diffuseTexture) {
  67779. activeTextures.push(this._diffuseTexture);
  67780. }
  67781. if (this._ambientTexture) {
  67782. activeTextures.push(this._ambientTexture);
  67783. }
  67784. if (this._opacityTexture) {
  67785. activeTextures.push(this._opacityTexture);
  67786. }
  67787. if (this._reflectionTexture) {
  67788. activeTextures.push(this._reflectionTexture);
  67789. }
  67790. if (this._emissiveTexture) {
  67791. activeTextures.push(this._emissiveTexture);
  67792. }
  67793. if (this._specularTexture) {
  67794. activeTextures.push(this._specularTexture);
  67795. }
  67796. if (this._bumpTexture) {
  67797. activeTextures.push(this._bumpTexture);
  67798. }
  67799. if (this._lightmapTexture) {
  67800. activeTextures.push(this._lightmapTexture);
  67801. }
  67802. if (this._refractionTexture) {
  67803. activeTextures.push(this._refractionTexture);
  67804. }
  67805. return activeTextures;
  67806. };
  67807. /**
  67808. * Specifies if the material uses a texture
  67809. * @param texture defines the texture to check against the material
  67810. * @returns a boolean specifying if the material uses the texture
  67811. */
  67812. StandardMaterial.prototype.hasTexture = function (texture) {
  67813. if (_super.prototype.hasTexture.call(this, texture)) {
  67814. return true;
  67815. }
  67816. if (this._diffuseTexture === texture) {
  67817. return true;
  67818. }
  67819. if (this._ambientTexture === texture) {
  67820. return true;
  67821. }
  67822. if (this._opacityTexture === texture) {
  67823. return true;
  67824. }
  67825. if (this._reflectionTexture === texture) {
  67826. return true;
  67827. }
  67828. if (this._emissiveTexture === texture) {
  67829. return true;
  67830. }
  67831. if (this._specularTexture === texture) {
  67832. return true;
  67833. }
  67834. if (this._bumpTexture === texture) {
  67835. return true;
  67836. }
  67837. if (this._lightmapTexture === texture) {
  67838. return true;
  67839. }
  67840. if (this._refractionTexture === texture) {
  67841. return true;
  67842. }
  67843. return false;
  67844. };
  67845. /**
  67846. * Disposes the material
  67847. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  67848. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  67849. */
  67850. StandardMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  67851. if (forceDisposeTextures) {
  67852. if (this._diffuseTexture) {
  67853. this._diffuseTexture.dispose();
  67854. }
  67855. if (this._ambientTexture) {
  67856. this._ambientTexture.dispose();
  67857. }
  67858. if (this._opacityTexture) {
  67859. this._opacityTexture.dispose();
  67860. }
  67861. if (this._reflectionTexture) {
  67862. this._reflectionTexture.dispose();
  67863. }
  67864. if (this._emissiveTexture) {
  67865. this._emissiveTexture.dispose();
  67866. }
  67867. if (this._specularTexture) {
  67868. this._specularTexture.dispose();
  67869. }
  67870. if (this._bumpTexture) {
  67871. this._bumpTexture.dispose();
  67872. }
  67873. if (this._lightmapTexture) {
  67874. this._lightmapTexture.dispose();
  67875. }
  67876. if (this._refractionTexture) {
  67877. this._refractionTexture.dispose();
  67878. }
  67879. }
  67880. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  67881. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  67882. }
  67883. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  67884. };
  67885. /**
  67886. * Makes a duplicate of the material, and gives it a new name
  67887. * @param name defines the new name for the duplicated material
  67888. * @returns the cloned material
  67889. */
  67890. StandardMaterial.prototype.clone = function (name) {
  67891. var _this = this;
  67892. var result = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new StandardMaterial(name, _this.getScene()); }, this);
  67893. result.name = name;
  67894. result.id = name;
  67895. return result;
  67896. };
  67897. /**
  67898. * Serializes this material in a JSON representation
  67899. * @returns the serialized material object
  67900. */
  67901. StandardMaterial.prototype.serialize = function () {
  67902. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  67903. };
  67904. /**
  67905. * Creates a standard material from parsed material data
  67906. * @param source defines the JSON representation of the material
  67907. * @param scene defines the hosting scene
  67908. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67909. * @returns a new standard material
  67910. */
  67911. StandardMaterial.Parse = function (source, scene, rootUrl) {
  67912. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new StandardMaterial(source.name, scene); }, source, scene, rootUrl);
  67913. };
  67914. Object.defineProperty(StandardMaterial, "DiffuseTextureEnabled", {
  67915. // Flags used to enable or disable a type of texture for all Standard Materials
  67916. /**
  67917. * Are diffuse textures enabled in the application.
  67918. */
  67919. get: function () {
  67920. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].DiffuseTextureEnabled;
  67921. },
  67922. set: function (value) {
  67923. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].DiffuseTextureEnabled = value;
  67924. },
  67925. enumerable: true,
  67926. configurable: true
  67927. });
  67928. Object.defineProperty(StandardMaterial, "AmbientTextureEnabled", {
  67929. /**
  67930. * Are ambient textures enabled in the application.
  67931. */
  67932. get: function () {
  67933. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].AmbientTextureEnabled;
  67934. },
  67935. set: function (value) {
  67936. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].AmbientTextureEnabled = value;
  67937. },
  67938. enumerable: true,
  67939. configurable: true
  67940. });
  67941. Object.defineProperty(StandardMaterial, "OpacityTextureEnabled", {
  67942. /**
  67943. * Are opacity textures enabled in the application.
  67944. */
  67945. get: function () {
  67946. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].OpacityTextureEnabled;
  67947. },
  67948. set: function (value) {
  67949. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].OpacityTextureEnabled = value;
  67950. },
  67951. enumerable: true,
  67952. configurable: true
  67953. });
  67954. Object.defineProperty(StandardMaterial, "ReflectionTextureEnabled", {
  67955. /**
  67956. * Are reflection textures enabled in the application.
  67957. */
  67958. get: function () {
  67959. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ReflectionTextureEnabled;
  67960. },
  67961. set: function (value) {
  67962. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ReflectionTextureEnabled = value;
  67963. },
  67964. enumerable: true,
  67965. configurable: true
  67966. });
  67967. Object.defineProperty(StandardMaterial, "EmissiveTextureEnabled", {
  67968. /**
  67969. * Are emissive textures enabled in the application.
  67970. */
  67971. get: function () {
  67972. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].EmissiveTextureEnabled;
  67973. },
  67974. set: function (value) {
  67975. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].EmissiveTextureEnabled = value;
  67976. },
  67977. enumerable: true,
  67978. configurable: true
  67979. });
  67980. Object.defineProperty(StandardMaterial, "SpecularTextureEnabled", {
  67981. /**
  67982. * Are specular textures enabled in the application.
  67983. */
  67984. get: function () {
  67985. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].SpecularTextureEnabled;
  67986. },
  67987. set: function (value) {
  67988. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].SpecularTextureEnabled = value;
  67989. },
  67990. enumerable: true,
  67991. configurable: true
  67992. });
  67993. Object.defineProperty(StandardMaterial, "BumpTextureEnabled", {
  67994. /**
  67995. * Are bump textures enabled in the application.
  67996. */
  67997. get: function () {
  67998. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].BumpTextureEnabled;
  67999. },
  68000. set: function (value) {
  68001. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].BumpTextureEnabled = value;
  68002. },
  68003. enumerable: true,
  68004. configurable: true
  68005. });
  68006. Object.defineProperty(StandardMaterial, "LightmapTextureEnabled", {
  68007. /**
  68008. * Are lightmap textures enabled in the application.
  68009. */
  68010. get: function () {
  68011. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].LightmapTextureEnabled;
  68012. },
  68013. set: function (value) {
  68014. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].LightmapTextureEnabled = value;
  68015. },
  68016. enumerable: true,
  68017. configurable: true
  68018. });
  68019. Object.defineProperty(StandardMaterial, "RefractionTextureEnabled", {
  68020. /**
  68021. * Are refraction textures enabled in the application.
  68022. */
  68023. get: function () {
  68024. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].RefractionTextureEnabled;
  68025. },
  68026. set: function (value) {
  68027. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].RefractionTextureEnabled = value;
  68028. },
  68029. enumerable: true,
  68030. configurable: true
  68031. });
  68032. Object.defineProperty(StandardMaterial, "ColorGradingTextureEnabled", {
  68033. /**
  68034. * Are color grading textures enabled in the application.
  68035. */
  68036. get: function () {
  68037. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ColorGradingTextureEnabled;
  68038. },
  68039. set: function (value) {
  68040. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ColorGradingTextureEnabled = value;
  68041. },
  68042. enumerable: true,
  68043. configurable: true
  68044. });
  68045. Object.defineProperty(StandardMaterial, "FresnelEnabled", {
  68046. /**
  68047. * Are fresnels enabled in the application.
  68048. */
  68049. get: function () {
  68050. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].FresnelEnabled;
  68051. },
  68052. set: function (value) {
  68053. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].FresnelEnabled = value;
  68054. },
  68055. enumerable: true,
  68056. configurable: true
  68057. });
  68058. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68059. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTexture")
  68060. ], StandardMaterial.prototype, "_diffuseTexture", void 0);
  68061. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68062. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  68063. ], StandardMaterial.prototype, "diffuseTexture", void 0);
  68064. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68065. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("ambientTexture")
  68066. ], StandardMaterial.prototype, "_ambientTexture", void 0);
  68067. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68068. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68069. ], StandardMaterial.prototype, "ambientTexture", void 0);
  68070. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68071. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("opacityTexture")
  68072. ], StandardMaterial.prototype, "_opacityTexture", void 0);
  68073. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68074. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  68075. ], StandardMaterial.prototype, "opacityTexture", void 0);
  68076. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68077. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("reflectionTexture")
  68078. ], StandardMaterial.prototype, "_reflectionTexture", void 0);
  68079. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68080. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68081. ], StandardMaterial.prototype, "reflectionTexture", void 0);
  68082. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68083. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("emissiveTexture")
  68084. ], StandardMaterial.prototype, "_emissiveTexture", void 0);
  68085. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68086. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68087. ], StandardMaterial.prototype, "emissiveTexture", void 0);
  68088. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68089. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("specularTexture")
  68090. ], StandardMaterial.prototype, "_specularTexture", void 0);
  68091. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68092. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68093. ], StandardMaterial.prototype, "specularTexture", void 0);
  68094. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68095. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("bumpTexture")
  68096. ], StandardMaterial.prototype, "_bumpTexture", void 0);
  68097. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68098. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68099. ], StandardMaterial.prototype, "bumpTexture", void 0);
  68100. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68101. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lightmapTexture")
  68102. ], StandardMaterial.prototype, "_lightmapTexture", void 0);
  68103. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68104. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68105. ], StandardMaterial.prototype, "lightmapTexture", void 0);
  68106. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68107. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("refractionTexture")
  68108. ], StandardMaterial.prototype, "_refractionTexture", void 0);
  68109. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68110. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68111. ], StandardMaterial.prototype, "refractionTexture", void 0);
  68112. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68113. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("ambient")
  68114. ], StandardMaterial.prototype, "ambientColor", void 0);
  68115. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68116. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("diffuse")
  68117. ], StandardMaterial.prototype, "diffuseColor", void 0);
  68118. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68119. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("specular")
  68120. ], StandardMaterial.prototype, "specularColor", void 0);
  68121. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68122. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive")
  68123. ], StandardMaterial.prototype, "emissiveColor", void 0);
  68124. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68125. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  68126. ], StandardMaterial.prototype, "specularPower", void 0);
  68127. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68128. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useAlphaFromDiffuseTexture")
  68129. ], StandardMaterial.prototype, "_useAlphaFromDiffuseTexture", void 0);
  68130. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68131. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68132. ], StandardMaterial.prototype, "useAlphaFromDiffuseTexture", void 0);
  68133. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68134. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useEmissiveAsIllumination")
  68135. ], StandardMaterial.prototype, "_useEmissiveAsIllumination", void 0);
  68136. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68137. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68138. ], StandardMaterial.prototype, "useEmissiveAsIllumination", void 0);
  68139. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68140. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("linkEmissiveWithDiffuse")
  68141. ], StandardMaterial.prototype, "_linkEmissiveWithDiffuse", void 0);
  68142. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68143. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68144. ], StandardMaterial.prototype, "linkEmissiveWithDiffuse", void 0);
  68145. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68146. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useSpecularOverAlpha")
  68147. ], StandardMaterial.prototype, "_useSpecularOverAlpha", void 0);
  68148. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68149. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68150. ], StandardMaterial.prototype, "useSpecularOverAlpha", void 0);
  68151. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68152. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useReflectionOverAlpha")
  68153. ], StandardMaterial.prototype, "_useReflectionOverAlpha", void 0);
  68154. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68155. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68156. ], StandardMaterial.prototype, "useReflectionOverAlpha", void 0);
  68157. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68158. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("disableLighting")
  68159. ], StandardMaterial.prototype, "_disableLighting", void 0);
  68160. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68161. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  68162. ], StandardMaterial.prototype, "disableLighting", void 0);
  68163. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68164. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useObjectSpaceNormalMap")
  68165. ], StandardMaterial.prototype, "_useObjectSpaceNormalMap", void 0);
  68166. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68167. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68168. ], StandardMaterial.prototype, "useObjectSpaceNormalMap", void 0);
  68169. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68170. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useParallax")
  68171. ], StandardMaterial.prototype, "_useParallax", void 0);
  68172. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68173. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68174. ], StandardMaterial.prototype, "useParallax", void 0);
  68175. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68176. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useParallaxOcclusion")
  68177. ], StandardMaterial.prototype, "_useParallaxOcclusion", void 0);
  68178. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68179. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68180. ], StandardMaterial.prototype, "useParallaxOcclusion", void 0);
  68181. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68182. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  68183. ], StandardMaterial.prototype, "parallaxScaleBias", void 0);
  68184. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68185. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("roughness")
  68186. ], StandardMaterial.prototype, "_roughness", void 0);
  68187. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68188. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68189. ], StandardMaterial.prototype, "roughness", void 0);
  68190. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68191. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  68192. ], StandardMaterial.prototype, "indexOfRefraction", void 0);
  68193. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68194. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  68195. ], StandardMaterial.prototype, "invertRefractionY", void 0);
  68196. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68197. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  68198. ], StandardMaterial.prototype, "alphaCutOff", void 0);
  68199. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68200. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useLightmapAsShadowmap")
  68201. ], StandardMaterial.prototype, "_useLightmapAsShadowmap", void 0);
  68202. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68203. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68204. ], StandardMaterial.prototype, "useLightmapAsShadowmap", void 0);
  68205. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68206. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("diffuseFresnelParameters")
  68207. ], StandardMaterial.prototype, "_diffuseFresnelParameters", void 0);
  68208. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68209. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  68210. ], StandardMaterial.prototype, "diffuseFresnelParameters", void 0);
  68211. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68212. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("opacityFresnelParameters")
  68213. ], StandardMaterial.prototype, "_opacityFresnelParameters", void 0);
  68214. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68215. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelAndMiscDirty")
  68216. ], StandardMaterial.prototype, "opacityFresnelParameters", void 0);
  68217. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68218. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("reflectionFresnelParameters")
  68219. ], StandardMaterial.prototype, "_reflectionFresnelParameters", void 0);
  68220. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68221. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  68222. ], StandardMaterial.prototype, "reflectionFresnelParameters", void 0);
  68223. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68224. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("refractionFresnelParameters")
  68225. ], StandardMaterial.prototype, "_refractionFresnelParameters", void 0);
  68226. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68227. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  68228. ], StandardMaterial.prototype, "refractionFresnelParameters", void 0);
  68229. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68230. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("emissiveFresnelParameters")
  68231. ], StandardMaterial.prototype, "_emissiveFresnelParameters", void 0);
  68232. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68233. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  68234. ], StandardMaterial.prototype, "emissiveFresnelParameters", void 0);
  68235. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68236. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useReflectionFresnelFromSpecular")
  68237. ], StandardMaterial.prototype, "_useReflectionFresnelFromSpecular", void 0);
  68238. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68239. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  68240. ], StandardMaterial.prototype, "useReflectionFresnelFromSpecular", void 0);
  68241. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68242. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useGlossinessFromSpecularMapAlpha")
  68243. ], StandardMaterial.prototype, "_useGlossinessFromSpecularMapAlpha", void 0);
  68244. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68245. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68246. ], StandardMaterial.prototype, "useGlossinessFromSpecularMapAlpha", void 0);
  68247. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68248. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("maxSimultaneousLights")
  68249. ], StandardMaterial.prototype, "_maxSimultaneousLights", void 0);
  68250. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68251. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  68252. ], StandardMaterial.prototype, "maxSimultaneousLights", void 0);
  68253. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68254. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("invertNormalMapX")
  68255. ], StandardMaterial.prototype, "_invertNormalMapX", void 0);
  68256. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68257. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68258. ], StandardMaterial.prototype, "invertNormalMapX", void 0);
  68259. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68260. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("invertNormalMapY")
  68261. ], StandardMaterial.prototype, "_invertNormalMapY", void 0);
  68262. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68263. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68264. ], StandardMaterial.prototype, "invertNormalMapY", void 0);
  68265. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68266. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("twoSidedLighting")
  68267. ], StandardMaterial.prototype, "_twoSidedLighting", void 0);
  68268. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68269. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  68270. ], StandardMaterial.prototype, "twoSidedLighting", void 0);
  68271. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  68272. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  68273. ], StandardMaterial.prototype, "useLogarithmicDepth", null);
  68274. return StandardMaterial;
  68275. }(_pushMaterial__WEBPACK_IMPORTED_MODULE_9__["PushMaterial"]));
  68276. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.StandardMaterial"] = StandardMaterial;
  68277. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].DefaultMaterialFactory = function (scene) {
  68278. return new StandardMaterial("default material", scene);
  68279. };
  68280. /***/ }),
  68281. /***/ "./Materials/uniformBuffer.ts":
  68282. /*!************************************!*\
  68283. !*** ./Materials/uniformBuffer.ts ***!
  68284. \************************************/
  68285. /*! exports provided: UniformBuffer */
  68286. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  68287. "use strict";
  68288. __webpack_require__.r(__webpack_exports__);
  68289. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return UniformBuffer; });
  68290. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  68291. /**
  68292. * Uniform buffer objects.
  68293. *
  68294. * Handles blocks of uniform on the GPU.
  68295. *
  68296. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  68297. *
  68298. * For more information, please refer to :
  68299. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  68300. */
  68301. var UniformBuffer = /** @class */ (function () {
  68302. /**
  68303. * Instantiates a new Uniform buffer objects.
  68304. *
  68305. * Handles blocks of uniform on the GPU.
  68306. *
  68307. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  68308. *
  68309. * For more information, please refer to :
  68310. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  68311. * @param engine Define the engine the buffer is associated with
  68312. * @param data Define the data contained in the buffer
  68313. * @param dynamic Define if the buffer is updatable
  68314. */
  68315. function UniformBuffer(engine, data, dynamic) {
  68316. this._engine = engine;
  68317. this._noUBO = !engine.supportsUniformBuffers;
  68318. this._dynamic = dynamic;
  68319. this._data = data || [];
  68320. this._uniformLocations = {};
  68321. this._uniformSizes = {};
  68322. this._uniformLocationPointer = 0;
  68323. this._needSync = false;
  68324. if (this._noUBO) {
  68325. this.updateMatrix3x3 = this._updateMatrix3x3ForEffect;
  68326. this.updateMatrix2x2 = this._updateMatrix2x2ForEffect;
  68327. this.updateFloat = this._updateFloatForEffect;
  68328. this.updateFloat2 = this._updateFloat2ForEffect;
  68329. this.updateFloat3 = this._updateFloat3ForEffect;
  68330. this.updateFloat4 = this._updateFloat4ForEffect;
  68331. this.updateMatrix = this._updateMatrixForEffect;
  68332. this.updateVector3 = this._updateVector3ForEffect;
  68333. this.updateVector4 = this._updateVector4ForEffect;
  68334. this.updateColor3 = this._updateColor3ForEffect;
  68335. this.updateColor4 = this._updateColor4ForEffect;
  68336. }
  68337. else {
  68338. this._engine._uniformBuffers.push(this);
  68339. this.updateMatrix3x3 = this._updateMatrix3x3ForUniform;
  68340. this.updateMatrix2x2 = this._updateMatrix2x2ForUniform;
  68341. this.updateFloat = this._updateFloatForUniform;
  68342. this.updateFloat2 = this._updateFloat2ForUniform;
  68343. this.updateFloat3 = this._updateFloat3ForUniform;
  68344. this.updateFloat4 = this._updateFloat4ForUniform;
  68345. this.updateMatrix = this._updateMatrixForUniform;
  68346. this.updateVector3 = this._updateVector3ForUniform;
  68347. this.updateVector4 = this._updateVector4ForUniform;
  68348. this.updateColor3 = this._updateColor3ForUniform;
  68349. this.updateColor4 = this._updateColor4ForUniform;
  68350. }
  68351. }
  68352. Object.defineProperty(UniformBuffer.prototype, "useUbo", {
  68353. /**
  68354. * Indicates if the buffer is using the WebGL2 UBO implementation,
  68355. * or just falling back on setUniformXXX calls.
  68356. */
  68357. get: function () {
  68358. return !this._noUBO;
  68359. },
  68360. enumerable: true,
  68361. configurable: true
  68362. });
  68363. Object.defineProperty(UniformBuffer.prototype, "isSync", {
  68364. /**
  68365. * Indicates if the WebGL underlying uniform buffer is in sync
  68366. * with the javascript cache data.
  68367. */
  68368. get: function () {
  68369. return !this._needSync;
  68370. },
  68371. enumerable: true,
  68372. configurable: true
  68373. });
  68374. /**
  68375. * Indicates if the WebGL underlying uniform buffer is dynamic.
  68376. * Also, a dynamic UniformBuffer will disable cache verification and always
  68377. * update the underlying WebGL uniform buffer to the GPU.
  68378. * @returns if Dynamic, otherwise false
  68379. */
  68380. UniformBuffer.prototype.isDynamic = function () {
  68381. return this._dynamic !== undefined;
  68382. };
  68383. /**
  68384. * The data cache on JS side.
  68385. * @returns the underlying data as a float array
  68386. */
  68387. UniformBuffer.prototype.getData = function () {
  68388. return this._bufferData;
  68389. };
  68390. /**
  68391. * The underlying WebGL Uniform buffer.
  68392. * @returns the webgl buffer
  68393. */
  68394. UniformBuffer.prototype.getBuffer = function () {
  68395. return this._buffer;
  68396. };
  68397. /**
  68398. * std140 layout specifies how to align data within an UBO structure.
  68399. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  68400. * for specs.
  68401. */
  68402. UniformBuffer.prototype._fillAlignment = function (size) {
  68403. // This code has been simplified because we only use floats, vectors of 1, 2, 3, 4 components
  68404. // and 4x4 matrices
  68405. // TODO : change if other types are used
  68406. var alignment;
  68407. if (size <= 2) {
  68408. alignment = size;
  68409. }
  68410. else {
  68411. alignment = 4;
  68412. }
  68413. if ((this._uniformLocationPointer % alignment) !== 0) {
  68414. var oldPointer = this._uniformLocationPointer;
  68415. this._uniformLocationPointer += alignment - (this._uniformLocationPointer % alignment);
  68416. var diff = this._uniformLocationPointer - oldPointer;
  68417. for (var i = 0; i < diff; i++) {
  68418. this._data.push(0);
  68419. }
  68420. }
  68421. };
  68422. /**
  68423. * Adds an uniform in the buffer.
  68424. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  68425. * for the layout to be correct !
  68426. * @param name Name of the uniform, as used in the uniform block in the shader.
  68427. * @param size Data size, or data directly.
  68428. */
  68429. UniformBuffer.prototype.addUniform = function (name, size) {
  68430. if (this._noUBO) {
  68431. return;
  68432. }
  68433. if (this._uniformLocations[name] !== undefined) {
  68434. // Already existing uniform
  68435. return;
  68436. }
  68437. // This function must be called in the order of the shader layout !
  68438. // size can be the size of the uniform, or data directly
  68439. var data;
  68440. if (size instanceof Array) {
  68441. data = size;
  68442. size = data.length;
  68443. }
  68444. else {
  68445. size = size;
  68446. data = [];
  68447. // Fill with zeros
  68448. for (var i = 0; i < size; i++) {
  68449. data.push(0);
  68450. }
  68451. }
  68452. this._fillAlignment(size);
  68453. this._uniformSizes[name] = size;
  68454. this._uniformLocations[name] = this._uniformLocationPointer;
  68455. this._uniformLocationPointer += size;
  68456. for (var i = 0; i < size; i++) {
  68457. this._data.push(data[i]);
  68458. }
  68459. this._needSync = true;
  68460. };
  68461. /**
  68462. * Adds a Matrix 4x4 to the uniform buffer.
  68463. * @param name Name of the uniform, as used in the uniform block in the shader.
  68464. * @param mat A 4x4 matrix.
  68465. */
  68466. UniformBuffer.prototype.addMatrix = function (name, mat) {
  68467. this.addUniform(name, Array.prototype.slice.call(mat.toArray()));
  68468. };
  68469. /**
  68470. * Adds a vec2 to the uniform buffer.
  68471. * @param name Name of the uniform, as used in the uniform block in the shader.
  68472. * @param x Define the x component value of the vec2
  68473. * @param y Define the y component value of the vec2
  68474. */
  68475. UniformBuffer.prototype.addFloat2 = function (name, x, y) {
  68476. var temp = [x, y];
  68477. this.addUniform(name, temp);
  68478. };
  68479. /**
  68480. * Adds a vec3 to the uniform buffer.
  68481. * @param name Name of the uniform, as used in the uniform block in the shader.
  68482. * @param x Define the x component value of the vec3
  68483. * @param y Define the y component value of the vec3
  68484. * @param z Define the z component value of the vec3
  68485. */
  68486. UniformBuffer.prototype.addFloat3 = function (name, x, y, z) {
  68487. var temp = [x, y, z];
  68488. this.addUniform(name, temp);
  68489. };
  68490. /**
  68491. * Adds a vec3 to the uniform buffer.
  68492. * @param name Name of the uniform, as used in the uniform block in the shader.
  68493. * @param color Define the vec3 from a Color
  68494. */
  68495. UniformBuffer.prototype.addColor3 = function (name, color) {
  68496. var temp = new Array();
  68497. color.toArray(temp);
  68498. this.addUniform(name, temp);
  68499. };
  68500. /**
  68501. * Adds a vec4 to the uniform buffer.
  68502. * @param name Name of the uniform, as used in the uniform block in the shader.
  68503. * @param color Define the rgb components from a Color
  68504. * @param alpha Define the a component of the vec4
  68505. */
  68506. UniformBuffer.prototype.addColor4 = function (name, color, alpha) {
  68507. var temp = new Array();
  68508. color.toArray(temp);
  68509. temp.push(alpha);
  68510. this.addUniform(name, temp);
  68511. };
  68512. /**
  68513. * Adds a vec3 to the uniform buffer.
  68514. * @param name Name of the uniform, as used in the uniform block in the shader.
  68515. * @param vector Define the vec3 components from a Vector
  68516. */
  68517. UniformBuffer.prototype.addVector3 = function (name, vector) {
  68518. var temp = new Array();
  68519. vector.toArray(temp);
  68520. this.addUniform(name, temp);
  68521. };
  68522. /**
  68523. * Adds a Matrix 3x3 to the uniform buffer.
  68524. * @param name Name of the uniform, as used in the uniform block in the shader.
  68525. */
  68526. UniformBuffer.prototype.addMatrix3x3 = function (name) {
  68527. this.addUniform(name, 12);
  68528. };
  68529. /**
  68530. * Adds a Matrix 2x2 to the uniform buffer.
  68531. * @param name Name of the uniform, as used in the uniform block in the shader.
  68532. */
  68533. UniformBuffer.prototype.addMatrix2x2 = function (name) {
  68534. this.addUniform(name, 8);
  68535. };
  68536. /**
  68537. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  68538. */
  68539. UniformBuffer.prototype.create = function () {
  68540. if (this._noUBO) {
  68541. return;
  68542. }
  68543. if (this._buffer) {
  68544. return; // nothing to do
  68545. }
  68546. // See spec, alignment must be filled as a vec4
  68547. this._fillAlignment(4);
  68548. this._bufferData = new Float32Array(this._data);
  68549. this._rebuild();
  68550. this._needSync = true;
  68551. };
  68552. /** @hidden */
  68553. UniformBuffer.prototype._rebuild = function () {
  68554. if (this._noUBO) {
  68555. return;
  68556. }
  68557. if (this._dynamic) {
  68558. this._buffer = this._engine.createDynamicUniformBuffer(this._bufferData);
  68559. }
  68560. else {
  68561. this._buffer = this._engine.createUniformBuffer(this._bufferData);
  68562. }
  68563. };
  68564. /**
  68565. * Updates the WebGL Uniform Buffer on the GPU.
  68566. * If the `dynamic` flag is set to true, no cache comparison is done.
  68567. * Otherwise, the buffer will be updated only if the cache differs.
  68568. */
  68569. UniformBuffer.prototype.update = function () {
  68570. if (!this._buffer) {
  68571. this.create();
  68572. return;
  68573. }
  68574. if (!this._dynamic && !this._needSync) {
  68575. return;
  68576. }
  68577. this._engine.updateUniformBuffer(this._buffer, this._bufferData);
  68578. this._needSync = false;
  68579. };
  68580. /**
  68581. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  68582. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  68583. * @param data Define the flattened data
  68584. * @param size Define the size of the data.
  68585. */
  68586. UniformBuffer.prototype.updateUniform = function (uniformName, data, size) {
  68587. var location = this._uniformLocations[uniformName];
  68588. if (location === undefined) {
  68589. if (this._buffer) {
  68590. // Cannot add an uniform if the buffer is already created
  68591. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Cannot add an uniform after UBO has been created.");
  68592. return;
  68593. }
  68594. this.addUniform(uniformName, size);
  68595. location = this._uniformLocations[uniformName];
  68596. }
  68597. if (!this._buffer) {
  68598. this.create();
  68599. }
  68600. if (!this._dynamic) {
  68601. // Cache for static uniform buffers
  68602. var changed = false;
  68603. for (var i = 0; i < size; i++) {
  68604. if (this._bufferData[location + i] !== data[i]) {
  68605. changed = true;
  68606. this._bufferData[location + i] = data[i];
  68607. }
  68608. }
  68609. this._needSync = this._needSync || changed;
  68610. }
  68611. else {
  68612. // No cache for dynamic
  68613. for (var i = 0; i < size; i++) {
  68614. this._bufferData[location + i] = data[i];
  68615. }
  68616. }
  68617. };
  68618. // Update methods
  68619. UniformBuffer.prototype._updateMatrix3x3ForUniform = function (name, matrix) {
  68620. // To match std140, matrix must be realigned
  68621. for (var i = 0; i < 3; i++) {
  68622. UniformBuffer._tempBuffer[i * 4] = matrix[i * 3];
  68623. UniformBuffer._tempBuffer[i * 4 + 1] = matrix[i * 3 + 1];
  68624. UniformBuffer._tempBuffer[i * 4 + 2] = matrix[i * 3 + 2];
  68625. UniformBuffer._tempBuffer[i * 4 + 3] = 0.0;
  68626. }
  68627. this.updateUniform(name, UniformBuffer._tempBuffer, 12);
  68628. };
  68629. UniformBuffer.prototype._updateMatrix3x3ForEffect = function (name, matrix) {
  68630. this._currentEffect.setMatrix3x3(name, matrix);
  68631. };
  68632. UniformBuffer.prototype._updateMatrix2x2ForEffect = function (name, matrix) {
  68633. this._currentEffect.setMatrix2x2(name, matrix);
  68634. };
  68635. UniformBuffer.prototype._updateMatrix2x2ForUniform = function (name, matrix) {
  68636. // To match std140, matrix must be realigned
  68637. for (var i = 0; i < 2; i++) {
  68638. UniformBuffer._tempBuffer[i * 4] = matrix[i * 2];
  68639. UniformBuffer._tempBuffer[i * 4 + 1] = matrix[i * 2 + 1];
  68640. UniformBuffer._tempBuffer[i * 4 + 2] = 0.0;
  68641. UniformBuffer._tempBuffer[i * 4 + 3] = 0.0;
  68642. }
  68643. this.updateUniform(name, UniformBuffer._tempBuffer, 8);
  68644. };
  68645. UniformBuffer.prototype._updateFloatForEffect = function (name, x) {
  68646. this._currentEffect.setFloat(name, x);
  68647. };
  68648. UniformBuffer.prototype._updateFloatForUniform = function (name, x) {
  68649. UniformBuffer._tempBuffer[0] = x;
  68650. this.updateUniform(name, UniformBuffer._tempBuffer, 1);
  68651. };
  68652. UniformBuffer.prototype._updateFloat2ForEffect = function (name, x, y, suffix) {
  68653. if (suffix === void 0) { suffix = ""; }
  68654. this._currentEffect.setFloat2(name + suffix, x, y);
  68655. };
  68656. UniformBuffer.prototype._updateFloat2ForUniform = function (name, x, y) {
  68657. UniformBuffer._tempBuffer[0] = x;
  68658. UniformBuffer._tempBuffer[1] = y;
  68659. this.updateUniform(name, UniformBuffer._tempBuffer, 2);
  68660. };
  68661. UniformBuffer.prototype._updateFloat3ForEffect = function (name, x, y, z, suffix) {
  68662. if (suffix === void 0) { suffix = ""; }
  68663. this._currentEffect.setFloat3(name + suffix, x, y, z);
  68664. };
  68665. UniformBuffer.prototype._updateFloat3ForUniform = function (name, x, y, z) {
  68666. UniformBuffer._tempBuffer[0] = x;
  68667. UniformBuffer._tempBuffer[1] = y;
  68668. UniformBuffer._tempBuffer[2] = z;
  68669. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  68670. };
  68671. UniformBuffer.prototype._updateFloat4ForEffect = function (name, x, y, z, w, suffix) {
  68672. if (suffix === void 0) { suffix = ""; }
  68673. this._currentEffect.setFloat4(name + suffix, x, y, z, w);
  68674. };
  68675. UniformBuffer.prototype._updateFloat4ForUniform = function (name, x, y, z, w) {
  68676. UniformBuffer._tempBuffer[0] = x;
  68677. UniformBuffer._tempBuffer[1] = y;
  68678. UniformBuffer._tempBuffer[2] = z;
  68679. UniformBuffer._tempBuffer[3] = w;
  68680. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  68681. };
  68682. UniformBuffer.prototype._updateMatrixForEffect = function (name, mat) {
  68683. this._currentEffect.setMatrix(name, mat);
  68684. };
  68685. UniformBuffer.prototype._updateMatrixForUniform = function (name, mat) {
  68686. this.updateUniform(name, mat.toArray(), 16);
  68687. };
  68688. UniformBuffer.prototype._updateVector3ForEffect = function (name, vector) {
  68689. this._currentEffect.setVector3(name, vector);
  68690. };
  68691. UniformBuffer.prototype._updateVector3ForUniform = function (name, vector) {
  68692. vector.toArray(UniformBuffer._tempBuffer);
  68693. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  68694. };
  68695. UniformBuffer.prototype._updateVector4ForEffect = function (name, vector) {
  68696. this._currentEffect.setVector4(name, vector);
  68697. };
  68698. UniformBuffer.prototype._updateVector4ForUniform = function (name, vector) {
  68699. vector.toArray(UniformBuffer._tempBuffer);
  68700. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  68701. };
  68702. UniformBuffer.prototype._updateColor3ForEffect = function (name, color, suffix) {
  68703. if (suffix === void 0) { suffix = ""; }
  68704. this._currentEffect.setColor3(name + suffix, color);
  68705. };
  68706. UniformBuffer.prototype._updateColor3ForUniform = function (name, color) {
  68707. color.toArray(UniformBuffer._tempBuffer);
  68708. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  68709. };
  68710. UniformBuffer.prototype._updateColor4ForEffect = function (name, color, alpha, suffix) {
  68711. if (suffix === void 0) { suffix = ""; }
  68712. this._currentEffect.setColor4(name + suffix, color, alpha);
  68713. };
  68714. UniformBuffer.prototype._updateColor4ForUniform = function (name, color, alpha) {
  68715. color.toArray(UniformBuffer._tempBuffer);
  68716. UniformBuffer._tempBuffer[3] = alpha;
  68717. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  68718. };
  68719. /**
  68720. * Sets a sampler uniform on the effect.
  68721. * @param name Define the name of the sampler.
  68722. * @param texture Define the texture to set in the sampler
  68723. */
  68724. UniformBuffer.prototype.setTexture = function (name, texture) {
  68725. this._currentEffect.setTexture(name, texture);
  68726. };
  68727. /**
  68728. * Directly updates the value of the uniform in the cache AND on the GPU.
  68729. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  68730. * @param data Define the flattened data
  68731. */
  68732. UniformBuffer.prototype.updateUniformDirectly = function (uniformName, data) {
  68733. this.updateUniform(uniformName, data, data.length);
  68734. this.update();
  68735. };
  68736. /**
  68737. * Binds this uniform buffer to an effect.
  68738. * @param effect Define the effect to bind the buffer to
  68739. * @param name Name of the uniform block in the shader.
  68740. */
  68741. UniformBuffer.prototype.bindToEffect = function (effect, name) {
  68742. this._currentEffect = effect;
  68743. if (this._noUBO || !this._buffer) {
  68744. return;
  68745. }
  68746. effect.bindUniformBuffer(this._buffer, name);
  68747. };
  68748. /**
  68749. * Disposes the uniform buffer.
  68750. */
  68751. UniformBuffer.prototype.dispose = function () {
  68752. if (this._noUBO) {
  68753. return;
  68754. }
  68755. var uniformBuffers = this._engine._uniformBuffers;
  68756. var index = uniformBuffers.indexOf(this);
  68757. if (index !== -1) {
  68758. uniformBuffers[index] = uniformBuffers[uniformBuffers.length - 1];
  68759. uniformBuffers.pop();
  68760. }
  68761. if (!this._buffer) {
  68762. return;
  68763. }
  68764. if (this._engine._releaseBuffer(this._buffer)) {
  68765. this._buffer = null;
  68766. }
  68767. };
  68768. // Pool for avoiding memory leaks
  68769. UniformBuffer._MAX_UNIFORM_SIZE = 256;
  68770. UniformBuffer._tempBuffer = new Float32Array(UniformBuffer._MAX_UNIFORM_SIZE);
  68771. return UniformBuffer;
  68772. }());
  68773. /***/ }),
  68774. /***/ "./Maths/index.ts":
  68775. /*!************************!*\
  68776. !*** ./Maths/index.ts ***!
  68777. \************************/
  68778. /*! 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 */
  68779. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  68780. "use strict";
  68781. __webpack_require__.r(__webpack_exports__);
  68782. /* harmony import */ var _math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./math.scalar */ "./Maths/math.scalar.ts");
  68783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"]; });
  68784. /* harmony import */ var _math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./math */ "./Maths/math.ts");
  68785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]; });
  68786. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["ToLinearSpace"]; });
  68787. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"]; });
  68788. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Color3"]; });
  68789. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Color4"]; });
  68790. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]; });
  68791. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]; });
  68792. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector4"]; });
  68793. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Size"]; });
  68794. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]; });
  68795. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]; });
  68796. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Plane"]; });
  68797. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Viewport"]; });
  68798. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Frustum"]; });
  68799. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Space"]; });
  68800. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Axis"]; });
  68801. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["BezierCurve"]; });
  68802. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Orientation"]; });
  68803. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Angle"]; });
  68804. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Arc2"]; });
  68805. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Path2"]; });
  68806. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Path3D"]; });
  68807. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Curve3"]; });
  68808. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["PositionNormalVertex"]; });
  68809. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["PositionNormalTextureVertex"]; });
  68810. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Tmp"]; });
  68811. /* harmony import */ var _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  68812. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalPolynomial"]; });
  68813. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalHarmonics"]; });
  68814. /***/ }),
  68815. /***/ "./Maths/math.scalar.ts":
  68816. /*!******************************!*\
  68817. !*** ./Maths/math.scalar.ts ***!
  68818. \******************************/
  68819. /*! exports provided: Scalar */
  68820. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  68821. "use strict";
  68822. __webpack_require__.r(__webpack_exports__);
  68823. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return Scalar; });
  68824. /**
  68825. * Scalar computation library
  68826. */
  68827. var Scalar = /** @class */ (function () {
  68828. function Scalar() {
  68829. }
  68830. /**
  68831. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  68832. * @param a number
  68833. * @param b number
  68834. * @param epsilon (default = 1.401298E-45)
  68835. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  68836. */
  68837. Scalar.WithinEpsilon = function (a, b, epsilon) {
  68838. if (epsilon === void 0) { epsilon = 1.401298E-45; }
  68839. var num = a - b;
  68840. return -epsilon <= num && num <= epsilon;
  68841. };
  68842. /**
  68843. * Returns a string : the upper case translation of the number i to hexadecimal.
  68844. * @param i number
  68845. * @returns the upper case translation of the number i to hexadecimal.
  68846. */
  68847. Scalar.ToHex = function (i) {
  68848. var str = i.toString(16);
  68849. if (i <= 15) {
  68850. return ("0" + str).toUpperCase();
  68851. }
  68852. return str.toUpperCase();
  68853. };
  68854. /**
  68855. * Returns -1 if value is negative and +1 is value is positive.
  68856. * @param value the value
  68857. * @returns the value itself if it's equal to zero.
  68858. */
  68859. Scalar.Sign = function (value) {
  68860. value = +value; // convert to a number
  68861. if (value === 0 || isNaN(value)) {
  68862. return value;
  68863. }
  68864. return value > 0 ? 1 : -1;
  68865. };
  68866. /**
  68867. * Returns the value itself if it's between min and max.
  68868. * Returns min if the value is lower than min.
  68869. * Returns max if the value is greater than max.
  68870. * @param value the value to clmap
  68871. * @param min the min value to clamp to (default: 0)
  68872. * @param max the max value to clamp to (default: 1)
  68873. * @returns the clamped value
  68874. */
  68875. Scalar.Clamp = function (value, min, max) {
  68876. if (min === void 0) { min = 0; }
  68877. if (max === void 0) { max = 1; }
  68878. return Math.min(max, Math.max(min, value));
  68879. };
  68880. /**
  68881. * the log2 of value.
  68882. * @param value the value to compute log2 of
  68883. * @returns the log2 of value.
  68884. */
  68885. Scalar.Log2 = function (value) {
  68886. return Math.log(value) * Math.LOG2E;
  68887. };
  68888. /**
  68889. * Loops the value, so that it is never larger than length and never smaller than 0.
  68890. *
  68891. * This is similar to the modulo operator but it works with floating point numbers.
  68892. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  68893. * With t = 5 and length = 2.5, the result would be 0.0.
  68894. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  68895. * @param value the value
  68896. * @param length the length
  68897. * @returns the looped value
  68898. */
  68899. Scalar.Repeat = function (value, length) {
  68900. return value - Math.floor(value / length) * length;
  68901. };
  68902. /**
  68903. * Normalize the value between 0.0 and 1.0 using min and max values
  68904. * @param value value to normalize
  68905. * @param min max to normalize between
  68906. * @param max min to normalize between
  68907. * @returns the normalized value
  68908. */
  68909. Scalar.Normalize = function (value, min, max) {
  68910. return (value - min) / (max - min);
  68911. };
  68912. /**
  68913. * Denormalize the value from 0.0 and 1.0 using min and max values
  68914. * @param normalized value to denormalize
  68915. * @param min max to denormalize between
  68916. * @param max min to denormalize between
  68917. * @returns the denormalized value
  68918. */
  68919. Scalar.Denormalize = function (normalized, min, max) {
  68920. return (normalized * (max - min) + min);
  68921. };
  68922. /**
  68923. * Calculates the shortest difference between two given angles given in degrees.
  68924. * @param current current angle in degrees
  68925. * @param target target angle in degrees
  68926. * @returns the delta
  68927. */
  68928. Scalar.DeltaAngle = function (current, target) {
  68929. var num = Scalar.Repeat(target - current, 360.0);
  68930. if (num > 180.0) {
  68931. num -= 360.0;
  68932. }
  68933. return num;
  68934. };
  68935. /**
  68936. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  68937. * @param tx value
  68938. * @param length length
  68939. * @returns The returned value will move back and forth between 0 and length
  68940. */
  68941. Scalar.PingPong = function (tx, length) {
  68942. var t = Scalar.Repeat(tx, length * 2.0);
  68943. return length - Math.abs(t - length);
  68944. };
  68945. /**
  68946. * Interpolates between min and max with smoothing at the limits.
  68947. *
  68948. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  68949. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  68950. * @param from from
  68951. * @param to to
  68952. * @param tx value
  68953. * @returns the smooth stepped value
  68954. */
  68955. Scalar.SmoothStep = function (from, to, tx) {
  68956. var t = Scalar.Clamp(tx);
  68957. t = -2.0 * t * t * t + 3.0 * t * t;
  68958. return to * t + from * (1.0 - t);
  68959. };
  68960. /**
  68961. * Moves a value current towards target.
  68962. *
  68963. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  68964. * Negative values of maxDelta pushes the value away from target.
  68965. * @param current current value
  68966. * @param target target value
  68967. * @param maxDelta max distance to move
  68968. * @returns resulting value
  68969. */
  68970. Scalar.MoveTowards = function (current, target, maxDelta) {
  68971. var result = 0;
  68972. if (Math.abs(target - current) <= maxDelta) {
  68973. result = target;
  68974. }
  68975. else {
  68976. result = current + Scalar.Sign(target - current) * maxDelta;
  68977. }
  68978. return result;
  68979. };
  68980. /**
  68981. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  68982. *
  68983. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  68984. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  68985. * @param current current value
  68986. * @param target target value
  68987. * @param maxDelta max distance to move
  68988. * @returns resulting angle
  68989. */
  68990. Scalar.MoveTowardsAngle = function (current, target, maxDelta) {
  68991. var num = Scalar.DeltaAngle(current, target);
  68992. var result = 0;
  68993. if (-maxDelta < num && num < maxDelta) {
  68994. result = target;
  68995. }
  68996. else {
  68997. target = current + num;
  68998. result = Scalar.MoveTowards(current, target, maxDelta);
  68999. }
  69000. return result;
  69001. };
  69002. /**
  69003. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  69004. * @param start start value
  69005. * @param end target value
  69006. * @param amount amount to lerp between
  69007. * @returns the lerped value
  69008. */
  69009. Scalar.Lerp = function (start, end, amount) {
  69010. return start + ((end - start) * amount);
  69011. };
  69012. /**
  69013. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  69014. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  69015. * @param start start value
  69016. * @param end target value
  69017. * @param amount amount to lerp between
  69018. * @returns the lerped value
  69019. */
  69020. Scalar.LerpAngle = function (start, end, amount) {
  69021. var num = Scalar.Repeat(end - start, 360.0);
  69022. if (num > 180.0) {
  69023. num -= 360.0;
  69024. }
  69025. return start + num * Scalar.Clamp(amount);
  69026. };
  69027. /**
  69028. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  69029. * @param a start value
  69030. * @param b target value
  69031. * @param value value between a and b
  69032. * @returns the inverseLerp value
  69033. */
  69034. Scalar.InverseLerp = function (a, b, value) {
  69035. var result = 0;
  69036. if (a != b) {
  69037. result = Scalar.Clamp((value - a) / (b - a));
  69038. }
  69039. else {
  69040. result = 0.0;
  69041. }
  69042. return result;
  69043. };
  69044. /**
  69045. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  69046. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  69047. * @param value1 spline value
  69048. * @param tangent1 spline value
  69049. * @param value2 spline value
  69050. * @param tangent2 spline value
  69051. * @param amount input value
  69052. * @returns hermite result
  69053. */
  69054. Scalar.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  69055. var squared = amount * amount;
  69056. var cubed = amount * squared;
  69057. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  69058. var part2 = (-2.0 * cubed) + (3.0 * squared);
  69059. var part3 = (cubed - (2.0 * squared)) + amount;
  69060. var part4 = cubed - squared;
  69061. return (((value1 * part1) + (value2 * part2)) + (tangent1 * part3)) + (tangent2 * part4);
  69062. };
  69063. /**
  69064. * Returns a random float number between and min and max values
  69065. * @param min min value of random
  69066. * @param max max value of random
  69067. * @returns random value
  69068. */
  69069. Scalar.RandomRange = function (min, max) {
  69070. if (min === max) {
  69071. return min;
  69072. }
  69073. return ((Math.random() * (max - min)) + min);
  69074. };
  69075. /**
  69076. * This function returns percentage of a number in a given range.
  69077. *
  69078. * RangeToPercent(40,20,60) will return 0.5 (50%)
  69079. * RangeToPercent(34,0,100) will return 0.34 (34%)
  69080. * @param number to convert to percentage
  69081. * @param min min range
  69082. * @param max max range
  69083. * @returns the percentage
  69084. */
  69085. Scalar.RangeToPercent = function (number, min, max) {
  69086. return ((number - min) / (max - min));
  69087. };
  69088. /**
  69089. * This function returns number that corresponds to the percentage in a given range.
  69090. *
  69091. * PercentToRange(0.34,0,100) will return 34.
  69092. * @param percent to convert to number
  69093. * @param min min range
  69094. * @param max max range
  69095. * @returns the number
  69096. */
  69097. Scalar.PercentToRange = function (percent, min, max) {
  69098. return ((max - min) * percent + min);
  69099. };
  69100. /**
  69101. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  69102. * @param angle The angle to normalize in radian.
  69103. * @return The converted angle.
  69104. */
  69105. Scalar.NormalizeRadians = function (angle) {
  69106. // More precise but slower version kept for reference.
  69107. // angle = angle % Tools.TwoPi;
  69108. // angle = (angle + Tools.TwoPi) % Tools.TwoPi;
  69109. //if (angle > Math.PI) {
  69110. // angle -= Tools.TwoPi;
  69111. //}
  69112. angle -= (Scalar.TwoPi * Math.floor((angle + Math.PI) / Scalar.TwoPi));
  69113. return angle;
  69114. };
  69115. /**
  69116. * Two pi constants convenient for computation.
  69117. */
  69118. Scalar.TwoPi = Math.PI * 2;
  69119. return Scalar;
  69120. }());
  69121. /***/ }),
  69122. /***/ "./Maths/math.ts":
  69123. /*!***********************!*\
  69124. !*** ./Maths/math.ts ***!
  69125. \***********************/
  69126. /*! 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 */
  69127. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  69128. "use strict";
  69129. __webpack_require__.r(__webpack_exports__);
  69130. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return ToGammaSpace; });
  69131. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return ToLinearSpace; });
  69132. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return Epsilon; });
  69133. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return Color3; });
  69134. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return Color4; });
  69135. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return Vector2; });
  69136. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return Vector3; });
  69137. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return Vector4; });
  69138. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return Size; });
  69139. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return Quaternion; });
  69140. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return Matrix; });
  69141. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return Plane; });
  69142. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return Viewport; });
  69143. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return Frustum; });
  69144. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return Space; });
  69145. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return Axis; });
  69146. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return BezierCurve; });
  69147. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return Orientation; });
  69148. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return Angle; });
  69149. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return Arc2; });
  69150. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return Path2; });
  69151. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return Path3D; });
  69152. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return Curve3; });
  69153. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return PositionNormalVertex; });
  69154. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return PositionNormalTextureVertex; });
  69155. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return Tmp; });
  69156. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  69157. /* harmony import */ var _math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./math.scalar */ "./Maths/math.scalar.ts");
  69158. /**
  69159. * Constant used to convert a value to gamma space
  69160. * @ignorenaming
  69161. */
  69162. var ToGammaSpace = 1 / 2.2;
  69163. /**
  69164. * Constant used to convert a value to linear space
  69165. * @ignorenaming
  69166. */
  69167. var ToLinearSpace = 2.2;
  69168. /**
  69169. * Constant used to define the minimal number value in Babylon.js
  69170. * @ignorenaming
  69171. */
  69172. var Epsilon = 0.001;
  69173. /**
  69174. * Class used to hold a RBG color
  69175. */
  69176. var Color3 = /** @class */ (function () {
  69177. /**
  69178. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  69179. * @param r defines the red component (between 0 and 1, default is 0)
  69180. * @param g defines the green component (between 0 and 1, default is 0)
  69181. * @param b defines the blue component (between 0 and 1, default is 0)
  69182. */
  69183. function Color3(
  69184. /**
  69185. * Defines the red component (between 0 and 1, default is 0)
  69186. */
  69187. r,
  69188. /**
  69189. * Defines the green component (between 0 and 1, default is 0)
  69190. */
  69191. g,
  69192. /**
  69193. * Defines the blue component (between 0 and 1, default is 0)
  69194. */
  69195. b) {
  69196. if (r === void 0) { r = 0; }
  69197. if (g === void 0) { g = 0; }
  69198. if (b === void 0) { b = 0; }
  69199. this.r = r;
  69200. this.g = g;
  69201. this.b = b;
  69202. }
  69203. /**
  69204. * Creates a string with the Color3 current values
  69205. * @returns the string representation of the Color3 object
  69206. */
  69207. Color3.prototype.toString = function () {
  69208. return "{R: " + this.r + " G:" + this.g + " B:" + this.b + "}";
  69209. };
  69210. /**
  69211. * Returns the string "Color3"
  69212. * @returns "Color3"
  69213. */
  69214. Color3.prototype.getClassName = function () {
  69215. return "Color3";
  69216. };
  69217. /**
  69218. * Compute the Color3 hash code
  69219. * @returns an unique number that can be used to hash Color3 objects
  69220. */
  69221. Color3.prototype.getHashCode = function () {
  69222. var hash = this.r || 0;
  69223. hash = (hash * 397) ^ (this.g || 0);
  69224. hash = (hash * 397) ^ (this.b || 0);
  69225. return hash;
  69226. };
  69227. // Operators
  69228. /**
  69229. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  69230. * @param array defines the array where to store the r,g,b components
  69231. * @param index defines an optional index in the target array to define where to start storing values
  69232. * @returns the current Color3 object
  69233. */
  69234. Color3.prototype.toArray = function (array, index) {
  69235. if (index === void 0) { index = 0; }
  69236. array[index] = this.r;
  69237. array[index + 1] = this.g;
  69238. array[index + 2] = this.b;
  69239. return this;
  69240. };
  69241. /**
  69242. * Returns a new Color4 object from the current Color3 and the given alpha
  69243. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  69244. * @returns a new Color4 object
  69245. */
  69246. Color3.prototype.toColor4 = function (alpha) {
  69247. if (alpha === void 0) { alpha = 1; }
  69248. return new Color4(this.r, this.g, this.b, alpha);
  69249. };
  69250. /**
  69251. * Returns a new array populated with 3 numeric elements : red, green and blue values
  69252. * @returns the new array
  69253. */
  69254. Color3.prototype.asArray = function () {
  69255. var result = new Array();
  69256. this.toArray(result, 0);
  69257. return result;
  69258. };
  69259. /**
  69260. * Returns the luminance value
  69261. * @returns a float value
  69262. */
  69263. Color3.prototype.toLuminance = function () {
  69264. return this.r * 0.3 + this.g * 0.59 + this.b * 0.11;
  69265. };
  69266. /**
  69267. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  69268. * @param otherColor defines the second operand
  69269. * @returns the new Color3 object
  69270. */
  69271. Color3.prototype.multiply = function (otherColor) {
  69272. return new Color3(this.r * otherColor.r, this.g * otherColor.g, this.b * otherColor.b);
  69273. };
  69274. /**
  69275. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  69276. * @param otherColor defines the second operand
  69277. * @param result defines the Color3 object where to store the result
  69278. * @returns the current Color3
  69279. */
  69280. Color3.prototype.multiplyToRef = function (otherColor, result) {
  69281. result.r = this.r * otherColor.r;
  69282. result.g = this.g * otherColor.g;
  69283. result.b = this.b * otherColor.b;
  69284. return this;
  69285. };
  69286. /**
  69287. * Determines equality between Color3 objects
  69288. * @param otherColor defines the second operand
  69289. * @returns true if the rgb values are equal to the given ones
  69290. */
  69291. Color3.prototype.equals = function (otherColor) {
  69292. return otherColor && this.r === otherColor.r && this.g === otherColor.g && this.b === otherColor.b;
  69293. };
  69294. /**
  69295. * Determines equality between the current Color3 object and a set of r,b,g values
  69296. * @param r defines the red component to check
  69297. * @param g defines the green component to check
  69298. * @param b defines the blue component to check
  69299. * @returns true if the rgb values are equal to the given ones
  69300. */
  69301. Color3.prototype.equalsFloats = function (r, g, b) {
  69302. return this.r === r && this.g === g && this.b === b;
  69303. };
  69304. /**
  69305. * Multiplies in place each rgb value by scale
  69306. * @param scale defines the scaling factor
  69307. * @returns the updated Color3
  69308. */
  69309. Color3.prototype.scale = function (scale) {
  69310. return new Color3(this.r * scale, this.g * scale, this.b * scale);
  69311. };
  69312. /**
  69313. * Multiplies the rgb values by scale and stores the result into "result"
  69314. * @param scale defines the scaling factor
  69315. * @param result defines the Color3 object where to store the result
  69316. * @returns the unmodified current Color3
  69317. */
  69318. Color3.prototype.scaleToRef = function (scale, result) {
  69319. result.r = this.r * scale;
  69320. result.g = this.g * scale;
  69321. result.b = this.b * scale;
  69322. return this;
  69323. };
  69324. /**
  69325. * Scale the current Color3 values by a factor and add the result to a given Color3
  69326. * @param scale defines the scale factor
  69327. * @param result defines color to store the result into
  69328. * @returns the unmodified current Color3
  69329. */
  69330. Color3.prototype.scaleAndAddToRef = function (scale, result) {
  69331. result.r += this.r * scale;
  69332. result.g += this.g * scale;
  69333. result.b += this.b * scale;
  69334. return this;
  69335. };
  69336. /**
  69337. * Clamps the rgb values by the min and max values and stores the result into "result"
  69338. * @param min defines minimum clamping value (default is 0)
  69339. * @param max defines maximum clamping value (default is 1)
  69340. * @param result defines color to store the result into
  69341. * @returns the original Color3
  69342. */
  69343. Color3.prototype.clampToRef = function (min, max, result) {
  69344. if (min === void 0) { min = 0; }
  69345. if (max === void 0) { max = 1; }
  69346. result.r = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.r, min, max);
  69347. result.g = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.g, min, max);
  69348. result.b = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.b, min, max);
  69349. return this;
  69350. };
  69351. /**
  69352. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  69353. * @param otherColor defines the second operand
  69354. * @returns the new Color3
  69355. */
  69356. Color3.prototype.add = function (otherColor) {
  69357. return new Color3(this.r + otherColor.r, this.g + otherColor.g, this.b + otherColor.b);
  69358. };
  69359. /**
  69360. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  69361. * @param otherColor defines the second operand
  69362. * @param result defines Color3 object to store the result into
  69363. * @returns the unmodified current Color3
  69364. */
  69365. Color3.prototype.addToRef = function (otherColor, result) {
  69366. result.r = this.r + otherColor.r;
  69367. result.g = this.g + otherColor.g;
  69368. result.b = this.b + otherColor.b;
  69369. return this;
  69370. };
  69371. /**
  69372. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  69373. * @param otherColor defines the second operand
  69374. * @returns the new Color3
  69375. */
  69376. Color3.prototype.subtract = function (otherColor) {
  69377. return new Color3(this.r - otherColor.r, this.g - otherColor.g, this.b - otherColor.b);
  69378. };
  69379. /**
  69380. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  69381. * @param otherColor defines the second operand
  69382. * @param result defines Color3 object to store the result into
  69383. * @returns the unmodified current Color3
  69384. */
  69385. Color3.prototype.subtractToRef = function (otherColor, result) {
  69386. result.r = this.r - otherColor.r;
  69387. result.g = this.g - otherColor.g;
  69388. result.b = this.b - otherColor.b;
  69389. return this;
  69390. };
  69391. /**
  69392. * Copy the current object
  69393. * @returns a new Color3 copied the current one
  69394. */
  69395. Color3.prototype.clone = function () {
  69396. return new Color3(this.r, this.g, this.b);
  69397. };
  69398. /**
  69399. * Copies the rgb values from the source in the current Color3
  69400. * @param source defines the source Color3 object
  69401. * @returns the updated Color3 object
  69402. */
  69403. Color3.prototype.copyFrom = function (source) {
  69404. this.r = source.r;
  69405. this.g = source.g;
  69406. this.b = source.b;
  69407. return this;
  69408. };
  69409. /**
  69410. * Updates the Color3 rgb values from the given floats
  69411. * @param r defines the red component to read from
  69412. * @param g defines the green component to read from
  69413. * @param b defines the blue component to read from
  69414. * @returns the current Color3 object
  69415. */
  69416. Color3.prototype.copyFromFloats = function (r, g, b) {
  69417. this.r = r;
  69418. this.g = g;
  69419. this.b = b;
  69420. return this;
  69421. };
  69422. /**
  69423. * Updates the Color3 rgb values from the given floats
  69424. * @param r defines the red component to read from
  69425. * @param g defines the green component to read from
  69426. * @param b defines the blue component to read from
  69427. * @returns the current Color3 object
  69428. */
  69429. Color3.prototype.set = function (r, g, b) {
  69430. return this.copyFromFloats(r, g, b);
  69431. };
  69432. /**
  69433. * Compute the Color3 hexadecimal code as a string
  69434. * @returns a string containing the hexadecimal representation of the Color3 object
  69435. */
  69436. Color3.prototype.toHexString = function () {
  69437. var intR = (this.r * 255) | 0;
  69438. var intG = (this.g * 255) | 0;
  69439. var intB = (this.b * 255) | 0;
  69440. 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);
  69441. };
  69442. /**
  69443. * Computes a new Color3 converted from the current one to linear space
  69444. * @returns a new Color3 object
  69445. */
  69446. Color3.prototype.toLinearSpace = function () {
  69447. var convertedColor = new Color3();
  69448. this.toLinearSpaceToRef(convertedColor);
  69449. return convertedColor;
  69450. };
  69451. /**
  69452. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  69453. * @param convertedColor defines the Color3 object where to store the linear space version
  69454. * @returns the unmodified Color3
  69455. */
  69456. Color3.prototype.toLinearSpaceToRef = function (convertedColor) {
  69457. convertedColor.r = Math.pow(this.r, ToLinearSpace);
  69458. convertedColor.g = Math.pow(this.g, ToLinearSpace);
  69459. convertedColor.b = Math.pow(this.b, ToLinearSpace);
  69460. return this;
  69461. };
  69462. /**
  69463. * Computes a new Color3 converted from the current one to gamma space
  69464. * @returns a new Color3 object
  69465. */
  69466. Color3.prototype.toGammaSpace = function () {
  69467. var convertedColor = new Color3();
  69468. this.toGammaSpaceToRef(convertedColor);
  69469. return convertedColor;
  69470. };
  69471. /**
  69472. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  69473. * @param convertedColor defines the Color3 object where to store the gamma space version
  69474. * @returns the unmodified Color3
  69475. */
  69476. Color3.prototype.toGammaSpaceToRef = function (convertedColor) {
  69477. convertedColor.r = Math.pow(this.r, ToGammaSpace);
  69478. convertedColor.g = Math.pow(this.g, ToGammaSpace);
  69479. convertedColor.b = Math.pow(this.b, ToGammaSpace);
  69480. return this;
  69481. };
  69482. /**
  69483. * Creates a new Color3 from the string containing valid hexadecimal values
  69484. * @param hex defines a string containing valid hexadecimal values
  69485. * @returns a new Color3 object
  69486. */
  69487. Color3.FromHexString = function (hex) {
  69488. if (hex.substring(0, 1) !== "#" || hex.length !== 7) {
  69489. return new Color3(0, 0, 0);
  69490. }
  69491. var r = parseInt(hex.substring(1, 3), 16);
  69492. var g = parseInt(hex.substring(3, 5), 16);
  69493. var b = parseInt(hex.substring(5, 7), 16);
  69494. return Color3.FromInts(r, g, b);
  69495. };
  69496. /**
  69497. * Creates a new Vector3 from the starting index of the given array
  69498. * @param array defines the source array
  69499. * @param offset defines an offset in the source array
  69500. * @returns a new Color3 object
  69501. */
  69502. Color3.FromArray = function (array, offset) {
  69503. if (offset === void 0) { offset = 0; }
  69504. return new Color3(array[offset], array[offset + 1], array[offset + 2]);
  69505. };
  69506. /**
  69507. * Creates a new Color3 from integer values (< 256)
  69508. * @param r defines the red component to read from (value between 0 and 255)
  69509. * @param g defines the green component to read from (value between 0 and 255)
  69510. * @param b defines the blue component to read from (value between 0 and 255)
  69511. * @returns a new Color3 object
  69512. */
  69513. Color3.FromInts = function (r, g, b) {
  69514. return new Color3(r / 255.0, g / 255.0, b / 255.0);
  69515. };
  69516. /**
  69517. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  69518. * @param start defines the start Color3 value
  69519. * @param end defines the end Color3 value
  69520. * @param amount defines the gradient value between start and end
  69521. * @returns a new Color3 object
  69522. */
  69523. Color3.Lerp = function (start, end, amount) {
  69524. var result = new Color3(0.0, 0.0, 0.0);
  69525. Color3.LerpToRef(start, end, amount, result);
  69526. return result;
  69527. };
  69528. /**
  69529. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  69530. * @param left defines the start value
  69531. * @param right defines the end value
  69532. * @param amount defines the gradient factor
  69533. * @param result defines the Color3 object where to store the result
  69534. */
  69535. Color3.LerpToRef = function (left, right, amount, result) {
  69536. result.r = left.r + ((right.r - left.r) * amount);
  69537. result.g = left.g + ((right.g - left.g) * amount);
  69538. result.b = left.b + ((right.b - left.b) * amount);
  69539. };
  69540. /**
  69541. * Returns a Color3 value containing a red color
  69542. * @returns a new Color3 object
  69543. */
  69544. Color3.Red = function () { return new Color3(1, 0, 0); };
  69545. /**
  69546. * Returns a Color3 value containing a green color
  69547. * @returns a new Color3 object
  69548. */
  69549. Color3.Green = function () { return new Color3(0, 1, 0); };
  69550. /**
  69551. * Returns a Color3 value containing a blue color
  69552. * @returns a new Color3 object
  69553. */
  69554. Color3.Blue = function () { return new Color3(0, 0, 1); };
  69555. /**
  69556. * Returns a Color3 value containing a black color
  69557. * @returns a new Color3 object
  69558. */
  69559. Color3.Black = function () { return new Color3(0, 0, 0); };
  69560. Object.defineProperty(Color3, "BlackReadOnly", {
  69561. /**
  69562. * Gets a Color3 value containing a black color that must not be updated
  69563. */
  69564. get: function () {
  69565. return Color3._BlackReadOnly;
  69566. },
  69567. enumerable: true,
  69568. configurable: true
  69569. });
  69570. /**
  69571. * Returns a Color3 value containing a white color
  69572. * @returns a new Color3 object
  69573. */
  69574. Color3.White = function () { return new Color3(1, 1, 1); };
  69575. /**
  69576. * Returns a Color3 value containing a purple color
  69577. * @returns a new Color3 object
  69578. */
  69579. Color3.Purple = function () { return new Color3(0.5, 0, 0.5); };
  69580. /**
  69581. * Returns a Color3 value containing a magenta color
  69582. * @returns a new Color3 object
  69583. */
  69584. Color3.Magenta = function () { return new Color3(1, 0, 1); };
  69585. /**
  69586. * Returns a Color3 value containing a yellow color
  69587. * @returns a new Color3 object
  69588. */
  69589. Color3.Yellow = function () { return new Color3(1, 1, 0); };
  69590. /**
  69591. * Returns a Color3 value containing a gray color
  69592. * @returns a new Color3 object
  69593. */
  69594. Color3.Gray = function () { return new Color3(0.5, 0.5, 0.5); };
  69595. /**
  69596. * Returns a Color3 value containing a teal color
  69597. * @returns a new Color3 object
  69598. */
  69599. Color3.Teal = function () { return new Color3(0, 1.0, 1.0); };
  69600. /**
  69601. * Returns a Color3 value containing a random color
  69602. * @returns a new Color3 object
  69603. */
  69604. Color3.Random = function () { return new Color3(Math.random(), Math.random(), Math.random()); };
  69605. // Statics
  69606. Color3._BlackReadOnly = Color3.Black();
  69607. return Color3;
  69608. }());
  69609. /**
  69610. * Class used to hold a RBGA color
  69611. */
  69612. var Color4 = /** @class */ (function () {
  69613. /**
  69614. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  69615. * @param r defines the red component (between 0 and 1, default is 0)
  69616. * @param g defines the green component (between 0 and 1, default is 0)
  69617. * @param b defines the blue component (between 0 and 1, default is 0)
  69618. * @param a defines the alpha component (between 0 and 1, default is 1)
  69619. */
  69620. function Color4(
  69621. /**
  69622. * Defines the red component (between 0 and 1, default is 0)
  69623. */
  69624. r,
  69625. /**
  69626. * Defines the green component (between 0 and 1, default is 0)
  69627. */
  69628. g,
  69629. /**
  69630. * Defines the blue component (between 0 and 1, default is 0)
  69631. */
  69632. b,
  69633. /**
  69634. * Defines the alpha component (between 0 and 1, default is 1)
  69635. */
  69636. a) {
  69637. if (r === void 0) { r = 0; }
  69638. if (g === void 0) { g = 0; }
  69639. if (b === void 0) { b = 0; }
  69640. if (a === void 0) { a = 1; }
  69641. this.r = r;
  69642. this.g = g;
  69643. this.b = b;
  69644. this.a = a;
  69645. }
  69646. // Operators
  69647. /**
  69648. * Adds in place the given Color4 values to the current Color4 object
  69649. * @param right defines the second operand
  69650. * @returns the current updated Color4 object
  69651. */
  69652. Color4.prototype.addInPlace = function (right) {
  69653. this.r += right.r;
  69654. this.g += right.g;
  69655. this.b += right.b;
  69656. this.a += right.a;
  69657. return this;
  69658. };
  69659. /**
  69660. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  69661. * @returns the new array
  69662. */
  69663. Color4.prototype.asArray = function () {
  69664. var result = new Array();
  69665. this.toArray(result, 0);
  69666. return result;
  69667. };
  69668. /**
  69669. * Stores from the starting index in the given array the Color4 successive values
  69670. * @param array defines the array where to store the r,g,b components
  69671. * @param index defines an optional index in the target array to define where to start storing values
  69672. * @returns the current Color4 object
  69673. */
  69674. Color4.prototype.toArray = function (array, index) {
  69675. if (index === void 0) { index = 0; }
  69676. array[index] = this.r;
  69677. array[index + 1] = this.g;
  69678. array[index + 2] = this.b;
  69679. array[index + 3] = this.a;
  69680. return this;
  69681. };
  69682. /**
  69683. * Determines equality between Color4 objects
  69684. * @param otherColor defines the second operand
  69685. * @returns true if the rgba values are equal to the given ones
  69686. */
  69687. Color4.prototype.equals = function (otherColor) {
  69688. return otherColor && this.r === otherColor.r && this.g === otherColor.g && this.b === otherColor.b && this.a === otherColor.a;
  69689. };
  69690. /**
  69691. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  69692. * @param right defines the second operand
  69693. * @returns a new Color4 object
  69694. */
  69695. Color4.prototype.add = function (right) {
  69696. return new Color4(this.r + right.r, this.g + right.g, this.b + right.b, this.a + right.a);
  69697. };
  69698. /**
  69699. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  69700. * @param right defines the second operand
  69701. * @returns a new Color4 object
  69702. */
  69703. Color4.prototype.subtract = function (right) {
  69704. return new Color4(this.r - right.r, this.g - right.g, this.b - right.b, this.a - right.a);
  69705. };
  69706. /**
  69707. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  69708. * @param right defines the second operand
  69709. * @param result defines the Color4 object where to store the result
  69710. * @returns the current Color4 object
  69711. */
  69712. Color4.prototype.subtractToRef = function (right, result) {
  69713. result.r = this.r - right.r;
  69714. result.g = this.g - right.g;
  69715. result.b = this.b - right.b;
  69716. result.a = this.a - right.a;
  69717. return this;
  69718. };
  69719. /**
  69720. * Creates a new Color4 with the current Color4 values multiplied by scale
  69721. * @param scale defines the scaling factor to apply
  69722. * @returns a new Color4 object
  69723. */
  69724. Color4.prototype.scale = function (scale) {
  69725. return new Color4(this.r * scale, this.g * scale, this.b * scale, this.a * scale);
  69726. };
  69727. /**
  69728. * Multiplies the current Color4 values by scale and stores the result in "result"
  69729. * @param scale defines the scaling factor to apply
  69730. * @param result defines the Color4 object where to store the result
  69731. * @returns the current unmodified Color4
  69732. */
  69733. Color4.prototype.scaleToRef = function (scale, result) {
  69734. result.r = this.r * scale;
  69735. result.g = this.g * scale;
  69736. result.b = this.b * scale;
  69737. result.a = this.a * scale;
  69738. return this;
  69739. };
  69740. /**
  69741. * Scale the current Color4 values by a factor and add the result to a given Color4
  69742. * @param scale defines the scale factor
  69743. * @param result defines the Color4 object where to store the result
  69744. * @returns the unmodified current Color4
  69745. */
  69746. Color4.prototype.scaleAndAddToRef = function (scale, result) {
  69747. result.r += this.r * scale;
  69748. result.g += this.g * scale;
  69749. result.b += this.b * scale;
  69750. result.a += this.a * scale;
  69751. return this;
  69752. };
  69753. /**
  69754. * Clamps the rgb values by the min and max values and stores the result into "result"
  69755. * @param min defines minimum clamping value (default is 0)
  69756. * @param max defines maximum clamping value (default is 1)
  69757. * @param result defines color to store the result into.
  69758. * @returns the cuurent Color4
  69759. */
  69760. Color4.prototype.clampToRef = function (min, max, result) {
  69761. if (min === void 0) { min = 0; }
  69762. if (max === void 0) { max = 1; }
  69763. result.r = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.r, min, max);
  69764. result.g = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.g, min, max);
  69765. result.b = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.b, min, max);
  69766. result.a = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.a, min, max);
  69767. return this;
  69768. };
  69769. /**
  69770. * Multipy an Color4 value by another and return a new Color4 object
  69771. * @param color defines the Color4 value to multiply by
  69772. * @returns a new Color4 object
  69773. */
  69774. Color4.prototype.multiply = function (color) {
  69775. return new Color4(this.r * color.r, this.g * color.g, this.b * color.b, this.a * color.a);
  69776. };
  69777. /**
  69778. * Multipy a Color4 value by another and push the result in a reference value
  69779. * @param color defines the Color4 value to multiply by
  69780. * @param result defines the Color4 to fill the result in
  69781. * @returns the result Color4
  69782. */
  69783. Color4.prototype.multiplyToRef = function (color, result) {
  69784. result.r = this.r * color.r;
  69785. result.g = this.g * color.g;
  69786. result.b = this.b * color.b;
  69787. result.a = this.a * color.a;
  69788. return result;
  69789. };
  69790. /**
  69791. * Creates a string with the Color4 current values
  69792. * @returns the string representation of the Color4 object
  69793. */
  69794. Color4.prototype.toString = function () {
  69795. return "{R: " + this.r + " G:" + this.g + " B:" + this.b + " A:" + this.a + "}";
  69796. };
  69797. /**
  69798. * Returns the string "Color4"
  69799. * @returns "Color4"
  69800. */
  69801. Color4.prototype.getClassName = function () {
  69802. return "Color4";
  69803. };
  69804. /**
  69805. * Compute the Color4 hash code
  69806. * @returns an unique number that can be used to hash Color4 objects
  69807. */
  69808. Color4.prototype.getHashCode = function () {
  69809. var hash = this.r || 0;
  69810. hash = (hash * 397) ^ (this.g || 0);
  69811. hash = (hash * 397) ^ (this.b || 0);
  69812. hash = (hash * 397) ^ (this.a || 0);
  69813. return hash;
  69814. };
  69815. /**
  69816. * Creates a new Color4 copied from the current one
  69817. * @returns a new Color4 object
  69818. */
  69819. Color4.prototype.clone = function () {
  69820. return new Color4(this.r, this.g, this.b, this.a);
  69821. };
  69822. /**
  69823. * Copies the given Color4 values into the current one
  69824. * @param source defines the source Color4 object
  69825. * @returns the current updated Color4 object
  69826. */
  69827. Color4.prototype.copyFrom = function (source) {
  69828. this.r = source.r;
  69829. this.g = source.g;
  69830. this.b = source.b;
  69831. this.a = source.a;
  69832. return this;
  69833. };
  69834. /**
  69835. * Copies the given float values into the current one
  69836. * @param r defines the red component to read from
  69837. * @param g defines the green component to read from
  69838. * @param b defines the blue component to read from
  69839. * @param a defines the alpha component to read from
  69840. * @returns the current updated Color4 object
  69841. */
  69842. Color4.prototype.copyFromFloats = function (r, g, b, a) {
  69843. this.r = r;
  69844. this.g = g;
  69845. this.b = b;
  69846. this.a = a;
  69847. return this;
  69848. };
  69849. /**
  69850. * Copies the given float values into the current one
  69851. * @param r defines the red component to read from
  69852. * @param g defines the green component to read from
  69853. * @param b defines the blue component to read from
  69854. * @param a defines the alpha component to read from
  69855. * @returns the current updated Color4 object
  69856. */
  69857. Color4.prototype.set = function (r, g, b, a) {
  69858. return this.copyFromFloats(r, g, b, a);
  69859. };
  69860. /**
  69861. * Compute the Color4 hexadecimal code as a string
  69862. * @returns a string containing the hexadecimal representation of the Color4 object
  69863. */
  69864. Color4.prototype.toHexString = function () {
  69865. var intR = (this.r * 255) | 0;
  69866. var intG = (this.g * 255) | 0;
  69867. var intB = (this.b * 255) | 0;
  69868. var intA = (this.a * 255) | 0;
  69869. 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);
  69870. };
  69871. /**
  69872. * Computes a new Color4 converted from the current one to linear space
  69873. * @returns a new Color4 object
  69874. */
  69875. Color4.prototype.toLinearSpace = function () {
  69876. var convertedColor = new Color4();
  69877. this.toLinearSpaceToRef(convertedColor);
  69878. return convertedColor;
  69879. };
  69880. /**
  69881. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  69882. * @param convertedColor defines the Color4 object where to store the linear space version
  69883. * @returns the unmodified Color4
  69884. */
  69885. Color4.prototype.toLinearSpaceToRef = function (convertedColor) {
  69886. convertedColor.r = Math.pow(this.r, ToLinearSpace);
  69887. convertedColor.g = Math.pow(this.g, ToLinearSpace);
  69888. convertedColor.b = Math.pow(this.b, ToLinearSpace);
  69889. convertedColor.a = this.a;
  69890. return this;
  69891. };
  69892. /**
  69893. * Computes a new Color4 converted from the current one to gamma space
  69894. * @returns a new Color4 object
  69895. */
  69896. Color4.prototype.toGammaSpace = function () {
  69897. var convertedColor = new Color4();
  69898. this.toGammaSpaceToRef(convertedColor);
  69899. return convertedColor;
  69900. };
  69901. /**
  69902. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  69903. * @param convertedColor defines the Color4 object where to store the gamma space version
  69904. * @returns the unmodified Color4
  69905. */
  69906. Color4.prototype.toGammaSpaceToRef = function (convertedColor) {
  69907. convertedColor.r = Math.pow(this.r, ToGammaSpace);
  69908. convertedColor.g = Math.pow(this.g, ToGammaSpace);
  69909. convertedColor.b = Math.pow(this.b, ToGammaSpace);
  69910. convertedColor.a = this.a;
  69911. return this;
  69912. };
  69913. // Statics
  69914. /**
  69915. * Creates a new Color4 from the string containing valid hexadecimal values
  69916. * @param hex defines a string containing valid hexadecimal values
  69917. * @returns a new Color4 object
  69918. */
  69919. Color4.FromHexString = function (hex) {
  69920. if (hex.substring(0, 1) !== "#" || hex.length !== 9) {
  69921. return new Color4(0.0, 0.0, 0.0, 0.0);
  69922. }
  69923. var r = parseInt(hex.substring(1, 3), 16);
  69924. var g = parseInt(hex.substring(3, 5), 16);
  69925. var b = parseInt(hex.substring(5, 7), 16);
  69926. var a = parseInt(hex.substring(7, 9), 16);
  69927. return Color4.FromInts(r, g, b, a);
  69928. };
  69929. /**
  69930. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  69931. * @param left defines the start value
  69932. * @param right defines the end value
  69933. * @param amount defines the gradient factor
  69934. * @returns a new Color4 object
  69935. */
  69936. Color4.Lerp = function (left, right, amount) {
  69937. var result = new Color4(0.0, 0.0, 0.0, 0.0);
  69938. Color4.LerpToRef(left, right, amount, result);
  69939. return result;
  69940. };
  69941. /**
  69942. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  69943. * @param left defines the start value
  69944. * @param right defines the end value
  69945. * @param amount defines the gradient factor
  69946. * @param result defines the Color4 object where to store data
  69947. */
  69948. Color4.LerpToRef = function (left, right, amount, result) {
  69949. result.r = left.r + (right.r - left.r) * amount;
  69950. result.g = left.g + (right.g - left.g) * amount;
  69951. result.b = left.b + (right.b - left.b) * amount;
  69952. result.a = left.a + (right.a - left.a) * amount;
  69953. };
  69954. /**
  69955. * Creates a new Color4 from a Color3 and an alpha value
  69956. * @param color3 defines the source Color3 to read from
  69957. * @param alpha defines the alpha component (1.0 by default)
  69958. * @returns a new Color4 object
  69959. */
  69960. Color4.FromColor3 = function (color3, alpha) {
  69961. if (alpha === void 0) { alpha = 1.0; }
  69962. return new Color4(color3.r, color3.g, color3.b, alpha);
  69963. };
  69964. /**
  69965. * Creates a new Color4 from the starting index element of the given array
  69966. * @param array defines the source array to read from
  69967. * @param offset defines the offset in the source array
  69968. * @returns a new Color4 object
  69969. */
  69970. Color4.FromArray = function (array, offset) {
  69971. if (offset === void 0) { offset = 0; }
  69972. return new Color4(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  69973. };
  69974. /**
  69975. * Creates a new Color3 from integer values (< 256)
  69976. * @param r defines the red component to read from (value between 0 and 255)
  69977. * @param g defines the green component to read from (value between 0 and 255)
  69978. * @param b defines the blue component to read from (value between 0 and 255)
  69979. * @param a defines the alpha component to read from (value between 0 and 255)
  69980. * @returns a new Color3 object
  69981. */
  69982. Color4.FromInts = function (r, g, b, a) {
  69983. return new Color4(r / 255.0, g / 255.0, b / 255.0, a / 255.0);
  69984. };
  69985. /**
  69986. * Check the content of a given array and convert it to an array containing RGBA data
  69987. * If the original array was already containing count * 4 values then it is returned directly
  69988. * @param colors defines the array to check
  69989. * @param count defines the number of RGBA data to expect
  69990. * @returns an array containing count * 4 values (RGBA)
  69991. */
  69992. Color4.CheckColors4 = function (colors, count) {
  69993. // Check if color3 was used
  69994. if (colors.length === count * 3) {
  69995. var colors4 = [];
  69996. for (var index = 0; index < colors.length; index += 3) {
  69997. var newIndex = (index / 3) * 4;
  69998. colors4[newIndex] = colors[index];
  69999. colors4[newIndex + 1] = colors[index + 1];
  70000. colors4[newIndex + 2] = colors[index + 2];
  70001. colors4[newIndex + 3] = 1.0;
  70002. }
  70003. return colors4;
  70004. }
  70005. return colors;
  70006. };
  70007. return Color4;
  70008. }());
  70009. /**
  70010. * Class representing a vector containing 2 coordinates
  70011. */
  70012. var Vector2 = /** @class */ (function () {
  70013. /**
  70014. * Creates a new Vector2 from the given x and y coordinates
  70015. * @param x defines the first coordinate
  70016. * @param y defines the second coordinate
  70017. */
  70018. function Vector2(
  70019. /** defines the first coordinate */
  70020. x,
  70021. /** defines the second coordinate */
  70022. y) {
  70023. if (x === void 0) { x = 0; }
  70024. if (y === void 0) { y = 0; }
  70025. this.x = x;
  70026. this.y = y;
  70027. }
  70028. /**
  70029. * Gets a string with the Vector2 coordinates
  70030. * @returns a string with the Vector2 coordinates
  70031. */
  70032. Vector2.prototype.toString = function () {
  70033. return "{X: " + this.x + " Y:" + this.y + "}";
  70034. };
  70035. /**
  70036. * Gets class name
  70037. * @returns the string "Vector2"
  70038. */
  70039. Vector2.prototype.getClassName = function () {
  70040. return "Vector2";
  70041. };
  70042. /**
  70043. * Gets current vector hash code
  70044. * @returns the Vector2 hash code as a number
  70045. */
  70046. Vector2.prototype.getHashCode = function () {
  70047. var hash = this.x || 0;
  70048. hash = (hash * 397) ^ (this.y || 0);
  70049. return hash;
  70050. };
  70051. // Operators
  70052. /**
  70053. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  70054. * @param array defines the source array
  70055. * @param index defines the offset in source array
  70056. * @returns the current Vector2
  70057. */
  70058. Vector2.prototype.toArray = function (array, index) {
  70059. if (index === void 0) { index = 0; }
  70060. array[index] = this.x;
  70061. array[index + 1] = this.y;
  70062. return this;
  70063. };
  70064. /**
  70065. * Copy the current vector to an array
  70066. * @returns a new array with 2 elements: the Vector2 coordinates.
  70067. */
  70068. Vector2.prototype.asArray = function () {
  70069. var result = new Array();
  70070. this.toArray(result, 0);
  70071. return result;
  70072. };
  70073. /**
  70074. * Sets the Vector2 coordinates with the given Vector2 coordinates
  70075. * @param source defines the source Vector2
  70076. * @returns the current updated Vector2
  70077. */
  70078. Vector2.prototype.copyFrom = function (source) {
  70079. this.x = source.x;
  70080. this.y = source.y;
  70081. return this;
  70082. };
  70083. /**
  70084. * Sets the Vector2 coordinates with the given floats
  70085. * @param x defines the first coordinate
  70086. * @param y defines the second coordinate
  70087. * @returns the current updated Vector2
  70088. */
  70089. Vector2.prototype.copyFromFloats = function (x, y) {
  70090. this.x = x;
  70091. this.y = y;
  70092. return this;
  70093. };
  70094. /**
  70095. * Sets the Vector2 coordinates with the given floats
  70096. * @param x defines the first coordinate
  70097. * @param y defines the second coordinate
  70098. * @returns the current updated Vector2
  70099. */
  70100. Vector2.prototype.set = function (x, y) {
  70101. return this.copyFromFloats(x, y);
  70102. };
  70103. /**
  70104. * Add another vector with the current one
  70105. * @param otherVector defines the other vector
  70106. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  70107. */
  70108. Vector2.prototype.add = function (otherVector) {
  70109. return new Vector2(this.x + otherVector.x, this.y + otherVector.y);
  70110. };
  70111. /**
  70112. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  70113. * @param otherVector defines the other vector
  70114. * @param result defines the target vector
  70115. * @returns the unmodified current Vector2
  70116. */
  70117. Vector2.prototype.addToRef = function (otherVector, result) {
  70118. result.x = this.x + otherVector.x;
  70119. result.y = this.y + otherVector.y;
  70120. return this;
  70121. };
  70122. /**
  70123. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  70124. * @param otherVector defines the other vector
  70125. * @returns the current updated Vector2
  70126. */
  70127. Vector2.prototype.addInPlace = function (otherVector) {
  70128. this.x += otherVector.x;
  70129. this.y += otherVector.y;
  70130. return this;
  70131. };
  70132. /**
  70133. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  70134. * @param otherVector defines the other vector
  70135. * @returns a new Vector2
  70136. */
  70137. Vector2.prototype.addVector3 = function (otherVector) {
  70138. return new Vector2(this.x + otherVector.x, this.y + otherVector.y);
  70139. };
  70140. /**
  70141. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  70142. * @param otherVector defines the other vector
  70143. * @returns a new Vector2
  70144. */
  70145. Vector2.prototype.subtract = function (otherVector) {
  70146. return new Vector2(this.x - otherVector.x, this.y - otherVector.y);
  70147. };
  70148. /**
  70149. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  70150. * @param otherVector defines the other vector
  70151. * @param result defines the target vector
  70152. * @returns the unmodified current Vector2
  70153. */
  70154. Vector2.prototype.subtractToRef = function (otherVector, result) {
  70155. result.x = this.x - otherVector.x;
  70156. result.y = this.y - otherVector.y;
  70157. return this;
  70158. };
  70159. /**
  70160. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  70161. * @param otherVector defines the other vector
  70162. * @returns the current updated Vector2
  70163. */
  70164. Vector2.prototype.subtractInPlace = function (otherVector) {
  70165. this.x -= otherVector.x;
  70166. this.y -= otherVector.y;
  70167. return this;
  70168. };
  70169. /**
  70170. * Multiplies in place the current Vector2 coordinates by the given ones
  70171. * @param otherVector defines the other vector
  70172. * @returns the current updated Vector2
  70173. */
  70174. Vector2.prototype.multiplyInPlace = function (otherVector) {
  70175. this.x *= otherVector.x;
  70176. this.y *= otherVector.y;
  70177. return this;
  70178. };
  70179. /**
  70180. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  70181. * @param otherVector defines the other vector
  70182. * @returns a new Vector2
  70183. */
  70184. Vector2.prototype.multiply = function (otherVector) {
  70185. return new Vector2(this.x * otherVector.x, this.y * otherVector.y);
  70186. };
  70187. /**
  70188. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  70189. * @param otherVector defines the other vector
  70190. * @param result defines the target vector
  70191. * @returns the unmodified current Vector2
  70192. */
  70193. Vector2.prototype.multiplyToRef = function (otherVector, result) {
  70194. result.x = this.x * otherVector.x;
  70195. result.y = this.y * otherVector.y;
  70196. return this;
  70197. };
  70198. /**
  70199. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  70200. * @param x defines the first coordinate
  70201. * @param y defines the second coordinate
  70202. * @returns a new Vector2
  70203. */
  70204. Vector2.prototype.multiplyByFloats = function (x, y) {
  70205. return new Vector2(this.x * x, this.y * y);
  70206. };
  70207. /**
  70208. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  70209. * @param otherVector defines the other vector
  70210. * @returns a new Vector2
  70211. */
  70212. Vector2.prototype.divide = function (otherVector) {
  70213. return new Vector2(this.x / otherVector.x, this.y / otherVector.y);
  70214. };
  70215. /**
  70216. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  70217. * @param otherVector defines the other vector
  70218. * @param result defines the target vector
  70219. * @returns the unmodified current Vector2
  70220. */
  70221. Vector2.prototype.divideToRef = function (otherVector, result) {
  70222. result.x = this.x / otherVector.x;
  70223. result.y = this.y / otherVector.y;
  70224. return this;
  70225. };
  70226. /**
  70227. * Divides the current Vector2 coordinates by the given ones
  70228. * @param otherVector defines the other vector
  70229. * @returns the current updated Vector2
  70230. */
  70231. Vector2.prototype.divideInPlace = function (otherVector) {
  70232. return this.divideToRef(otherVector, this);
  70233. };
  70234. /**
  70235. * Gets a new Vector2 with current Vector2 negated coordinates
  70236. * @returns a new Vector2
  70237. */
  70238. Vector2.prototype.negate = function () {
  70239. return new Vector2(-this.x, -this.y);
  70240. };
  70241. /**
  70242. * Multiply the Vector2 coordinates by scale
  70243. * @param scale defines the scaling factor
  70244. * @returns the current updated Vector2
  70245. */
  70246. Vector2.prototype.scaleInPlace = function (scale) {
  70247. this.x *= scale;
  70248. this.y *= scale;
  70249. return this;
  70250. };
  70251. /**
  70252. * Returns a new Vector2 scaled by "scale" from the current Vector2
  70253. * @param scale defines the scaling factor
  70254. * @returns a new Vector2
  70255. */
  70256. Vector2.prototype.scale = function (scale) {
  70257. var result = new Vector2(0, 0);
  70258. this.scaleToRef(scale, result);
  70259. return result;
  70260. };
  70261. /**
  70262. * Scale the current Vector2 values by a factor to a given Vector2
  70263. * @param scale defines the scale factor
  70264. * @param result defines the Vector2 object where to store the result
  70265. * @returns the unmodified current Vector2
  70266. */
  70267. Vector2.prototype.scaleToRef = function (scale, result) {
  70268. result.x = this.x * scale;
  70269. result.y = this.y * scale;
  70270. return this;
  70271. };
  70272. /**
  70273. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  70274. * @param scale defines the scale factor
  70275. * @param result defines the Vector2 object where to store the result
  70276. * @returns the unmodified current Vector2
  70277. */
  70278. Vector2.prototype.scaleAndAddToRef = function (scale, result) {
  70279. result.x += this.x * scale;
  70280. result.y += this.y * scale;
  70281. return this;
  70282. };
  70283. /**
  70284. * Gets a boolean if two vectors are equals
  70285. * @param otherVector defines the other vector
  70286. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  70287. */
  70288. Vector2.prototype.equals = function (otherVector) {
  70289. return otherVector && this.x === otherVector.x && this.y === otherVector.y;
  70290. };
  70291. /**
  70292. * Gets a boolean if two vectors are equals (using an epsilon value)
  70293. * @param otherVector defines the other vector
  70294. * @param epsilon defines the minimal distance to consider equality
  70295. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  70296. */
  70297. Vector2.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  70298. if (epsilon === void 0) { epsilon = Epsilon; }
  70299. 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);
  70300. };
  70301. /**
  70302. * Gets a new Vector2 from current Vector2 floored values
  70303. * @returns a new Vector2
  70304. */
  70305. Vector2.prototype.floor = function () {
  70306. return new Vector2(Math.floor(this.x), Math.floor(this.y));
  70307. };
  70308. /**
  70309. * Gets a new Vector2 from current Vector2 floored values
  70310. * @returns a new Vector2
  70311. */
  70312. Vector2.prototype.fract = function () {
  70313. return new Vector2(this.x - Math.floor(this.x), this.y - Math.floor(this.y));
  70314. };
  70315. // Properties
  70316. /**
  70317. * Gets the length of the vector
  70318. * @returns the vector length (float)
  70319. */
  70320. Vector2.prototype.length = function () {
  70321. return Math.sqrt(this.x * this.x + this.y * this.y);
  70322. };
  70323. /**
  70324. * Gets the vector squared length
  70325. * @returns the vector squared length (float)
  70326. */
  70327. Vector2.prototype.lengthSquared = function () {
  70328. return (this.x * this.x + this.y * this.y);
  70329. };
  70330. // Methods
  70331. /**
  70332. * Normalize the vector
  70333. * @returns the current updated Vector2
  70334. */
  70335. Vector2.prototype.normalize = function () {
  70336. var len = this.length();
  70337. if (len === 0) {
  70338. return this;
  70339. }
  70340. var num = 1.0 / len;
  70341. this.x *= num;
  70342. this.y *= num;
  70343. return this;
  70344. };
  70345. /**
  70346. * Gets a new Vector2 copied from the Vector2
  70347. * @returns a new Vector2
  70348. */
  70349. Vector2.prototype.clone = function () {
  70350. return new Vector2(this.x, this.y);
  70351. };
  70352. // Statics
  70353. /**
  70354. * Gets a new Vector2(0, 0)
  70355. * @returns a new Vector2
  70356. */
  70357. Vector2.Zero = function () {
  70358. return new Vector2(0, 0);
  70359. };
  70360. /**
  70361. * Gets a new Vector2(1, 1)
  70362. * @returns a new Vector2
  70363. */
  70364. Vector2.One = function () {
  70365. return new Vector2(1, 1);
  70366. };
  70367. /**
  70368. * Gets a new Vector2 set from the given index element of the given array
  70369. * @param array defines the data source
  70370. * @param offset defines the offset in the data source
  70371. * @returns a new Vector2
  70372. */
  70373. Vector2.FromArray = function (array, offset) {
  70374. if (offset === void 0) { offset = 0; }
  70375. return new Vector2(array[offset], array[offset + 1]);
  70376. };
  70377. /**
  70378. * Sets "result" from the given index element of the given array
  70379. * @param array defines the data source
  70380. * @param offset defines the offset in the data source
  70381. * @param result defines the target vector
  70382. */
  70383. Vector2.FromArrayToRef = function (array, offset, result) {
  70384. result.x = array[offset];
  70385. result.y = array[offset + 1];
  70386. };
  70387. /**
  70388. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  70389. * @param value1 defines 1st point of control
  70390. * @param value2 defines 2nd point of control
  70391. * @param value3 defines 3rd point of control
  70392. * @param value4 defines 4th point of control
  70393. * @param amount defines the interpolation factor
  70394. * @returns a new Vector2
  70395. */
  70396. Vector2.CatmullRom = function (value1, value2, value3, value4, amount) {
  70397. var squared = amount * amount;
  70398. var cubed = amount * squared;
  70399. var x = 0.5 * ((((2.0 * value2.x) + ((-value1.x + value3.x) * amount)) +
  70400. (((((2.0 * value1.x) - (5.0 * value2.x)) + (4.0 * value3.x)) - value4.x) * squared)) +
  70401. ((((-value1.x + (3.0 * value2.x)) - (3.0 * value3.x)) + value4.x) * cubed));
  70402. var y = 0.5 * ((((2.0 * value2.y) + ((-value1.y + value3.y) * amount)) +
  70403. (((((2.0 * value1.y) - (5.0 * value2.y)) + (4.0 * value3.y)) - value4.y) * squared)) +
  70404. ((((-value1.y + (3.0 * value2.y)) - (3.0 * value3.y)) + value4.y) * cubed));
  70405. return new Vector2(x, y);
  70406. };
  70407. /**
  70408. * 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".
  70409. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  70410. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  70411. * @param value defines the value to clamp
  70412. * @param min defines the lower limit
  70413. * @param max defines the upper limit
  70414. * @returns a new Vector2
  70415. */
  70416. Vector2.Clamp = function (value, min, max) {
  70417. var x = value.x;
  70418. x = (x > max.x) ? max.x : x;
  70419. x = (x < min.x) ? min.x : x;
  70420. var y = value.y;
  70421. y = (y > max.y) ? max.y : y;
  70422. y = (y < min.y) ? min.y : y;
  70423. return new Vector2(x, y);
  70424. };
  70425. /**
  70426. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  70427. * @param value1 defines the 1st control point
  70428. * @param tangent1 defines the outgoing tangent
  70429. * @param value2 defines the 2nd control point
  70430. * @param tangent2 defines the incoming tangent
  70431. * @param amount defines the interpolation factor
  70432. * @returns a new Vector2
  70433. */
  70434. Vector2.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  70435. var squared = amount * amount;
  70436. var cubed = amount * squared;
  70437. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  70438. var part2 = (-2.0 * cubed) + (3.0 * squared);
  70439. var part3 = (cubed - (2.0 * squared)) + amount;
  70440. var part4 = cubed - squared;
  70441. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  70442. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  70443. return new Vector2(x, y);
  70444. };
  70445. /**
  70446. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  70447. * @param start defines the start vector
  70448. * @param end defines the end vector
  70449. * @param amount defines the interpolation factor
  70450. * @returns a new Vector2
  70451. */
  70452. Vector2.Lerp = function (start, end, amount) {
  70453. var x = start.x + ((end.x - start.x) * amount);
  70454. var y = start.y + ((end.y - start.y) * amount);
  70455. return new Vector2(x, y);
  70456. };
  70457. /**
  70458. * Gets the dot product of the vector "left" and the vector "right"
  70459. * @param left defines first vector
  70460. * @param right defines second vector
  70461. * @returns the dot product (float)
  70462. */
  70463. Vector2.Dot = function (left, right) {
  70464. return left.x * right.x + left.y * right.y;
  70465. };
  70466. /**
  70467. * Returns a new Vector2 equal to the normalized given vector
  70468. * @param vector defines the vector to normalize
  70469. * @returns a new Vector2
  70470. */
  70471. Vector2.Normalize = function (vector) {
  70472. var newVector = vector.clone();
  70473. newVector.normalize();
  70474. return newVector;
  70475. };
  70476. /**
  70477. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  70478. * @param left defines 1st vector
  70479. * @param right defines 2nd vector
  70480. * @returns a new Vector2
  70481. */
  70482. Vector2.Minimize = function (left, right) {
  70483. var x = (left.x < right.x) ? left.x : right.x;
  70484. var y = (left.y < right.y) ? left.y : right.y;
  70485. return new Vector2(x, y);
  70486. };
  70487. /**
  70488. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  70489. * @param left defines 1st vector
  70490. * @param right defines 2nd vector
  70491. * @returns a new Vector2
  70492. */
  70493. Vector2.Maximize = function (left, right) {
  70494. var x = (left.x > right.x) ? left.x : right.x;
  70495. var y = (left.y > right.y) ? left.y : right.y;
  70496. return new Vector2(x, y);
  70497. };
  70498. /**
  70499. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  70500. * @param vector defines the vector to transform
  70501. * @param transformation defines the matrix to apply
  70502. * @returns a new Vector2
  70503. */
  70504. Vector2.Transform = function (vector, transformation) {
  70505. var r = Vector2.Zero();
  70506. Vector2.TransformToRef(vector, transformation, r);
  70507. return r;
  70508. };
  70509. /**
  70510. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  70511. * @param vector defines the vector to transform
  70512. * @param transformation defines the matrix to apply
  70513. * @param result defines the target vector
  70514. */
  70515. Vector2.TransformToRef = function (vector, transformation, result) {
  70516. var m = transformation.m;
  70517. var x = (vector.x * m[0]) + (vector.y * m[4]) + m[12];
  70518. var y = (vector.x * m[1]) + (vector.y * m[5]) + m[13];
  70519. result.x = x;
  70520. result.y = y;
  70521. };
  70522. /**
  70523. * Determines if a given vector is included in a triangle
  70524. * @param p defines the vector to test
  70525. * @param p0 defines 1st triangle point
  70526. * @param p1 defines 2nd triangle point
  70527. * @param p2 defines 3rd triangle point
  70528. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  70529. */
  70530. Vector2.PointInTriangle = function (p, p0, p1, p2) {
  70531. var a = 1 / 2 * (-p1.y * p2.x + p0.y * (-p1.x + p2.x) + p0.x * (p1.y - p2.y) + p1.x * p2.y);
  70532. var sign = a < 0 ? -1 : 1;
  70533. var s = (p0.y * p2.x - p0.x * p2.y + (p2.y - p0.y) * p.x + (p0.x - p2.x) * p.y) * sign;
  70534. var t = (p0.x * p1.y - p0.y * p1.x + (p0.y - p1.y) * p.x + (p1.x - p0.x) * p.y) * sign;
  70535. return s > 0 && t > 0 && (s + t) < 2 * a * sign;
  70536. };
  70537. /**
  70538. * Gets the distance between the vectors "value1" and "value2"
  70539. * @param value1 defines first vector
  70540. * @param value2 defines second vector
  70541. * @returns the distance between vectors
  70542. */
  70543. Vector2.Distance = function (value1, value2) {
  70544. return Math.sqrt(Vector2.DistanceSquared(value1, value2));
  70545. };
  70546. /**
  70547. * Returns the squared distance between the vectors "value1" and "value2"
  70548. * @param value1 defines first vector
  70549. * @param value2 defines second vector
  70550. * @returns the squared distance between vectors
  70551. */
  70552. Vector2.DistanceSquared = function (value1, value2) {
  70553. var x = value1.x - value2.x;
  70554. var y = value1.y - value2.y;
  70555. return (x * x) + (y * y);
  70556. };
  70557. /**
  70558. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  70559. * @param value1 defines first vector
  70560. * @param value2 defines second vector
  70561. * @returns a new Vector2
  70562. */
  70563. Vector2.Center = function (value1, value2) {
  70564. var center = value1.add(value2);
  70565. center.scaleInPlace(0.5);
  70566. return center;
  70567. };
  70568. /**
  70569. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  70570. * @param p defines the middle point
  70571. * @param segA defines one point of the segment
  70572. * @param segB defines the other point of the segment
  70573. * @returns the shortest distance
  70574. */
  70575. Vector2.DistanceOfPointFromSegment = function (p, segA, segB) {
  70576. var l2 = Vector2.DistanceSquared(segA, segB);
  70577. if (l2 === 0.0) {
  70578. return Vector2.Distance(p, segA);
  70579. }
  70580. var v = segB.subtract(segA);
  70581. var t = Math.max(0, Math.min(1, Vector2.Dot(p.subtract(segA), v) / l2));
  70582. var proj = segA.add(v.multiplyByFloats(t, t));
  70583. return Vector2.Distance(p, proj);
  70584. };
  70585. return Vector2;
  70586. }());
  70587. /**
  70588. * Classed used to store (x,y,z) vector representation
  70589. * A Vector3 is the main object used in 3D geometry
  70590. * It can represent etiher the coordinates of a point the space, either a direction
  70591. * Reminder: js uses a left handed forward facing system
  70592. */
  70593. var Vector3 = /** @class */ (function () {
  70594. /**
  70595. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  70596. * @param x defines the first coordinates (on X axis)
  70597. * @param y defines the second coordinates (on Y axis)
  70598. * @param z defines the third coordinates (on Z axis)
  70599. */
  70600. function Vector3(
  70601. /**
  70602. * Defines the first coordinates (on X axis)
  70603. */
  70604. x,
  70605. /**
  70606. * Defines the second coordinates (on Y axis)
  70607. */
  70608. y,
  70609. /**
  70610. * Defines the third coordinates (on Z axis)
  70611. */
  70612. z) {
  70613. if (x === void 0) { x = 0; }
  70614. if (y === void 0) { y = 0; }
  70615. if (z === void 0) { z = 0; }
  70616. this.x = x;
  70617. this.y = y;
  70618. this.z = z;
  70619. }
  70620. /**
  70621. * Creates a string representation of the Vector3
  70622. * @returns a string with the Vector3 coordinates.
  70623. */
  70624. Vector3.prototype.toString = function () {
  70625. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + "}";
  70626. };
  70627. /**
  70628. * Gets the class name
  70629. * @returns the string "Vector3"
  70630. */
  70631. Vector3.prototype.getClassName = function () {
  70632. return "Vector3";
  70633. };
  70634. /**
  70635. * Creates the Vector3 hash code
  70636. * @returns a number which tends to be unique between Vector3 instances
  70637. */
  70638. Vector3.prototype.getHashCode = function () {
  70639. var hash = this.x || 0;
  70640. hash = (hash * 397) ^ (this.y || 0);
  70641. hash = (hash * 397) ^ (this.z || 0);
  70642. return hash;
  70643. };
  70644. // Operators
  70645. /**
  70646. * Creates an array containing three elements : the coordinates of the Vector3
  70647. * @returns a new array of numbers
  70648. */
  70649. Vector3.prototype.asArray = function () {
  70650. var result = [];
  70651. this.toArray(result, 0);
  70652. return result;
  70653. };
  70654. /**
  70655. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  70656. * @param array defines the destination array
  70657. * @param index defines the offset in the destination array
  70658. * @returns the current Vector3
  70659. */
  70660. Vector3.prototype.toArray = function (array, index) {
  70661. if (index === void 0) { index = 0; }
  70662. array[index] = this.x;
  70663. array[index + 1] = this.y;
  70664. array[index + 2] = this.z;
  70665. return this;
  70666. };
  70667. /**
  70668. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  70669. * @returns a new Quaternion object, computed from the Vector3 coordinates
  70670. */
  70671. Vector3.prototype.toQuaternion = function () {
  70672. return Quaternion.RotationYawPitchRoll(this.y, this.x, this.z);
  70673. };
  70674. /**
  70675. * Adds the given vector to the current Vector3
  70676. * @param otherVector defines the second operand
  70677. * @returns the current updated Vector3
  70678. */
  70679. Vector3.prototype.addInPlace = function (otherVector) {
  70680. return this.addInPlaceFromFloats(otherVector.x, otherVector.y, otherVector.z);
  70681. };
  70682. /**
  70683. * Adds the given coordinates to the current Vector3
  70684. * @param x defines the x coordinate of the operand
  70685. * @param y defines the y coordinate of the operand
  70686. * @param z defines the z coordinate of the operand
  70687. * @returns the current updated Vector3
  70688. */
  70689. Vector3.prototype.addInPlaceFromFloats = function (x, y, z) {
  70690. this.x += x;
  70691. this.y += y;
  70692. this.z += z;
  70693. return this;
  70694. };
  70695. /**
  70696. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  70697. * @param otherVector defines the second operand
  70698. * @returns the resulting Vector3
  70699. */
  70700. Vector3.prototype.add = function (otherVector) {
  70701. return new Vector3(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z);
  70702. };
  70703. /**
  70704. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  70705. * @param otherVector defines the second operand
  70706. * @param result defines the Vector3 object where to store the result
  70707. * @returns the current Vector3
  70708. */
  70709. Vector3.prototype.addToRef = function (otherVector, result) {
  70710. return result.copyFromFloats(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z);
  70711. };
  70712. /**
  70713. * Subtract the given vector from the current Vector3
  70714. * @param otherVector defines the second operand
  70715. * @returns the current updated Vector3
  70716. */
  70717. Vector3.prototype.subtractInPlace = function (otherVector) {
  70718. this.x -= otherVector.x;
  70719. this.y -= otherVector.y;
  70720. this.z -= otherVector.z;
  70721. return this;
  70722. };
  70723. /**
  70724. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  70725. * @param otherVector defines the second operand
  70726. * @returns the resulting Vector3
  70727. */
  70728. Vector3.prototype.subtract = function (otherVector) {
  70729. return new Vector3(this.x - otherVector.x, this.y - otherVector.y, this.z - otherVector.z);
  70730. };
  70731. /**
  70732. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  70733. * @param otherVector defines the second operand
  70734. * @param result defines the Vector3 object where to store the result
  70735. * @returns the current Vector3
  70736. */
  70737. Vector3.prototype.subtractToRef = function (otherVector, result) {
  70738. return this.subtractFromFloatsToRef(otherVector.x, otherVector.y, otherVector.z, result);
  70739. };
  70740. /**
  70741. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  70742. * @param x defines the x coordinate of the operand
  70743. * @param y defines the y coordinate of the operand
  70744. * @param z defines the z coordinate of the operand
  70745. * @returns the resulting Vector3
  70746. */
  70747. Vector3.prototype.subtractFromFloats = function (x, y, z) {
  70748. return new Vector3(this.x - x, this.y - y, this.z - z);
  70749. };
  70750. /**
  70751. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  70752. * @param x defines the x coordinate of the operand
  70753. * @param y defines the y coordinate of the operand
  70754. * @param z defines the z coordinate of the operand
  70755. * @param result defines the Vector3 object where to store the result
  70756. * @returns the current Vector3
  70757. */
  70758. Vector3.prototype.subtractFromFloatsToRef = function (x, y, z, result) {
  70759. return result.copyFromFloats(this.x - x, this.y - y, this.z - z);
  70760. };
  70761. /**
  70762. * Gets a new Vector3 set with the current Vector3 negated coordinates
  70763. * @returns a new Vector3
  70764. */
  70765. Vector3.prototype.negate = function () {
  70766. return new Vector3(-this.x, -this.y, -this.z);
  70767. };
  70768. /**
  70769. * Multiplies the Vector3 coordinates by the float "scale"
  70770. * @param scale defines the multiplier factor
  70771. * @returns the current updated Vector3
  70772. */
  70773. Vector3.prototype.scaleInPlace = function (scale) {
  70774. this.x *= scale;
  70775. this.y *= scale;
  70776. this.z *= scale;
  70777. return this;
  70778. };
  70779. /**
  70780. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  70781. * @param scale defines the multiplier factor
  70782. * @returns a new Vector3
  70783. */
  70784. Vector3.prototype.scale = function (scale) {
  70785. return new Vector3(this.x * scale, this.y * scale, this.z * scale);
  70786. };
  70787. /**
  70788. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  70789. * @param scale defines the multiplier factor
  70790. * @param result defines the Vector3 object where to store the result
  70791. * @returns the current Vector3
  70792. */
  70793. Vector3.prototype.scaleToRef = function (scale, result) {
  70794. return result.copyFromFloats(this.x * scale, this.y * scale, this.z * scale);
  70795. };
  70796. /**
  70797. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  70798. * @param scale defines the scale factor
  70799. * @param result defines the Vector3 object where to store the result
  70800. * @returns the unmodified current Vector3
  70801. */
  70802. Vector3.prototype.scaleAndAddToRef = function (scale, result) {
  70803. return result.addInPlaceFromFloats(this.x * scale, this.y * scale, this.z * scale);
  70804. };
  70805. /**
  70806. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  70807. * @param otherVector defines the second operand
  70808. * @returns true if both vectors are equals
  70809. */
  70810. Vector3.prototype.equals = function (otherVector) {
  70811. return otherVector && this.x === otherVector.x && this.y === otherVector.y && this.z === otherVector.z;
  70812. };
  70813. /**
  70814. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  70815. * @param otherVector defines the second operand
  70816. * @param epsilon defines the minimal distance to define values as equals
  70817. * @returns true if both vectors are distant less than epsilon
  70818. */
  70819. Vector3.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  70820. if (epsilon === void 0) { epsilon = Epsilon; }
  70821. 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);
  70822. };
  70823. /**
  70824. * Returns true if the current Vector3 coordinates equals the given floats
  70825. * @param x defines the x coordinate of the operand
  70826. * @param y defines the y coordinate of the operand
  70827. * @param z defines the z coordinate of the operand
  70828. * @returns true if both vectors are equals
  70829. */
  70830. Vector3.prototype.equalsToFloats = function (x, y, z) {
  70831. return this.x === x && this.y === y && this.z === z;
  70832. };
  70833. /**
  70834. * Multiplies the current Vector3 coordinates by the given ones
  70835. * @param otherVector defines the second operand
  70836. * @returns the current updated Vector3
  70837. */
  70838. Vector3.prototype.multiplyInPlace = function (otherVector) {
  70839. this.x *= otherVector.x;
  70840. this.y *= otherVector.y;
  70841. this.z *= otherVector.z;
  70842. return this;
  70843. };
  70844. /**
  70845. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  70846. * @param otherVector defines the second operand
  70847. * @returns the new Vector3
  70848. */
  70849. Vector3.prototype.multiply = function (otherVector) {
  70850. return this.multiplyByFloats(otherVector.x, otherVector.y, otherVector.z);
  70851. };
  70852. /**
  70853. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  70854. * @param otherVector defines the second operand
  70855. * @param result defines the Vector3 object where to store the result
  70856. * @returns the current Vector3
  70857. */
  70858. Vector3.prototype.multiplyToRef = function (otherVector, result) {
  70859. return result.copyFromFloats(this.x * otherVector.x, this.y * otherVector.y, this.z * otherVector.z);
  70860. };
  70861. /**
  70862. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  70863. * @param x defines the x coordinate of the operand
  70864. * @param y defines the y coordinate of the operand
  70865. * @param z defines the z coordinate of the operand
  70866. * @returns the new Vector3
  70867. */
  70868. Vector3.prototype.multiplyByFloats = function (x, y, z) {
  70869. return new Vector3(this.x * x, this.y * y, this.z * z);
  70870. };
  70871. /**
  70872. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  70873. * @param otherVector defines the second operand
  70874. * @returns the new Vector3
  70875. */
  70876. Vector3.prototype.divide = function (otherVector) {
  70877. return new Vector3(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z);
  70878. };
  70879. /**
  70880. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  70881. * @param otherVector defines the second operand
  70882. * @param result defines the Vector3 object where to store the result
  70883. * @returns the current Vector3
  70884. */
  70885. Vector3.prototype.divideToRef = function (otherVector, result) {
  70886. return result.copyFromFloats(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z);
  70887. };
  70888. /**
  70889. * Divides the current Vector3 coordinates by the given ones.
  70890. * @param otherVector defines the second operand
  70891. * @returns the current updated Vector3
  70892. */
  70893. Vector3.prototype.divideInPlace = function (otherVector) {
  70894. return this.divideToRef(otherVector, this);
  70895. };
  70896. /**
  70897. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  70898. * @param other defines the second operand
  70899. * @returns the current updated Vector3
  70900. */
  70901. Vector3.prototype.minimizeInPlace = function (other) {
  70902. return this.minimizeInPlaceFromFloats(other.x, other.y, other.z);
  70903. };
  70904. /**
  70905. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  70906. * @param other defines the second operand
  70907. * @returns the current updated Vector3
  70908. */
  70909. Vector3.prototype.maximizeInPlace = function (other) {
  70910. return this.maximizeInPlaceFromFloats(other.x, other.y, other.z);
  70911. };
  70912. /**
  70913. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  70914. * @param x defines the x coordinate of the operand
  70915. * @param y defines the y coordinate of the operand
  70916. * @param z defines the z coordinate of the operand
  70917. * @returns the current updated Vector3
  70918. */
  70919. Vector3.prototype.minimizeInPlaceFromFloats = function (x, y, z) {
  70920. if (x < this.x) {
  70921. this.x = x;
  70922. }
  70923. if (y < this.y) {
  70924. this.y = y;
  70925. }
  70926. if (z < this.z) {
  70927. this.z = z;
  70928. }
  70929. return this;
  70930. };
  70931. /**
  70932. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  70933. * @param x defines the x coordinate of the operand
  70934. * @param y defines the y coordinate of the operand
  70935. * @param z defines the z coordinate of the operand
  70936. * @returns the current updated Vector3
  70937. */
  70938. Vector3.prototype.maximizeInPlaceFromFloats = function (x, y, z) {
  70939. if (x > this.x) {
  70940. this.x = x;
  70941. }
  70942. if (y > this.y) {
  70943. this.y = y;
  70944. }
  70945. if (z > this.z) {
  70946. this.z = z;
  70947. }
  70948. return this;
  70949. };
  70950. /**
  70951. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  70952. * Check if is non uniform within a certain amount of decimal places to account for this
  70953. * @param epsilon the amount the values can differ
  70954. * @returns if the the vector is non uniform to a certain number of decimal places
  70955. */
  70956. Vector3.prototype.isNonUniformWithinEpsilon = function (epsilon) {
  70957. var absX = Math.abs(this.x);
  70958. var absY = Math.abs(this.y);
  70959. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absX, absY, epsilon)) {
  70960. return true;
  70961. }
  70962. var absZ = Math.abs(this.z);
  70963. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absX, absZ, epsilon)) {
  70964. return true;
  70965. }
  70966. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absY, absZ, epsilon)) {
  70967. return true;
  70968. }
  70969. return false;
  70970. };
  70971. Object.defineProperty(Vector3.prototype, "isNonUniform", {
  70972. /**
  70973. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  70974. */
  70975. get: function () {
  70976. var absX = Math.abs(this.x);
  70977. var absY = Math.abs(this.y);
  70978. if (absX !== absY) {
  70979. return true;
  70980. }
  70981. var absZ = Math.abs(this.z);
  70982. if (absX !== absZ) {
  70983. return true;
  70984. }
  70985. if (absY !== absZ) {
  70986. return true;
  70987. }
  70988. return false;
  70989. },
  70990. enumerable: true,
  70991. configurable: true
  70992. });
  70993. /**
  70994. * Gets a new Vector3 from current Vector3 floored values
  70995. * @returns a new Vector3
  70996. */
  70997. Vector3.prototype.floor = function () {
  70998. return new Vector3(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z));
  70999. };
  71000. /**
  71001. * Gets a new Vector3 from current Vector3 floored values
  71002. * @returns a new Vector3
  71003. */
  71004. Vector3.prototype.fract = function () {
  71005. return new Vector3(this.x - Math.floor(this.x), this.y - Math.floor(this.y), this.z - Math.floor(this.z));
  71006. };
  71007. // Properties
  71008. /**
  71009. * Gets the length of the Vector3
  71010. * @returns the length of the Vecto3
  71011. */
  71012. Vector3.prototype.length = function () {
  71013. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
  71014. };
  71015. /**
  71016. * Gets the squared length of the Vector3
  71017. * @returns squared length of the Vector3
  71018. */
  71019. Vector3.prototype.lengthSquared = function () {
  71020. return (this.x * this.x + this.y * this.y + this.z * this.z);
  71021. };
  71022. /**
  71023. * Normalize the current Vector3.
  71024. * Please note that this is an in place operation.
  71025. * @returns the current updated Vector3
  71026. */
  71027. Vector3.prototype.normalize = function () {
  71028. return this.normalizeFromLength(this.length());
  71029. };
  71030. /**
  71031. * Reorders the x y z properties of the vector in place
  71032. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  71033. * @returns the current updated vector
  71034. */
  71035. Vector3.prototype.reorderInPlace = function (order) {
  71036. var _this = this;
  71037. order = order.toLowerCase();
  71038. if (order === "xyz") {
  71039. return this;
  71040. }
  71041. MathTmp.Vector3[0].copyFrom(this);
  71042. ["x", "y", "z"].forEach(function (val, i) {
  71043. _this[val] = MathTmp.Vector3[0][order[i]];
  71044. });
  71045. return this;
  71046. };
  71047. /**
  71048. * Rotates the vector around 0,0,0 by a quaternion
  71049. * @param quaternion the rotation quaternion
  71050. * @param result vector to store the result
  71051. * @returns the resulting vector
  71052. */
  71053. Vector3.prototype.rotateByQuaternionToRef = function (quaternion, result) {
  71054. quaternion.toRotationMatrix(MathTmp.Matrix[0]);
  71055. Vector3.TransformCoordinatesToRef(this, MathTmp.Matrix[0], result);
  71056. return result;
  71057. };
  71058. /**
  71059. * Rotates a vector around a given point
  71060. * @param quaternion the rotation quaternion
  71061. * @param point the point to rotate around
  71062. * @param result vector to store the result
  71063. * @returns the resulting vector
  71064. */
  71065. Vector3.prototype.rotateByQuaternionAroundPointToRef = function (quaternion, point, result) {
  71066. this.subtractToRef(point, MathTmp.Vector3[0]);
  71067. MathTmp.Vector3[0].rotateByQuaternionToRef(quaternion, MathTmp.Vector3[0]);
  71068. point.addToRef(MathTmp.Vector3[0], result);
  71069. return result;
  71070. };
  71071. /**
  71072. * Normalize the current Vector3 with the given input length.
  71073. * Please note that this is an in place operation.
  71074. * @param len the length of the vector
  71075. * @returns the current updated Vector3
  71076. */
  71077. Vector3.prototype.normalizeFromLength = function (len) {
  71078. if (len === 0 || len === 1.0) {
  71079. return this;
  71080. }
  71081. return this.scaleInPlace(1.0 / len);
  71082. };
  71083. /**
  71084. * Normalize the current Vector3 to a new vector
  71085. * @returns the new Vector3
  71086. */
  71087. Vector3.prototype.normalizeToNew = function () {
  71088. var normalized = new Vector3(0, 0, 0);
  71089. this.normalizeToRef(normalized);
  71090. return normalized;
  71091. };
  71092. /**
  71093. * Normalize the current Vector3 to the reference
  71094. * @param reference define the Vector3 to update
  71095. * @returns the updated Vector3
  71096. */
  71097. Vector3.prototype.normalizeToRef = function (reference) {
  71098. var len = this.length();
  71099. if (len === 0 || len === 1.0) {
  71100. return reference.copyFromFloats(this.x, this.y, this.z);
  71101. }
  71102. return this.scaleToRef(1.0 / len, reference);
  71103. };
  71104. /**
  71105. * Creates a new Vector3 copied from the current Vector3
  71106. * @returns the new Vector3
  71107. */
  71108. Vector3.prototype.clone = function () {
  71109. return new Vector3(this.x, this.y, this.z);
  71110. };
  71111. /**
  71112. * Copies the given vector coordinates to the current Vector3 ones
  71113. * @param source defines the source Vector3
  71114. * @returns the current updated Vector3
  71115. */
  71116. Vector3.prototype.copyFrom = function (source) {
  71117. return this.copyFromFloats(source.x, source.y, source.z);
  71118. };
  71119. /**
  71120. * Copies the given floats to the current Vector3 coordinates
  71121. * @param x defines the x coordinate of the operand
  71122. * @param y defines the y coordinate of the operand
  71123. * @param z defines the z coordinate of the operand
  71124. * @returns the current updated Vector3
  71125. */
  71126. Vector3.prototype.copyFromFloats = function (x, y, z) {
  71127. this.x = x;
  71128. this.y = y;
  71129. this.z = z;
  71130. return this;
  71131. };
  71132. /**
  71133. * Copies the given floats to the current Vector3 coordinates
  71134. * @param x defines the x coordinate of the operand
  71135. * @param y defines the y coordinate of the operand
  71136. * @param z defines the z coordinate of the operand
  71137. * @returns the current updated Vector3
  71138. */
  71139. Vector3.prototype.set = function (x, y, z) {
  71140. return this.copyFromFloats(x, y, z);
  71141. };
  71142. /**
  71143. * Copies the given float to the current Vector3 coordinates
  71144. * @param v defines the x, y and z coordinates of the operand
  71145. * @returns the current updated Vector3
  71146. */
  71147. Vector3.prototype.setAll = function (v) {
  71148. this.x = this.y = this.z = v;
  71149. return this;
  71150. };
  71151. // Statics
  71152. /**
  71153. * Get the clip factor between two vectors
  71154. * @param vector0 defines the first operand
  71155. * @param vector1 defines the second operand
  71156. * @param axis defines the axis to use
  71157. * @param size defines the size along the axis
  71158. * @returns the clip factor
  71159. */
  71160. Vector3.GetClipFactor = function (vector0, vector1, axis, size) {
  71161. var d0 = Vector3.Dot(vector0, axis) - size;
  71162. var d1 = Vector3.Dot(vector1, axis) - size;
  71163. var s = d0 / (d0 - d1);
  71164. return s;
  71165. };
  71166. /**
  71167. * Get angle between two vectors
  71168. * @param vector0 angle between vector0 and vector1
  71169. * @param vector1 angle between vector0 and vector1
  71170. * @param normal direction of the normal
  71171. * @return the angle between vector0 and vector1
  71172. */
  71173. Vector3.GetAngleBetweenVectors = function (vector0, vector1, normal) {
  71174. var v0 = vector0.normalizeToRef(MathTmp.Vector3[1]);
  71175. var v1 = vector1.normalizeToRef(MathTmp.Vector3[2]);
  71176. var dot = Vector3.Dot(v0, v1);
  71177. var n = MathTmp.Vector3[3];
  71178. Vector3.CrossToRef(v0, v1, n);
  71179. if (Vector3.Dot(n, normal) > 0) {
  71180. return Math.acos(dot);
  71181. }
  71182. return -Math.acos(dot);
  71183. };
  71184. /**
  71185. * Returns a new Vector3 set from the index "offset" of the given array
  71186. * @param array defines the source array
  71187. * @param offset defines the offset in the source array
  71188. * @returns the new Vector3
  71189. */
  71190. Vector3.FromArray = function (array, offset) {
  71191. if (offset === void 0) { offset = 0; }
  71192. return new Vector3(array[offset], array[offset + 1], array[offset + 2]);
  71193. };
  71194. /**
  71195. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  71196. * This function is deprecated. Use FromArray instead
  71197. * @param array defines the source array
  71198. * @param offset defines the offset in the source array
  71199. * @returns the new Vector3
  71200. */
  71201. Vector3.FromFloatArray = function (array, offset) {
  71202. return Vector3.FromArray(array, offset);
  71203. };
  71204. /**
  71205. * Sets the given vector "result" with the element values from the index "offset" of the given array
  71206. * @param array defines the source array
  71207. * @param offset defines the offset in the source array
  71208. * @param result defines the Vector3 where to store the result
  71209. */
  71210. Vector3.FromArrayToRef = function (array, offset, result) {
  71211. result.x = array[offset];
  71212. result.y = array[offset + 1];
  71213. result.z = array[offset + 2];
  71214. };
  71215. /**
  71216. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  71217. * This function is deprecated. Use FromArrayToRef instead.
  71218. * @param array defines the source array
  71219. * @param offset defines the offset in the source array
  71220. * @param result defines the Vector3 where to store the result
  71221. */
  71222. Vector3.FromFloatArrayToRef = function (array, offset, result) {
  71223. return Vector3.FromArrayToRef(array, offset, result);
  71224. };
  71225. /**
  71226. * Sets the given vector "result" with the given floats.
  71227. * @param x defines the x coordinate of the source
  71228. * @param y defines the y coordinate of the source
  71229. * @param z defines the z coordinate of the source
  71230. * @param result defines the Vector3 where to store the result
  71231. */
  71232. Vector3.FromFloatsToRef = function (x, y, z, result) {
  71233. result.copyFromFloats(x, y, z);
  71234. };
  71235. /**
  71236. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  71237. * @returns a new empty Vector3
  71238. */
  71239. Vector3.Zero = function () {
  71240. return new Vector3(0.0, 0.0, 0.0);
  71241. };
  71242. /**
  71243. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  71244. * @returns a new unit Vector3
  71245. */
  71246. Vector3.One = function () {
  71247. return new Vector3(1.0, 1.0, 1.0);
  71248. };
  71249. /**
  71250. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  71251. * @returns a new up Vector3
  71252. */
  71253. Vector3.Up = function () {
  71254. return new Vector3(0.0, 1.0, 0.0);
  71255. };
  71256. Object.defineProperty(Vector3, "UpReadOnly", {
  71257. /**
  71258. * Gets a up Vector3 that must not be updated
  71259. */
  71260. get: function () {
  71261. return Vector3._UpReadOnly;
  71262. },
  71263. enumerable: true,
  71264. configurable: true
  71265. });
  71266. /**
  71267. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  71268. * @returns a new down Vector3
  71269. */
  71270. Vector3.Down = function () {
  71271. return new Vector3(0.0, -1.0, 0.0);
  71272. };
  71273. /**
  71274. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  71275. * @returns a new forward Vector3
  71276. */
  71277. Vector3.Forward = function () {
  71278. return new Vector3(0.0, 0.0, 1.0);
  71279. };
  71280. /**
  71281. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  71282. * @returns a new forward Vector3
  71283. */
  71284. Vector3.Backward = function () {
  71285. return new Vector3(0.0, 0.0, -1.0);
  71286. };
  71287. /**
  71288. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  71289. * @returns a new right Vector3
  71290. */
  71291. Vector3.Right = function () {
  71292. return new Vector3(1.0, 0.0, 0.0);
  71293. };
  71294. /**
  71295. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  71296. * @returns a new left Vector3
  71297. */
  71298. Vector3.Left = function () {
  71299. return new Vector3(-1.0, 0.0, 0.0);
  71300. };
  71301. /**
  71302. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  71303. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  71304. * @param vector defines the Vector3 to transform
  71305. * @param transformation defines the transformation matrix
  71306. * @returns the transformed Vector3
  71307. */
  71308. Vector3.TransformCoordinates = function (vector, transformation) {
  71309. var result = Vector3.Zero();
  71310. Vector3.TransformCoordinatesToRef(vector, transformation, result);
  71311. return result;
  71312. };
  71313. /**
  71314. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  71315. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  71316. * @param vector defines the Vector3 to transform
  71317. * @param transformation defines the transformation matrix
  71318. * @param result defines the Vector3 where to store the result
  71319. */
  71320. Vector3.TransformCoordinatesToRef = function (vector, transformation, result) {
  71321. Vector3.TransformCoordinatesFromFloatsToRef(vector.x, vector.y, vector.z, transformation, result);
  71322. };
  71323. /**
  71324. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  71325. * This method computes tranformed coordinates only, not transformed direction vectors
  71326. * @param x define the x coordinate of the source vector
  71327. * @param y define the y coordinate of the source vector
  71328. * @param z define the z coordinate of the source vector
  71329. * @param transformation defines the transformation matrix
  71330. * @param result defines the Vector3 where to store the result
  71331. */
  71332. Vector3.TransformCoordinatesFromFloatsToRef = function (x, y, z, transformation, result) {
  71333. var m = transformation.m;
  71334. var rx = x * m[0] + y * m[4] + z * m[8] + m[12];
  71335. var ry = x * m[1] + y * m[5] + z * m[9] + m[13];
  71336. var rz = x * m[2] + y * m[6] + z * m[10] + m[14];
  71337. var rw = 1 / (x * m[3] + y * m[7] + z * m[11] + m[15]);
  71338. result.x = rx * rw;
  71339. result.y = ry * rw;
  71340. result.z = rz * rw;
  71341. };
  71342. /**
  71343. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  71344. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  71345. * @param vector defines the Vector3 to transform
  71346. * @param transformation defines the transformation matrix
  71347. * @returns the new Vector3
  71348. */
  71349. Vector3.TransformNormal = function (vector, transformation) {
  71350. var result = Vector3.Zero();
  71351. Vector3.TransformNormalToRef(vector, transformation, result);
  71352. return result;
  71353. };
  71354. /**
  71355. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  71356. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  71357. * @param vector defines the Vector3 to transform
  71358. * @param transformation defines the transformation matrix
  71359. * @param result defines the Vector3 where to store the result
  71360. */
  71361. Vector3.TransformNormalToRef = function (vector, transformation, result) {
  71362. this.TransformNormalFromFloatsToRef(vector.x, vector.y, vector.z, transformation, result);
  71363. };
  71364. /**
  71365. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  71366. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  71367. * @param x define the x coordinate of the source vector
  71368. * @param y define the y coordinate of the source vector
  71369. * @param z define the z coordinate of the source vector
  71370. * @param transformation defines the transformation matrix
  71371. * @param result defines the Vector3 where to store the result
  71372. */
  71373. Vector3.TransformNormalFromFloatsToRef = function (x, y, z, transformation, result) {
  71374. var m = transformation.m;
  71375. result.x = x * m[0] + y * m[4] + z * m[8];
  71376. result.y = x * m[1] + y * m[5] + z * m[9];
  71377. result.z = x * m[2] + y * m[6] + z * m[10];
  71378. };
  71379. /**
  71380. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  71381. * @param value1 defines the first control point
  71382. * @param value2 defines the second control point
  71383. * @param value3 defines the third control point
  71384. * @param value4 defines the fourth control point
  71385. * @param amount defines the amount on the spline to use
  71386. * @returns the new Vector3
  71387. */
  71388. Vector3.CatmullRom = function (value1, value2, value3, value4, amount) {
  71389. var squared = amount * amount;
  71390. var cubed = amount * squared;
  71391. var x = 0.5 * ((((2.0 * value2.x) + ((-value1.x + value3.x) * amount)) +
  71392. (((((2.0 * value1.x) - (5.0 * value2.x)) + (4.0 * value3.x)) - value4.x) * squared)) +
  71393. ((((-value1.x + (3.0 * value2.x)) - (3.0 * value3.x)) + value4.x) * cubed));
  71394. var y = 0.5 * ((((2.0 * value2.y) + ((-value1.y + value3.y) * amount)) +
  71395. (((((2.0 * value1.y) - (5.0 * value2.y)) + (4.0 * value3.y)) - value4.y) * squared)) +
  71396. ((((-value1.y + (3.0 * value2.y)) - (3.0 * value3.y)) + value4.y) * cubed));
  71397. var z = 0.5 * ((((2.0 * value2.z) + ((-value1.z + value3.z) * amount)) +
  71398. (((((2.0 * value1.z) - (5.0 * value2.z)) + (4.0 * value3.z)) - value4.z) * squared)) +
  71399. ((((-value1.z + (3.0 * value2.z)) - (3.0 * value3.z)) + value4.z) * cubed));
  71400. return new Vector3(x, y, z);
  71401. };
  71402. /**
  71403. * 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"
  71404. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  71405. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  71406. * @param value defines the current value
  71407. * @param min defines the lower range value
  71408. * @param max defines the upper range value
  71409. * @returns the new Vector3
  71410. */
  71411. Vector3.Clamp = function (value, min, max) {
  71412. var v = new Vector3();
  71413. Vector3.ClampToRef(value, min, max, v);
  71414. return v;
  71415. };
  71416. /**
  71417. * 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"
  71418. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  71419. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  71420. * @param value defines the current value
  71421. * @param min defines the lower range value
  71422. * @param max defines the upper range value
  71423. * @param result defines the Vector3 where to store the result
  71424. */
  71425. Vector3.ClampToRef = function (value, min, max, result) {
  71426. var x = value.x;
  71427. x = (x > max.x) ? max.x : x;
  71428. x = (x < min.x) ? min.x : x;
  71429. var y = value.y;
  71430. y = (y > max.y) ? max.y : y;
  71431. y = (y < min.y) ? min.y : y;
  71432. var z = value.z;
  71433. z = (z > max.z) ? max.z : z;
  71434. z = (z < min.z) ? min.z : z;
  71435. result.copyFromFloats(x, y, z);
  71436. };
  71437. /**
  71438. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  71439. * @param value1 defines the first control point
  71440. * @param tangent1 defines the first tangent vector
  71441. * @param value2 defines the second control point
  71442. * @param tangent2 defines the second tangent vector
  71443. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  71444. * @returns the new Vector3
  71445. */
  71446. Vector3.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  71447. var squared = amount * amount;
  71448. var cubed = amount * squared;
  71449. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  71450. var part2 = (-2.0 * cubed) + (3.0 * squared);
  71451. var part3 = (cubed - (2.0 * squared)) + amount;
  71452. var part4 = cubed - squared;
  71453. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  71454. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  71455. var z = (((value1.z * part1) + (value2.z * part2)) + (tangent1.z * part3)) + (tangent2.z * part4);
  71456. return new Vector3(x, y, z);
  71457. };
  71458. /**
  71459. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  71460. * @param start defines the start value
  71461. * @param end defines the end value
  71462. * @param amount max defines amount between both (between 0 and 1)
  71463. * @returns the new Vector3
  71464. */
  71465. Vector3.Lerp = function (start, end, amount) {
  71466. var result = new Vector3(0, 0, 0);
  71467. Vector3.LerpToRef(start, end, amount, result);
  71468. return result;
  71469. };
  71470. /**
  71471. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  71472. * @param start defines the start value
  71473. * @param end defines the end value
  71474. * @param amount max defines amount between both (between 0 and 1)
  71475. * @param result defines the Vector3 where to store the result
  71476. */
  71477. Vector3.LerpToRef = function (start, end, amount, result) {
  71478. result.x = start.x + ((end.x - start.x) * amount);
  71479. result.y = start.y + ((end.y - start.y) * amount);
  71480. result.z = start.z + ((end.z - start.z) * amount);
  71481. };
  71482. /**
  71483. * Returns the dot product (float) between the vectors "left" and "right"
  71484. * @param left defines the left operand
  71485. * @param right defines the right operand
  71486. * @returns the dot product
  71487. */
  71488. Vector3.Dot = function (left, right) {
  71489. return (left.x * right.x + left.y * right.y + left.z * right.z);
  71490. };
  71491. /**
  71492. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  71493. * The cross product is then orthogonal to both "left" and "right"
  71494. * @param left defines the left operand
  71495. * @param right defines the right operand
  71496. * @returns the cross product
  71497. */
  71498. Vector3.Cross = function (left, right) {
  71499. var result = Vector3.Zero();
  71500. Vector3.CrossToRef(left, right, result);
  71501. return result;
  71502. };
  71503. /**
  71504. * Sets the given vector "result" with the cross product of "left" and "right"
  71505. * The cross product is then orthogonal to both "left" and "right"
  71506. * @param left defines the left operand
  71507. * @param right defines the right operand
  71508. * @param result defines the Vector3 where to store the result
  71509. */
  71510. Vector3.CrossToRef = function (left, right, result) {
  71511. var x = left.y * right.z - left.z * right.y;
  71512. var y = left.z * right.x - left.x * right.z;
  71513. var z = left.x * right.y - left.y * right.x;
  71514. result.copyFromFloats(x, y, z);
  71515. };
  71516. /**
  71517. * Returns a new Vector3 as the normalization of the given vector
  71518. * @param vector defines the Vector3 to normalize
  71519. * @returns the new Vector3
  71520. */
  71521. Vector3.Normalize = function (vector) {
  71522. var result = Vector3.Zero();
  71523. Vector3.NormalizeToRef(vector, result);
  71524. return result;
  71525. };
  71526. /**
  71527. * Sets the given vector "result" with the normalization of the given first vector
  71528. * @param vector defines the Vector3 to normalize
  71529. * @param result defines the Vector3 where to store the result
  71530. */
  71531. Vector3.NormalizeToRef = function (vector, result) {
  71532. vector.normalizeToRef(result);
  71533. };
  71534. /**
  71535. * Project a Vector3 onto screen space
  71536. * @param vector defines the Vector3 to project
  71537. * @param world defines the world matrix to use
  71538. * @param transform defines the transform (view x projection) matrix to use
  71539. * @param viewport defines the screen viewport to use
  71540. * @returns the new Vector3
  71541. */
  71542. Vector3.Project = function (vector, world, transform, viewport) {
  71543. var cw = viewport.width;
  71544. var ch = viewport.height;
  71545. var cx = viewport.x;
  71546. var cy = viewport.y;
  71547. var viewportMatrix = MathTmp.Matrix[1];
  71548. 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);
  71549. var matrix = MathTmp.Matrix[0];
  71550. world.multiplyToRef(transform, matrix);
  71551. matrix.multiplyToRef(viewportMatrix, matrix);
  71552. return Vector3.TransformCoordinates(vector, matrix);
  71553. };
  71554. /** @hidden */
  71555. Vector3._UnprojectFromInvertedMatrixToRef = function (source, matrix, result) {
  71556. Vector3.TransformCoordinatesToRef(source, matrix, result);
  71557. var m = matrix.m;
  71558. var num = source.x * m[3] + source.y * m[7] + source.z * m[11] + m[15];
  71559. if (_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(num, 1.0)) {
  71560. result.scaleInPlace(1.0 / num);
  71561. }
  71562. };
  71563. /**
  71564. * Unproject from screen space to object space
  71565. * @param source defines the screen space Vector3 to use
  71566. * @param viewportWidth defines the current width of the viewport
  71567. * @param viewportHeight defines the current height of the viewport
  71568. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71569. * @param transform defines the transform (view x projection) matrix to use
  71570. * @returns the new Vector3
  71571. */
  71572. Vector3.UnprojectFromTransform = function (source, viewportWidth, viewportHeight, world, transform) {
  71573. var matrix = MathTmp.Matrix[0];
  71574. world.multiplyToRef(transform, matrix);
  71575. matrix.invert();
  71576. source.x = source.x / viewportWidth * 2 - 1;
  71577. source.y = -(source.y / viewportHeight * 2 - 1);
  71578. var vector = new Vector3();
  71579. Vector3._UnprojectFromInvertedMatrixToRef(source, matrix, vector);
  71580. return vector;
  71581. };
  71582. /**
  71583. * Unproject from screen space to object space
  71584. * @param source defines the screen space Vector3 to use
  71585. * @param viewportWidth defines the current width of the viewport
  71586. * @param viewportHeight defines the current height of the viewport
  71587. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71588. * @param view defines the view matrix to use
  71589. * @param projection defines the projection matrix to use
  71590. * @returns the new Vector3
  71591. */
  71592. Vector3.Unproject = function (source, viewportWidth, viewportHeight, world, view, projection) {
  71593. var result = Vector3.Zero();
  71594. Vector3.UnprojectToRef(source, viewportWidth, viewportHeight, world, view, projection, result);
  71595. return result;
  71596. };
  71597. /**
  71598. * Unproject from screen space to object space
  71599. * @param source defines the screen space Vector3 to use
  71600. * @param viewportWidth defines the current width of the viewport
  71601. * @param viewportHeight defines the current height of the viewport
  71602. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71603. * @param view defines the view matrix to use
  71604. * @param projection defines the projection matrix to use
  71605. * @param result defines the Vector3 where to store the result
  71606. */
  71607. Vector3.UnprojectToRef = function (source, viewportWidth, viewportHeight, world, view, projection, result) {
  71608. Vector3.UnprojectFloatsToRef(source.x, source.y, source.z, viewportWidth, viewportHeight, world, view, projection, result);
  71609. };
  71610. /**
  71611. * Unproject from screen space to object space
  71612. * @param sourceX defines the screen space x coordinate to use
  71613. * @param sourceY defines the screen space y coordinate to use
  71614. * @param sourceZ defines the screen space z coordinate to use
  71615. * @param viewportWidth defines the current width of the viewport
  71616. * @param viewportHeight defines the current height of the viewport
  71617. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71618. * @param view defines the view matrix to use
  71619. * @param projection defines the projection matrix to use
  71620. * @param result defines the Vector3 where to store the result
  71621. */
  71622. Vector3.UnprojectFloatsToRef = function (sourceX, sourceY, sourceZ, viewportWidth, viewportHeight, world, view, projection, result) {
  71623. var matrix = MathTmp.Matrix[0];
  71624. world.multiplyToRef(view, matrix);
  71625. matrix.multiplyToRef(projection, matrix);
  71626. matrix.invert();
  71627. var screenSource = MathTmp.Vector3[0];
  71628. screenSource.x = sourceX / viewportWidth * 2 - 1;
  71629. screenSource.y = -(sourceY / viewportHeight * 2 - 1);
  71630. screenSource.z = 2 * sourceZ - 1.0;
  71631. Vector3._UnprojectFromInvertedMatrixToRef(screenSource, matrix, result);
  71632. };
  71633. /**
  71634. * Gets the minimal coordinate values between two Vector3
  71635. * @param left defines the first operand
  71636. * @param right defines the second operand
  71637. * @returns the new Vector3
  71638. */
  71639. Vector3.Minimize = function (left, right) {
  71640. var min = left.clone();
  71641. min.minimizeInPlace(right);
  71642. return min;
  71643. };
  71644. /**
  71645. * Gets the maximal coordinate values between two Vector3
  71646. * @param left defines the first operand
  71647. * @param right defines the second operand
  71648. * @returns the new Vector3
  71649. */
  71650. Vector3.Maximize = function (left, right) {
  71651. var max = left.clone();
  71652. max.maximizeInPlace(right);
  71653. return max;
  71654. };
  71655. /**
  71656. * Returns the distance between the vectors "value1" and "value2"
  71657. * @param value1 defines the first operand
  71658. * @param value2 defines the second operand
  71659. * @returns the distance
  71660. */
  71661. Vector3.Distance = function (value1, value2) {
  71662. return Math.sqrt(Vector3.DistanceSquared(value1, value2));
  71663. };
  71664. /**
  71665. * Returns the squared distance between the vectors "value1" and "value2"
  71666. * @param value1 defines the first operand
  71667. * @param value2 defines the second operand
  71668. * @returns the squared distance
  71669. */
  71670. Vector3.DistanceSquared = function (value1, value2) {
  71671. var x = value1.x - value2.x;
  71672. var y = value1.y - value2.y;
  71673. var z = value1.z - value2.z;
  71674. return (x * x) + (y * y) + (z * z);
  71675. };
  71676. /**
  71677. * Returns a new Vector3 located at the center between "value1" and "value2"
  71678. * @param value1 defines the first operand
  71679. * @param value2 defines the second operand
  71680. * @returns the new Vector3
  71681. */
  71682. Vector3.Center = function (value1, value2) {
  71683. var center = value1.add(value2);
  71684. center.scaleInPlace(0.5);
  71685. return center;
  71686. };
  71687. /**
  71688. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  71689. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  71690. * to something in order to rotate it from its local system to the given target system
  71691. * Note: axis1, axis2 and axis3 are normalized during this operation
  71692. * @param axis1 defines the first axis
  71693. * @param axis2 defines the second axis
  71694. * @param axis3 defines the third axis
  71695. * @returns a new Vector3
  71696. */
  71697. Vector3.RotationFromAxis = function (axis1, axis2, axis3) {
  71698. var rotation = Vector3.Zero();
  71699. Vector3.RotationFromAxisToRef(axis1, axis2, axis3, rotation);
  71700. return rotation;
  71701. };
  71702. /**
  71703. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  71704. * @param axis1 defines the first axis
  71705. * @param axis2 defines the second axis
  71706. * @param axis3 defines the third axis
  71707. * @param ref defines the Vector3 where to store the result
  71708. */
  71709. Vector3.RotationFromAxisToRef = function (axis1, axis2, axis3, ref) {
  71710. var quat = MathTmp.Quaternion[0];
  71711. Quaternion.RotationQuaternionFromAxisToRef(axis1, axis2, axis3, quat);
  71712. quat.toEulerAnglesToRef(ref);
  71713. };
  71714. Vector3._UpReadOnly = Vector3.Up();
  71715. return Vector3;
  71716. }());
  71717. /**
  71718. * Vector4 class created for EulerAngle class conversion to Quaternion
  71719. */
  71720. var Vector4 = /** @class */ (function () {
  71721. /**
  71722. * Creates a Vector4 object from the given floats.
  71723. * @param x x value of the vector
  71724. * @param y y value of the vector
  71725. * @param z z value of the vector
  71726. * @param w w value of the vector
  71727. */
  71728. function Vector4(
  71729. /** x value of the vector */
  71730. x,
  71731. /** y value of the vector */
  71732. y,
  71733. /** z value of the vector */
  71734. z,
  71735. /** w value of the vector */
  71736. w) {
  71737. this.x = x;
  71738. this.y = y;
  71739. this.z = z;
  71740. this.w = w;
  71741. }
  71742. /**
  71743. * Returns the string with the Vector4 coordinates.
  71744. * @returns a string containing all the vector values
  71745. */
  71746. Vector4.prototype.toString = function () {
  71747. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + " W:" + this.w + "}";
  71748. };
  71749. /**
  71750. * Returns the string "Vector4".
  71751. * @returns "Vector4"
  71752. */
  71753. Vector4.prototype.getClassName = function () {
  71754. return "Vector4";
  71755. };
  71756. /**
  71757. * Returns the Vector4 hash code.
  71758. * @returns a unique hash code
  71759. */
  71760. Vector4.prototype.getHashCode = function () {
  71761. var hash = this.x || 0;
  71762. hash = (hash * 397) ^ (this.y || 0);
  71763. hash = (hash * 397) ^ (this.z || 0);
  71764. hash = (hash * 397) ^ (this.w || 0);
  71765. return hash;
  71766. };
  71767. // Operators
  71768. /**
  71769. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  71770. * @returns the resulting array
  71771. */
  71772. Vector4.prototype.asArray = function () {
  71773. var result = new Array();
  71774. this.toArray(result, 0);
  71775. return result;
  71776. };
  71777. /**
  71778. * Populates the given array from the given index with the Vector4 coordinates.
  71779. * @param array array to populate
  71780. * @param index index of the array to start at (default: 0)
  71781. * @returns the Vector4.
  71782. */
  71783. Vector4.prototype.toArray = function (array, index) {
  71784. if (index === undefined) {
  71785. index = 0;
  71786. }
  71787. array[index] = this.x;
  71788. array[index + 1] = this.y;
  71789. array[index + 2] = this.z;
  71790. array[index + 3] = this.w;
  71791. return this;
  71792. };
  71793. /**
  71794. * Adds the given vector to the current Vector4.
  71795. * @param otherVector the vector to add
  71796. * @returns the updated Vector4.
  71797. */
  71798. Vector4.prototype.addInPlace = function (otherVector) {
  71799. this.x += otherVector.x;
  71800. this.y += otherVector.y;
  71801. this.z += otherVector.z;
  71802. this.w += otherVector.w;
  71803. return this;
  71804. };
  71805. /**
  71806. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  71807. * @param otherVector the vector to add
  71808. * @returns the resulting vector
  71809. */
  71810. Vector4.prototype.add = function (otherVector) {
  71811. return new Vector4(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z, this.w + otherVector.w);
  71812. };
  71813. /**
  71814. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  71815. * @param otherVector the vector to add
  71816. * @param result the vector to store the result
  71817. * @returns the current Vector4.
  71818. */
  71819. Vector4.prototype.addToRef = function (otherVector, result) {
  71820. result.x = this.x + otherVector.x;
  71821. result.y = this.y + otherVector.y;
  71822. result.z = this.z + otherVector.z;
  71823. result.w = this.w + otherVector.w;
  71824. return this;
  71825. };
  71826. /**
  71827. * Subtract in place the given vector from the current Vector4.
  71828. * @param otherVector the vector to subtract
  71829. * @returns the updated Vector4.
  71830. */
  71831. Vector4.prototype.subtractInPlace = function (otherVector) {
  71832. this.x -= otherVector.x;
  71833. this.y -= otherVector.y;
  71834. this.z -= otherVector.z;
  71835. this.w -= otherVector.w;
  71836. return this;
  71837. };
  71838. /**
  71839. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  71840. * @param otherVector the vector to add
  71841. * @returns the new vector with the result
  71842. */
  71843. Vector4.prototype.subtract = function (otherVector) {
  71844. return new Vector4(this.x - otherVector.x, this.y - otherVector.y, this.z - otherVector.z, this.w - otherVector.w);
  71845. };
  71846. /**
  71847. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  71848. * @param otherVector the vector to subtract
  71849. * @param result the vector to store the result
  71850. * @returns the current Vector4.
  71851. */
  71852. Vector4.prototype.subtractToRef = function (otherVector, result) {
  71853. result.x = this.x - otherVector.x;
  71854. result.y = this.y - otherVector.y;
  71855. result.z = this.z - otherVector.z;
  71856. result.w = this.w - otherVector.w;
  71857. return this;
  71858. };
  71859. /**
  71860. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  71861. */
  71862. /**
  71863. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  71864. * @param x value to subtract
  71865. * @param y value to subtract
  71866. * @param z value to subtract
  71867. * @param w value to subtract
  71868. * @returns new vector containing the result
  71869. */
  71870. Vector4.prototype.subtractFromFloats = function (x, y, z, w) {
  71871. return new Vector4(this.x - x, this.y - y, this.z - z, this.w - w);
  71872. };
  71873. /**
  71874. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  71875. * @param x value to subtract
  71876. * @param y value to subtract
  71877. * @param z value to subtract
  71878. * @param w value to subtract
  71879. * @param result the vector to store the result in
  71880. * @returns the current Vector4.
  71881. */
  71882. Vector4.prototype.subtractFromFloatsToRef = function (x, y, z, w, result) {
  71883. result.x = this.x - x;
  71884. result.y = this.y - y;
  71885. result.z = this.z - z;
  71886. result.w = this.w - w;
  71887. return this;
  71888. };
  71889. /**
  71890. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  71891. * @returns a new vector with the negated values
  71892. */
  71893. Vector4.prototype.negate = function () {
  71894. return new Vector4(-this.x, -this.y, -this.z, -this.w);
  71895. };
  71896. /**
  71897. * Multiplies the current Vector4 coordinates by scale (float).
  71898. * @param scale the number to scale with
  71899. * @returns the updated Vector4.
  71900. */
  71901. Vector4.prototype.scaleInPlace = function (scale) {
  71902. this.x *= scale;
  71903. this.y *= scale;
  71904. this.z *= scale;
  71905. this.w *= scale;
  71906. return this;
  71907. };
  71908. /**
  71909. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  71910. * @param scale the number to scale with
  71911. * @returns a new vector with the result
  71912. */
  71913. Vector4.prototype.scale = function (scale) {
  71914. return new Vector4(this.x * scale, this.y * scale, this.z * scale, this.w * scale);
  71915. };
  71916. /**
  71917. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  71918. * @param scale the number to scale with
  71919. * @param result a vector to store the result in
  71920. * @returns the current Vector4.
  71921. */
  71922. Vector4.prototype.scaleToRef = function (scale, result) {
  71923. result.x = this.x * scale;
  71924. result.y = this.y * scale;
  71925. result.z = this.z * scale;
  71926. result.w = this.w * scale;
  71927. return this;
  71928. };
  71929. /**
  71930. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  71931. * @param scale defines the scale factor
  71932. * @param result defines the Vector4 object where to store the result
  71933. * @returns the unmodified current Vector4
  71934. */
  71935. Vector4.prototype.scaleAndAddToRef = function (scale, result) {
  71936. result.x += this.x * scale;
  71937. result.y += this.y * scale;
  71938. result.z += this.z * scale;
  71939. result.w += this.w * scale;
  71940. return this;
  71941. };
  71942. /**
  71943. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  71944. * @param otherVector the vector to compare against
  71945. * @returns true if they are equal
  71946. */
  71947. Vector4.prototype.equals = function (otherVector) {
  71948. return otherVector && this.x === otherVector.x && this.y === otherVector.y && this.z === otherVector.z && this.w === otherVector.w;
  71949. };
  71950. /**
  71951. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  71952. * @param otherVector vector to compare against
  71953. * @param epsilon (Default: very small number)
  71954. * @returns true if they are equal
  71955. */
  71956. Vector4.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  71957. if (epsilon === void 0) { epsilon = Epsilon; }
  71958. return otherVector
  71959. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.x, otherVector.x, epsilon)
  71960. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.y, otherVector.y, epsilon)
  71961. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.z, otherVector.z, epsilon)
  71962. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.w, otherVector.w, epsilon);
  71963. };
  71964. /**
  71965. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  71966. * @param x x value to compare against
  71967. * @param y y value to compare against
  71968. * @param z z value to compare against
  71969. * @param w w value to compare against
  71970. * @returns true if equal
  71971. */
  71972. Vector4.prototype.equalsToFloats = function (x, y, z, w) {
  71973. return this.x === x && this.y === y && this.z === z && this.w === w;
  71974. };
  71975. /**
  71976. * Multiplies in place the current Vector4 by the given one.
  71977. * @param otherVector vector to multiple with
  71978. * @returns the updated Vector4.
  71979. */
  71980. Vector4.prototype.multiplyInPlace = function (otherVector) {
  71981. this.x *= otherVector.x;
  71982. this.y *= otherVector.y;
  71983. this.z *= otherVector.z;
  71984. this.w *= otherVector.w;
  71985. return this;
  71986. };
  71987. /**
  71988. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  71989. * @param otherVector vector to multiple with
  71990. * @returns resulting new vector
  71991. */
  71992. Vector4.prototype.multiply = function (otherVector) {
  71993. return new Vector4(this.x * otherVector.x, this.y * otherVector.y, this.z * otherVector.z, this.w * otherVector.w);
  71994. };
  71995. /**
  71996. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  71997. * @param otherVector vector to multiple with
  71998. * @param result vector to store the result
  71999. * @returns the current Vector4.
  72000. */
  72001. Vector4.prototype.multiplyToRef = function (otherVector, result) {
  72002. result.x = this.x * otherVector.x;
  72003. result.y = this.y * otherVector.y;
  72004. result.z = this.z * otherVector.z;
  72005. result.w = this.w * otherVector.w;
  72006. return this;
  72007. };
  72008. /**
  72009. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  72010. * @param x x value multiply with
  72011. * @param y y value multiply with
  72012. * @param z z value multiply with
  72013. * @param w w value multiply with
  72014. * @returns resulting new vector
  72015. */
  72016. Vector4.prototype.multiplyByFloats = function (x, y, z, w) {
  72017. return new Vector4(this.x * x, this.y * y, this.z * z, this.w * w);
  72018. };
  72019. /**
  72020. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  72021. * @param otherVector vector to devide with
  72022. * @returns resulting new vector
  72023. */
  72024. Vector4.prototype.divide = function (otherVector) {
  72025. return new Vector4(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z, this.w / otherVector.w);
  72026. };
  72027. /**
  72028. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  72029. * @param otherVector vector to devide with
  72030. * @param result vector to store the result
  72031. * @returns the current Vector4.
  72032. */
  72033. Vector4.prototype.divideToRef = function (otherVector, result) {
  72034. result.x = this.x / otherVector.x;
  72035. result.y = this.y / otherVector.y;
  72036. result.z = this.z / otherVector.z;
  72037. result.w = this.w / otherVector.w;
  72038. return this;
  72039. };
  72040. /**
  72041. * Divides the current Vector3 coordinates by the given ones.
  72042. * @param otherVector vector to devide with
  72043. * @returns the updated Vector3.
  72044. */
  72045. Vector4.prototype.divideInPlace = function (otherVector) {
  72046. return this.divideToRef(otherVector, this);
  72047. };
  72048. /**
  72049. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  72050. * @param other defines the second operand
  72051. * @returns the current updated Vector4
  72052. */
  72053. Vector4.prototype.minimizeInPlace = function (other) {
  72054. if (other.x < this.x) {
  72055. this.x = other.x;
  72056. }
  72057. if (other.y < this.y) {
  72058. this.y = other.y;
  72059. }
  72060. if (other.z < this.z) {
  72061. this.z = other.z;
  72062. }
  72063. if (other.w < this.w) {
  72064. this.w = other.w;
  72065. }
  72066. return this;
  72067. };
  72068. /**
  72069. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  72070. * @param other defines the second operand
  72071. * @returns the current updated Vector4
  72072. */
  72073. Vector4.prototype.maximizeInPlace = function (other) {
  72074. if (other.x > this.x) {
  72075. this.x = other.x;
  72076. }
  72077. if (other.y > this.y) {
  72078. this.y = other.y;
  72079. }
  72080. if (other.z > this.z) {
  72081. this.z = other.z;
  72082. }
  72083. if (other.w > this.w) {
  72084. this.w = other.w;
  72085. }
  72086. return this;
  72087. };
  72088. /**
  72089. * Gets a new Vector4 from current Vector4 floored values
  72090. * @returns a new Vector4
  72091. */
  72092. Vector4.prototype.floor = function () {
  72093. return new Vector4(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z), Math.floor(this.w));
  72094. };
  72095. /**
  72096. * Gets a new Vector4 from current Vector3 floored values
  72097. * @returns a new Vector4
  72098. */
  72099. Vector4.prototype.fract = function () {
  72100. 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));
  72101. };
  72102. // Properties
  72103. /**
  72104. * Returns the Vector4 length (float).
  72105. * @returns the length
  72106. */
  72107. Vector4.prototype.length = function () {
  72108. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  72109. };
  72110. /**
  72111. * Returns the Vector4 squared length (float).
  72112. * @returns the length squared
  72113. */
  72114. Vector4.prototype.lengthSquared = function () {
  72115. return (this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  72116. };
  72117. // Methods
  72118. /**
  72119. * Normalizes in place the Vector4.
  72120. * @returns the updated Vector4.
  72121. */
  72122. Vector4.prototype.normalize = function () {
  72123. var len = this.length();
  72124. if (len === 0) {
  72125. return this;
  72126. }
  72127. return this.scaleInPlace(1.0 / len);
  72128. };
  72129. /**
  72130. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  72131. * @returns this converted to a new vector3
  72132. */
  72133. Vector4.prototype.toVector3 = function () {
  72134. return new Vector3(this.x, this.y, this.z);
  72135. };
  72136. /**
  72137. * Returns a new Vector4 copied from the current one.
  72138. * @returns the new cloned vector
  72139. */
  72140. Vector4.prototype.clone = function () {
  72141. return new Vector4(this.x, this.y, this.z, this.w);
  72142. };
  72143. /**
  72144. * Updates the current Vector4 with the given one coordinates.
  72145. * @param source the source vector to copy from
  72146. * @returns the updated Vector4.
  72147. */
  72148. Vector4.prototype.copyFrom = function (source) {
  72149. this.x = source.x;
  72150. this.y = source.y;
  72151. this.z = source.z;
  72152. this.w = source.w;
  72153. return this;
  72154. };
  72155. /**
  72156. * Updates the current Vector4 coordinates with the given floats.
  72157. * @param x float to copy from
  72158. * @param y float to copy from
  72159. * @param z float to copy from
  72160. * @param w float to copy from
  72161. * @returns the updated Vector4.
  72162. */
  72163. Vector4.prototype.copyFromFloats = function (x, y, z, w) {
  72164. this.x = x;
  72165. this.y = y;
  72166. this.z = z;
  72167. this.w = w;
  72168. return this;
  72169. };
  72170. /**
  72171. * Updates the current Vector4 coordinates with the given floats.
  72172. * @param x float to set from
  72173. * @param y float to set from
  72174. * @param z float to set from
  72175. * @param w float to set from
  72176. * @returns the updated Vector4.
  72177. */
  72178. Vector4.prototype.set = function (x, y, z, w) {
  72179. return this.copyFromFloats(x, y, z, w);
  72180. };
  72181. /**
  72182. * Copies the given float to the current Vector3 coordinates
  72183. * @param v defines the x, y, z and w coordinates of the operand
  72184. * @returns the current updated Vector3
  72185. */
  72186. Vector4.prototype.setAll = function (v) {
  72187. this.x = this.y = this.z = this.w = v;
  72188. return this;
  72189. };
  72190. // Statics
  72191. /**
  72192. * Returns a new Vector4 set from the starting index of the given array.
  72193. * @param array the array to pull values from
  72194. * @param offset the offset into the array to start at
  72195. * @returns the new vector
  72196. */
  72197. Vector4.FromArray = function (array, offset) {
  72198. if (!offset) {
  72199. offset = 0;
  72200. }
  72201. return new Vector4(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  72202. };
  72203. /**
  72204. * Updates the given vector "result" from the starting index of the given array.
  72205. * @param array the array to pull values from
  72206. * @param offset the offset into the array to start at
  72207. * @param result the vector to store the result in
  72208. */
  72209. Vector4.FromArrayToRef = function (array, offset, result) {
  72210. result.x = array[offset];
  72211. result.y = array[offset + 1];
  72212. result.z = array[offset + 2];
  72213. result.w = array[offset + 3];
  72214. };
  72215. /**
  72216. * Updates the given vector "result" from the starting index of the given Float32Array.
  72217. * @param array the array to pull values from
  72218. * @param offset the offset into the array to start at
  72219. * @param result the vector to store the result in
  72220. */
  72221. Vector4.FromFloatArrayToRef = function (array, offset, result) {
  72222. Vector4.FromArrayToRef(array, offset, result);
  72223. };
  72224. /**
  72225. * Updates the given vector "result" coordinates from the given floats.
  72226. * @param x float to set from
  72227. * @param y float to set from
  72228. * @param z float to set from
  72229. * @param w float to set from
  72230. * @param result the vector to the floats in
  72231. */
  72232. Vector4.FromFloatsToRef = function (x, y, z, w, result) {
  72233. result.x = x;
  72234. result.y = y;
  72235. result.z = z;
  72236. result.w = w;
  72237. };
  72238. /**
  72239. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  72240. * @returns the new vector
  72241. */
  72242. Vector4.Zero = function () {
  72243. return new Vector4(0.0, 0.0, 0.0, 0.0);
  72244. };
  72245. /**
  72246. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  72247. * @returns the new vector
  72248. */
  72249. Vector4.One = function () {
  72250. return new Vector4(1.0, 1.0, 1.0, 1.0);
  72251. };
  72252. /**
  72253. * Returns a new normalized Vector4 from the given one.
  72254. * @param vector the vector to normalize
  72255. * @returns the vector
  72256. */
  72257. Vector4.Normalize = function (vector) {
  72258. var result = Vector4.Zero();
  72259. Vector4.NormalizeToRef(vector, result);
  72260. return result;
  72261. };
  72262. /**
  72263. * Updates the given vector "result" from the normalization of the given one.
  72264. * @param vector the vector to normalize
  72265. * @param result the vector to store the result in
  72266. */
  72267. Vector4.NormalizeToRef = function (vector, result) {
  72268. result.copyFrom(vector);
  72269. result.normalize();
  72270. };
  72271. /**
  72272. * Returns a vector with the minimum values from the left and right vectors
  72273. * @param left left vector to minimize
  72274. * @param right right vector to minimize
  72275. * @returns a new vector with the minimum of the left and right vector values
  72276. */
  72277. Vector4.Minimize = function (left, right) {
  72278. var min = left.clone();
  72279. min.minimizeInPlace(right);
  72280. return min;
  72281. };
  72282. /**
  72283. * Returns a vector with the maximum values from the left and right vectors
  72284. * @param left left vector to maximize
  72285. * @param right right vector to maximize
  72286. * @returns a new vector with the maximum of the left and right vector values
  72287. */
  72288. Vector4.Maximize = function (left, right) {
  72289. var max = left.clone();
  72290. max.maximizeInPlace(right);
  72291. return max;
  72292. };
  72293. /**
  72294. * Returns the distance (float) between the vectors "value1" and "value2".
  72295. * @param value1 value to calulate the distance between
  72296. * @param value2 value to calulate the distance between
  72297. * @return the distance between the two vectors
  72298. */
  72299. Vector4.Distance = function (value1, value2) {
  72300. return Math.sqrt(Vector4.DistanceSquared(value1, value2));
  72301. };
  72302. /**
  72303. * Returns the squared distance (float) between the vectors "value1" and "value2".
  72304. * @param value1 value to calulate the distance between
  72305. * @param value2 value to calulate the distance between
  72306. * @return the distance between the two vectors squared
  72307. */
  72308. Vector4.DistanceSquared = function (value1, value2) {
  72309. var x = value1.x - value2.x;
  72310. var y = value1.y - value2.y;
  72311. var z = value1.z - value2.z;
  72312. var w = value1.w - value2.w;
  72313. return (x * x) + (y * y) + (z * z) + (w * w);
  72314. };
  72315. /**
  72316. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  72317. * @param value1 value to calulate the center between
  72318. * @param value2 value to calulate the center between
  72319. * @return the center between the two vectors
  72320. */
  72321. Vector4.Center = function (value1, value2) {
  72322. var center = value1.add(value2);
  72323. center.scaleInPlace(0.5);
  72324. return center;
  72325. };
  72326. /**
  72327. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  72328. * This methods computes transformed normalized direction vectors only.
  72329. * @param vector the vector to transform
  72330. * @param transformation the transformation matrix to apply
  72331. * @returns the new vector
  72332. */
  72333. Vector4.TransformNormal = function (vector, transformation) {
  72334. var result = Vector4.Zero();
  72335. Vector4.TransformNormalToRef(vector, transformation, result);
  72336. return result;
  72337. };
  72338. /**
  72339. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  72340. * This methods computes transformed normalized direction vectors only.
  72341. * @param vector the vector to transform
  72342. * @param transformation the transformation matrix to apply
  72343. * @param result the vector to store the result in
  72344. */
  72345. Vector4.TransformNormalToRef = function (vector, transformation, result) {
  72346. var m = transformation.m;
  72347. var x = (vector.x * m[0]) + (vector.y * m[4]) + (vector.z * m[8]);
  72348. var y = (vector.x * m[1]) + (vector.y * m[5]) + (vector.z * m[9]);
  72349. var z = (vector.x * m[2]) + (vector.y * m[6]) + (vector.z * m[10]);
  72350. result.x = x;
  72351. result.y = y;
  72352. result.z = z;
  72353. result.w = vector.w;
  72354. };
  72355. /**
  72356. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  72357. * This methods computes transformed normalized direction vectors only.
  72358. * @param x value to transform
  72359. * @param y value to transform
  72360. * @param z value to transform
  72361. * @param w value to transform
  72362. * @param transformation the transformation matrix to apply
  72363. * @param result the vector to store the results in
  72364. */
  72365. Vector4.TransformNormalFromFloatsToRef = function (x, y, z, w, transformation, result) {
  72366. var m = transformation.m;
  72367. result.x = (x * m[0]) + (y * m[4]) + (z * m[8]);
  72368. result.y = (x * m[1]) + (y * m[5]) + (z * m[9]);
  72369. result.z = (x * m[2]) + (y * m[6]) + (z * m[10]);
  72370. result.w = w;
  72371. };
  72372. /**
  72373. * Creates a new Vector4 from a Vector3
  72374. * @param source defines the source data
  72375. * @param w defines the 4th component (default is 0)
  72376. * @returns a new Vector4
  72377. */
  72378. Vector4.FromVector3 = function (source, w) {
  72379. if (w === void 0) { w = 0; }
  72380. return new Vector4(source.x, source.y, source.z, w);
  72381. };
  72382. return Vector4;
  72383. }());
  72384. /**
  72385. * Size containing widht and height
  72386. */
  72387. var Size = /** @class */ (function () {
  72388. /**
  72389. * Creates a Size object from the given width and height (floats).
  72390. * @param width width of the new size
  72391. * @param height height of the new size
  72392. */
  72393. function Size(width, height) {
  72394. this.width = width;
  72395. this.height = height;
  72396. }
  72397. /**
  72398. * Returns a string with the Size width and height
  72399. * @returns a string with the Size width and height
  72400. */
  72401. Size.prototype.toString = function () {
  72402. return "{W: " + this.width + ", H: " + this.height + "}";
  72403. };
  72404. /**
  72405. * "Size"
  72406. * @returns the string "Size"
  72407. */
  72408. Size.prototype.getClassName = function () {
  72409. return "Size";
  72410. };
  72411. /**
  72412. * Returns the Size hash code.
  72413. * @returns a hash code for a unique width and height
  72414. */
  72415. Size.prototype.getHashCode = function () {
  72416. var hash = this.width || 0;
  72417. hash = (hash * 397) ^ (this.height || 0);
  72418. return hash;
  72419. };
  72420. /**
  72421. * Updates the current size from the given one.
  72422. * @param src the given size
  72423. */
  72424. Size.prototype.copyFrom = function (src) {
  72425. this.width = src.width;
  72426. this.height = src.height;
  72427. };
  72428. /**
  72429. * Updates in place the current Size from the given floats.
  72430. * @param width width of the new size
  72431. * @param height height of the new size
  72432. * @returns the updated Size.
  72433. */
  72434. Size.prototype.copyFromFloats = function (width, height) {
  72435. this.width = width;
  72436. this.height = height;
  72437. return this;
  72438. };
  72439. /**
  72440. * Updates in place the current Size from the given floats.
  72441. * @param width width to set
  72442. * @param height height to set
  72443. * @returns the updated Size.
  72444. */
  72445. Size.prototype.set = function (width, height) {
  72446. return this.copyFromFloats(width, height);
  72447. };
  72448. /**
  72449. * Multiplies the width and height by numbers
  72450. * @param w factor to multiple the width by
  72451. * @param h factor to multiple the height by
  72452. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  72453. */
  72454. Size.prototype.multiplyByFloats = function (w, h) {
  72455. return new Size(this.width * w, this.height * h);
  72456. };
  72457. /**
  72458. * Clones the size
  72459. * @returns a new Size copied from the given one.
  72460. */
  72461. Size.prototype.clone = function () {
  72462. return new Size(this.width, this.height);
  72463. };
  72464. /**
  72465. * True if the current Size and the given one width and height are strictly equal.
  72466. * @param other the other size to compare against
  72467. * @returns True if the current Size and the given one width and height are strictly equal.
  72468. */
  72469. Size.prototype.equals = function (other) {
  72470. if (!other) {
  72471. return false;
  72472. }
  72473. return (this.width === other.width) && (this.height === other.height);
  72474. };
  72475. Object.defineProperty(Size.prototype, "surface", {
  72476. /**
  72477. * The surface of the Size : width * height (float).
  72478. */
  72479. get: function () {
  72480. return this.width * this.height;
  72481. },
  72482. enumerable: true,
  72483. configurable: true
  72484. });
  72485. /**
  72486. * Create a new size of zero
  72487. * @returns a new Size set to (0.0, 0.0)
  72488. */
  72489. Size.Zero = function () {
  72490. return new Size(0.0, 0.0);
  72491. };
  72492. /**
  72493. * Sums the width and height of two sizes
  72494. * @param otherSize size to add to this size
  72495. * @returns a new Size set as the addition result of the current Size and the given one.
  72496. */
  72497. Size.prototype.add = function (otherSize) {
  72498. var r = new Size(this.width + otherSize.width, this.height + otherSize.height);
  72499. return r;
  72500. };
  72501. /**
  72502. * Subtracts the width and height of two
  72503. * @param otherSize size to subtract to this size
  72504. * @returns a new Size set as the subtraction result of the given one from the current Size.
  72505. */
  72506. Size.prototype.subtract = function (otherSize) {
  72507. var r = new Size(this.width - otherSize.width, this.height - otherSize.height);
  72508. return r;
  72509. };
  72510. /**
  72511. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  72512. * @param start starting size to lerp between
  72513. * @param end end size to lerp between
  72514. * @param amount amount to lerp between the start and end values
  72515. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  72516. */
  72517. Size.Lerp = function (start, end, amount) {
  72518. var w = start.width + ((end.width - start.width) * amount);
  72519. var h = start.height + ((end.height - start.height) * amount);
  72520. return new Size(w, h);
  72521. };
  72522. return Size;
  72523. }());
  72524. /**
  72525. * Class used to store quaternion data
  72526. * @see https://en.wikipedia.org/wiki/Quaternion
  72527. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  72528. */
  72529. var Quaternion = /** @class */ (function () {
  72530. /**
  72531. * Creates a new Quaternion from the given floats
  72532. * @param x defines the first component (0 by default)
  72533. * @param y defines the second component (0 by default)
  72534. * @param z defines the third component (0 by default)
  72535. * @param w defines the fourth component (1.0 by default)
  72536. */
  72537. function Quaternion(
  72538. /** defines the first component (0 by default) */
  72539. x,
  72540. /** defines the second component (0 by default) */
  72541. y,
  72542. /** defines the third component (0 by default) */
  72543. z,
  72544. /** defines the fourth component (1.0 by default) */
  72545. w) {
  72546. if (x === void 0) { x = 0.0; }
  72547. if (y === void 0) { y = 0.0; }
  72548. if (z === void 0) { z = 0.0; }
  72549. if (w === void 0) { w = 1.0; }
  72550. this.x = x;
  72551. this.y = y;
  72552. this.z = z;
  72553. this.w = w;
  72554. }
  72555. /**
  72556. * Gets a string representation for the current quaternion
  72557. * @returns a string with the Quaternion coordinates
  72558. */
  72559. Quaternion.prototype.toString = function () {
  72560. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + " W:" + this.w + "}";
  72561. };
  72562. /**
  72563. * Gets the class name of the quaternion
  72564. * @returns the string "Quaternion"
  72565. */
  72566. Quaternion.prototype.getClassName = function () {
  72567. return "Quaternion";
  72568. };
  72569. /**
  72570. * Gets a hash code for this quaternion
  72571. * @returns the quaternion hash code
  72572. */
  72573. Quaternion.prototype.getHashCode = function () {
  72574. var hash = this.x || 0;
  72575. hash = (hash * 397) ^ (this.y || 0);
  72576. hash = (hash * 397) ^ (this.z || 0);
  72577. hash = (hash * 397) ^ (this.w || 0);
  72578. return hash;
  72579. };
  72580. /**
  72581. * Copy the quaternion to an array
  72582. * @returns a new array populated with 4 elements from the quaternion coordinates
  72583. */
  72584. Quaternion.prototype.asArray = function () {
  72585. return [this.x, this.y, this.z, this.w];
  72586. };
  72587. /**
  72588. * Check if two quaternions are equals
  72589. * @param otherQuaternion defines the second operand
  72590. * @return true if the current quaternion and the given one coordinates are strictly equals
  72591. */
  72592. Quaternion.prototype.equals = function (otherQuaternion) {
  72593. return otherQuaternion && this.x === otherQuaternion.x && this.y === otherQuaternion.y && this.z === otherQuaternion.z && this.w === otherQuaternion.w;
  72594. };
  72595. /**
  72596. * Clone the current quaternion
  72597. * @returns a new quaternion copied from the current one
  72598. */
  72599. Quaternion.prototype.clone = function () {
  72600. return new Quaternion(this.x, this.y, this.z, this.w);
  72601. };
  72602. /**
  72603. * Copy a quaternion to the current one
  72604. * @param other defines the other quaternion
  72605. * @returns the updated current quaternion
  72606. */
  72607. Quaternion.prototype.copyFrom = function (other) {
  72608. this.x = other.x;
  72609. this.y = other.y;
  72610. this.z = other.z;
  72611. this.w = other.w;
  72612. return this;
  72613. };
  72614. /**
  72615. * Updates the current quaternion with the given float coordinates
  72616. * @param x defines the x coordinate
  72617. * @param y defines the y coordinate
  72618. * @param z defines the z coordinate
  72619. * @param w defines the w coordinate
  72620. * @returns the updated current quaternion
  72621. */
  72622. Quaternion.prototype.copyFromFloats = function (x, y, z, w) {
  72623. this.x = x;
  72624. this.y = y;
  72625. this.z = z;
  72626. this.w = w;
  72627. return this;
  72628. };
  72629. /**
  72630. * Updates the current quaternion from the given float coordinates
  72631. * @param x defines the x coordinate
  72632. * @param y defines the y coordinate
  72633. * @param z defines the z coordinate
  72634. * @param w defines the w coordinate
  72635. * @returns the updated current quaternion
  72636. */
  72637. Quaternion.prototype.set = function (x, y, z, w) {
  72638. return this.copyFromFloats(x, y, z, w);
  72639. };
  72640. /**
  72641. * Adds two quaternions
  72642. * @param other defines the second operand
  72643. * @returns a new quaternion as the addition result of the given one and the current quaternion
  72644. */
  72645. Quaternion.prototype.add = function (other) {
  72646. return new Quaternion(this.x + other.x, this.y + other.y, this.z + other.z, this.w + other.w);
  72647. };
  72648. /**
  72649. * Add a quaternion to the current one
  72650. * @param other defines the quaternion to add
  72651. * @returns the current quaternion
  72652. */
  72653. Quaternion.prototype.addInPlace = function (other) {
  72654. this.x += other.x;
  72655. this.y += other.y;
  72656. this.z += other.z;
  72657. this.w += other.w;
  72658. return this;
  72659. };
  72660. /**
  72661. * Subtract two quaternions
  72662. * @param other defines the second operand
  72663. * @returns a new quaternion as the subtraction result of the given one from the current one
  72664. */
  72665. Quaternion.prototype.subtract = function (other) {
  72666. return new Quaternion(this.x - other.x, this.y - other.y, this.z - other.z, this.w - other.w);
  72667. };
  72668. /**
  72669. * Multiplies the current quaternion by a scale factor
  72670. * @param value defines the scale factor
  72671. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  72672. */
  72673. Quaternion.prototype.scale = function (value) {
  72674. return new Quaternion(this.x * value, this.y * value, this.z * value, this.w * value);
  72675. };
  72676. /**
  72677. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  72678. * @param scale defines the scale factor
  72679. * @param result defines the Quaternion object where to store the result
  72680. * @returns the unmodified current quaternion
  72681. */
  72682. Quaternion.prototype.scaleToRef = function (scale, result) {
  72683. result.x = this.x * scale;
  72684. result.y = this.y * scale;
  72685. result.z = this.z * scale;
  72686. result.w = this.w * scale;
  72687. return this;
  72688. };
  72689. /**
  72690. * Multiplies in place the current quaternion by a scale factor
  72691. * @param value defines the scale factor
  72692. * @returns the current modified quaternion
  72693. */
  72694. Quaternion.prototype.scaleInPlace = function (value) {
  72695. this.x *= value;
  72696. this.y *= value;
  72697. this.z *= value;
  72698. this.w *= value;
  72699. return this;
  72700. };
  72701. /**
  72702. * Scale the current quaternion values by a factor and add the result to a given quaternion
  72703. * @param scale defines the scale factor
  72704. * @param result defines the Quaternion object where to store the result
  72705. * @returns the unmodified current quaternion
  72706. */
  72707. Quaternion.prototype.scaleAndAddToRef = function (scale, result) {
  72708. result.x += this.x * scale;
  72709. result.y += this.y * scale;
  72710. result.z += this.z * scale;
  72711. result.w += this.w * scale;
  72712. return this;
  72713. };
  72714. /**
  72715. * Multiplies two quaternions
  72716. * @param q1 defines the second operand
  72717. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  72718. */
  72719. Quaternion.prototype.multiply = function (q1) {
  72720. var result = new Quaternion(0, 0, 0, 1.0);
  72721. this.multiplyToRef(q1, result);
  72722. return result;
  72723. };
  72724. /**
  72725. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  72726. * @param q1 defines the second operand
  72727. * @param result defines the target quaternion
  72728. * @returns the current quaternion
  72729. */
  72730. Quaternion.prototype.multiplyToRef = function (q1, result) {
  72731. var x = this.x * q1.w + this.y * q1.z - this.z * q1.y + this.w * q1.x;
  72732. var y = -this.x * q1.z + this.y * q1.w + this.z * q1.x + this.w * q1.y;
  72733. var z = this.x * q1.y - this.y * q1.x + this.z * q1.w + this.w * q1.z;
  72734. var w = -this.x * q1.x - this.y * q1.y - this.z * q1.z + this.w * q1.w;
  72735. result.copyFromFloats(x, y, z, w);
  72736. return this;
  72737. };
  72738. /**
  72739. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  72740. * @param q1 defines the second operand
  72741. * @returns the currentupdated quaternion
  72742. */
  72743. Quaternion.prototype.multiplyInPlace = function (q1) {
  72744. this.multiplyToRef(q1, this);
  72745. return this;
  72746. };
  72747. /**
  72748. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  72749. * @param ref defines the target quaternion
  72750. * @returns the current quaternion
  72751. */
  72752. Quaternion.prototype.conjugateToRef = function (ref) {
  72753. ref.copyFromFloats(-this.x, -this.y, -this.z, this.w);
  72754. return this;
  72755. };
  72756. /**
  72757. * Conjugates in place (1-q) the current quaternion
  72758. * @returns the current updated quaternion
  72759. */
  72760. Quaternion.prototype.conjugateInPlace = function () {
  72761. this.x *= -1;
  72762. this.y *= -1;
  72763. this.z *= -1;
  72764. return this;
  72765. };
  72766. /**
  72767. * Conjugates in place (1-q) the current quaternion
  72768. * @returns a new quaternion
  72769. */
  72770. Quaternion.prototype.conjugate = function () {
  72771. var result = new Quaternion(-this.x, -this.y, -this.z, this.w);
  72772. return result;
  72773. };
  72774. /**
  72775. * Gets length of current quaternion
  72776. * @returns the quaternion length (float)
  72777. */
  72778. Quaternion.prototype.length = function () {
  72779. return Math.sqrt((this.x * this.x) + (this.y * this.y) + (this.z * this.z) + (this.w * this.w));
  72780. };
  72781. /**
  72782. * Normalize in place the current quaternion
  72783. * @returns the current updated quaternion
  72784. */
  72785. Quaternion.prototype.normalize = function () {
  72786. var length = 1.0 / this.length();
  72787. this.x *= length;
  72788. this.y *= length;
  72789. this.z *= length;
  72790. this.w *= length;
  72791. return this;
  72792. };
  72793. /**
  72794. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  72795. * @param order is a reserved parameter and is ignore for now
  72796. * @returns a new Vector3 containing the Euler angles
  72797. */
  72798. Quaternion.prototype.toEulerAngles = function (order) {
  72799. if (order === void 0) { order = "YZX"; }
  72800. var result = Vector3.Zero();
  72801. this.toEulerAnglesToRef(result);
  72802. return result;
  72803. };
  72804. /**
  72805. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  72806. * @param result defines the vector which will be filled with the Euler angles
  72807. * @param order is a reserved parameter and is ignore for now
  72808. * @returns the current unchanged quaternion
  72809. */
  72810. Quaternion.prototype.toEulerAnglesToRef = function (result) {
  72811. var qz = this.z;
  72812. var qx = this.x;
  72813. var qy = this.y;
  72814. var qw = this.w;
  72815. var sqw = qw * qw;
  72816. var sqz = qz * qz;
  72817. var sqx = qx * qx;
  72818. var sqy = qy * qy;
  72819. var zAxisY = qy * qz - qx * qw;
  72820. var limit = .4999999;
  72821. if (zAxisY < -limit) {
  72822. result.y = 2 * Math.atan2(qy, qw);
  72823. result.x = Math.PI / 2;
  72824. result.z = 0;
  72825. }
  72826. else if (zAxisY > limit) {
  72827. result.y = 2 * Math.atan2(qy, qw);
  72828. result.x = -Math.PI / 2;
  72829. result.z = 0;
  72830. }
  72831. else {
  72832. result.z = Math.atan2(2.0 * (qx * qy + qz * qw), (-sqz - sqx + sqy + sqw));
  72833. result.x = Math.asin(-2.0 * (qz * qy - qx * qw));
  72834. result.y = Math.atan2(2.0 * (qz * qx + qy * qw), (sqz - sqx - sqy + sqw));
  72835. }
  72836. return this;
  72837. };
  72838. /**
  72839. * Updates the given rotation matrix with the current quaternion values
  72840. * @param result defines the target matrix
  72841. * @returns the current unchanged quaternion
  72842. */
  72843. Quaternion.prototype.toRotationMatrix = function (result) {
  72844. Matrix.FromQuaternionToRef(this, result);
  72845. return this;
  72846. };
  72847. /**
  72848. * Updates the current quaternion from the given rotation matrix values
  72849. * @param matrix defines the source matrix
  72850. * @returns the current updated quaternion
  72851. */
  72852. Quaternion.prototype.fromRotationMatrix = function (matrix) {
  72853. Quaternion.FromRotationMatrixToRef(matrix, this);
  72854. return this;
  72855. };
  72856. // Statics
  72857. /**
  72858. * Creates a new quaternion from a rotation matrix
  72859. * @param matrix defines the source matrix
  72860. * @returns a new quaternion created from the given rotation matrix values
  72861. */
  72862. Quaternion.FromRotationMatrix = function (matrix) {
  72863. var result = new Quaternion();
  72864. Quaternion.FromRotationMatrixToRef(matrix, result);
  72865. return result;
  72866. };
  72867. /**
  72868. * Updates the given quaternion with the given rotation matrix values
  72869. * @param matrix defines the source matrix
  72870. * @param result defines the target quaternion
  72871. */
  72872. Quaternion.FromRotationMatrixToRef = function (matrix, result) {
  72873. var data = matrix.m;
  72874. var m11 = data[0], m12 = data[4], m13 = data[8];
  72875. var m21 = data[1], m22 = data[5], m23 = data[9];
  72876. var m31 = data[2], m32 = data[6], m33 = data[10];
  72877. var trace = m11 + m22 + m33;
  72878. var s;
  72879. if (trace > 0) {
  72880. s = 0.5 / Math.sqrt(trace + 1.0);
  72881. result.w = 0.25 / s;
  72882. result.x = (m32 - m23) * s;
  72883. result.y = (m13 - m31) * s;
  72884. result.z = (m21 - m12) * s;
  72885. }
  72886. else if (m11 > m22 && m11 > m33) {
  72887. s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m33);
  72888. result.w = (m32 - m23) / s;
  72889. result.x = 0.25 * s;
  72890. result.y = (m12 + m21) / s;
  72891. result.z = (m13 + m31) / s;
  72892. }
  72893. else if (m22 > m33) {
  72894. s = 2.0 * Math.sqrt(1.0 + m22 - m11 - m33);
  72895. result.w = (m13 - m31) / s;
  72896. result.x = (m12 + m21) / s;
  72897. result.y = 0.25 * s;
  72898. result.z = (m23 + m32) / s;
  72899. }
  72900. else {
  72901. s = 2.0 * Math.sqrt(1.0 + m33 - m11 - m22);
  72902. result.w = (m21 - m12) / s;
  72903. result.x = (m13 + m31) / s;
  72904. result.y = (m23 + m32) / s;
  72905. result.z = 0.25 * s;
  72906. }
  72907. };
  72908. /**
  72909. * Returns the dot product (float) between the quaternions "left" and "right"
  72910. * @param left defines the left operand
  72911. * @param right defines the right operand
  72912. * @returns the dot product
  72913. */
  72914. Quaternion.Dot = function (left, right) {
  72915. return (left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w);
  72916. };
  72917. /**
  72918. * Checks if the two quaternions are close to each other
  72919. * @param quat0 defines the first quaternion to check
  72920. * @param quat1 defines the second quaternion to check
  72921. * @returns true if the two quaternions are close to each other
  72922. */
  72923. Quaternion.AreClose = function (quat0, quat1) {
  72924. var dot = Quaternion.Dot(quat0, quat1);
  72925. return dot >= 0;
  72926. };
  72927. /**
  72928. * Creates an empty quaternion
  72929. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  72930. */
  72931. Quaternion.Zero = function () {
  72932. return new Quaternion(0.0, 0.0, 0.0, 0.0);
  72933. };
  72934. /**
  72935. * Inverse a given quaternion
  72936. * @param q defines the source quaternion
  72937. * @returns a new quaternion as the inverted current quaternion
  72938. */
  72939. Quaternion.Inverse = function (q) {
  72940. return new Quaternion(-q.x, -q.y, -q.z, q.w);
  72941. };
  72942. /**
  72943. * Inverse a given quaternion
  72944. * @param q defines the source quaternion
  72945. * @param result the quaternion the result will be stored in
  72946. * @returns the result quaternion
  72947. */
  72948. Quaternion.InverseToRef = function (q, result) {
  72949. result.set(-q.x, -q.y, -q.z, q.w);
  72950. return result;
  72951. };
  72952. /**
  72953. * Creates an identity quaternion
  72954. * @returns the identity quaternion
  72955. */
  72956. Quaternion.Identity = function () {
  72957. return new Quaternion(0.0, 0.0, 0.0, 1.0);
  72958. };
  72959. /**
  72960. * Gets a boolean indicating if the given quaternion is identity
  72961. * @param quaternion defines the quaternion to check
  72962. * @returns true if the quaternion is identity
  72963. */
  72964. Quaternion.IsIdentity = function (quaternion) {
  72965. return quaternion && quaternion.x === 0 && quaternion.y === 0 && quaternion.z === 0 && quaternion.w === 1;
  72966. };
  72967. /**
  72968. * Creates a quaternion from a rotation around an axis
  72969. * @param axis defines the axis to use
  72970. * @param angle defines the angle to use
  72971. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  72972. */
  72973. Quaternion.RotationAxis = function (axis, angle) {
  72974. return Quaternion.RotationAxisToRef(axis, angle, new Quaternion());
  72975. };
  72976. /**
  72977. * Creates a rotation around an axis and stores it into the given quaternion
  72978. * @param axis defines the axis to use
  72979. * @param angle defines the angle to use
  72980. * @param result defines the target quaternion
  72981. * @returns the target quaternion
  72982. */
  72983. Quaternion.RotationAxisToRef = function (axis, angle, result) {
  72984. var sin = Math.sin(angle / 2);
  72985. axis.normalize();
  72986. result.w = Math.cos(angle / 2);
  72987. result.x = axis.x * sin;
  72988. result.y = axis.y * sin;
  72989. result.z = axis.z * sin;
  72990. return result;
  72991. };
  72992. /**
  72993. * Creates a new quaternion from data stored into an array
  72994. * @param array defines the data source
  72995. * @param offset defines the offset in the source array where the data starts
  72996. * @returns a new quaternion
  72997. */
  72998. Quaternion.FromArray = function (array, offset) {
  72999. if (!offset) {
  73000. offset = 0;
  73001. }
  73002. return new Quaternion(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  73003. };
  73004. /**
  73005. * Create a quaternion from Euler rotation angles
  73006. * @param x Pitch
  73007. * @param y Yaw
  73008. * @param z Roll
  73009. * @returns the new Quaternion
  73010. */
  73011. Quaternion.FromEulerAngles = function (x, y, z) {
  73012. var q = new Quaternion();
  73013. Quaternion.RotationYawPitchRollToRef(y, x, z, q);
  73014. return q;
  73015. };
  73016. /**
  73017. * Updates a quaternion from Euler rotation angles
  73018. * @param x Pitch
  73019. * @param y Yaw
  73020. * @param z Roll
  73021. * @param result the quaternion to store the result
  73022. * @returns the updated quaternion
  73023. */
  73024. Quaternion.FromEulerAnglesToRef = function (x, y, z, result) {
  73025. Quaternion.RotationYawPitchRollToRef(y, x, z, result);
  73026. return result;
  73027. };
  73028. /**
  73029. * Create a quaternion from Euler rotation vector
  73030. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  73031. * @returns the new Quaternion
  73032. */
  73033. Quaternion.FromEulerVector = function (vec) {
  73034. var q = new Quaternion();
  73035. Quaternion.RotationYawPitchRollToRef(vec.y, vec.x, vec.z, q);
  73036. return q;
  73037. };
  73038. /**
  73039. * Updates a quaternion from Euler rotation vector
  73040. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  73041. * @param result the quaternion to store the result
  73042. * @returns the updated quaternion
  73043. */
  73044. Quaternion.FromEulerVectorToRef = function (vec, result) {
  73045. Quaternion.RotationYawPitchRollToRef(vec.y, vec.x, vec.z, result);
  73046. return result;
  73047. };
  73048. /**
  73049. * Creates a new quaternion from the given Euler float angles (y, x, z)
  73050. * @param yaw defines the rotation around Y axis
  73051. * @param pitch defines the rotation around X axis
  73052. * @param roll defines the rotation around Z axis
  73053. * @returns the new quaternion
  73054. */
  73055. Quaternion.RotationYawPitchRoll = function (yaw, pitch, roll) {
  73056. var q = new Quaternion();
  73057. Quaternion.RotationYawPitchRollToRef(yaw, pitch, roll, q);
  73058. return q;
  73059. };
  73060. /**
  73061. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  73062. * @param yaw defines the rotation around Y axis
  73063. * @param pitch defines the rotation around X axis
  73064. * @param roll defines the rotation around Z axis
  73065. * @param result defines the target quaternion
  73066. */
  73067. Quaternion.RotationYawPitchRollToRef = function (yaw, pitch, roll, result) {
  73068. // Produces a quaternion from Euler angles in the z-y-x orientation (Tait-Bryan angles)
  73069. var halfRoll = roll * 0.5;
  73070. var halfPitch = pitch * 0.5;
  73071. var halfYaw = yaw * 0.5;
  73072. var sinRoll = Math.sin(halfRoll);
  73073. var cosRoll = Math.cos(halfRoll);
  73074. var sinPitch = Math.sin(halfPitch);
  73075. var cosPitch = Math.cos(halfPitch);
  73076. var sinYaw = Math.sin(halfYaw);
  73077. var cosYaw = Math.cos(halfYaw);
  73078. result.x = (cosYaw * sinPitch * cosRoll) + (sinYaw * cosPitch * sinRoll);
  73079. result.y = (sinYaw * cosPitch * cosRoll) - (cosYaw * sinPitch * sinRoll);
  73080. result.z = (cosYaw * cosPitch * sinRoll) - (sinYaw * sinPitch * cosRoll);
  73081. result.w = (cosYaw * cosPitch * cosRoll) + (sinYaw * sinPitch * sinRoll);
  73082. };
  73083. /**
  73084. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  73085. * @param alpha defines the rotation around first axis
  73086. * @param beta defines the rotation around second axis
  73087. * @param gamma defines the rotation around third axis
  73088. * @returns the new quaternion
  73089. */
  73090. Quaternion.RotationAlphaBetaGamma = function (alpha, beta, gamma) {
  73091. var result = new Quaternion();
  73092. Quaternion.RotationAlphaBetaGammaToRef(alpha, beta, gamma, result);
  73093. return result;
  73094. };
  73095. /**
  73096. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  73097. * @param alpha defines the rotation around first axis
  73098. * @param beta defines the rotation around second axis
  73099. * @param gamma defines the rotation around third axis
  73100. * @param result defines the target quaternion
  73101. */
  73102. Quaternion.RotationAlphaBetaGammaToRef = function (alpha, beta, gamma, result) {
  73103. // Produces a quaternion from Euler angles in the z-x-z orientation
  73104. var halfGammaPlusAlpha = (gamma + alpha) * 0.5;
  73105. var halfGammaMinusAlpha = (gamma - alpha) * 0.5;
  73106. var halfBeta = beta * 0.5;
  73107. result.x = Math.cos(halfGammaMinusAlpha) * Math.sin(halfBeta);
  73108. result.y = Math.sin(halfGammaMinusAlpha) * Math.sin(halfBeta);
  73109. result.z = Math.sin(halfGammaPlusAlpha) * Math.cos(halfBeta);
  73110. result.w = Math.cos(halfGammaPlusAlpha) * Math.cos(halfBeta);
  73111. };
  73112. /**
  73113. * 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)
  73114. * @param axis1 defines the first axis
  73115. * @param axis2 defines the second axis
  73116. * @param axis3 defines the third axis
  73117. * @returns the new quaternion
  73118. */
  73119. Quaternion.RotationQuaternionFromAxis = function (axis1, axis2, axis3) {
  73120. var quat = new Quaternion(0.0, 0.0, 0.0, 0.0);
  73121. Quaternion.RotationQuaternionFromAxisToRef(axis1, axis2, axis3, quat);
  73122. return quat;
  73123. };
  73124. /**
  73125. * 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
  73126. * @param axis1 defines the first axis
  73127. * @param axis2 defines the second axis
  73128. * @param axis3 defines the third axis
  73129. * @param ref defines the target quaternion
  73130. */
  73131. Quaternion.RotationQuaternionFromAxisToRef = function (axis1, axis2, axis3, ref) {
  73132. var rotMat = MathTmp.Matrix[0];
  73133. Matrix.FromXYZAxesToRef(axis1.normalize(), axis2.normalize(), axis3.normalize(), rotMat);
  73134. Quaternion.FromRotationMatrixToRef(rotMat, ref);
  73135. };
  73136. /**
  73137. * Interpolates between two quaternions
  73138. * @param left defines first quaternion
  73139. * @param right defines second quaternion
  73140. * @param amount defines the gradient to use
  73141. * @returns the new interpolated quaternion
  73142. */
  73143. Quaternion.Slerp = function (left, right, amount) {
  73144. var result = Quaternion.Identity();
  73145. Quaternion.SlerpToRef(left, right, amount, result);
  73146. return result;
  73147. };
  73148. /**
  73149. * Interpolates between two quaternions and stores it into a target quaternion
  73150. * @param left defines first quaternion
  73151. * @param right defines second quaternion
  73152. * @param amount defines the gradient to use
  73153. * @param result defines the target quaternion
  73154. */
  73155. Quaternion.SlerpToRef = function (left, right, amount, result) {
  73156. var num2;
  73157. var num3;
  73158. var num4 = (((left.x * right.x) + (left.y * right.y)) + (left.z * right.z)) + (left.w * right.w);
  73159. var flag = false;
  73160. if (num4 < 0) {
  73161. flag = true;
  73162. num4 = -num4;
  73163. }
  73164. if (num4 > 0.999999) {
  73165. num3 = 1 - amount;
  73166. num2 = flag ? -amount : amount;
  73167. }
  73168. else {
  73169. var num5 = Math.acos(num4);
  73170. var num6 = (1.0 / Math.sin(num5));
  73171. num3 = (Math.sin((1.0 - amount) * num5)) * num6;
  73172. num2 = flag ? ((-Math.sin(amount * num5)) * num6) : ((Math.sin(amount * num5)) * num6);
  73173. }
  73174. result.x = (num3 * left.x) + (num2 * right.x);
  73175. result.y = (num3 * left.y) + (num2 * right.y);
  73176. result.z = (num3 * left.z) + (num2 * right.z);
  73177. result.w = (num3 * left.w) + (num2 * right.w);
  73178. };
  73179. /**
  73180. * Interpolate between two quaternions using Hermite interpolation
  73181. * @param value1 defines first quaternion
  73182. * @param tangent1 defines the incoming tangent
  73183. * @param value2 defines second quaternion
  73184. * @param tangent2 defines the outgoing tangent
  73185. * @param amount defines the target quaternion
  73186. * @returns the new interpolated quaternion
  73187. */
  73188. Quaternion.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  73189. var squared = amount * amount;
  73190. var cubed = amount * squared;
  73191. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  73192. var part2 = (-2.0 * cubed) + (3.0 * squared);
  73193. var part3 = (cubed - (2.0 * squared)) + amount;
  73194. var part4 = cubed - squared;
  73195. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  73196. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  73197. var z = (((value1.z * part1) + (value2.z * part2)) + (tangent1.z * part3)) + (tangent2.z * part4);
  73198. var w = (((value1.w * part1) + (value2.w * part2)) + (tangent1.w * part3)) + (tangent2.w * part4);
  73199. return new Quaternion(x, y, z, w);
  73200. };
  73201. return Quaternion;
  73202. }());
  73203. /**
  73204. * Class used to store matrix data (4x4)
  73205. */
  73206. var Matrix = /** @class */ (function () {
  73207. /**
  73208. * Creates an empty matrix (filled with zeros)
  73209. */
  73210. function Matrix() {
  73211. this._isIdentity = false;
  73212. this._isIdentityDirty = true;
  73213. this._isIdentity3x2 = true;
  73214. this._isIdentity3x2Dirty = true;
  73215. this._m = new Float32Array(16);
  73216. this._updateIdentityStatus(false);
  73217. }
  73218. Object.defineProperty(Matrix.prototype, "m", {
  73219. /**
  73220. * Gets the internal data of the matrix
  73221. */
  73222. get: function () { return this._m; },
  73223. enumerable: true,
  73224. configurable: true
  73225. });
  73226. /** @hidden */
  73227. Matrix.prototype._markAsUpdated = function () {
  73228. this.updateFlag = Matrix._updateFlagSeed++;
  73229. this._isIdentity = false;
  73230. this._isIdentity3x2 = false;
  73231. this._isIdentityDirty = true;
  73232. this._isIdentity3x2Dirty = true;
  73233. };
  73234. /** @hidden */
  73235. Matrix.prototype._updateIdentityStatus = function (isIdentity, isIdentityDirty, isIdentity3x2, isIdentity3x2Dirty) {
  73236. if (isIdentityDirty === void 0) { isIdentityDirty = false; }
  73237. if (isIdentity3x2 === void 0) { isIdentity3x2 = false; }
  73238. if (isIdentity3x2Dirty === void 0) { isIdentity3x2Dirty = true; }
  73239. this.updateFlag = Matrix._updateFlagSeed++;
  73240. this._isIdentity = isIdentity;
  73241. this._isIdentity3x2 = isIdentity || isIdentity3x2;
  73242. this._isIdentityDirty = this._isIdentity ? false : isIdentityDirty;
  73243. this._isIdentity3x2Dirty = this._isIdentity3x2 ? false : isIdentity3x2Dirty;
  73244. };
  73245. // Properties
  73246. /**
  73247. * Check if the current matrix is identity
  73248. * @returns true is the matrix is the identity matrix
  73249. */
  73250. Matrix.prototype.isIdentity = function () {
  73251. if (this._isIdentityDirty) {
  73252. this._isIdentityDirty = false;
  73253. var m = this._m;
  73254. this._isIdentity = (m[0] === 1.0 && m[1] === 0.0 && m[2] === 0.0 && m[3] === 0.0 &&
  73255. m[4] === 0.0 && m[5] === 1.0 && m[6] === 0.0 && m[7] === 0.0 &&
  73256. m[8] === 0.0 && m[9] === 0.0 && m[10] === 1.0 && m[11] === 0.0 &&
  73257. m[12] === 0.0 && m[13] === 0.0 && m[14] === 0.0 && m[15] === 1.0);
  73258. }
  73259. return this._isIdentity;
  73260. };
  73261. /**
  73262. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  73263. * @returns true is the matrix is the identity matrix
  73264. */
  73265. Matrix.prototype.isIdentityAs3x2 = function () {
  73266. if (this._isIdentity3x2Dirty) {
  73267. this._isIdentity3x2Dirty = false;
  73268. if (this._m[0] !== 1.0 || this._m[5] !== 1.0 || this._m[15] !== 1.0) {
  73269. this._isIdentity3x2 = false;
  73270. }
  73271. else if (this._m[1] !== 0.0 || this._m[2] !== 0.0 || this._m[3] !== 0.0 ||
  73272. this._m[4] !== 0.0 || this._m[6] !== 0.0 || this._m[7] !== 0.0 ||
  73273. this._m[8] !== 0.0 || this._m[9] !== 0.0 || this._m[10] !== 0.0 || this._m[11] !== 0.0 ||
  73274. this._m[12] !== 0.0 || this._m[13] !== 0.0 || this._m[14] !== 0.0) {
  73275. this._isIdentity3x2 = false;
  73276. }
  73277. else {
  73278. this._isIdentity3x2 = true;
  73279. }
  73280. }
  73281. return this._isIdentity3x2;
  73282. };
  73283. /**
  73284. * Gets the determinant of the matrix
  73285. * @returns the matrix determinant
  73286. */
  73287. Matrix.prototype.determinant = function () {
  73288. if (this._isIdentity === true) {
  73289. return 1;
  73290. }
  73291. var m = this._m;
  73292. var m00 = m[0], m01 = m[1], m02 = m[2], m03 = m[3];
  73293. var m10 = m[4], m11 = m[5], m12 = m[6], m13 = m[7];
  73294. var m20 = m[8], m21 = m[9], m22 = m[10], m23 = m[11];
  73295. var m30 = m[12], m31 = m[13], m32 = m[14], m33 = m[15];
  73296. // https://en.wikipedia.org/wiki/Laplace_expansion
  73297. // to compute the deterrminant of a 4x4 Matrix we compute the cofactors of any row or column,
  73298. // then we multiply each Cofactor by its corresponding matrix value and sum them all to get the determinant
  73299. // Cofactor(i, j) = sign(i,j) * det(Minor(i, j))
  73300. // where
  73301. // - sign(i,j) = (i+j) % 2 === 0 ? 1 : -1
  73302. // - Minor(i, j) is the 3x3 matrix we get by removing row i and column j from current Matrix
  73303. //
  73304. // Here we do that for the 1st row.
  73305. var det_22_33 = m22 * m33 - m32 * m23;
  73306. var det_21_33 = m21 * m33 - m31 * m23;
  73307. var det_21_32 = m21 * m32 - m31 * m22;
  73308. var det_20_33 = m20 * m33 - m30 * m23;
  73309. var det_20_32 = m20 * m32 - m22 * m30;
  73310. var det_20_31 = m20 * m31 - m30 * m21;
  73311. var cofact_00 = +(m11 * det_22_33 - m12 * det_21_33 + m13 * det_21_32);
  73312. var cofact_01 = -(m10 * det_22_33 - m12 * det_20_33 + m13 * det_20_32);
  73313. var cofact_02 = +(m10 * det_21_33 - m11 * det_20_33 + m13 * det_20_31);
  73314. var cofact_03 = -(m10 * det_21_32 - m11 * det_20_32 + m12 * det_20_31);
  73315. return m00 * cofact_00 + m01 * cofact_01 + m02 * cofact_02 + m03 * cofact_03;
  73316. };
  73317. // Methods
  73318. /**
  73319. * Returns the matrix as a Float32Array
  73320. * @returns the matrix underlying array
  73321. */
  73322. Matrix.prototype.toArray = function () {
  73323. return this._m;
  73324. };
  73325. /**
  73326. * Returns the matrix as a Float32Array
  73327. * @returns the matrix underlying array.
  73328. */
  73329. Matrix.prototype.asArray = function () {
  73330. return this._m;
  73331. };
  73332. /**
  73333. * Inverts the current matrix in place
  73334. * @returns the current inverted matrix
  73335. */
  73336. Matrix.prototype.invert = function () {
  73337. this.invertToRef(this);
  73338. return this;
  73339. };
  73340. /**
  73341. * Sets all the matrix elements to zero
  73342. * @returns the current matrix
  73343. */
  73344. Matrix.prototype.reset = function () {
  73345. 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);
  73346. this._updateIdentityStatus(false);
  73347. return this;
  73348. };
  73349. /**
  73350. * Adds the current matrix with a second one
  73351. * @param other defines the matrix to add
  73352. * @returns a new matrix as the addition of the current matrix and the given one
  73353. */
  73354. Matrix.prototype.add = function (other) {
  73355. var result = new Matrix();
  73356. this.addToRef(other, result);
  73357. return result;
  73358. };
  73359. /**
  73360. * Sets the given matrix "result" to the addition of the current matrix and the given one
  73361. * @param other defines the matrix to add
  73362. * @param result defines the target matrix
  73363. * @returns the current matrix
  73364. */
  73365. Matrix.prototype.addToRef = function (other, result) {
  73366. var m = this._m;
  73367. var resultM = result._m;
  73368. var otherM = other.m;
  73369. for (var index = 0; index < 16; index++) {
  73370. resultM[index] = m[index] + otherM[index];
  73371. }
  73372. result._markAsUpdated();
  73373. return this;
  73374. };
  73375. /**
  73376. * Adds in place the given matrix to the current matrix
  73377. * @param other defines the second operand
  73378. * @returns the current updated matrix
  73379. */
  73380. Matrix.prototype.addToSelf = function (other) {
  73381. var m = this._m;
  73382. var otherM = other.m;
  73383. for (var index = 0; index < 16; index++) {
  73384. m[index] += otherM[index];
  73385. }
  73386. this._markAsUpdated();
  73387. return this;
  73388. };
  73389. /**
  73390. * Sets the given matrix to the current inverted Matrix
  73391. * @param other defines the target matrix
  73392. * @returns the unmodified current matrix
  73393. */
  73394. Matrix.prototype.invertToRef = function (other) {
  73395. if (this._isIdentity === true) {
  73396. Matrix.IdentityToRef(other);
  73397. return this;
  73398. }
  73399. // the inverse of a Matrix is the transpose of cofactor matrix divided by the determinant
  73400. var m = this._m;
  73401. var m00 = m[0], m01 = m[1], m02 = m[2], m03 = m[3];
  73402. var m10 = m[4], m11 = m[5], m12 = m[6], m13 = m[7];
  73403. var m20 = m[8], m21 = m[9], m22 = m[10], m23 = m[11];
  73404. var m30 = m[12], m31 = m[13], m32 = m[14], m33 = m[15];
  73405. var det_22_33 = m22 * m33 - m32 * m23;
  73406. var det_21_33 = m21 * m33 - m31 * m23;
  73407. var det_21_32 = m21 * m32 - m31 * m22;
  73408. var det_20_33 = m20 * m33 - m30 * m23;
  73409. var det_20_32 = m20 * m32 - m22 * m30;
  73410. var det_20_31 = m20 * m31 - m30 * m21;
  73411. var cofact_00 = +(m11 * det_22_33 - m12 * det_21_33 + m13 * det_21_32);
  73412. var cofact_01 = -(m10 * det_22_33 - m12 * det_20_33 + m13 * det_20_32);
  73413. var cofact_02 = +(m10 * det_21_33 - m11 * det_20_33 + m13 * det_20_31);
  73414. var cofact_03 = -(m10 * det_21_32 - m11 * det_20_32 + m12 * det_20_31);
  73415. var det = m00 * cofact_00 + m01 * cofact_01 + m02 * cofact_02 + m03 * cofact_03;
  73416. if (det === 0) {
  73417. // not invertible
  73418. other.copyFrom(this);
  73419. return this;
  73420. }
  73421. var detInv = 1 / det;
  73422. var det_12_33 = m12 * m33 - m32 * m13;
  73423. var det_11_33 = m11 * m33 - m31 * m13;
  73424. var det_11_32 = m11 * m32 - m31 * m12;
  73425. var det_10_33 = m10 * m33 - m30 * m13;
  73426. var det_10_32 = m10 * m32 - m30 * m12;
  73427. var det_10_31 = m10 * m31 - m30 * m11;
  73428. var det_12_23 = m12 * m23 - m22 * m13;
  73429. var det_11_23 = m11 * m23 - m21 * m13;
  73430. var det_11_22 = m11 * m22 - m21 * m12;
  73431. var det_10_23 = m10 * m23 - m20 * m13;
  73432. var det_10_22 = m10 * m22 - m20 * m12;
  73433. var det_10_21 = m10 * m21 - m20 * m11;
  73434. var cofact_10 = -(m01 * det_22_33 - m02 * det_21_33 + m03 * det_21_32);
  73435. var cofact_11 = +(m00 * det_22_33 - m02 * det_20_33 + m03 * det_20_32);
  73436. var cofact_12 = -(m00 * det_21_33 - m01 * det_20_33 + m03 * det_20_31);
  73437. var cofact_13 = +(m00 * det_21_32 - m01 * det_20_32 + m02 * det_20_31);
  73438. var cofact_20 = +(m01 * det_12_33 - m02 * det_11_33 + m03 * det_11_32);
  73439. var cofact_21 = -(m00 * det_12_33 - m02 * det_10_33 + m03 * det_10_32);
  73440. var cofact_22 = +(m00 * det_11_33 - m01 * det_10_33 + m03 * det_10_31);
  73441. var cofact_23 = -(m00 * det_11_32 - m01 * det_10_32 + m02 * det_10_31);
  73442. var cofact_30 = -(m01 * det_12_23 - m02 * det_11_23 + m03 * det_11_22);
  73443. var cofact_31 = +(m00 * det_12_23 - m02 * det_10_23 + m03 * det_10_22);
  73444. var cofact_32 = -(m00 * det_11_23 - m01 * det_10_23 + m03 * det_10_21);
  73445. var cofact_33 = +(m00 * det_11_22 - m01 * det_10_22 + m02 * det_10_21);
  73446. 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);
  73447. return this;
  73448. };
  73449. /**
  73450. * add a value at the specified position in the current Matrix
  73451. * @param index the index of the value within the matrix. between 0 and 15.
  73452. * @param value the value to be added
  73453. * @returns the current updated matrix
  73454. */
  73455. Matrix.prototype.addAtIndex = function (index, value) {
  73456. this._m[index] += value;
  73457. this._markAsUpdated();
  73458. return this;
  73459. };
  73460. /**
  73461. * mutiply the specified position in the current Matrix by a value
  73462. * @param index the index of the value within the matrix. between 0 and 15.
  73463. * @param value the value to be added
  73464. * @returns the current updated matrix
  73465. */
  73466. Matrix.prototype.multiplyAtIndex = function (index, value) {
  73467. this._m[index] *= value;
  73468. this._markAsUpdated();
  73469. return this;
  73470. };
  73471. /**
  73472. * Inserts the translation vector (using 3 floats) in the current matrix
  73473. * @param x defines the 1st component of the translation
  73474. * @param y defines the 2nd component of the translation
  73475. * @param z defines the 3rd component of the translation
  73476. * @returns the current updated matrix
  73477. */
  73478. Matrix.prototype.setTranslationFromFloats = function (x, y, z) {
  73479. this._m[12] = x;
  73480. this._m[13] = y;
  73481. this._m[14] = z;
  73482. this._markAsUpdated();
  73483. return this;
  73484. };
  73485. /**
  73486. * Inserts the translation vector in the current matrix
  73487. * @param vector3 defines the translation to insert
  73488. * @returns the current updated matrix
  73489. */
  73490. Matrix.prototype.setTranslation = function (vector3) {
  73491. return this.setTranslationFromFloats(vector3.x, vector3.y, vector3.z);
  73492. };
  73493. /**
  73494. * Gets the translation value of the current matrix
  73495. * @returns a new Vector3 as the extracted translation from the matrix
  73496. */
  73497. Matrix.prototype.getTranslation = function () {
  73498. return new Vector3(this._m[12], this._m[13], this._m[14]);
  73499. };
  73500. /**
  73501. * Fill a Vector3 with the extracted translation from the matrix
  73502. * @param result defines the Vector3 where to store the translation
  73503. * @returns the current matrix
  73504. */
  73505. Matrix.prototype.getTranslationToRef = function (result) {
  73506. result.x = this._m[12];
  73507. result.y = this._m[13];
  73508. result.z = this._m[14];
  73509. return this;
  73510. };
  73511. /**
  73512. * Remove rotation and scaling part from the matrix
  73513. * @returns the updated matrix
  73514. */
  73515. Matrix.prototype.removeRotationAndScaling = function () {
  73516. var m = this.m;
  73517. 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);
  73518. this._updateIdentityStatus(m[12] === 0 && m[13] === 0 && m[14] === 0 && m[15] === 1);
  73519. return this;
  73520. };
  73521. /**
  73522. * Multiply two matrices
  73523. * @param other defines the second operand
  73524. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  73525. */
  73526. Matrix.prototype.multiply = function (other) {
  73527. var result = new Matrix();
  73528. this.multiplyToRef(other, result);
  73529. return result;
  73530. };
  73531. /**
  73532. * Copy the current matrix from the given one
  73533. * @param other defines the source matrix
  73534. * @returns the current updated matrix
  73535. */
  73536. Matrix.prototype.copyFrom = function (other) {
  73537. other.copyToArray(this._m);
  73538. var o = other;
  73539. this._updateIdentityStatus(o._isIdentity, o._isIdentityDirty, o._isIdentity3x2, o._isIdentity3x2Dirty);
  73540. return this;
  73541. };
  73542. /**
  73543. * Populates the given array from the starting index with the current matrix values
  73544. * @param array defines the target array
  73545. * @param offset defines the offset in the target array where to start storing values
  73546. * @returns the current matrix
  73547. */
  73548. Matrix.prototype.copyToArray = function (array, offset) {
  73549. if (offset === void 0) { offset = 0; }
  73550. for (var index = 0; index < 16; index++) {
  73551. array[offset + index] = this._m[index];
  73552. }
  73553. return this;
  73554. };
  73555. /**
  73556. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  73557. * @param other defines the second operand
  73558. * @param result defines the matrix where to store the multiplication
  73559. * @returns the current matrix
  73560. */
  73561. Matrix.prototype.multiplyToRef = function (other, result) {
  73562. if (this._isIdentity) {
  73563. result.copyFrom(other);
  73564. return this;
  73565. }
  73566. if (other._isIdentity) {
  73567. result.copyFrom(this);
  73568. return this;
  73569. }
  73570. this.multiplyToArray(other, result._m, 0);
  73571. result._markAsUpdated();
  73572. return this;
  73573. };
  73574. /**
  73575. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  73576. * @param other defines the second operand
  73577. * @param result defines the array where to store the multiplication
  73578. * @param offset defines the offset in the target array where to start storing values
  73579. * @returns the current matrix
  73580. */
  73581. Matrix.prototype.multiplyToArray = function (other, result, offset) {
  73582. var m = this._m;
  73583. var otherM = other.m;
  73584. var tm0 = m[0], tm1 = m[1], tm2 = m[2], tm3 = m[3];
  73585. var tm4 = m[4], tm5 = m[5], tm6 = m[6], tm7 = m[7];
  73586. var tm8 = m[8], tm9 = m[9], tm10 = m[10], tm11 = m[11];
  73587. var tm12 = m[12], tm13 = m[13], tm14 = m[14], tm15 = m[15];
  73588. var om0 = otherM[0], om1 = otherM[1], om2 = otherM[2], om3 = otherM[3];
  73589. var om4 = otherM[4], om5 = otherM[5], om6 = otherM[6], om7 = otherM[7];
  73590. var om8 = otherM[8], om9 = otherM[9], om10 = otherM[10], om11 = otherM[11];
  73591. var om12 = otherM[12], om13 = otherM[13], om14 = otherM[14], om15 = otherM[15];
  73592. result[offset] = tm0 * om0 + tm1 * om4 + tm2 * om8 + tm3 * om12;
  73593. result[offset + 1] = tm0 * om1 + tm1 * om5 + tm2 * om9 + tm3 * om13;
  73594. result[offset + 2] = tm0 * om2 + tm1 * om6 + tm2 * om10 + tm3 * om14;
  73595. result[offset + 3] = tm0 * om3 + tm1 * om7 + tm2 * om11 + tm3 * om15;
  73596. result[offset + 4] = tm4 * om0 + tm5 * om4 + tm6 * om8 + tm7 * om12;
  73597. result[offset + 5] = tm4 * om1 + tm5 * om5 + tm6 * om9 + tm7 * om13;
  73598. result[offset + 6] = tm4 * om2 + tm5 * om6 + tm6 * om10 + tm7 * om14;
  73599. result[offset + 7] = tm4 * om3 + tm5 * om7 + tm6 * om11 + tm7 * om15;
  73600. result[offset + 8] = tm8 * om0 + tm9 * om4 + tm10 * om8 + tm11 * om12;
  73601. result[offset + 9] = tm8 * om1 + tm9 * om5 + tm10 * om9 + tm11 * om13;
  73602. result[offset + 10] = tm8 * om2 + tm9 * om6 + tm10 * om10 + tm11 * om14;
  73603. result[offset + 11] = tm8 * om3 + tm9 * om7 + tm10 * om11 + tm11 * om15;
  73604. result[offset + 12] = tm12 * om0 + tm13 * om4 + tm14 * om8 + tm15 * om12;
  73605. result[offset + 13] = tm12 * om1 + tm13 * om5 + tm14 * om9 + tm15 * om13;
  73606. result[offset + 14] = tm12 * om2 + tm13 * om6 + tm14 * om10 + tm15 * om14;
  73607. result[offset + 15] = tm12 * om3 + tm13 * om7 + tm14 * om11 + tm15 * om15;
  73608. return this;
  73609. };
  73610. /**
  73611. * Check equality between this matrix and a second one
  73612. * @param value defines the second matrix to compare
  73613. * @returns true is the current matrix and the given one values are strictly equal
  73614. */
  73615. Matrix.prototype.equals = function (value) {
  73616. var other = value;
  73617. if (!other) {
  73618. return false;
  73619. }
  73620. if (this._isIdentity || other._isIdentity) {
  73621. if (!this._isIdentityDirty && !other._isIdentityDirty) {
  73622. return this._isIdentity && other._isIdentity;
  73623. }
  73624. }
  73625. var m = this.m;
  73626. var om = other.m;
  73627. return (m[0] === om[0] && m[1] === om[1] && m[2] === om[2] && m[3] === om[3] &&
  73628. m[4] === om[4] && m[5] === om[5] && m[6] === om[6] && m[7] === om[7] &&
  73629. m[8] === om[8] && m[9] === om[9] && m[10] === om[10] && m[11] === om[11] &&
  73630. m[12] === om[12] && m[13] === om[13] && m[14] === om[14] && m[15] === om[15]);
  73631. };
  73632. /**
  73633. * Clone the current matrix
  73634. * @returns a new matrix from the current matrix
  73635. */
  73636. Matrix.prototype.clone = function () {
  73637. var matrix = new Matrix();
  73638. matrix.copyFrom(this);
  73639. return matrix;
  73640. };
  73641. /**
  73642. * Returns the name of the current matrix class
  73643. * @returns the string "Matrix"
  73644. */
  73645. Matrix.prototype.getClassName = function () {
  73646. return "Matrix";
  73647. };
  73648. /**
  73649. * Gets the hash code of the current matrix
  73650. * @returns the hash code
  73651. */
  73652. Matrix.prototype.getHashCode = function () {
  73653. var hash = this._m[0] || 0;
  73654. for (var i = 1; i < 16; i++) {
  73655. hash = (hash * 397) ^ (this._m[i] || 0);
  73656. }
  73657. return hash;
  73658. };
  73659. /**
  73660. * Decomposes the current Matrix into a translation, rotation and scaling components
  73661. * @param scale defines the scale vector3 given as a reference to update
  73662. * @param rotation defines the rotation quaternion given as a reference to update
  73663. * @param translation defines the translation vector3 given as a reference to update
  73664. * @returns true if operation was successful
  73665. */
  73666. Matrix.prototype.decompose = function (scale, rotation, translation) {
  73667. if (this._isIdentity) {
  73668. if (translation) {
  73669. translation.setAll(0);
  73670. }
  73671. if (scale) {
  73672. scale.setAll(1);
  73673. }
  73674. if (rotation) {
  73675. rotation.copyFromFloats(0, 0, 0, 1);
  73676. }
  73677. return true;
  73678. }
  73679. var m = this._m;
  73680. if (translation) {
  73681. translation.copyFromFloats(m[12], m[13], m[14]);
  73682. }
  73683. scale = scale || MathTmp.Vector3[0];
  73684. scale.x = Math.sqrt(m[0] * m[0] + m[1] * m[1] + m[2] * m[2]);
  73685. scale.y = Math.sqrt(m[4] * m[4] + m[5] * m[5] + m[6] * m[6]);
  73686. scale.z = Math.sqrt(m[8] * m[8] + m[9] * m[9] + m[10] * m[10]);
  73687. if (this.determinant() <= 0) {
  73688. scale.y *= -1;
  73689. }
  73690. if (scale.x === 0 || scale.y === 0 || scale.z === 0) {
  73691. if (rotation) {
  73692. rotation.copyFromFloats(0.0, 0.0, 0.0, 1.0);
  73693. }
  73694. return false;
  73695. }
  73696. if (rotation) {
  73697. var sx = 1 / scale.x, sy = 1 / scale.y, sz = 1 / scale.z;
  73698. 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]);
  73699. Quaternion.FromRotationMatrixToRef(MathTmp.Matrix[0], rotation);
  73700. }
  73701. return true;
  73702. };
  73703. /**
  73704. * Gets specific row of the matrix
  73705. * @param index defines the number of the row to get
  73706. * @returns the index-th row of the current matrix as a new Vector4
  73707. */
  73708. Matrix.prototype.getRow = function (index) {
  73709. if (index < 0 || index > 3) {
  73710. return null;
  73711. }
  73712. var i = index * 4;
  73713. return new Vector4(this._m[i + 0], this._m[i + 1], this._m[i + 2], this._m[i + 3]);
  73714. };
  73715. /**
  73716. * Sets the index-th row of the current matrix to the vector4 values
  73717. * @param index defines the number of the row to set
  73718. * @param row defines the target vector4
  73719. * @returns the updated current matrix
  73720. */
  73721. Matrix.prototype.setRow = function (index, row) {
  73722. return this.setRowFromFloats(index, row.x, row.y, row.z, row.w);
  73723. };
  73724. /**
  73725. * Compute the transpose of the matrix
  73726. * @returns the new transposed matrix
  73727. */
  73728. Matrix.prototype.transpose = function () {
  73729. return Matrix.Transpose(this);
  73730. };
  73731. /**
  73732. * Compute the transpose of the matrix and store it in a given matrix
  73733. * @param result defines the target matrix
  73734. * @returns the current matrix
  73735. */
  73736. Matrix.prototype.transposeToRef = function (result) {
  73737. Matrix.TransposeToRef(this, result);
  73738. return this;
  73739. };
  73740. /**
  73741. * Sets the index-th row of the current matrix with the given 4 x float values
  73742. * @param index defines the row index
  73743. * @param x defines the x component to set
  73744. * @param y defines the y component to set
  73745. * @param z defines the z component to set
  73746. * @param w defines the w component to set
  73747. * @returns the updated current matrix
  73748. */
  73749. Matrix.prototype.setRowFromFloats = function (index, x, y, z, w) {
  73750. if (index < 0 || index > 3) {
  73751. return this;
  73752. }
  73753. var i = index * 4;
  73754. this._m[i + 0] = x;
  73755. this._m[i + 1] = y;
  73756. this._m[i + 2] = z;
  73757. this._m[i + 3] = w;
  73758. this._markAsUpdated();
  73759. return this;
  73760. };
  73761. /**
  73762. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  73763. * @param scale defines the scale factor
  73764. * @returns a new matrix
  73765. */
  73766. Matrix.prototype.scale = function (scale) {
  73767. var result = new Matrix();
  73768. this.scaleToRef(scale, result);
  73769. return result;
  73770. };
  73771. /**
  73772. * Scale the current matrix values by a factor to a given result matrix
  73773. * @param scale defines the scale factor
  73774. * @param result defines the matrix to store the result
  73775. * @returns the current matrix
  73776. */
  73777. Matrix.prototype.scaleToRef = function (scale, result) {
  73778. for (var index = 0; index < 16; index++) {
  73779. result._m[index] = this._m[index] * scale;
  73780. }
  73781. result._markAsUpdated();
  73782. return this;
  73783. };
  73784. /**
  73785. * Scale the current matrix values by a factor and add the result to a given matrix
  73786. * @param scale defines the scale factor
  73787. * @param result defines the Matrix to store the result
  73788. * @returns the current matrix
  73789. */
  73790. Matrix.prototype.scaleAndAddToRef = function (scale, result) {
  73791. for (var index = 0; index < 16; index++) {
  73792. result._m[index] += this._m[index] * scale;
  73793. }
  73794. result._markAsUpdated();
  73795. return this;
  73796. };
  73797. /**
  73798. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  73799. * @param ref matrix to store the result
  73800. */
  73801. Matrix.prototype.toNormalMatrix = function (ref) {
  73802. var tmp = MathTmp.Matrix[0];
  73803. this.invertToRef(tmp);
  73804. tmp.transposeToRef(ref);
  73805. var m = ref._m;
  73806. 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);
  73807. };
  73808. /**
  73809. * Gets only rotation part of the current matrix
  73810. * @returns a new matrix sets to the extracted rotation matrix from the current one
  73811. */
  73812. Matrix.prototype.getRotationMatrix = function () {
  73813. var result = new Matrix();
  73814. this.getRotationMatrixToRef(result);
  73815. return result;
  73816. };
  73817. /**
  73818. * Extracts the rotation matrix from the current one and sets it as the given "result"
  73819. * @param result defines the target matrix to store data to
  73820. * @returns the current matrix
  73821. */
  73822. Matrix.prototype.getRotationMatrixToRef = function (result) {
  73823. var scale = MathTmp.Vector3[0];
  73824. if (!this.decompose(scale)) {
  73825. Matrix.IdentityToRef(result);
  73826. return this;
  73827. }
  73828. var m = this._m;
  73829. var sx = 1 / scale.x, sy = 1 / scale.y, sz = 1 / scale.z;
  73830. 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);
  73831. return this;
  73832. };
  73833. /**
  73834. * Toggles model matrix from being right handed to left handed in place and vice versa
  73835. */
  73836. Matrix.prototype.toggleModelMatrixHandInPlace = function () {
  73837. var m = this._m;
  73838. m[2] *= -1;
  73839. m[6] *= -1;
  73840. m[8] *= -1;
  73841. m[9] *= -1;
  73842. m[14] *= -1;
  73843. this._markAsUpdated();
  73844. };
  73845. /**
  73846. * Toggles projection matrix from being right handed to left handed in place and vice versa
  73847. */
  73848. Matrix.prototype.toggleProjectionMatrixHandInPlace = function () {
  73849. var m = this._m;
  73850. m[8] *= -1;
  73851. m[9] *= -1;
  73852. m[10] *= -1;
  73853. m[11] *= -1;
  73854. this._markAsUpdated();
  73855. };
  73856. // Statics
  73857. /**
  73858. * Creates a matrix from an array
  73859. * @param array defines the source array
  73860. * @param offset defines an offset in the source array
  73861. * @returns a new Matrix set from the starting index of the given array
  73862. */
  73863. Matrix.FromArray = function (array, offset) {
  73864. if (offset === void 0) { offset = 0; }
  73865. var result = new Matrix();
  73866. Matrix.FromArrayToRef(array, offset, result);
  73867. return result;
  73868. };
  73869. /**
  73870. * Copy the content of an array into a given matrix
  73871. * @param array defines the source array
  73872. * @param offset defines an offset in the source array
  73873. * @param result defines the target matrix
  73874. */
  73875. Matrix.FromArrayToRef = function (array, offset, result) {
  73876. for (var index = 0; index < 16; index++) {
  73877. result._m[index] = array[index + offset];
  73878. }
  73879. result._markAsUpdated();
  73880. };
  73881. /**
  73882. * Stores an array into a matrix after having multiplied each component by a given factor
  73883. * @param array defines the source array
  73884. * @param offset defines the offset in the source array
  73885. * @param scale defines the scaling factor
  73886. * @param result defines the target matrix
  73887. */
  73888. Matrix.FromFloat32ArrayToRefScaled = function (array, offset, scale, result) {
  73889. for (var index = 0; index < 16; index++) {
  73890. result._m[index] = array[index + offset] * scale;
  73891. }
  73892. result._markAsUpdated();
  73893. };
  73894. Object.defineProperty(Matrix, "IdentityReadOnly", {
  73895. /**
  73896. * Gets an identity matrix that must not be updated
  73897. */
  73898. get: function () {
  73899. return Matrix._identityReadOnly;
  73900. },
  73901. enumerable: true,
  73902. configurable: true
  73903. });
  73904. /**
  73905. * Stores a list of values (16) inside a given matrix
  73906. * @param initialM11 defines 1st value of 1st row
  73907. * @param initialM12 defines 2nd value of 1st row
  73908. * @param initialM13 defines 3rd value of 1st row
  73909. * @param initialM14 defines 4th value of 1st row
  73910. * @param initialM21 defines 1st value of 2nd row
  73911. * @param initialM22 defines 2nd value of 2nd row
  73912. * @param initialM23 defines 3rd value of 2nd row
  73913. * @param initialM24 defines 4th value of 2nd row
  73914. * @param initialM31 defines 1st value of 3rd row
  73915. * @param initialM32 defines 2nd value of 3rd row
  73916. * @param initialM33 defines 3rd value of 3rd row
  73917. * @param initialM34 defines 4th value of 3rd row
  73918. * @param initialM41 defines 1st value of 4th row
  73919. * @param initialM42 defines 2nd value of 4th row
  73920. * @param initialM43 defines 3rd value of 4th row
  73921. * @param initialM44 defines 4th value of 4th row
  73922. * @param result defines the target matrix
  73923. */
  73924. Matrix.FromValuesToRef = function (initialM11, initialM12, initialM13, initialM14, initialM21, initialM22, initialM23, initialM24, initialM31, initialM32, initialM33, initialM34, initialM41, initialM42, initialM43, initialM44, result) {
  73925. var m = result._m;
  73926. m[0] = initialM11;
  73927. m[1] = initialM12;
  73928. m[2] = initialM13;
  73929. m[3] = initialM14;
  73930. m[4] = initialM21;
  73931. m[5] = initialM22;
  73932. m[6] = initialM23;
  73933. m[7] = initialM24;
  73934. m[8] = initialM31;
  73935. m[9] = initialM32;
  73936. m[10] = initialM33;
  73937. m[11] = initialM34;
  73938. m[12] = initialM41;
  73939. m[13] = initialM42;
  73940. m[14] = initialM43;
  73941. m[15] = initialM44;
  73942. result._markAsUpdated();
  73943. };
  73944. /**
  73945. * Creates new matrix from a list of values (16)
  73946. * @param initialM11 defines 1st value of 1st row
  73947. * @param initialM12 defines 2nd value of 1st row
  73948. * @param initialM13 defines 3rd value of 1st row
  73949. * @param initialM14 defines 4th value of 1st row
  73950. * @param initialM21 defines 1st value of 2nd row
  73951. * @param initialM22 defines 2nd value of 2nd row
  73952. * @param initialM23 defines 3rd value of 2nd row
  73953. * @param initialM24 defines 4th value of 2nd row
  73954. * @param initialM31 defines 1st value of 3rd row
  73955. * @param initialM32 defines 2nd value of 3rd row
  73956. * @param initialM33 defines 3rd value of 3rd row
  73957. * @param initialM34 defines 4th value of 3rd row
  73958. * @param initialM41 defines 1st value of 4th row
  73959. * @param initialM42 defines 2nd value of 4th row
  73960. * @param initialM43 defines 3rd value of 4th row
  73961. * @param initialM44 defines 4th value of 4th row
  73962. * @returns the new matrix
  73963. */
  73964. Matrix.FromValues = function (initialM11, initialM12, initialM13, initialM14, initialM21, initialM22, initialM23, initialM24, initialM31, initialM32, initialM33, initialM34, initialM41, initialM42, initialM43, initialM44) {
  73965. var result = new Matrix();
  73966. var m = result._m;
  73967. m[0] = initialM11;
  73968. m[1] = initialM12;
  73969. m[2] = initialM13;
  73970. m[3] = initialM14;
  73971. m[4] = initialM21;
  73972. m[5] = initialM22;
  73973. m[6] = initialM23;
  73974. m[7] = initialM24;
  73975. m[8] = initialM31;
  73976. m[9] = initialM32;
  73977. m[10] = initialM33;
  73978. m[11] = initialM34;
  73979. m[12] = initialM41;
  73980. m[13] = initialM42;
  73981. m[14] = initialM43;
  73982. m[15] = initialM44;
  73983. result._markAsUpdated();
  73984. return result;
  73985. };
  73986. /**
  73987. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  73988. * @param scale defines the scale vector3
  73989. * @param rotation defines the rotation quaternion
  73990. * @param translation defines the translation vector3
  73991. * @returns a new matrix
  73992. */
  73993. Matrix.Compose = function (scale, rotation, translation) {
  73994. var result = new Matrix();
  73995. Matrix.ComposeToRef(scale, rotation, translation, result);
  73996. return result;
  73997. };
  73998. /**
  73999. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  74000. * @param scale defines the scale vector3
  74001. * @param rotation defines the rotation quaternion
  74002. * @param translation defines the translation vector3
  74003. * @param result defines the target matrix
  74004. */
  74005. Matrix.ComposeToRef = function (scale, rotation, translation, result) {
  74006. Matrix.ScalingToRef(scale.x, scale.y, scale.z, MathTmp.Matrix[1]);
  74007. rotation.toRotationMatrix(MathTmp.Matrix[0]);
  74008. MathTmp.Matrix[1].multiplyToRef(MathTmp.Matrix[0], result);
  74009. result.setTranslation(translation);
  74010. };
  74011. /**
  74012. * Creates a new identity matrix
  74013. * @returns a new identity matrix
  74014. */
  74015. Matrix.Identity = function () {
  74016. 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);
  74017. identity._updateIdentityStatus(true);
  74018. return identity;
  74019. };
  74020. /**
  74021. * Creates a new identity matrix and stores the result in a given matrix
  74022. * @param result defines the target matrix
  74023. */
  74024. Matrix.IdentityToRef = function (result) {
  74025. 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);
  74026. result._updateIdentityStatus(true);
  74027. };
  74028. /**
  74029. * Creates a new zero matrix
  74030. * @returns a new zero matrix
  74031. */
  74032. Matrix.Zero = function () {
  74033. 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);
  74034. zero._updateIdentityStatus(false);
  74035. return zero;
  74036. };
  74037. /**
  74038. * Creates a new rotation matrix for "angle" radians around the X axis
  74039. * @param angle defines the angle (in radians) to use
  74040. * @return the new matrix
  74041. */
  74042. Matrix.RotationX = function (angle) {
  74043. var result = new Matrix();
  74044. Matrix.RotationXToRef(angle, result);
  74045. return result;
  74046. };
  74047. /**
  74048. * Creates a new matrix as the invert of a given matrix
  74049. * @param source defines the source matrix
  74050. * @returns the new matrix
  74051. */
  74052. Matrix.Invert = function (source) {
  74053. var result = new Matrix();
  74054. source.invertToRef(result);
  74055. return result;
  74056. };
  74057. /**
  74058. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  74059. * @param angle defines the angle (in radians) to use
  74060. * @param result defines the target matrix
  74061. */
  74062. Matrix.RotationXToRef = function (angle, result) {
  74063. var s = Math.sin(angle);
  74064. var c = Math.cos(angle);
  74065. 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);
  74066. result._updateIdentityStatus(c === 1 && s === 0);
  74067. };
  74068. /**
  74069. * Creates a new rotation matrix for "angle" radians around the Y axis
  74070. * @param angle defines the angle (in radians) to use
  74071. * @return the new matrix
  74072. */
  74073. Matrix.RotationY = function (angle) {
  74074. var result = new Matrix();
  74075. Matrix.RotationYToRef(angle, result);
  74076. return result;
  74077. };
  74078. /**
  74079. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  74080. * @param angle defines the angle (in radians) to use
  74081. * @param result defines the target matrix
  74082. */
  74083. Matrix.RotationYToRef = function (angle, result) {
  74084. var s = Math.sin(angle);
  74085. var c = Math.cos(angle);
  74086. 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);
  74087. result._updateIdentityStatus(c === 1 && s === 0);
  74088. };
  74089. /**
  74090. * Creates a new rotation matrix for "angle" radians around the Z axis
  74091. * @param angle defines the angle (in radians) to use
  74092. * @return the new matrix
  74093. */
  74094. Matrix.RotationZ = function (angle) {
  74095. var result = new Matrix();
  74096. Matrix.RotationZToRef(angle, result);
  74097. return result;
  74098. };
  74099. /**
  74100. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  74101. * @param angle defines the angle (in radians) to use
  74102. * @param result defines the target matrix
  74103. */
  74104. Matrix.RotationZToRef = function (angle, result) {
  74105. var s = Math.sin(angle);
  74106. var c = Math.cos(angle);
  74107. 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);
  74108. result._updateIdentityStatus(c === 1 && s === 0);
  74109. };
  74110. /**
  74111. * Creates a new rotation matrix for "angle" radians around the given axis
  74112. * @param axis defines the axis to use
  74113. * @param angle defines the angle (in radians) to use
  74114. * @return the new matrix
  74115. */
  74116. Matrix.RotationAxis = function (axis, angle) {
  74117. var result = new Matrix();
  74118. Matrix.RotationAxisToRef(axis, angle, result);
  74119. return result;
  74120. };
  74121. /**
  74122. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  74123. * @param axis defines the axis to use
  74124. * @param angle defines the angle (in radians) to use
  74125. * @param result defines the target matrix
  74126. */
  74127. Matrix.RotationAxisToRef = function (axis, angle, result) {
  74128. var s = Math.sin(-angle);
  74129. var c = Math.cos(-angle);
  74130. var c1 = 1 - c;
  74131. axis.normalize();
  74132. var m = result._m;
  74133. m[0] = (axis.x * axis.x) * c1 + c;
  74134. m[1] = (axis.x * axis.y) * c1 - (axis.z * s);
  74135. m[2] = (axis.x * axis.z) * c1 + (axis.y * s);
  74136. m[3] = 0.0;
  74137. m[4] = (axis.y * axis.x) * c1 + (axis.z * s);
  74138. m[5] = (axis.y * axis.y) * c1 + c;
  74139. m[6] = (axis.y * axis.z) * c1 - (axis.x * s);
  74140. m[7] = 0.0;
  74141. m[8] = (axis.z * axis.x) * c1 - (axis.y * s);
  74142. m[9] = (axis.z * axis.y) * c1 + (axis.x * s);
  74143. m[10] = (axis.z * axis.z) * c1 + c;
  74144. m[11] = 0.0;
  74145. m[12] = 0.0;
  74146. m[13] = 0.0;
  74147. m[14] = 0.0;
  74148. m[15] = 1.0;
  74149. result._markAsUpdated();
  74150. };
  74151. /**
  74152. * Creates a rotation matrix
  74153. * @param yaw defines the yaw angle in radians (Y axis)
  74154. * @param pitch defines the pitch angle in radians (X axis)
  74155. * @param roll defines the roll angle in radians (X axis)
  74156. * @returns the new rotation matrix
  74157. */
  74158. Matrix.RotationYawPitchRoll = function (yaw, pitch, roll) {
  74159. var result = new Matrix();
  74160. Matrix.RotationYawPitchRollToRef(yaw, pitch, roll, result);
  74161. return result;
  74162. };
  74163. /**
  74164. * Creates a rotation matrix and stores it in a given matrix
  74165. * @param yaw defines the yaw angle in radians (Y axis)
  74166. * @param pitch defines the pitch angle in radians (X axis)
  74167. * @param roll defines the roll angle in radians (X axis)
  74168. * @param result defines the target matrix
  74169. */
  74170. Matrix.RotationYawPitchRollToRef = function (yaw, pitch, roll, result) {
  74171. Quaternion.RotationYawPitchRollToRef(yaw, pitch, roll, MathTmp.Quaternion[0]);
  74172. MathTmp.Quaternion[0].toRotationMatrix(result);
  74173. };
  74174. /**
  74175. * Creates a scaling matrix
  74176. * @param x defines the scale factor on X axis
  74177. * @param y defines the scale factor on Y axis
  74178. * @param z defines the scale factor on Z axis
  74179. * @returns the new matrix
  74180. */
  74181. Matrix.Scaling = function (x, y, z) {
  74182. var result = new Matrix();
  74183. Matrix.ScalingToRef(x, y, z, result);
  74184. return result;
  74185. };
  74186. /**
  74187. * Creates a scaling matrix and stores it in a given matrix
  74188. * @param x defines the scale factor on X axis
  74189. * @param y defines the scale factor on Y axis
  74190. * @param z defines the scale factor on Z axis
  74191. * @param result defines the target matrix
  74192. */
  74193. Matrix.ScalingToRef = function (x, y, z, result) {
  74194. 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);
  74195. result._updateIdentityStatus(x === 1 && y === 1 && z === 1);
  74196. };
  74197. /**
  74198. * Creates a translation matrix
  74199. * @param x defines the translation on X axis
  74200. * @param y defines the translation on Y axis
  74201. * @param z defines the translationon Z axis
  74202. * @returns the new matrix
  74203. */
  74204. Matrix.Translation = function (x, y, z) {
  74205. var result = new Matrix();
  74206. Matrix.TranslationToRef(x, y, z, result);
  74207. return result;
  74208. };
  74209. /**
  74210. * Creates a translation matrix and stores it in a given matrix
  74211. * @param x defines the translation on X axis
  74212. * @param y defines the translation on Y axis
  74213. * @param z defines the translationon Z axis
  74214. * @param result defines the target matrix
  74215. */
  74216. Matrix.TranslationToRef = function (x, y, z, result) {
  74217. 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);
  74218. result._updateIdentityStatus(x === 0 && y === 0 && z === 0);
  74219. };
  74220. /**
  74221. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  74222. * @param startValue defines the start value
  74223. * @param endValue defines the end value
  74224. * @param gradient defines the gradient factor
  74225. * @returns the new matrix
  74226. */
  74227. Matrix.Lerp = function (startValue, endValue, gradient) {
  74228. var result = new Matrix();
  74229. Matrix.LerpToRef(startValue, endValue, gradient, result);
  74230. return result;
  74231. };
  74232. /**
  74233. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  74234. * @param startValue defines the start value
  74235. * @param endValue defines the end value
  74236. * @param gradient defines the gradient factor
  74237. * @param result defines the Matrix object where to store data
  74238. */
  74239. Matrix.LerpToRef = function (startValue, endValue, gradient, result) {
  74240. var resultM = result._m;
  74241. var startM = startValue.m;
  74242. var endM = endValue.m;
  74243. for (var index = 0; index < 16; index++) {
  74244. resultM[index] = startM[index] * (1.0 - gradient) + endM[index] * gradient;
  74245. }
  74246. result._markAsUpdated();
  74247. };
  74248. /**
  74249. * Builds a new matrix whose values are computed by:
  74250. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  74251. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  74252. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  74253. * @param startValue defines the first matrix
  74254. * @param endValue defines the second matrix
  74255. * @param gradient defines the gradient between the two matrices
  74256. * @returns the new matrix
  74257. */
  74258. Matrix.DecomposeLerp = function (startValue, endValue, gradient) {
  74259. var result = new Matrix();
  74260. Matrix.DecomposeLerpToRef(startValue, endValue, gradient, result);
  74261. return result;
  74262. };
  74263. /**
  74264. * Update a matrix to values which are computed by:
  74265. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  74266. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  74267. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  74268. * @param startValue defines the first matrix
  74269. * @param endValue defines the second matrix
  74270. * @param gradient defines the gradient between the two matrices
  74271. * @param result defines the target matrix
  74272. */
  74273. Matrix.DecomposeLerpToRef = function (startValue, endValue, gradient, result) {
  74274. var startScale = MathTmp.Vector3[0];
  74275. var startRotation = MathTmp.Quaternion[0];
  74276. var startTranslation = MathTmp.Vector3[1];
  74277. startValue.decompose(startScale, startRotation, startTranslation);
  74278. var endScale = MathTmp.Vector3[2];
  74279. var endRotation = MathTmp.Quaternion[1];
  74280. var endTranslation = MathTmp.Vector3[3];
  74281. endValue.decompose(endScale, endRotation, endTranslation);
  74282. var resultScale = MathTmp.Vector3[4];
  74283. Vector3.LerpToRef(startScale, endScale, gradient, resultScale);
  74284. var resultRotation = MathTmp.Quaternion[2];
  74285. Quaternion.SlerpToRef(startRotation, endRotation, gradient, resultRotation);
  74286. var resultTranslation = MathTmp.Vector3[5];
  74287. Vector3.LerpToRef(startTranslation, endTranslation, gradient, resultTranslation);
  74288. Matrix.ComposeToRef(resultScale, resultRotation, resultTranslation, result);
  74289. };
  74290. /**
  74291. * 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"
  74292. * This function works in left handed mode
  74293. * @param eye defines the final position of the entity
  74294. * @param target defines where the entity should look at
  74295. * @param up defines the up vector for the entity
  74296. * @returns the new matrix
  74297. */
  74298. Matrix.LookAtLH = function (eye, target, up) {
  74299. var result = new Matrix();
  74300. Matrix.LookAtLHToRef(eye, target, up, result);
  74301. return result;
  74302. };
  74303. /**
  74304. * 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".
  74305. * This function works in left handed mode
  74306. * @param eye defines the final position of the entity
  74307. * @param target defines where the entity should look at
  74308. * @param up defines the up vector for the entity
  74309. * @param result defines the target matrix
  74310. */
  74311. Matrix.LookAtLHToRef = function (eye, target, up, result) {
  74312. var xAxis = MathTmp.Vector3[0];
  74313. var yAxis = MathTmp.Vector3[1];
  74314. var zAxis = MathTmp.Vector3[2];
  74315. // Z axis
  74316. target.subtractToRef(eye, zAxis);
  74317. zAxis.normalize();
  74318. // X axis
  74319. Vector3.CrossToRef(up, zAxis, xAxis);
  74320. var xSquareLength = xAxis.lengthSquared();
  74321. if (xSquareLength === 0) {
  74322. xAxis.x = 1.0;
  74323. }
  74324. else {
  74325. xAxis.normalizeFromLength(Math.sqrt(xSquareLength));
  74326. }
  74327. // Y axis
  74328. Vector3.CrossToRef(zAxis, xAxis, yAxis);
  74329. yAxis.normalize();
  74330. // Eye angles
  74331. var ex = -Vector3.Dot(xAxis, eye);
  74332. var ey = -Vector3.Dot(yAxis, eye);
  74333. var ez = -Vector3.Dot(zAxis, eye);
  74334. 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);
  74335. };
  74336. /**
  74337. * 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"
  74338. * This function works in right handed mode
  74339. * @param eye defines the final position of the entity
  74340. * @param target defines where the entity should look at
  74341. * @param up defines the up vector for the entity
  74342. * @returns the new matrix
  74343. */
  74344. Matrix.LookAtRH = function (eye, target, up) {
  74345. var result = new Matrix();
  74346. Matrix.LookAtRHToRef(eye, target, up, result);
  74347. return result;
  74348. };
  74349. /**
  74350. * 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".
  74351. * This function works in right handed mode
  74352. * @param eye defines the final position of the entity
  74353. * @param target defines where the entity should look at
  74354. * @param up defines the up vector for the entity
  74355. * @param result defines the target matrix
  74356. */
  74357. Matrix.LookAtRHToRef = function (eye, target, up, result) {
  74358. var xAxis = MathTmp.Vector3[0];
  74359. var yAxis = MathTmp.Vector3[1];
  74360. var zAxis = MathTmp.Vector3[2];
  74361. // Z axis
  74362. eye.subtractToRef(target, zAxis);
  74363. zAxis.normalize();
  74364. // X axis
  74365. Vector3.CrossToRef(up, zAxis, xAxis);
  74366. var xSquareLength = xAxis.lengthSquared();
  74367. if (xSquareLength === 0) {
  74368. xAxis.x = 1.0;
  74369. }
  74370. else {
  74371. xAxis.normalizeFromLength(Math.sqrt(xSquareLength));
  74372. }
  74373. // Y axis
  74374. Vector3.CrossToRef(zAxis, xAxis, yAxis);
  74375. yAxis.normalize();
  74376. // Eye angles
  74377. var ex = -Vector3.Dot(xAxis, eye);
  74378. var ey = -Vector3.Dot(yAxis, eye);
  74379. var ez = -Vector3.Dot(zAxis, eye);
  74380. 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);
  74381. };
  74382. /**
  74383. * Create a left-handed orthographic projection matrix
  74384. * @param width defines the viewport width
  74385. * @param height defines the viewport height
  74386. * @param znear defines the near clip plane
  74387. * @param zfar defines the far clip plane
  74388. * @returns a new matrix as a left-handed orthographic projection matrix
  74389. */
  74390. Matrix.OrthoLH = function (width, height, znear, zfar) {
  74391. var matrix = new Matrix();
  74392. Matrix.OrthoLHToRef(width, height, znear, zfar, matrix);
  74393. return matrix;
  74394. };
  74395. /**
  74396. * Store a left-handed orthographic projection to a given matrix
  74397. * @param width defines the viewport width
  74398. * @param height defines the viewport height
  74399. * @param znear defines the near clip plane
  74400. * @param zfar defines the far clip plane
  74401. * @param result defines the target matrix
  74402. */
  74403. Matrix.OrthoLHToRef = function (width, height, znear, zfar, result) {
  74404. var n = znear;
  74405. var f = zfar;
  74406. var a = 2.0 / width;
  74407. var b = 2.0 / height;
  74408. var c = 2.0 / (f - n);
  74409. var d = -(f + n) / (f - n);
  74410. 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);
  74411. result._updateIdentityStatus(a === 1 && b === 1 && c === 1 && d === 0);
  74412. };
  74413. /**
  74414. * Create a left-handed orthographic projection matrix
  74415. * @param left defines the viewport left coordinate
  74416. * @param right defines the viewport right coordinate
  74417. * @param bottom defines the viewport bottom coordinate
  74418. * @param top defines the viewport top coordinate
  74419. * @param znear defines the near clip plane
  74420. * @param zfar defines the far clip plane
  74421. * @returns a new matrix as a left-handed orthographic projection matrix
  74422. */
  74423. Matrix.OrthoOffCenterLH = function (left, right, bottom, top, znear, zfar) {
  74424. var matrix = new Matrix();
  74425. Matrix.OrthoOffCenterLHToRef(left, right, bottom, top, znear, zfar, matrix);
  74426. return matrix;
  74427. };
  74428. /**
  74429. * Stores a left-handed orthographic projection into a given matrix
  74430. * @param left defines the viewport left coordinate
  74431. * @param right defines the viewport right coordinate
  74432. * @param bottom defines the viewport bottom coordinate
  74433. * @param top defines the viewport top coordinate
  74434. * @param znear defines the near clip plane
  74435. * @param zfar defines the far clip plane
  74436. * @param result defines the target matrix
  74437. */
  74438. Matrix.OrthoOffCenterLHToRef = function (left, right, bottom, top, znear, zfar, result) {
  74439. var n = znear;
  74440. var f = zfar;
  74441. var a = 2.0 / (right - left);
  74442. var b = 2.0 / (top - bottom);
  74443. var c = 2.0 / (f - n);
  74444. var d = -(f + n) / (f - n);
  74445. var i0 = (left + right) / (left - right);
  74446. var i1 = (top + bottom) / (bottom - top);
  74447. 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);
  74448. result._markAsUpdated();
  74449. };
  74450. /**
  74451. * Creates a right-handed orthographic projection matrix
  74452. * @param left defines the viewport left coordinate
  74453. * @param right defines the viewport right coordinate
  74454. * @param bottom defines the viewport bottom coordinate
  74455. * @param top defines the viewport top coordinate
  74456. * @param znear defines the near clip plane
  74457. * @param zfar defines the far clip plane
  74458. * @returns a new matrix as a right-handed orthographic projection matrix
  74459. */
  74460. Matrix.OrthoOffCenterRH = function (left, right, bottom, top, znear, zfar) {
  74461. var matrix = new Matrix();
  74462. Matrix.OrthoOffCenterRHToRef(left, right, bottom, top, znear, zfar, matrix);
  74463. return matrix;
  74464. };
  74465. /**
  74466. * Stores a right-handed orthographic projection into a given matrix
  74467. * @param left defines the viewport left coordinate
  74468. * @param right defines the viewport right coordinate
  74469. * @param bottom defines the viewport bottom coordinate
  74470. * @param top defines the viewport top coordinate
  74471. * @param znear defines the near clip plane
  74472. * @param zfar defines the far clip plane
  74473. * @param result defines the target matrix
  74474. */
  74475. Matrix.OrthoOffCenterRHToRef = function (left, right, bottom, top, znear, zfar, result) {
  74476. Matrix.OrthoOffCenterLHToRef(left, right, bottom, top, znear, zfar, result);
  74477. result._m[10] *= -1; // No need to call _markAsUpdated as previous function already called it and let _isIdentityDirty to true
  74478. };
  74479. /**
  74480. * Creates a left-handed perspective projection matrix
  74481. * @param width defines the viewport width
  74482. * @param height defines the viewport height
  74483. * @param znear defines the near clip plane
  74484. * @param zfar defines the far clip plane
  74485. * @returns a new matrix as a left-handed perspective projection matrix
  74486. */
  74487. Matrix.PerspectiveLH = function (width, height, znear, zfar) {
  74488. var matrix = new Matrix();
  74489. var n = znear;
  74490. var f = zfar;
  74491. var a = 2.0 * n / width;
  74492. var b = 2.0 * n / height;
  74493. var c = (f + n) / (f - n);
  74494. var d = -2.0 * f * n / (f - n);
  74495. 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);
  74496. matrix._updateIdentityStatus(false);
  74497. return matrix;
  74498. };
  74499. /**
  74500. * Creates a left-handed perspective projection matrix
  74501. * @param fov defines the horizontal field of view
  74502. * @param aspect defines the aspect ratio
  74503. * @param znear defines the near clip plane
  74504. * @param zfar defines the far clip plane
  74505. * @returns a new matrix as a left-handed perspective projection matrix
  74506. */
  74507. Matrix.PerspectiveFovLH = function (fov, aspect, znear, zfar) {
  74508. var matrix = new Matrix();
  74509. Matrix.PerspectiveFovLHToRef(fov, aspect, znear, zfar, matrix);
  74510. return matrix;
  74511. };
  74512. /**
  74513. * Stores a left-handed perspective projection into a given matrix
  74514. * @param fov defines the horizontal field of view
  74515. * @param aspect defines the aspect ratio
  74516. * @param znear defines the near clip plane
  74517. * @param zfar defines the far clip plane
  74518. * @param result defines the target matrix
  74519. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  74520. */
  74521. Matrix.PerspectiveFovLHToRef = function (fov, aspect, znear, zfar, result, isVerticalFovFixed) {
  74522. if (isVerticalFovFixed === void 0) { isVerticalFovFixed = true; }
  74523. var n = znear;
  74524. var f = zfar;
  74525. var t = 1.0 / (Math.tan(fov * 0.5));
  74526. var a = isVerticalFovFixed ? (t / aspect) : t;
  74527. var b = isVerticalFovFixed ? t : (t * aspect);
  74528. var c = (f + n) / (f - n);
  74529. var d = -2.0 * f * n / (f - n);
  74530. 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);
  74531. result._updateIdentityStatus(false);
  74532. };
  74533. /**
  74534. * Creates a right-handed perspective projection matrix
  74535. * @param fov defines the horizontal field of view
  74536. * @param aspect defines the aspect ratio
  74537. * @param znear defines the near clip plane
  74538. * @param zfar defines the far clip plane
  74539. * @returns a new matrix as a right-handed perspective projection matrix
  74540. */
  74541. Matrix.PerspectiveFovRH = function (fov, aspect, znear, zfar) {
  74542. var matrix = new Matrix();
  74543. Matrix.PerspectiveFovRHToRef(fov, aspect, znear, zfar, matrix);
  74544. return matrix;
  74545. };
  74546. /**
  74547. * Stores a right-handed perspective projection into a given matrix
  74548. * @param fov defines the horizontal field of view
  74549. * @param aspect defines the aspect ratio
  74550. * @param znear defines the near clip plane
  74551. * @param zfar defines the far clip plane
  74552. * @param result defines the target matrix
  74553. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  74554. */
  74555. Matrix.PerspectiveFovRHToRef = function (fov, aspect, znear, zfar, result, isVerticalFovFixed) {
  74556. //alternatively this could be expressed as:
  74557. // m = PerspectiveFovLHToRef
  74558. // m[10] *= -1.0;
  74559. // m[11] *= -1.0;
  74560. if (isVerticalFovFixed === void 0) { isVerticalFovFixed = true; }
  74561. var n = znear;
  74562. var f = zfar;
  74563. var t = 1.0 / (Math.tan(fov * 0.5));
  74564. var a = isVerticalFovFixed ? (t / aspect) : t;
  74565. var b = isVerticalFovFixed ? t : (t * aspect);
  74566. var c = -(f + n) / (f - n);
  74567. var d = -2 * f * n / (f - n);
  74568. 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);
  74569. result._updateIdentityStatus(false);
  74570. };
  74571. /**
  74572. * Stores a perspective projection for WebVR info a given matrix
  74573. * @param fov defines the field of view
  74574. * @param znear defines the near clip plane
  74575. * @param zfar defines the far clip plane
  74576. * @param result defines the target matrix
  74577. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  74578. */
  74579. Matrix.PerspectiveFovWebVRToRef = function (fov, znear, zfar, result, rightHanded) {
  74580. if (rightHanded === void 0) { rightHanded = false; }
  74581. var rightHandedFactor = rightHanded ? -1 : 1;
  74582. var upTan = Math.tan(fov.upDegrees * Math.PI / 180.0);
  74583. var downTan = Math.tan(fov.downDegrees * Math.PI / 180.0);
  74584. var leftTan = Math.tan(fov.leftDegrees * Math.PI / 180.0);
  74585. var rightTan = Math.tan(fov.rightDegrees * Math.PI / 180.0);
  74586. var xScale = 2.0 / (leftTan + rightTan);
  74587. var yScale = 2.0 / (upTan + downTan);
  74588. var m = result._m;
  74589. m[0] = xScale;
  74590. m[1] = m[2] = m[3] = m[4] = 0.0;
  74591. m[5] = yScale;
  74592. m[6] = m[7] = 0.0;
  74593. m[8] = ((leftTan - rightTan) * xScale * 0.5);
  74594. m[9] = -((upTan - downTan) * yScale * 0.5);
  74595. m[10] = -zfar / (znear - zfar);
  74596. m[11] = 1.0 * rightHandedFactor;
  74597. m[12] = m[13] = m[15] = 0.0;
  74598. m[14] = -(2.0 * zfar * znear) / (zfar - znear);
  74599. result._markAsUpdated();
  74600. };
  74601. /**
  74602. * Computes a complete transformation matrix
  74603. * @param viewport defines the viewport to use
  74604. * @param world defines the world matrix
  74605. * @param view defines the view matrix
  74606. * @param projection defines the projection matrix
  74607. * @param zmin defines the near clip plane
  74608. * @param zmax defines the far clip plane
  74609. * @returns the transformation matrix
  74610. */
  74611. Matrix.GetFinalMatrix = function (viewport, world, view, projection, zmin, zmax) {
  74612. var cw = viewport.width;
  74613. var ch = viewport.height;
  74614. var cx = viewport.x;
  74615. var cy = viewport.y;
  74616. 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);
  74617. var matrix = MathTmp.Matrix[0];
  74618. world.multiplyToRef(view, matrix);
  74619. matrix.multiplyToRef(projection, matrix);
  74620. return matrix.multiply(viewportMatrix);
  74621. };
  74622. /**
  74623. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  74624. * @param matrix defines the matrix to use
  74625. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  74626. */
  74627. Matrix.GetAsMatrix2x2 = function (matrix) {
  74628. var m = matrix.m;
  74629. return new Float32Array([m[0], m[1], m[4], m[5]]);
  74630. };
  74631. /**
  74632. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  74633. * @param matrix defines the matrix to use
  74634. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  74635. */
  74636. Matrix.GetAsMatrix3x3 = function (matrix) {
  74637. var m = matrix.m;
  74638. return new Float32Array([
  74639. m[0], m[1], m[2],
  74640. m[4], m[5], m[6],
  74641. m[8], m[9], m[10]
  74642. ]);
  74643. };
  74644. /**
  74645. * Compute the transpose of a given matrix
  74646. * @param matrix defines the matrix to transpose
  74647. * @returns the new matrix
  74648. */
  74649. Matrix.Transpose = function (matrix) {
  74650. var result = new Matrix();
  74651. Matrix.TransposeToRef(matrix, result);
  74652. return result;
  74653. };
  74654. /**
  74655. * Compute the transpose of a matrix and store it in a target matrix
  74656. * @param matrix defines the matrix to transpose
  74657. * @param result defines the target matrix
  74658. */
  74659. Matrix.TransposeToRef = function (matrix, result) {
  74660. var rm = result._m;
  74661. var mm = matrix.m;
  74662. rm[0] = mm[0];
  74663. rm[1] = mm[4];
  74664. rm[2] = mm[8];
  74665. rm[3] = mm[12];
  74666. rm[4] = mm[1];
  74667. rm[5] = mm[5];
  74668. rm[6] = mm[9];
  74669. rm[7] = mm[13];
  74670. rm[8] = mm[2];
  74671. rm[9] = mm[6];
  74672. rm[10] = mm[10];
  74673. rm[11] = mm[14];
  74674. rm[12] = mm[3];
  74675. rm[13] = mm[7];
  74676. rm[14] = mm[11];
  74677. rm[15] = mm[15];
  74678. // identity-ness does not change when transposing
  74679. result._updateIdentityStatus(matrix._isIdentity, matrix._isIdentityDirty);
  74680. };
  74681. /**
  74682. * Computes a reflection matrix from a plane
  74683. * @param plane defines the reflection plane
  74684. * @returns a new matrix
  74685. */
  74686. Matrix.Reflection = function (plane) {
  74687. var matrix = new Matrix();
  74688. Matrix.ReflectionToRef(plane, matrix);
  74689. return matrix;
  74690. };
  74691. /**
  74692. * Computes a reflection matrix from a plane
  74693. * @param plane defines the reflection plane
  74694. * @param result defines the target matrix
  74695. */
  74696. Matrix.ReflectionToRef = function (plane, result) {
  74697. plane.normalize();
  74698. var x = plane.normal.x;
  74699. var y = plane.normal.y;
  74700. var z = plane.normal.z;
  74701. var temp = -2 * x;
  74702. var temp2 = -2 * y;
  74703. var temp3 = -2 * z;
  74704. 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);
  74705. };
  74706. /**
  74707. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  74708. * @param xaxis defines the value of the 1st axis
  74709. * @param yaxis defines the value of the 2nd axis
  74710. * @param zaxis defines the value of the 3rd axis
  74711. * @param result defines the target matrix
  74712. */
  74713. Matrix.FromXYZAxesToRef = function (xaxis, yaxis, zaxis, result) {
  74714. 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);
  74715. };
  74716. /**
  74717. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  74718. * @param quat defines the quaternion to use
  74719. * @param result defines the target matrix
  74720. */
  74721. Matrix.FromQuaternionToRef = function (quat, result) {
  74722. var xx = quat.x * quat.x;
  74723. var yy = quat.y * quat.y;
  74724. var zz = quat.z * quat.z;
  74725. var xy = quat.x * quat.y;
  74726. var zw = quat.z * quat.w;
  74727. var zx = quat.z * quat.x;
  74728. var yw = quat.y * quat.w;
  74729. var yz = quat.y * quat.z;
  74730. var xw = quat.x * quat.w;
  74731. result._m[0] = 1.0 - (2.0 * (yy + zz));
  74732. result._m[1] = 2.0 * (xy + zw);
  74733. result._m[2] = 2.0 * (zx - yw);
  74734. result._m[3] = 0.0;
  74735. result._m[4] = 2.0 * (xy - zw);
  74736. result._m[5] = 1.0 - (2.0 * (zz + xx));
  74737. result._m[6] = 2.0 * (yz + xw);
  74738. result._m[7] = 0.0;
  74739. result._m[8] = 2.0 * (zx + yw);
  74740. result._m[9] = 2.0 * (yz - xw);
  74741. result._m[10] = 1.0 - (2.0 * (yy + xx));
  74742. result._m[11] = 0.0;
  74743. result._m[12] = 0.0;
  74744. result._m[13] = 0.0;
  74745. result._m[14] = 0.0;
  74746. result._m[15] = 1.0;
  74747. result._markAsUpdated();
  74748. };
  74749. Matrix._updateFlagSeed = 0;
  74750. Matrix._identityReadOnly = Matrix.Identity();
  74751. return Matrix;
  74752. }());
  74753. /**
  74754. * Represens a plane by the equation ax + by + cz + d = 0
  74755. */
  74756. var Plane = /** @class */ (function () {
  74757. /**
  74758. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  74759. * @param a a component of the plane
  74760. * @param b b component of the plane
  74761. * @param c c component of the plane
  74762. * @param d d component of the plane
  74763. */
  74764. function Plane(a, b, c, d) {
  74765. this.normal = new Vector3(a, b, c);
  74766. this.d = d;
  74767. }
  74768. /**
  74769. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  74770. */
  74771. Plane.prototype.asArray = function () {
  74772. return [this.normal.x, this.normal.y, this.normal.z, this.d];
  74773. };
  74774. // Methods
  74775. /**
  74776. * @returns a new plane copied from the current Plane.
  74777. */
  74778. Plane.prototype.clone = function () {
  74779. return new Plane(this.normal.x, this.normal.y, this.normal.z, this.d);
  74780. };
  74781. /**
  74782. * @returns the string "Plane".
  74783. */
  74784. Plane.prototype.getClassName = function () {
  74785. return "Plane";
  74786. };
  74787. /**
  74788. * @returns the Plane hash code.
  74789. */
  74790. Plane.prototype.getHashCode = function () {
  74791. var hash = this.normal.getHashCode();
  74792. hash = (hash * 397) ^ (this.d || 0);
  74793. return hash;
  74794. };
  74795. /**
  74796. * Normalize the current Plane in place.
  74797. * @returns the updated Plane.
  74798. */
  74799. Plane.prototype.normalize = function () {
  74800. var norm = (Math.sqrt((this.normal.x * this.normal.x) + (this.normal.y * this.normal.y) + (this.normal.z * this.normal.z)));
  74801. var magnitude = 0.0;
  74802. if (norm !== 0) {
  74803. magnitude = 1.0 / norm;
  74804. }
  74805. this.normal.x *= magnitude;
  74806. this.normal.y *= magnitude;
  74807. this.normal.z *= magnitude;
  74808. this.d *= magnitude;
  74809. return this;
  74810. };
  74811. /**
  74812. * Applies a transformation the plane and returns the result
  74813. * @param transformation the transformation matrix to be applied to the plane
  74814. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  74815. */
  74816. Plane.prototype.transform = function (transformation) {
  74817. var transposedMatrix = MathTmp.Matrix[0];
  74818. Matrix.TransposeToRef(transformation, transposedMatrix);
  74819. var m = transposedMatrix.m;
  74820. var x = this.normal.x;
  74821. var y = this.normal.y;
  74822. var z = this.normal.z;
  74823. var d = this.d;
  74824. var normalX = x * m[0] + y * m[1] + z * m[2] + d * m[3];
  74825. var normalY = x * m[4] + y * m[5] + z * m[6] + d * m[7];
  74826. var normalZ = x * m[8] + y * m[9] + z * m[10] + d * m[11];
  74827. var finalD = x * m[12] + y * m[13] + z * m[14] + d * m[15];
  74828. return new Plane(normalX, normalY, normalZ, finalD);
  74829. };
  74830. /**
  74831. * Calcualtte the dot product between the point and the plane normal
  74832. * @param point point to calculate the dot product with
  74833. * @returns the dot product (float) of the point coordinates and the plane normal.
  74834. */
  74835. Plane.prototype.dotCoordinate = function (point) {
  74836. return ((((this.normal.x * point.x) + (this.normal.y * point.y)) + (this.normal.z * point.z)) + this.d);
  74837. };
  74838. /**
  74839. * Updates the current Plane from the plane defined by the three given points.
  74840. * @param point1 one of the points used to contruct the plane
  74841. * @param point2 one of the points used to contruct the plane
  74842. * @param point3 one of the points used to contruct the plane
  74843. * @returns the updated Plane.
  74844. */
  74845. Plane.prototype.copyFromPoints = function (point1, point2, point3) {
  74846. var x1 = point2.x - point1.x;
  74847. var y1 = point2.y - point1.y;
  74848. var z1 = point2.z - point1.z;
  74849. var x2 = point3.x - point1.x;
  74850. var y2 = point3.y - point1.y;
  74851. var z2 = point3.z - point1.z;
  74852. var yz = (y1 * z2) - (z1 * y2);
  74853. var xz = (z1 * x2) - (x1 * z2);
  74854. var xy = (x1 * y2) - (y1 * x2);
  74855. var pyth = (Math.sqrt((yz * yz) + (xz * xz) + (xy * xy)));
  74856. var invPyth;
  74857. if (pyth !== 0) {
  74858. invPyth = 1.0 / pyth;
  74859. }
  74860. else {
  74861. invPyth = 0.0;
  74862. }
  74863. this.normal.x = yz * invPyth;
  74864. this.normal.y = xz * invPyth;
  74865. this.normal.z = xy * invPyth;
  74866. this.d = -((this.normal.x * point1.x) + (this.normal.y * point1.y) + (this.normal.z * point1.z));
  74867. return this;
  74868. };
  74869. /**
  74870. * Checks if the plane is facing a given direction
  74871. * @param direction the direction to check if the plane is facing
  74872. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  74873. * @returns True is the vector "direction" is the same side than the plane normal.
  74874. */
  74875. Plane.prototype.isFrontFacingTo = function (direction, epsilon) {
  74876. var dot = Vector3.Dot(this.normal, direction);
  74877. return (dot <= epsilon);
  74878. };
  74879. /**
  74880. * Calculates the distance to a point
  74881. * @param point point to calculate distance to
  74882. * @returns the signed distance (float) from the given point to the Plane.
  74883. */
  74884. Plane.prototype.signedDistanceTo = function (point) {
  74885. return Vector3.Dot(point, this.normal) + this.d;
  74886. };
  74887. // Statics
  74888. /**
  74889. * Creates a plane from an array
  74890. * @param array the array to create a plane from
  74891. * @returns a new Plane from the given array.
  74892. */
  74893. Plane.FromArray = function (array) {
  74894. return new Plane(array[0], array[1], array[2], array[3]);
  74895. };
  74896. /**
  74897. * Creates a plane from three points
  74898. * @param point1 point used to create the plane
  74899. * @param point2 point used to create the plane
  74900. * @param point3 point used to create the plane
  74901. * @returns a new Plane defined by the three given points.
  74902. */
  74903. Plane.FromPoints = function (point1, point2, point3) {
  74904. var result = new Plane(0.0, 0.0, 0.0, 0.0);
  74905. result.copyFromPoints(point1, point2, point3);
  74906. return result;
  74907. };
  74908. /**
  74909. * Creates a plane from an origin point and a normal
  74910. * @param origin origin of the plane to be constructed
  74911. * @param normal normal of the plane to be constructed
  74912. * @returns a new Plane the normal vector to this plane at the given origin point.
  74913. * Note : the vector "normal" is updated because normalized.
  74914. */
  74915. Plane.FromPositionAndNormal = function (origin, normal) {
  74916. var result = new Plane(0.0, 0.0, 0.0, 0.0);
  74917. normal.normalize();
  74918. result.normal = normal;
  74919. result.d = -(normal.x * origin.x + normal.y * origin.y + normal.z * origin.z);
  74920. return result;
  74921. };
  74922. /**
  74923. * Calculates the distance from a plane and a point
  74924. * @param origin origin of the plane to be constructed
  74925. * @param normal normal of the plane to be constructed
  74926. * @param point point to calculate distance to
  74927. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  74928. */
  74929. Plane.SignedDistanceToPlaneFromPositionAndNormal = function (origin, normal, point) {
  74930. var d = -(normal.x * origin.x + normal.y * origin.y + normal.z * origin.z);
  74931. return Vector3.Dot(point, normal) + d;
  74932. };
  74933. return Plane;
  74934. }());
  74935. /**
  74936. * Class used to represent a viewport on screen
  74937. */
  74938. var Viewport = /** @class */ (function () {
  74939. /**
  74940. * Creates a Viewport object located at (x, y) and sized (width, height)
  74941. * @param x defines viewport left coordinate
  74942. * @param y defines viewport top coordinate
  74943. * @param width defines the viewport width
  74944. * @param height defines the viewport height
  74945. */
  74946. function Viewport(
  74947. /** viewport left coordinate */
  74948. x,
  74949. /** viewport top coordinate */
  74950. y,
  74951. /**viewport width */
  74952. width,
  74953. /** viewport height */
  74954. height) {
  74955. this.x = x;
  74956. this.y = y;
  74957. this.width = width;
  74958. this.height = height;
  74959. }
  74960. /**
  74961. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  74962. * @param renderWidth defines the rendering width
  74963. * @param renderHeight defines the rendering height
  74964. * @returns a new Viewport
  74965. */
  74966. Viewport.prototype.toGlobal = function (renderWidth, renderHeight) {
  74967. return new Viewport(this.x * renderWidth, this.y * renderHeight, this.width * renderWidth, this.height * renderHeight);
  74968. };
  74969. /**
  74970. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  74971. * @param renderWidth defines the rendering width
  74972. * @param renderHeight defines the rendering height
  74973. * @param ref defines the target viewport
  74974. * @returns the current viewport
  74975. */
  74976. Viewport.prototype.toGlobalToRef = function (renderWidth, renderHeight, ref) {
  74977. ref.x = this.x * renderWidth;
  74978. ref.y = this.y * renderHeight;
  74979. ref.width = this.width * renderWidth;
  74980. ref.height = this.height * renderHeight;
  74981. return this;
  74982. };
  74983. /**
  74984. * Returns a new Viewport copied from the current one
  74985. * @returns a new Viewport
  74986. */
  74987. Viewport.prototype.clone = function () {
  74988. return new Viewport(this.x, this.y, this.width, this.height);
  74989. };
  74990. return Viewport;
  74991. }());
  74992. /**
  74993. * Reprasents a camera frustum
  74994. */
  74995. var Frustum = /** @class */ (function () {
  74996. function Frustum() {
  74997. }
  74998. /**
  74999. * Gets the planes representing the frustum
  75000. * @param transform matrix to be applied to the returned planes
  75001. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  75002. */
  75003. Frustum.GetPlanes = function (transform) {
  75004. var frustumPlanes = [];
  75005. for (var index = 0; index < 6; index++) {
  75006. frustumPlanes.push(new Plane(0.0, 0.0, 0.0, 0.0));
  75007. }
  75008. Frustum.GetPlanesToRef(transform, frustumPlanes);
  75009. return frustumPlanes;
  75010. };
  75011. /**
  75012. * Gets the near frustum plane transformed by the transform matrix
  75013. * @param transform transformation matrix to be applied to the resulting frustum plane
  75014. * @param frustumPlane the resuling frustum plane
  75015. */
  75016. Frustum.GetNearPlaneToRef = function (transform, frustumPlane) {
  75017. var m = transform.m;
  75018. frustumPlane.normal.x = m[3] + m[2];
  75019. frustumPlane.normal.y = m[7] + m[6];
  75020. frustumPlane.normal.z = m[11] + m[10];
  75021. frustumPlane.d = m[15] + m[14];
  75022. frustumPlane.normalize();
  75023. };
  75024. /**
  75025. * Gets the far frustum plane transformed by the transform matrix
  75026. * @param transform transformation matrix to be applied to the resulting frustum plane
  75027. * @param frustumPlane the resuling frustum plane
  75028. */
  75029. Frustum.GetFarPlaneToRef = function (transform, frustumPlane) {
  75030. var m = transform.m;
  75031. frustumPlane.normal.x = m[3] - m[2];
  75032. frustumPlane.normal.y = m[7] - m[6];
  75033. frustumPlane.normal.z = m[11] - m[10];
  75034. frustumPlane.d = m[15] - m[14];
  75035. frustumPlane.normalize();
  75036. };
  75037. /**
  75038. * Gets the left frustum plane transformed by the transform matrix
  75039. * @param transform transformation matrix to be applied to the resulting frustum plane
  75040. * @param frustumPlane the resuling frustum plane
  75041. */
  75042. Frustum.GetLeftPlaneToRef = function (transform, frustumPlane) {
  75043. var m = transform.m;
  75044. frustumPlane.normal.x = m[3] + m[0];
  75045. frustumPlane.normal.y = m[7] + m[4];
  75046. frustumPlane.normal.z = m[11] + m[8];
  75047. frustumPlane.d = m[15] + m[12];
  75048. frustumPlane.normalize();
  75049. };
  75050. /**
  75051. * Gets the right frustum plane transformed by the transform matrix
  75052. * @param transform transformation matrix to be applied to the resulting frustum plane
  75053. * @param frustumPlane the resuling frustum plane
  75054. */
  75055. Frustum.GetRightPlaneToRef = function (transform, frustumPlane) {
  75056. var m = transform.m;
  75057. frustumPlane.normal.x = m[3] - m[0];
  75058. frustumPlane.normal.y = m[7] - m[4];
  75059. frustumPlane.normal.z = m[11] - m[8];
  75060. frustumPlane.d = m[15] - m[12];
  75061. frustumPlane.normalize();
  75062. };
  75063. /**
  75064. * Gets the top frustum plane transformed by the transform matrix
  75065. * @param transform transformation matrix to be applied to the resulting frustum plane
  75066. * @param frustumPlane the resuling frustum plane
  75067. */
  75068. Frustum.GetTopPlaneToRef = function (transform, frustumPlane) {
  75069. var m = transform.m;
  75070. frustumPlane.normal.x = m[3] - m[1];
  75071. frustumPlane.normal.y = m[7] - m[5];
  75072. frustumPlane.normal.z = m[11] - m[9];
  75073. frustumPlane.d = m[15] - m[13];
  75074. frustumPlane.normalize();
  75075. };
  75076. /**
  75077. * Gets the bottom frustum plane transformed by the transform matrix
  75078. * @param transform transformation matrix to be applied to the resulting frustum plane
  75079. * @param frustumPlane the resuling frustum plane
  75080. */
  75081. Frustum.GetBottomPlaneToRef = function (transform, frustumPlane) {
  75082. var m = transform.m;
  75083. frustumPlane.normal.x = m[3] + m[1];
  75084. frustumPlane.normal.y = m[7] + m[5];
  75085. frustumPlane.normal.z = m[11] + m[9];
  75086. frustumPlane.d = m[15] + m[13];
  75087. frustumPlane.normalize();
  75088. };
  75089. /**
  75090. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  75091. * @param transform transformation matrix to be applied to the resulting frustum planes
  75092. * @param frustumPlanes the resuling frustum planes
  75093. */
  75094. Frustum.GetPlanesToRef = function (transform, frustumPlanes) {
  75095. // Near
  75096. Frustum.GetNearPlaneToRef(transform, frustumPlanes[0]);
  75097. // Far
  75098. Frustum.GetFarPlaneToRef(transform, frustumPlanes[1]);
  75099. // Left
  75100. Frustum.GetLeftPlaneToRef(transform, frustumPlanes[2]);
  75101. // Right
  75102. Frustum.GetRightPlaneToRef(transform, frustumPlanes[3]);
  75103. // Top
  75104. Frustum.GetTopPlaneToRef(transform, frustumPlanes[4]);
  75105. // Bottom
  75106. Frustum.GetBottomPlaneToRef(transform, frustumPlanes[5]);
  75107. };
  75108. return Frustum;
  75109. }());
  75110. /** Defines supported spaces */
  75111. var Space;
  75112. (function (Space) {
  75113. /** Local (object) space */
  75114. Space[Space["LOCAL"] = 0] = "LOCAL";
  75115. /** World space */
  75116. Space[Space["WORLD"] = 1] = "WORLD";
  75117. /** Bone space */
  75118. Space[Space["BONE"] = 2] = "BONE";
  75119. })(Space || (Space = {}));
  75120. /** Defines the 3 main axes */
  75121. var Axis = /** @class */ (function () {
  75122. function Axis() {
  75123. }
  75124. /** X axis */
  75125. Axis.X = new Vector3(1.0, 0.0, 0.0);
  75126. /** Y axis */
  75127. Axis.Y = new Vector3(0.0, 1.0, 0.0);
  75128. /** Z axis */
  75129. Axis.Z = new Vector3(0.0, 0.0, 1.0);
  75130. return Axis;
  75131. }());
  75132. /** Class used to represent a Bezier curve */
  75133. var BezierCurve = /** @class */ (function () {
  75134. function BezierCurve() {
  75135. }
  75136. /**
  75137. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  75138. * @param t defines the time
  75139. * @param x1 defines the left coordinate on X axis
  75140. * @param y1 defines the left coordinate on Y axis
  75141. * @param x2 defines the right coordinate on X axis
  75142. * @param y2 defines the right coordinate on Y axis
  75143. * @returns the interpolated value
  75144. */
  75145. BezierCurve.Interpolate = function (t, x1, y1, x2, y2) {
  75146. // Extract X (which is equal to time here)
  75147. var f0 = 1 - 3 * x2 + 3 * x1;
  75148. var f1 = 3 * x2 - 6 * x1;
  75149. var f2 = 3 * x1;
  75150. var refinedT = t;
  75151. for (var i = 0; i < 5; i++) {
  75152. var refinedT2 = refinedT * refinedT;
  75153. var refinedT3 = refinedT2 * refinedT;
  75154. var x = f0 * refinedT3 + f1 * refinedT2 + f2 * refinedT;
  75155. var slope = 1.0 / (3.0 * f0 * refinedT2 + 2.0 * f1 * refinedT + f2);
  75156. refinedT -= (x - t) * slope;
  75157. refinedT = Math.min(1, Math.max(0, refinedT));
  75158. }
  75159. // Resolve cubic bezier for the given x
  75160. return 3 * Math.pow(1 - refinedT, 2) * refinedT * y1 +
  75161. 3 * (1 - refinedT) * Math.pow(refinedT, 2) * y2 +
  75162. Math.pow(refinedT, 3);
  75163. };
  75164. return BezierCurve;
  75165. }());
  75166. /**
  75167. * Defines potential orientation for back face culling
  75168. */
  75169. var Orientation;
  75170. (function (Orientation) {
  75171. /**
  75172. * Clockwise
  75173. */
  75174. Orientation[Orientation["CW"] = 0] = "CW";
  75175. /** Counter clockwise */
  75176. Orientation[Orientation["CCW"] = 1] = "CCW";
  75177. })(Orientation || (Orientation = {}));
  75178. /**
  75179. * Defines angle representation
  75180. */
  75181. var Angle = /** @class */ (function () {
  75182. /**
  75183. * Creates an Angle object of "radians" radians (float).
  75184. * @param radians the angle in radians
  75185. */
  75186. function Angle(radians) {
  75187. this._radians = radians;
  75188. if (this._radians < 0.0) {
  75189. this._radians += (2.0 * Math.PI);
  75190. }
  75191. }
  75192. /**
  75193. * Get value in degrees
  75194. * @returns the Angle value in degrees (float)
  75195. */
  75196. Angle.prototype.degrees = function () {
  75197. return this._radians * 180.0 / Math.PI;
  75198. };
  75199. /**
  75200. * Get value in radians
  75201. * @returns the Angle value in radians (float)
  75202. */
  75203. Angle.prototype.radians = function () {
  75204. return this._radians;
  75205. };
  75206. /**
  75207. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  75208. * @param a defines first vector
  75209. * @param b defines second vector
  75210. * @returns a new Angle
  75211. */
  75212. Angle.BetweenTwoPoints = function (a, b) {
  75213. var delta = b.subtract(a);
  75214. var theta = Math.atan2(delta.y, delta.x);
  75215. return new Angle(theta);
  75216. };
  75217. /**
  75218. * Gets a new Angle object from the given float in radians
  75219. * @param radians defines the angle value in radians
  75220. * @returns a new Angle
  75221. */
  75222. Angle.FromRadians = function (radians) {
  75223. return new Angle(radians);
  75224. };
  75225. /**
  75226. * Gets a new Angle object from the given float in degrees
  75227. * @param degrees defines the angle value in degrees
  75228. * @returns a new Angle
  75229. */
  75230. Angle.FromDegrees = function (degrees) {
  75231. return new Angle(degrees * Math.PI / 180.0);
  75232. };
  75233. return Angle;
  75234. }());
  75235. /**
  75236. * This represents an arc in a 2d space.
  75237. */
  75238. var Arc2 = /** @class */ (function () {
  75239. /**
  75240. * Creates an Arc object from the three given points : start, middle and end.
  75241. * @param startPoint Defines the start point of the arc
  75242. * @param midPoint Defines the midlle point of the arc
  75243. * @param endPoint Defines the end point of the arc
  75244. */
  75245. function Arc2(
  75246. /** Defines the start point of the arc */
  75247. startPoint,
  75248. /** Defines the mid point of the arc */
  75249. midPoint,
  75250. /** Defines the end point of the arc */
  75251. endPoint) {
  75252. this.startPoint = startPoint;
  75253. this.midPoint = midPoint;
  75254. this.endPoint = endPoint;
  75255. var temp = Math.pow(midPoint.x, 2) + Math.pow(midPoint.y, 2);
  75256. var startToMid = (Math.pow(startPoint.x, 2) + Math.pow(startPoint.y, 2) - temp) / 2.;
  75257. var midToEnd = (temp - Math.pow(endPoint.x, 2) - Math.pow(endPoint.y, 2)) / 2.;
  75258. var det = (startPoint.x - midPoint.x) * (midPoint.y - endPoint.y) - (midPoint.x - endPoint.x) * (startPoint.y - midPoint.y);
  75259. 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);
  75260. this.radius = this.centerPoint.subtract(this.startPoint).length();
  75261. this.startAngle = Angle.BetweenTwoPoints(this.centerPoint, this.startPoint);
  75262. var a1 = this.startAngle.degrees();
  75263. var a2 = Angle.BetweenTwoPoints(this.centerPoint, this.midPoint).degrees();
  75264. var a3 = Angle.BetweenTwoPoints(this.centerPoint, this.endPoint).degrees();
  75265. // angles correction
  75266. if (a2 - a1 > +180.0) {
  75267. a2 -= 360.0;
  75268. }
  75269. if (a2 - a1 < -180.0) {
  75270. a2 += 360.0;
  75271. }
  75272. if (a3 - a2 > +180.0) {
  75273. a3 -= 360.0;
  75274. }
  75275. if (a3 - a2 < -180.0) {
  75276. a3 += 360.0;
  75277. }
  75278. this.orientation = (a2 - a1) < 0 ? Orientation.CW : Orientation.CCW;
  75279. this.angle = Angle.FromDegrees(this.orientation === Orientation.CW ? a1 - a3 : a3 - a1);
  75280. }
  75281. return Arc2;
  75282. }());
  75283. /**
  75284. * Represents a 2D path made up of multiple 2D points
  75285. */
  75286. var Path2 = /** @class */ (function () {
  75287. /**
  75288. * Creates a Path2 object from the starting 2D coordinates x and y.
  75289. * @param x the starting points x value
  75290. * @param y the starting points y value
  75291. */
  75292. function Path2(x, y) {
  75293. this._points = new Array();
  75294. this._length = 0.0;
  75295. /**
  75296. * If the path start and end point are the same
  75297. */
  75298. this.closed = false;
  75299. this._points.push(new Vector2(x, y));
  75300. }
  75301. /**
  75302. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  75303. * @param x the added points x value
  75304. * @param y the added points y value
  75305. * @returns the updated Path2.
  75306. */
  75307. Path2.prototype.addLineTo = function (x, y) {
  75308. if (this.closed) {
  75309. return this;
  75310. }
  75311. var newPoint = new Vector2(x, y);
  75312. var previousPoint = this._points[this._points.length - 1];
  75313. this._points.push(newPoint);
  75314. this._length += newPoint.subtract(previousPoint).length();
  75315. return this;
  75316. };
  75317. /**
  75318. * 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.
  75319. * @param midX middle point x value
  75320. * @param midY middle point y value
  75321. * @param endX end point x value
  75322. * @param endY end point y value
  75323. * @param numberOfSegments (default: 36)
  75324. * @returns the updated Path2.
  75325. */
  75326. Path2.prototype.addArcTo = function (midX, midY, endX, endY, numberOfSegments) {
  75327. if (numberOfSegments === void 0) { numberOfSegments = 36; }
  75328. if (this.closed) {
  75329. return this;
  75330. }
  75331. var startPoint = this._points[this._points.length - 1];
  75332. var midPoint = new Vector2(midX, midY);
  75333. var endPoint = new Vector2(endX, endY);
  75334. var arc = new Arc2(startPoint, midPoint, endPoint);
  75335. var increment = arc.angle.radians() / numberOfSegments;
  75336. if (arc.orientation === Orientation.CW) {
  75337. increment *= -1;
  75338. }
  75339. var currentAngle = arc.startAngle.radians() + increment;
  75340. for (var i = 0; i < numberOfSegments; i++) {
  75341. var x = Math.cos(currentAngle) * arc.radius + arc.centerPoint.x;
  75342. var y = Math.sin(currentAngle) * arc.radius + arc.centerPoint.y;
  75343. this.addLineTo(x, y);
  75344. currentAngle += increment;
  75345. }
  75346. return this;
  75347. };
  75348. /**
  75349. * Closes the Path2.
  75350. * @returns the Path2.
  75351. */
  75352. Path2.prototype.close = function () {
  75353. this.closed = true;
  75354. return this;
  75355. };
  75356. /**
  75357. * Gets the sum of the distance between each sequential point in the path
  75358. * @returns the Path2 total length (float).
  75359. */
  75360. Path2.prototype.length = function () {
  75361. var result = this._length;
  75362. if (!this.closed) {
  75363. var lastPoint = this._points[this._points.length - 1];
  75364. var firstPoint = this._points[0];
  75365. result += (firstPoint.subtract(lastPoint).length());
  75366. }
  75367. return result;
  75368. };
  75369. /**
  75370. * Gets the points which construct the path
  75371. * @returns the Path2 internal array of points.
  75372. */
  75373. Path2.prototype.getPoints = function () {
  75374. return this._points;
  75375. };
  75376. /**
  75377. * Retreives the point at the distance aways from the starting point
  75378. * @param normalizedLengthPosition the length along the path to retreive the point from
  75379. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  75380. */
  75381. Path2.prototype.getPointAtLengthPosition = function (normalizedLengthPosition) {
  75382. if (normalizedLengthPosition < 0 || normalizedLengthPosition > 1) {
  75383. return Vector2.Zero();
  75384. }
  75385. var lengthPosition = normalizedLengthPosition * this.length();
  75386. var previousOffset = 0;
  75387. for (var i = 0; i < this._points.length; i++) {
  75388. var j = (i + 1) % this._points.length;
  75389. var a = this._points[i];
  75390. var b = this._points[j];
  75391. var bToA = b.subtract(a);
  75392. var nextOffset = (bToA.length() + previousOffset);
  75393. if (lengthPosition >= previousOffset && lengthPosition <= nextOffset) {
  75394. var dir = bToA.normalize();
  75395. var localOffset = lengthPosition - previousOffset;
  75396. return new Vector2(a.x + (dir.x * localOffset), a.y + (dir.y * localOffset));
  75397. }
  75398. previousOffset = nextOffset;
  75399. }
  75400. return Vector2.Zero();
  75401. };
  75402. /**
  75403. * Creates a new path starting from an x and y position
  75404. * @param x starting x value
  75405. * @param y starting y value
  75406. * @returns a new Path2 starting at the coordinates (x, y).
  75407. */
  75408. Path2.StartingAt = function (x, y) {
  75409. return new Path2(x, y);
  75410. };
  75411. return Path2;
  75412. }());
  75413. /**
  75414. * Represents a 3D path made up of multiple 3D points
  75415. */
  75416. var Path3D = /** @class */ (function () {
  75417. /**
  75418. * new Path3D(path, normal, raw)
  75419. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  75420. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  75421. * @param path an array of Vector3, the curve axis of the Path3D
  75422. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  75423. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  75424. */
  75425. function Path3D(
  75426. /**
  75427. * an array of Vector3, the curve axis of the Path3D
  75428. */
  75429. path, firstNormal, raw) {
  75430. if (firstNormal === void 0) { firstNormal = null; }
  75431. this.path = path;
  75432. this._curve = new Array();
  75433. this._distances = new Array();
  75434. this._tangents = new Array();
  75435. this._normals = new Array();
  75436. this._binormals = new Array();
  75437. for (var p = 0; p < path.length; p++) {
  75438. this._curve[p] = path[p].clone(); // hard copy
  75439. }
  75440. this._raw = raw || false;
  75441. this._compute(firstNormal);
  75442. }
  75443. /**
  75444. * Returns the Path3D array of successive Vector3 designing its curve.
  75445. * @returns the Path3D array of successive Vector3 designing its curve.
  75446. */
  75447. Path3D.prototype.getCurve = function () {
  75448. return this._curve;
  75449. };
  75450. /**
  75451. * Returns an array populated with tangent vectors on each Path3D curve point.
  75452. * @returns an array populated with tangent vectors on each Path3D curve point.
  75453. */
  75454. Path3D.prototype.getTangents = function () {
  75455. return this._tangents;
  75456. };
  75457. /**
  75458. * Returns an array populated with normal vectors on each Path3D curve point.
  75459. * @returns an array populated with normal vectors on each Path3D curve point.
  75460. */
  75461. Path3D.prototype.getNormals = function () {
  75462. return this._normals;
  75463. };
  75464. /**
  75465. * Returns an array populated with binormal vectors on each Path3D curve point.
  75466. * @returns an array populated with binormal vectors on each Path3D curve point.
  75467. */
  75468. Path3D.prototype.getBinormals = function () {
  75469. return this._binormals;
  75470. };
  75471. /**
  75472. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  75473. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  75474. */
  75475. Path3D.prototype.getDistances = function () {
  75476. return this._distances;
  75477. };
  75478. /**
  75479. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  75480. * @param path path which all values are copied into the curves points
  75481. * @param firstNormal which should be projected onto the curve
  75482. * @returns the same object updated.
  75483. */
  75484. Path3D.prototype.update = function (path, firstNormal) {
  75485. if (firstNormal === void 0) { firstNormal = null; }
  75486. for (var p = 0; p < path.length; p++) {
  75487. this._curve[p].x = path[p].x;
  75488. this._curve[p].y = path[p].y;
  75489. this._curve[p].z = path[p].z;
  75490. }
  75491. this._compute(firstNormal);
  75492. return this;
  75493. };
  75494. // private function compute() : computes tangents, normals and binormals
  75495. Path3D.prototype._compute = function (firstNormal) {
  75496. var l = this._curve.length;
  75497. // first and last tangents
  75498. this._tangents[0] = this._getFirstNonNullVector(0);
  75499. if (!this._raw) {
  75500. this._tangents[0].normalize();
  75501. }
  75502. this._tangents[l - 1] = this._curve[l - 1].subtract(this._curve[l - 2]);
  75503. if (!this._raw) {
  75504. this._tangents[l - 1].normalize();
  75505. }
  75506. // normals and binormals at first point : arbitrary vector with _normalVector()
  75507. var tg0 = this._tangents[0];
  75508. var pp0 = this._normalVector(tg0, firstNormal);
  75509. this._normals[0] = pp0;
  75510. if (!this._raw) {
  75511. this._normals[0].normalize();
  75512. }
  75513. this._binormals[0] = Vector3.Cross(tg0, this._normals[0]);
  75514. if (!this._raw) {
  75515. this._binormals[0].normalize();
  75516. }
  75517. this._distances[0] = 0.0;
  75518. // normals and binormals : next points
  75519. var prev; // previous vector (segment)
  75520. var cur; // current vector (segment)
  75521. var curTang; // current tangent
  75522. // previous normal
  75523. var prevBinor; // previous binormal
  75524. for (var i = 1; i < l; i++) {
  75525. // tangents
  75526. prev = this._getLastNonNullVector(i);
  75527. if (i < l - 1) {
  75528. cur = this._getFirstNonNullVector(i);
  75529. this._tangents[i] = prev.add(cur);
  75530. this._tangents[i].normalize();
  75531. }
  75532. this._distances[i] = this._distances[i - 1] + prev.length();
  75533. // normals and binormals
  75534. // http://www.cs.cmu.edu/afs/andrew/scs/cs/15-462/web/old/asst2camera.html
  75535. curTang = this._tangents[i];
  75536. prevBinor = this._binormals[i - 1];
  75537. this._normals[i] = Vector3.Cross(prevBinor, curTang);
  75538. if (!this._raw) {
  75539. this._normals[i].normalize();
  75540. }
  75541. this._binormals[i] = Vector3.Cross(curTang, this._normals[i]);
  75542. if (!this._raw) {
  75543. this._binormals[i].normalize();
  75544. }
  75545. }
  75546. };
  75547. // private function getFirstNonNullVector(index)
  75548. // returns the first non null vector from index : curve[index + N].subtract(curve[index])
  75549. Path3D.prototype._getFirstNonNullVector = function (index) {
  75550. var i = 1;
  75551. var nNVector = this._curve[index + i].subtract(this._curve[index]);
  75552. while (nNVector.length() === 0 && index + i + 1 < this._curve.length) {
  75553. i++;
  75554. nNVector = this._curve[index + i].subtract(this._curve[index]);
  75555. }
  75556. return nNVector;
  75557. };
  75558. // private function getLastNonNullVector(index)
  75559. // returns the last non null vector from index : curve[index].subtract(curve[index - N])
  75560. Path3D.prototype._getLastNonNullVector = function (index) {
  75561. var i = 1;
  75562. var nLVector = this._curve[index].subtract(this._curve[index - i]);
  75563. while (nLVector.length() === 0 && index > i + 1) {
  75564. i++;
  75565. nLVector = this._curve[index].subtract(this._curve[index - i]);
  75566. }
  75567. return nLVector;
  75568. };
  75569. // private function normalVector(v0, vt, va) :
  75570. // returns an arbitrary point in the plane defined by the point v0 and the vector vt orthogonal to this plane
  75571. // if va is passed, it returns the va projection on the plane orthogonal to vt at the point v0
  75572. Path3D.prototype._normalVector = function (vt, va) {
  75573. var normal0;
  75574. var tgl = vt.length();
  75575. if (tgl === 0.0) {
  75576. tgl = 1.0;
  75577. }
  75578. if (va === undefined || va === null) {
  75579. var point;
  75580. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.y) / tgl, 1.0, Epsilon)) { // search for a point in the plane
  75581. point = new Vector3(0.0, -1.0, 0.0);
  75582. }
  75583. else if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.x) / tgl, 1.0, Epsilon)) {
  75584. point = new Vector3(1.0, 0.0, 0.0);
  75585. }
  75586. else if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.z) / tgl, 1.0, Epsilon)) {
  75587. point = new Vector3(0.0, 0.0, 1.0);
  75588. }
  75589. else {
  75590. point = Vector3.Zero();
  75591. }
  75592. normal0 = Vector3.Cross(vt, point);
  75593. }
  75594. else {
  75595. normal0 = Vector3.Cross(vt, va);
  75596. Vector3.CrossToRef(normal0, vt, normal0);
  75597. }
  75598. normal0.normalize();
  75599. return normal0;
  75600. };
  75601. return Path3D;
  75602. }());
  75603. /**
  75604. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  75605. * A Curve3 is designed from a series of successive Vector3.
  75606. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  75607. */
  75608. var Curve3 = /** @class */ (function () {
  75609. /**
  75610. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  75611. * A Curve3 is designed from a series of successive Vector3.
  75612. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  75613. * @param points points which make up the curve
  75614. */
  75615. function Curve3(points) {
  75616. this._length = 0.0;
  75617. this._points = points;
  75618. this._length = this._computeLength(points);
  75619. }
  75620. /**
  75621. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  75622. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  75623. * @param v1 (Vector3) the control point
  75624. * @param v2 (Vector3) the end point of the Quadratic Bezier
  75625. * @param nbPoints (integer) the wanted number of points in the curve
  75626. * @returns the created Curve3
  75627. */
  75628. Curve3.CreateQuadraticBezier = function (v0, v1, v2, nbPoints) {
  75629. nbPoints = nbPoints > 2 ? nbPoints : 3;
  75630. var bez = new Array();
  75631. var equation = function (t, val0, val1, val2) {
  75632. var res = (1.0 - t) * (1.0 - t) * val0 + 2.0 * t * (1.0 - t) * val1 + t * t * val2;
  75633. return res;
  75634. };
  75635. for (var i = 0; i <= nbPoints; i++) {
  75636. 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)));
  75637. }
  75638. return new Curve3(bez);
  75639. };
  75640. /**
  75641. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  75642. * @param v0 (Vector3) the origin point of the Cubic Bezier
  75643. * @param v1 (Vector3) the first control point
  75644. * @param v2 (Vector3) the second control point
  75645. * @param v3 (Vector3) the end point of the Cubic Bezier
  75646. * @param nbPoints (integer) the wanted number of points in the curve
  75647. * @returns the created Curve3
  75648. */
  75649. Curve3.CreateCubicBezier = function (v0, v1, v2, v3, nbPoints) {
  75650. nbPoints = nbPoints > 3 ? nbPoints : 4;
  75651. var bez = new Array();
  75652. var equation = function (t, val0, val1, val2, val3) {
  75653. 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;
  75654. return res;
  75655. };
  75656. for (var i = 0; i <= nbPoints; i++) {
  75657. 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)));
  75658. }
  75659. return new Curve3(bez);
  75660. };
  75661. /**
  75662. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  75663. * @param p1 (Vector3) the origin point of the Hermite Spline
  75664. * @param t1 (Vector3) the tangent vector at the origin point
  75665. * @param p2 (Vector3) the end point of the Hermite Spline
  75666. * @param t2 (Vector3) the tangent vector at the end point
  75667. * @param nbPoints (integer) the wanted number of points in the curve
  75668. * @returns the created Curve3
  75669. */
  75670. Curve3.CreateHermiteSpline = function (p1, t1, p2, t2, nbPoints) {
  75671. var hermite = new Array();
  75672. var step = 1.0 / nbPoints;
  75673. for (var i = 0; i <= nbPoints; i++) {
  75674. hermite.push(Vector3.Hermite(p1, t1, p2, t2, i * step));
  75675. }
  75676. return new Curve3(hermite);
  75677. };
  75678. /**
  75679. * Returns a Curve3 object along a CatmullRom Spline curve :
  75680. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  75681. * @param nbPoints (integer) the wanted number of points between each curve control points
  75682. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  75683. * @returns the created Curve3
  75684. */
  75685. Curve3.CreateCatmullRomSpline = function (points, nbPoints, closed) {
  75686. var catmullRom = new Array();
  75687. var step = 1.0 / nbPoints;
  75688. var amount = 0.0;
  75689. if (closed) {
  75690. var pointsCount = points.length;
  75691. for (var i = 0; i < pointsCount; i++) {
  75692. amount = 0;
  75693. for (var c = 0; c < nbPoints; c++) {
  75694. catmullRom.push(Vector3.CatmullRom(points[i % pointsCount], points[(i + 1) % pointsCount], points[(i + 2) % pointsCount], points[(i + 3) % pointsCount], amount));
  75695. amount += step;
  75696. }
  75697. }
  75698. catmullRom.push(catmullRom[0]);
  75699. }
  75700. else {
  75701. var totalPoints = new Array();
  75702. totalPoints.push(points[0].clone());
  75703. Array.prototype.push.apply(totalPoints, points);
  75704. totalPoints.push(points[points.length - 1].clone());
  75705. for (var i = 0; i < totalPoints.length - 3; i++) {
  75706. amount = 0;
  75707. for (var c = 0; c < nbPoints; c++) {
  75708. catmullRom.push(Vector3.CatmullRom(totalPoints[i], totalPoints[i + 1], totalPoints[i + 2], totalPoints[i + 3], amount));
  75709. amount += step;
  75710. }
  75711. }
  75712. i--;
  75713. catmullRom.push(Vector3.CatmullRom(totalPoints[i], totalPoints[i + 1], totalPoints[i + 2], totalPoints[i + 3], amount));
  75714. }
  75715. return new Curve3(catmullRom);
  75716. };
  75717. /**
  75718. * @returns the Curve3 stored array of successive Vector3
  75719. */
  75720. Curve3.prototype.getPoints = function () {
  75721. return this._points;
  75722. };
  75723. /**
  75724. * @returns the computed length (float) of the curve.
  75725. */
  75726. Curve3.prototype.length = function () {
  75727. return this._length;
  75728. };
  75729. /**
  75730. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  75731. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  75732. * curveA and curveB keep unchanged.
  75733. * @param curve the curve to continue from this curve
  75734. * @returns the newly constructed curve
  75735. */
  75736. Curve3.prototype.continue = function (curve) {
  75737. var lastPoint = this._points[this._points.length - 1];
  75738. var continuedPoints = this._points.slice();
  75739. var curvePoints = curve.getPoints();
  75740. for (var i = 1; i < curvePoints.length; i++) {
  75741. continuedPoints.push(curvePoints[i].subtract(curvePoints[0]).add(lastPoint));
  75742. }
  75743. var continuedCurve = new Curve3(continuedPoints);
  75744. return continuedCurve;
  75745. };
  75746. Curve3.prototype._computeLength = function (path) {
  75747. var l = 0;
  75748. for (var i = 1; i < path.length; i++) {
  75749. l += (path[i].subtract(path[i - 1])).length();
  75750. }
  75751. return l;
  75752. };
  75753. return Curve3;
  75754. }());
  75755. // Vertex formats
  75756. /**
  75757. * Contains position and normal vectors for a vertex
  75758. */
  75759. var PositionNormalVertex = /** @class */ (function () {
  75760. /**
  75761. * Creates a PositionNormalVertex
  75762. * @param position the position of the vertex (defaut: 0,0,0)
  75763. * @param normal the normal of the vertex (defaut: 0,1,0)
  75764. */
  75765. function PositionNormalVertex(
  75766. /** the position of the vertex (defaut: 0,0,0) */
  75767. position,
  75768. /** the normal of the vertex (defaut: 0,1,0) */
  75769. normal) {
  75770. if (position === void 0) { position = Vector3.Zero(); }
  75771. if (normal === void 0) { normal = Vector3.Up(); }
  75772. this.position = position;
  75773. this.normal = normal;
  75774. }
  75775. /**
  75776. * Clones the PositionNormalVertex
  75777. * @returns the cloned PositionNormalVertex
  75778. */
  75779. PositionNormalVertex.prototype.clone = function () {
  75780. return new PositionNormalVertex(this.position.clone(), this.normal.clone());
  75781. };
  75782. return PositionNormalVertex;
  75783. }());
  75784. /**
  75785. * Contains position, normal and uv vectors for a vertex
  75786. */
  75787. var PositionNormalTextureVertex = /** @class */ (function () {
  75788. /**
  75789. * Creates a PositionNormalTextureVertex
  75790. * @param position the position of the vertex (defaut: 0,0,0)
  75791. * @param normal the normal of the vertex (defaut: 0,1,0)
  75792. * @param uv the uv of the vertex (default: 0,0)
  75793. */
  75794. function PositionNormalTextureVertex(
  75795. /** the position of the vertex (defaut: 0,0,0) */
  75796. position,
  75797. /** the normal of the vertex (defaut: 0,1,0) */
  75798. normal,
  75799. /** the uv of the vertex (default: 0,0) */
  75800. uv) {
  75801. if (position === void 0) { position = Vector3.Zero(); }
  75802. if (normal === void 0) { normal = Vector3.Up(); }
  75803. if (uv === void 0) { uv = Vector2.Zero(); }
  75804. this.position = position;
  75805. this.normal = normal;
  75806. this.uv = uv;
  75807. }
  75808. /**
  75809. * Clones the PositionNormalTextureVertex
  75810. * @returns the cloned PositionNormalTextureVertex
  75811. */
  75812. PositionNormalTextureVertex.prototype.clone = function () {
  75813. return new PositionNormalTextureVertex(this.position.clone(), this.normal.clone(), this.uv.clone());
  75814. };
  75815. return PositionNormalTextureVertex;
  75816. }());
  75817. // Temporary pre-allocated objects for engine internal use
  75818. // usage in any internal function :
  75819. // var tmp = Tmp.Vector3[0]; <= gets access to the first pre-created Vector3
  75820. // There's a Tmp array per object type : int, float, Vector2, Vector3, Vector4, Quaternion, Matrix
  75821. /**
  75822. * @hidden
  75823. */
  75824. var Tmp = /** @class */ (function () {
  75825. function Tmp() {
  75826. }
  75827. Tmp.Color3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Color3.Black);
  75828. Tmp.Color4 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, function () { return new Color4(0, 0, 0, 0); });
  75829. Tmp.Vector2 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Vector2.Zero); // 3 temp Vector2 at once should be enough
  75830. Tmp.Vector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(13, Vector3.Zero); // 13 temp Vector3 at once should be enough
  75831. Tmp.Vector4 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Vector4.Zero); // 3 temp Vector4 at once should be enough
  75832. Tmp.Quaternion = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, Quaternion.Zero); // 2 temp Quaternion at once should be enough
  75833. Tmp.Matrix = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, Matrix.Identity); // 8 temp Matrices at once should be enough
  75834. return Tmp;
  75835. }());
  75836. /**
  75837. * @hidden
  75838. * Same as Tmp but not exported to keep it only for math functions to avoid conflicts
  75839. */
  75840. var MathTmp = /** @class */ (function () {
  75841. function MathTmp() {
  75842. }
  75843. MathTmp.Vector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(6, Vector3.Zero);
  75844. MathTmp.Matrix = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, Matrix.Identity);
  75845. MathTmp.Quaternion = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Quaternion.Zero);
  75846. return MathTmp;
  75847. }());
  75848. /***/ }),
  75849. /***/ "./Maths/sphericalPolynomial.ts":
  75850. /*!**************************************!*\
  75851. !*** ./Maths/sphericalPolynomial.ts ***!
  75852. \**************************************/
  75853. /*! exports provided: SphericalPolynomial, SphericalHarmonics */
  75854. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  75855. "use strict";
  75856. __webpack_require__.r(__webpack_exports__);
  75857. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return SphericalPolynomial; });
  75858. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return SphericalHarmonics; });
  75859. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  75860. /**
  75861. * Class representing spherical polynomial coefficients to the 3rd degree
  75862. */
  75863. var SphericalPolynomial = /** @class */ (function () {
  75864. function SphericalPolynomial() {
  75865. /**
  75866. * The x coefficients of the spherical polynomial
  75867. */
  75868. this.x = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  75869. /**
  75870. * The y coefficients of the spherical polynomial
  75871. */
  75872. this.y = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  75873. /**
  75874. * The z coefficients of the spherical polynomial
  75875. */
  75876. this.z = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  75877. /**
  75878. * The xx coefficients of the spherical polynomial
  75879. */
  75880. this.xx = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  75881. /**
  75882. * The yy coefficients of the spherical polynomial
  75883. */
  75884. this.yy = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  75885. /**
  75886. * The zz coefficients of the spherical polynomial
  75887. */
  75888. this.zz = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  75889. /**
  75890. * The xy coefficients of the spherical polynomial
  75891. */
  75892. this.xy = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  75893. /**
  75894. * The yz coefficients of the spherical polynomial
  75895. */
  75896. this.yz = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  75897. /**
  75898. * The zx coefficients of the spherical polynomial
  75899. */
  75900. this.zx = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  75901. }
  75902. /**
  75903. * Adds an ambient color to the spherical polynomial
  75904. * @param color the color to add
  75905. */
  75906. SphericalPolynomial.prototype.addAmbient = function (color) {
  75907. var colorVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](color.r, color.g, color.b);
  75908. this.xx = this.xx.add(colorVector);
  75909. this.yy = this.yy.add(colorVector);
  75910. this.zz = this.zz.add(colorVector);
  75911. };
  75912. /**
  75913. * Scales the spherical polynomial by the given amount
  75914. * @param scale the amount to scale
  75915. */
  75916. SphericalPolynomial.prototype.scale = function (scale) {
  75917. this.x = this.x.scale(scale);
  75918. this.y = this.y.scale(scale);
  75919. this.z = this.z.scale(scale);
  75920. this.xx = this.xx.scale(scale);
  75921. this.yy = this.yy.scale(scale);
  75922. this.zz = this.zz.scale(scale);
  75923. this.yz = this.yz.scale(scale);
  75924. this.zx = this.zx.scale(scale);
  75925. this.xy = this.xy.scale(scale);
  75926. };
  75927. /**
  75928. * Gets the spherical polynomial from harmonics
  75929. * @param harmonics the spherical harmonics
  75930. * @returns the spherical polynomial
  75931. */
  75932. SphericalPolynomial.FromHarmonics = function (harmonics) {
  75933. var result = new SphericalPolynomial();
  75934. result.x = harmonics.l11.scale(1.02333);
  75935. result.y = harmonics.l1_1.scale(1.02333);
  75936. result.z = harmonics.l10.scale(1.02333);
  75937. result.xx = harmonics.l00.scale(0.886277).subtract(harmonics.l20.scale(0.247708)).add(harmonics.lL22.scale(0.429043));
  75938. result.yy = harmonics.l00.scale(0.886277).subtract(harmonics.l20.scale(0.247708)).subtract(harmonics.lL22.scale(0.429043));
  75939. result.zz = harmonics.l00.scale(0.886277).add(harmonics.l20.scale(0.495417));
  75940. result.yz = harmonics.l2_1.scale(0.858086);
  75941. result.zx = harmonics.l21.scale(0.858086);
  75942. result.xy = harmonics.l2_2.scale(0.858086);
  75943. result.scale(1.0 / Math.PI);
  75944. return result;
  75945. };
  75946. /**
  75947. * Constructs a spherical polynomial from an array.
  75948. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  75949. * @returns the spherical polynomial
  75950. */
  75951. SphericalPolynomial.FromArray = function (data) {
  75952. var sp = new SphericalPolynomial();
  75953. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[0], 0, sp.x);
  75954. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[1], 0, sp.y);
  75955. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[2], 0, sp.z);
  75956. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[3], 0, sp.xx);
  75957. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[4], 0, sp.yy);
  75958. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[5], 0, sp.zz);
  75959. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[6], 0, sp.yz);
  75960. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[7], 0, sp.zx);
  75961. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[8], 0, sp.xy);
  75962. return sp;
  75963. };
  75964. return SphericalPolynomial;
  75965. }());
  75966. /**
  75967. * Class representing spherical harmonics coefficients to the 3rd degree
  75968. */
  75969. var SphericalHarmonics = /** @class */ (function () {
  75970. function SphericalHarmonics() {
  75971. /**
  75972. * The l0,0 coefficients of the spherical harmonics
  75973. */
  75974. this.l00 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  75975. /**
  75976. * The l1,-1 coefficients of the spherical harmonics
  75977. */
  75978. this.l1_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  75979. /**
  75980. * The l1,0 coefficients of the spherical harmonics
  75981. */
  75982. this.l10 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  75983. /**
  75984. * The l1,1 coefficients of the spherical harmonics
  75985. */
  75986. this.l11 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  75987. /**
  75988. * The l2,-2 coefficients of the spherical harmonics
  75989. */
  75990. this.l2_2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  75991. /**
  75992. * The l2,-1 coefficients of the spherical harmonics
  75993. */
  75994. this.l2_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  75995. /**
  75996. * The l2,0 coefficients of the spherical harmonics
  75997. */
  75998. this.l20 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  75999. /**
  76000. * The l2,1 coefficients of the spherical harmonics
  76001. */
  76002. this.l21 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76003. /**
  76004. * The l2,2 coefficients of the spherical harmonics
  76005. */
  76006. this.lL22 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76007. }
  76008. /**
  76009. * Adds a light to the spherical harmonics
  76010. * @param direction the direction of the light
  76011. * @param color the color of the light
  76012. * @param deltaSolidAngle the delta solid angle of the light
  76013. */
  76014. SphericalHarmonics.prototype.addLight = function (direction, color, deltaSolidAngle) {
  76015. var colorVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](color.r, color.g, color.b);
  76016. var c = colorVector.scale(deltaSolidAngle);
  76017. this.l00 = this.l00.add(c.scale(0.282095));
  76018. this.l1_1 = this.l1_1.add(c.scale(0.488603 * direction.y));
  76019. this.l10 = this.l10.add(c.scale(0.488603 * direction.z));
  76020. this.l11 = this.l11.add(c.scale(0.488603 * direction.x));
  76021. this.l2_2 = this.l2_2.add(c.scale(1.092548 * direction.x * direction.y));
  76022. this.l2_1 = this.l2_1.add(c.scale(1.092548 * direction.y * direction.z));
  76023. this.l21 = this.l21.add(c.scale(1.092548 * direction.x * direction.z));
  76024. this.l20 = this.l20.add(c.scale(0.315392 * (3.0 * direction.z * direction.z - 1.0)));
  76025. this.lL22 = this.lL22.add(c.scale(0.546274 * (direction.x * direction.x - direction.y * direction.y)));
  76026. };
  76027. /**
  76028. * Scales the spherical harmonics by the given amount
  76029. * @param scale the amount to scale
  76030. */
  76031. SphericalHarmonics.prototype.scale = function (scale) {
  76032. this.l00 = this.l00.scale(scale);
  76033. this.l1_1 = this.l1_1.scale(scale);
  76034. this.l10 = this.l10.scale(scale);
  76035. this.l11 = this.l11.scale(scale);
  76036. this.l2_2 = this.l2_2.scale(scale);
  76037. this.l2_1 = this.l2_1.scale(scale);
  76038. this.l20 = this.l20.scale(scale);
  76039. this.l21 = this.l21.scale(scale);
  76040. this.lL22 = this.lL22.scale(scale);
  76041. };
  76042. /**
  76043. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  76044. *
  76045. * ```
  76046. * E_lm = A_l * L_lm
  76047. * ```
  76048. *
  76049. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  76050. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  76051. * the scaling factors are given in equation 9.
  76052. */
  76053. SphericalHarmonics.prototype.convertIncidentRadianceToIrradiance = function () {
  76054. // Constant (Band 0)
  76055. this.l00 = this.l00.scale(3.141593);
  76056. // Linear (Band 1)
  76057. this.l1_1 = this.l1_1.scale(2.094395);
  76058. this.l10 = this.l10.scale(2.094395);
  76059. this.l11 = this.l11.scale(2.094395);
  76060. // Quadratic (Band 2)
  76061. this.l2_2 = this.l2_2.scale(0.785398);
  76062. this.l2_1 = this.l2_1.scale(0.785398);
  76063. this.l20 = this.l20.scale(0.785398);
  76064. this.l21 = this.l21.scale(0.785398);
  76065. this.lL22 = this.lL22.scale(0.785398);
  76066. };
  76067. /**
  76068. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  76069. *
  76070. * ```
  76071. * L = (1/pi) * E * rho
  76072. * ```
  76073. *
  76074. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  76075. */
  76076. SphericalHarmonics.prototype.convertIrradianceToLambertianRadiance = function () {
  76077. this.scale(1.0 / Math.PI);
  76078. // The resultant SH now represents outgoing radiance, so includes the Lambert 1/pi normalisation factor but without albedo (rho) applied
  76079. // (The pixel shader must apply albedo after texture fetches, etc).
  76080. };
  76081. /**
  76082. * Gets the spherical harmonics from polynomial
  76083. * @param polynomial the spherical polynomial
  76084. * @returns the spherical harmonics
  76085. */
  76086. SphericalHarmonics.FromPolynomial = function (polynomial) {
  76087. var result = new SphericalHarmonics();
  76088. result.l00 = polynomial.xx.scale(0.376127).add(polynomial.yy.scale(0.376127)).add(polynomial.zz.scale(0.376126));
  76089. result.l1_1 = polynomial.y.scale(0.977204);
  76090. result.l10 = polynomial.z.scale(0.977204);
  76091. result.l11 = polynomial.x.scale(0.977204);
  76092. result.l2_2 = polynomial.xy.scale(1.16538);
  76093. result.l2_1 = polynomial.yz.scale(1.16538);
  76094. result.l20 = polynomial.zz.scale(1.34567).subtract(polynomial.xx.scale(0.672834)).subtract(polynomial.yy.scale(0.672834));
  76095. result.l21 = polynomial.zx.scale(1.16538);
  76096. result.lL22 = polynomial.xx.scale(1.16538).subtract(polynomial.yy.scale(1.16538));
  76097. result.scale(Math.PI);
  76098. return result;
  76099. };
  76100. /**
  76101. * Constructs a spherical harmonics from an array.
  76102. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  76103. * @returns the spherical harmonics
  76104. */
  76105. SphericalHarmonics.FromArray = function (data) {
  76106. var sh = new SphericalHarmonics();
  76107. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[0], 0, sh.l00);
  76108. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[1], 0, sh.l1_1);
  76109. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[2], 0, sh.l10);
  76110. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[3], 0, sh.l11);
  76111. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[4], 0, sh.l2_2);
  76112. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[5], 0, sh.l2_1);
  76113. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[6], 0, sh.l20);
  76114. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[7], 0, sh.l21);
  76115. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[8], 0, sh.lL22);
  76116. return sh;
  76117. };
  76118. return SphericalHarmonics;
  76119. }());
  76120. /***/ }),
  76121. /***/ "./Meshes/Builders/boxBuilder.ts":
  76122. /*!***************************************!*\
  76123. !*** ./Meshes/Builders/boxBuilder.ts ***!
  76124. \***************************************/
  76125. /*! exports provided: BoxBuilder */
  76126. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76127. "use strict";
  76128. __webpack_require__.r(__webpack_exports__);
  76129. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return BoxBuilder; });
  76130. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  76131. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  76132. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  76133. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateBox = function (options) {
  76134. var normalsSource = [
  76135. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1),
  76136. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1),
  76137. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 0, 0),
  76138. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1, 0, 0),
  76139. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0),
  76140. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0)
  76141. ];
  76142. var indices = [];
  76143. var positions = [];
  76144. var normals = [];
  76145. var uvs = [];
  76146. var width = options.width || options.size || 1;
  76147. var height = options.height || options.size || 1;
  76148. var depth = options.depth || options.size || 1;
  76149. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  76150. var faceUV = options.faceUV || new Array(6);
  76151. var faceColors = options.faceColors;
  76152. var colors = [];
  76153. // default face colors and UV if undefined
  76154. for (var f = 0; f < 6; f++) {
  76155. if (faceUV[f] === undefined) {
  76156. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  76157. }
  76158. if (faceColors && faceColors[f] === undefined) {
  76159. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  76160. }
  76161. }
  76162. var scaleVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](width / 2, height / 2, depth / 2);
  76163. // Create each face in turn.
  76164. for (var index = 0; index < normalsSource.length; index++) {
  76165. var normal = normalsSource[index];
  76166. // Get two vectors perpendicular to the face normal and to each other.
  76167. var side1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](normal.y, normal.z, normal.x);
  76168. var side2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(normal, side1);
  76169. // Six indices (two triangles) per face.
  76170. var verticesLength = positions.length / 3;
  76171. indices.push(verticesLength);
  76172. indices.push(verticesLength + 1);
  76173. indices.push(verticesLength + 2);
  76174. indices.push(verticesLength);
  76175. indices.push(verticesLength + 2);
  76176. indices.push(verticesLength + 3);
  76177. // Four vertices per face.
  76178. var vertex = normal.subtract(side1).subtract(side2).multiply(scaleVector);
  76179. positions.push(vertex.x, vertex.y, vertex.z);
  76180. normals.push(normal.x, normal.y, normal.z);
  76181. uvs.push(faceUV[index].z, faceUV[index].w);
  76182. if (faceColors) {
  76183. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  76184. }
  76185. vertex = normal.subtract(side1).add(side2).multiply(scaleVector);
  76186. positions.push(vertex.x, vertex.y, vertex.z);
  76187. normals.push(normal.x, normal.y, normal.z);
  76188. uvs.push(faceUV[index].x, faceUV[index].w);
  76189. if (faceColors) {
  76190. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  76191. }
  76192. vertex = normal.add(side1).add(side2).multiply(scaleVector);
  76193. positions.push(vertex.x, vertex.y, vertex.z);
  76194. normals.push(normal.x, normal.y, normal.z);
  76195. uvs.push(faceUV[index].x, faceUV[index].y);
  76196. if (faceColors) {
  76197. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  76198. }
  76199. vertex = normal.add(side1).subtract(side2).multiply(scaleVector);
  76200. positions.push(vertex.x, vertex.y, vertex.z);
  76201. normals.push(normal.x, normal.y, normal.z);
  76202. uvs.push(faceUV[index].z, faceUV[index].y);
  76203. if (faceColors) {
  76204. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  76205. }
  76206. }
  76207. // sides
  76208. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  76209. // Result
  76210. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  76211. vertexData.indices = indices;
  76212. vertexData.positions = positions;
  76213. vertexData.normals = normals;
  76214. vertexData.uvs = uvs;
  76215. if (faceColors) {
  76216. var totalColors = (sideOrientation === _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DOUBLESIDE) ? colors.concat(colors) : colors;
  76217. vertexData.colors = totalColors;
  76218. }
  76219. return vertexData;
  76220. };
  76221. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateBox = function (name, size, scene, updatable, sideOrientation) {
  76222. if (scene === void 0) { scene = null; }
  76223. var options = {
  76224. size: size,
  76225. sideOrientation: sideOrientation,
  76226. updatable: updatable
  76227. };
  76228. return BoxBuilder.CreateBox(name, options, scene);
  76229. };
  76230. /**
  76231. * Class containing static functions to help procedurally build meshes
  76232. */
  76233. var BoxBuilder = /** @class */ (function () {
  76234. function BoxBuilder() {
  76235. }
  76236. /**
  76237. * Creates a box mesh
  76238. * * The parameter `size` sets the size (float) of each box side (default 1)
  76239. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  76240. * * 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)
  76241. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  76242. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  76243. * * 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
  76244. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76245. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  76246. * @param name defines the name of the mesh
  76247. * @param options defines the options used to create the mesh
  76248. * @param scene defines the hosting scene
  76249. * @returns the box mesh
  76250. */
  76251. BoxBuilder.CreateBox = function (name, options, scene) {
  76252. if (scene === void 0) { scene = null; }
  76253. var box = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  76254. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  76255. box._originalBuilderSideOrientation = options.sideOrientation;
  76256. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateBox(options);
  76257. vertexData.applyToMesh(box, options.updatable);
  76258. return box;
  76259. };
  76260. return BoxBuilder;
  76261. }());
  76262. /***/ }),
  76263. /***/ "./Meshes/Builders/cylinderBuilder.ts":
  76264. /*!********************************************!*\
  76265. !*** ./Meshes/Builders/cylinderBuilder.ts ***!
  76266. \********************************************/
  76267. /*! exports provided: CylinderBuilder */
  76268. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76269. "use strict";
  76270. __webpack_require__.r(__webpack_exports__);
  76271. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return CylinderBuilder; });
  76272. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  76273. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  76274. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  76275. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  76276. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateCylinder = function (options) {
  76277. var height = options.height || 2;
  76278. var diameterTop = (options.diameterTop === 0) ? 0 : options.diameterTop || options.diameter || 1;
  76279. var diameterBottom = (options.diameterBottom === 0) ? 0 : options.diameterBottom || options.diameter || 1;
  76280. var tessellation = options.tessellation || 24;
  76281. var subdivisions = options.subdivisions || 1;
  76282. var hasRings = options.hasRings ? true : false;
  76283. var enclose = options.enclose ? true : false;
  76284. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  76285. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  76286. var faceUV = options.faceUV || new Array(3);
  76287. var faceColors = options.faceColors;
  76288. // default face colors and UV if undefined
  76289. var quadNb = (arc !== 1 && enclose) ? 2 : 0;
  76290. var ringNb = (hasRings) ? subdivisions : 1;
  76291. var surfaceNb = 2 + (1 + quadNb) * ringNb;
  76292. var f;
  76293. for (f = 0; f < surfaceNb; f++) {
  76294. if (faceColors && faceColors[f] === undefined) {
  76295. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  76296. }
  76297. }
  76298. for (f = 0; f < surfaceNb; f++) {
  76299. if (faceUV && faceUV[f] === undefined) {
  76300. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  76301. }
  76302. }
  76303. var indices = new Array();
  76304. var positions = new Array();
  76305. var normals = new Array();
  76306. var uvs = new Array();
  76307. var colors = new Array();
  76308. var angle_step = Math.PI * 2 * arc / tessellation;
  76309. var angle;
  76310. var h;
  76311. var radius;
  76312. var tan = (diameterBottom - diameterTop) / 2 / height;
  76313. var ringVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76314. var ringNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76315. var ringFirstVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76316. var ringFirstNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76317. var quadNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76318. var Y = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Axis"].Y;
  76319. // positions, normals, uvs
  76320. var i;
  76321. var j;
  76322. var r;
  76323. var ringIdx = 1;
  76324. var s = 1; // surface index
  76325. var cs = 0;
  76326. var v = 0;
  76327. for (i = 0; i <= subdivisions; i++) {
  76328. h = i / subdivisions;
  76329. radius = (h * (diameterTop - diameterBottom) + diameterBottom) / 2;
  76330. ringIdx = (hasRings && i !== 0 && i !== subdivisions) ? 2 : 1;
  76331. for (r = 0; r < ringIdx; r++) {
  76332. if (hasRings) {
  76333. s += r;
  76334. }
  76335. if (enclose) {
  76336. s += 2 * r;
  76337. }
  76338. for (j = 0; j <= tessellation; j++) {
  76339. angle = j * angle_step;
  76340. // position
  76341. ringVertex.x = Math.cos(-angle) * radius;
  76342. ringVertex.y = -height / 2 + h * height;
  76343. ringVertex.z = Math.sin(-angle) * radius;
  76344. // normal
  76345. if (diameterTop === 0 && i === subdivisions) {
  76346. // if no top cap, reuse former normals
  76347. ringNormal.x = normals[normals.length - (tessellation + 1) * 3];
  76348. ringNormal.y = normals[normals.length - (tessellation + 1) * 3 + 1];
  76349. ringNormal.z = normals[normals.length - (tessellation + 1) * 3 + 2];
  76350. }
  76351. else {
  76352. ringNormal.x = ringVertex.x;
  76353. ringNormal.z = ringVertex.z;
  76354. ringNormal.y = Math.sqrt(ringNormal.x * ringNormal.x + ringNormal.z * ringNormal.z) * tan;
  76355. ringNormal.normalize();
  76356. }
  76357. // keep first ring vertex values for enclose
  76358. if (j === 0) {
  76359. ringFirstVertex.copyFrom(ringVertex);
  76360. ringFirstNormal.copyFrom(ringNormal);
  76361. }
  76362. positions.push(ringVertex.x, ringVertex.y, ringVertex.z);
  76363. normals.push(ringNormal.x, ringNormal.y, ringNormal.z);
  76364. if (hasRings) {
  76365. v = (cs !== s) ? faceUV[s].y : faceUV[s].w;
  76366. }
  76367. else {
  76368. v = faceUV[s].y + (faceUV[s].w - faceUV[s].y) * h;
  76369. }
  76370. uvs.push(faceUV[s].x + (faceUV[s].z - faceUV[s].x) * j / tessellation, v);
  76371. if (faceColors) {
  76372. colors.push(faceColors[s].r, faceColors[s].g, faceColors[s].b, faceColors[s].a);
  76373. }
  76374. }
  76375. // if enclose, add four vertices and their dedicated normals
  76376. if (arc !== 1 && enclose) {
  76377. positions.push(ringVertex.x, ringVertex.y, ringVertex.z);
  76378. positions.push(0, ringVertex.y, 0);
  76379. positions.push(0, ringVertex.y, 0);
  76380. positions.push(ringFirstVertex.x, ringFirstVertex.y, ringFirstVertex.z);
  76381. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(Y, ringNormal, quadNormal);
  76382. quadNormal.normalize();
  76383. normals.push(quadNormal.x, quadNormal.y, quadNormal.z, quadNormal.x, quadNormal.y, quadNormal.z);
  76384. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(ringFirstNormal, Y, quadNormal);
  76385. quadNormal.normalize();
  76386. normals.push(quadNormal.x, quadNormal.y, quadNormal.z, quadNormal.x, quadNormal.y, quadNormal.z);
  76387. if (hasRings) {
  76388. v = (cs !== s) ? faceUV[s + 1].y : faceUV[s + 1].w;
  76389. }
  76390. else {
  76391. v = faceUV[s + 1].y + (faceUV[s + 1].w - faceUV[s + 1].y) * h;
  76392. }
  76393. uvs.push(faceUV[s + 1].x, v);
  76394. uvs.push(faceUV[s + 1].z, v);
  76395. if (hasRings) {
  76396. v = (cs !== s) ? faceUV[s + 2].y : faceUV[s + 2].w;
  76397. }
  76398. else {
  76399. v = faceUV[s + 2].y + (faceUV[s + 2].w - faceUV[s + 2].y) * h;
  76400. }
  76401. uvs.push(faceUV[s + 2].x, v);
  76402. uvs.push(faceUV[s + 2].z, v);
  76403. if (faceColors) {
  76404. colors.push(faceColors[s + 1].r, faceColors[s + 1].g, faceColors[s + 1].b, faceColors[s + 1].a);
  76405. colors.push(faceColors[s + 1].r, faceColors[s + 1].g, faceColors[s + 1].b, faceColors[s + 1].a);
  76406. colors.push(faceColors[s + 2].r, faceColors[s + 2].g, faceColors[s + 2].b, faceColors[s + 2].a);
  76407. colors.push(faceColors[s + 2].r, faceColors[s + 2].g, faceColors[s + 2].b, faceColors[s + 2].a);
  76408. }
  76409. }
  76410. if (cs !== s) {
  76411. cs = s;
  76412. }
  76413. }
  76414. }
  76415. // indices
  76416. var e = (arc !== 1 && enclose) ? tessellation + 4 : tessellation; // correction of number of iteration if enclose
  76417. var s;
  76418. i = 0;
  76419. for (s = 0; s < subdivisions; s++) {
  76420. var i0 = 0;
  76421. var i1 = 0;
  76422. var i2 = 0;
  76423. var i3 = 0;
  76424. for (j = 0; j < tessellation; j++) {
  76425. i0 = i * (e + 1) + j;
  76426. i1 = (i + 1) * (e + 1) + j;
  76427. i2 = i * (e + 1) + (j + 1);
  76428. i3 = (i + 1) * (e + 1) + (j + 1);
  76429. indices.push(i0, i1, i2);
  76430. indices.push(i3, i2, i1);
  76431. }
  76432. if (arc !== 1 && enclose) { // if enclose, add two quads
  76433. indices.push(i0 + 2, i1 + 2, i2 + 2);
  76434. indices.push(i3 + 2, i2 + 2, i1 + 2);
  76435. indices.push(i0 + 4, i1 + 4, i2 + 4);
  76436. indices.push(i3 + 4, i2 + 4, i1 + 4);
  76437. }
  76438. i = (hasRings) ? (i + 2) : (i + 1);
  76439. }
  76440. // Caps
  76441. var createCylinderCap = function (isTop) {
  76442. var radius = isTop ? diameterTop / 2 : diameterBottom / 2;
  76443. if (radius === 0) {
  76444. return;
  76445. }
  76446. // Cap positions, normals & uvs
  76447. var angle;
  76448. var circleVector;
  76449. var i;
  76450. var u = (isTop) ? faceUV[surfaceNb - 1] : faceUV[0];
  76451. var c = null;
  76452. if (faceColors) {
  76453. c = (isTop) ? faceColors[surfaceNb - 1] : faceColors[0];
  76454. }
  76455. // cap center
  76456. var vbase = positions.length / 3;
  76457. var offset = isTop ? height / 2 : -height / 2;
  76458. var center = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, offset, 0);
  76459. positions.push(center.x, center.y, center.z);
  76460. normals.push(0, isTop ? 1 : -1, 0);
  76461. uvs.push(u.x + (u.z - u.x) * 0.5, u.y + (u.w - u.y) * 0.5);
  76462. if (c) {
  76463. colors.push(c.r, c.g, c.b, c.a);
  76464. }
  76465. var textureScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0.5, 0.5);
  76466. for (i = 0; i <= tessellation; i++) {
  76467. angle = Math.PI * 2 * i * arc / tessellation;
  76468. var cos = Math.cos(-angle);
  76469. var sin = Math.sin(-angle);
  76470. circleVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](cos * radius, offset, sin * radius);
  76471. var textureCoordinate = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](cos * textureScale.x + 0.5, sin * textureScale.y + 0.5);
  76472. positions.push(circleVector.x, circleVector.y, circleVector.z);
  76473. normals.push(0, isTop ? 1 : -1, 0);
  76474. uvs.push(u.x + (u.z - u.x) * textureCoordinate.x, u.y + (u.w - u.y) * textureCoordinate.y);
  76475. if (c) {
  76476. colors.push(c.r, c.g, c.b, c.a);
  76477. }
  76478. }
  76479. // Cap indices
  76480. for (i = 0; i < tessellation; i++) {
  76481. if (!isTop) {
  76482. indices.push(vbase);
  76483. indices.push(vbase + (i + 1));
  76484. indices.push(vbase + (i + 2));
  76485. }
  76486. else {
  76487. indices.push(vbase);
  76488. indices.push(vbase + (i + 2));
  76489. indices.push(vbase + (i + 1));
  76490. }
  76491. }
  76492. };
  76493. // add caps to geometry
  76494. createCylinderCap(false);
  76495. createCylinderCap(true);
  76496. // Sides
  76497. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  76498. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  76499. vertexData.indices = indices;
  76500. vertexData.positions = positions;
  76501. vertexData.normals = normals;
  76502. vertexData.uvs = uvs;
  76503. if (faceColors) {
  76504. vertexData.colors = colors;
  76505. }
  76506. return vertexData;
  76507. };
  76508. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateCylinder = function (name, height, diameterTop, diameterBottom, tessellation, subdivisions, scene, updatable, sideOrientation) {
  76509. if (scene === undefined || !(scene instanceof _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"])) {
  76510. if (scene !== undefined) {
  76511. sideOrientation = updatable || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].DEFAULTSIDE;
  76512. updatable = scene;
  76513. }
  76514. scene = subdivisions;
  76515. subdivisions = 1;
  76516. }
  76517. var options = {
  76518. height: height,
  76519. diameterTop: diameterTop,
  76520. diameterBottom: diameterBottom,
  76521. tessellation: tessellation,
  76522. subdivisions: subdivisions,
  76523. sideOrientation: sideOrientation,
  76524. updatable: updatable
  76525. };
  76526. return CylinderBuilder.CreateCylinder(name, options, scene);
  76527. };
  76528. /**
  76529. * Class containing static functions to help procedurally build meshes
  76530. */
  76531. var CylinderBuilder = /** @class */ (function () {
  76532. function CylinderBuilder() {
  76533. }
  76534. /**
  76535. * Creates a cylinder or a cone mesh
  76536. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  76537. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  76538. * * 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.
  76539. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  76540. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  76541. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  76542. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  76543. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  76544. * * 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).
  76545. * * 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
  76546. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  76547. * * 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
  76548. * * 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.
  76549. * * If `enclose` is false, a ring surface is one element.
  76550. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  76551. * * 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
  76552. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  76553. * * 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
  76554. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  76555. * @param name defines the name of the mesh
  76556. * @param options defines the options used to create the mesh
  76557. * @param scene defines the hosting scene
  76558. * @returns the cylinder mesh
  76559. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  76560. */
  76561. CylinderBuilder.CreateCylinder = function (name, options, scene) {
  76562. var cylinder = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  76563. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  76564. cylinder._originalBuilderSideOrientation = options.sideOrientation;
  76565. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateCylinder(options);
  76566. vertexData.applyToMesh(cylinder, options.updatable);
  76567. return cylinder;
  76568. };
  76569. return CylinderBuilder;
  76570. }());
  76571. /***/ }),
  76572. /***/ "./Meshes/Builders/decalBuilder.ts":
  76573. /*!*****************************************!*\
  76574. !*** ./Meshes/Builders/decalBuilder.ts ***!
  76575. \*****************************************/
  76576. /*! exports provided: DecalBuilder */
  76577. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76578. "use strict";
  76579. __webpack_require__.r(__webpack_exports__);
  76580. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return DecalBuilder; });
  76581. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  76582. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  76583. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../buffer */ "./Meshes/buffer.ts");
  76584. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  76585. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateDecal = function (name, sourceMesh, position, normal, size, angle) {
  76586. var options = {
  76587. position: position,
  76588. normal: normal,
  76589. size: size,
  76590. angle: angle
  76591. };
  76592. return DecalBuilder.CreateDecal(name, sourceMesh, options);
  76593. };
  76594. /**
  76595. * Class containing static functions to help procedurally build meshes
  76596. */
  76597. var DecalBuilder = /** @class */ (function () {
  76598. function DecalBuilder() {
  76599. }
  76600. /**
  76601. * Creates a decal mesh.
  76602. * 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
  76603. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  76604. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  76605. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  76606. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  76607. * @param name defines the name of the mesh
  76608. * @param sourceMesh defines the mesh where the decal must be applied
  76609. * @param options defines the options used to create the mesh
  76610. * @param scene defines the hosting scene
  76611. * @returns the decal mesh
  76612. * @see https://doc.babylonjs.com/how_to/decals
  76613. */
  76614. DecalBuilder.CreateDecal = function (name, sourceMesh, options) {
  76615. var indices = sourceMesh.getIndices();
  76616. var positions = sourceMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  76617. var normals = sourceMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  76618. var position = options.position || _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76619. var normal = options.normal || _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up();
  76620. var size = options.size || _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  76621. var angle = options.angle || 0;
  76622. // Getting correct rotation
  76623. if (!normal) {
  76624. var target = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1);
  76625. var camera = sourceMesh.getScene().activeCamera;
  76626. var cameraWorldTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(target, camera.getWorldMatrix());
  76627. normal = camera.globalPosition.subtract(cameraWorldTarget);
  76628. }
  76629. var yaw = -Math.atan2(normal.z, normal.x) - Math.PI / 2;
  76630. var len = Math.sqrt(normal.x * normal.x + normal.z * normal.z);
  76631. var pitch = Math.atan2(normal.y, len);
  76632. // Matrix
  76633. 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));
  76634. var inverseDecalWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Invert(decalWorldMatrix);
  76635. var meshWorldMatrix = sourceMesh.getWorldMatrix();
  76636. var transformMatrix = meshWorldMatrix.multiply(inverseDecalWorldMatrix);
  76637. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]();
  76638. vertexData.indices = [];
  76639. vertexData.positions = [];
  76640. vertexData.normals = [];
  76641. vertexData.uvs = [];
  76642. var currentVertexDataIndex = 0;
  76643. var extractDecalVector3 = function (indexId) {
  76644. var result = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["PositionNormalVertex"]();
  76645. if (!indices || !positions || !normals) {
  76646. return result;
  76647. }
  76648. var vertexId = indices[indexId];
  76649. result.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](positions[vertexId * 3], positions[vertexId * 3 + 1], positions[vertexId * 3 + 2]);
  76650. // Send vector to decal local world
  76651. result.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(result.position, transformMatrix);
  76652. // Get normal
  76653. result.normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](normals[vertexId * 3], normals[vertexId * 3 + 1], normals[vertexId * 3 + 2]);
  76654. result.normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(result.normal, transformMatrix);
  76655. return result;
  76656. }; // Inspired by https://github.com/mrdoob/three.js/blob/eee231960882f6f3b6113405f524956145148146/examples/js/geometries/DecalGeometry.js
  76657. var clip = function (vertices, axis) {
  76658. if (vertices.length === 0) {
  76659. return vertices;
  76660. }
  76661. var clipSize = 0.5 * Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(size, axis));
  76662. var clipVertices = function (v0, v1) {
  76663. var clipFactor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].GetClipFactor(v0.position, v1.position, axis, clipSize);
  76664. 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));
  76665. };
  76666. var result = new Array();
  76667. for (var index = 0; index < vertices.length; index += 3) {
  76668. var v1Out;
  76669. var v2Out;
  76670. var v3Out;
  76671. var total = 0;
  76672. var nV1 = null;
  76673. var nV2 = null;
  76674. var nV3 = null;
  76675. var nV4 = null;
  76676. var d1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index].position, axis) - clipSize;
  76677. var d2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index + 1].position, axis) - clipSize;
  76678. var d3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index + 2].position, axis) - clipSize;
  76679. v1Out = d1 > 0;
  76680. v2Out = d2 > 0;
  76681. v3Out = d3 > 0;
  76682. total = (v1Out ? 1 : 0) + (v2Out ? 1 : 0) + (v3Out ? 1 : 0);
  76683. switch (total) {
  76684. case 0:
  76685. result.push(vertices[index]);
  76686. result.push(vertices[index + 1]);
  76687. result.push(vertices[index + 2]);
  76688. break;
  76689. case 1:
  76690. if (v1Out) {
  76691. nV1 = vertices[index + 1];
  76692. nV2 = vertices[index + 2];
  76693. nV3 = clipVertices(vertices[index], nV1);
  76694. nV4 = clipVertices(vertices[index], nV2);
  76695. }
  76696. if (v2Out) {
  76697. nV1 = vertices[index];
  76698. nV2 = vertices[index + 2];
  76699. nV3 = clipVertices(vertices[index + 1], nV1);
  76700. nV4 = clipVertices(vertices[index + 1], nV2);
  76701. result.push(nV3);
  76702. result.push(nV2.clone());
  76703. result.push(nV1.clone());
  76704. result.push(nV2.clone());
  76705. result.push(nV3.clone());
  76706. result.push(nV4);
  76707. break;
  76708. }
  76709. if (v3Out) {
  76710. nV1 = vertices[index];
  76711. nV2 = vertices[index + 1];
  76712. nV3 = clipVertices(vertices[index + 2], nV1);
  76713. nV4 = clipVertices(vertices[index + 2], nV2);
  76714. }
  76715. if (nV1 && nV2 && nV3 && nV4) {
  76716. result.push(nV1.clone());
  76717. result.push(nV2.clone());
  76718. result.push(nV3);
  76719. result.push(nV4);
  76720. result.push(nV3.clone());
  76721. result.push(nV2.clone());
  76722. }
  76723. break;
  76724. case 2:
  76725. if (!v1Out) {
  76726. nV1 = vertices[index].clone();
  76727. nV2 = clipVertices(nV1, vertices[index + 1]);
  76728. nV3 = clipVertices(nV1, vertices[index + 2]);
  76729. result.push(nV1);
  76730. result.push(nV2);
  76731. result.push(nV3);
  76732. }
  76733. if (!v2Out) {
  76734. nV1 = vertices[index + 1].clone();
  76735. nV2 = clipVertices(nV1, vertices[index + 2]);
  76736. nV3 = clipVertices(nV1, vertices[index]);
  76737. result.push(nV1);
  76738. result.push(nV2);
  76739. result.push(nV3);
  76740. }
  76741. if (!v3Out) {
  76742. nV1 = vertices[index + 2].clone();
  76743. nV2 = clipVertices(nV1, vertices[index]);
  76744. nV3 = clipVertices(nV1, vertices[index + 1]);
  76745. result.push(nV1);
  76746. result.push(nV2);
  76747. result.push(nV3);
  76748. }
  76749. break;
  76750. case 3:
  76751. break;
  76752. }
  76753. }
  76754. return result;
  76755. };
  76756. for (var index = 0; index < indices.length; index += 3) {
  76757. var faceVertices = new Array();
  76758. faceVertices.push(extractDecalVector3(index));
  76759. faceVertices.push(extractDecalVector3(index + 1));
  76760. faceVertices.push(extractDecalVector3(index + 2));
  76761. // Clip
  76762. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 0, 0));
  76763. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1, 0, 0));
  76764. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0));
  76765. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0));
  76766. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1));
  76767. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1));
  76768. if (faceVertices.length === 0) {
  76769. continue;
  76770. }
  76771. // Add UVs and get back to world
  76772. for (var vIndex = 0; vIndex < faceVertices.length; vIndex++) {
  76773. var vertex = faceVertices[vIndex];
  76774. //TODO check for Int32Array | Uint32Array | Uint16Array
  76775. vertexData.indices.push(currentVertexDataIndex);
  76776. vertex.position.toArray(vertexData.positions, currentVertexDataIndex * 3);
  76777. vertex.normal.toArray(vertexData.normals, currentVertexDataIndex * 3);
  76778. vertexData.uvs.push(0.5 + vertex.position.x / size.x);
  76779. vertexData.uvs.push(0.5 + vertex.position.y / size.y);
  76780. currentVertexDataIndex++;
  76781. }
  76782. }
  76783. // Return mesh
  76784. var decal = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, sourceMesh.getScene());
  76785. vertexData.applyToMesh(decal);
  76786. decal.position = position.clone();
  76787. decal.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](pitch, yaw, angle);
  76788. return decal;
  76789. };
  76790. return DecalBuilder;
  76791. }());
  76792. /***/ }),
  76793. /***/ "./Meshes/Builders/discBuilder.ts":
  76794. /*!****************************************!*\
  76795. !*** ./Meshes/Builders/discBuilder.ts ***!
  76796. \****************************************/
  76797. /*! exports provided: DiscBuilder */
  76798. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76799. "use strict";
  76800. __webpack_require__.r(__webpack_exports__);
  76801. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return DiscBuilder; });
  76802. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  76803. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  76804. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreateDisc = function (options) {
  76805. var positions = new Array();
  76806. var indices = new Array();
  76807. var normals = new Array();
  76808. var uvs = new Array();
  76809. var radius = options.radius || 0.5;
  76810. var tessellation = options.tessellation || 64;
  76811. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  76812. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].DEFAULTSIDE;
  76813. // positions and uvs
  76814. positions.push(0, 0, 0); // disc center first
  76815. uvs.push(0.5, 0.5);
  76816. var theta = Math.PI * 2 * arc;
  76817. var step = theta / tessellation;
  76818. for (var a = 0; a < theta; a += step) {
  76819. var x = Math.cos(a);
  76820. var y = Math.sin(a);
  76821. var u = (x + 1) / 2;
  76822. var v = (1 - y) / 2;
  76823. positions.push(radius * x, radius * y, 0);
  76824. uvs.push(u, v);
  76825. }
  76826. if (arc === 1) {
  76827. positions.push(positions[3], positions[4], positions[5]); // close the circle
  76828. uvs.push(uvs[2], uvs[3]);
  76829. }
  76830. //indices
  76831. var vertexNb = positions.length / 3;
  76832. for (var i = 1; i < vertexNb - 1; i++) {
  76833. indices.push(i + 1, 0, i);
  76834. }
  76835. // result
  76836. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ComputeNormals(positions, indices, normals);
  76837. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  76838. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  76839. vertexData.indices = indices;
  76840. vertexData.positions = positions;
  76841. vertexData.normals = normals;
  76842. vertexData.uvs = uvs;
  76843. return vertexData;
  76844. };
  76845. _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreateDisc = function (name, radius, tessellation, scene, updatable, sideOrientation) {
  76846. if (scene === void 0) { scene = null; }
  76847. var options = {
  76848. radius: radius,
  76849. tessellation: tessellation,
  76850. sideOrientation: sideOrientation,
  76851. updatable: updatable
  76852. };
  76853. return DiscBuilder.CreateDisc(name, options, scene);
  76854. };
  76855. /**
  76856. * Class containing static functions to help procedurally build meshes
  76857. */
  76858. var DiscBuilder = /** @class */ (function () {
  76859. function DiscBuilder() {
  76860. }
  76861. /**
  76862. * Creates a plane polygonal mesh. By default, this is a disc
  76863. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  76864. * * 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
  76865. * * 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
  76866. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  76867. * * 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
  76868. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76869. * @param name defines the name of the mesh
  76870. * @param options defines the options used to create the mesh
  76871. * @param scene defines the hosting scene
  76872. * @returns the plane polygonal mesh
  76873. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  76874. */
  76875. DiscBuilder.CreateDisc = function (name, options, scene) {
  76876. if (scene === void 0) { scene = null; }
  76877. var disc = new _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"](name, scene);
  76878. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  76879. disc._originalBuilderSideOrientation = options.sideOrientation;
  76880. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreateDisc(options);
  76881. vertexData.applyToMesh(disc, options.updatable);
  76882. return disc;
  76883. };
  76884. return DiscBuilder;
  76885. }());
  76886. /***/ }),
  76887. /***/ "./Meshes/Builders/groundBuilder.ts":
  76888. /*!******************************************!*\
  76889. !*** ./Meshes/Builders/groundBuilder.ts ***!
  76890. \******************************************/
  76891. /*! exports provided: GroundBuilder */
  76892. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76893. "use strict";
  76894. __webpack_require__.r(__webpack_exports__);
  76895. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return GroundBuilder; });
  76896. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  76897. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  76898. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  76899. /* harmony import */ var _groundMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../groundMesh */ "./Meshes/groundMesh.ts");
  76900. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  76901. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGround = function (options) {
  76902. var indices = [];
  76903. var positions = [];
  76904. var normals = [];
  76905. var uvs = [];
  76906. var row, col;
  76907. var width = options.width || 1;
  76908. var height = options.height || 1;
  76909. var subdivisionsX = options.subdivisionsX || options.subdivisions || 1;
  76910. var subdivisionsY = options.subdivisionsY || options.subdivisions || 1;
  76911. for (row = 0; row <= subdivisionsY; row++) {
  76912. for (col = 0; col <= subdivisionsX; col++) {
  76913. var position = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]((col * width) / subdivisionsX - (width / 2.0), 0, ((subdivisionsY - row) * height) / subdivisionsY - (height / 2.0));
  76914. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0);
  76915. positions.push(position.x, position.y, position.z);
  76916. normals.push(normal.x, normal.y, normal.z);
  76917. uvs.push(col / subdivisionsX, 1.0 - row / subdivisionsY);
  76918. }
  76919. }
  76920. for (row = 0; row < subdivisionsY; row++) {
  76921. for (col = 0; col < subdivisionsX; col++) {
  76922. indices.push(col + 1 + (row + 1) * (subdivisionsX + 1));
  76923. indices.push(col + 1 + row * (subdivisionsX + 1));
  76924. indices.push(col + row * (subdivisionsX + 1));
  76925. indices.push(col + (row + 1) * (subdivisionsX + 1));
  76926. indices.push(col + 1 + (row + 1) * (subdivisionsX + 1));
  76927. indices.push(col + row * (subdivisionsX + 1));
  76928. }
  76929. }
  76930. // Result
  76931. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  76932. vertexData.indices = indices;
  76933. vertexData.positions = positions;
  76934. vertexData.normals = normals;
  76935. vertexData.uvs = uvs;
  76936. return vertexData;
  76937. };
  76938. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTiledGround = function (options) {
  76939. var xmin = (options.xmin !== undefined && options.xmin !== null) ? options.xmin : -1.0;
  76940. var zmin = (options.zmin !== undefined && options.zmin !== null) ? options.zmin : -1.0;
  76941. var xmax = (options.xmax !== undefined && options.xmax !== null) ? options.xmax : 1.0;
  76942. var zmax = (options.zmax !== undefined && options.zmax !== null) ? options.zmax : 1.0;
  76943. var subdivisions = options.subdivisions || { w: 1, h: 1 };
  76944. var precision = options.precision || { w: 1, h: 1 };
  76945. var indices = new Array();
  76946. var positions = new Array();
  76947. var normals = new Array();
  76948. var uvs = new Array();
  76949. var row, col, tileRow, tileCol;
  76950. subdivisions.h = (subdivisions.h < 1) ? 1 : subdivisions.h;
  76951. subdivisions.w = (subdivisions.w < 1) ? 1 : subdivisions.w;
  76952. precision.w = (precision.w < 1) ? 1 : precision.w;
  76953. precision.h = (precision.h < 1) ? 1 : precision.h;
  76954. var tileSize = {
  76955. 'w': (xmax - xmin) / subdivisions.w,
  76956. 'h': (zmax - zmin) / subdivisions.h
  76957. };
  76958. function applyTile(xTileMin, zTileMin, xTileMax, zTileMax) {
  76959. // Indices
  76960. var base = positions.length / 3;
  76961. var rowLength = precision.w + 1;
  76962. for (row = 0; row < precision.h; row++) {
  76963. for (col = 0; col < precision.w; col++) {
  76964. var square = [
  76965. base + col + row * rowLength,
  76966. base + (col + 1) + row * rowLength,
  76967. base + (col + 1) + (row + 1) * rowLength,
  76968. base + col + (row + 1) * rowLength
  76969. ];
  76970. indices.push(square[1]);
  76971. indices.push(square[2]);
  76972. indices.push(square[3]);
  76973. indices.push(square[0]);
  76974. indices.push(square[1]);
  76975. indices.push(square[3]);
  76976. }
  76977. }
  76978. // Position, normals and uvs
  76979. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76980. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0);
  76981. for (row = 0; row <= precision.h; row++) {
  76982. position.z = (row * (zTileMax - zTileMin)) / precision.h + zTileMin;
  76983. for (col = 0; col <= precision.w; col++) {
  76984. position.x = (col * (xTileMax - xTileMin)) / precision.w + xTileMin;
  76985. position.y = 0;
  76986. positions.push(position.x, position.y, position.z);
  76987. normals.push(normal.x, normal.y, normal.z);
  76988. uvs.push(col / precision.w, row / precision.h);
  76989. }
  76990. }
  76991. }
  76992. for (tileRow = 0; tileRow < subdivisions.h; tileRow++) {
  76993. for (tileCol = 0; tileCol < subdivisions.w; tileCol++) {
  76994. applyTile(xmin + tileCol * tileSize.w, zmin + tileRow * tileSize.h, xmin + (tileCol + 1) * tileSize.w, zmin + (tileRow + 1) * tileSize.h);
  76995. }
  76996. }
  76997. // Result
  76998. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  76999. vertexData.indices = indices;
  77000. vertexData.positions = positions;
  77001. vertexData.normals = normals;
  77002. vertexData.uvs = uvs;
  77003. return vertexData;
  77004. };
  77005. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGroundFromHeightMap = function (options) {
  77006. var indices = [];
  77007. var positions = [];
  77008. var normals = [];
  77009. var uvs = [];
  77010. var row, col;
  77011. var filter = options.colorFilter || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](0.3, 0.59, 0.11);
  77012. var alphaFilter = options.alphaFilter || 0.0;
  77013. // Vertices
  77014. for (row = 0; row <= options.subdivisions; row++) {
  77015. for (col = 0; col <= options.subdivisions; col++) {
  77016. 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));
  77017. // Compute height
  77018. var heightMapX = (((position.x + options.width / 2) / options.width) * (options.bufferWidth - 1)) | 0;
  77019. var heightMapY = ((1.0 - (position.z + options.height / 2) / options.height) * (options.bufferHeight - 1)) | 0;
  77020. var pos = (heightMapX + heightMapY * options.bufferWidth) * 4;
  77021. var r = options.buffer[pos] / 255.0;
  77022. var g = options.buffer[pos + 1] / 255.0;
  77023. var b = options.buffer[pos + 2] / 255.0;
  77024. var a = options.buffer[pos + 3] / 255.0;
  77025. var gradient = r * filter.r + g * filter.g + b * filter.b;
  77026. // If our alpha channel is not within our filter then we will assign a 'special' height
  77027. // Then when building the indices, we will ignore any vertex that is using the special height
  77028. if (a >= alphaFilter) {
  77029. position.y = options.minHeight + (options.maxHeight - options.minHeight) * gradient;
  77030. }
  77031. else {
  77032. position.y = options.minHeight - _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]; // We can't have a height below minHeight, normally.
  77033. }
  77034. // Add vertex
  77035. positions.push(position.x, position.y, position.z);
  77036. normals.push(0, 0, 0);
  77037. uvs.push(col / options.subdivisions, 1.0 - row / options.subdivisions);
  77038. }
  77039. }
  77040. // Indices
  77041. for (row = 0; row < options.subdivisions; row++) {
  77042. for (col = 0; col < options.subdivisions; col++) {
  77043. // Calculate Indices
  77044. var idx1 = (col + 1 + (row + 1) * (options.subdivisions + 1));
  77045. var idx2 = (col + 1 + row * (options.subdivisions + 1));
  77046. var idx3 = (col + row * (options.subdivisions + 1));
  77047. var idx4 = (col + (row + 1) * (options.subdivisions + 1));
  77048. // Check that all indices are visible (based on our special height)
  77049. // Only display the vertex if all Indices are visible
  77050. // Positions are stored x,y,z for each vertex, hence the * 3 and + 1 for height
  77051. var isVisibleIdx1 = positions[idx1 * 3 + 1] >= options.minHeight;
  77052. var isVisibleIdx2 = positions[idx2 * 3 + 1] >= options.minHeight;
  77053. var isVisibleIdx3 = positions[idx3 * 3 + 1] >= options.minHeight;
  77054. if (isVisibleIdx1 && isVisibleIdx2 && isVisibleIdx3) {
  77055. indices.push(idx1);
  77056. indices.push(idx2);
  77057. indices.push(idx3);
  77058. }
  77059. var isVisibleIdx4 = positions[idx4 * 3 + 1] >= options.minHeight;
  77060. if (isVisibleIdx4 && isVisibleIdx1 && isVisibleIdx3) {
  77061. indices.push(idx4);
  77062. indices.push(idx1);
  77063. indices.push(idx3);
  77064. }
  77065. }
  77066. }
  77067. // Normals
  77068. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  77069. // Result
  77070. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  77071. vertexData.indices = indices;
  77072. vertexData.positions = positions;
  77073. vertexData.normals = normals;
  77074. vertexData.uvs = uvs;
  77075. return vertexData;
  77076. };
  77077. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateGround = function (name, width, height, subdivisions, scene, updatable) {
  77078. var options = {
  77079. width: width,
  77080. height: height,
  77081. subdivisions: subdivisions,
  77082. updatable: updatable
  77083. };
  77084. return GroundBuilder.CreateGround(name, options, scene);
  77085. };
  77086. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTiledGround = function (name, xmin, zmin, xmax, zmax, subdivisions, precision, scene, updatable) {
  77087. var options = {
  77088. xmin: xmin,
  77089. zmin: zmin,
  77090. xmax: xmax,
  77091. zmax: zmax,
  77092. subdivisions: subdivisions,
  77093. precision: precision,
  77094. updatable: updatable
  77095. };
  77096. return GroundBuilder.CreateTiledGround(name, options, scene);
  77097. };
  77098. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateGroundFromHeightMap = function (name, url, width, height, subdivisions, minHeight, maxHeight, scene, updatable, onReady, alphaFilter) {
  77099. var options = {
  77100. width: width,
  77101. height: height,
  77102. subdivisions: subdivisions,
  77103. minHeight: minHeight,
  77104. maxHeight: maxHeight,
  77105. updatable: updatable,
  77106. onReady: onReady,
  77107. alphaFilter: alphaFilter
  77108. };
  77109. return GroundBuilder.CreateGroundFromHeightMap(name, url, options, scene);
  77110. };
  77111. /**
  77112. * Class containing static functions to help procedurally build meshes
  77113. */
  77114. var GroundBuilder = /** @class */ (function () {
  77115. function GroundBuilder() {
  77116. }
  77117. /**
  77118. * Creates a ground mesh
  77119. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  77120. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  77121. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77122. * @param name defines the name of the mesh
  77123. * @param options defines the options used to create the mesh
  77124. * @param scene defines the hosting scene
  77125. * @returns the ground mesh
  77126. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  77127. */
  77128. GroundBuilder.CreateGround = function (name, options, scene) {
  77129. var ground = new _groundMesh__WEBPACK_IMPORTED_MODULE_3__["GroundMesh"](name, scene);
  77130. ground._setReady(false);
  77131. ground._subdivisionsX = options.subdivisionsX || options.subdivisions || 1;
  77132. ground._subdivisionsY = options.subdivisionsY || options.subdivisions || 1;
  77133. ground._width = options.width || 1;
  77134. ground._height = options.height || 1;
  77135. ground._maxX = ground._width / 2;
  77136. ground._maxZ = ground._height / 2;
  77137. ground._minX = -ground._maxX;
  77138. ground._minZ = -ground._maxZ;
  77139. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGround(options);
  77140. vertexData.applyToMesh(ground, options.updatable);
  77141. ground._setReady(true);
  77142. return ground;
  77143. };
  77144. /**
  77145. * Creates a tiled ground mesh
  77146. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  77147. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  77148. * * 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
  77149. * * 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
  77150. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  77151. * @param name defines the name of the mesh
  77152. * @param options defines the options used to create the mesh
  77153. * @param scene defines the hosting scene
  77154. * @returns the tiled ground mesh
  77155. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  77156. */
  77157. GroundBuilder.CreateTiledGround = function (name, options, scene) {
  77158. var tiledGround = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  77159. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTiledGround(options);
  77160. vertexData.applyToMesh(tiledGround, options.updatable);
  77161. return tiledGround;
  77162. };
  77163. /**
  77164. * Creates a ground mesh from a height map
  77165. * * The parameter `url` sets the URL of the height map image resource.
  77166. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  77167. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  77168. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  77169. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  77170. * * 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.
  77171. * * 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).
  77172. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  77173. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  77174. * @param name defines the name of the mesh
  77175. * @param url defines the url to the height map
  77176. * @param options defines the options used to create the mesh
  77177. * @param scene defines the hosting scene
  77178. * @returns the ground mesh
  77179. * @see https://doc.babylonjs.com/babylon101/height_map
  77180. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  77181. */
  77182. GroundBuilder.CreateGroundFromHeightMap = function (name, url, options, scene) {
  77183. var width = options.width || 10.0;
  77184. var height = options.height || 10.0;
  77185. var subdivisions = options.subdivisions || 1 | 0;
  77186. var minHeight = options.minHeight || 0.0;
  77187. var maxHeight = options.maxHeight || 1.0;
  77188. var filter = options.colorFilter || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](0.3, 0.59, 0.11);
  77189. var alphaFilter = options.alphaFilter || 0.0;
  77190. var updatable = options.updatable;
  77191. var onReady = options.onReady;
  77192. var ground = new _groundMesh__WEBPACK_IMPORTED_MODULE_3__["GroundMesh"](name, scene);
  77193. ground._subdivisionsX = subdivisions;
  77194. ground._subdivisionsY = subdivisions;
  77195. ground._width = width;
  77196. ground._height = height;
  77197. ground._maxX = ground._width / 2.0;
  77198. ground._maxZ = ground._height / 2.0;
  77199. ground._minX = -ground._maxX;
  77200. ground._minZ = -ground._maxZ;
  77201. ground._setReady(false);
  77202. var onload = function (img) {
  77203. // Getting height map data
  77204. var canvas = document.createElement("canvas");
  77205. var context = canvas.getContext("2d");
  77206. if (!context) {
  77207. throw new Error("Unable to get 2d context for CreateGroundFromHeightMap");
  77208. }
  77209. if (scene.isDisposed) {
  77210. return;
  77211. }
  77212. var bufferWidth = img.width;
  77213. var bufferHeight = img.height;
  77214. canvas.width = bufferWidth;
  77215. canvas.height = bufferHeight;
  77216. context.drawImage(img, 0, 0);
  77217. // Create VertexData from map data
  77218. // Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949
  77219. var buffer = context.getImageData(0, 0, bufferWidth, bufferHeight).data;
  77220. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGroundFromHeightMap({
  77221. width: width, height: height,
  77222. subdivisions: subdivisions,
  77223. minHeight: minHeight, maxHeight: maxHeight, colorFilter: filter,
  77224. buffer: buffer, bufferWidth: bufferWidth, bufferHeight: bufferHeight,
  77225. alphaFilter: alphaFilter
  77226. });
  77227. vertexData.applyToMesh(ground, updatable);
  77228. //execute ready callback, if set
  77229. if (onReady) {
  77230. onReady(ground);
  77231. }
  77232. ground._setReady(true);
  77233. };
  77234. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["Tools"].LoadImage(url, onload, function () { }, scene.offlineProvider);
  77235. return ground;
  77236. };
  77237. return GroundBuilder;
  77238. }());
  77239. /***/ }),
  77240. /***/ "./Meshes/Builders/icoSphereBuilder.ts":
  77241. /*!*********************************************!*\
  77242. !*** ./Meshes/Builders/icoSphereBuilder.ts ***!
  77243. \*********************************************/
  77244. /*! exports provided: IcoSphereBuilder */
  77245. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77246. "use strict";
  77247. __webpack_require__.r(__webpack_exports__);
  77248. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return IcoSphereBuilder; });
  77249. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77250. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77251. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77252. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateIcoSphere = function (options) {
  77253. var sideOrientation = options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  77254. var radius = options.radius || 1;
  77255. var flat = (options.flat === undefined) ? true : options.flat;
  77256. var subdivisions = options.subdivisions || 4;
  77257. var radiusX = options.radiusX || radius;
  77258. var radiusY = options.radiusY || radius;
  77259. var radiusZ = options.radiusZ || radius;
  77260. var t = (1 + Math.sqrt(5)) / 2;
  77261. // 12 vertex x,y,z
  77262. var ico_vertices = [
  77263. -1, t, -0, 1, t, 0, -1, -t, 0, 1, -t, 0,
  77264. 0, -1, -t, 0, 1, -t, 0, -1, t, 0, 1, t,
  77265. t, 0, 1, t, 0, -1, -t, 0, 1, -t, 0, -1 // v8-11
  77266. ];
  77267. // index of 3 vertex makes a face of icopshere
  77268. var ico_indices = [
  77269. 0, 11, 5, 0, 5, 1, 0, 1, 7, 0, 7, 10, 12, 22, 23,
  77270. 1, 5, 20, 5, 11, 4, 23, 22, 13, 22, 18, 6, 7, 1, 8,
  77271. 14, 21, 4, 14, 4, 2, 16, 13, 6, 15, 6, 19, 3, 8, 9,
  77272. 4, 21, 5, 13, 17, 23, 6, 13, 22, 19, 6, 18, 9, 8, 1
  77273. ];
  77274. // vertex for uv have aliased position, not for UV
  77275. var vertices_unalias_id = [
  77276. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
  77277. // vertex alias
  77278. 0,
  77279. 2,
  77280. 3,
  77281. 3,
  77282. 3,
  77283. 4,
  77284. 7,
  77285. 8,
  77286. 9,
  77287. 9,
  77288. 10,
  77289. 11 // 23: B + 12
  77290. ];
  77291. // uv as integer step (not pixels !)
  77292. var ico_vertexuv = [
  77293. 5, 1, 3, 1, 6, 4, 0, 0,
  77294. 5, 3, 4, 2, 2, 2, 4, 0,
  77295. 2, 0, 1, 1, 6, 0, 6, 2,
  77296. // vertex alias (for same vertex on different faces)
  77297. 0, 4,
  77298. 3, 3,
  77299. 4, 4,
  77300. 3, 1,
  77301. 4, 2,
  77302. 4, 4,
  77303. 0, 2,
  77304. 1, 1,
  77305. 2, 2,
  77306. 3, 3,
  77307. 1, 3,
  77308. 2, 4 // 23: B + 12
  77309. ];
  77310. // Vertices[0, 1, ...9, A, B] : position on UV plane
  77311. // '+' indicate duplicate position to be fixed (3,9:0,2,3,4,7,8,A,B)
  77312. // First island of uv mapping
  77313. // v = 4h 3+ 2
  77314. // v = 3h 9+ 4
  77315. // v = 2h 9+ 5 B
  77316. // v = 1h 9 1 0
  77317. // v = 0h 3 8 7 A
  77318. // u = 0 1 2 3 4 5 6 *a
  77319. // Second island of uv mapping
  77320. // v = 4h 0+ B+ 4+
  77321. // v = 3h A+ 2+
  77322. // v = 2h 7+ 6 3+
  77323. // v = 1h 8+ 3+
  77324. // v = 0h
  77325. // u = 0 1 2 3 4 5 6 *a
  77326. // Face layout on texture UV mapping
  77327. // ============
  77328. // \ 4 /\ 16 / ======
  77329. // \ / \ / /\ 11 /
  77330. // \/ 7 \/ / \ /
  77331. // ======= / 10 \/
  77332. // /\ 17 /\ =======
  77333. // / \ / \ \ 15 /\
  77334. // / 8 \/ 12 \ \ / \
  77335. // ============ \/ 6 \
  77336. // \ 18 /\ ============
  77337. // \ / \ \ 5 /\ 0 /
  77338. // \/ 13 \ \ / \ /
  77339. // ======= \/ 1 \/
  77340. // =============
  77341. // /\ 19 /\ 2 /\
  77342. // / \ / \ / \
  77343. // / 14 \/ 9 \/ 3 \
  77344. // ===================
  77345. // uv step is u:1 or 0.5, v:cos(30)=sqrt(3)/2, ratio approx is 84/97
  77346. var ustep = 138 / 1024;
  77347. var vstep = 239 / 1024;
  77348. var uoffset = 60 / 1024;
  77349. var voffset = 26 / 1024;
  77350. // Second island should have margin, not to touch the first island
  77351. // avoid any borderline artefact in pixel rounding
  77352. var island_u_offset = -40 / 1024;
  77353. var island_v_offset = +20 / 1024;
  77354. // face is either island 0 or 1 :
  77355. // second island is for faces : [4, 7, 8, 12, 13, 16, 17, 18]
  77356. var island = [
  77357. 0, 0, 0, 0, 1,
  77358. 0, 0, 1, 1, 0,
  77359. 0, 0, 1, 1, 0,
  77360. 0, 1, 1, 1, 0 // 15 - 19
  77361. ];
  77362. var indices = new Array();
  77363. var positions = new Array();
  77364. var normals = new Array();
  77365. var uvs = new Array();
  77366. var current_indice = 0;
  77367. // prepare array of 3 vector (empty) (to be worked in place, shared for each face)
  77368. var face_vertex_pos = new Array(3);
  77369. var face_vertex_uv = new Array(3);
  77370. var v012;
  77371. for (v012 = 0; v012 < 3; v012++) {
  77372. face_vertex_pos[v012] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77373. face_vertex_uv[v012] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  77374. }
  77375. // create all with normals
  77376. for (var face = 0; face < 20; face++) {
  77377. // 3 vertex per face
  77378. for (v012 = 0; v012 < 3; v012++) {
  77379. // look up vertex 0,1,2 to its index in 0 to 11 (or 23 including alias)
  77380. var v_id = ico_indices[3 * face + v012];
  77381. // vertex have 3D position (x,y,z)
  77382. 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]);
  77383. // Normalize to get normal, then scale to radius
  77384. face_vertex_pos[v012].normalize().scaleInPlace(radius);
  77385. // uv Coordinates from vertex ID
  77386. 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);
  77387. }
  77388. // Subdivide the face (interpolate pos, norm, uv)
  77389. // - pos is linear interpolation, then projected to sphere (converge polyhedron to sphere)
  77390. // - norm is linear interpolation of vertex corner normal
  77391. // (to be checked if better to re-calc from face vertex, or if approximation is OK ??? )
  77392. // - uv is linear interpolation
  77393. //
  77394. // Topology is as below for sub-divide by 2
  77395. // vertex shown as v0,v1,v2
  77396. // interp index is i1 to progress in range [v0,v1[
  77397. // interp index is i2 to progress in range [v0,v2[
  77398. // face index as (i1,i2) for /\ : (i1,i2),(i1+1,i2),(i1,i2+1)
  77399. // and (i1,i2)' for \/ : (i1+1,i2),(i1+1,i2+1),(i1,i2+1)
  77400. //
  77401. //
  77402. // i2 v2
  77403. // ^ ^
  77404. // / / \
  77405. // / / \
  77406. // / / \
  77407. // / / (0,1) \
  77408. // / #---------\
  77409. // / / \ (0,0)'/ \
  77410. // / / \ / \
  77411. // / / \ / \
  77412. // / / (0,0) \ / (1,0) \
  77413. // / #---------#---------\
  77414. // v0 v1
  77415. //
  77416. // --------------------> i1
  77417. //
  77418. // interp of (i1,i2):
  77419. // along i2 : x0=lerp(v0,v2, i2/S) <---> x1=lerp(v1,v2, i2/S)
  77420. // along i1 : lerp(x0,x1, i1/(S-i2))
  77421. //
  77422. // centroid of triangle is needed to get help normal computation
  77423. // (c1,c2) are used for centroid location
  77424. var interp_vertex = function (i1, i2, c1, c2) {
  77425. // vertex is interpolated from
  77426. // - face_vertex_pos[0..2]
  77427. // - face_vertex_uv[0..2]
  77428. var pos_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[0], face_vertex_pos[2], i2 / subdivisions);
  77429. var pos_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[1], face_vertex_pos[2], i2 / subdivisions);
  77430. var pos_interp = (subdivisions === i2) ? face_vertex_pos[2] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(pos_x0, pos_x1, i1 / (subdivisions - i2));
  77431. pos_interp.normalize();
  77432. var vertex_normal;
  77433. if (flat) {
  77434. // in flat mode, recalculate normal as face centroid normal
  77435. var centroid_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[0], face_vertex_pos[2], c2 / subdivisions);
  77436. var centroid_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[1], face_vertex_pos[2], c2 / subdivisions);
  77437. vertex_normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(centroid_x0, centroid_x1, c1 / (subdivisions - c2));
  77438. }
  77439. else {
  77440. // in smooth mode, recalculate normal from each single vertex position
  77441. vertex_normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](pos_interp.x, pos_interp.y, pos_interp.z);
  77442. }
  77443. // Vertex normal need correction due to X,Y,Z radius scaling
  77444. vertex_normal.x /= radiusX;
  77445. vertex_normal.y /= radiusY;
  77446. vertex_normal.z /= radiusZ;
  77447. vertex_normal.normalize();
  77448. var uv_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(face_vertex_uv[0], face_vertex_uv[2], i2 / subdivisions);
  77449. var uv_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(face_vertex_uv[1], face_vertex_uv[2], i2 / subdivisions);
  77450. var uv_interp = (subdivisions === i2) ? face_vertex_uv[2] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(uv_x0, uv_x1, i1 / (subdivisions - i2));
  77451. positions.push(pos_interp.x * radiusX, pos_interp.y * radiusY, pos_interp.z * radiusZ);
  77452. normals.push(vertex_normal.x, vertex_normal.y, vertex_normal.z);
  77453. uvs.push(uv_interp.x, uv_interp.y);
  77454. // push each vertex has member of a face
  77455. // Same vertex can bleong to multiple face, it is pushed multiple time (duplicate vertex are present)
  77456. indices.push(current_indice);
  77457. current_indice++;
  77458. };
  77459. for (var i2 = 0; i2 < subdivisions; i2++) {
  77460. for (var i1 = 0; i1 + i2 < subdivisions; i1++) {
  77461. // face : (i1,i2) for /\ :
  77462. // interp for : (i1,i2),(i1+1,i2),(i1,i2+1)
  77463. interp_vertex(i1, i2, i1 + 1.0 / 3, i2 + 1.0 / 3);
  77464. interp_vertex(i1 + 1, i2, i1 + 1.0 / 3, i2 + 1.0 / 3);
  77465. interp_vertex(i1, i2 + 1, i1 + 1.0 / 3, i2 + 1.0 / 3);
  77466. if (i1 + i2 + 1 < subdivisions) {
  77467. // face : (i1,i2)' for \/ :
  77468. // interp for (i1+1,i2),(i1+1,i2+1),(i1,i2+1)
  77469. interp_vertex(i1 + 1, i2, i1 + 2.0 / 3, i2 + 2.0 / 3);
  77470. interp_vertex(i1 + 1, i2 + 1, i1 + 2.0 / 3, i2 + 2.0 / 3);
  77471. interp_vertex(i1, i2 + 1, i1 + 2.0 / 3, i2 + 2.0 / 3);
  77472. }
  77473. }
  77474. }
  77475. }
  77476. // Sides
  77477. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  77478. // Result
  77479. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  77480. vertexData.indices = indices;
  77481. vertexData.positions = positions;
  77482. vertexData.normals = normals;
  77483. vertexData.uvs = uvs;
  77484. return vertexData;
  77485. };
  77486. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateIcoSphere = function (name, options, scene) {
  77487. return IcoSphereBuilder.CreateIcoSphere(name, options, scene);
  77488. };
  77489. /**
  77490. * Class containing static functions to help procedurally build meshes
  77491. */
  77492. var IcoSphereBuilder = /** @class */ (function () {
  77493. function IcoSphereBuilder() {
  77494. }
  77495. /**
  77496. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  77497. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  77498. * * 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`)
  77499. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  77500. * * 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
  77501. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77502. * * 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
  77503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77504. * @param name defines the name of the mesh
  77505. * @param options defines the options used to create the mesh
  77506. * @param scene defines the hosting scene
  77507. * @returns the icosahedron mesh
  77508. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  77509. */
  77510. IcoSphereBuilder.CreateIcoSphere = function (name, options, scene) {
  77511. var sphere = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  77512. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77513. sphere._originalBuilderSideOrientation = options.sideOrientation;
  77514. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateIcoSphere(options);
  77515. vertexData.applyToMesh(sphere, options.updatable);
  77516. return sphere;
  77517. };
  77518. return IcoSphereBuilder;
  77519. }());
  77520. /***/ }),
  77521. /***/ "./Meshes/Builders/index.ts":
  77522. /*!**********************************!*\
  77523. !*** ./Meshes/Builders/index.ts ***!
  77524. \**********************************/
  77525. /*! exports provided: BoxBuilder, SphereBuilder, CylinderBuilder, TorusBuilder, LinesBuilder, PlaneBuilder, GroundBuilder, DiscBuilder, RibbonBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder */
  77526. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77527. "use strict";
  77528. __webpack_require__.r(__webpack_exports__);
  77529. /* harmony import */ var _boxBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  77530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _boxBuilder__WEBPACK_IMPORTED_MODULE_0__["BoxBuilder"]; });
  77531. /* harmony import */ var _discBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./discBuilder */ "./Meshes/Builders/discBuilder.ts");
  77532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _discBuilder__WEBPACK_IMPORTED_MODULE_1__["DiscBuilder"]; });
  77533. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  77534. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__["RibbonBuilder"]; });
  77535. /* harmony import */ var _sphereBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  77536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _sphereBuilder__WEBPACK_IMPORTED_MODULE_3__["SphereBuilder"]; });
  77537. /* harmony import */ var _cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  77538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"]; });
  77539. /* harmony import */ var _torusBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  77540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _torusBuilder__WEBPACK_IMPORTED_MODULE_5__["TorusBuilder"]; });
  77541. /* harmony import */ var _torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./torusKnotBuilder */ "./Meshes/Builders/torusKnotBuilder.ts");
  77542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__["TorusKnotBuilder"]; });
  77543. /* harmony import */ var _linesBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  77544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"]; });
  77545. /* harmony import */ var _polygonBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./polygonBuilder */ "./Meshes/Builders/polygonBuilder.ts");
  77546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _polygonBuilder__WEBPACK_IMPORTED_MODULE_8__["PolygonBuilder"]; });
  77547. /* harmony import */ var _shapeBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./shapeBuilder */ "./Meshes/Builders/shapeBuilder.ts");
  77548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _shapeBuilder__WEBPACK_IMPORTED_MODULE_9__["ShapeBuilder"]; });
  77549. /* harmony import */ var _latheBuilder__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./latheBuilder */ "./Meshes/Builders/latheBuilder.ts");
  77550. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _latheBuilder__WEBPACK_IMPORTED_MODULE_10__["LatheBuilder"]; });
  77551. /* harmony import */ var _planeBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  77552. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _planeBuilder__WEBPACK_IMPORTED_MODULE_11__["PlaneBuilder"]; });
  77553. /* harmony import */ var _groundBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  77554. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"]; });
  77555. /* harmony import */ var _tubeBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./tubeBuilder */ "./Meshes/Builders/tubeBuilder.ts");
  77556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _tubeBuilder__WEBPACK_IMPORTED_MODULE_13__["TubeBuilder"]; });
  77557. /* harmony import */ var _polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  77558. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__["PolyhedronBuilder"]; });
  77559. /* harmony import */ var _icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./icoSphereBuilder */ "./Meshes/Builders/icoSphereBuilder.ts");
  77560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__["IcoSphereBuilder"]; });
  77561. /* harmony import */ var _decalBuilder__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./decalBuilder */ "./Meshes/Builders/decalBuilder.ts");
  77562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _decalBuilder__WEBPACK_IMPORTED_MODULE_16__["DecalBuilder"]; });
  77563. /***/ }),
  77564. /***/ "./Meshes/Builders/latheBuilder.ts":
  77565. /*!*****************************************!*\
  77566. !*** ./Meshes/Builders/latheBuilder.ts ***!
  77567. \*****************************************/
  77568. /*! exports provided: LatheBuilder */
  77569. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77570. "use strict";
  77571. __webpack_require__.r(__webpack_exports__);
  77572. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return LatheBuilder; });
  77573. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77574. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77575. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  77576. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLathe = function (name, shape, radius, tessellation, scene, updatable, sideOrientation) {
  77577. var options = {
  77578. shape: shape,
  77579. radius: radius,
  77580. tessellation: tessellation,
  77581. sideOrientation: sideOrientation,
  77582. updatable: updatable
  77583. };
  77584. return LatheBuilder.CreateLathe(name, options, scene);
  77585. };
  77586. /**
  77587. * Class containing static functions to help procedurally build meshes
  77588. */
  77589. var LatheBuilder = /** @class */ (function () {
  77590. function LatheBuilder() {
  77591. }
  77592. /**
  77593. * Creates lathe mesh.
  77594. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  77595. * * 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
  77596. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  77597. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  77598. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  77599. * * 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
  77600. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  77601. * * 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
  77602. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77603. * * 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
  77604. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  77605. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77606. * @param name defines the name of the mesh
  77607. * @param options defines the options used to create the mesh
  77608. * @param scene defines the hosting scene
  77609. * @returns the lathe mesh
  77610. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  77611. */
  77612. LatheBuilder.CreateLathe = function (name, options, scene) {
  77613. var arc = options.arc ? ((options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc) : 1.0;
  77614. var closed = (options.closed === undefined) ? true : options.closed;
  77615. var shape = options.shape;
  77616. var radius = options.radius || 1;
  77617. var tessellation = options.tessellation || 64;
  77618. var clip = options.clip || 0;
  77619. var updatable = options.updatable;
  77620. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77621. var cap = options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  77622. var pi2 = Math.PI * 2;
  77623. var paths = new Array();
  77624. var invertUV = options.invertUV || false;
  77625. var i = 0;
  77626. var p = 0;
  77627. var step = pi2 / tessellation * arc;
  77628. var rotated;
  77629. var path = new Array();
  77630. for (i = 0; i <= tessellation - clip; i++) {
  77631. var path = [];
  77632. if (cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START || cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL) {
  77633. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, shape[0].y, 0));
  77634. 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));
  77635. }
  77636. for (p = 0; p < shape.length; p++) {
  77637. 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);
  77638. path.push(rotated);
  77639. }
  77640. if (cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END || cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL) {
  77641. 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));
  77642. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, shape[shape.length - 1].y, 0));
  77643. }
  77644. paths.push(path);
  77645. }
  77646. // lathe ribbon
  77647. 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);
  77648. return lathe;
  77649. };
  77650. return LatheBuilder;
  77651. }());
  77652. /***/ }),
  77653. /***/ "./Meshes/Builders/linesBuilder.ts":
  77654. /*!*****************************************!*\
  77655. !*** ./Meshes/Builders/linesBuilder.ts ***!
  77656. \*****************************************/
  77657. /*! exports provided: LinesBuilder */
  77658. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77659. "use strict";
  77660. __webpack_require__.r(__webpack_exports__);
  77661. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return LinesBuilder; });
  77662. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77663. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77664. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77665. /* harmony import */ var _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Meshes/linesMesh */ "./Meshes/linesMesh.ts");
  77666. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  77667. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateLineSystem = function (options) {
  77668. var indices = [];
  77669. var positions = [];
  77670. var lines = options.lines;
  77671. var colors = options.colors;
  77672. var vertexColors = [];
  77673. var idx = 0;
  77674. for (var l = 0; l < lines.length; l++) {
  77675. var points = lines[l];
  77676. for (var index = 0; index < points.length; index++) {
  77677. positions.push(points[index].x, points[index].y, points[index].z);
  77678. if (colors) {
  77679. var color = colors[l];
  77680. vertexColors.push(color[index].r, color[index].g, color[index].b, color[index].a);
  77681. }
  77682. if (index > 0) {
  77683. indices.push(idx - 1);
  77684. indices.push(idx);
  77685. }
  77686. idx++;
  77687. }
  77688. }
  77689. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  77690. vertexData.indices = indices;
  77691. vertexData.positions = positions;
  77692. if (colors) {
  77693. vertexData.colors = vertexColors;
  77694. }
  77695. return vertexData;
  77696. };
  77697. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateDashedLines = function (options) {
  77698. var dashSize = options.dashSize || 3;
  77699. var gapSize = options.gapSize || 1;
  77700. var dashNb = options.dashNb || 200;
  77701. var points = options.points;
  77702. var positions = new Array();
  77703. var indices = new Array();
  77704. var curvect = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77705. var lg = 0;
  77706. var nb = 0;
  77707. var shft = 0;
  77708. var dashshft = 0;
  77709. var curshft = 0;
  77710. var idx = 0;
  77711. var i = 0;
  77712. for (i = 0; i < points.length - 1; i++) {
  77713. points[i + 1].subtractToRef(points[i], curvect);
  77714. lg += curvect.length();
  77715. }
  77716. shft = lg / dashNb;
  77717. dashshft = dashSize * shft / (dashSize + gapSize);
  77718. for (i = 0; i < points.length - 1; i++) {
  77719. points[i + 1].subtractToRef(points[i], curvect);
  77720. nb = Math.floor(curvect.length() / shft);
  77721. curvect.normalize();
  77722. for (var j = 0; j < nb; j++) {
  77723. curshft = shft * j;
  77724. positions.push(points[i].x + curshft * curvect.x, points[i].y + curshft * curvect.y, points[i].z + curshft * curvect.z);
  77725. positions.push(points[i].x + (curshft + dashshft) * curvect.x, points[i].y + (curshft + dashshft) * curvect.y, points[i].z + (curshft + dashshft) * curvect.z);
  77726. indices.push(idx, idx + 1);
  77727. idx += 2;
  77728. }
  77729. }
  77730. // Result
  77731. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  77732. vertexData.positions = positions;
  77733. vertexData.indices = indices;
  77734. return vertexData;
  77735. };
  77736. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines = function (name, points, scene, updatable, instance) {
  77737. if (scene === void 0) { scene = null; }
  77738. if (updatable === void 0) { updatable = false; }
  77739. if (instance === void 0) { instance = null; }
  77740. var options = {
  77741. points: points,
  77742. updatable: updatable,
  77743. instance: instance
  77744. };
  77745. return LinesBuilder.CreateLines(name, options, scene);
  77746. };
  77747. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateDashedLines = function (name, points, dashSize, gapSize, dashNb, scene, updatable, instance) {
  77748. if (scene === void 0) { scene = null; }
  77749. var options = {
  77750. points: points,
  77751. dashSize: dashSize,
  77752. gapSize: gapSize,
  77753. dashNb: dashNb,
  77754. updatable: updatable,
  77755. instance: instance
  77756. };
  77757. return LinesBuilder.CreateDashedLines(name, options, scene);
  77758. };
  77759. /**
  77760. * Class containing static functions to help procedurally build meshes
  77761. */
  77762. var LinesBuilder = /** @class */ (function () {
  77763. function LinesBuilder() {
  77764. }
  77765. /**
  77766. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  77767. * * 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
  77768. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  77769. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  77770. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  77771. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  77772. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  77773. * * 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
  77774. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  77775. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77776. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  77777. * @param name defines the name of the new line system
  77778. * @param options defines the options used to create the line system
  77779. * @param scene defines the hosting scene
  77780. * @returns a new line system mesh
  77781. */
  77782. LinesBuilder.CreateLineSystem = function (name, options, scene) {
  77783. var instance = options.instance;
  77784. var lines = options.lines;
  77785. var colors = options.colors;
  77786. if (instance) { // lines update
  77787. var positions = instance.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  77788. var vertexColor;
  77789. var lineColors;
  77790. if (colors) {
  77791. vertexColor = instance.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  77792. }
  77793. var i = 0;
  77794. var c = 0;
  77795. for (var l = 0; l < lines.length; l++) {
  77796. var points = lines[l];
  77797. for (var p = 0; p < points.length; p++) {
  77798. positions[i] = points[p].x;
  77799. positions[i + 1] = points[p].y;
  77800. positions[i + 2] = points[p].z;
  77801. if (colors && vertexColor) {
  77802. lineColors = colors[l];
  77803. vertexColor[c] = lineColors[p].r;
  77804. vertexColor[c + 1] = lineColors[p].g;
  77805. vertexColor[c + 2] = lineColors[p].b;
  77806. vertexColor[c + 3] = lineColors[p].a;
  77807. c += 4;
  77808. }
  77809. i += 3;
  77810. }
  77811. }
  77812. instance.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind, positions, false, false);
  77813. if (colors && vertexColor) {
  77814. instance.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind, vertexColor, false, false);
  77815. }
  77816. return instance;
  77817. }
  77818. // line system creation
  77819. var useVertexColor = (colors) ? true : false;
  77820. var lineSystem = new _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"](name, scene, null, undefined, undefined, useVertexColor, options.useVertexAlpha);
  77821. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateLineSystem(options);
  77822. vertexData.applyToMesh(lineSystem, options.updatable);
  77823. return lineSystem;
  77824. };
  77825. /**
  77826. * Creates a line mesh
  77827. * 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
  77828. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  77829. * * The parameter `points` is an array successive Vector3
  77830. * * 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
  77831. * * The optional parameter `colors` is an array of successive Color4, one per line point
  77832. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  77833. * * When updating an instance, remember that only point positions can change, not the number of points
  77834. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77835. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  77836. * @param name defines the name of the new line system
  77837. * @param options defines the options used to create the line system
  77838. * @param scene defines the hosting scene
  77839. * @returns a new line mesh
  77840. */
  77841. LinesBuilder.CreateLines = function (name, options, scene) {
  77842. if (scene === void 0) { scene = null; }
  77843. var colors = (options.colors) ? [options.colors] : null;
  77844. var lines = LinesBuilder.CreateLineSystem(name, { lines: [options.points], updatable: options.updatable, instance: options.instance, colors: colors, useVertexAlpha: options.useVertexAlpha }, scene);
  77845. return lines;
  77846. };
  77847. /**
  77848. * Creates a dashed line mesh
  77849. * * 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
  77850. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  77851. * * The parameter `points` is an array successive Vector3
  77852. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  77853. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  77854. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  77855. * * 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
  77856. * * When updating an instance, remember that only point positions can change, not the number of points
  77857. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77858. * @param name defines the name of the mesh
  77859. * @param options defines the options used to create the mesh
  77860. * @param scene defines the hosting scene
  77861. * @returns the dashed line mesh
  77862. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  77863. */
  77864. LinesBuilder.CreateDashedLines = function (name, options, scene) {
  77865. if (scene === void 0) { scene = null; }
  77866. var points = options.points;
  77867. var instance = options.instance;
  77868. var gapSize = options.gapSize || 1;
  77869. var dashSize = options.dashSize || 3;
  77870. if (instance) { // dashed lines update
  77871. var positionFunction = function (positions) {
  77872. var curvect = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77873. var nbSeg = positions.length / 6;
  77874. var lg = 0;
  77875. var nb = 0;
  77876. var shft = 0;
  77877. var dashshft = 0;
  77878. var curshft = 0;
  77879. var p = 0;
  77880. var i = 0;
  77881. var j = 0;
  77882. for (i = 0; i < points.length - 1; i++) {
  77883. points[i + 1].subtractToRef(points[i], curvect);
  77884. lg += curvect.length();
  77885. }
  77886. shft = lg / nbSeg;
  77887. var dashSize = instance._creationDataStorage.dashSize;
  77888. var gapSize = instance._creationDataStorage.gapSize;
  77889. dashshft = dashSize * shft / (dashSize + gapSize);
  77890. for (i = 0; i < points.length - 1; i++) {
  77891. points[i + 1].subtractToRef(points[i], curvect);
  77892. nb = Math.floor(curvect.length() / shft);
  77893. curvect.normalize();
  77894. j = 0;
  77895. while (j < nb && p < positions.length) {
  77896. curshft = shft * j;
  77897. positions[p] = points[i].x + curshft * curvect.x;
  77898. positions[p + 1] = points[i].y + curshft * curvect.y;
  77899. positions[p + 2] = points[i].z + curshft * curvect.z;
  77900. positions[p + 3] = points[i].x + (curshft + dashshft) * curvect.x;
  77901. positions[p + 4] = points[i].y + (curshft + dashshft) * curvect.y;
  77902. positions[p + 5] = points[i].z + (curshft + dashshft) * curvect.z;
  77903. p += 6;
  77904. j++;
  77905. }
  77906. }
  77907. while (p < positions.length) {
  77908. positions[p] = points[i].x;
  77909. positions[p + 1] = points[i].y;
  77910. positions[p + 2] = points[i].z;
  77911. p += 3;
  77912. }
  77913. };
  77914. instance.updateMeshPositions(positionFunction, false);
  77915. return instance;
  77916. }
  77917. // dashed lines creation
  77918. var dashedLines = new _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"](name, scene);
  77919. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateDashedLines(options);
  77920. vertexData.applyToMesh(dashedLines, options.updatable);
  77921. dashedLines._creationDataStorage = new _mesh__WEBPACK_IMPORTED_MODULE_1__["_CreationDataStorage"]();
  77922. dashedLines._creationDataStorage.dashSize = dashSize;
  77923. dashedLines._creationDataStorage.gapSize = gapSize;
  77924. return dashedLines;
  77925. };
  77926. return LinesBuilder;
  77927. }());
  77928. /***/ }),
  77929. /***/ "./Meshes/Builders/planeBuilder.ts":
  77930. /*!*****************************************!*\
  77931. !*** ./Meshes/Builders/planeBuilder.ts ***!
  77932. \*****************************************/
  77933. /*! exports provided: PlaneBuilder */
  77934. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77935. "use strict";
  77936. __webpack_require__.r(__webpack_exports__);
  77937. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return PlaneBuilder; });
  77938. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77939. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77940. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreatePlane = function (options) {
  77941. var indices = [];
  77942. var positions = [];
  77943. var normals = [];
  77944. var uvs = [];
  77945. var width = options.width || options.size || 1;
  77946. var height = options.height || options.size || 1;
  77947. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].DEFAULTSIDE;
  77948. // Vertices
  77949. var halfWidth = width / 2.0;
  77950. var halfHeight = height / 2.0;
  77951. positions.push(-halfWidth, -halfHeight, 0);
  77952. normals.push(0, 0, -1.0);
  77953. uvs.push(0.0, 0.0);
  77954. positions.push(halfWidth, -halfHeight, 0);
  77955. normals.push(0, 0, -1.0);
  77956. uvs.push(1.0, 0.0);
  77957. positions.push(halfWidth, halfHeight, 0);
  77958. normals.push(0, 0, -1.0);
  77959. uvs.push(1.0, 1.0);
  77960. positions.push(-halfWidth, halfHeight, 0);
  77961. normals.push(0, 0, -1.0);
  77962. uvs.push(0.0, 1.0);
  77963. // Indices
  77964. indices.push(0);
  77965. indices.push(1);
  77966. indices.push(2);
  77967. indices.push(0);
  77968. indices.push(2);
  77969. indices.push(3);
  77970. // Sides
  77971. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  77972. // Result
  77973. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  77974. vertexData.indices = indices;
  77975. vertexData.positions = positions;
  77976. vertexData.normals = normals;
  77977. vertexData.uvs = uvs;
  77978. return vertexData;
  77979. };
  77980. _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreatePlane = function (name, size, scene, updatable, sideOrientation) {
  77981. var options = {
  77982. size: size,
  77983. width: size,
  77984. height: size,
  77985. sideOrientation: sideOrientation,
  77986. updatable: updatable
  77987. };
  77988. return PlaneBuilder.CreatePlane(name, options, scene);
  77989. };
  77990. /**
  77991. * Class containing static functions to help procedurally build meshes
  77992. */
  77993. var PlaneBuilder = /** @class */ (function () {
  77994. function PlaneBuilder() {
  77995. }
  77996. /**
  77997. * Creates a plane mesh
  77998. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  77999. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  78000. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  78001. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  78002. * * 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
  78003. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78004. * @param name defines the name of the mesh
  78005. * @param options defines the options used to create the mesh
  78006. * @param scene defines the hosting scene
  78007. * @returns the plane mesh
  78008. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  78009. */
  78010. PlaneBuilder.CreatePlane = function (name, options, scene) {
  78011. var plane = new _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"](name, scene);
  78012. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  78013. plane._originalBuilderSideOrientation = options.sideOrientation;
  78014. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreatePlane(options);
  78015. vertexData.applyToMesh(plane, options.updatable);
  78016. if (options.sourcePlane) {
  78017. plane.translate(options.sourcePlane.normal, -options.sourcePlane.d);
  78018. plane.setDirection(options.sourcePlane.normal.scale(-1));
  78019. }
  78020. return plane;
  78021. };
  78022. return PlaneBuilder;
  78023. }());
  78024. /***/ }),
  78025. /***/ "./Meshes/Builders/polygonBuilder.ts":
  78026. /*!*******************************************!*\
  78027. !*** ./Meshes/Builders/polygonBuilder.ts ***!
  78028. \*******************************************/
  78029. /*! exports provided: PolygonBuilder */
  78030. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78031. "use strict";
  78032. __webpack_require__.r(__webpack_exports__);
  78033. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return PolygonBuilder; });
  78034. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  78035. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  78036. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  78037. /* harmony import */ var _polygonMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../polygonMesh */ "./Meshes/polygonMesh.ts");
  78038. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  78039. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolygon = function (polygon, sideOrientation, fUV, fColors, frontUVs, backUVs) {
  78040. var faceUV = fUV || new Array(3);
  78041. var faceColors = fColors;
  78042. var colors = [];
  78043. // default face colors and UV if undefined
  78044. for (var f = 0; f < 3; f++) {
  78045. if (faceUV[f] === undefined) {
  78046. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  78047. }
  78048. if (faceColors && faceColors[f] === undefined) {
  78049. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  78050. }
  78051. }
  78052. var positions = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  78053. var normals = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind);
  78054. var uvs = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  78055. var indices = polygon.getIndices();
  78056. // set face colours and textures
  78057. var idx = 0;
  78058. var face = 0;
  78059. for (var index = 0; index < normals.length; index += 3) {
  78060. //Edge Face no. 1
  78061. if (Math.abs(normals[index + 1]) < 0.001) {
  78062. face = 1;
  78063. }
  78064. //Top Face no. 0
  78065. if (Math.abs(normals[index + 1] - 1) < 0.001) {
  78066. face = 0;
  78067. }
  78068. //Bottom Face no. 2
  78069. if (Math.abs(normals[index + 1] + 1) < 0.001) {
  78070. face = 2;
  78071. }
  78072. idx = index / 3;
  78073. uvs[2 * idx] = (1 - uvs[2 * idx]) * faceUV[face].x + uvs[2 * idx] * faceUV[face].z;
  78074. uvs[2 * idx + 1] = (1 - uvs[2 * idx + 1]) * faceUV[face].y + uvs[2 * idx + 1] * faceUV[face].w;
  78075. if (faceColors) {
  78076. colors.push(faceColors[face].r, faceColors[face].g, faceColors[face].b, faceColors[face].a);
  78077. }
  78078. }
  78079. // sides
  78080. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs, backUVs);
  78081. // Result
  78082. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  78083. vertexData.indices = indices;
  78084. vertexData.positions = positions;
  78085. vertexData.normals = normals;
  78086. vertexData.uvs = uvs;
  78087. if (faceColors) {
  78088. var totalColors = (sideOrientation === _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DOUBLESIDE) ? colors.concat(colors) : colors;
  78089. vertexData.colors = totalColors;
  78090. }
  78091. return vertexData;
  78092. };
  78093. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreatePolygon = function (name, shape, scene, holes, updatable, sideOrientation, earcutInjection) {
  78094. if (earcutInjection === void 0) { earcutInjection = earcut; }
  78095. var options = {
  78096. shape: shape,
  78097. holes: holes,
  78098. updatable: updatable,
  78099. sideOrientation: sideOrientation
  78100. };
  78101. return PolygonBuilder.CreatePolygon(name, options, scene, earcutInjection);
  78102. };
  78103. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudePolygon = function (name, shape, depth, scene, holes, updatable, sideOrientation, earcutInjection) {
  78104. if (earcutInjection === void 0) { earcutInjection = earcut; }
  78105. var options = {
  78106. shape: shape,
  78107. holes: holes,
  78108. depth: depth,
  78109. updatable: updatable,
  78110. sideOrientation: sideOrientation
  78111. };
  78112. return PolygonBuilder.ExtrudePolygon(name, options, scene, earcutInjection);
  78113. };
  78114. /**
  78115. * Class containing static functions to help procedurally build meshes
  78116. */
  78117. var PolygonBuilder = /** @class */ (function () {
  78118. function PolygonBuilder() {
  78119. }
  78120. /**
  78121. * Creates a polygon mesh
  78122. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  78123. * * 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
  78124. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78126. * * 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)
  78127. * * Remember you can only change the shape positions, not their number when updating a polygon
  78128. * @param name defines the name of the mesh
  78129. * @param options defines the options used to create the mesh
  78130. * @param scene defines the hosting scene
  78131. * @param earcutInjection can be used to inject your own earcut reference
  78132. * @returns the polygon mesh
  78133. */
  78134. PolygonBuilder.CreatePolygon = function (name, options, scene, earcutInjection) {
  78135. if (earcutInjection === void 0) { earcutInjection = earcut; }
  78136. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  78137. var shape = options.shape;
  78138. var holes = options.holes || [];
  78139. var depth = options.depth || 0;
  78140. var contours = [];
  78141. var hole = [];
  78142. for (var i = 0; i < shape.length; i++) {
  78143. contours[i] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](shape[i].x, shape[i].z);
  78144. }
  78145. var epsilon = 0.00000001;
  78146. if (contours[0].equalsWithEpsilon(contours[contours.length - 1], epsilon)) {
  78147. contours.pop();
  78148. }
  78149. var polygonTriangulation = new _polygonMesh__WEBPACK_IMPORTED_MODULE_3__["PolygonMeshBuilder"](name, contours, scene, earcutInjection);
  78150. for (var hNb = 0; hNb < holes.length; hNb++) {
  78151. hole = [];
  78152. for (var hPoint = 0; hPoint < holes[hNb].length; hPoint++) {
  78153. hole.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](holes[hNb][hPoint].x, holes[hNb][hPoint].z));
  78154. }
  78155. polygonTriangulation.addHole(hole);
  78156. }
  78157. var polygon = polygonTriangulation.build(options.updatable, depth);
  78158. polygon._originalBuilderSideOrientation = options.sideOrientation;
  78159. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolygon(polygon, options.sideOrientation, options.faceUV, options.faceColors, options.frontUVs, options.backUVs);
  78160. vertexData.applyToMesh(polygon, options.updatable);
  78161. return polygon;
  78162. };
  78163. /**
  78164. * Creates an extruded polygon mesh, with depth in the Y direction.
  78165. * * 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)
  78166. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  78167. * @param name defines the name of the mesh
  78168. * @param options defines the options used to create the mesh
  78169. * @param scene defines the hosting scene
  78170. * @param earcutInjection can be used to inject your own earcut reference
  78171. * @returns the polygon mesh
  78172. */
  78173. PolygonBuilder.ExtrudePolygon = function (name, options, scene, earcutInjection) {
  78174. if (earcutInjection === void 0) { earcutInjection = earcut; }
  78175. return PolygonBuilder.CreatePolygon(name, options, scene, earcutInjection);
  78176. };
  78177. return PolygonBuilder;
  78178. }());
  78179. /***/ }),
  78180. /***/ "./Meshes/Builders/polyhedronBuilder.ts":
  78181. /*!**********************************************!*\
  78182. !*** ./Meshes/Builders/polyhedronBuilder.ts ***!
  78183. \**********************************************/
  78184. /*! exports provided: PolyhedronBuilder */
  78185. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78186. "use strict";
  78187. __webpack_require__.r(__webpack_exports__);
  78188. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return PolyhedronBuilder; });
  78189. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  78190. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  78191. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  78192. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolyhedron = function (options) {
  78193. // provided polyhedron types :
  78194. // 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  78195. // 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)
  78196. var polyhedra = [];
  78197. 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]] };
  78198. 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]] };
  78199. polyhedra[2] = {
  78200. 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]],
  78201. 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]]
  78202. };
  78203. polyhedra[3] = {
  78204. 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]],
  78205. 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]]
  78206. };
  78207. polyhedra[4] = {
  78208. 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]],
  78209. 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]]
  78210. };
  78211. 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]] };
  78212. 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]] };
  78213. 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]] };
  78214. 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]] };
  78215. 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]] };
  78216. 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]] };
  78217. 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]] };
  78218. 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]] };
  78219. 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]] };
  78220. polyhedra[14] = {
  78221. 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]],
  78222. 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]]
  78223. };
  78224. var type = options.type && (options.type < 0 || options.type >= polyhedra.length) ? 0 : options.type || 0;
  78225. var size = options.size;
  78226. var sizeX = options.sizeX || size || 1;
  78227. var sizeY = options.sizeY || size || 1;
  78228. var sizeZ = options.sizeZ || size || 1;
  78229. var data = options.custom || polyhedra[type];
  78230. var nbfaces = data.face.length;
  78231. var faceUV = options.faceUV || new Array(nbfaces);
  78232. var faceColors = options.faceColors;
  78233. var flat = (options.flat === undefined) ? true : options.flat;
  78234. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  78235. var positions = new Array();
  78236. var indices = new Array();
  78237. var normals = new Array();
  78238. var uvs = new Array();
  78239. var colors = new Array();
  78240. var index = 0;
  78241. var faceIdx = 0; // face cursor in the array "indexes"
  78242. var indexes = new Array();
  78243. var i = 0;
  78244. var f = 0;
  78245. var u, v, ang, x, y, tmp;
  78246. // default face colors and UV if undefined
  78247. if (flat) {
  78248. for (f = 0; f < nbfaces; f++) {
  78249. if (faceColors && faceColors[f] === undefined) {
  78250. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  78251. }
  78252. if (faceUV && faceUV[f] === undefined) {
  78253. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  78254. }
  78255. }
  78256. }
  78257. if (!flat) {
  78258. for (i = 0; i < data.vertex.length; i++) {
  78259. positions.push(data.vertex[i][0] * sizeX, data.vertex[i][1] * sizeY, data.vertex[i][2] * sizeZ);
  78260. uvs.push(0, 0);
  78261. }
  78262. for (f = 0; f < nbfaces; f++) {
  78263. for (i = 0; i < data.face[f].length - 2; i++) {
  78264. indices.push(data.face[f][0], data.face[f][i + 2], data.face[f][i + 1]);
  78265. }
  78266. }
  78267. }
  78268. else {
  78269. for (f = 0; f < nbfaces; f++) {
  78270. var fl = data.face[f].length; // number of vertices of the current face
  78271. ang = 2 * Math.PI / fl;
  78272. x = 0.5 * Math.tan(ang / 2);
  78273. y = 0.5;
  78274. // positions, uvs, colors
  78275. for (i = 0; i < fl; i++) {
  78276. // positions
  78277. 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);
  78278. indexes.push(index);
  78279. index++;
  78280. // uvs
  78281. u = faceUV[f].x + (faceUV[f].z - faceUV[f].x) * (0.5 + x);
  78282. v = faceUV[f].y + (faceUV[f].w - faceUV[f].y) * (y - 0.5);
  78283. uvs.push(u, v);
  78284. tmp = x * Math.cos(ang) - y * Math.sin(ang);
  78285. y = x * Math.sin(ang) + y * Math.cos(ang);
  78286. x = tmp;
  78287. // colors
  78288. if (faceColors) {
  78289. colors.push(faceColors[f].r, faceColors[f].g, faceColors[f].b, faceColors[f].a);
  78290. }
  78291. }
  78292. // indices from indexes
  78293. for (i = 0; i < fl - 2; i++) {
  78294. indices.push(indexes[0 + faceIdx], indexes[i + 2 + faceIdx], indexes[i + 1 + faceIdx]);
  78295. }
  78296. faceIdx += fl;
  78297. }
  78298. }
  78299. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  78300. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  78301. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  78302. vertexData.positions = positions;
  78303. vertexData.indices = indices;
  78304. vertexData.normals = normals;
  78305. vertexData.uvs = uvs;
  78306. if (faceColors && flat) {
  78307. vertexData.colors = colors;
  78308. }
  78309. return vertexData;
  78310. };
  78311. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreatePolyhedron = function (name, options, scene) {
  78312. return PolyhedronBuilder.CreatePolyhedron(name, options, scene);
  78313. };
  78314. /**
  78315. * Class containing static functions to help procedurally build meshes
  78316. */
  78317. var PolyhedronBuilder = /** @class */ (function () {
  78318. function PolyhedronBuilder() {
  78319. }
  78320. /**
  78321. * Creates a polyhedron mesh
  78322. * * 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
  78323. * * The parameter `size` (positive float, default 1) sets the polygon size
  78324. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  78325. * * 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`
  78326. * * 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
  78327. * * 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)`)
  78328. * * 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
  78329. * * 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
  78330. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  78331. * * 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
  78332. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78333. * @param name defines the name of the mesh
  78334. * @param options defines the options used to create the mesh
  78335. * @param scene defines the hosting scene
  78336. * @returns the polyhedron mesh
  78337. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  78338. */
  78339. PolyhedronBuilder.CreatePolyhedron = function (name, options, scene) {
  78340. var polyhedron = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  78341. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  78342. polyhedron._originalBuilderSideOrientation = options.sideOrientation;
  78343. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolyhedron(options);
  78344. vertexData.applyToMesh(polyhedron, options.updatable);
  78345. return polyhedron;
  78346. };
  78347. return PolyhedronBuilder;
  78348. }());
  78349. /***/ }),
  78350. /***/ "./Meshes/Builders/ribbonBuilder.ts":
  78351. /*!******************************************!*\
  78352. !*** ./Meshes/Builders/ribbonBuilder.ts ***!
  78353. \******************************************/
  78354. /*! exports provided: RibbonBuilder */
  78355. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78356. "use strict";
  78357. __webpack_require__.r(__webpack_exports__);
  78358. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return RibbonBuilder; });
  78359. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  78360. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  78361. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../buffer */ "./Meshes/buffer.ts");
  78362. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  78363. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  78364. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateRibbon = function (options) {
  78365. var pathArray = options.pathArray;
  78366. var closeArray = options.closeArray || false;
  78367. var closePath = options.closePath || false;
  78368. var invertUV = options.invertUV || false;
  78369. var defaultOffset = Math.floor(pathArray[0].length / 2);
  78370. var offset = options.offset || defaultOffset;
  78371. offset = offset > defaultOffset ? defaultOffset : Math.floor(offset); // offset max allowed : defaultOffset
  78372. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].DEFAULTSIDE;
  78373. var customUV = options.uvs;
  78374. var customColors = options.colors;
  78375. var positions = [];
  78376. var indices = [];
  78377. var normals = [];
  78378. var uvs = [];
  78379. var us = []; // us[path_id] = [uDist1, uDist2, uDist3 ... ] distances between points on path path_id
  78380. var vs = []; // vs[i] = [vDist1, vDist2, vDist3, ... ] distances between points i of consecutives paths from pathArray
  78381. var uTotalDistance = []; // uTotalDistance[p] : total distance of path p
  78382. var vTotalDistance = []; // vTotalDistance[i] : total distance between points i of first and last path from pathArray
  78383. var minlg; // minimal length among all paths from pathArray
  78384. var lg = []; // array of path lengths : nb of vertex per path
  78385. var idx = []; // array of path indexes : index of each path (first vertex) in the total vertex number
  78386. var p; // path iterator
  78387. var i; // point iterator
  78388. var j; // point iterator
  78389. // if single path in pathArray
  78390. if (pathArray.length < 2) {
  78391. var ar1 = [];
  78392. var ar2 = [];
  78393. for (i = 0; i < pathArray[0].length - offset; i++) {
  78394. ar1.push(pathArray[0][i]);
  78395. ar2.push(pathArray[0][i + offset]);
  78396. }
  78397. pathArray = [ar1, ar2];
  78398. }
  78399. // positions and horizontal distances (u)
  78400. var idc = 0;
  78401. var closePathCorr = (closePath) ? 1 : 0; // the final index will be +1 if closePath
  78402. var path;
  78403. var l;
  78404. minlg = pathArray[0].length;
  78405. var vectlg;
  78406. var dist;
  78407. for (p = 0; p < pathArray.length; p++) {
  78408. uTotalDistance[p] = 0;
  78409. us[p] = [0];
  78410. path = pathArray[p];
  78411. l = path.length;
  78412. minlg = (minlg < l) ? minlg : l;
  78413. j = 0;
  78414. while (j < l) {
  78415. positions.push(path[j].x, path[j].y, path[j].z);
  78416. if (j > 0) {
  78417. vectlg = path[j].subtract(path[j - 1]).length();
  78418. dist = vectlg + uTotalDistance[p];
  78419. us[p].push(dist);
  78420. uTotalDistance[p] = dist;
  78421. }
  78422. j++;
  78423. }
  78424. if (closePath) { // an extra hidden vertex is added in the "positions" array
  78425. j--;
  78426. positions.push(path[0].x, path[0].y, path[0].z);
  78427. vectlg = path[j].subtract(path[0]).length();
  78428. dist = vectlg + uTotalDistance[p];
  78429. us[p].push(dist);
  78430. uTotalDistance[p] = dist;
  78431. }
  78432. lg[p] = l + closePathCorr;
  78433. idx[p] = idc;
  78434. idc += (l + closePathCorr);
  78435. }
  78436. // vertical distances (v)
  78437. var path1;
  78438. var path2;
  78439. var vertex1 = null;
  78440. var vertex2 = null;
  78441. for (i = 0; i < minlg + closePathCorr; i++) {
  78442. vTotalDistance[i] = 0;
  78443. vs[i] = [0];
  78444. for (p = 0; p < pathArray.length - 1; p++) {
  78445. path1 = pathArray[p];
  78446. path2 = pathArray[p + 1];
  78447. if (i === minlg) { // closePath
  78448. vertex1 = path1[0];
  78449. vertex2 = path2[0];
  78450. }
  78451. else {
  78452. vertex1 = path1[i];
  78453. vertex2 = path2[i];
  78454. }
  78455. vectlg = vertex2.subtract(vertex1).length();
  78456. dist = vectlg + vTotalDistance[i];
  78457. vs[i].push(dist);
  78458. vTotalDistance[i] = dist;
  78459. }
  78460. if (closeArray && vertex2 && vertex1) {
  78461. path1 = pathArray[p];
  78462. path2 = pathArray[0];
  78463. if (i === minlg) { // closePath
  78464. vertex2 = path2[0];
  78465. }
  78466. vectlg = vertex2.subtract(vertex1).length();
  78467. dist = vectlg + vTotalDistance[i];
  78468. vTotalDistance[i] = dist;
  78469. }
  78470. }
  78471. // uvs
  78472. var u;
  78473. var v;
  78474. if (customUV) {
  78475. for (p = 0; p < customUV.length; p++) {
  78476. uvs.push(customUV[p].x, customUV[p].y);
  78477. }
  78478. }
  78479. else {
  78480. for (p = 0; p < pathArray.length; p++) {
  78481. for (i = 0; i < minlg + closePathCorr; i++) {
  78482. u = (uTotalDistance[p] != 0.0) ? us[p][i] / uTotalDistance[p] : 0.0;
  78483. v = (vTotalDistance[i] != 0.0) ? vs[i][p] / vTotalDistance[i] : 0.0;
  78484. if (invertUV) {
  78485. uvs.push(v, u);
  78486. }
  78487. else {
  78488. uvs.push(u, v);
  78489. }
  78490. }
  78491. }
  78492. }
  78493. // indices
  78494. p = 0; // path index
  78495. var pi = 0; // positions array index
  78496. var l1 = lg[p] - 1; // path1 length
  78497. var l2 = lg[p + 1] - 1; // path2 length
  78498. var min = (l1 < l2) ? l1 : l2; // current path stop index
  78499. var shft = idx[1] - idx[0]; // shift
  78500. var path1nb = closeArray ? lg.length : lg.length - 1; // number of path1 to iterate on
  78501. while (pi <= min && p < path1nb) { // stay under min and don't go over next to last path
  78502. // 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
  78503. indices.push(pi, pi + shft, pi + 1);
  78504. indices.push(pi + shft + 1, pi + 1, pi + shft);
  78505. pi += 1;
  78506. if (pi === min) { // if end of one of two consecutive paths reached, go to next existing path
  78507. p++;
  78508. if (p === lg.length - 1) { // last path of pathArray reached <=> closeArray == true
  78509. shft = idx[0] - idx[p];
  78510. l1 = lg[p] - 1;
  78511. l2 = lg[0] - 1;
  78512. }
  78513. else {
  78514. shft = idx[p + 1] - idx[p];
  78515. l1 = lg[p] - 1;
  78516. l2 = lg[p + 1] - 1;
  78517. }
  78518. pi = idx[p];
  78519. min = (l1 < l2) ? l1 + pi : l2 + pi;
  78520. }
  78521. }
  78522. // normals
  78523. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].ComputeNormals(positions, indices, normals);
  78524. if (closePath) { // update both the first and last vertex normals to their average value
  78525. var indexFirst = 0;
  78526. var indexLast = 0;
  78527. for (p = 0; p < pathArray.length; p++) {
  78528. indexFirst = idx[p] * 3;
  78529. if (p + 1 < pathArray.length) {
  78530. indexLast = (idx[p + 1] - 1) * 3;
  78531. }
  78532. else {
  78533. indexLast = normals.length - 3;
  78534. }
  78535. normals[indexFirst] = (normals[indexFirst] + normals[indexLast]) * 0.5;
  78536. normals[indexFirst + 1] = (normals[indexFirst + 1] + normals[indexLast + 1]) * 0.5;
  78537. normals[indexFirst + 2] = (normals[indexFirst + 2] + normals[indexLast + 2]) * 0.5;
  78538. normals[indexLast] = normals[indexFirst];
  78539. normals[indexLast + 1] = normals[indexFirst + 1];
  78540. normals[indexLast + 2] = normals[indexFirst + 2];
  78541. }
  78542. }
  78543. // sides
  78544. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  78545. // Colors
  78546. var colors = null;
  78547. if (customColors) {
  78548. colors = new Float32Array(customColors.length * 4);
  78549. for (var c = 0; c < customColors.length; c++) {
  78550. colors[c * 4] = customColors[c].r;
  78551. colors[c * 4 + 1] = customColors[c].g;
  78552. colors[c * 4 + 2] = customColors[c].b;
  78553. colors[c * 4 + 3] = customColors[c].a;
  78554. }
  78555. }
  78556. // Result
  78557. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]();
  78558. var positions32 = new Float32Array(positions);
  78559. var normals32 = new Float32Array(normals);
  78560. var uvs32 = new Float32Array(uvs);
  78561. vertexData.indices = indices;
  78562. vertexData.positions = positions32;
  78563. vertexData.normals = normals32;
  78564. vertexData.uvs = uvs32;
  78565. if (colors) {
  78566. vertexData.set(colors, _buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  78567. }
  78568. if (closePath) {
  78569. vertexData._idx = idx;
  78570. }
  78571. return vertexData;
  78572. };
  78573. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateRibbon = function (name, pathArray, closeArray, closePath, offset, scene, updatable, sideOrientation, instance) {
  78574. if (closeArray === void 0) { closeArray = false; }
  78575. if (updatable === void 0) { updatable = false; }
  78576. return RibbonBuilder.CreateRibbon(name, {
  78577. pathArray: pathArray,
  78578. closeArray: closeArray,
  78579. closePath: closePath,
  78580. offset: offset,
  78581. updatable: updatable,
  78582. sideOrientation: sideOrientation,
  78583. instance: instance
  78584. }, scene);
  78585. };
  78586. /**
  78587. * Class containing static functions to help procedurally build meshes
  78588. */
  78589. var RibbonBuilder = /** @class */ (function () {
  78590. function RibbonBuilder() {
  78591. }
  78592. /**
  78593. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  78594. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  78595. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  78596. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  78597. * * 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
  78598. * * 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
  78599. * * 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
  78600. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  78601. * * 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
  78602. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  78603. * * 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
  78604. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  78605. * * 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
  78606. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  78607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78608. * @param name defines the name of the mesh
  78609. * @param options defines the options used to create the mesh
  78610. * @param scene defines the hosting scene
  78611. * @returns the ribbon mesh
  78612. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  78613. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  78614. */
  78615. RibbonBuilder.CreateRibbon = function (name, options, scene) {
  78616. if (scene === void 0) { scene = null; }
  78617. var pathArray = options.pathArray;
  78618. var closeArray = options.closeArray;
  78619. var closePath = options.closePath;
  78620. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  78621. var instance = options.instance;
  78622. var updatable = options.updatable;
  78623. if (instance) { // existing ribbon instance update
  78624. // positionFunction : ribbon case
  78625. // only pathArray and sideOrientation parameters are taken into account for positions update
  78626. var minimum_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0].setAll(Number.MAX_VALUE);
  78627. var maximum_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1].setAll(-Number.MAX_VALUE);
  78628. var positionFunction = function (positions) {
  78629. var minlg = pathArray[0].length;
  78630. var mesh = instance;
  78631. var i = 0;
  78632. var ns = (mesh._originalBuilderSideOrientation === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].DOUBLESIDE) ? 2 : 1;
  78633. for (var si = 1; si <= ns; ++si) {
  78634. for (var p = 0; p < pathArray.length; ++p) {
  78635. var path = pathArray[p];
  78636. var l = path.length;
  78637. minlg = (minlg < l) ? minlg : l;
  78638. for (var j = 0; j < minlg; ++j) {
  78639. var pathPoint = path[j];
  78640. positions[i] = pathPoint.x;
  78641. positions[i + 1] = pathPoint.y;
  78642. positions[i + 2] = pathPoint.z;
  78643. minimum_1.minimizeInPlaceFromFloats(pathPoint.x, pathPoint.y, pathPoint.z);
  78644. maximum_1.maximizeInPlaceFromFloats(pathPoint.x, pathPoint.y, pathPoint.z);
  78645. i += 3;
  78646. }
  78647. if (mesh._creationDataStorage && mesh._creationDataStorage.closePath) {
  78648. var pathPoint = path[0];
  78649. positions[i] = pathPoint.x;
  78650. positions[i + 1] = pathPoint.y;
  78651. positions[i + 2] = pathPoint.z;
  78652. i += 3;
  78653. }
  78654. }
  78655. }
  78656. };
  78657. var positions = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  78658. positionFunction(positions);
  78659. if (instance._boundingInfo) {
  78660. instance._boundingInfo.reConstruct(minimum_1, maximum_1, instance._worldMatrix);
  78661. }
  78662. else {
  78663. instance._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](minimum_1, maximum_1, instance._worldMatrix);
  78664. }
  78665. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, positions, false, false);
  78666. if (options.colors) {
  78667. var colors = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  78668. for (var c = 0, colorIndex = 0; c < options.colors.length; c++, colorIndex += 4) {
  78669. var color = options.colors[c];
  78670. colors[colorIndex] = color.r;
  78671. colors[colorIndex + 1] = color.g;
  78672. colors[colorIndex + 2] = color.b;
  78673. colors[colorIndex + 3] = color.a;
  78674. }
  78675. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, colors, false, false);
  78676. }
  78677. if (options.uvs) {
  78678. var uvs = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  78679. for (var i = 0; i < options.uvs.length; i++) {
  78680. uvs[i * 2] = options.uvs[i].x;
  78681. uvs[i * 2 + 1] = options.uvs[i].y;
  78682. }
  78683. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, uvs, false, false);
  78684. }
  78685. if (!instance.areNormalsFrozen || instance.isFacetDataEnabled) {
  78686. var indices = instance.getIndices();
  78687. var normals = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  78688. var params = instance.isFacetDataEnabled ? instance.getFacetDataParameters() : null;
  78689. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].ComputeNormals(positions, indices, normals, params);
  78690. if (instance._creationDataStorage && instance._creationDataStorage.closePath) {
  78691. var indexFirst = 0;
  78692. var indexLast = 0;
  78693. for (var p = 0; p < pathArray.length; p++) {
  78694. indexFirst = instance._creationDataStorage.idx[p] * 3;
  78695. if (p + 1 < pathArray.length) {
  78696. indexLast = (instance._creationDataStorage.idx[p + 1] - 1) * 3;
  78697. }
  78698. else {
  78699. indexLast = normals.length - 3;
  78700. }
  78701. normals[indexFirst] = (normals[indexFirst] + normals[indexLast]) * 0.5;
  78702. normals[indexFirst + 1] = (normals[indexFirst + 1] + normals[indexLast + 1]) * 0.5;
  78703. normals[indexFirst + 2] = (normals[indexFirst + 2] + normals[indexLast + 2]) * 0.5;
  78704. normals[indexLast] = normals[indexFirst];
  78705. normals[indexLast + 1] = normals[indexFirst + 1];
  78706. normals[indexLast + 2] = normals[indexFirst + 2];
  78707. }
  78708. }
  78709. if (!(instance.areNormalsFrozen)) {
  78710. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, normals, false, false);
  78711. }
  78712. }
  78713. return instance;
  78714. }
  78715. else { // new ribbon creation
  78716. var ribbon = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  78717. ribbon._originalBuilderSideOrientation = sideOrientation;
  78718. ribbon._creationDataStorage = new _mesh__WEBPACK_IMPORTED_MODULE_1__["_CreationDataStorage"]();
  78719. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateRibbon(options);
  78720. if (closePath) {
  78721. ribbon._creationDataStorage.idx = vertexData._idx;
  78722. }
  78723. ribbon._creationDataStorage.closePath = closePath;
  78724. ribbon._creationDataStorage.closeArray = closeArray;
  78725. vertexData.applyToMesh(ribbon, updatable);
  78726. return ribbon;
  78727. }
  78728. };
  78729. return RibbonBuilder;
  78730. }());
  78731. /***/ }),
  78732. /***/ "./Meshes/Builders/shapeBuilder.ts":
  78733. /*!*****************************************!*\
  78734. !*** ./Meshes/Builders/shapeBuilder.ts ***!
  78735. \*****************************************/
  78736. /*! exports provided: ShapeBuilder */
  78737. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78738. "use strict";
  78739. __webpack_require__.r(__webpack_exports__);
  78740. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return ShapeBuilder; });
  78741. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  78742. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  78743. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  78744. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudeShape = function (name, shape, path, scale, rotation, cap, scene, updatable, sideOrientation, instance) {
  78745. if (scene === void 0) { scene = null; }
  78746. var options = {
  78747. shape: shape,
  78748. path: path,
  78749. scale: scale,
  78750. rotation: rotation,
  78751. cap: (cap === 0) ? 0 : cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP,
  78752. sideOrientation: sideOrientation,
  78753. instance: instance,
  78754. updatable: updatable
  78755. };
  78756. return ShapeBuilder.ExtrudeShape(name, options, scene);
  78757. };
  78758. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudeShapeCustom = function (name, shape, path, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, cap, scene, updatable, sideOrientation, instance) {
  78759. var options = {
  78760. shape: shape,
  78761. path: path,
  78762. scaleFunction: scaleFunction,
  78763. rotationFunction: rotationFunction,
  78764. ribbonCloseArray: ribbonCloseArray,
  78765. ribbonClosePath: ribbonClosePath,
  78766. cap: (cap === 0) ? 0 : cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP,
  78767. sideOrientation: sideOrientation,
  78768. instance: instance,
  78769. updatable: updatable
  78770. };
  78771. return ShapeBuilder.ExtrudeShapeCustom(name, options, scene);
  78772. };
  78773. /**
  78774. * Class containing static functions to help procedurally build meshes
  78775. */
  78776. var ShapeBuilder = /** @class */ (function () {
  78777. function ShapeBuilder() {
  78778. }
  78779. /**
  78780. * 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.
  78781. * * 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.
  78782. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  78783. * * 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.
  78784. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  78785. * * 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
  78786. * * 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
  78787. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  78788. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  78789. * * 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
  78790. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  78791. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  78792. * @param name defines the name of the mesh
  78793. * @param options defines the options used to create the mesh
  78794. * @param scene defines the hosting scene
  78795. * @returns the extruded shape mesh
  78796. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  78797. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  78798. */
  78799. ShapeBuilder.ExtrudeShape = function (name, options, scene) {
  78800. if (scene === void 0) { scene = null; }
  78801. var path = options.path;
  78802. var shape = options.shape;
  78803. var scale = options.scale || 1;
  78804. var rotation = options.rotation || 0;
  78805. var cap = (options.cap === 0) ? 0 : options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  78806. var updatable = options.updatable;
  78807. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  78808. var instance = options.instance || null;
  78809. var invertUV = options.invertUV || false;
  78810. 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);
  78811. };
  78812. /**
  78813. * Creates an custom extruded shape mesh.
  78814. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  78815. * * 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.
  78816. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  78817. * * 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
  78818. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  78819. * * 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
  78820. * * It must returns a float value that will be the scale value applied to the shape on each path point
  78821. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  78822. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  78823. * * 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
  78824. * * 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
  78825. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  78826. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  78827. * * 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
  78828. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  78829. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78830. * @param name defines the name of the mesh
  78831. * @param options defines the options used to create the mesh
  78832. * @param scene defines the hosting scene
  78833. * @returns the custom extruded shape mesh
  78834. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  78835. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  78836. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  78837. */
  78838. ShapeBuilder.ExtrudeShapeCustom = function (name, options, scene) {
  78839. var path = options.path;
  78840. var shape = options.shape;
  78841. var scaleFunction = options.scaleFunction || (function () { return 1; });
  78842. var rotationFunction = options.rotationFunction || (function () { return 0; });
  78843. var ribbonCloseArray = options.ribbonCloseArray || false;
  78844. var ribbonClosePath = options.ribbonClosePath || false;
  78845. var cap = (options.cap === 0) ? 0 : options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  78846. var updatable = options.updatable;
  78847. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  78848. var instance = options.instance;
  78849. var invertUV = options.invertUV || false;
  78850. 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);
  78851. };
  78852. ShapeBuilder._ExtrudeShapeGeneric = function (name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs) {
  78853. // extrusion geometry
  78854. var extrusionPathArray = function (shape, curve, path3D, shapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom) {
  78855. var tangents = path3D.getTangents();
  78856. var normals = path3D.getNormals();
  78857. var binormals = path3D.getBinormals();
  78858. var distances = path3D.getDistances();
  78859. var angle = 0;
  78860. var returnScale = function () { return scale !== null ? scale : 1; };
  78861. var returnRotation = function () { return rotation !== null ? rotation : 0; };
  78862. var rotate = custom && rotateFunction ? rotateFunction : returnRotation;
  78863. var scl = custom && scaleFunction ? scaleFunction : returnScale;
  78864. var index = (cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP || cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END) ? 0 : 2;
  78865. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  78866. for (var i = 0; i < curve.length; i++) {
  78867. var shapePath = new Array();
  78868. var angleStep = rotate(i, distances[i]);
  78869. var scaleRatio = scl(i, distances[i]);
  78870. for (var p = 0; p < shape.length; p++) {
  78871. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(tangents[i], angle, rotationMatrix);
  78872. var planed = ((tangents[i].scale(shape[p].z)).add(normals[i].scale(shape[p].x)).add(binormals[i].scale(shape[p].y)));
  78873. var rotated = shapePath[p] ? shapePath[p] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78874. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(planed, rotationMatrix, rotated);
  78875. rotated.scaleInPlace(scaleRatio).addInPlace(curve[i]);
  78876. shapePath[p] = rotated;
  78877. }
  78878. shapePaths[index] = shapePath;
  78879. angle += angleStep;
  78880. index++;
  78881. }
  78882. // cap
  78883. var capPath = function (shapePath) {
  78884. var pointCap = Array();
  78885. var barycenter = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78886. var i;
  78887. for (i = 0; i < shapePath.length; i++) {
  78888. barycenter.addInPlace(shapePath[i]);
  78889. }
  78890. barycenter.scaleInPlace(1.0 / shapePath.length);
  78891. for (i = 0; i < shapePath.length; i++) {
  78892. pointCap.push(barycenter);
  78893. }
  78894. return pointCap;
  78895. };
  78896. switch (cap) {
  78897. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP:
  78898. break;
  78899. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START:
  78900. shapePaths[0] = capPath(shapePaths[2]);
  78901. shapePaths[1] = shapePaths[2];
  78902. break;
  78903. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END:
  78904. shapePaths[index] = shapePaths[index - 1];
  78905. shapePaths[index + 1] = capPath(shapePaths[index - 1]);
  78906. break;
  78907. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL:
  78908. shapePaths[0] = capPath(shapePaths[2]);
  78909. shapePaths[1] = shapePaths[2];
  78910. shapePaths[index] = shapePaths[index - 1];
  78911. shapePaths[index + 1] = capPath(shapePaths[index - 1]);
  78912. break;
  78913. default:
  78914. break;
  78915. }
  78916. return shapePaths;
  78917. };
  78918. var path3D;
  78919. var pathArray;
  78920. if (instance) { // instance update
  78921. var storage = instance._creationDataStorage;
  78922. path3D = storage.path3D.update(curve);
  78923. pathArray = extrusionPathArray(shape, curve, storage.path3D, storage.pathArray, scale, rotation, scaleFunction, rotateFunction, storage.cap, custom);
  78924. instance = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateRibbon("", pathArray, false, false, 0, scene || undefined, false, 0, instance);
  78925. return instance;
  78926. }
  78927. // extruded shape creation
  78928. path3D = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Path3D"](curve);
  78929. var newShapePaths = new Array();
  78930. cap = (cap < 0 || cap > 3) ? 0 : cap;
  78931. pathArray = extrusionPathArray(shape, curve, path3D, newShapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom);
  78932. 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);
  78933. extrudedGeneric._creationDataStorage.pathArray = pathArray;
  78934. extrudedGeneric._creationDataStorage.path3D = path3D;
  78935. extrudedGeneric._creationDataStorage.cap = cap;
  78936. return extrudedGeneric;
  78937. };
  78938. return ShapeBuilder;
  78939. }());
  78940. /***/ }),
  78941. /***/ "./Meshes/Builders/sphereBuilder.ts":
  78942. /*!******************************************!*\
  78943. !*** ./Meshes/Builders/sphereBuilder.ts ***!
  78944. \******************************************/
  78945. /*! exports provided: SphereBuilder */
  78946. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78947. "use strict";
  78948. __webpack_require__.r(__webpack_exports__);
  78949. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return SphereBuilder; });
  78950. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  78951. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  78952. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  78953. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateSphere = function (options) {
  78954. var segments = options.segments || 32;
  78955. var diameterX = options.diameterX || options.diameter || 1;
  78956. var diameterY = options.diameterY || options.diameter || 1;
  78957. var diameterZ = options.diameterZ || options.diameter || 1;
  78958. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  78959. var slice = options.slice && (options.slice <= 0) ? 1.0 : options.slice || 1.0;
  78960. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  78961. var radius = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](diameterX / 2, diameterY / 2, diameterZ / 2);
  78962. var totalZRotationSteps = 2 + segments;
  78963. var totalYRotationSteps = 2 * totalZRotationSteps;
  78964. var indices = [];
  78965. var positions = [];
  78966. var normals = [];
  78967. var uvs = [];
  78968. for (var zRotationStep = 0; zRotationStep <= totalZRotationSteps; zRotationStep++) {
  78969. var normalizedZ = zRotationStep / totalZRotationSteps;
  78970. var angleZ = normalizedZ * Math.PI * slice;
  78971. for (var yRotationStep = 0; yRotationStep <= totalYRotationSteps; yRotationStep++) {
  78972. var normalizedY = yRotationStep / totalYRotationSteps;
  78973. var angleY = normalizedY * Math.PI * 2 * arc;
  78974. var rotationZ = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationZ(-angleZ);
  78975. var rotationY = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationY(angleY);
  78976. var afterRotZ = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), rotationZ);
  78977. var complete = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(afterRotZ, rotationY);
  78978. var vertex = complete.multiply(radius);
  78979. var normal = complete.divide(radius).normalize();
  78980. positions.push(vertex.x, vertex.y, vertex.z);
  78981. normals.push(normal.x, normal.y, normal.z);
  78982. uvs.push(normalizedY, normalizedZ);
  78983. }
  78984. if (zRotationStep > 0) {
  78985. var verticesCount = positions.length / 3;
  78986. for (var firstIndex = verticesCount - 2 * (totalYRotationSteps + 1); (firstIndex + totalYRotationSteps + 2) < verticesCount; firstIndex++) {
  78987. indices.push((firstIndex));
  78988. indices.push((firstIndex + 1));
  78989. indices.push(firstIndex + totalYRotationSteps + 1);
  78990. indices.push((firstIndex + totalYRotationSteps + 1));
  78991. indices.push((firstIndex + 1));
  78992. indices.push((firstIndex + totalYRotationSteps + 2));
  78993. }
  78994. }
  78995. }
  78996. // Sides
  78997. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  78998. // Result
  78999. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  79000. vertexData.indices = indices;
  79001. vertexData.positions = positions;
  79002. vertexData.normals = normals;
  79003. vertexData.uvs = uvs;
  79004. return vertexData;
  79005. };
  79006. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateSphere = function (name, segments, diameter, scene, updatable, sideOrientation) {
  79007. var options = {
  79008. segments: segments,
  79009. diameterX: diameter,
  79010. diameterY: diameter,
  79011. diameterZ: diameter,
  79012. sideOrientation: sideOrientation,
  79013. updatable: updatable
  79014. };
  79015. return SphereBuilder.CreateSphere(name, options, scene);
  79016. };
  79017. /**
  79018. * Class containing static functions to help procedurally build meshes
  79019. */
  79020. var SphereBuilder = /** @class */ (function () {
  79021. function SphereBuilder() {
  79022. }
  79023. /**
  79024. * Creates a sphere mesh
  79025. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  79026. * * 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`)
  79027. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  79028. * * 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
  79029. * * 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)
  79030. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79031. * * 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
  79032. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79033. * @param name defines the name of the mesh
  79034. * @param options defines the options used to create the mesh
  79035. * @param scene defines the hosting scene
  79036. * @returns the sphere mesh
  79037. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  79038. */
  79039. SphereBuilder.CreateSphere = function (name, options, scene) {
  79040. var sphere = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  79041. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  79042. sphere._originalBuilderSideOrientation = options.sideOrientation;
  79043. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateSphere(options);
  79044. vertexData.applyToMesh(sphere, options.updatable);
  79045. return sphere;
  79046. };
  79047. return SphereBuilder;
  79048. }());
  79049. /***/ }),
  79050. /***/ "./Meshes/Builders/torusBuilder.ts":
  79051. /*!*****************************************!*\
  79052. !*** ./Meshes/Builders/torusBuilder.ts ***!
  79053. \*****************************************/
  79054. /*! exports provided: TorusBuilder */
  79055. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79056. "use strict";
  79057. __webpack_require__.r(__webpack_exports__);
  79058. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return TorusBuilder; });
  79059. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  79060. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  79061. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  79062. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorus = function (options) {
  79063. var indices = [];
  79064. var positions = [];
  79065. var normals = [];
  79066. var uvs = [];
  79067. var diameter = options.diameter || 1;
  79068. var thickness = options.thickness || 0.5;
  79069. var tessellation = options.tessellation || 16;
  79070. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  79071. var stride = tessellation + 1;
  79072. for (var i = 0; i <= tessellation; i++) {
  79073. var u = i / tessellation;
  79074. var outerAngle = i * Math.PI * 2.0 / tessellation - Math.PI / 2.0;
  79075. 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));
  79076. for (var j = 0; j <= tessellation; j++) {
  79077. var v = 1 - j / tessellation;
  79078. var innerAngle = j * Math.PI * 2.0 / tessellation + Math.PI;
  79079. var dx = Math.cos(innerAngle);
  79080. var dy = Math.sin(innerAngle);
  79081. // Create a vertex.
  79082. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](dx, dy, 0);
  79083. var position = normal.scale(thickness / 2);
  79084. var textureCoordinate = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](u, v);
  79085. position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(position, transform);
  79086. normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(normal, transform);
  79087. positions.push(position.x, position.y, position.z);
  79088. normals.push(normal.x, normal.y, normal.z);
  79089. uvs.push(textureCoordinate.x, textureCoordinate.y);
  79090. // And create indices for two triangles.
  79091. var nextI = (i + 1) % stride;
  79092. var nextJ = (j + 1) % stride;
  79093. indices.push(i * stride + j);
  79094. indices.push(i * stride + nextJ);
  79095. indices.push(nextI * stride + j);
  79096. indices.push(i * stride + nextJ);
  79097. indices.push(nextI * stride + nextJ);
  79098. indices.push(nextI * stride + j);
  79099. }
  79100. }
  79101. // Sides
  79102. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  79103. // Result
  79104. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  79105. vertexData.indices = indices;
  79106. vertexData.positions = positions;
  79107. vertexData.normals = normals;
  79108. vertexData.uvs = uvs;
  79109. return vertexData;
  79110. };
  79111. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTorus = function (name, diameter, thickness, tessellation, scene, updatable, sideOrientation) {
  79112. var options = {
  79113. diameter: diameter,
  79114. thickness: thickness,
  79115. tessellation: tessellation,
  79116. sideOrientation: sideOrientation,
  79117. updatable: updatable
  79118. };
  79119. return TorusBuilder.CreateTorus(name, options, scene);
  79120. };
  79121. /**
  79122. * Class containing static functions to help procedurally build meshes
  79123. */
  79124. var TorusBuilder = /** @class */ (function () {
  79125. function TorusBuilder() {
  79126. }
  79127. /**
  79128. * Creates a torus mesh
  79129. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  79130. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  79131. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  79132. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79133. * * 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
  79134. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  79135. * @param name defines the name of the mesh
  79136. * @param options defines the options used to create the mesh
  79137. * @param scene defines the hosting scene
  79138. * @returns the torus mesh
  79139. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  79140. */
  79141. TorusBuilder.CreateTorus = function (name, options, scene) {
  79142. var torus = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  79143. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  79144. torus._originalBuilderSideOrientation = options.sideOrientation;
  79145. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorus(options);
  79146. vertexData.applyToMesh(torus, options.updatable);
  79147. return torus;
  79148. };
  79149. return TorusBuilder;
  79150. }());
  79151. /***/ }),
  79152. /***/ "./Meshes/Builders/torusKnotBuilder.ts":
  79153. /*!*********************************************!*\
  79154. !*** ./Meshes/Builders/torusKnotBuilder.ts ***!
  79155. \*********************************************/
  79156. /*! exports provided: TorusKnotBuilder */
  79157. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79158. "use strict";
  79159. __webpack_require__.r(__webpack_exports__);
  79160. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return TorusKnotBuilder; });
  79161. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  79162. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  79163. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  79164. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorusKnot = function (options) {
  79165. var indices = new Array();
  79166. var positions = new Array();
  79167. var normals = new Array();
  79168. var uvs = new Array();
  79169. var radius = options.radius || 2;
  79170. var tube = options.tube || 0.5;
  79171. var radialSegments = options.radialSegments || 32;
  79172. var tubularSegments = options.tubularSegments || 32;
  79173. var p = options.p || 2;
  79174. var q = options.q || 3;
  79175. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  79176. // Helper
  79177. var getPos = function (angle) {
  79178. var cu = Math.cos(angle);
  79179. var su = Math.sin(angle);
  79180. var quOverP = q / p * angle;
  79181. var cs = Math.cos(quOverP);
  79182. var tx = radius * (2 + cs) * 0.5 * cu;
  79183. var ty = radius * (2 + cs) * su * 0.5;
  79184. var tz = radius * Math.sin(quOverP) * 0.5;
  79185. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](tx, ty, tz);
  79186. };
  79187. // Vertices
  79188. var i;
  79189. var j;
  79190. for (i = 0; i <= radialSegments; i++) {
  79191. var modI = i % radialSegments;
  79192. var u = modI / radialSegments * 2 * p * Math.PI;
  79193. var p1 = getPos(u);
  79194. var p2 = getPos(u + 0.01);
  79195. var tang = p2.subtract(p1);
  79196. var n = p2.add(p1);
  79197. var bitan = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(tang, n);
  79198. n = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(bitan, tang);
  79199. bitan.normalize();
  79200. n.normalize();
  79201. for (j = 0; j < tubularSegments; j++) {
  79202. var modJ = j % tubularSegments;
  79203. var v = modJ / tubularSegments * 2 * Math.PI;
  79204. var cx = -tube * Math.cos(v);
  79205. var cy = tube * Math.sin(v);
  79206. positions.push(p1.x + cx * n.x + cy * bitan.x);
  79207. positions.push(p1.y + cx * n.y + cy * bitan.y);
  79208. positions.push(p1.z + cx * n.z + cy * bitan.z);
  79209. uvs.push(i / radialSegments);
  79210. uvs.push(j / tubularSegments);
  79211. }
  79212. }
  79213. for (i = 0; i < radialSegments; i++) {
  79214. for (j = 0; j < tubularSegments; j++) {
  79215. var jNext = (j + 1) % tubularSegments;
  79216. var a = i * tubularSegments + j;
  79217. var b = (i + 1) * tubularSegments + j;
  79218. var c = (i + 1) * tubularSegments + jNext;
  79219. var d = i * tubularSegments + jNext;
  79220. indices.push(d);
  79221. indices.push(b);
  79222. indices.push(a);
  79223. indices.push(d);
  79224. indices.push(c);
  79225. indices.push(b);
  79226. }
  79227. }
  79228. // Normals
  79229. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  79230. // Sides
  79231. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  79232. // Result
  79233. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  79234. vertexData.indices = indices;
  79235. vertexData.positions = positions;
  79236. vertexData.normals = normals;
  79237. vertexData.uvs = uvs;
  79238. return vertexData;
  79239. };
  79240. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTorusKnot = function (name, radius, tube, radialSegments, tubularSegments, p, q, scene, updatable, sideOrientation) {
  79241. var options = {
  79242. radius: radius,
  79243. tube: tube,
  79244. radialSegments: radialSegments,
  79245. tubularSegments: tubularSegments,
  79246. p: p,
  79247. q: q,
  79248. sideOrientation: sideOrientation,
  79249. updatable: updatable
  79250. };
  79251. return TorusKnotBuilder.CreateTorusKnot(name, options, scene);
  79252. };
  79253. /**
  79254. * Class containing static functions to help procedurally build meshes
  79255. */
  79256. var TorusKnotBuilder = /** @class */ (function () {
  79257. function TorusKnotBuilder() {
  79258. }
  79259. /**
  79260. * Creates a torus knot mesh
  79261. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  79262. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  79263. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  79264. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  79265. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79266. * * 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
  79267. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  79268. * @param name defines the name of the mesh
  79269. * @param options defines the options used to create the mesh
  79270. * @param scene defines the hosting scene
  79271. * @returns the torus knot mesh
  79272. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  79273. */
  79274. TorusKnotBuilder.CreateTorusKnot = function (name, options, scene) {
  79275. var torusKnot = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  79276. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  79277. torusKnot._originalBuilderSideOrientation = options.sideOrientation;
  79278. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorusKnot(options);
  79279. vertexData.applyToMesh(torusKnot, options.updatable);
  79280. return torusKnot;
  79281. };
  79282. return TorusKnotBuilder;
  79283. }());
  79284. /***/ }),
  79285. /***/ "./Meshes/Builders/tubeBuilder.ts":
  79286. /*!****************************************!*\
  79287. !*** ./Meshes/Builders/tubeBuilder.ts ***!
  79288. \****************************************/
  79289. /*! exports provided: TubeBuilder */
  79290. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79291. "use strict";
  79292. __webpack_require__.r(__webpack_exports__);
  79293. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return TubeBuilder; });
  79294. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  79295. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  79296. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  79297. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTube = function (name, path, radius, tessellation, radiusFunction, cap, scene, updatable, sideOrientation, instance) {
  79298. var options = {
  79299. path: path,
  79300. radius: radius,
  79301. tessellation: tessellation,
  79302. radiusFunction: radiusFunction,
  79303. arc: 1,
  79304. cap: cap,
  79305. updatable: updatable,
  79306. sideOrientation: sideOrientation,
  79307. instance: instance
  79308. };
  79309. return TubeBuilder.CreateTube(name, options, scene);
  79310. };
  79311. /**
  79312. * Class containing static functions to help procedurally build meshes
  79313. */
  79314. var TubeBuilder = /** @class */ (function () {
  79315. function TubeBuilder() {
  79316. }
  79317. /**
  79318. * Creates a tube mesh.
  79319. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  79320. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  79321. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  79322. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  79323. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  79324. * * 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)
  79325. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  79326. * * 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
  79327. * * 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
  79328. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79329. * * 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
  79330. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  79331. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79332. * @param name defines the name of the mesh
  79333. * @param options defines the options used to create the mesh
  79334. * @param scene defines the hosting scene
  79335. * @returns the tube mesh
  79336. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  79337. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  79338. */
  79339. TubeBuilder.CreateTube = function (name, options, scene) {
  79340. var path = options.path;
  79341. var instance = options.instance;
  79342. var radius = 1.0;
  79343. if (options.radius !== undefined) {
  79344. radius = options.radius;
  79345. }
  79346. else if (instance) {
  79347. radius = instance._creationDataStorage.radius;
  79348. }
  79349. var tessellation = options.tessellation || 64 | 0;
  79350. var radiusFunction = options.radiusFunction || null;
  79351. var cap = options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  79352. var invertUV = options.invertUV || false;
  79353. var updatable = options.updatable;
  79354. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  79355. options.arc = options.arc && (options.arc <= 0.0 || options.arc > 1.0) ? 1.0 : options.arc || 1.0;
  79356. // tube geometry
  79357. var tubePathArray = function (path, path3D, circlePaths, radius, tessellation, radiusFunction, cap, arc) {
  79358. var tangents = path3D.getTangents();
  79359. var normals = path3D.getNormals();
  79360. var distances = path3D.getDistances();
  79361. var pi2 = Math.PI * 2;
  79362. var step = pi2 / tessellation * arc;
  79363. var returnRadius = function () { return radius; };
  79364. var radiusFunctionFinal = radiusFunction || returnRadius;
  79365. var circlePath;
  79366. var rad;
  79367. var normal;
  79368. var rotated;
  79369. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  79370. var index = (cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP || cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END) ? 0 : 2;
  79371. for (var i = 0; i < path.length; i++) {
  79372. rad = radiusFunctionFinal(i, distances[i]); // current radius
  79373. circlePath = Array(); // current circle array
  79374. normal = normals[i]; // current normal
  79375. for (var t = 0; t < tessellation; t++) {
  79376. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(tangents[i], step * t, rotationMatrix);
  79377. rotated = circlePath[t] ? circlePath[t] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  79378. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(normal, rotationMatrix, rotated);
  79379. rotated.scaleInPlace(rad).addInPlace(path[i]);
  79380. circlePath[t] = rotated;
  79381. }
  79382. circlePaths[index] = circlePath;
  79383. index++;
  79384. }
  79385. // cap
  79386. var capPath = function (nbPoints, pathIndex) {
  79387. var pointCap = Array();
  79388. for (var i = 0; i < nbPoints; i++) {
  79389. pointCap.push(path[pathIndex]);
  79390. }
  79391. return pointCap;
  79392. };
  79393. switch (cap) {
  79394. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP:
  79395. break;
  79396. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START:
  79397. circlePaths[0] = capPath(tessellation, 0);
  79398. circlePaths[1] = circlePaths[2].slice(0);
  79399. break;
  79400. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END:
  79401. circlePaths[index] = circlePaths[index - 1].slice(0);
  79402. circlePaths[index + 1] = capPath(tessellation, path.length - 1);
  79403. break;
  79404. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL:
  79405. circlePaths[0] = capPath(tessellation, 0);
  79406. circlePaths[1] = circlePaths[2].slice(0);
  79407. circlePaths[index] = circlePaths[index - 1].slice(0);
  79408. circlePaths[index + 1] = capPath(tessellation, path.length - 1);
  79409. break;
  79410. default:
  79411. break;
  79412. }
  79413. return circlePaths;
  79414. };
  79415. var path3D;
  79416. var pathArray;
  79417. if (instance) { // tube update
  79418. var storage = instance._creationDataStorage;
  79419. var arc = options.arc || storage.arc;
  79420. path3D = storage.path3D.update(path);
  79421. pathArray = tubePathArray(path, path3D, storage.pathArray, radius, storage.tessellation, radiusFunction, storage.cap, arc);
  79422. instance = _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__["RibbonBuilder"].CreateRibbon("", { pathArray: pathArray, instance: instance });
  79423. // Update mode, no need to recreate the storage.
  79424. storage.path3D = path3D;
  79425. storage.pathArray = pathArray;
  79426. storage.arc = arc;
  79427. storage.radius = radius;
  79428. return instance;
  79429. }
  79430. // tube creation
  79431. path3D = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Path3D"](path);
  79432. var newPathArray = new Array();
  79433. cap = (cap < 0 || cap > 3) ? 0 : cap;
  79434. pathArray = tubePathArray(path, path3D, newPathArray, radius, tessellation, radiusFunction, cap, options.arc);
  79435. 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);
  79436. tube._creationDataStorage.pathArray = pathArray;
  79437. tube._creationDataStorage.path3D = path3D;
  79438. tube._creationDataStorage.tessellation = tessellation;
  79439. tube._creationDataStorage.cap = cap;
  79440. tube._creationDataStorage.arc = options.arc;
  79441. tube._creationDataStorage.radius = radius;
  79442. return tube;
  79443. };
  79444. return TubeBuilder;
  79445. }());
  79446. /***/ }),
  79447. /***/ "./Meshes/Compression/dracoCompression.ts":
  79448. /*!************************************************!*\
  79449. !*** ./Meshes/Compression/dracoCompression.ts ***!
  79450. \************************************************/
  79451. /*! exports provided: DracoCompression */
  79452. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79453. "use strict";
  79454. __webpack_require__.r(__webpack_exports__);
  79455. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return DracoCompression; });
  79456. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  79457. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  79458. /**
  79459. * Draco compression (https://google.github.io/draco/)
  79460. *
  79461. * This class wraps the Draco module.
  79462. *
  79463. * **Encoder**
  79464. *
  79465. * The encoder is not currently implemented.
  79466. *
  79467. * **Decoder**
  79468. *
  79469. * 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.
  79470. *
  79471. * To update the configuration, use the following code:
  79472. * ```javascript
  79473. * DracoCompression.Configuration = {
  79474. * decoder: {
  79475. * wasmUrl: "<url to the WebAssembly library>",
  79476. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  79477. * fallbackUrl: "<url to the fallback JavaScript library>",
  79478. * }
  79479. * };
  79480. * ```
  79481. *
  79482. * 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.
  79483. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  79484. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  79485. *
  79486. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  79487. * ```javascript
  79488. * var dracoCompression = new DracoCompression();
  79489. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  79490. * [VertexBuffer.PositionKind]: 0
  79491. * });
  79492. * ```
  79493. *
  79494. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  79495. */
  79496. var DracoCompression = /** @class */ (function () {
  79497. /**
  79498. * Constructor
  79499. */
  79500. function DracoCompression() {
  79501. }
  79502. Object.defineProperty(DracoCompression, "DecoderAvailable", {
  79503. /**
  79504. * Returns true if the decoder is available.
  79505. */
  79506. get: function () {
  79507. if (typeof DracoDecoderModule !== "undefined") {
  79508. return true;
  79509. }
  79510. var decoder = DracoCompression.Configuration.decoder;
  79511. if (decoder) {
  79512. if (decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === "object") {
  79513. return true;
  79514. }
  79515. if (decoder.fallbackUrl) {
  79516. return true;
  79517. }
  79518. }
  79519. return false;
  79520. },
  79521. enumerable: true,
  79522. configurable: true
  79523. });
  79524. /**
  79525. * Stop all async operations and release resources.
  79526. */
  79527. DracoCompression.prototype.dispose = function () {
  79528. };
  79529. /**
  79530. * Decode Draco compressed mesh data to vertex data.
  79531. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  79532. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  79533. * @returns A promise that resolves with the decoded vertex data
  79534. */
  79535. DracoCompression.prototype.decodeMeshAsync = function (data, attributes) {
  79536. var dataView = data instanceof ArrayBuffer ? new Uint8Array(data) : data;
  79537. return DracoCompression._GetDecoderModule().then(function (wrappedModule) {
  79538. var module = wrappedModule.module;
  79539. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  79540. var buffer = new module.DecoderBuffer();
  79541. buffer.Init(dataView, dataView.byteLength);
  79542. var decoder = new module.Decoder();
  79543. var geometry;
  79544. var status;
  79545. try {
  79546. var type = decoder.GetEncodedGeometryType(buffer);
  79547. switch (type) {
  79548. case module.TRIANGULAR_MESH:
  79549. geometry = new module.Mesh();
  79550. status = decoder.DecodeBufferToMesh(buffer, geometry);
  79551. break;
  79552. case module.POINT_CLOUD:
  79553. geometry = new module.PointCloud();
  79554. status = decoder.DecodeBufferToPointCloud(buffer, geometry);
  79555. break;
  79556. default:
  79557. throw new Error("Invalid geometry type " + type);
  79558. }
  79559. if (!status.ok() || !geometry.ptr) {
  79560. throw new Error(status.error_msg());
  79561. }
  79562. var numPoints = geometry.num_points();
  79563. if (type === module.TRIANGULAR_MESH) {
  79564. var numFaces = geometry.num_faces();
  79565. var faceIndices = new module.DracoInt32Array();
  79566. try {
  79567. var indices = new Uint32Array(numFaces * 3);
  79568. for (var i = 0; i < numFaces; i++) {
  79569. decoder.GetFaceFromMesh(geometry, i, faceIndices);
  79570. var offset = i * 3;
  79571. indices[offset + 0] = faceIndices.GetValue(0);
  79572. indices[offset + 1] = faceIndices.GetValue(1);
  79573. indices[offset + 2] = faceIndices.GetValue(2);
  79574. }
  79575. vertexData.indices = indices;
  79576. }
  79577. finally {
  79578. module.destroy(faceIndices);
  79579. }
  79580. }
  79581. for (var kind in attributes) {
  79582. var uniqueId = attributes[kind];
  79583. var attribute = decoder.GetAttributeByUniqueId(geometry, uniqueId);
  79584. var dracoData = new module.DracoFloat32Array();
  79585. try {
  79586. decoder.GetAttributeFloatForAllPoints(geometry, attribute, dracoData);
  79587. var babylonData = new Float32Array(numPoints * attribute.num_components());
  79588. for (var i = 0; i < babylonData.length; i++) {
  79589. babylonData[i] = dracoData.GetValue(i);
  79590. }
  79591. vertexData.set(babylonData, kind);
  79592. }
  79593. finally {
  79594. module.destroy(dracoData);
  79595. }
  79596. }
  79597. }
  79598. finally {
  79599. if (geometry) {
  79600. module.destroy(geometry);
  79601. }
  79602. module.destroy(decoder);
  79603. module.destroy(buffer);
  79604. }
  79605. return vertexData;
  79606. });
  79607. };
  79608. DracoCompression._GetDecoderModule = function () {
  79609. if (!DracoCompression._DecoderModulePromise) {
  79610. var promise = null;
  79611. var config_1 = {};
  79612. if (typeof DracoDecoderModule !== "undefined") {
  79613. promise = Promise.resolve();
  79614. }
  79615. else {
  79616. var decoder = DracoCompression.Configuration.decoder;
  79617. if (decoder) {
  79618. if (decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === "object") {
  79619. promise = Promise.all([
  79620. DracoCompression._LoadScriptAsync(decoder.wasmUrl),
  79621. DracoCompression._LoadFileAsync(decoder.wasmBinaryUrl).then(function (data) {
  79622. config_1.wasmBinary = data;
  79623. })
  79624. ]);
  79625. }
  79626. else if (decoder.fallbackUrl) {
  79627. promise = DracoCompression._LoadScriptAsync(decoder.fallbackUrl);
  79628. }
  79629. }
  79630. }
  79631. if (!promise) {
  79632. throw new Error("Draco decoder module is not available");
  79633. }
  79634. DracoCompression._DecoderModulePromise = promise.then(function () {
  79635. return new Promise(function (resolve) {
  79636. config_1.onModuleLoaded = function (decoderModule) {
  79637. // decoderModule is Promise-like. Wrap before resolving to avoid loop.
  79638. resolve({ module: decoderModule });
  79639. };
  79640. DracoDecoderModule(config_1);
  79641. });
  79642. });
  79643. }
  79644. return DracoCompression._DecoderModulePromise;
  79645. };
  79646. DracoCompression._LoadScriptAsync = function (url) {
  79647. return new Promise(function (resolve, reject) {
  79648. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadScript(url, function () {
  79649. resolve();
  79650. }, function (message) {
  79651. reject(new Error(message));
  79652. });
  79653. });
  79654. };
  79655. DracoCompression._LoadFileAsync = function (url) {
  79656. return new Promise(function (resolve, reject) {
  79657. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(url, function (data) {
  79658. resolve(data);
  79659. }, undefined, undefined, true, function (request, exception) {
  79660. reject(exception);
  79661. });
  79662. });
  79663. };
  79664. /**
  79665. * The configuration. Defaults to the following urls:
  79666. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  79667. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  79668. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  79669. */
  79670. DracoCompression.Configuration = {
  79671. decoder: {
  79672. wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js",
  79673. wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm",
  79674. fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  79675. }
  79676. };
  79677. return DracoCompression;
  79678. }());
  79679. /***/ }),
  79680. /***/ "./Meshes/Compression/index.ts":
  79681. /*!*************************************!*\
  79682. !*** ./Meshes/Compression/index.ts ***!
  79683. \*************************************/
  79684. /*! exports provided: DracoCompression */
  79685. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79686. "use strict";
  79687. __webpack_require__.r(__webpack_exports__);
  79688. /* harmony import */ var _dracoCompression__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./dracoCompression */ "./Meshes/Compression/dracoCompression.ts");
  79689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _dracoCompression__WEBPACK_IMPORTED_MODULE_0__["DracoCompression"]; });
  79690. /***/ }),
  79691. /***/ "./Meshes/abstractMesh.ts":
  79692. /*!********************************!*\
  79693. !*** ./Meshes/abstractMesh.ts ***!
  79694. \********************************/
  79695. /*! exports provided: AbstractMesh */
  79696. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79697. "use strict";
  79698. __webpack_require__.r(__webpack_exports__);
  79699. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return AbstractMesh; });
  79700. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  79701. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  79702. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  79703. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  79704. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  79705. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  79706. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  79707. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  79708. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  79709. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  79710. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  79711. /** @hidden */
  79712. var _FacetDataStorage = /** @class */ (function () {
  79713. function _FacetDataStorage() {
  79714. this.facetNb = 0; // facet number
  79715. this.partitioningSubdivisions = 10; // number of subdivisions per axis in the partioning space
  79716. this.partitioningBBoxRatio = 1.01; // the partioning array space is by default 1% bigger than the bounding box
  79717. this.facetDataEnabled = false; // is the facet data feature enabled on this mesh ?
  79718. this.facetParameters = {}; // keep a reference to the object parameters to avoid memory re-allocation
  79719. this.bbSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(); // bbox size approximated for facet data
  79720. this.subDiv = {
  79721. max: 1,
  79722. X: 1,
  79723. Y: 1,
  79724. Z: 1
  79725. };
  79726. this.facetDepthSort = false; // is the facet depth sort to be computed
  79727. this.facetDepthSortEnabled = false; // is the facet depth sort initialized
  79728. }
  79729. return _FacetDataStorage;
  79730. }());
  79731. /**
  79732. * Class used to store all common mesh properties
  79733. */
  79734. var AbstractMesh = /** @class */ (function (_super) {
  79735. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AbstractMesh, _super);
  79736. // Constructor
  79737. /**
  79738. * Creates a new AbstractMesh
  79739. * @param name defines the name of the mesh
  79740. * @param scene defines the hosting scene
  79741. */
  79742. function AbstractMesh(name, scene) {
  79743. if (scene === void 0) { scene = null; }
  79744. var _this = _super.call(this, name, scene, false) || this;
  79745. _this._facetData = new _FacetDataStorage();
  79746. /**
  79747. * The culling strategy to use to check whether the mesh must be rendered or not.
  79748. * This value can be changed at any time and will be used on the next render mesh selection.
  79749. * The possible values are :
  79750. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  79751. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  79752. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  79753. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  79754. * Please read each static variable documentation to get details about the culling process.
  79755. * */
  79756. _this.cullingStrategy = AbstractMesh.CULLINGSTRATEGY_STANDARD;
  79757. // Events
  79758. /**
  79759. * An event triggered when this mesh collides with another one
  79760. */
  79761. _this.onCollideObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  79762. /**
  79763. * An event triggered when the collision's position changes
  79764. */
  79765. _this.onCollisionPositionChangeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  79766. /**
  79767. * An event triggered when material is changed
  79768. */
  79769. _this.onMaterialChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  79770. // Properties
  79771. /**
  79772. * Gets or sets the orientation for POV movement & rotation
  79773. */
  79774. _this.definedFacingForward = true;
  79775. _this._visibility = 1.0;
  79776. /** Gets or sets the alpha index used to sort transparent meshes
  79777. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  79778. */
  79779. _this.alphaIndex = Number.MAX_VALUE;
  79780. /**
  79781. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  79782. */
  79783. _this.isVisible = true;
  79784. /**
  79785. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  79786. */
  79787. _this.isPickable = true;
  79788. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  79789. _this.showSubMeshesBoundingBox = false;
  79790. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  79791. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  79792. */
  79793. _this.isBlocker = false;
  79794. /**
  79795. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  79796. */
  79797. _this.enablePointerMoveEvents = false;
  79798. /**
  79799. * Specifies the rendering group id for this mesh (0 by default)
  79800. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  79801. */
  79802. _this.renderingGroupId = 0;
  79803. _this._receiveShadows = false;
  79804. /** Defines color to use when rendering outline */
  79805. _this.outlineColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Red();
  79806. /** Define width to use when rendering outline */
  79807. _this.outlineWidth = 0.02;
  79808. /** Defines color to use when rendering overlay */
  79809. _this.overlayColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Red();
  79810. /** Defines alpha to use when rendering overlay */
  79811. _this.overlayAlpha = 0.5;
  79812. _this._hasVertexAlpha = false;
  79813. _this._useVertexColors = true;
  79814. _this._computeBonesUsingShaders = true;
  79815. _this._numBoneInfluencers = 4;
  79816. _this._applyFog = true;
  79817. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  79818. _this.useOctreeForRenderingSelection = true;
  79819. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  79820. _this.useOctreeForPicking = true;
  79821. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  79822. _this.useOctreeForCollisions = true;
  79823. _this._layerMask = 0x0FFFFFFF;
  79824. /**
  79825. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  79826. */
  79827. _this.alwaysSelectAsActiveMesh = false;
  79828. /**
  79829. * Gets or sets the current action manager
  79830. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79831. */
  79832. _this.actionManager = null;
  79833. // Collisions
  79834. _this._checkCollisions = false;
  79835. _this._collisionMask = -1;
  79836. _this._collisionGroup = -1;
  79837. /**
  79838. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  79839. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  79840. */
  79841. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0.5, 1, 0.5);
  79842. /**
  79843. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  79844. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  79845. */
  79846. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  79847. _this._oldPositionForCollisions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  79848. _this._diffPositionForCollisions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  79849. // Edges
  79850. /**
  79851. * Defines edge width used when edgesRenderer is enabled
  79852. * @see https://www.babylonjs-playground.com/#10OJSG#13
  79853. */
  79854. _this.edgesWidth = 1;
  79855. /**
  79856. * Defines edge color used when edgesRenderer is enabled
  79857. * @see https://www.babylonjs-playground.com/#10OJSG#13
  79858. */
  79859. _this.edgesColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](1, 0, 0, 1);
  79860. /** @hidden */
  79861. _this._renderId = 0;
  79862. /** @hidden */
  79863. _this._intersectionsInProgress = new Array();
  79864. /** @hidden */
  79865. _this._unIndexed = false;
  79866. /** @hidden */
  79867. _this._lightSources = new Array();
  79868. /**
  79869. * An event triggered when the mesh is rebuilt.
  79870. */
  79871. _this.onRebuildObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  79872. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  79873. if (collidedMesh === void 0) { collidedMesh = null; }
  79874. newPosition.subtractToRef(_this._oldPositionForCollisions, _this._diffPositionForCollisions);
  79875. if (_this._diffPositionForCollisions.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].CollisionsEpsilon) {
  79876. _this.position.addInPlace(_this._diffPositionForCollisions);
  79877. }
  79878. if (collidedMesh) {
  79879. _this.onCollideObservable.notifyObservers(collidedMesh);
  79880. }
  79881. _this.onCollisionPositionChangeObservable.notifyObservers(_this.position);
  79882. };
  79883. _this.getScene().addMesh(_this);
  79884. _this._resyncLightSources();
  79885. return _this;
  79886. }
  79887. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_NONE", {
  79888. /**
  79889. * No billboard
  79890. */
  79891. get: function () {
  79892. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_NONE;
  79893. },
  79894. enumerable: true,
  79895. configurable: true
  79896. });
  79897. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_X", {
  79898. /** Billboard on X axis */
  79899. get: function () {
  79900. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_X;
  79901. },
  79902. enumerable: true,
  79903. configurable: true
  79904. });
  79905. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_Y", {
  79906. /** Billboard on Y axis */
  79907. get: function () {
  79908. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_Y;
  79909. },
  79910. enumerable: true,
  79911. configurable: true
  79912. });
  79913. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_Z", {
  79914. /** Billboard on Z axis */
  79915. get: function () {
  79916. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_Z;
  79917. },
  79918. enumerable: true,
  79919. configurable: true
  79920. });
  79921. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_ALL", {
  79922. /** Billboard on all axes */
  79923. get: function () {
  79924. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_ALL;
  79925. },
  79926. enumerable: true,
  79927. configurable: true
  79928. });
  79929. Object.defineProperty(AbstractMesh.prototype, "facetNb", {
  79930. /**
  79931. * Gets the number of facets in the mesh
  79932. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  79933. */
  79934. get: function () {
  79935. return this._facetData.facetNb;
  79936. },
  79937. enumerable: true,
  79938. configurable: true
  79939. });
  79940. Object.defineProperty(AbstractMesh.prototype, "partitioningSubdivisions", {
  79941. /**
  79942. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  79943. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  79944. */
  79945. get: function () {
  79946. return this._facetData.partitioningSubdivisions;
  79947. },
  79948. set: function (nb) {
  79949. this._facetData.partitioningSubdivisions = nb;
  79950. },
  79951. enumerable: true,
  79952. configurable: true
  79953. });
  79954. Object.defineProperty(AbstractMesh.prototype, "partitioningBBoxRatio", {
  79955. /**
  79956. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  79957. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  79958. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  79959. */
  79960. get: function () {
  79961. return this._facetData.partitioningBBoxRatio;
  79962. },
  79963. set: function (ratio) {
  79964. this._facetData.partitioningBBoxRatio = ratio;
  79965. },
  79966. enumerable: true,
  79967. configurable: true
  79968. });
  79969. Object.defineProperty(AbstractMesh.prototype, "mustDepthSortFacets", {
  79970. /**
  79971. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  79972. * Works only for updatable meshes.
  79973. * Doesn't work with multi-materials
  79974. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  79975. */
  79976. get: function () {
  79977. return this._facetData.facetDepthSort;
  79978. },
  79979. set: function (sort) {
  79980. this._facetData.facetDepthSort = sort;
  79981. },
  79982. enumerable: true,
  79983. configurable: true
  79984. });
  79985. Object.defineProperty(AbstractMesh.prototype, "facetDepthSortFrom", {
  79986. /**
  79987. * The location (Vector3) where the facet depth sort must be computed from.
  79988. * By default, the active camera position.
  79989. * Used only when facet depth sort is enabled
  79990. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  79991. */
  79992. get: function () {
  79993. return this._facetData.facetDepthSortFrom;
  79994. },
  79995. set: function (location) {
  79996. this._facetData.facetDepthSortFrom = location;
  79997. },
  79998. enumerable: true,
  79999. configurable: true
  80000. });
  80001. Object.defineProperty(AbstractMesh.prototype, "isFacetDataEnabled", {
  80002. /**
  80003. * gets a boolean indicating if facetData is enabled
  80004. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  80005. */
  80006. get: function () {
  80007. return this._facetData.facetDataEnabled;
  80008. },
  80009. enumerable: true,
  80010. configurable: true
  80011. });
  80012. /** @hidden */
  80013. AbstractMesh.prototype._updateNonUniformScalingState = function (value) {
  80014. if (!_super.prototype._updateNonUniformScalingState.call(this, value)) {
  80015. return false;
  80016. }
  80017. this._markSubMeshesAsMiscDirty();
  80018. return true;
  80019. };
  80020. Object.defineProperty(AbstractMesh.prototype, "onCollide", {
  80021. /** Set a function to call when this mesh collides with another one */
  80022. set: function (callback) {
  80023. if (this._onCollideObserver) {
  80024. this.onCollideObservable.remove(this._onCollideObserver);
  80025. }
  80026. this._onCollideObserver = this.onCollideObservable.add(callback);
  80027. },
  80028. enumerable: true,
  80029. configurable: true
  80030. });
  80031. Object.defineProperty(AbstractMesh.prototype, "onCollisionPositionChange", {
  80032. /** Set a function to call when the collision's position changes */
  80033. set: function (callback) {
  80034. if (this._onCollisionPositionChangeObserver) {
  80035. this.onCollisionPositionChangeObservable.remove(this._onCollisionPositionChangeObserver);
  80036. }
  80037. this._onCollisionPositionChangeObserver = this.onCollisionPositionChangeObservable.add(callback);
  80038. },
  80039. enumerable: true,
  80040. configurable: true
  80041. });
  80042. Object.defineProperty(AbstractMesh.prototype, "visibility", {
  80043. /**
  80044. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  80045. */
  80046. get: function () {
  80047. return this._visibility;
  80048. },
  80049. /**
  80050. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  80051. */
  80052. set: function (value) {
  80053. if (this._visibility === value) {
  80054. return;
  80055. }
  80056. this._visibility = value;
  80057. this._markSubMeshesAsMiscDirty();
  80058. },
  80059. enumerable: true,
  80060. configurable: true
  80061. });
  80062. Object.defineProperty(AbstractMesh.prototype, "material", {
  80063. /** Gets or sets current material */
  80064. get: function () {
  80065. return this._material;
  80066. },
  80067. set: function (value) {
  80068. if (this._material === value) {
  80069. return;
  80070. }
  80071. // remove from material mesh map id needed
  80072. if (this._material && this._material.meshMap) {
  80073. this._material.meshMap[this.uniqueId] = undefined;
  80074. }
  80075. this._material = value;
  80076. if (value && value.meshMap) {
  80077. value.meshMap[this.uniqueId] = this;
  80078. }
  80079. if (this.onMaterialChangedObservable.hasObservers) {
  80080. this.onMaterialChangedObservable.notifyObservers(this);
  80081. }
  80082. if (!this.subMeshes) {
  80083. return;
  80084. }
  80085. this._unBindEffect();
  80086. },
  80087. enumerable: true,
  80088. configurable: true
  80089. });
  80090. Object.defineProperty(AbstractMesh.prototype, "receiveShadows", {
  80091. /**
  80092. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  80093. * @see http://doc.babylonjs.com/babylon101/shadows
  80094. */
  80095. get: function () {
  80096. return this._receiveShadows;
  80097. },
  80098. set: function (value) {
  80099. if (this._receiveShadows === value) {
  80100. return;
  80101. }
  80102. this._receiveShadows = value;
  80103. this._markSubMeshesAsLightDirty();
  80104. },
  80105. enumerable: true,
  80106. configurable: true
  80107. });
  80108. Object.defineProperty(AbstractMesh.prototype, "hasVertexAlpha", {
  80109. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  80110. get: function () {
  80111. return this._hasVertexAlpha;
  80112. },
  80113. set: function (value) {
  80114. if (this._hasVertexAlpha === value) {
  80115. return;
  80116. }
  80117. this._hasVertexAlpha = value;
  80118. this._markSubMeshesAsAttributesDirty();
  80119. this._markSubMeshesAsMiscDirty();
  80120. },
  80121. enumerable: true,
  80122. configurable: true
  80123. });
  80124. Object.defineProperty(AbstractMesh.prototype, "useVertexColors", {
  80125. /** 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) */
  80126. get: function () {
  80127. return this._useVertexColors;
  80128. },
  80129. set: function (value) {
  80130. if (this._useVertexColors === value) {
  80131. return;
  80132. }
  80133. this._useVertexColors = value;
  80134. this._markSubMeshesAsAttributesDirty();
  80135. },
  80136. enumerable: true,
  80137. configurable: true
  80138. });
  80139. Object.defineProperty(AbstractMesh.prototype, "computeBonesUsingShaders", {
  80140. /**
  80141. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  80142. */
  80143. get: function () {
  80144. return this._computeBonesUsingShaders;
  80145. },
  80146. set: function (value) {
  80147. if (this._computeBonesUsingShaders === value) {
  80148. return;
  80149. }
  80150. this._computeBonesUsingShaders = value;
  80151. this._markSubMeshesAsAttributesDirty();
  80152. },
  80153. enumerable: true,
  80154. configurable: true
  80155. });
  80156. Object.defineProperty(AbstractMesh.prototype, "numBoneInfluencers", {
  80157. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  80158. get: function () {
  80159. return this._numBoneInfluencers;
  80160. },
  80161. set: function (value) {
  80162. if (this._numBoneInfluencers === value) {
  80163. return;
  80164. }
  80165. this._numBoneInfluencers = value;
  80166. this._markSubMeshesAsAttributesDirty();
  80167. },
  80168. enumerable: true,
  80169. configurable: true
  80170. });
  80171. Object.defineProperty(AbstractMesh.prototype, "applyFog", {
  80172. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  80173. get: function () {
  80174. return this._applyFog;
  80175. },
  80176. set: function (value) {
  80177. if (this._applyFog === value) {
  80178. return;
  80179. }
  80180. this._applyFog = value;
  80181. this._markSubMeshesAsMiscDirty();
  80182. },
  80183. enumerable: true,
  80184. configurable: true
  80185. });
  80186. Object.defineProperty(AbstractMesh.prototype, "layerMask", {
  80187. /**
  80188. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  80189. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  80190. */
  80191. get: function () {
  80192. return this._layerMask;
  80193. },
  80194. set: function (value) {
  80195. if (value === this._layerMask) {
  80196. return;
  80197. }
  80198. this._layerMask = value;
  80199. this._resyncLightSources();
  80200. },
  80201. enumerable: true,
  80202. configurable: true
  80203. });
  80204. Object.defineProperty(AbstractMesh.prototype, "collisionMask", {
  80205. /**
  80206. * Gets or sets a collision mask used to mask collisions (default is -1).
  80207. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  80208. */
  80209. get: function () {
  80210. return this._collisionMask;
  80211. },
  80212. set: function (mask) {
  80213. this._collisionMask = !isNaN(mask) ? mask : -1;
  80214. },
  80215. enumerable: true,
  80216. configurable: true
  80217. });
  80218. Object.defineProperty(AbstractMesh.prototype, "collisionGroup", {
  80219. /**
  80220. * Gets or sets the current collision group mask (-1 by default).
  80221. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  80222. */
  80223. get: function () {
  80224. return this._collisionGroup;
  80225. },
  80226. set: function (mask) {
  80227. this._collisionGroup = !isNaN(mask) ? mask : -1;
  80228. },
  80229. enumerable: true,
  80230. configurable: true
  80231. });
  80232. Object.defineProperty(AbstractMesh.prototype, "_positions", {
  80233. /** @hidden */
  80234. get: function () {
  80235. return null;
  80236. },
  80237. enumerable: true,
  80238. configurable: true
  80239. });
  80240. Object.defineProperty(AbstractMesh.prototype, "skeleton", {
  80241. get: function () {
  80242. return this._skeleton;
  80243. },
  80244. /**
  80245. * Gets or sets a skeleton to apply skining transformations
  80246. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  80247. */
  80248. set: function (value) {
  80249. if (this._skeleton && this._skeleton.needInitialSkinMatrix) {
  80250. this._skeleton._unregisterMeshWithPoseMatrix(this);
  80251. }
  80252. if (value && value.needInitialSkinMatrix) {
  80253. value._registerMeshWithPoseMatrix(this);
  80254. }
  80255. this._skeleton = value;
  80256. if (!this._skeleton) {
  80257. this._bonesTransformMatrices = null;
  80258. }
  80259. this._markSubMeshesAsAttributesDirty();
  80260. },
  80261. enumerable: true,
  80262. configurable: true
  80263. });
  80264. /**
  80265. * Returns the string "AbstractMesh"
  80266. * @returns "AbstractMesh"
  80267. */
  80268. AbstractMesh.prototype.getClassName = function () {
  80269. return "AbstractMesh";
  80270. };
  80271. /**
  80272. * Gets a string representation of the current mesh
  80273. * @param fullDetails defines a boolean indicating if full details must be included
  80274. * @returns a string representation of the current mesh
  80275. */
  80276. AbstractMesh.prototype.toString = function (fullDetails) {
  80277. var ret = "Name: " + this.name + ", isInstance: " + (this.getClassName() !== "InstancedMesh" ? "YES" : "NO");
  80278. ret += ", # of submeshes: " + (this.subMeshes ? this.subMeshes.length : 0);
  80279. if (this._skeleton) {
  80280. ret += ", skeleton: " + this._skeleton.name;
  80281. }
  80282. if (fullDetails) {
  80283. ret += ", billboard mode: " + (["NONE", "X", "Y", null, "Z", null, null, "ALL"])[this.billboardMode];
  80284. ret += ", freeze wrld mat: " + (this._isWorldMatrixFrozen || this._waitingFreezeWorldMatrix ? "YES" : "NO");
  80285. }
  80286. return ret;
  80287. };
  80288. /** @hidden */
  80289. AbstractMesh.prototype._getActionManagerForTrigger = function (trigger, initialCall) {
  80290. if (initialCall === void 0) { initialCall = true; }
  80291. if (this.actionManager && (initialCall || this.actionManager.isRecursive)) {
  80292. if (trigger) {
  80293. if (this.actionManager.hasSpecificTrigger(trigger)) {
  80294. return this.actionManager;
  80295. }
  80296. }
  80297. else {
  80298. return this.actionManager;
  80299. }
  80300. }
  80301. if (!this.parent) {
  80302. return null;
  80303. }
  80304. return this.parent._getActionManagerForTrigger(trigger, false);
  80305. };
  80306. /** @hidden */
  80307. AbstractMesh.prototype._rebuild = function () {
  80308. this.onRebuildObservable.notifyObservers(this);
  80309. if (this._occlusionQuery) {
  80310. this._occlusionQuery = null;
  80311. }
  80312. if (!this.subMeshes) {
  80313. return;
  80314. }
  80315. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  80316. var subMesh = _a[_i];
  80317. subMesh._rebuild();
  80318. }
  80319. };
  80320. /** @hidden */
  80321. AbstractMesh.prototype._resyncLightSources = function () {
  80322. this._lightSources.length = 0;
  80323. for (var _i = 0, _a = this.getScene().lights; _i < _a.length; _i++) {
  80324. var light = _a[_i];
  80325. if (!light.isEnabled()) {
  80326. continue;
  80327. }
  80328. if (light.canAffectMesh(this)) {
  80329. this._lightSources.push(light);
  80330. }
  80331. }
  80332. this._markSubMeshesAsLightDirty();
  80333. };
  80334. /** @hidden */
  80335. AbstractMesh.prototype._resyncLighSource = function (light) {
  80336. var isIn = light.isEnabled() && light.canAffectMesh(this);
  80337. var index = this._lightSources.indexOf(light);
  80338. if (index === -1) {
  80339. if (!isIn) {
  80340. return;
  80341. }
  80342. this._lightSources.push(light);
  80343. }
  80344. else {
  80345. if (isIn) {
  80346. return;
  80347. }
  80348. this._lightSources.splice(index, 1);
  80349. }
  80350. this._markSubMeshesAsLightDirty();
  80351. };
  80352. /** @hidden */
  80353. AbstractMesh.prototype._unBindEffect = function () {
  80354. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  80355. var subMesh = _a[_i];
  80356. subMesh.setEffect(null);
  80357. }
  80358. };
  80359. /** @hidden */
  80360. AbstractMesh.prototype._removeLightSource = function (light) {
  80361. var index = this._lightSources.indexOf(light);
  80362. if (index === -1) {
  80363. return;
  80364. }
  80365. this._lightSources.splice(index, 1);
  80366. this._markSubMeshesAsLightDirty();
  80367. };
  80368. AbstractMesh.prototype._markSubMeshesAsDirty = function (func) {
  80369. if (!this.subMeshes) {
  80370. return;
  80371. }
  80372. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  80373. var subMesh = _a[_i];
  80374. if (subMesh._materialDefines) {
  80375. func(subMesh._materialDefines);
  80376. }
  80377. }
  80378. };
  80379. /** @hidden */
  80380. AbstractMesh.prototype._markSubMeshesAsLightDirty = function () {
  80381. this._markSubMeshesAsDirty(function (defines) { return defines.markAsLightDirty(); });
  80382. };
  80383. /** @hidden */
  80384. AbstractMesh.prototype._markSubMeshesAsAttributesDirty = function () {
  80385. this._markSubMeshesAsDirty(function (defines) { return defines.markAsAttributesDirty(); });
  80386. };
  80387. /** @hidden */
  80388. AbstractMesh.prototype._markSubMeshesAsMiscDirty = function () {
  80389. if (!this.subMeshes) {
  80390. return;
  80391. }
  80392. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  80393. var subMesh = _a[_i];
  80394. var material = subMesh.getMaterial();
  80395. if (material) {
  80396. material.markAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MATERIAL_MiscDirtyFlag);
  80397. }
  80398. }
  80399. };
  80400. Object.defineProperty(AbstractMesh.prototype, "scaling", {
  80401. /**
  80402. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  80403. */
  80404. get: function () {
  80405. return this._scaling;
  80406. },
  80407. set: function (newScaling) {
  80408. this._scaling = newScaling;
  80409. if (this.physicsImpostor) {
  80410. this.physicsImpostor.forceUpdate();
  80411. }
  80412. },
  80413. enumerable: true,
  80414. configurable: true
  80415. });
  80416. Object.defineProperty(AbstractMesh.prototype, "isBlocked", {
  80417. // Methods
  80418. /**
  80419. * Returns true if the mesh is blocked. Implemented by child classes
  80420. */
  80421. get: function () {
  80422. return false;
  80423. },
  80424. enumerable: true,
  80425. configurable: true
  80426. });
  80427. /**
  80428. * Returns the mesh itself by default. Implemented by child classes
  80429. * @param camera defines the camera to use to pick the right LOD level
  80430. * @returns the currentAbstractMesh
  80431. */
  80432. AbstractMesh.prototype.getLOD = function (camera) {
  80433. return this;
  80434. };
  80435. /**
  80436. * Returns 0 by default. Implemented by child classes
  80437. * @returns an integer
  80438. */
  80439. AbstractMesh.prototype.getTotalVertices = function () {
  80440. return 0;
  80441. };
  80442. /**
  80443. * Returns a positive integer : the total number of indices in this mesh geometry.
  80444. * @returns the numner of indices or zero if the mesh has no geometry.
  80445. */
  80446. AbstractMesh.prototype.getTotalIndices = function () {
  80447. return 0;
  80448. };
  80449. /**
  80450. * Returns null by default. Implemented by child classes
  80451. * @returns null
  80452. */
  80453. AbstractMesh.prototype.getIndices = function () {
  80454. return null;
  80455. };
  80456. /**
  80457. * Returns the array of the requested vertex data kind. Implemented by child classes
  80458. * @param kind defines the vertex data kind to use
  80459. * @returns null
  80460. */
  80461. AbstractMesh.prototype.getVerticesData = function (kind) {
  80462. return null;
  80463. };
  80464. /**
  80465. * Sets the vertex data of the mesh geometry for the requested `kind`.
  80466. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  80467. * Note that a new underlying VertexBuffer object is created each call.
  80468. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  80469. * @param kind defines vertex data kind:
  80470. * * VertexBuffer.PositionKind
  80471. * * VertexBuffer.UVKind
  80472. * * VertexBuffer.UV2Kind
  80473. * * VertexBuffer.UV3Kind
  80474. * * VertexBuffer.UV4Kind
  80475. * * VertexBuffer.UV5Kind
  80476. * * VertexBuffer.UV6Kind
  80477. * * VertexBuffer.ColorKind
  80478. * * VertexBuffer.MatricesIndicesKind
  80479. * * VertexBuffer.MatricesIndicesExtraKind
  80480. * * VertexBuffer.MatricesWeightsKind
  80481. * * VertexBuffer.MatricesWeightsExtraKind
  80482. * @param data defines the data source
  80483. * @param updatable defines if the data must be flagged as updatable (or static)
  80484. * @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
  80485. * @returns the current mesh
  80486. */
  80487. AbstractMesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  80488. return this;
  80489. };
  80490. /**
  80491. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  80492. * If the mesh has no geometry, it is simply returned as it is.
  80493. * @param kind defines vertex data kind:
  80494. * * VertexBuffer.PositionKind
  80495. * * VertexBuffer.UVKind
  80496. * * VertexBuffer.UV2Kind
  80497. * * VertexBuffer.UV3Kind
  80498. * * VertexBuffer.UV4Kind
  80499. * * VertexBuffer.UV5Kind
  80500. * * VertexBuffer.UV6Kind
  80501. * * VertexBuffer.ColorKind
  80502. * * VertexBuffer.MatricesIndicesKind
  80503. * * VertexBuffer.MatricesIndicesExtraKind
  80504. * * VertexBuffer.MatricesWeightsKind
  80505. * * VertexBuffer.MatricesWeightsExtraKind
  80506. * @param data defines the data source
  80507. * @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
  80508. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  80509. * @returns the current mesh
  80510. */
  80511. AbstractMesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  80512. return this;
  80513. };
  80514. /**
  80515. * Sets the mesh indices,
  80516. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  80517. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  80518. * @param totalVertices Defines the total number of vertices
  80519. * @returns the current mesh
  80520. */
  80521. AbstractMesh.prototype.setIndices = function (indices, totalVertices) {
  80522. return this;
  80523. };
  80524. /**
  80525. * Gets a boolean indicating if specific vertex data is present
  80526. * @param kind defines the vertex data kind to use
  80527. * @returns true is data kind is present
  80528. */
  80529. AbstractMesh.prototype.isVerticesDataPresent = function (kind) {
  80530. return false;
  80531. };
  80532. /**
  80533. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  80534. * @returns a BoundingInfo
  80535. */
  80536. AbstractMesh.prototype.getBoundingInfo = function () {
  80537. if (this._masterMesh) {
  80538. return this._masterMesh.getBoundingInfo();
  80539. }
  80540. if (!this._boundingInfo) {
  80541. // this._boundingInfo is being created here
  80542. this._updateBoundingInfo();
  80543. }
  80544. // cannot be null.
  80545. return this._boundingInfo;
  80546. };
  80547. /**
  80548. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  80549. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  80550. * @returns the current mesh
  80551. */
  80552. AbstractMesh.prototype.normalizeToUnitCube = function (includeDescendants) {
  80553. if (includeDescendants === void 0) { includeDescendants = true; }
  80554. var boundingVectors = this.getHierarchyBoundingVectors(includeDescendants);
  80555. var sizeVec = boundingVectors.max.subtract(boundingVectors.min);
  80556. var maxDimension = Math.max(sizeVec.x, sizeVec.y, sizeVec.z);
  80557. if (maxDimension === 0) {
  80558. return this;
  80559. }
  80560. var scale = 1 / maxDimension;
  80561. this.scaling.scaleInPlace(scale);
  80562. return this;
  80563. };
  80564. /**
  80565. * Overwrite the current bounding info
  80566. * @param boundingInfo defines the new bounding info
  80567. * @returns the current mesh
  80568. */
  80569. AbstractMesh.prototype.setBoundingInfo = function (boundingInfo) {
  80570. this._boundingInfo = boundingInfo;
  80571. return this;
  80572. };
  80573. Object.defineProperty(AbstractMesh.prototype, "useBones", {
  80574. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  80575. get: function () {
  80576. 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));
  80577. },
  80578. enumerable: true,
  80579. configurable: true
  80580. });
  80581. /** @hidden */
  80582. AbstractMesh.prototype._preActivate = function () {
  80583. };
  80584. /** @hidden */
  80585. AbstractMesh.prototype._preActivateForIntermediateRendering = function (renderId) {
  80586. };
  80587. /** @hidden */
  80588. AbstractMesh.prototype._activate = function (renderId) {
  80589. this._renderId = renderId;
  80590. };
  80591. /**
  80592. * Gets the current world matrix
  80593. * @returns a Matrix
  80594. */
  80595. AbstractMesh.prototype.getWorldMatrix = function () {
  80596. if (this._masterMesh) {
  80597. return this._masterMesh.getWorldMatrix();
  80598. }
  80599. return _super.prototype.getWorldMatrix.call(this);
  80600. };
  80601. /** @hidden */
  80602. AbstractMesh.prototype._getWorldMatrixDeterminant = function () {
  80603. if (this._masterMesh) {
  80604. return this._masterMesh._getWorldMatrixDeterminant();
  80605. }
  80606. return _super.prototype._getWorldMatrixDeterminant.call(this);
  80607. };
  80608. // ================================== Point of View Movement =================================
  80609. /**
  80610. * Perform relative position change from the point of view of behind the front of the mesh.
  80611. * This is performed taking into account the meshes current rotation, so you do not have to care.
  80612. * Supports definition of mesh facing forward or backward
  80613. * @param amountRight defines the distance on the right axis
  80614. * @param amountUp defines the distance on the up axis
  80615. * @param amountForward defines the distance on the forward axis
  80616. * @returns the current mesh
  80617. */
  80618. AbstractMesh.prototype.movePOV = function (amountRight, amountUp, amountForward) {
  80619. this.position.addInPlace(this.calcMovePOV(amountRight, amountUp, amountForward));
  80620. return this;
  80621. };
  80622. /**
  80623. * Calculate relative position change from the point of view of behind the front of the mesh.
  80624. * This is performed taking into account the meshes current rotation, so you do not have to care.
  80625. * Supports definition of mesh facing forward or backward
  80626. * @param amountRight defines the distance on the right axis
  80627. * @param amountUp defines the distance on the up axis
  80628. * @param amountForward defines the distance on the forward axis
  80629. * @returns the new displacement vector
  80630. */
  80631. AbstractMesh.prototype.calcMovePOV = function (amountRight, amountUp, amountForward) {
  80632. var rotMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  80633. var rotQuaternion = (this.rotationQuaternion) ? this.rotationQuaternion : _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
  80634. rotQuaternion.toRotationMatrix(rotMatrix);
  80635. var translationDelta = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  80636. var defForwardMult = this.definedFacingForward ? -1 : 1;
  80637. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(amountRight * defForwardMult, amountUp, amountForward * defForwardMult, rotMatrix, translationDelta);
  80638. return translationDelta;
  80639. };
  80640. // ================================== Point of View Rotation =================================
  80641. /**
  80642. * Perform relative rotation change from the point of view of behind the front of the mesh.
  80643. * Supports definition of mesh facing forward or backward
  80644. * @param flipBack defines the flip
  80645. * @param twirlClockwise defines the twirl
  80646. * @param tiltRight defines the tilt
  80647. * @returns the current mesh
  80648. */
  80649. AbstractMesh.prototype.rotatePOV = function (flipBack, twirlClockwise, tiltRight) {
  80650. this.rotation.addInPlace(this.calcRotatePOV(flipBack, twirlClockwise, tiltRight));
  80651. return this;
  80652. };
  80653. /**
  80654. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  80655. * Supports definition of mesh facing forward or backward.
  80656. * @param flipBack defines the flip
  80657. * @param twirlClockwise defines the twirl
  80658. * @param tiltRight defines the tilt
  80659. * @returns the new rotation vector
  80660. */
  80661. AbstractMesh.prototype.calcRotatePOV = function (flipBack, twirlClockwise, tiltRight) {
  80662. var defForwardMult = this.definedFacingForward ? 1 : -1;
  80663. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](flipBack * defForwardMult, twirlClockwise, tiltRight * defForwardMult);
  80664. };
  80665. /**
  80666. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  80667. * @param includeDescendants Include bounding info from descendants as well (true by default)
  80668. * @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
  80669. * @returns the new bounding vectors
  80670. */
  80671. AbstractMesh.prototype.getHierarchyBoundingVectors = function (includeDescendants, predicate) {
  80672. if (includeDescendants === void 0) { includeDescendants = true; }
  80673. if (predicate === void 0) { predicate = null; }
  80674. // Ensures that all world matrix will be recomputed.
  80675. this.getScene().incrementRenderId();
  80676. this.computeWorldMatrix(true);
  80677. var min;
  80678. var max;
  80679. var boundingInfo = this.getBoundingInfo();
  80680. if (!this.subMeshes) {
  80681. min = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  80682. max = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  80683. }
  80684. else {
  80685. min = boundingInfo.boundingBox.minimumWorld;
  80686. max = boundingInfo.boundingBox.maximumWorld;
  80687. }
  80688. if (includeDescendants) {
  80689. var descendants = this.getDescendants(false);
  80690. for (var _i = 0, descendants_1 = descendants; _i < descendants_1.length; _i++) {
  80691. var descendant = descendants_1[_i];
  80692. var childMesh = descendant;
  80693. childMesh.computeWorldMatrix(true);
  80694. // Filters meshes based on custom predicate function.
  80695. if (predicate && !predicate(childMesh)) {
  80696. continue;
  80697. }
  80698. //make sure we have the needed params to get mix and max
  80699. if (!childMesh.getBoundingInfo || childMesh.getTotalVertices() === 0) {
  80700. continue;
  80701. }
  80702. var childBoundingInfo = childMesh.getBoundingInfo();
  80703. var boundingBox = childBoundingInfo.boundingBox;
  80704. var minBox = boundingBox.minimumWorld;
  80705. var maxBox = boundingBox.maximumWorld;
  80706. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(minBox, min, max);
  80707. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(maxBox, min, max);
  80708. }
  80709. }
  80710. return {
  80711. min: min,
  80712. max: max
  80713. };
  80714. };
  80715. /**
  80716. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  80717. * This means the mesh underlying bounding box and sphere are recomputed.
  80718. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  80719. * @returns the current mesh
  80720. */
  80721. AbstractMesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  80722. if (applySkeleton === void 0) { applySkeleton = false; }
  80723. if (this._boundingInfo && this._boundingInfo.isLocked) {
  80724. return this;
  80725. }
  80726. this._refreshBoundingInfo(this._getPositionData(applySkeleton), null);
  80727. return this;
  80728. };
  80729. /** @hidden */
  80730. AbstractMesh.prototype._refreshBoundingInfo = function (data, bias) {
  80731. if (data) {
  80732. var extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].ExtractMinAndMax(data, 0, this.getTotalVertices(), bias);
  80733. if (this._boundingInfo) {
  80734. this._boundingInfo.reConstruct(extend.minimum, extend.maximum);
  80735. }
  80736. else {
  80737. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"](extend.minimum, extend.maximum);
  80738. }
  80739. }
  80740. if (this.subMeshes) {
  80741. for (var index = 0; index < this.subMeshes.length; index++) {
  80742. this.subMeshes[index].refreshBoundingInfo();
  80743. }
  80744. }
  80745. this._updateBoundingInfo();
  80746. };
  80747. /** @hidden */
  80748. AbstractMesh.prototype._getPositionData = function (applySkeleton) {
  80749. var data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  80750. if (data && applySkeleton && this.skeleton) {
  80751. data = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Slice(data);
  80752. var matricesIndicesData = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesIndicesKind);
  80753. var matricesWeightsData = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesWeightsKind);
  80754. if (matricesWeightsData && matricesIndicesData) {
  80755. var needExtras = this.numBoneInfluencers > 4;
  80756. var matricesIndicesExtraData = needExtras ? this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesIndicesExtraKind) : null;
  80757. var matricesWeightsExtraData = needExtras ? this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesWeightsExtraKind) : null;
  80758. var skeletonMatrices = this.skeleton.getTransformMatrices(this);
  80759. var tempVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  80760. var finalMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  80761. var tempMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  80762. var matWeightIdx = 0;
  80763. for (var index = 0; index < data.length; index += 3, matWeightIdx += 4) {
  80764. finalMatrix.reset();
  80765. var inf;
  80766. var weight;
  80767. for (inf = 0; inf < 4; inf++) {
  80768. weight = matricesWeightsData[matWeightIdx + inf];
  80769. if (weight > 0) {
  80770. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[matWeightIdx + inf] * 16), weight, tempMatrix);
  80771. finalMatrix.addToSelf(tempMatrix);
  80772. }
  80773. }
  80774. if (needExtras) {
  80775. for (inf = 0; inf < 4; inf++) {
  80776. weight = matricesWeightsExtraData[matWeightIdx + inf];
  80777. if (weight > 0) {
  80778. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[matWeightIdx + inf] * 16), weight, tempMatrix);
  80779. finalMatrix.addToSelf(tempMatrix);
  80780. }
  80781. }
  80782. }
  80783. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(data[index], data[index + 1], data[index + 2], finalMatrix, tempVector);
  80784. tempVector.toArray(data, index);
  80785. }
  80786. }
  80787. }
  80788. return data;
  80789. };
  80790. /** @hidden */
  80791. AbstractMesh.prototype._updateBoundingInfo = function () {
  80792. var effectiveMesh = (this.skeleton && this.skeleton.overrideMesh) || this;
  80793. if (this._boundingInfo) {
  80794. this._boundingInfo.update(effectiveMesh.worldMatrixFromCache);
  80795. }
  80796. else {
  80797. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"](this.absolutePosition, this.absolutePosition, effectiveMesh.worldMatrixFromCache);
  80798. }
  80799. this._updateSubMeshesBoundingInfo(effectiveMesh.worldMatrixFromCache);
  80800. return this;
  80801. };
  80802. /** @hidden */
  80803. AbstractMesh.prototype._updateSubMeshesBoundingInfo = function (matrix) {
  80804. if (!this.subMeshes) {
  80805. return this;
  80806. }
  80807. var count = this.subMeshes.length;
  80808. for (var subIndex = 0; subIndex < count; subIndex++) {
  80809. var subMesh = this.subMeshes[subIndex];
  80810. if (count > 1 || !subMesh.IsGlobal) {
  80811. subMesh.updateBoundingInfo(matrix);
  80812. }
  80813. }
  80814. return this;
  80815. };
  80816. /** @hidden */
  80817. AbstractMesh.prototype._afterComputeWorldMatrix = function () {
  80818. // Bounding info
  80819. this._updateBoundingInfo();
  80820. };
  80821. /**
  80822. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  80823. * A mesh is in the frustum if its bounding box intersects the frustum
  80824. * @param frustumPlanes defines the frustum to test
  80825. * @returns true if the mesh is in the frustum planes
  80826. */
  80827. AbstractMesh.prototype.isInFrustum = function (frustumPlanes) {
  80828. return this._boundingInfo !== null && this._boundingInfo.isInFrustum(frustumPlanes, this.cullingStrategy);
  80829. };
  80830. /**
  80831. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  80832. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  80833. * @param frustumPlanes defines the frustum to test
  80834. * @returns true if the mesh is completely in the frustum planes
  80835. */
  80836. AbstractMesh.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  80837. return this._boundingInfo !== null && this._boundingInfo.isCompletelyInFrustum(frustumPlanes);
  80838. };
  80839. /**
  80840. * True if the mesh intersects another mesh or a SolidParticle object
  80841. * @param mesh defines a target mesh or SolidParticle to test
  80842. * @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)
  80843. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  80844. * @returns true if there is an intersection
  80845. */
  80846. AbstractMesh.prototype.intersectsMesh = function (mesh, precise, includeDescendants) {
  80847. if (precise === void 0) { precise = false; }
  80848. if (!this._boundingInfo || !mesh._boundingInfo) {
  80849. return false;
  80850. }
  80851. if (this._boundingInfo.intersects(mesh._boundingInfo, precise)) {
  80852. return true;
  80853. }
  80854. if (includeDescendants) {
  80855. for (var _i = 0, _a = this.getChildMeshes(); _i < _a.length; _i++) {
  80856. var child = _a[_i];
  80857. if (child.intersectsMesh(mesh, precise, true)) {
  80858. return true;
  80859. }
  80860. }
  80861. }
  80862. return false;
  80863. };
  80864. /**
  80865. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  80866. * @param point defines the point to test
  80867. * @returns true if there is an intersection
  80868. */
  80869. AbstractMesh.prototype.intersectsPoint = function (point) {
  80870. if (!this._boundingInfo) {
  80871. return false;
  80872. }
  80873. return this._boundingInfo.intersectsPoint(point);
  80874. };
  80875. Object.defineProperty(AbstractMesh.prototype, "checkCollisions", {
  80876. // Collisions
  80877. /**
  80878. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  80879. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80880. */
  80881. get: function () {
  80882. return this._checkCollisions;
  80883. },
  80884. set: function (collisionEnabled) {
  80885. this._checkCollisions = collisionEnabled;
  80886. },
  80887. enumerable: true,
  80888. configurable: true
  80889. });
  80890. Object.defineProperty(AbstractMesh.prototype, "collider", {
  80891. /**
  80892. * Gets Collider object used to compute collisions (not physics)
  80893. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80894. */
  80895. get: function () {
  80896. return this._collider;
  80897. },
  80898. enumerable: true,
  80899. configurable: true
  80900. });
  80901. /**
  80902. * Move the mesh using collision engine
  80903. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80904. * @param displacement defines the requested displacement vector
  80905. * @returns the current mesh
  80906. */
  80907. AbstractMesh.prototype.moveWithCollisions = function (displacement) {
  80908. var globalPosition = this.getAbsolutePosition();
  80909. globalPosition.addToRef(this.ellipsoidOffset, this._oldPositionForCollisions);
  80910. var coordinator = this.getScene().collisionCoordinator;
  80911. if (!this._collider) {
  80912. this._collider = coordinator.createCollider();
  80913. }
  80914. this._collider._radius = this.ellipsoid;
  80915. coordinator.getNewPosition(this._oldPositionForCollisions, displacement, this._collider, 3, this, this._onCollisionPositionChange, this.uniqueId);
  80916. return this;
  80917. };
  80918. // Collisions
  80919. /** @hidden */
  80920. AbstractMesh.prototype._collideForSubMesh = function (subMesh, transformMatrix, collider) {
  80921. this._generatePointsArray();
  80922. if (!this._positions) {
  80923. return this;
  80924. }
  80925. // Transformation
  80926. if (!subMesh._lastColliderWorldVertices || !subMesh._lastColliderTransformMatrix.equals(transformMatrix)) {
  80927. subMesh._lastColliderTransformMatrix = transformMatrix.clone();
  80928. subMesh._lastColliderWorldVertices = [];
  80929. subMesh._trianglePlanes = [];
  80930. var start = subMesh.verticesStart;
  80931. var end = (subMesh.verticesStart + subMesh.verticesCount);
  80932. for (var i = start; i < end; i++) {
  80933. subMesh._lastColliderWorldVertices.push(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(this._positions[i], transformMatrix));
  80934. }
  80935. }
  80936. // Collide
  80937. collider._collide(subMesh._trianglePlanes, subMesh._lastColliderWorldVertices, this.getIndices(), subMesh.indexStart, subMesh.indexStart + subMesh.indexCount, subMesh.verticesStart, !!subMesh.getMaterial());
  80938. if (collider.collisionFound) {
  80939. collider.collidedMesh = this;
  80940. }
  80941. return this;
  80942. };
  80943. /** @hidden */
  80944. AbstractMesh.prototype._processCollisionsForSubMeshes = function (collider, transformMatrix) {
  80945. var subMeshes = this._scene.getCollidingSubMeshCandidates(this, collider);
  80946. var len = subMeshes.length;
  80947. for (var index = 0; index < len; index++) {
  80948. var subMesh = subMeshes.data[index];
  80949. // Bounding test
  80950. if (len > 1 && !subMesh._checkCollision(collider)) {
  80951. continue;
  80952. }
  80953. this._collideForSubMesh(subMesh, transformMatrix, collider);
  80954. }
  80955. return this;
  80956. };
  80957. /** @hidden */
  80958. AbstractMesh.prototype._checkCollision = function (collider) {
  80959. // Bounding box test
  80960. if (!this._boundingInfo || !this._boundingInfo._checkCollision(collider)) {
  80961. return this;
  80962. }
  80963. // Transformation matrix
  80964. var collisionsScalingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  80965. var collisionsTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  80966. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].ScalingToRef(1.0 / collider._radius.x, 1.0 / collider._radius.y, 1.0 / collider._radius.z, collisionsScalingMatrix);
  80967. this.worldMatrixFromCache.multiplyToRef(collisionsScalingMatrix, collisionsTransformMatrix);
  80968. this._processCollisionsForSubMeshes(collider, collisionsTransformMatrix);
  80969. return this;
  80970. };
  80971. // Picking
  80972. /** @hidden */
  80973. AbstractMesh.prototype._generatePointsArray = function () {
  80974. return false;
  80975. };
  80976. /**
  80977. * Checks if the passed Ray intersects with the mesh
  80978. * @param ray defines the ray to use
  80979. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  80980. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  80981. * @returns the picking info
  80982. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80983. */
  80984. AbstractMesh.prototype.intersects = function (ray, fastCheck, trianglePredicate) {
  80985. var pickingInfo = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_8__["PickingInfo"]();
  80986. var intersectionThreshold = this.getClassName() === "InstancedLinesMesh" || this.getClassName() === "LinesMesh" ? this.intersectionThreshold : 0;
  80987. var boundingInfo = this._boundingInfo;
  80988. if (!this.subMeshes || !boundingInfo || !ray.intersectsSphere(boundingInfo.boundingSphere, intersectionThreshold) || !ray.intersectsBox(boundingInfo.boundingBox, intersectionThreshold)) {
  80989. return pickingInfo;
  80990. }
  80991. if (!this._generatePointsArray()) {
  80992. return pickingInfo;
  80993. }
  80994. var intersectInfo = null;
  80995. var subMeshes = this._scene.getIntersectingSubMeshCandidates(this, ray);
  80996. var len = subMeshes.length;
  80997. for (var index = 0; index < len; index++) {
  80998. var subMesh = subMeshes.data[index];
  80999. // Bounding test
  81000. if (len > 1 && !subMesh.canIntersects(ray)) {
  81001. continue;
  81002. }
  81003. var currentIntersectInfo = subMesh.intersects(ray, this._positions, this.getIndices(), fastCheck, trianglePredicate);
  81004. if (currentIntersectInfo) {
  81005. if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
  81006. intersectInfo = currentIntersectInfo;
  81007. intersectInfo.subMeshId = index;
  81008. if (fastCheck) {
  81009. break;
  81010. }
  81011. }
  81012. }
  81013. }
  81014. if (intersectInfo) {
  81015. // Get picked point
  81016. var world = this.getWorldMatrix();
  81017. var worldOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  81018. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  81019. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(ray.origin, world, worldOrigin);
  81020. ray.direction.scaleToRef(intersectInfo.distance, direction);
  81021. var worldDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(direction, world);
  81022. var pickedPoint = worldDirection.addInPlace(worldOrigin);
  81023. // Return result
  81024. pickingInfo.hit = true;
  81025. pickingInfo.distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(worldOrigin, pickedPoint);
  81026. pickingInfo.pickedPoint = pickedPoint;
  81027. pickingInfo.pickedMesh = this;
  81028. pickingInfo.bu = intersectInfo.bu || 0;
  81029. pickingInfo.bv = intersectInfo.bv || 0;
  81030. pickingInfo.faceId = intersectInfo.faceId;
  81031. pickingInfo.subMeshId = intersectInfo.subMeshId;
  81032. return pickingInfo;
  81033. }
  81034. return pickingInfo;
  81035. };
  81036. /**
  81037. * Clones the current mesh
  81038. * @param name defines the mesh name
  81039. * @param newParent defines the new mesh parent
  81040. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  81041. * @returns the new mesh
  81042. */
  81043. AbstractMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  81044. return null;
  81045. };
  81046. /**
  81047. * Disposes all the submeshes of the current meshnp
  81048. * @returns the current mesh
  81049. */
  81050. AbstractMesh.prototype.releaseSubMeshes = function () {
  81051. if (this.subMeshes) {
  81052. while (this.subMeshes.length) {
  81053. this.subMeshes[0].dispose();
  81054. }
  81055. }
  81056. else {
  81057. this.subMeshes = new Array();
  81058. }
  81059. return this;
  81060. };
  81061. /**
  81062. * Releases resources associated with this abstract mesh.
  81063. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81064. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81065. */
  81066. AbstractMesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  81067. var _this = this;
  81068. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  81069. var index;
  81070. // Smart Array Retainers.
  81071. this.getScene().freeActiveMeshes();
  81072. this.getScene().freeRenderingGroups();
  81073. // Action manager
  81074. if (this.actionManager !== undefined && this.actionManager !== null) {
  81075. this.actionManager.dispose();
  81076. this.actionManager = null;
  81077. }
  81078. // Skeleton
  81079. this._skeleton = null;
  81080. // Intersections in progress
  81081. for (index = 0; index < this._intersectionsInProgress.length; index++) {
  81082. var other = this._intersectionsInProgress[index];
  81083. var pos = other._intersectionsInProgress.indexOf(this);
  81084. other._intersectionsInProgress.splice(pos, 1);
  81085. }
  81086. this._intersectionsInProgress = [];
  81087. // Lights
  81088. var lights = this.getScene().lights;
  81089. lights.forEach(function (light) {
  81090. var meshIndex = light.includedOnlyMeshes.indexOf(_this);
  81091. if (meshIndex !== -1) {
  81092. light.includedOnlyMeshes.splice(meshIndex, 1);
  81093. }
  81094. meshIndex = light.excludedMeshes.indexOf(_this);
  81095. if (meshIndex !== -1) {
  81096. light.excludedMeshes.splice(meshIndex, 1);
  81097. }
  81098. // Shadow generators
  81099. var generator = light.getShadowGenerator();
  81100. if (generator) {
  81101. var shadowMap = generator.getShadowMap();
  81102. if (shadowMap && shadowMap.renderList) {
  81103. meshIndex = shadowMap.renderList.indexOf(_this);
  81104. if (meshIndex !== -1) {
  81105. shadowMap.renderList.splice(meshIndex, 1);
  81106. }
  81107. }
  81108. }
  81109. });
  81110. // SubMeshes
  81111. if (this.getClassName() !== "InstancedMesh" || this.getClassName() !== "InstancedLinesMesh") {
  81112. this.releaseSubMeshes();
  81113. }
  81114. // Query
  81115. var engine = this.getScene().getEngine();
  81116. if (this._occlusionQuery) {
  81117. this.isOcclusionQueryInProgress = false;
  81118. engine.deleteQuery(this._occlusionQuery);
  81119. this._occlusionQuery = null;
  81120. }
  81121. // Engine
  81122. engine.wipeCaches();
  81123. // Remove from scene
  81124. this.getScene().removeMesh(this);
  81125. if (disposeMaterialAndTextures) {
  81126. if (this.material) {
  81127. if (this.material.getClassName() === "MultiMaterial") {
  81128. this.material.dispose(false, true, true);
  81129. }
  81130. else {
  81131. this.material.dispose(false, true);
  81132. }
  81133. }
  81134. }
  81135. if (!doNotRecurse) {
  81136. // Particles
  81137. for (index = 0; index < this.getScene().particleSystems.length; index++) {
  81138. if (this.getScene().particleSystems[index].emitter === this) {
  81139. this.getScene().particleSystems[index].dispose();
  81140. index--;
  81141. }
  81142. }
  81143. }
  81144. // facet data
  81145. if (this._facetData.facetDataEnabled) {
  81146. this.disableFacetData();
  81147. }
  81148. this.onAfterWorldMatrixUpdateObservable.clear();
  81149. this.onCollideObservable.clear();
  81150. this.onCollisionPositionChangeObservable.clear();
  81151. this.onRebuildObservable.clear();
  81152. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  81153. };
  81154. /**
  81155. * Adds the passed mesh as a child to the current mesh
  81156. * @param mesh defines the child mesh
  81157. * @returns the current mesh
  81158. */
  81159. AbstractMesh.prototype.addChild = function (mesh) {
  81160. mesh.setParent(this);
  81161. return this;
  81162. };
  81163. /**
  81164. * Removes the passed mesh from the current mesh children list
  81165. * @param mesh defines the child mesh
  81166. * @returns the current mesh
  81167. */
  81168. AbstractMesh.prototype.removeChild = function (mesh) {
  81169. mesh.setParent(null);
  81170. return this;
  81171. };
  81172. // Facet data
  81173. /** @hidden */
  81174. AbstractMesh.prototype._initFacetData = function () {
  81175. var data = this._facetData;
  81176. if (!data.facetNormals) {
  81177. data.facetNormals = new Array();
  81178. }
  81179. if (!data.facetPositions) {
  81180. data.facetPositions = new Array();
  81181. }
  81182. if (!data.facetPartitioning) {
  81183. data.facetPartitioning = new Array();
  81184. }
  81185. data.facetNb = (this.getIndices().length / 3) | 0;
  81186. data.partitioningSubdivisions = (data.partitioningSubdivisions) ? data.partitioningSubdivisions : 10; // default nb of partitioning subdivisions = 10
  81187. data.partitioningBBoxRatio = (data.partitioningBBoxRatio) ? data.partitioningBBoxRatio : 1.01; // default ratio 1.01 = the partitioning is 1% bigger than the bounding box
  81188. for (var f = 0; f < data.facetNb; f++) {
  81189. data.facetNormals[f] = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  81190. data.facetPositions[f] = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  81191. }
  81192. data.facetDataEnabled = true;
  81193. return this;
  81194. };
  81195. /**
  81196. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  81197. * This method can be called within the render loop.
  81198. * 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
  81199. * @returns the current mesh
  81200. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81201. */
  81202. AbstractMesh.prototype.updateFacetData = function () {
  81203. var data = this._facetData;
  81204. if (!data.facetDataEnabled) {
  81205. this._initFacetData();
  81206. }
  81207. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  81208. var indices = this.getIndices();
  81209. var normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  81210. var bInfo = this.getBoundingInfo();
  81211. if (data.facetDepthSort && !data.facetDepthSortEnabled) {
  81212. // init arrays, matrix and sort function on first call
  81213. data.facetDepthSortEnabled = true;
  81214. if (indices instanceof Uint16Array) {
  81215. data.depthSortedIndices = new Uint16Array(indices);
  81216. }
  81217. else if (indices instanceof Uint32Array) {
  81218. data.depthSortedIndices = new Uint32Array(indices);
  81219. }
  81220. else {
  81221. var needs32bits = false;
  81222. for (var i = 0; i < indices.length; i++) {
  81223. if (indices[i] > 65535) {
  81224. needs32bits = true;
  81225. break;
  81226. }
  81227. }
  81228. if (needs32bits) {
  81229. data.depthSortedIndices = new Uint32Array(indices);
  81230. }
  81231. else {
  81232. data.depthSortedIndices = new Uint16Array(indices);
  81233. }
  81234. }
  81235. data.facetDepthSortFunction = function (f1, f2) {
  81236. return (f2.sqDistance - f1.sqDistance);
  81237. };
  81238. if (!data.facetDepthSortFrom) {
  81239. var camera = this.getScene().activeCamera;
  81240. data.facetDepthSortFrom = (camera) ? camera.position : _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  81241. }
  81242. data.depthSortedFacets = [];
  81243. for (var f = 0; f < data.facetNb; f++) {
  81244. var depthSortedFacet = { ind: f * 3, sqDistance: 0.0 };
  81245. data.depthSortedFacets.push(depthSortedFacet);
  81246. }
  81247. data.invertedMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  81248. data.facetDepthSortOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  81249. }
  81250. 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"];
  81251. 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"];
  81252. 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"];
  81253. var bbSizeMax = (data.bbSize.x > data.bbSize.y) ? data.bbSize.x : data.bbSize.y;
  81254. bbSizeMax = (bbSizeMax > data.bbSize.z) ? bbSizeMax : data.bbSize.z;
  81255. data.subDiv.max = data.partitioningSubdivisions;
  81256. data.subDiv.X = Math.floor(data.subDiv.max * data.bbSize.x / bbSizeMax); // adjust the number of subdivisions per axis
  81257. data.subDiv.Y = Math.floor(data.subDiv.max * data.bbSize.y / bbSizeMax); // according to each bbox size per axis
  81258. data.subDiv.Z = Math.floor(data.subDiv.max * data.bbSize.z / bbSizeMax);
  81259. data.subDiv.X = data.subDiv.X < 1 ? 1 : data.subDiv.X; // at least one subdivision
  81260. data.subDiv.Y = data.subDiv.Y < 1 ? 1 : data.subDiv.Y;
  81261. data.subDiv.Z = data.subDiv.Z < 1 ? 1 : data.subDiv.Z;
  81262. // set the parameters for ComputeNormals()
  81263. data.facetParameters.facetNormals = this.getFacetLocalNormals();
  81264. data.facetParameters.facetPositions = this.getFacetLocalPositions();
  81265. data.facetParameters.facetPartitioning = this.getFacetLocalPartitioning();
  81266. data.facetParameters.bInfo = bInfo;
  81267. data.facetParameters.bbSize = data.bbSize;
  81268. data.facetParameters.subDiv = data.subDiv;
  81269. data.facetParameters.ratio = this.partitioningBBoxRatio;
  81270. data.facetParameters.depthSort = data.facetDepthSort;
  81271. if (data.facetDepthSort && data.facetDepthSortEnabled) {
  81272. this.computeWorldMatrix(true);
  81273. this._worldMatrix.invertToRef(data.invertedMatrix);
  81274. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(data.facetDepthSortFrom, data.invertedMatrix, data.facetDepthSortOrigin);
  81275. data.facetParameters.distanceTo = data.facetDepthSortOrigin;
  81276. }
  81277. data.facetParameters.depthSortedFacets = data.depthSortedFacets;
  81278. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].ComputeNormals(positions, indices, normals, data.facetParameters);
  81279. if (data.facetDepthSort && data.facetDepthSortEnabled) {
  81280. data.depthSortedFacets.sort(data.facetDepthSortFunction);
  81281. var l = (data.depthSortedIndices.length / 3) | 0;
  81282. for (var f = 0; f < l; f++) {
  81283. var sind = data.depthSortedFacets[f].ind;
  81284. data.depthSortedIndices[f * 3] = indices[sind];
  81285. data.depthSortedIndices[f * 3 + 1] = indices[sind + 1];
  81286. data.depthSortedIndices[f * 3 + 2] = indices[sind + 2];
  81287. }
  81288. this.updateIndices(data.depthSortedIndices);
  81289. }
  81290. return this;
  81291. };
  81292. /**
  81293. * Returns the facetLocalNormals array.
  81294. * The normals are expressed in the mesh local spac
  81295. * @returns an array of Vector3
  81296. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81297. */
  81298. AbstractMesh.prototype.getFacetLocalNormals = function () {
  81299. if (!this._facetData.facetNormals) {
  81300. this.updateFacetData();
  81301. }
  81302. return this._facetData.facetNormals;
  81303. };
  81304. /**
  81305. * Returns the facetLocalPositions array.
  81306. * The facet positions are expressed in the mesh local space
  81307. * @returns an array of Vector3
  81308. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81309. */
  81310. AbstractMesh.prototype.getFacetLocalPositions = function () {
  81311. if (!this._facetData.facetPositions) {
  81312. this.updateFacetData();
  81313. }
  81314. return this._facetData.facetPositions;
  81315. };
  81316. /**
  81317. * Returns the facetLocalPartioning array
  81318. * @returns an array of array of numbers
  81319. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81320. */
  81321. AbstractMesh.prototype.getFacetLocalPartitioning = function () {
  81322. if (!this._facetData.facetPartitioning) {
  81323. this.updateFacetData();
  81324. }
  81325. return this._facetData.facetPartitioning;
  81326. };
  81327. /**
  81328. * Returns the i-th facet position in the world system.
  81329. * This method allocates a new Vector3 per call
  81330. * @param i defines the facet index
  81331. * @returns a new Vector3
  81332. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81333. */
  81334. AbstractMesh.prototype.getFacetPosition = function (i) {
  81335. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  81336. this.getFacetPositionToRef(i, pos);
  81337. return pos;
  81338. };
  81339. /**
  81340. * Sets the reference Vector3 with the i-th facet position in the world system
  81341. * @param i defines the facet index
  81342. * @param ref defines the target vector
  81343. * @returns the current mesh
  81344. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81345. */
  81346. AbstractMesh.prototype.getFacetPositionToRef = function (i, ref) {
  81347. var localPos = (this.getFacetLocalPositions())[i];
  81348. var world = this.getWorldMatrix();
  81349. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(localPos, world, ref);
  81350. return this;
  81351. };
  81352. /**
  81353. * Returns the i-th facet normal in the world system.
  81354. * This method allocates a new Vector3 per call
  81355. * @param i defines the facet index
  81356. * @returns a new Vector3
  81357. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81358. */
  81359. AbstractMesh.prototype.getFacetNormal = function (i) {
  81360. var norm = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  81361. this.getFacetNormalToRef(i, norm);
  81362. return norm;
  81363. };
  81364. /**
  81365. * Sets the reference Vector3 with the i-th facet normal in the world system
  81366. * @param i defines the facet index
  81367. * @param ref defines the target vector
  81368. * @returns the current mesh
  81369. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81370. */
  81371. AbstractMesh.prototype.getFacetNormalToRef = function (i, ref) {
  81372. var localNorm = (this.getFacetLocalNormals())[i];
  81373. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(localNorm, this.getWorldMatrix(), ref);
  81374. return this;
  81375. };
  81376. /**
  81377. * 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)
  81378. * @param x defines x coordinate
  81379. * @param y defines y coordinate
  81380. * @param z defines z coordinate
  81381. * @returns the array of facet indexes
  81382. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81383. */
  81384. AbstractMesh.prototype.getFacetsAtLocalCoordinates = function (x, y, z) {
  81385. var bInfo = this.getBoundingInfo();
  81386. var data = this._facetData;
  81387. var ox = Math.floor((x - bInfo.minimum.x * data.partitioningBBoxRatio) * data.subDiv.X * data.partitioningBBoxRatio / data.bbSize.x);
  81388. var oy = Math.floor((y - bInfo.minimum.y * data.partitioningBBoxRatio) * data.subDiv.Y * data.partitioningBBoxRatio / data.bbSize.y);
  81389. var oz = Math.floor((z - bInfo.minimum.z * data.partitioningBBoxRatio) * data.subDiv.Z * data.partitioningBBoxRatio / data.bbSize.z);
  81390. if (ox < 0 || ox > data.subDiv.max || oy < 0 || oy > data.subDiv.max || oz < 0 || oz > data.subDiv.max) {
  81391. return null;
  81392. }
  81393. return data.facetPartitioning[ox + data.subDiv.max * oy + data.subDiv.max * data.subDiv.max * oz];
  81394. };
  81395. /**
  81396. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  81397. * @param projected sets as the (x,y,z) world projection on the facet
  81398. * @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
  81399. * @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
  81400. * @param x defines x coordinate
  81401. * @param y defines y coordinate
  81402. * @param z defines z coordinate
  81403. * @returns the face index if found (or null instead)
  81404. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81405. */
  81406. AbstractMesh.prototype.getClosestFacetAtCoordinates = function (x, y, z, projected, checkFace, facing) {
  81407. if (checkFace === void 0) { checkFace = false; }
  81408. if (facing === void 0) { facing = true; }
  81409. var world = this.getWorldMatrix();
  81410. var invMat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5];
  81411. world.invertToRef(invMat);
  81412. var invVect = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[8];
  81413. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(x, y, z, invMat, invVect); // transform (x,y,z) to coordinates in the mesh local space
  81414. var closest = this.getClosestFacetAtLocalCoordinates(invVect.x, invVect.y, invVect.z, projected, checkFace, facing);
  81415. if (projected) {
  81416. // tranform the local computed projected vector to world coordinates
  81417. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(projected.x, projected.y, projected.z, world, projected);
  81418. }
  81419. return closest;
  81420. };
  81421. /**
  81422. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  81423. * @param projected sets as the (x,y,z) local projection on the facet
  81424. * @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
  81425. * @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
  81426. * @param x defines x coordinate
  81427. * @param y defines y coordinate
  81428. * @param z defines z coordinate
  81429. * @returns the face index if found (or null instead)
  81430. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81431. */
  81432. AbstractMesh.prototype.getClosestFacetAtLocalCoordinates = function (x, y, z, projected, checkFace, facing) {
  81433. if (checkFace === void 0) { checkFace = false; }
  81434. if (facing === void 0) { facing = true; }
  81435. var closest = null;
  81436. var tmpx = 0.0;
  81437. var tmpy = 0.0;
  81438. var tmpz = 0.0;
  81439. var d = 0.0; // tmp dot facet normal * facet position
  81440. var t0 = 0.0;
  81441. var projx = 0.0;
  81442. var projy = 0.0;
  81443. var projz = 0.0;
  81444. // Get all the facets in the same partitioning block than (x, y, z)
  81445. var facetPositions = this.getFacetLocalPositions();
  81446. var facetNormals = this.getFacetLocalNormals();
  81447. var facetsInBlock = this.getFacetsAtLocalCoordinates(x, y, z);
  81448. if (!facetsInBlock) {
  81449. return null;
  81450. }
  81451. // Get the closest facet to (x, y, z)
  81452. var shortest = Number.MAX_VALUE; // init distance vars
  81453. var tmpDistance = shortest;
  81454. var fib; // current facet in the block
  81455. var norm; // current facet normal
  81456. var p0; // current facet barycenter position
  81457. // loop on all the facets in the current partitioning block
  81458. for (var idx = 0; idx < facetsInBlock.length; idx++) {
  81459. fib = facetsInBlock[idx];
  81460. norm = facetNormals[fib];
  81461. p0 = facetPositions[fib];
  81462. d = (x - p0.x) * norm.x + (y - p0.y) * norm.y + (z - p0.z) * norm.z;
  81463. if (!checkFace || (checkFace && facing && d >= 0.0) || (checkFace && !facing && d <= 0.0)) {
  81464. // compute (x,y,z) projection on the facet = (projx, projy, projz)
  81465. d = norm.x * p0.x + norm.y * p0.y + norm.z * p0.z;
  81466. t0 = -(norm.x * x + norm.y * y + norm.z * z - d) / (norm.x * norm.x + norm.y * norm.y + norm.z * norm.z);
  81467. projx = x + norm.x * t0;
  81468. projy = y + norm.y * t0;
  81469. projz = z + norm.z * t0;
  81470. tmpx = projx - x;
  81471. tmpy = projy - y;
  81472. tmpz = projz - z;
  81473. tmpDistance = tmpx * tmpx + tmpy * tmpy + tmpz * tmpz; // compute length between (x, y, z) and its projection on the facet
  81474. if (tmpDistance < shortest) { // just keep the closest facet to (x, y, z)
  81475. shortest = tmpDistance;
  81476. closest = fib;
  81477. if (projected) {
  81478. projected.x = projx;
  81479. projected.y = projy;
  81480. projected.z = projz;
  81481. }
  81482. }
  81483. }
  81484. }
  81485. return closest;
  81486. };
  81487. /**
  81488. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  81489. * @returns the parameters
  81490. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81491. */
  81492. AbstractMesh.prototype.getFacetDataParameters = function () {
  81493. return this._facetData.facetParameters;
  81494. };
  81495. /**
  81496. * Disables the feature FacetData and frees the related memory
  81497. * @returns the current mesh
  81498. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81499. */
  81500. AbstractMesh.prototype.disableFacetData = function () {
  81501. if (this._facetData.facetDataEnabled) {
  81502. this._facetData.facetDataEnabled = false;
  81503. this._facetData.facetPositions = new Array();
  81504. this._facetData.facetNormals = new Array();
  81505. this._facetData.facetPartitioning = new Array();
  81506. this._facetData.facetParameters = null;
  81507. this._facetData.depthSortedIndices = new Uint32Array(0);
  81508. }
  81509. return this;
  81510. };
  81511. /**
  81512. * Updates the AbstractMesh indices array
  81513. * @param indices defines the data source
  81514. * @returns the current mesh
  81515. */
  81516. AbstractMesh.prototype.updateIndices = function (indices) {
  81517. return this;
  81518. };
  81519. /**
  81520. * Creates new normals data for the mesh
  81521. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  81522. * @returns the current mesh
  81523. */
  81524. AbstractMesh.prototype.createNormals = function (updatable) {
  81525. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  81526. var indices = this.getIndices();
  81527. var normals;
  81528. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind)) {
  81529. normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  81530. }
  81531. else {
  81532. normals = [];
  81533. }
  81534. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].ComputeNormals(positions, indices, normals, { useRightHandedSystem: this.getScene().useRightHandedSystem });
  81535. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind, normals, updatable);
  81536. return this;
  81537. };
  81538. /**
  81539. * Align the mesh with a normal
  81540. * @param normal defines the normal to use
  81541. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  81542. * @returns the current mesh
  81543. */
  81544. AbstractMesh.prototype.alignWithNormal = function (normal, upDirection) {
  81545. if (!upDirection) {
  81546. upDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y;
  81547. }
  81548. var axisX = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  81549. var axisZ = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  81550. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(upDirection, normal, axisZ);
  81551. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(normal, axisZ, axisX);
  81552. if (this.rotationQuaternion) {
  81553. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationQuaternionFromAxisToRef(axisX, normal, axisZ, this.rotationQuaternion);
  81554. }
  81555. else {
  81556. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].RotationFromAxisToRef(axisX, normal, axisZ, this.rotation);
  81557. }
  81558. return this;
  81559. };
  81560. /** @hidden */
  81561. AbstractMesh.prototype._checkOcclusionQuery = function () {
  81562. return false;
  81563. };
  81564. /** No occlusion */
  81565. AbstractMesh.OCCLUSION_TYPE_NONE = 0;
  81566. /** Occlusion set to optimisitic */
  81567. AbstractMesh.OCCLUSION_TYPE_OPTIMISTIC = 1;
  81568. /** Occlusion set to strict */
  81569. AbstractMesh.OCCLUSION_TYPE_STRICT = 2;
  81570. /** Use an accurante occlusion algorithm */
  81571. AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE = 0;
  81572. /** Use a conservative occlusion algorithm */
  81573. AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE = 1;
  81574. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  81575. * Test order :
  81576. * Is the bounding sphere outside the frustum ?
  81577. * If not, are the bounding box vertices outside the frustum ?
  81578. * It not, then the cullable object is in the frustum.
  81579. */
  81580. AbstractMesh.CULLINGSTRATEGY_STANDARD = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_STANDARD;
  81581. /** Culling strategy : Bounding Sphere Only.
  81582. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  81583. * It's also less accurate than the standard because some not visible objects can still be selected.
  81584. * Test : is the bounding sphere outside the frustum ?
  81585. * If not, then the cullable object is in the frustum.
  81586. */
  81587. AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY;
  81588. /** Culling strategy : Optimistic Inclusion.
  81589. * This in an inclusion test first, then the standard exclusion test.
  81590. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  81591. * 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.
  81592. * Anyway, it's as accurate as the standard strategy.
  81593. * Test :
  81594. * Is the cullable object bounding sphere center in the frustum ?
  81595. * If not, apply the default culling strategy.
  81596. */
  81597. AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION;
  81598. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  81599. * This in an inclusion test first, then the bounding sphere only exclusion test.
  81600. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  81601. * 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.
  81602. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  81603. * Test :
  81604. * Is the cullable object bounding sphere center in the frustum ?
  81605. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  81606. */
  81607. AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY;
  81608. return AbstractMesh;
  81609. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"]));
  81610. /***/ }),
  81611. /***/ "./Meshes/buffer.ts":
  81612. /*!**************************!*\
  81613. !*** ./Meshes/buffer.ts ***!
  81614. \**************************/
  81615. /*! exports provided: Buffer, VertexBuffer */
  81616. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  81617. "use strict";
  81618. __webpack_require__.r(__webpack_exports__);
  81619. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return Buffer; });
  81620. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return VertexBuffer; });
  81621. /**
  81622. * Class used to store data that will be store in GPU memory
  81623. */
  81624. var Buffer = /** @class */ (function () {
  81625. /**
  81626. * Constructor
  81627. * @param engine the engine
  81628. * @param data the data to use for this buffer
  81629. * @param updatable whether the data is updatable
  81630. * @param stride the stride (optional)
  81631. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  81632. * @param instanced whether the buffer is instanced (optional)
  81633. * @param useBytes set to true if the stride in in bytes (optional)
  81634. */
  81635. function Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes) {
  81636. if (stride === void 0) { stride = 0; }
  81637. if (postponeInternalCreation === void 0) { postponeInternalCreation = false; }
  81638. if (instanced === void 0) { instanced = false; }
  81639. if (useBytes === void 0) { useBytes = false; }
  81640. if (engine.getScene) { // old versions of VertexBuffer accepted 'mesh' instead of 'engine'
  81641. this._engine = engine.getScene().getEngine();
  81642. }
  81643. else {
  81644. this._engine = engine;
  81645. }
  81646. this._updatable = updatable;
  81647. this._instanced = instanced;
  81648. this._data = data;
  81649. this.byteStride = useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT;
  81650. if (!postponeInternalCreation) { // by default
  81651. this.create();
  81652. }
  81653. }
  81654. /**
  81655. * Create a new VertexBuffer based on the current buffer
  81656. * @param kind defines the vertex buffer kind (position, normal, etc.)
  81657. * @param offset defines offset in the buffer (0 by default)
  81658. * @param size defines the size in floats of attributes (position is 3 for instance)
  81659. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  81660. * @param instanced defines if the vertex buffer contains indexed data
  81661. * @param useBytes defines if the offset and stride are in bytes
  81662. * @returns the new vertex buffer
  81663. */
  81664. Buffer.prototype.createVertexBuffer = function (kind, offset, size, stride, instanced, useBytes) {
  81665. if (useBytes === void 0) { useBytes = false; }
  81666. var byteOffset = useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT;
  81667. var byteStride = stride ? (useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT) : this.byteStride;
  81668. // a lot of these parameters are ignored as they are overriden by the buffer
  81669. return new VertexBuffer(this._engine, this, kind, this._updatable, true, byteStride, instanced === undefined ? this._instanced : instanced, byteOffset, size, undefined, undefined, true);
  81670. };
  81671. // Properties
  81672. /**
  81673. * Gets a boolean indicating if the Buffer is updatable?
  81674. * @returns true if the buffer is updatable
  81675. */
  81676. Buffer.prototype.isUpdatable = function () {
  81677. return this._updatable;
  81678. };
  81679. /**
  81680. * Gets current buffer's data
  81681. * @returns a DataArray or null
  81682. */
  81683. Buffer.prototype.getData = function () {
  81684. return this._data;
  81685. };
  81686. /**
  81687. * Gets underlying native buffer
  81688. * @returns underlying native buffer
  81689. */
  81690. Buffer.prototype.getBuffer = function () {
  81691. return this._buffer;
  81692. };
  81693. /**
  81694. * Gets the stride in float32 units (i.e. byte stride / 4).
  81695. * May not be an integer if the byte stride is not divisible by 4.
  81696. * DEPRECATED. Use byteStride instead.
  81697. * @returns the stride in float32 units
  81698. */
  81699. Buffer.prototype.getStrideSize = function () {
  81700. return this.byteStride / Float32Array.BYTES_PER_ELEMENT;
  81701. };
  81702. // Methods
  81703. /**
  81704. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  81705. * @param data defines the data to store
  81706. */
  81707. Buffer.prototype.create = function (data) {
  81708. if (data === void 0) { data = null; }
  81709. if (!data && this._buffer) {
  81710. return; // nothing to do
  81711. }
  81712. data = data || this._data;
  81713. if (!data) {
  81714. return;
  81715. }
  81716. if (!this._buffer) { // create buffer
  81717. if (this._updatable) {
  81718. this._buffer = this._engine.createDynamicVertexBuffer(data);
  81719. this._data = data;
  81720. }
  81721. else {
  81722. this._buffer = this._engine.createVertexBuffer(data);
  81723. }
  81724. }
  81725. else if (this._updatable) { // update buffer
  81726. this._engine.updateDynamicVertexBuffer(this._buffer, data);
  81727. this._data = data;
  81728. }
  81729. };
  81730. /** @hidden */
  81731. Buffer.prototype._rebuild = function () {
  81732. this._buffer = null;
  81733. this.create(this._data);
  81734. };
  81735. /**
  81736. * Update current buffer data
  81737. * @param data defines the data to store
  81738. */
  81739. Buffer.prototype.update = function (data) {
  81740. this.create(data);
  81741. };
  81742. /**
  81743. * Updates the data directly.
  81744. * @param data the new data
  81745. * @param offset the new offset
  81746. * @param vertexCount the vertex count (optional)
  81747. * @param useBytes set to true if the offset is in bytes
  81748. */
  81749. Buffer.prototype.updateDirectly = function (data, offset, vertexCount, useBytes) {
  81750. if (useBytes === void 0) { useBytes = false; }
  81751. if (!this._buffer) {
  81752. return;
  81753. }
  81754. if (this._updatable) { // update buffer
  81755. this._engine.updateDynamicVertexBuffer(this._buffer, data, useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT, (vertexCount ? vertexCount * this.byteStride : undefined));
  81756. this._data = null;
  81757. }
  81758. };
  81759. /**
  81760. * Release all resources
  81761. */
  81762. Buffer.prototype.dispose = function () {
  81763. if (!this._buffer) {
  81764. return;
  81765. }
  81766. if (this._engine._releaseBuffer(this._buffer)) {
  81767. this._buffer = null;
  81768. }
  81769. };
  81770. return Buffer;
  81771. }());
  81772. /**
  81773. * Specialized buffer used to store vertex data
  81774. */
  81775. var VertexBuffer = /** @class */ (function () {
  81776. /**
  81777. * Constructor
  81778. * @param engine the engine
  81779. * @param data the data to use for this vertex buffer
  81780. * @param kind the vertex buffer kind
  81781. * @param updatable whether the data is updatable
  81782. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  81783. * @param stride the stride (optional)
  81784. * @param instanced whether the buffer is instanced (optional)
  81785. * @param offset the offset of the data (optional)
  81786. * @param size the number of components (optional)
  81787. * @param type the type of the component (optional)
  81788. * @param normalized whether the data contains normalized data (optional)
  81789. * @param useBytes set to true if stride and offset are in bytes (optional)
  81790. */
  81791. function VertexBuffer(engine, data, kind, updatable, postponeInternalCreation, stride, instanced, offset, size, type, normalized, useBytes) {
  81792. if (normalized === void 0) { normalized = false; }
  81793. if (useBytes === void 0) { useBytes = false; }
  81794. if (data instanceof Buffer) {
  81795. this._buffer = data;
  81796. this._ownsBuffer = false;
  81797. }
  81798. else {
  81799. this._buffer = new Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes);
  81800. this._ownsBuffer = true;
  81801. }
  81802. this._kind = kind;
  81803. if (type == undefined) {
  81804. var data_1 = this.getData();
  81805. this.type = VertexBuffer.FLOAT;
  81806. if (data_1 instanceof Int8Array) {
  81807. this.type = VertexBuffer.BYTE;
  81808. }
  81809. else if (data_1 instanceof Uint8Array) {
  81810. this.type = VertexBuffer.UNSIGNED_BYTE;
  81811. }
  81812. else if (data_1 instanceof Int16Array) {
  81813. this.type = VertexBuffer.SHORT;
  81814. }
  81815. else if (data_1 instanceof Uint16Array) {
  81816. this.type = VertexBuffer.UNSIGNED_SHORT;
  81817. }
  81818. else if (data_1 instanceof Int32Array) {
  81819. this.type = VertexBuffer.INT;
  81820. }
  81821. else if (data_1 instanceof Uint32Array) {
  81822. this.type = VertexBuffer.UNSIGNED_INT;
  81823. }
  81824. }
  81825. else {
  81826. this.type = type;
  81827. }
  81828. var typeByteLength = VertexBuffer.GetTypeByteLength(this.type);
  81829. if (useBytes) {
  81830. this._size = size || (stride ? (stride / typeByteLength) : VertexBuffer.DeduceStride(kind));
  81831. this.byteStride = stride || this._buffer.byteStride || (this._size * typeByteLength);
  81832. this.byteOffset = offset || 0;
  81833. }
  81834. else {
  81835. this._size = size || stride || VertexBuffer.DeduceStride(kind);
  81836. this.byteStride = stride ? (stride * typeByteLength) : (this._buffer.byteStride || (this._size * typeByteLength));
  81837. this.byteOffset = (offset || 0) * typeByteLength;
  81838. }
  81839. this.normalized = normalized;
  81840. this._instanced = instanced !== undefined ? instanced : false;
  81841. this._instanceDivisor = instanced ? 1 : 0;
  81842. }
  81843. Object.defineProperty(VertexBuffer.prototype, "instanceDivisor", {
  81844. /**
  81845. * Gets or sets the instance divisor when in instanced mode
  81846. */
  81847. get: function () {
  81848. return this._instanceDivisor;
  81849. },
  81850. set: function (value) {
  81851. this._instanceDivisor = value;
  81852. if (value == 0) {
  81853. this._instanced = false;
  81854. }
  81855. else {
  81856. this._instanced = true;
  81857. }
  81858. },
  81859. enumerable: true,
  81860. configurable: true
  81861. });
  81862. /** @hidden */
  81863. VertexBuffer.prototype._rebuild = function () {
  81864. if (!this._buffer) {
  81865. return;
  81866. }
  81867. this._buffer._rebuild();
  81868. };
  81869. /**
  81870. * Returns the kind of the VertexBuffer (string)
  81871. * @returns a string
  81872. */
  81873. VertexBuffer.prototype.getKind = function () {
  81874. return this._kind;
  81875. };
  81876. // Properties
  81877. /**
  81878. * Gets a boolean indicating if the VertexBuffer is updatable?
  81879. * @returns true if the buffer is updatable
  81880. */
  81881. VertexBuffer.prototype.isUpdatable = function () {
  81882. return this._buffer.isUpdatable();
  81883. };
  81884. /**
  81885. * Gets current buffer's data
  81886. * @returns a DataArray or null
  81887. */
  81888. VertexBuffer.prototype.getData = function () {
  81889. return this._buffer.getData();
  81890. };
  81891. /**
  81892. * Gets underlying native buffer
  81893. * @returns underlying native buffer
  81894. */
  81895. VertexBuffer.prototype.getBuffer = function () {
  81896. return this._buffer.getBuffer();
  81897. };
  81898. /**
  81899. * Gets the stride in float32 units (i.e. byte stride / 4).
  81900. * May not be an integer if the byte stride is not divisible by 4.
  81901. * DEPRECATED. Use byteStride instead.
  81902. * @returns the stride in float32 units
  81903. */
  81904. VertexBuffer.prototype.getStrideSize = function () {
  81905. return this.byteStride / VertexBuffer.GetTypeByteLength(this.type);
  81906. };
  81907. /**
  81908. * Returns the offset as a multiple of the type byte length.
  81909. * DEPRECATED. Use byteOffset instead.
  81910. * @returns the offset in bytes
  81911. */
  81912. VertexBuffer.prototype.getOffset = function () {
  81913. return this.byteOffset / VertexBuffer.GetTypeByteLength(this.type);
  81914. };
  81915. /**
  81916. * Returns the number of components per vertex attribute (integer)
  81917. * @returns the size in float
  81918. */
  81919. VertexBuffer.prototype.getSize = function () {
  81920. return this._size;
  81921. };
  81922. /**
  81923. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  81924. * @returns true if this buffer is instanced
  81925. */
  81926. VertexBuffer.prototype.getIsInstanced = function () {
  81927. return this._instanced;
  81928. };
  81929. /**
  81930. * Returns the instancing divisor, zero for non-instanced (integer).
  81931. * @returns a number
  81932. */
  81933. VertexBuffer.prototype.getInstanceDivisor = function () {
  81934. return this._instanceDivisor;
  81935. };
  81936. // Methods
  81937. /**
  81938. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  81939. * @param data defines the data to store
  81940. */
  81941. VertexBuffer.prototype.create = function (data) {
  81942. this._buffer.create(data);
  81943. };
  81944. /**
  81945. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  81946. * This function will create a new buffer if the current one is not updatable
  81947. * @param data defines the data to store
  81948. */
  81949. VertexBuffer.prototype.update = function (data) {
  81950. this._buffer.update(data);
  81951. };
  81952. /**
  81953. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  81954. * Returns the directly updated WebGLBuffer.
  81955. * @param data the new data
  81956. * @param offset the new offset
  81957. * @param useBytes set to true if the offset is in bytes
  81958. */
  81959. VertexBuffer.prototype.updateDirectly = function (data, offset, useBytes) {
  81960. if (useBytes === void 0) { useBytes = false; }
  81961. this._buffer.updateDirectly(data, offset, undefined, useBytes);
  81962. };
  81963. /**
  81964. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  81965. */
  81966. VertexBuffer.prototype.dispose = function () {
  81967. if (this._ownsBuffer) {
  81968. this._buffer.dispose();
  81969. }
  81970. };
  81971. /**
  81972. * Enumerates each value of this vertex buffer as numbers.
  81973. * @param count the number of values to enumerate
  81974. * @param callback the callback function called for each value
  81975. */
  81976. VertexBuffer.prototype.forEach = function (count, callback) {
  81977. VertexBuffer.ForEach(this._buffer.getData(), this.byteOffset, this.byteStride, this._size, this.type, count, this.normalized, callback);
  81978. };
  81979. /**
  81980. * Deduces the stride given a kind.
  81981. * @param kind The kind string to deduce
  81982. * @returns The deduced stride
  81983. */
  81984. VertexBuffer.DeduceStride = function (kind) {
  81985. switch (kind) {
  81986. case VertexBuffer.UVKind:
  81987. case VertexBuffer.UV2Kind:
  81988. case VertexBuffer.UV3Kind:
  81989. case VertexBuffer.UV4Kind:
  81990. case VertexBuffer.UV5Kind:
  81991. case VertexBuffer.UV6Kind:
  81992. return 2;
  81993. case VertexBuffer.NormalKind:
  81994. case VertexBuffer.PositionKind:
  81995. return 3;
  81996. case VertexBuffer.ColorKind:
  81997. case VertexBuffer.MatricesIndicesKind:
  81998. case VertexBuffer.MatricesIndicesExtraKind:
  81999. case VertexBuffer.MatricesWeightsKind:
  82000. case VertexBuffer.MatricesWeightsExtraKind:
  82001. case VertexBuffer.TangentKind:
  82002. return 4;
  82003. default:
  82004. throw new Error("Invalid kind '" + kind + "'");
  82005. }
  82006. };
  82007. /**
  82008. * Gets the byte length of the given type.
  82009. * @param type the type
  82010. * @returns the number of bytes
  82011. */
  82012. VertexBuffer.GetTypeByteLength = function (type) {
  82013. switch (type) {
  82014. case VertexBuffer.BYTE:
  82015. case VertexBuffer.UNSIGNED_BYTE:
  82016. return 1;
  82017. case VertexBuffer.SHORT:
  82018. case VertexBuffer.UNSIGNED_SHORT:
  82019. return 2;
  82020. case VertexBuffer.INT:
  82021. case VertexBuffer.FLOAT:
  82022. return 4;
  82023. default:
  82024. throw new Error("Invalid type '" + type + "'");
  82025. }
  82026. };
  82027. /**
  82028. * Enumerates each value of the given parameters as numbers.
  82029. * @param data the data to enumerate
  82030. * @param byteOffset the byte offset of the data
  82031. * @param byteStride the byte stride of the data
  82032. * @param componentCount the number of components per element
  82033. * @param componentType the type of the component
  82034. * @param count the total number of components
  82035. * @param normalized whether the data is normalized
  82036. * @param callback the callback function called for each value
  82037. */
  82038. VertexBuffer.ForEach = function (data, byteOffset, byteStride, componentCount, componentType, count, normalized, callback) {
  82039. if (data instanceof Array) {
  82040. var offset = byteOffset / 4;
  82041. var stride = byteStride / 4;
  82042. for (var index = 0; index < count; index += componentCount) {
  82043. for (var componentIndex = 0; componentIndex < componentCount; componentIndex++) {
  82044. callback(data[offset + componentIndex], index + componentIndex);
  82045. }
  82046. offset += stride;
  82047. }
  82048. }
  82049. else {
  82050. var dataView = data instanceof ArrayBuffer ? new DataView(data) : new DataView(data.buffer, data.byteOffset, data.byteLength);
  82051. var componentByteLength = VertexBuffer.GetTypeByteLength(componentType);
  82052. for (var index = 0; index < count; index += componentCount) {
  82053. var componentByteOffset = byteOffset;
  82054. for (var componentIndex = 0; componentIndex < componentCount; componentIndex++) {
  82055. var value = VertexBuffer._GetFloatValue(dataView, componentType, componentByteOffset, normalized);
  82056. callback(value, index + componentIndex);
  82057. componentByteOffset += componentByteLength;
  82058. }
  82059. byteOffset += byteStride;
  82060. }
  82061. }
  82062. };
  82063. VertexBuffer._GetFloatValue = function (dataView, type, byteOffset, normalized) {
  82064. switch (type) {
  82065. case VertexBuffer.BYTE: {
  82066. var value = dataView.getInt8(byteOffset);
  82067. if (normalized) {
  82068. value = Math.max(value / 127, -1);
  82069. }
  82070. return value;
  82071. }
  82072. case VertexBuffer.UNSIGNED_BYTE: {
  82073. var value = dataView.getUint8(byteOffset);
  82074. if (normalized) {
  82075. value = value / 255;
  82076. }
  82077. return value;
  82078. }
  82079. case VertexBuffer.SHORT: {
  82080. var value = dataView.getInt16(byteOffset, true);
  82081. if (normalized) {
  82082. value = Math.max(value / 16383, -1);
  82083. }
  82084. return value;
  82085. }
  82086. case VertexBuffer.UNSIGNED_SHORT: {
  82087. var value = dataView.getUint16(byteOffset, true);
  82088. if (normalized) {
  82089. value = value / 65535;
  82090. }
  82091. return value;
  82092. }
  82093. case VertexBuffer.FLOAT: {
  82094. return dataView.getFloat32(byteOffset, true);
  82095. }
  82096. default: {
  82097. throw new Error("Invalid component type " + type);
  82098. }
  82099. }
  82100. };
  82101. /**
  82102. * The byte type.
  82103. */
  82104. VertexBuffer.BYTE = 5120;
  82105. /**
  82106. * The unsigned byte type.
  82107. */
  82108. VertexBuffer.UNSIGNED_BYTE = 5121;
  82109. /**
  82110. * The short type.
  82111. */
  82112. VertexBuffer.SHORT = 5122;
  82113. /**
  82114. * The unsigned short type.
  82115. */
  82116. VertexBuffer.UNSIGNED_SHORT = 5123;
  82117. /**
  82118. * The integer type.
  82119. */
  82120. VertexBuffer.INT = 5124;
  82121. /**
  82122. * The unsigned integer type.
  82123. */
  82124. VertexBuffer.UNSIGNED_INT = 5125;
  82125. /**
  82126. * The float type.
  82127. */
  82128. VertexBuffer.FLOAT = 5126;
  82129. // Enums
  82130. /**
  82131. * Positions
  82132. */
  82133. VertexBuffer.PositionKind = "position";
  82134. /**
  82135. * Normals
  82136. */
  82137. VertexBuffer.NormalKind = "normal";
  82138. /**
  82139. * Tangents
  82140. */
  82141. VertexBuffer.TangentKind = "tangent";
  82142. /**
  82143. * Texture coordinates
  82144. */
  82145. VertexBuffer.UVKind = "uv";
  82146. /**
  82147. * Texture coordinates 2
  82148. */
  82149. VertexBuffer.UV2Kind = "uv2";
  82150. /**
  82151. * Texture coordinates 3
  82152. */
  82153. VertexBuffer.UV3Kind = "uv3";
  82154. /**
  82155. * Texture coordinates 4
  82156. */
  82157. VertexBuffer.UV4Kind = "uv4";
  82158. /**
  82159. * Texture coordinates 5
  82160. */
  82161. VertexBuffer.UV5Kind = "uv5";
  82162. /**
  82163. * Texture coordinates 6
  82164. */
  82165. VertexBuffer.UV6Kind = "uv6";
  82166. /**
  82167. * Colors
  82168. */
  82169. VertexBuffer.ColorKind = "color";
  82170. /**
  82171. * Matrix indices (for bones)
  82172. */
  82173. VertexBuffer.MatricesIndicesKind = "matricesIndices";
  82174. /**
  82175. * Matrix weights (for bones)
  82176. */
  82177. VertexBuffer.MatricesWeightsKind = "matricesWeights";
  82178. /**
  82179. * Additional matrix indices (for bones)
  82180. */
  82181. VertexBuffer.MatricesIndicesExtraKind = "matricesIndicesExtra";
  82182. /**
  82183. * Additional matrix weights (for bones)
  82184. */
  82185. VertexBuffer.MatricesWeightsExtraKind = "matricesWeightsExtra";
  82186. return VertexBuffer;
  82187. }());
  82188. /***/ }),
  82189. /***/ "./Meshes/csg.ts":
  82190. /*!***********************!*\
  82191. !*** ./Meshes/csg.ts ***!
  82192. \***********************/
  82193. /*! exports provided: CSG */
  82194. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  82195. "use strict";
  82196. __webpack_require__.r(__webpack_exports__);
  82197. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return CSG; });
  82198. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  82199. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  82200. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  82201. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  82202. /**
  82203. * Unique ID when we import meshes from Babylon to CSG
  82204. */
  82205. var currentCSGMeshId = 0;
  82206. /**
  82207. * Represents a vertex of a polygon. Use your own vertex class instead of this
  82208. * one to provide additional features like texture coordinates and vertex
  82209. * colors. Custom vertex classes need to provide a `pos` property and `clone()`,
  82210. * `flip()`, and `interpolate()` methods that behave analogous to the ones
  82211. * defined by `BABYLON.CSG.Vertex`. This class provides `normal` so convenience
  82212. * functions like `BABYLON.CSG.sphere()` can return a smooth vertex normal, but `normal`
  82213. * is not used anywhere else.
  82214. * Same goes for uv, it allows to keep the original vertex uv coordinates of the 2 meshes
  82215. */
  82216. var Vertex = /** @class */ (function () {
  82217. /**
  82218. * Initializes the vertex
  82219. * @param pos The position of the vertex
  82220. * @param normal The normal of the vertex
  82221. * @param uv The texture coordinate of the vertex
  82222. */
  82223. function Vertex(
  82224. /**
  82225. * The position of the vertex
  82226. */
  82227. pos,
  82228. /**
  82229. * The normal of the vertex
  82230. */
  82231. normal,
  82232. /**
  82233. * The texture coordinate of the vertex
  82234. */
  82235. uv) {
  82236. this.pos = pos;
  82237. this.normal = normal;
  82238. this.uv = uv;
  82239. }
  82240. /**
  82241. * Make a clone, or deep copy, of the vertex
  82242. * @returns A new Vertex
  82243. */
  82244. Vertex.prototype.clone = function () {
  82245. return new Vertex(this.pos.clone(), this.normal.clone(), this.uv.clone());
  82246. };
  82247. /**
  82248. * Invert all orientation-specific data (e.g. vertex normal). Called when the
  82249. * orientation of a polygon is flipped.
  82250. */
  82251. Vertex.prototype.flip = function () {
  82252. this.normal = this.normal.scale(-1);
  82253. };
  82254. /**
  82255. * Create a new vertex between this vertex and `other` by linearly
  82256. * interpolating all properties using a parameter of `t`. Subclasses should
  82257. * override this to interpolate additional properties.
  82258. * @param other the vertex to interpolate against
  82259. * @param t The factor used to linearly interpolate between the vertices
  82260. */
  82261. Vertex.prototype.interpolate = function (other, t) {
  82262. 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));
  82263. };
  82264. return Vertex;
  82265. }());
  82266. /**
  82267. * Represents a plane in 3D space.
  82268. */
  82269. var Plane = /** @class */ (function () {
  82270. /**
  82271. * Initializes the plane
  82272. * @param normal The normal for the plane
  82273. * @param w
  82274. */
  82275. function Plane(normal, w) {
  82276. this.normal = normal;
  82277. this.w = w;
  82278. }
  82279. /**
  82280. * Construct a plane from three points
  82281. * @param a Point a
  82282. * @param b Point b
  82283. * @param c Point c
  82284. */
  82285. Plane.FromPoints = function (a, b, c) {
  82286. var v0 = c.subtract(a);
  82287. var v1 = b.subtract(a);
  82288. if (v0.lengthSquared() === 0 || v1.lengthSquared() === 0) {
  82289. return null;
  82290. }
  82291. var n = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(v0, v1));
  82292. return new Plane(n, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(n, a));
  82293. };
  82294. /**
  82295. * Clone, or make a deep copy of the plane
  82296. * @returns a new Plane
  82297. */
  82298. Plane.prototype.clone = function () {
  82299. return new Plane(this.normal.clone(), this.w);
  82300. };
  82301. /**
  82302. * Flip the face of the plane
  82303. */
  82304. Plane.prototype.flip = function () {
  82305. this.normal.scaleInPlace(-1);
  82306. this.w = -this.w;
  82307. };
  82308. /**
  82309. * Split `polygon` by this plane if needed, then put the polygon or polygon
  82310. * fragments in the appropriate lists. Coplanar polygons go into either
  82311. `* coplanarFront` or `coplanarBack` depending on their orientation with
  82312. * respect to this plane. Polygons in front or in back of this plane go into
  82313. * either `front` or `back`
  82314. * @param polygon The polygon to be split
  82315. * @param coplanarFront Will contain polygons coplanar with the plane that are oriented to the front of the plane
  82316. * @param coplanarBack Will contain polygons coplanar with the plane that are oriented to the back of the plane
  82317. * @param front Will contain the polygons in front of the plane
  82318. * @param back Will contain the polygons begind the plane
  82319. */
  82320. Plane.prototype.splitPolygon = function (polygon, coplanarFront, coplanarBack, front, back) {
  82321. var COPLANAR = 0;
  82322. var FRONT = 1;
  82323. var BACK = 2;
  82324. var SPANNING = 3;
  82325. // Classify each point as well as the entire polygon into one of the above
  82326. // four classes.
  82327. var polygonType = 0;
  82328. var types = [];
  82329. var i;
  82330. var t;
  82331. for (i = 0; i < polygon.vertices.length; i++) {
  82332. t = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this.normal, polygon.vertices[i].pos) - this.w;
  82333. var type = (t < -Plane.EPSILON) ? BACK : (t > Plane.EPSILON) ? FRONT : COPLANAR;
  82334. polygonType |= type;
  82335. types.push(type);
  82336. }
  82337. // Put the polygon in the correct list, splitting it when necessary
  82338. switch (polygonType) {
  82339. case COPLANAR:
  82340. (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this.normal, polygon.plane.normal) > 0 ? coplanarFront : coplanarBack).push(polygon);
  82341. break;
  82342. case FRONT:
  82343. front.push(polygon);
  82344. break;
  82345. case BACK:
  82346. back.push(polygon);
  82347. break;
  82348. case SPANNING:
  82349. var f = [], b = [];
  82350. for (i = 0; i < polygon.vertices.length; i++) {
  82351. var j = (i + 1) % polygon.vertices.length;
  82352. var ti = types[i], tj = types[j];
  82353. var vi = polygon.vertices[i], vj = polygon.vertices[j];
  82354. if (ti !== BACK) {
  82355. f.push(vi);
  82356. }
  82357. if (ti !== FRONT) {
  82358. b.push(ti !== BACK ? vi.clone() : vi);
  82359. }
  82360. if ((ti | tj) === SPANNING) {
  82361. 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));
  82362. var v = vi.interpolate(vj, t);
  82363. f.push(v);
  82364. b.push(v.clone());
  82365. }
  82366. }
  82367. var poly;
  82368. if (f.length >= 3) {
  82369. poly = new Polygon(f, polygon.shared);
  82370. if (poly.plane) {
  82371. front.push(poly);
  82372. }
  82373. }
  82374. if (b.length >= 3) {
  82375. poly = new Polygon(b, polygon.shared);
  82376. if (poly.plane) {
  82377. back.push(poly);
  82378. }
  82379. }
  82380. break;
  82381. }
  82382. };
  82383. /**
  82384. * `CSG.Plane.EPSILON` is the tolerance used by `splitPolygon()` to decide if a
  82385. * point is on the plane
  82386. */
  82387. Plane.EPSILON = 1e-5;
  82388. return Plane;
  82389. }());
  82390. /**
  82391. * Represents a convex polygon. The vertices used to initialize a polygon must
  82392. * be coplanar and form a convex loop.
  82393. *
  82394. * Each convex polygon has a `shared` property, which is shared between all
  82395. * polygons that are clones of each other or were split from the same polygon.
  82396. * This can be used to define per-polygon properties (such as surface color)
  82397. */
  82398. var Polygon = /** @class */ (function () {
  82399. /**
  82400. * Initializes the polygon
  82401. * @param vertices The vertices of the polygon
  82402. * @param shared The properties shared across all polygons
  82403. */
  82404. function Polygon(vertices, shared) {
  82405. this.vertices = vertices;
  82406. this.shared = shared;
  82407. this.plane = Plane.FromPoints(vertices[0].pos, vertices[1].pos, vertices[2].pos);
  82408. }
  82409. /**
  82410. * Clones, or makes a deep copy, or the polygon
  82411. */
  82412. Polygon.prototype.clone = function () {
  82413. var vertices = this.vertices.map(function (v) { return v.clone(); });
  82414. return new Polygon(vertices, this.shared);
  82415. };
  82416. /**
  82417. * Flips the faces of the polygon
  82418. */
  82419. Polygon.prototype.flip = function () {
  82420. this.vertices.reverse().map(function (v) { v.flip(); });
  82421. this.plane.flip();
  82422. };
  82423. return Polygon;
  82424. }());
  82425. /**
  82426. * Holds a node in a BSP tree. A BSP tree is built from a collection of polygons
  82427. * by picking a polygon to split along. That polygon (and all other coplanar
  82428. * polygons) are added directly to that node and the other polygons are added to
  82429. * the front and/or back subtrees. This is not a leafy BSP tree since there is
  82430. * no distinction between internal and leaf nodes
  82431. */
  82432. var Node = /** @class */ (function () {
  82433. /**
  82434. * Initializes the node
  82435. * @param polygons A collection of polygons held in the node
  82436. */
  82437. function Node(polygons) {
  82438. this.plane = null;
  82439. this.front = null;
  82440. this.back = null;
  82441. this.polygons = new Array();
  82442. if (polygons) {
  82443. this.build(polygons);
  82444. }
  82445. }
  82446. /**
  82447. * Clones, or makes a deep copy, of the node
  82448. * @returns The cloned node
  82449. */
  82450. Node.prototype.clone = function () {
  82451. var node = new Node();
  82452. node.plane = this.plane && this.plane.clone();
  82453. node.front = this.front && this.front.clone();
  82454. node.back = this.back && this.back.clone();
  82455. node.polygons = this.polygons.map(function (p) { return p.clone(); });
  82456. return node;
  82457. };
  82458. /**
  82459. * Convert solid space to empty space and empty space to solid space
  82460. */
  82461. Node.prototype.invert = function () {
  82462. for (var i = 0; i < this.polygons.length; i++) {
  82463. this.polygons[i].flip();
  82464. }
  82465. if (this.plane) {
  82466. this.plane.flip();
  82467. }
  82468. if (this.front) {
  82469. this.front.invert();
  82470. }
  82471. if (this.back) {
  82472. this.back.invert();
  82473. }
  82474. var temp = this.front;
  82475. this.front = this.back;
  82476. this.back = temp;
  82477. };
  82478. /**
  82479. * Recursively remove all polygons in `polygons` that are inside this BSP
  82480. * tree.
  82481. * @param polygons Polygons to remove from the BSP
  82482. * @returns Polygons clipped from the BSP
  82483. */
  82484. Node.prototype.clipPolygons = function (polygons) {
  82485. if (!this.plane) {
  82486. return polygons.slice();
  82487. }
  82488. var front = new Array(), back = new Array();
  82489. for (var i = 0; i < polygons.length; i++) {
  82490. this.plane.splitPolygon(polygons[i], front, back, front, back);
  82491. }
  82492. if (this.front) {
  82493. front = this.front.clipPolygons(front);
  82494. }
  82495. if (this.back) {
  82496. back = this.back.clipPolygons(back);
  82497. }
  82498. else {
  82499. back = [];
  82500. }
  82501. return front.concat(back);
  82502. };
  82503. /**
  82504. * Remove all polygons in this BSP tree that are inside the other BSP tree
  82505. * `bsp`.
  82506. * @param bsp BSP containing polygons to remove from this BSP
  82507. */
  82508. Node.prototype.clipTo = function (bsp) {
  82509. this.polygons = bsp.clipPolygons(this.polygons);
  82510. if (this.front) {
  82511. this.front.clipTo(bsp);
  82512. }
  82513. if (this.back) {
  82514. this.back.clipTo(bsp);
  82515. }
  82516. };
  82517. /**
  82518. * Return a list of all polygons in this BSP tree
  82519. * @returns List of all polygons in this BSP tree
  82520. */
  82521. Node.prototype.allPolygons = function () {
  82522. var polygons = this.polygons.slice();
  82523. if (this.front) {
  82524. polygons = polygons.concat(this.front.allPolygons());
  82525. }
  82526. if (this.back) {
  82527. polygons = polygons.concat(this.back.allPolygons());
  82528. }
  82529. return polygons;
  82530. };
  82531. /**
  82532. * Build a BSP tree out of `polygons`. When called on an existing tree, the
  82533. * new polygons are filtered down to the bottom of the tree and become new
  82534. * nodes there. Each set of polygons is partitioned using the first polygon
  82535. * (no heuristic is used to pick a good split)
  82536. * @param polygons Polygons used to construct the BSP tree
  82537. */
  82538. Node.prototype.build = function (polygons) {
  82539. if (!polygons.length) {
  82540. return;
  82541. }
  82542. if (!this.plane) {
  82543. this.plane = polygons[0].plane.clone();
  82544. }
  82545. var front = new Array(), back = new Array();
  82546. for (var i = 0; i < polygons.length; i++) {
  82547. this.plane.splitPolygon(polygons[i], this.polygons, this.polygons, front, back);
  82548. }
  82549. if (front.length) {
  82550. if (!this.front) {
  82551. this.front = new Node();
  82552. }
  82553. this.front.build(front);
  82554. }
  82555. if (back.length) {
  82556. if (!this.back) {
  82557. this.back = new Node();
  82558. }
  82559. this.back.build(back);
  82560. }
  82561. };
  82562. return Node;
  82563. }());
  82564. /**
  82565. * Class for building Constructive Solid Geometry
  82566. */
  82567. var CSG = /** @class */ (function () {
  82568. function CSG() {
  82569. this.polygons = new Array();
  82570. }
  82571. /**
  82572. * Convert the Mesh to CSG
  82573. * @param mesh The Mesh to convert to CSG
  82574. * @returns A new CSG from the Mesh
  82575. */
  82576. CSG.FromMesh = function (mesh) {
  82577. var vertex, normal, uv, position, polygon, polygons = new Array(), vertices;
  82578. var matrix, meshPosition, meshRotation, meshRotationQuaternion = null, meshScaling;
  82579. if (mesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]) {
  82580. mesh.computeWorldMatrix(true);
  82581. matrix = mesh.getWorldMatrix();
  82582. meshPosition = mesh.position.clone();
  82583. meshRotation = mesh.rotation.clone();
  82584. if (mesh.rotationQuaternion) {
  82585. meshRotationQuaternion = mesh.rotationQuaternion.clone();
  82586. }
  82587. meshScaling = mesh.scaling.clone();
  82588. }
  82589. else {
  82590. throw 'BABYLON.CSG: Wrong Mesh type, must be BABYLON.Mesh';
  82591. }
  82592. 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);
  82593. var subMeshes = mesh.subMeshes;
  82594. for (var sm = 0, sml = subMeshes.length; sm < sml; sm++) {
  82595. for (var i = subMeshes[sm].indexStart, il = subMeshes[sm].indexCount + subMeshes[sm].indexStart; i < il; i += 3) {
  82596. vertices = [];
  82597. for (var j = 0; j < 3; j++) {
  82598. 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]);
  82599. uv = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](uvs[indices[i + j] * 2], uvs[indices[i + j] * 2 + 1]);
  82600. 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]);
  82601. position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(sourcePosition, matrix);
  82602. normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(sourceNormal, matrix);
  82603. vertex = new Vertex(position, normal, uv);
  82604. vertices.push(vertex);
  82605. }
  82606. polygon = new Polygon(vertices, { subMeshId: sm, meshId: currentCSGMeshId, materialIndex: subMeshes[sm].materialIndex });
  82607. // To handle the case of degenerated triangle
  82608. // polygon.plane == null <=> the polygon does not represent 1 single plane <=> the triangle is degenerated
  82609. if (polygon.plane) {
  82610. polygons.push(polygon);
  82611. }
  82612. }
  82613. }
  82614. var csg = CSG.FromPolygons(polygons);
  82615. csg.matrix = matrix;
  82616. csg.position = meshPosition;
  82617. csg.rotation = meshRotation;
  82618. csg.scaling = meshScaling;
  82619. csg.rotationQuaternion = meshRotationQuaternion;
  82620. currentCSGMeshId++;
  82621. return csg;
  82622. };
  82623. /**
  82624. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  82625. * @param polygons Polygons used to construct a CSG solid
  82626. */
  82627. CSG.FromPolygons = function (polygons) {
  82628. var csg = new CSG();
  82629. csg.polygons = polygons;
  82630. return csg;
  82631. };
  82632. /**
  82633. * Clones, or makes a deep copy, of the CSG
  82634. * @returns A new CSG
  82635. */
  82636. CSG.prototype.clone = function () {
  82637. var csg = new CSG();
  82638. csg.polygons = this.polygons.map(function (p) { return p.clone(); });
  82639. csg.copyTransformAttributes(this);
  82640. return csg;
  82641. };
  82642. /**
  82643. * Unions this CSG with another CSG
  82644. * @param csg The CSG to union against this CSG
  82645. * @returns The unioned CSG
  82646. */
  82647. CSG.prototype.union = function (csg) {
  82648. var a = new Node(this.clone().polygons);
  82649. var b = new Node(csg.clone().polygons);
  82650. a.clipTo(b);
  82651. b.clipTo(a);
  82652. b.invert();
  82653. b.clipTo(a);
  82654. b.invert();
  82655. a.build(b.allPolygons());
  82656. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  82657. };
  82658. /**
  82659. * Unions this CSG with another CSG in place
  82660. * @param csg The CSG to union against this CSG
  82661. */
  82662. CSG.prototype.unionInPlace = function (csg) {
  82663. var a = new Node(this.polygons);
  82664. var b = new Node(csg.polygons);
  82665. a.clipTo(b);
  82666. b.clipTo(a);
  82667. b.invert();
  82668. b.clipTo(a);
  82669. b.invert();
  82670. a.build(b.allPolygons());
  82671. this.polygons = a.allPolygons();
  82672. };
  82673. /**
  82674. * Subtracts this CSG with another CSG
  82675. * @param csg The CSG to subtract against this CSG
  82676. * @returns A new CSG
  82677. */
  82678. CSG.prototype.subtract = function (csg) {
  82679. var a = new Node(this.clone().polygons);
  82680. var b = new Node(csg.clone().polygons);
  82681. a.invert();
  82682. a.clipTo(b);
  82683. b.clipTo(a);
  82684. b.invert();
  82685. b.clipTo(a);
  82686. b.invert();
  82687. a.build(b.allPolygons());
  82688. a.invert();
  82689. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  82690. };
  82691. /**
  82692. * Subtracts this CSG with another CSG in place
  82693. * @param csg The CSG to subtact against this CSG
  82694. */
  82695. CSG.prototype.subtractInPlace = function (csg) {
  82696. var a = new Node(this.polygons);
  82697. var b = new Node(csg.polygons);
  82698. a.invert();
  82699. a.clipTo(b);
  82700. b.clipTo(a);
  82701. b.invert();
  82702. b.clipTo(a);
  82703. b.invert();
  82704. a.build(b.allPolygons());
  82705. a.invert();
  82706. this.polygons = a.allPolygons();
  82707. };
  82708. /**
  82709. * Intersect this CSG with another CSG
  82710. * @param csg The CSG to intersect against this CSG
  82711. * @returns A new CSG
  82712. */
  82713. CSG.prototype.intersect = function (csg) {
  82714. var a = new Node(this.clone().polygons);
  82715. var b = new Node(csg.clone().polygons);
  82716. a.invert();
  82717. b.clipTo(a);
  82718. b.invert();
  82719. a.clipTo(b);
  82720. b.clipTo(a);
  82721. a.build(b.allPolygons());
  82722. a.invert();
  82723. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  82724. };
  82725. /**
  82726. * Intersects this CSG with another CSG in place
  82727. * @param csg The CSG to intersect against this CSG
  82728. */
  82729. CSG.prototype.intersectInPlace = function (csg) {
  82730. var a = new Node(this.polygons);
  82731. var b = new Node(csg.polygons);
  82732. a.invert();
  82733. b.clipTo(a);
  82734. b.invert();
  82735. a.clipTo(b);
  82736. b.clipTo(a);
  82737. a.build(b.allPolygons());
  82738. a.invert();
  82739. this.polygons = a.allPolygons();
  82740. };
  82741. /**
  82742. * Return a new CSG solid with solid and empty space switched. This solid is
  82743. * not modified.
  82744. * @returns A new CSG solid with solid and empty space switched
  82745. */
  82746. CSG.prototype.inverse = function () {
  82747. var csg = this.clone();
  82748. csg.inverseInPlace();
  82749. return csg;
  82750. };
  82751. /**
  82752. * Inverses the CSG in place
  82753. */
  82754. CSG.prototype.inverseInPlace = function () {
  82755. this.polygons.map(function (p) { p.flip(); });
  82756. };
  82757. /**
  82758. * This is used to keep meshes transformations so they can be restored
  82759. * when we build back a Babylon Mesh
  82760. * NB : All CSG operations are performed in world coordinates
  82761. * @param csg The CSG to copy the transform attributes from
  82762. * @returns This CSG
  82763. */
  82764. CSG.prototype.copyTransformAttributes = function (csg) {
  82765. this.matrix = csg.matrix;
  82766. this.position = csg.position;
  82767. this.rotation = csg.rotation;
  82768. this.scaling = csg.scaling;
  82769. this.rotationQuaternion = csg.rotationQuaternion;
  82770. return this;
  82771. };
  82772. /**
  82773. * Build Raw mesh from CSG
  82774. * Coordinates here are in world space
  82775. * @param name The name of the mesh geometry
  82776. * @param scene The Scene
  82777. * @param keepSubMeshes Specifies if the submeshes should be kept
  82778. * @returns A new Mesh
  82779. */
  82780. CSG.prototype.buildMeshGeometry = function (name, scene, keepSubMeshes) {
  82781. var matrix = this.matrix.clone();
  82782. matrix.invert();
  82783. 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;
  82784. if (keepSubMeshes) {
  82785. // Sort Polygons, since subMeshes are indices range
  82786. polygons.sort(function (a, b) {
  82787. if (a.shared.meshId === b.shared.meshId) {
  82788. return a.shared.subMeshId - b.shared.subMeshId;
  82789. }
  82790. else {
  82791. return a.shared.meshId - b.shared.meshId;
  82792. }
  82793. });
  82794. }
  82795. for (var i = 0, il = polygons.length; i < il; i++) {
  82796. polygon = polygons[i];
  82797. // Building SubMeshes
  82798. if (!subMesh_dict[polygon.shared.meshId]) {
  82799. subMesh_dict[polygon.shared.meshId] = {};
  82800. }
  82801. if (!subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId]) {
  82802. subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId] = {
  82803. indexStart: +Infinity,
  82804. indexEnd: -Infinity,
  82805. materialIndex: polygon.shared.materialIndex
  82806. };
  82807. }
  82808. subMesh_obj = subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId];
  82809. for (var j = 2, jl = polygon.vertices.length; j < jl; j++) {
  82810. polygonIndices[0] = 0;
  82811. polygonIndices[1] = j - 1;
  82812. polygonIndices[2] = j;
  82813. for (var k = 0; k < 3; k++) {
  82814. vertex.copyFrom(polygon.vertices[polygonIndices[k]].pos);
  82815. normal.copyFrom(polygon.vertices[polygonIndices[k]].normal);
  82816. uv.copyFrom(polygon.vertices[polygonIndices[k]].uv);
  82817. var localVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(vertex, matrix);
  82818. var localNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(normal, matrix);
  82819. vertex_idx = vertice_dict[localVertex.x + ',' + localVertex.y + ',' + localVertex.z];
  82820. // Check if 2 points can be merged
  82821. if (!(typeof vertex_idx !== 'undefined' &&
  82822. normals[vertex_idx * 3] === localNormal.x &&
  82823. normals[vertex_idx * 3 + 1] === localNormal.y &&
  82824. normals[vertex_idx * 3 + 2] === localNormal.z &&
  82825. uvs[vertex_idx * 2] === uv.x &&
  82826. uvs[vertex_idx * 2 + 1] === uv.y)) {
  82827. vertices.push(localVertex.x, localVertex.y, localVertex.z);
  82828. uvs.push(uv.x, uv.y);
  82829. normals.push(normal.x, normal.y, normal.z);
  82830. vertex_idx = vertice_dict[localVertex.x + ',' + localVertex.y + ',' + localVertex.z] = (vertices.length / 3) - 1;
  82831. }
  82832. indices.push(vertex_idx);
  82833. subMesh_obj.indexStart = Math.min(currentIndex, subMesh_obj.indexStart);
  82834. subMesh_obj.indexEnd = Math.max(currentIndex, subMesh_obj.indexEnd);
  82835. currentIndex++;
  82836. }
  82837. }
  82838. }
  82839. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, vertices);
  82840. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, normals);
  82841. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, uvs);
  82842. mesh.setIndices(indices, null);
  82843. if (keepSubMeshes) {
  82844. // We offset the materialIndex by the previous number of materials in the CSG mixed meshes
  82845. var materialIndexOffset = 0, materialMaxIndex;
  82846. mesh.subMeshes = new Array();
  82847. for (var m in subMesh_dict) {
  82848. materialMaxIndex = -1;
  82849. for (var sm in subMesh_dict[m]) {
  82850. subMesh_obj = subMesh_dict[m][sm];
  82851. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].CreateFromIndices(subMesh_obj.materialIndex + materialIndexOffset, subMesh_obj.indexStart, subMesh_obj.indexEnd - subMesh_obj.indexStart + 1, mesh);
  82852. materialMaxIndex = Math.max(subMesh_obj.materialIndex, materialMaxIndex);
  82853. }
  82854. materialIndexOffset += ++materialMaxIndex;
  82855. }
  82856. }
  82857. return mesh;
  82858. };
  82859. /**
  82860. * Build Mesh from CSG taking material and transforms into account
  82861. * @param name The name of the Mesh
  82862. * @param material The material of the Mesh
  82863. * @param scene The Scene
  82864. * @param keepSubMeshes Specifies if submeshes should be kept
  82865. * @returns The new Mesh
  82866. */
  82867. CSG.prototype.toMesh = function (name, material, scene, keepSubMeshes) {
  82868. var mesh = this.buildMeshGeometry(name, scene, keepSubMeshes);
  82869. mesh.material = material;
  82870. mesh.position.copyFrom(this.position);
  82871. mesh.rotation.copyFrom(this.rotation);
  82872. if (this.rotationQuaternion) {
  82873. mesh.rotationQuaternion = this.rotationQuaternion.clone();
  82874. }
  82875. mesh.scaling.copyFrom(this.scaling);
  82876. mesh.computeWorldMatrix(true);
  82877. return mesh;
  82878. };
  82879. return CSG;
  82880. }());
  82881. /***/ }),
  82882. /***/ "./Meshes/geometry.ts":
  82883. /*!****************************!*\
  82884. !*** ./Meshes/geometry.ts ***!
  82885. \****************************/
  82886. /*! exports provided: Geometry */
  82887. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  82888. "use strict";
  82889. __webpack_require__.r(__webpack_exports__);
  82890. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return Geometry; });
  82891. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  82892. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  82893. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  82894. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  82895. /* harmony import */ var _Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Loading/sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  82896. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  82897. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  82898. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  82899. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  82900. /**
  82901. * Class used to store geometry data (vertex buffers + index buffer)
  82902. */
  82903. var Geometry = /** @class */ (function () {
  82904. /**
  82905. * Creates a new geometry
  82906. * @param id defines the unique ID
  82907. * @param scene defines the hosting scene
  82908. * @param vertexData defines the VertexData used to get geometry data
  82909. * @param updatable defines if geometry must be updatable (false by default)
  82910. * @param mesh defines the mesh that will be associated with the geometry
  82911. */
  82912. function Geometry(id, scene, vertexData, updatable, mesh) {
  82913. if (updatable === void 0) { updatable = false; }
  82914. if (mesh === void 0) { mesh = null; }
  82915. /**
  82916. * Gets the delay loading state of the geometry (none by default which means not delayed)
  82917. */
  82918. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  82919. this._totalVertices = 0;
  82920. this._isDisposed = false;
  82921. this._indexBufferIsUpdatable = false;
  82922. this.id = id;
  82923. this.uniqueId = scene.getUniqueId();
  82924. this._engine = scene.getEngine();
  82925. this._meshes = [];
  82926. this._scene = scene;
  82927. //Init vertex buffer cache
  82928. this._vertexBuffers = {};
  82929. this._indices = [];
  82930. this._updatable = updatable;
  82931. // vertexData
  82932. if (vertexData) {
  82933. this.setAllVerticesData(vertexData, updatable);
  82934. }
  82935. else {
  82936. this._totalVertices = 0;
  82937. this._indices = [];
  82938. }
  82939. if (this._engine.getCaps().vertexArrayObject) {
  82940. this._vertexArrayObjects = {};
  82941. }
  82942. // applyToMesh
  82943. if (mesh) {
  82944. this.applyToMesh(mesh);
  82945. mesh.computeWorldMatrix(true);
  82946. }
  82947. }
  82948. Object.defineProperty(Geometry.prototype, "boundingBias", {
  82949. /**
  82950. * 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
  82951. */
  82952. get: function () {
  82953. return this._boundingBias;
  82954. },
  82955. /**
  82956. * 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
  82957. */
  82958. set: function (value) {
  82959. if (this._boundingBias) {
  82960. this._boundingBias.copyFrom(value);
  82961. }
  82962. else {
  82963. this._boundingBias = value.clone();
  82964. }
  82965. this._updateBoundingInfo(true, null);
  82966. },
  82967. enumerable: true,
  82968. configurable: true
  82969. });
  82970. /**
  82971. * Static function used to attach a new empty geometry to a mesh
  82972. * @param mesh defines the mesh to attach the geometry to
  82973. * @returns the new Geometry
  82974. */
  82975. Geometry.CreateGeometryForMesh = function (mesh) {
  82976. var geometry = new Geometry(Geometry.RandomId(), mesh.getScene());
  82977. geometry.applyToMesh(mesh);
  82978. return geometry;
  82979. };
  82980. Object.defineProperty(Geometry.prototype, "extend", {
  82981. /**
  82982. * Gets the current extend of the geometry
  82983. */
  82984. get: function () {
  82985. return this._extend;
  82986. },
  82987. enumerable: true,
  82988. configurable: true
  82989. });
  82990. /**
  82991. * Gets the hosting scene
  82992. * @returns the hosting Scene
  82993. */
  82994. Geometry.prototype.getScene = function () {
  82995. return this._scene;
  82996. };
  82997. /**
  82998. * Gets the hosting engine
  82999. * @returns the hosting Engine
  83000. */
  83001. Geometry.prototype.getEngine = function () {
  83002. return this._engine;
  83003. };
  83004. /**
  83005. * Defines if the geometry is ready to use
  83006. * @returns true if the geometry is ready to be used
  83007. */
  83008. Geometry.prototype.isReady = function () {
  83009. return this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED || this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  83010. };
  83011. Object.defineProperty(Geometry.prototype, "doNotSerialize", {
  83012. /**
  83013. * Gets a value indicating that the geometry should not be serialized
  83014. */
  83015. get: function () {
  83016. for (var index = 0; index < this._meshes.length; index++) {
  83017. if (!this._meshes[index].doNotSerialize) {
  83018. return false;
  83019. }
  83020. }
  83021. return true;
  83022. },
  83023. enumerable: true,
  83024. configurable: true
  83025. });
  83026. /** @hidden */
  83027. Geometry.prototype._rebuild = function () {
  83028. if (this._vertexArrayObjects) {
  83029. this._vertexArrayObjects = {};
  83030. }
  83031. // Index buffer
  83032. if (this._meshes.length !== 0 && this._indices) {
  83033. this._indexBuffer = this._engine.createIndexBuffer(this._indices);
  83034. }
  83035. // Vertex buffers
  83036. for (var key in this._vertexBuffers) {
  83037. var vertexBuffer = this._vertexBuffers[key];
  83038. vertexBuffer._rebuild();
  83039. }
  83040. };
  83041. /**
  83042. * Affects all geometry data in one call
  83043. * @param vertexData defines the geometry data
  83044. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  83045. */
  83046. Geometry.prototype.setAllVerticesData = function (vertexData, updatable) {
  83047. vertexData.applyToGeometry(this, updatable);
  83048. this.notifyUpdate();
  83049. };
  83050. /**
  83051. * Set specific vertex data
  83052. * @param kind defines the data kind (Position, normal, etc...)
  83053. * @param data defines the vertex data to use
  83054. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  83055. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  83056. */
  83057. Geometry.prototype.setVerticesData = function (kind, data, updatable, stride) {
  83058. if (updatable === void 0) { updatable = false; }
  83059. var buffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"](this._engine, data, kind, updatable, this._meshes.length === 0, stride);
  83060. this.setVerticesBuffer(buffer);
  83061. };
  83062. /**
  83063. * Removes a specific vertex data
  83064. * @param kind defines the data kind (Position, normal, etc...)
  83065. */
  83066. Geometry.prototype.removeVerticesData = function (kind) {
  83067. if (this._vertexBuffers[kind]) {
  83068. this._vertexBuffers[kind].dispose();
  83069. delete this._vertexBuffers[kind];
  83070. }
  83071. };
  83072. /**
  83073. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  83074. * @param buffer defines the vertex buffer to use
  83075. * @param totalVertices defines the total number of vertices for position kind (could be null)
  83076. */
  83077. Geometry.prototype.setVerticesBuffer = function (buffer, totalVertices) {
  83078. if (totalVertices === void 0) { totalVertices = null; }
  83079. var kind = buffer.getKind();
  83080. if (this._vertexBuffers[kind]) {
  83081. this._vertexBuffers[kind].dispose();
  83082. }
  83083. this._vertexBuffers[kind] = buffer;
  83084. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) {
  83085. var data = buffer.getData();
  83086. if (totalVertices != null) {
  83087. this._totalVertices = totalVertices;
  83088. }
  83089. else {
  83090. if (data != null) {
  83091. this._totalVertices = data.length / (buffer.byteStride / 4);
  83092. }
  83093. }
  83094. this._updateExtend(data);
  83095. this._resetPointsArrayCache();
  83096. var meshes = this._meshes;
  83097. var numOfMeshes = meshes.length;
  83098. for (var index = 0; index < numOfMeshes; index++) {
  83099. var mesh = meshes[index];
  83100. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  83101. mesh._createGlobalSubMesh(false);
  83102. mesh.computeWorldMatrix(true);
  83103. }
  83104. }
  83105. this.notifyUpdate(kind);
  83106. if (this._vertexArrayObjects) {
  83107. this._disposeVertexArrayObjects();
  83108. this._vertexArrayObjects = {}; // Will trigger a rebuild of the VAO if supported
  83109. }
  83110. };
  83111. /**
  83112. * Update a specific vertex buffer
  83113. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  83114. * It will do nothing if the buffer is not updatable
  83115. * @param kind defines the data kind (Position, normal, etc...)
  83116. * @param data defines the data to use
  83117. * @param offset defines the offset in the target buffer where to store the data
  83118. * @param useBytes set to true if the offset is in bytes
  83119. */
  83120. Geometry.prototype.updateVerticesDataDirectly = function (kind, data, offset, useBytes) {
  83121. if (useBytes === void 0) { useBytes = false; }
  83122. var vertexBuffer = this.getVertexBuffer(kind);
  83123. if (!vertexBuffer) {
  83124. return;
  83125. }
  83126. vertexBuffer.updateDirectly(data, offset, useBytes);
  83127. this.notifyUpdate(kind);
  83128. };
  83129. /**
  83130. * Update a specific vertex buffer
  83131. * This function will create a new buffer if the current one is not updatable
  83132. * @param kind defines the data kind (Position, normal, etc...)
  83133. * @param data defines the data to use
  83134. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  83135. */
  83136. Geometry.prototype.updateVerticesData = function (kind, data, updateExtends) {
  83137. if (updateExtends === void 0) { updateExtends = false; }
  83138. var vertexBuffer = this.getVertexBuffer(kind);
  83139. if (!vertexBuffer) {
  83140. return;
  83141. }
  83142. vertexBuffer.update(data);
  83143. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) {
  83144. this._updateBoundingInfo(updateExtends, data);
  83145. }
  83146. this.notifyUpdate(kind);
  83147. };
  83148. Geometry.prototype._updateBoundingInfo = function (updateExtends, data) {
  83149. if (updateExtends) {
  83150. this._updateExtend(data);
  83151. }
  83152. this._resetPointsArrayCache();
  83153. if (updateExtends) {
  83154. var meshes = this._meshes;
  83155. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  83156. var mesh = meshes_1[_i];
  83157. if (mesh._boundingInfo) {
  83158. mesh._boundingInfo.reConstruct(this._extend.minimum, this._extend.maximum);
  83159. }
  83160. else {
  83161. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  83162. }
  83163. var subMeshes = mesh.subMeshes;
  83164. for (var _a = 0, subMeshes_1 = subMeshes; _a < subMeshes_1.length; _a++) {
  83165. var subMesh = subMeshes_1[_a];
  83166. subMesh.refreshBoundingInfo();
  83167. }
  83168. }
  83169. }
  83170. };
  83171. /** @hidden */
  83172. Geometry.prototype._bind = function (effect, indexToBind) {
  83173. if (!effect) {
  83174. return;
  83175. }
  83176. if (indexToBind === undefined) {
  83177. indexToBind = this._indexBuffer;
  83178. }
  83179. var vbs = this.getVertexBuffers();
  83180. if (!vbs) {
  83181. return;
  83182. }
  83183. if (indexToBind != this._indexBuffer || !this._vertexArrayObjects) {
  83184. this._engine.bindBuffers(vbs, indexToBind, effect);
  83185. return;
  83186. }
  83187. // Using VAO
  83188. if (!this._vertexArrayObjects[effect.key]) {
  83189. this._vertexArrayObjects[effect.key] = this._engine.recordVertexArrayObject(vbs, indexToBind, effect);
  83190. }
  83191. this._engine.bindVertexArrayObject(this._vertexArrayObjects[effect.key], indexToBind);
  83192. };
  83193. /**
  83194. * Gets total number of vertices
  83195. * @returns the total number of vertices
  83196. */
  83197. Geometry.prototype.getTotalVertices = function () {
  83198. if (!this.isReady()) {
  83199. return 0;
  83200. }
  83201. return this._totalVertices;
  83202. };
  83203. /**
  83204. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  83205. * @param kind defines the data kind (Position, normal, etc...)
  83206. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  83207. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  83208. * @returns a float array containing vertex data
  83209. */
  83210. Geometry.prototype.getVerticesData = function (kind, copyWhenShared, forceCopy) {
  83211. var vertexBuffer = this.getVertexBuffer(kind);
  83212. if (!vertexBuffer) {
  83213. return null;
  83214. }
  83215. var data = vertexBuffer.getData();
  83216. if (!data) {
  83217. return null;
  83218. }
  83219. var tightlyPackedByteStride = vertexBuffer.getSize() * _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].GetTypeByteLength(vertexBuffer.type);
  83220. var count = this._totalVertices * vertexBuffer.getSize();
  83221. if (vertexBuffer.type !== _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].FLOAT || vertexBuffer.byteStride !== tightlyPackedByteStride) {
  83222. var copy_1 = [];
  83223. vertexBuffer.forEach(count, function (value) { return copy_1.push(value); });
  83224. return copy_1;
  83225. }
  83226. if (!((data instanceof Array) || (data instanceof Float32Array)) || vertexBuffer.byteOffset !== 0 || data.length !== count) {
  83227. if (data instanceof Array) {
  83228. var offset = vertexBuffer.byteOffset / 4;
  83229. return _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].Slice(data, offset, offset + count);
  83230. }
  83231. else if (data instanceof ArrayBuffer) {
  83232. return new Float32Array(data, vertexBuffer.byteOffset, count);
  83233. }
  83234. else {
  83235. var offset = data.byteOffset + vertexBuffer.byteOffset;
  83236. if (forceCopy || (copyWhenShared && this._meshes.length !== 1)) {
  83237. var result = new Float32Array(count);
  83238. var source = new Float32Array(data.buffer, offset, count);
  83239. result.set(source);
  83240. return result;
  83241. }
  83242. return new Float32Array(data.buffer, offset, count);
  83243. }
  83244. }
  83245. if (forceCopy || (copyWhenShared && this._meshes.length !== 1)) {
  83246. return _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].Slice(data);
  83247. }
  83248. return data;
  83249. };
  83250. /**
  83251. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  83252. * @param kind defines the data kind (Position, normal, etc...)
  83253. * @returns true if the vertex buffer with the specified kind is updatable
  83254. */
  83255. Geometry.prototype.isVertexBufferUpdatable = function (kind) {
  83256. var vb = this._vertexBuffers[kind];
  83257. if (!vb) {
  83258. return false;
  83259. }
  83260. return vb.isUpdatable();
  83261. };
  83262. /**
  83263. * Gets a specific vertex buffer
  83264. * @param kind defines the data kind (Position, normal, etc...)
  83265. * @returns a VertexBuffer
  83266. */
  83267. Geometry.prototype.getVertexBuffer = function (kind) {
  83268. if (!this.isReady()) {
  83269. return null;
  83270. }
  83271. return this._vertexBuffers[kind];
  83272. };
  83273. /**
  83274. * Returns all vertex buffers
  83275. * @return an object holding all vertex buffers indexed by kind
  83276. */
  83277. Geometry.prototype.getVertexBuffers = function () {
  83278. if (!this.isReady()) {
  83279. return null;
  83280. }
  83281. return this._vertexBuffers;
  83282. };
  83283. /**
  83284. * Gets a boolean indicating if specific vertex buffer is present
  83285. * @param kind defines the data kind (Position, normal, etc...)
  83286. * @returns true if data is present
  83287. */
  83288. Geometry.prototype.isVerticesDataPresent = function (kind) {
  83289. if (!this._vertexBuffers) {
  83290. if (this._delayInfo) {
  83291. return this._delayInfo.indexOf(kind) !== -1;
  83292. }
  83293. return false;
  83294. }
  83295. return this._vertexBuffers[kind] !== undefined;
  83296. };
  83297. /**
  83298. * Gets a list of all attached data kinds (Position, normal, etc...)
  83299. * @returns a list of string containing all kinds
  83300. */
  83301. Geometry.prototype.getVerticesDataKinds = function () {
  83302. var result = [];
  83303. var kind;
  83304. if (!this._vertexBuffers && this._delayInfo) {
  83305. for (kind in this._delayInfo) {
  83306. result.push(kind);
  83307. }
  83308. }
  83309. else {
  83310. for (kind in this._vertexBuffers) {
  83311. result.push(kind);
  83312. }
  83313. }
  83314. return result;
  83315. };
  83316. /**
  83317. * Update index buffer
  83318. * @param indices defines the indices to store in the index buffer
  83319. * @param offset defines the offset in the target buffer where to store the data
  83320. */
  83321. Geometry.prototype.updateIndices = function (indices, offset) {
  83322. if (!this._indexBuffer) {
  83323. return;
  83324. }
  83325. if (!this._indexBufferIsUpdatable) {
  83326. this.setIndices(indices, null, true);
  83327. }
  83328. else {
  83329. var needToUpdateSubMeshes = indices.length !== this._indices.length;
  83330. this._indices = indices;
  83331. this._engine.updateDynamicIndexBuffer(this._indexBuffer, indices, offset);
  83332. if (needToUpdateSubMeshes) {
  83333. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  83334. var mesh = _a[_i];
  83335. mesh._createGlobalSubMesh(true);
  83336. }
  83337. }
  83338. }
  83339. };
  83340. /**
  83341. * Creates a new index buffer
  83342. * @param indices defines the indices to store in the index buffer
  83343. * @param totalVertices defines the total number of vertices (could be null)
  83344. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  83345. */
  83346. Geometry.prototype.setIndices = function (indices, totalVertices, updatable) {
  83347. if (totalVertices === void 0) { totalVertices = null; }
  83348. if (updatable === void 0) { updatable = false; }
  83349. if (this._indexBuffer) {
  83350. this._engine._releaseBuffer(this._indexBuffer);
  83351. }
  83352. this._disposeVertexArrayObjects();
  83353. this._indices = indices;
  83354. this._indexBufferIsUpdatable = updatable;
  83355. if (this._meshes.length !== 0 && this._indices) {
  83356. this._indexBuffer = this._engine.createIndexBuffer(this._indices, updatable);
  83357. }
  83358. if (totalVertices != undefined) { // including null and undefined
  83359. this._totalVertices = totalVertices;
  83360. }
  83361. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  83362. var mesh = _a[_i];
  83363. mesh._createGlobalSubMesh(true);
  83364. }
  83365. this.notifyUpdate();
  83366. };
  83367. /**
  83368. * Return the total number of indices
  83369. * @returns the total number of indices
  83370. */
  83371. Geometry.prototype.getTotalIndices = function () {
  83372. if (!this.isReady()) {
  83373. return 0;
  83374. }
  83375. return this._indices.length;
  83376. };
  83377. /**
  83378. * Gets the index buffer array
  83379. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  83380. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  83381. * @returns the index buffer array
  83382. */
  83383. Geometry.prototype.getIndices = function (copyWhenShared, forceCopy) {
  83384. if (!this.isReady()) {
  83385. return null;
  83386. }
  83387. var orig = this._indices;
  83388. if (!forceCopy && (!copyWhenShared || this._meshes.length === 1)) {
  83389. return orig;
  83390. }
  83391. else {
  83392. var len = orig.length;
  83393. var copy = [];
  83394. for (var i = 0; i < len; i++) {
  83395. copy.push(orig[i]);
  83396. }
  83397. return copy;
  83398. }
  83399. };
  83400. /**
  83401. * Gets the index buffer
  83402. * @return the index buffer
  83403. */
  83404. Geometry.prototype.getIndexBuffer = function () {
  83405. if (!this.isReady()) {
  83406. return null;
  83407. }
  83408. return this._indexBuffer;
  83409. };
  83410. /** @hidden */
  83411. Geometry.prototype._releaseVertexArrayObject = function (effect) {
  83412. if (effect === void 0) { effect = null; }
  83413. if (!effect || !this._vertexArrayObjects) {
  83414. return;
  83415. }
  83416. if (this._vertexArrayObjects[effect.key]) {
  83417. this._engine.releaseVertexArrayObject(this._vertexArrayObjects[effect.key]);
  83418. delete this._vertexArrayObjects[effect.key];
  83419. }
  83420. };
  83421. /**
  83422. * Release the associated resources for a specific mesh
  83423. * @param mesh defines the source mesh
  83424. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  83425. */
  83426. Geometry.prototype.releaseForMesh = function (mesh, shouldDispose) {
  83427. var meshes = this._meshes;
  83428. var index = meshes.indexOf(mesh);
  83429. if (index === -1) {
  83430. return;
  83431. }
  83432. meshes.splice(index, 1);
  83433. mesh._geometry = null;
  83434. if (meshes.length === 0 && shouldDispose) {
  83435. this.dispose();
  83436. }
  83437. };
  83438. /**
  83439. * Apply current geometry to a given mesh
  83440. * @param mesh defines the mesh to apply geometry to
  83441. */
  83442. Geometry.prototype.applyToMesh = function (mesh) {
  83443. if (mesh._geometry === this) {
  83444. return;
  83445. }
  83446. var previousGeometry = mesh._geometry;
  83447. if (previousGeometry) {
  83448. previousGeometry.releaseForMesh(mesh);
  83449. }
  83450. var meshes = this._meshes;
  83451. // must be done before setting vertexBuffers because of mesh._createGlobalSubMesh()
  83452. mesh._geometry = this;
  83453. this._scene.pushGeometry(this);
  83454. meshes.push(mesh);
  83455. if (this.isReady()) {
  83456. this._applyToMesh(mesh);
  83457. }
  83458. else {
  83459. mesh._boundingInfo = this._boundingInfo;
  83460. }
  83461. };
  83462. Geometry.prototype._updateExtend = function (data) {
  83463. if (data === void 0) { data = null; }
  83464. if (!data) {
  83465. data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  83466. }
  83467. this._extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].ExtractMinAndMax(data, 0, this._totalVertices, this.boundingBias, 3);
  83468. };
  83469. Geometry.prototype._applyToMesh = function (mesh) {
  83470. var numOfMeshes = this._meshes.length;
  83471. // vertexBuffers
  83472. for (var kind in this._vertexBuffers) {
  83473. if (numOfMeshes === 1) {
  83474. this._vertexBuffers[kind].create();
  83475. }
  83476. var buffer = this._vertexBuffers[kind].getBuffer();
  83477. if (buffer) {
  83478. buffer.references = numOfMeshes;
  83479. }
  83480. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) {
  83481. if (!this._extend) {
  83482. this._updateExtend();
  83483. }
  83484. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  83485. mesh._createGlobalSubMesh(false);
  83486. //bounding info was just created again, world matrix should be applied again.
  83487. mesh._updateBoundingInfo();
  83488. }
  83489. }
  83490. // indexBuffer
  83491. if (numOfMeshes === 1 && this._indices && this._indices.length > 0) {
  83492. this._indexBuffer = this._engine.createIndexBuffer(this._indices);
  83493. }
  83494. if (this._indexBuffer) {
  83495. this._indexBuffer.references = numOfMeshes;
  83496. }
  83497. // morphTargets
  83498. mesh._syncGeometryWithMorphTargetManager();
  83499. // instances
  83500. mesh.synchronizeInstances();
  83501. };
  83502. Geometry.prototype.notifyUpdate = function (kind) {
  83503. if (this.onGeometryUpdated) {
  83504. this.onGeometryUpdated(this, kind);
  83505. }
  83506. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  83507. var mesh = _a[_i];
  83508. mesh._markSubMeshesAsAttributesDirty();
  83509. }
  83510. };
  83511. /**
  83512. * Load the geometry if it was flagged as delay loaded
  83513. * @param scene defines the hosting scene
  83514. * @param onLoaded defines a callback called when the geometry is loaded
  83515. */
  83516. Geometry.prototype.load = function (scene, onLoaded) {
  83517. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADING) {
  83518. return;
  83519. }
  83520. if (this.isReady()) {
  83521. if (onLoaded) {
  83522. onLoaded();
  83523. }
  83524. return;
  83525. }
  83526. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADING;
  83527. this._queueLoad(scene, onLoaded);
  83528. };
  83529. Geometry.prototype._queueLoad = function (scene, onLoaded) {
  83530. var _this = this;
  83531. if (!this.delayLoadingFile) {
  83532. return;
  83533. }
  83534. scene._addPendingData(this);
  83535. scene._loadFile(this.delayLoadingFile, function (data) {
  83536. if (!_this._delayLoadingFunction) {
  83537. return;
  83538. }
  83539. _this._delayLoadingFunction(JSON.parse(data), _this);
  83540. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  83541. _this._delayInfo = [];
  83542. scene._removePendingData(_this);
  83543. var meshes = _this._meshes;
  83544. var numOfMeshes = meshes.length;
  83545. for (var index = 0; index < numOfMeshes; index++) {
  83546. _this._applyToMesh(meshes[index]);
  83547. }
  83548. if (onLoaded) {
  83549. onLoaded();
  83550. }
  83551. }, undefined, true);
  83552. };
  83553. /**
  83554. * Invert the geometry to move from a right handed system to a left handed one.
  83555. */
  83556. Geometry.prototype.toLeftHanded = function () {
  83557. // Flip faces
  83558. var tIndices = this.getIndices(false);
  83559. if (tIndices != null && tIndices.length > 0) {
  83560. for (var i = 0; i < tIndices.length; i += 3) {
  83561. var tTemp = tIndices[i + 0];
  83562. tIndices[i + 0] = tIndices[i + 2];
  83563. tIndices[i + 2] = tTemp;
  83564. }
  83565. this.setIndices(tIndices);
  83566. }
  83567. // Negate position.z
  83568. var tPositions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, false);
  83569. if (tPositions != null && tPositions.length > 0) {
  83570. for (var i = 0; i < tPositions.length; i += 3) {
  83571. tPositions[i + 2] = -tPositions[i + 2];
  83572. }
  83573. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, tPositions, false);
  83574. }
  83575. // Negate normal.z
  83576. var tNormals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, false);
  83577. if (tNormals != null && tNormals.length > 0) {
  83578. for (var i = 0; i < tNormals.length; i += 3) {
  83579. tNormals[i + 2] = -tNormals[i + 2];
  83580. }
  83581. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, tNormals, false);
  83582. }
  83583. };
  83584. // Cache
  83585. /** @hidden */
  83586. Geometry.prototype._resetPointsArrayCache = function () {
  83587. this._positions = null;
  83588. };
  83589. /** @hidden */
  83590. Geometry.prototype._generatePointsArray = function () {
  83591. if (this._positions) {
  83592. return true;
  83593. }
  83594. var data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  83595. if (!data || data.length === 0) {
  83596. return false;
  83597. }
  83598. this._positions = [];
  83599. for (var index = 0; index < data.length; index += 3) {
  83600. this._positions.push(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(data, index));
  83601. }
  83602. return true;
  83603. };
  83604. /**
  83605. * Gets a value indicating if the geometry is disposed
  83606. * @returns true if the geometry was disposed
  83607. */
  83608. Geometry.prototype.isDisposed = function () {
  83609. return this._isDisposed;
  83610. };
  83611. Geometry.prototype._disposeVertexArrayObjects = function () {
  83612. if (this._vertexArrayObjects) {
  83613. for (var kind in this._vertexArrayObjects) {
  83614. this._engine.releaseVertexArrayObject(this._vertexArrayObjects[kind]);
  83615. }
  83616. this._vertexArrayObjects = {};
  83617. }
  83618. };
  83619. /**
  83620. * Free all associated resources
  83621. */
  83622. Geometry.prototype.dispose = function () {
  83623. var meshes = this._meshes;
  83624. var numOfMeshes = meshes.length;
  83625. var index;
  83626. for (index = 0; index < numOfMeshes; index++) {
  83627. this.releaseForMesh(meshes[index]);
  83628. }
  83629. this._meshes = [];
  83630. this._disposeVertexArrayObjects();
  83631. for (var kind in this._vertexBuffers) {
  83632. this._vertexBuffers[kind].dispose();
  83633. }
  83634. this._vertexBuffers = {};
  83635. this._totalVertices = 0;
  83636. if (this._indexBuffer) {
  83637. this._engine._releaseBuffer(this._indexBuffer);
  83638. }
  83639. this._indexBuffer = null;
  83640. this._indices = [];
  83641. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  83642. this.delayLoadingFile = null;
  83643. this._delayLoadingFunction = null;
  83644. this._delayInfo = [];
  83645. this._boundingInfo = null;
  83646. this._scene.removeGeometry(this);
  83647. this._isDisposed = true;
  83648. };
  83649. /**
  83650. * Clone the current geometry into a new geometry
  83651. * @param id defines the unique ID of the new geometry
  83652. * @returns a new geometry object
  83653. */
  83654. Geometry.prototype.copy = function (id) {
  83655. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  83656. vertexData.indices = [];
  83657. var indices = this.getIndices();
  83658. if (indices) {
  83659. for (var index = 0; index < indices.length; index++) {
  83660. vertexData.indices.push(indices[index]);
  83661. }
  83662. }
  83663. var updatable = false;
  83664. var stopChecking = false;
  83665. var kind;
  83666. for (kind in this._vertexBuffers) {
  83667. // using slice() to make a copy of the array and not just reference it
  83668. var data = this.getVerticesData(kind);
  83669. if (data) {
  83670. if (data instanceof Float32Array) {
  83671. vertexData.set(new Float32Array(data), kind);
  83672. }
  83673. else {
  83674. vertexData.set(data.slice(0), kind);
  83675. }
  83676. if (!stopChecking) {
  83677. var vb = this.getVertexBuffer(kind);
  83678. if (vb) {
  83679. updatable = vb.isUpdatable();
  83680. stopChecking = !updatable;
  83681. }
  83682. }
  83683. }
  83684. }
  83685. var geometry = new Geometry(id, this._scene, vertexData, updatable);
  83686. geometry.delayLoadState = this.delayLoadState;
  83687. geometry.delayLoadingFile = this.delayLoadingFile;
  83688. geometry._delayLoadingFunction = this._delayLoadingFunction;
  83689. for (kind in this._delayInfo) {
  83690. geometry._delayInfo = geometry._delayInfo || [];
  83691. geometry._delayInfo.push(kind);
  83692. }
  83693. // Bounding info
  83694. geometry._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  83695. return geometry;
  83696. };
  83697. /**
  83698. * Serialize the current geometry info (and not the vertices data) into a JSON object
  83699. * @return a JSON representation of the current geometry data (without the vertices data)
  83700. */
  83701. Geometry.prototype.serialize = function () {
  83702. var serializationObject = {};
  83703. serializationObject.id = this.id;
  83704. serializationObject.updatable = this._updatable;
  83705. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"].HasTags(this)) {
  83706. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"].GetTags(this);
  83707. }
  83708. return serializationObject;
  83709. };
  83710. Geometry.prototype.toNumberArray = function (origin) {
  83711. if (Array.isArray(origin)) {
  83712. return origin;
  83713. }
  83714. else {
  83715. return Array.prototype.slice.call(origin);
  83716. }
  83717. };
  83718. /**
  83719. * Serialize all vertices data into a JSON oject
  83720. * @returns a JSON representation of the current geometry data
  83721. */
  83722. Geometry.prototype.serializeVerticeData = function () {
  83723. var serializationObject = this.serialize();
  83724. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind)) {
  83725. serializationObject.positions = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind));
  83726. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind)) {
  83727. serializationObject.positions._updatable = true;
  83728. }
  83729. }
  83730. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  83731. serializationObject.normals = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind));
  83732. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  83733. serializationObject.normals._updatable = true;
  83734. }
  83735. }
  83736. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind)) {
  83737. serializationObject.tangets = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind));
  83738. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind)) {
  83739. serializationObject.tangets._updatable = true;
  83740. }
  83741. }
  83742. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  83743. serializationObject.uvs = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind));
  83744. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  83745. serializationObject.uvs._updatable = true;
  83746. }
  83747. }
  83748. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  83749. serializationObject.uv2s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind));
  83750. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  83751. serializationObject.uv2s._updatable = true;
  83752. }
  83753. }
  83754. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind)) {
  83755. serializationObject.uv3s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind));
  83756. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind)) {
  83757. serializationObject.uv3s._updatable = true;
  83758. }
  83759. }
  83760. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind)) {
  83761. serializationObject.uv4s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind));
  83762. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind)) {
  83763. serializationObject.uv4s._updatable = true;
  83764. }
  83765. }
  83766. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind)) {
  83767. serializationObject.uv5s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind));
  83768. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind)) {
  83769. serializationObject.uv5s._updatable = true;
  83770. }
  83771. }
  83772. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind)) {
  83773. serializationObject.uv6s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind));
  83774. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind)) {
  83775. serializationObject.uv6s._updatable = true;
  83776. }
  83777. }
  83778. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind)) {
  83779. serializationObject.colors = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind));
  83780. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind)) {
  83781. serializationObject.colors._updatable = true;
  83782. }
  83783. }
  83784. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind)) {
  83785. serializationObject.matricesIndices = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind));
  83786. serializationObject.matricesIndices._isExpanded = true;
  83787. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind)) {
  83788. serializationObject.matricesIndices._updatable = true;
  83789. }
  83790. }
  83791. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind)) {
  83792. serializationObject.matricesWeights = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind));
  83793. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind)) {
  83794. serializationObject.matricesWeights._updatable = true;
  83795. }
  83796. }
  83797. serializationObject.indices = this.toNumberArray(this.getIndices());
  83798. return serializationObject;
  83799. };
  83800. // Statics
  83801. /**
  83802. * Extracts a clone of a mesh geometry
  83803. * @param mesh defines the source mesh
  83804. * @param id defines the unique ID of the new geometry object
  83805. * @returns the new geometry object
  83806. */
  83807. Geometry.ExtractFromMesh = function (mesh, id) {
  83808. var geometry = mesh._geometry;
  83809. if (!geometry) {
  83810. return null;
  83811. }
  83812. return geometry.copy(id);
  83813. };
  83814. /**
  83815. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  83816. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  83817. * Be aware Math.random() could cause collisions, but:
  83818. * "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"
  83819. * @returns a string containing a new GUID
  83820. */
  83821. Geometry.RandomId = function () {
  83822. return _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].RandomId();
  83823. };
  83824. /** @hidden */
  83825. Geometry._ImportGeometry = function (parsedGeometry, mesh) {
  83826. var scene = mesh.getScene();
  83827. // Geometry
  83828. var geometryId = parsedGeometry.geometryId;
  83829. if (geometryId) {
  83830. var geometry = scene.getGeometryByID(geometryId);
  83831. if (geometry) {
  83832. geometry.applyToMesh(mesh);
  83833. }
  83834. }
  83835. else if (parsedGeometry instanceof ArrayBuffer) {
  83836. var binaryInfo = mesh._binaryInfo;
  83837. if (binaryInfo.positionsAttrDesc && binaryInfo.positionsAttrDesc.count > 0) {
  83838. var positionsData = new Float32Array(parsedGeometry, binaryInfo.positionsAttrDesc.offset, binaryInfo.positionsAttrDesc.count);
  83839. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, positionsData, false);
  83840. }
  83841. if (binaryInfo.normalsAttrDesc && binaryInfo.normalsAttrDesc.count > 0) {
  83842. var normalsData = new Float32Array(parsedGeometry, binaryInfo.normalsAttrDesc.offset, binaryInfo.normalsAttrDesc.count);
  83843. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, normalsData, false);
  83844. }
  83845. if (binaryInfo.tangetsAttrDesc && binaryInfo.tangetsAttrDesc.count > 0) {
  83846. var tangentsData = new Float32Array(parsedGeometry, binaryInfo.tangetsAttrDesc.offset, binaryInfo.tangetsAttrDesc.count);
  83847. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind, tangentsData, false);
  83848. }
  83849. if (binaryInfo.uvsAttrDesc && binaryInfo.uvsAttrDesc.count > 0) {
  83850. var uvsData = new Float32Array(parsedGeometry, binaryInfo.uvsAttrDesc.offset, binaryInfo.uvsAttrDesc.count);
  83851. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, uvsData, false);
  83852. }
  83853. if (binaryInfo.uvs2AttrDesc && binaryInfo.uvs2AttrDesc.count > 0) {
  83854. var uvs2Data = new Float32Array(parsedGeometry, binaryInfo.uvs2AttrDesc.offset, binaryInfo.uvs2AttrDesc.count);
  83855. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind, uvs2Data, false);
  83856. }
  83857. if (binaryInfo.uvs3AttrDesc && binaryInfo.uvs3AttrDesc.count > 0) {
  83858. var uvs3Data = new Float32Array(parsedGeometry, binaryInfo.uvs3AttrDesc.offset, binaryInfo.uvs3AttrDesc.count);
  83859. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind, uvs3Data, false);
  83860. }
  83861. if (binaryInfo.uvs4AttrDesc && binaryInfo.uvs4AttrDesc.count > 0) {
  83862. var uvs4Data = new Float32Array(parsedGeometry, binaryInfo.uvs4AttrDesc.offset, binaryInfo.uvs4AttrDesc.count);
  83863. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind, uvs4Data, false);
  83864. }
  83865. if (binaryInfo.uvs5AttrDesc && binaryInfo.uvs5AttrDesc.count > 0) {
  83866. var uvs5Data = new Float32Array(parsedGeometry, binaryInfo.uvs5AttrDesc.offset, binaryInfo.uvs5AttrDesc.count);
  83867. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind, uvs5Data, false);
  83868. }
  83869. if (binaryInfo.uvs6AttrDesc && binaryInfo.uvs6AttrDesc.count > 0) {
  83870. var uvs6Data = new Float32Array(parsedGeometry, binaryInfo.uvs6AttrDesc.offset, binaryInfo.uvs6AttrDesc.count);
  83871. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind, uvs6Data, false);
  83872. }
  83873. if (binaryInfo.colorsAttrDesc && binaryInfo.colorsAttrDesc.count > 0) {
  83874. var colorsData = new Float32Array(parsedGeometry, binaryInfo.colorsAttrDesc.offset, binaryInfo.colorsAttrDesc.count);
  83875. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, colorsData, false, binaryInfo.colorsAttrDesc.stride);
  83876. }
  83877. if (binaryInfo.matricesIndicesAttrDesc && binaryInfo.matricesIndicesAttrDesc.count > 0) {
  83878. var matricesIndicesData = new Int32Array(parsedGeometry, binaryInfo.matricesIndicesAttrDesc.offset, binaryInfo.matricesIndicesAttrDesc.count);
  83879. var floatIndices = [];
  83880. for (var i = 0; i < matricesIndicesData.length; i++) {
  83881. var index = matricesIndicesData[i];
  83882. floatIndices.push(index & 0x000000FF);
  83883. floatIndices.push((index & 0x0000FF00) >> 8);
  83884. floatIndices.push((index & 0x00FF0000) >> 16);
  83885. floatIndices.push(index >> 24);
  83886. }
  83887. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, floatIndices, false);
  83888. }
  83889. if (binaryInfo.matricesWeightsAttrDesc && binaryInfo.matricesWeightsAttrDesc.count > 0) {
  83890. var matricesWeightsData = new Float32Array(parsedGeometry, binaryInfo.matricesWeightsAttrDesc.offset, binaryInfo.matricesWeightsAttrDesc.count);
  83891. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind, matricesWeightsData, false);
  83892. }
  83893. if (binaryInfo.indicesAttrDesc && binaryInfo.indicesAttrDesc.count > 0) {
  83894. var indicesData = new Int32Array(parsedGeometry, binaryInfo.indicesAttrDesc.offset, binaryInfo.indicesAttrDesc.count);
  83895. mesh.setIndices(indicesData, null);
  83896. }
  83897. if (binaryInfo.subMeshesAttrDesc && binaryInfo.subMeshesAttrDesc.count > 0) {
  83898. var subMeshesData = new Int32Array(parsedGeometry, binaryInfo.subMeshesAttrDesc.offset, binaryInfo.subMeshesAttrDesc.count * 5);
  83899. mesh.subMeshes = [];
  83900. for (var i = 0; i < binaryInfo.subMeshesAttrDesc.count; i++) {
  83901. var materialIndex = subMeshesData[(i * 5) + 0];
  83902. var verticesStart = subMeshesData[(i * 5) + 1];
  83903. var verticesCount = subMeshesData[(i * 5) + 2];
  83904. var indexStart = subMeshesData[(i * 5) + 3];
  83905. var indexCount = subMeshesData[(i * 5) + 4];
  83906. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_3__["SubMesh"].AddToMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh);
  83907. }
  83908. }
  83909. }
  83910. else if (parsedGeometry.positions && parsedGeometry.normals && parsedGeometry.indices) {
  83911. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, parsedGeometry.positions, parsedGeometry.positions._updatable);
  83912. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, parsedGeometry.normals, parsedGeometry.normals._updatable);
  83913. if (parsedGeometry.tangents) {
  83914. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind, parsedGeometry.tangents, parsedGeometry.tangents._updatable);
  83915. }
  83916. if (parsedGeometry.uvs) {
  83917. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, parsedGeometry.uvs, parsedGeometry.uvs._updatable);
  83918. }
  83919. if (parsedGeometry.uvs2) {
  83920. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind, parsedGeometry.uvs2, parsedGeometry.uvs2._updatable);
  83921. }
  83922. if (parsedGeometry.uvs3) {
  83923. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind, parsedGeometry.uvs3, parsedGeometry.uvs3._updatable);
  83924. }
  83925. if (parsedGeometry.uvs4) {
  83926. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind, parsedGeometry.uvs4, parsedGeometry.uvs4._updatable);
  83927. }
  83928. if (parsedGeometry.uvs5) {
  83929. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind, parsedGeometry.uvs5, parsedGeometry.uvs5._updatable);
  83930. }
  83931. if (parsedGeometry.uvs6) {
  83932. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind, parsedGeometry.uvs6, parsedGeometry.uvs6._updatable);
  83933. }
  83934. if (parsedGeometry.colors) {
  83935. 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);
  83936. }
  83937. if (parsedGeometry.matricesIndices) {
  83938. if (!parsedGeometry.matricesIndices._isExpanded) {
  83939. var floatIndices = [];
  83940. for (var i = 0; i < parsedGeometry.matricesIndices.length; i++) {
  83941. var matricesIndex = parsedGeometry.matricesIndices[i];
  83942. floatIndices.push(matricesIndex & 0x000000FF);
  83943. floatIndices.push((matricesIndex & 0x0000FF00) >> 8);
  83944. floatIndices.push((matricesIndex & 0x00FF0000) >> 16);
  83945. floatIndices.push(matricesIndex >> 24);
  83946. }
  83947. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, floatIndices, parsedGeometry.matricesIndices._updatable);
  83948. }
  83949. else {
  83950. delete parsedGeometry.matricesIndices._isExpanded;
  83951. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, parsedGeometry.matricesIndices, parsedGeometry.matricesIndices._updatable);
  83952. }
  83953. }
  83954. if (parsedGeometry.matricesIndicesExtra) {
  83955. if (!parsedGeometry.matricesIndicesExtra._isExpanded) {
  83956. var floatIndices = [];
  83957. for (var i = 0; i < parsedGeometry.matricesIndicesExtra.length; i++) {
  83958. var matricesIndex = parsedGeometry.matricesIndicesExtra[i];
  83959. floatIndices.push(matricesIndex & 0x000000FF);
  83960. floatIndices.push((matricesIndex & 0x0000FF00) >> 8);
  83961. floatIndices.push((matricesIndex & 0x00FF0000) >> 16);
  83962. floatIndices.push(matricesIndex >> 24);
  83963. }
  83964. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind, floatIndices, parsedGeometry.matricesIndicesExtra._updatable);
  83965. }
  83966. else {
  83967. delete parsedGeometry.matricesIndices._isExpanded;
  83968. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind, parsedGeometry.matricesIndicesExtra, parsedGeometry.matricesIndicesExtra._updatable);
  83969. }
  83970. }
  83971. if (parsedGeometry.matricesWeights) {
  83972. Geometry._CleanMatricesWeights(parsedGeometry, mesh);
  83973. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind, parsedGeometry.matricesWeights, parsedGeometry.matricesWeights._updatable);
  83974. }
  83975. if (parsedGeometry.matricesWeightsExtra) {
  83976. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsExtraKind, parsedGeometry.matricesWeightsExtra, parsedGeometry.matricesWeights._updatable);
  83977. }
  83978. mesh.setIndices(parsedGeometry.indices, null);
  83979. }
  83980. // SubMeshes
  83981. if (parsedGeometry.subMeshes) {
  83982. mesh.subMeshes = [];
  83983. for (var subIndex = 0; subIndex < parsedGeometry.subMeshes.length; subIndex++) {
  83984. var parsedSubMesh = parsedGeometry.subMeshes[subIndex];
  83985. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_3__["SubMesh"].AddToMesh(parsedSubMesh.materialIndex, parsedSubMesh.verticesStart, parsedSubMesh.verticesCount, parsedSubMesh.indexStart, parsedSubMesh.indexCount, mesh);
  83986. }
  83987. }
  83988. // Flat shading
  83989. if (mesh._shouldGenerateFlatShading) {
  83990. mesh.convertToFlatShadedMesh();
  83991. delete mesh._shouldGenerateFlatShading;
  83992. }
  83993. // Update
  83994. mesh.computeWorldMatrix(true);
  83995. scene.onMeshImportedObservable.notifyObservers(mesh);
  83996. };
  83997. Geometry._CleanMatricesWeights = function (parsedGeometry, mesh) {
  83998. var epsilon = 1e-3;
  83999. if (!_Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_4__["SceneLoaderFlags"].CleanBoneMatrixWeights) {
  84000. return;
  84001. }
  84002. var noInfluenceBoneIndex = 0.0;
  84003. if (parsedGeometry.skeletonId > -1) {
  84004. var skeleton = mesh.getScene().getLastSkeletonByID(parsedGeometry.skeletonId);
  84005. if (!skeleton) {
  84006. return;
  84007. }
  84008. noInfluenceBoneIndex = skeleton.bones.length;
  84009. }
  84010. else {
  84011. return;
  84012. }
  84013. var matricesIndices = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  84014. var matricesIndicesExtra = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind);
  84015. var matricesWeights = parsedGeometry.matricesWeights;
  84016. var matricesWeightsExtra = parsedGeometry.matricesWeightsExtra;
  84017. var influencers = parsedGeometry.numBoneInfluencer;
  84018. var size = matricesWeights.length;
  84019. for (var i = 0; i < size; i += 4) {
  84020. var weight = 0.0;
  84021. var firstZeroWeight = -1;
  84022. for (var j = 0; j < 4; j++) {
  84023. var w = matricesWeights[i + j];
  84024. weight += w;
  84025. if (w < epsilon && firstZeroWeight < 0) {
  84026. firstZeroWeight = j;
  84027. }
  84028. }
  84029. if (matricesWeightsExtra) {
  84030. for (var j = 0; j < 4; j++) {
  84031. var w = matricesWeightsExtra[i + j];
  84032. weight += w;
  84033. if (w < epsilon && firstZeroWeight < 0) {
  84034. firstZeroWeight = j + 4;
  84035. }
  84036. }
  84037. }
  84038. if (firstZeroWeight < 0 || firstZeroWeight > (influencers - 1)) {
  84039. firstZeroWeight = influencers - 1;
  84040. }
  84041. if (weight > epsilon) {
  84042. var mweight = 1.0 / weight;
  84043. for (var j = 0; j < 4; j++) {
  84044. matricesWeights[i + j] *= mweight;
  84045. }
  84046. if (matricesWeightsExtra) {
  84047. for (var j = 0; j < 4; j++) {
  84048. matricesWeightsExtra[i + j] *= mweight;
  84049. }
  84050. }
  84051. }
  84052. else {
  84053. if (firstZeroWeight >= 4) {
  84054. matricesWeightsExtra[i + firstZeroWeight - 4] = 1.0 - weight;
  84055. matricesIndicesExtra[i + firstZeroWeight - 4] = noInfluenceBoneIndex;
  84056. }
  84057. else {
  84058. matricesWeights[i + firstZeroWeight] = 1.0 - weight;
  84059. matricesIndices[i + firstZeroWeight] = noInfluenceBoneIndex;
  84060. }
  84061. }
  84062. }
  84063. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, matricesIndices);
  84064. if (parsedGeometry.matricesWeightsExtra) {
  84065. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind, matricesIndicesExtra);
  84066. }
  84067. };
  84068. /**
  84069. * Create a new geometry from persisted data (Using .babylon file format)
  84070. * @param parsedVertexData defines the persisted data
  84071. * @param scene defines the hosting scene
  84072. * @param rootUrl defines the root url to use to load assets (like delayed data)
  84073. * @returns the new geometry object
  84074. */
  84075. Geometry.Parse = function (parsedVertexData, scene, rootUrl) {
  84076. if (scene.getGeometryByID(parsedVertexData.id)) {
  84077. return null; // null since geometry could be something else than a box...
  84078. }
  84079. var geometry = new Geometry(parsedVertexData.id, scene, undefined, parsedVertexData.updatable);
  84080. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"]) {
  84081. _Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"].AddTagsTo(geometry, parsedVertexData.tags);
  84082. }
  84083. if (parsedVertexData.delayLoadingFile) {
  84084. geometry.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  84085. geometry.delayLoadingFile = rootUrl + parsedVertexData.delayLoadingFile;
  84086. 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));
  84087. geometry._delayInfo = [];
  84088. if (parsedVertexData.hasUVs) {
  84089. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  84090. }
  84091. if (parsedVertexData.hasUVs2) {
  84092. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind);
  84093. }
  84094. if (parsedVertexData.hasUVs3) {
  84095. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind);
  84096. }
  84097. if (parsedVertexData.hasUVs4) {
  84098. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind);
  84099. }
  84100. if (parsedVertexData.hasUVs5) {
  84101. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind);
  84102. }
  84103. if (parsedVertexData.hasUVs6) {
  84104. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind);
  84105. }
  84106. if (parsedVertexData.hasColors) {
  84107. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  84108. }
  84109. if (parsedVertexData.hasMatricesIndices) {
  84110. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  84111. }
  84112. if (parsedVertexData.hasMatricesWeights) {
  84113. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind);
  84114. }
  84115. geometry._delayLoadingFunction = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ImportVertexData;
  84116. }
  84117. else {
  84118. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ImportVertexData(parsedVertexData, geometry);
  84119. }
  84120. scene.pushGeometry(geometry, true);
  84121. return geometry;
  84122. };
  84123. return Geometry;
  84124. }());
  84125. /***/ }),
  84126. /***/ "./Meshes/groundMesh.ts":
  84127. /*!******************************!*\
  84128. !*** ./Meshes/groundMesh.ts ***!
  84129. \******************************/
  84130. /*! exports provided: GroundMesh */
  84131. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  84132. "use strict";
  84133. __webpack_require__.r(__webpack_exports__);
  84134. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return GroundMesh; });
  84135. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  84136. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  84137. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  84138. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  84139. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]._GroundMeshParser = function (parsedMesh, scene) {
  84140. return GroundMesh.Parse(parsedMesh, scene);
  84141. };
  84142. /**
  84143. * Mesh representing the gorund
  84144. */
  84145. var GroundMesh = /** @class */ (function (_super) {
  84146. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GroundMesh, _super);
  84147. function GroundMesh(name, scene) {
  84148. var _this = _super.call(this, name, scene) || this;
  84149. /** If octree should be generated */
  84150. _this.generateOctree = false;
  84151. return _this;
  84152. }
  84153. /**
  84154. * "GroundMesh"
  84155. * @returns "GroundMesh"
  84156. */
  84157. GroundMesh.prototype.getClassName = function () {
  84158. return "GroundMesh";
  84159. };
  84160. Object.defineProperty(GroundMesh.prototype, "subdivisions", {
  84161. /**
  84162. * The minimum of x and y subdivisions
  84163. */
  84164. get: function () {
  84165. return Math.min(this._subdivisionsX, this._subdivisionsY);
  84166. },
  84167. enumerable: true,
  84168. configurable: true
  84169. });
  84170. Object.defineProperty(GroundMesh.prototype, "subdivisionsX", {
  84171. /**
  84172. * X subdivisions
  84173. */
  84174. get: function () {
  84175. return this._subdivisionsX;
  84176. },
  84177. enumerable: true,
  84178. configurable: true
  84179. });
  84180. Object.defineProperty(GroundMesh.prototype, "subdivisionsY", {
  84181. /**
  84182. * Y subdivisions
  84183. */
  84184. get: function () {
  84185. return this._subdivisionsY;
  84186. },
  84187. enumerable: true,
  84188. configurable: true
  84189. });
  84190. /**
  84191. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  84192. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  84193. * @param chunksCount the number of subdivisions for x and y
  84194. * @param octreeBlocksSize (Default: 32)
  84195. */
  84196. GroundMesh.prototype.optimize = function (chunksCount, octreeBlocksSize) {
  84197. if (octreeBlocksSize === void 0) { octreeBlocksSize = 32; }
  84198. this._subdivisionsX = chunksCount;
  84199. this._subdivisionsY = chunksCount;
  84200. this.subdivide(chunksCount);
  84201. // Call the octree system optimization if it is defined.
  84202. var thisAsAny = this;
  84203. if (thisAsAny.createOrUpdateSubmeshesOctree) {
  84204. thisAsAny.createOrUpdateSubmeshesOctree(octreeBlocksSize);
  84205. }
  84206. };
  84207. /**
  84208. * Returns a height (y) value in the Worl system :
  84209. * the ground altitude at the coordinates (x, z) expressed in the World system.
  84210. * @param x x coordinate
  84211. * @param z z coordinate
  84212. * @returns the ground y position if (x, z) are outside the ground surface.
  84213. */
  84214. GroundMesh.prototype.getHeightAtCoordinates = function (x, z) {
  84215. var world = this.getWorldMatrix();
  84216. var invMat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[5];
  84217. world.invertToRef(invMat);
  84218. var tmpVect = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  84219. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(x, 0.0, z, invMat, tmpVect); // transform x,z in the mesh local space
  84220. x = tmpVect.x;
  84221. z = tmpVect.z;
  84222. if (x < this._minX || x > this._maxX || z < this._minZ || z > this._maxZ) {
  84223. return this.position.y;
  84224. }
  84225. if (!this._heightQuads || this._heightQuads.length == 0) {
  84226. this._initHeightQuads();
  84227. this._computeHeightQuads();
  84228. }
  84229. var facet = this._getFacetAt(x, z);
  84230. var y = -(facet.x * x + facet.z * z + facet.w) / facet.y;
  84231. // return y in the World system
  84232. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(0.0, y, 0.0, world, tmpVect);
  84233. return tmpVect.y;
  84234. };
  84235. /**
  84236. * Returns a normalized vector (Vector3) orthogonal to the ground
  84237. * at the ground coordinates (x, z) expressed in the World system.
  84238. * @param x x coordinate
  84239. * @param z z coordinate
  84240. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  84241. */
  84242. GroundMesh.prototype.getNormalAtCoordinates = function (x, z) {
  84243. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0.0, 1.0, 0.0);
  84244. this.getNormalAtCoordinatesToRef(x, z, normal);
  84245. return normal;
  84246. };
  84247. /**
  84248. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  84249. * at the ground coordinates (x, z) expressed in the World system.
  84250. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  84251. * @param x x coordinate
  84252. * @param z z coordinate
  84253. * @param ref vector to store the result
  84254. * @returns the GroundMesh.
  84255. */
  84256. GroundMesh.prototype.getNormalAtCoordinatesToRef = function (x, z, ref) {
  84257. var world = this.getWorldMatrix();
  84258. var tmpMat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[5];
  84259. world.invertToRef(tmpMat);
  84260. var tmpVect = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  84261. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(x, 0.0, z, tmpMat, tmpVect); // transform x,z in the mesh local space
  84262. x = tmpVect.x;
  84263. z = tmpVect.z;
  84264. if (x < this._minX || x > this._maxX || z < this._minZ || z > this._maxZ) {
  84265. return this;
  84266. }
  84267. if (!this._heightQuads || this._heightQuads.length == 0) {
  84268. this._initHeightQuads();
  84269. this._computeHeightQuads();
  84270. }
  84271. var facet = this._getFacetAt(x, z);
  84272. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(facet.x, facet.y, facet.z, world, ref);
  84273. return this;
  84274. };
  84275. /**
  84276. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  84277. * if the ground has been updated.
  84278. * This can be used in the render loop.
  84279. * @returns the GroundMesh.
  84280. */
  84281. GroundMesh.prototype.updateCoordinateHeights = function () {
  84282. if (!this._heightQuads || this._heightQuads.length == 0) {
  84283. this._initHeightQuads();
  84284. }
  84285. this._computeHeightQuads();
  84286. return this;
  84287. };
  84288. // Returns the element "facet" from the heightQuads array relative to (x, z) local coordinates
  84289. GroundMesh.prototype._getFacetAt = function (x, z) {
  84290. // retrieve col and row from x, z coordinates in the ground local system
  84291. var col = Math.floor((x + this._maxX) * this._subdivisionsX / this._width);
  84292. var row = Math.floor(-(z + this._maxZ) * this._subdivisionsY / this._height + this._subdivisionsY);
  84293. var quad = this._heightQuads[row * this._subdivisionsX + col];
  84294. var facet;
  84295. if (z < quad.slope.x * x + quad.slope.y) {
  84296. facet = quad.facet1;
  84297. }
  84298. else {
  84299. facet = quad.facet2;
  84300. }
  84301. return facet;
  84302. };
  84303. // Creates and populates the heightMap array with "facet" elements :
  84304. // a quad is two triangular facets separated by a slope, so a "facet" element is 1 slope + 2 facets
  84305. // slope : Vector2(c, h) = 2D diagonal line equation setting appart two triangular facets in a quad : z = cx + h
  84306. // facet1 : Vector4(a, b, c, d) = first facet 3D plane equation : ax + by + cz + d = 0
  84307. // facet2 : Vector4(a, b, c, d) = second facet 3D plane equation : ax + by + cz + d = 0
  84308. // Returns the GroundMesh.
  84309. GroundMesh.prototype._initHeightQuads = function () {
  84310. var subdivisionsX = this._subdivisionsX;
  84311. var subdivisionsY = this._subdivisionsY;
  84312. this._heightQuads = new Array();
  84313. for (var row = 0; row < subdivisionsY; row++) {
  84314. for (var col = 0; col < subdivisionsX; col++) {
  84315. 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) };
  84316. this._heightQuads[row * subdivisionsX + col] = quad;
  84317. }
  84318. }
  84319. return this;
  84320. };
  84321. // Compute each quad element values and update the the heightMap array :
  84322. // slope : Vector2(c, h) = 2D diagonal line equation setting appart two triangular facets in a quad : z = cx + h
  84323. // facet1 : Vector4(a, b, c, d) = first facet 3D plane equation : ax + by + cz + d = 0
  84324. // facet2 : Vector4(a, b, c, d) = second facet 3D plane equation : ax + by + cz + d = 0
  84325. // Returns the GroundMesh.
  84326. GroundMesh.prototype._computeHeightQuads = function () {
  84327. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  84328. if (!positions) {
  84329. return this;
  84330. }
  84331. var v1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  84332. var v2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  84333. var v3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  84334. var v4 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  84335. var v1v2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[4];
  84336. var v1v3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[5];
  84337. var v1v4 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[6];
  84338. var norm1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[7];
  84339. var norm2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  84340. var i = 0;
  84341. var j = 0;
  84342. var k = 0;
  84343. var cd = 0; // 2D slope coefficient : z = cd * x + h
  84344. var h = 0;
  84345. var d1 = 0; // facet plane equation : ax + by + cz + d = 0
  84346. var d2 = 0;
  84347. var subdivisionsX = this._subdivisionsX;
  84348. var subdivisionsY = this._subdivisionsY;
  84349. for (var row = 0; row < subdivisionsY; row++) {
  84350. for (var col = 0; col < subdivisionsX; col++) {
  84351. i = col * 3;
  84352. j = row * (subdivisionsX + 1) * 3;
  84353. k = (row + 1) * (subdivisionsX + 1) * 3;
  84354. v1.x = positions[j + i];
  84355. v1.y = positions[j + i + 1];
  84356. v1.z = positions[j + i + 2];
  84357. v2.x = positions[j + i + 3];
  84358. v2.y = positions[j + i + 4];
  84359. v2.z = positions[j + i + 5];
  84360. v3.x = positions[k + i];
  84361. v3.y = positions[k + i + 1];
  84362. v3.z = positions[k + i + 2];
  84363. v4.x = positions[k + i + 3];
  84364. v4.y = positions[k + i + 4];
  84365. v4.z = positions[k + i + 5];
  84366. // 2D slope V1V4
  84367. cd = (v4.z - v1.z) / (v4.x - v1.x);
  84368. h = v1.z - cd * v1.x; // v1 belongs to the slope
  84369. // facet equations :
  84370. // we compute each facet normal vector
  84371. // the equation of the facet plane is : norm.x * x + norm.y * y + norm.z * z + d = 0
  84372. // we compute the value d by applying the equation to v1 which belongs to the plane
  84373. // then we store the facet equation in a Vector4
  84374. v2.subtractToRef(v1, v1v2);
  84375. v3.subtractToRef(v1, v1v3);
  84376. v4.subtractToRef(v1, v1v4);
  84377. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(v1v4, v1v3, norm1); // caution : CrossToRef uses the Tmp class
  84378. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(v1v2, v1v4, norm2);
  84379. norm1.normalize();
  84380. norm2.normalize();
  84381. d1 = -(norm1.x * v1.x + norm1.y * v1.y + norm1.z * v1.z);
  84382. d2 = -(norm2.x * v2.x + norm2.y * v2.y + norm2.z * v2.z);
  84383. var quad = this._heightQuads[row * subdivisionsX + col];
  84384. quad.slope.copyFromFloats(cd, h);
  84385. quad.facet1.copyFromFloats(norm1.x, norm1.y, norm1.z, d1);
  84386. quad.facet2.copyFromFloats(norm2.x, norm2.y, norm2.z, d2);
  84387. }
  84388. }
  84389. return this;
  84390. };
  84391. /**
  84392. * Serializes this ground mesh
  84393. * @param serializationObject object to write serialization to
  84394. */
  84395. GroundMesh.prototype.serialize = function (serializationObject) {
  84396. _super.prototype.serialize.call(this, serializationObject);
  84397. serializationObject.subdivisionsX = this._subdivisionsX;
  84398. serializationObject.subdivisionsY = this._subdivisionsY;
  84399. serializationObject.minX = this._minX;
  84400. serializationObject.maxX = this._maxX;
  84401. serializationObject.minZ = this._minZ;
  84402. serializationObject.maxZ = this._maxZ;
  84403. serializationObject.width = this._width;
  84404. serializationObject.height = this._height;
  84405. };
  84406. /**
  84407. * Parses a serialized ground mesh
  84408. * @param parsedMesh the serialized mesh
  84409. * @param scene the scene to create the ground mesh in
  84410. * @returns the created ground mesh
  84411. */
  84412. GroundMesh.Parse = function (parsedMesh, scene) {
  84413. var result = new GroundMesh(parsedMesh.name, scene);
  84414. result._subdivisionsX = parsedMesh.subdivisionsX || 1;
  84415. result._subdivisionsY = parsedMesh.subdivisionsY || 1;
  84416. result._minX = parsedMesh.minX;
  84417. result._maxX = parsedMesh.maxX;
  84418. result._minZ = parsedMesh.minZ;
  84419. result._maxZ = parsedMesh.maxZ;
  84420. result._width = parsedMesh.width;
  84421. result._height = parsedMesh.height;
  84422. return result;
  84423. };
  84424. return GroundMesh;
  84425. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]));
  84426. /***/ }),
  84427. /***/ "./Meshes/index.ts":
  84428. /*!*************************!*\
  84429. !*** ./Meshes/index.ts ***!
  84430. \*************************/
  84431. /*! exports provided: AbstractMesh, Buffer, VertexBuffer, CSG, Geometry, GroundMesh, TrailMesh, InstancedMesh, LinesMesh, InstancedLinesMesh, MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh, VertexData, MeshBuilder, SimplificationSettings, SimplificationQueue, SimplificationType, SimplicationQueueSceneComponent, Polygon, PolygonMeshBuilder, BaseSubMesh, SubMesh, TransformNode, BoxBuilder, SphereBuilder, CylinderBuilder, TorusBuilder, LinesBuilder, PlaneBuilder, GroundBuilder, DracoCompression, DiscBuilder, RibbonBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder */
  84432. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  84433. "use strict";
  84434. __webpack_require__.r(__webpack_exports__);
  84435. /* harmony import */ var _abstractMesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractMesh */ "./Meshes/abstractMesh.ts");
  84436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]; });
  84437. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  84438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _buffer__WEBPACK_IMPORTED_MODULE_1__["Buffer"]; });
  84439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"]; });
  84440. /* harmony import */ var _Compression_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Compression/index */ "./Meshes/Compression/index.ts");
  84441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _Compression_index__WEBPACK_IMPORTED_MODULE_2__["DracoCompression"]; });
  84442. /* harmony import */ var _csg__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./csg */ "./Meshes/csg.ts");
  84443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _csg__WEBPACK_IMPORTED_MODULE_3__["CSG"]; });
  84444. /* harmony import */ var _geometry__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./geometry */ "./Meshes/geometry.ts");
  84445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"]; });
  84446. /* harmony import */ var _groundMesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./groundMesh */ "./Meshes/groundMesh.ts");
  84447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _groundMesh__WEBPACK_IMPORTED_MODULE_5__["GroundMesh"]; });
  84448. /* harmony import */ var _trailMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./trailMesh */ "./Meshes/trailMesh.ts");
  84449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TrailMesh", function() { return _trailMesh__WEBPACK_IMPORTED_MODULE_6__["TrailMesh"]; });
  84450. /* harmony import */ var _instancedMesh__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./instancedMesh */ "./Meshes/instancedMesh.ts");
  84451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _instancedMesh__WEBPACK_IMPORTED_MODULE_7__["InstancedMesh"]; });
  84452. /* harmony import */ var _linesMesh__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./linesMesh */ "./Meshes/linesMesh.ts");
  84453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _linesMesh__WEBPACK_IMPORTED_MODULE_8__["LinesMesh"]; });
  84454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _linesMesh__WEBPACK_IMPORTED_MODULE_8__["InstancedLinesMesh"]; });
  84455. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./mesh */ "./Meshes/mesh.ts");
  84456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _mesh__WEBPACK_IMPORTED_MODULE_9__["MeshLODLevel"]; });
  84457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _mesh__WEBPACK_IMPORTED_MODULE_9__["_CreationDataStorage"]; });
  84458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _mesh__WEBPACK_IMPORTED_MODULE_9__["_InstancesBatch"]; });
  84459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _mesh__WEBPACK_IMPORTED_MODULE_9__["Mesh"]; });
  84460. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  84461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _mesh_vertexData__WEBPACK_IMPORTED_MODULE_10__["VertexData"]; });
  84462. /* harmony import */ var _meshBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./meshBuilder */ "./Meshes/meshBuilder.ts");
  84463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _meshBuilder__WEBPACK_IMPORTED_MODULE_11__["MeshBuilder"]; });
  84464. /* harmony import */ var _meshSimplification__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./meshSimplification */ "./Meshes/meshSimplification.ts");
  84465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_12__["SimplificationSettings"]; });
  84466. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_12__["SimplificationQueue"]; });
  84467. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_12__["SimplificationType"]; });
  84468. /* harmony import */ var _meshSimplificationSceneComponent__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./meshSimplificationSceneComponent */ "./Meshes/meshSimplificationSceneComponent.ts");
  84469. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _meshSimplificationSceneComponent__WEBPACK_IMPORTED_MODULE_13__["SimplicationQueueSceneComponent"]; });
  84470. /* harmony import */ var _polygonMesh__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./polygonMesh */ "./Meshes/polygonMesh.ts");
  84471. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _polygonMesh__WEBPACK_IMPORTED_MODULE_14__["Polygon"]; });
  84472. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _polygonMesh__WEBPACK_IMPORTED_MODULE_14__["PolygonMeshBuilder"]; });
  84473. /* harmony import */ var _subMesh__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./subMesh */ "./Meshes/subMesh.ts");
  84474. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _subMesh__WEBPACK_IMPORTED_MODULE_15__["BaseSubMesh"]; });
  84475. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _subMesh__WEBPACK_IMPORTED_MODULE_15__["SubMesh"]; });
  84476. /* harmony import */ var _transformNode__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./transformNode */ "./Meshes/transformNode.ts");
  84477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _transformNode__WEBPACK_IMPORTED_MODULE_16__["TransformNode"]; });
  84478. /* harmony import */ var _Builders_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Builders/index */ "./Meshes/Builders/index.ts");
  84479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["BoxBuilder"]; });
  84480. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["SphereBuilder"]; });
  84481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["CylinderBuilder"]; });
  84482. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["TorusBuilder"]; });
  84483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["LinesBuilder"]; });
  84484. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["PlaneBuilder"]; });
  84485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["GroundBuilder"]; });
  84486. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["DiscBuilder"]; });
  84487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["RibbonBuilder"]; });
  84488. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["TorusKnotBuilder"]; });
  84489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["PolygonBuilder"]; });
  84490. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["ShapeBuilder"]; });
  84491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["LatheBuilder"]; });
  84492. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["TubeBuilder"]; });
  84493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["PolyhedronBuilder"]; });
  84494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["IcoSphereBuilder"]; });
  84495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["DecalBuilder"]; });
  84496. /***/ }),
  84497. /***/ "./Meshes/instancedMesh.ts":
  84498. /*!*********************************!*\
  84499. !*** ./Meshes/instancedMesh.ts ***!
  84500. \*********************************/
  84501. /*! exports provided: InstancedMesh */
  84502. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  84503. "use strict";
  84504. __webpack_require__.r(__webpack_exports__);
  84505. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return InstancedMesh; });
  84506. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  84507. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  84508. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  84509. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  84510. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  84511. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]._instancedMeshFactory = function (name, mesh) {
  84512. return new InstancedMesh(name, mesh);
  84513. };
  84514. /**
  84515. * Creates an instance based on a source mesh.
  84516. */
  84517. var InstancedMesh = /** @class */ (function (_super) {
  84518. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InstancedMesh, _super);
  84519. function InstancedMesh(name, source) {
  84520. var _this = _super.call(this, name, source.getScene()) || this;
  84521. /** @hidden */
  84522. _this._indexInSourceMeshInstanceArray = -1;
  84523. source.addInstance(_this);
  84524. _this._sourceMesh = source;
  84525. _this.position.copyFrom(source.position);
  84526. _this.rotation.copyFrom(source.rotation);
  84527. _this.scaling.copyFrom(source.scaling);
  84528. if (source.rotationQuaternion) {
  84529. _this.rotationQuaternion = source.rotationQuaternion.clone();
  84530. }
  84531. _this.infiniteDistance = source.infiniteDistance;
  84532. _this.setPivotMatrix(source.getPivotMatrix());
  84533. _this.refreshBoundingInfo();
  84534. _this._syncSubMeshes();
  84535. return _this;
  84536. }
  84537. /**
  84538. * Returns the string "InstancedMesh".
  84539. */
  84540. InstancedMesh.prototype.getClassName = function () {
  84541. return "InstancedMesh";
  84542. };
  84543. Object.defineProperty(InstancedMesh.prototype, "receiveShadows", {
  84544. // Methods
  84545. /**
  84546. * If the source mesh receives shadows
  84547. */
  84548. get: function () {
  84549. return this._sourceMesh.receiveShadows;
  84550. },
  84551. enumerable: true,
  84552. configurable: true
  84553. });
  84554. Object.defineProperty(InstancedMesh.prototype, "material", {
  84555. /**
  84556. * The material of the source mesh
  84557. */
  84558. get: function () {
  84559. return this._sourceMesh.material;
  84560. },
  84561. enumerable: true,
  84562. configurable: true
  84563. });
  84564. Object.defineProperty(InstancedMesh.prototype, "visibility", {
  84565. /**
  84566. * Visibility of the source mesh
  84567. */
  84568. get: function () {
  84569. return this._sourceMesh.visibility;
  84570. },
  84571. enumerable: true,
  84572. configurable: true
  84573. });
  84574. Object.defineProperty(InstancedMesh.prototype, "skeleton", {
  84575. /**
  84576. * Skeleton of the source mesh
  84577. */
  84578. get: function () {
  84579. return this._sourceMesh.skeleton;
  84580. },
  84581. enumerable: true,
  84582. configurable: true
  84583. });
  84584. Object.defineProperty(InstancedMesh.prototype, "renderingGroupId", {
  84585. /**
  84586. * Rendering ground id of the source mesh
  84587. */
  84588. get: function () {
  84589. return this._sourceMesh.renderingGroupId;
  84590. },
  84591. set: function (value) {
  84592. if (!this._sourceMesh || value === this._sourceMesh.renderingGroupId) {
  84593. return;
  84594. }
  84595. //no-op with warning
  84596. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Note - setting renderingGroupId of an instanced mesh has no effect on the scene");
  84597. },
  84598. enumerable: true,
  84599. configurable: true
  84600. });
  84601. /**
  84602. * Returns the total number of vertices (integer).
  84603. */
  84604. InstancedMesh.prototype.getTotalVertices = function () {
  84605. return this._sourceMesh.getTotalVertices();
  84606. };
  84607. /**
  84608. * Returns a positive integer : the total number of indices in this mesh geometry.
  84609. * @returns the numner of indices or zero if the mesh has no geometry.
  84610. */
  84611. InstancedMesh.prototype.getTotalIndices = function () {
  84612. return this._sourceMesh.getTotalIndices();
  84613. };
  84614. Object.defineProperty(InstancedMesh.prototype, "sourceMesh", {
  84615. /**
  84616. * The source mesh of the instance
  84617. */
  84618. get: function () {
  84619. return this._sourceMesh;
  84620. },
  84621. enumerable: true,
  84622. configurable: true
  84623. });
  84624. /**
  84625. * Is this node ready to be used/rendered
  84626. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  84627. * @return {boolean} is it ready
  84628. */
  84629. InstancedMesh.prototype.isReady = function (completeCheck) {
  84630. if (completeCheck === void 0) { completeCheck = false; }
  84631. return this._sourceMesh.isReady(completeCheck, true);
  84632. };
  84633. /**
  84634. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  84635. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  84636. * @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.
  84637. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  84638. */
  84639. InstancedMesh.prototype.getVerticesData = function (kind, copyWhenShared) {
  84640. return this._sourceMesh.getVerticesData(kind, copyWhenShared);
  84641. };
  84642. /**
  84643. * Sets the vertex data of the mesh geometry for the requested `kind`.
  84644. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  84645. * The `data` are either a numeric array either a Float32Array.
  84646. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  84647. * 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).
  84648. * Note that a new underlying VertexBuffer object is created each call.
  84649. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  84650. *
  84651. * Possible `kind` values :
  84652. * - VertexBuffer.PositionKind
  84653. * - VertexBuffer.UVKind
  84654. * - VertexBuffer.UV2Kind
  84655. * - VertexBuffer.UV3Kind
  84656. * - VertexBuffer.UV4Kind
  84657. * - VertexBuffer.UV5Kind
  84658. * - VertexBuffer.UV6Kind
  84659. * - VertexBuffer.ColorKind
  84660. * - VertexBuffer.MatricesIndicesKind
  84661. * - VertexBuffer.MatricesIndicesExtraKind
  84662. * - VertexBuffer.MatricesWeightsKind
  84663. * - VertexBuffer.MatricesWeightsExtraKind
  84664. *
  84665. * Returns the Mesh.
  84666. */
  84667. InstancedMesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  84668. if (this.sourceMesh) {
  84669. this.sourceMesh.setVerticesData(kind, data, updatable, stride);
  84670. }
  84671. return this.sourceMesh;
  84672. };
  84673. /**
  84674. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  84675. * If the mesh has no geometry, it is simply returned as it is.
  84676. * The `data` are either a numeric array either a Float32Array.
  84677. * No new underlying VertexBuffer object is created.
  84678. * 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.
  84679. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  84680. *
  84681. * Possible `kind` values :
  84682. * - VertexBuffer.PositionKind
  84683. * - VertexBuffer.UVKind
  84684. * - VertexBuffer.UV2Kind
  84685. * - VertexBuffer.UV3Kind
  84686. * - VertexBuffer.UV4Kind
  84687. * - VertexBuffer.UV5Kind
  84688. * - VertexBuffer.UV6Kind
  84689. * - VertexBuffer.ColorKind
  84690. * - VertexBuffer.MatricesIndicesKind
  84691. * - VertexBuffer.MatricesIndicesExtraKind
  84692. * - VertexBuffer.MatricesWeightsKind
  84693. * - VertexBuffer.MatricesWeightsExtraKind
  84694. *
  84695. * Returns the Mesh.
  84696. */
  84697. InstancedMesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  84698. if (this.sourceMesh) {
  84699. this.sourceMesh.updateVerticesData(kind, data, updateExtends, makeItUnique);
  84700. }
  84701. return this.sourceMesh;
  84702. };
  84703. /**
  84704. * Sets the mesh indices.
  84705. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  84706. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  84707. * This method creates a new index buffer each call.
  84708. * Returns the Mesh.
  84709. */
  84710. InstancedMesh.prototype.setIndices = function (indices, totalVertices) {
  84711. if (totalVertices === void 0) { totalVertices = null; }
  84712. if (this.sourceMesh) {
  84713. this.sourceMesh.setIndices(indices, totalVertices);
  84714. }
  84715. return this.sourceMesh;
  84716. };
  84717. /**
  84718. * Boolean : True if the mesh owns the requested kind of data.
  84719. */
  84720. InstancedMesh.prototype.isVerticesDataPresent = function (kind) {
  84721. return this._sourceMesh.isVerticesDataPresent(kind);
  84722. };
  84723. /**
  84724. * Returns an array of indices (IndicesArray).
  84725. */
  84726. InstancedMesh.prototype.getIndices = function () {
  84727. return this._sourceMesh.getIndices();
  84728. };
  84729. Object.defineProperty(InstancedMesh.prototype, "_positions", {
  84730. get: function () {
  84731. return this._sourceMesh._positions;
  84732. },
  84733. enumerable: true,
  84734. configurable: true
  84735. });
  84736. /**
  84737. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  84738. * This means the mesh underlying bounding box and sphere are recomputed.
  84739. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  84740. * @returns the current mesh
  84741. */
  84742. InstancedMesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  84743. if (applySkeleton === void 0) { applySkeleton = false; }
  84744. if (this._boundingInfo && this._boundingInfo.isLocked) {
  84745. return this;
  84746. }
  84747. var bias = this._sourceMesh.geometry ? this._sourceMesh.geometry.boundingBias : null;
  84748. this._refreshBoundingInfo(this._sourceMesh._getPositionData(applySkeleton), bias);
  84749. return this;
  84750. };
  84751. /** @hidden */
  84752. InstancedMesh.prototype._preActivate = function () {
  84753. if (this._currentLOD) {
  84754. this._currentLOD._preActivate();
  84755. }
  84756. return this;
  84757. };
  84758. /** @hidden */
  84759. InstancedMesh.prototype._activate = function (renderId) {
  84760. if (this._currentLOD) {
  84761. this._currentLOD._registerInstanceForRenderId(this, renderId);
  84762. }
  84763. return this;
  84764. };
  84765. /**
  84766. * Returns the current associated LOD AbstractMesh.
  84767. */
  84768. InstancedMesh.prototype.getLOD = function (camera) {
  84769. if (!camera) {
  84770. return this;
  84771. }
  84772. var boundingInfo = this.getBoundingInfo();
  84773. this._currentLOD = this.sourceMesh.getLOD(camera, boundingInfo.boundingSphere);
  84774. if (this._currentLOD === this.sourceMesh) {
  84775. return this;
  84776. }
  84777. return this._currentLOD;
  84778. };
  84779. /** @hidden */
  84780. InstancedMesh.prototype._syncSubMeshes = function () {
  84781. this.releaseSubMeshes();
  84782. if (this._sourceMesh.subMeshes) {
  84783. for (var index = 0; index < this._sourceMesh.subMeshes.length; index++) {
  84784. this._sourceMesh.subMeshes[index].clone(this, this._sourceMesh);
  84785. }
  84786. }
  84787. return this;
  84788. };
  84789. /** @hidden */
  84790. InstancedMesh.prototype._generatePointsArray = function () {
  84791. return this._sourceMesh._generatePointsArray();
  84792. };
  84793. /**
  84794. * Creates a new InstancedMesh from the current mesh.
  84795. * - name (string) : the cloned mesh name
  84796. * - newParent (optional Node) : the optional Node to parent the clone to.
  84797. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  84798. *
  84799. * Returns the clone.
  84800. */
  84801. InstancedMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  84802. var result = this._sourceMesh.createInstance(name);
  84803. // Deep copy
  84804. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_4__["DeepCopier"].DeepCopy(this, result, ["name", "subMeshes", "uniqueId"], []);
  84805. // Bounding info
  84806. this.refreshBoundingInfo();
  84807. // Parent
  84808. if (newParent) {
  84809. result.parent = newParent;
  84810. }
  84811. if (!doNotCloneChildren) {
  84812. // Children
  84813. for (var index = 0; index < this.getScene().meshes.length; index++) {
  84814. var mesh = this.getScene().meshes[index];
  84815. if (mesh.parent === this) {
  84816. mesh.clone(mesh.name, result);
  84817. }
  84818. }
  84819. }
  84820. result.computeWorldMatrix(true);
  84821. return result;
  84822. };
  84823. /**
  84824. * Disposes the InstancedMesh.
  84825. * Returns nothing.
  84826. */
  84827. InstancedMesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  84828. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  84829. // Remove from mesh
  84830. this._sourceMesh.removeInstance(this);
  84831. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  84832. };
  84833. return InstancedMesh;
  84834. }(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]));
  84835. /***/ }),
  84836. /***/ "./Meshes/linesMesh.ts":
  84837. /*!*****************************!*\
  84838. !*** ./Meshes/linesMesh.ts ***!
  84839. \*****************************/
  84840. /*! exports provided: LinesMesh, InstancedLinesMesh */
  84841. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  84842. "use strict";
  84843. __webpack_require__.r(__webpack_exports__);
  84844. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return LinesMesh; });
  84845. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return InstancedLinesMesh; });
  84846. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  84847. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  84848. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  84849. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  84850. /* harmony import */ var _Meshes_instancedMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/instancedMesh */ "./Meshes/instancedMesh.ts");
  84851. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  84852. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  84853. /* harmony import */ var _Shaders_color_fragment__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/color.fragment */ "./Shaders/color.fragment.ts");
  84854. /* harmony import */ var _Shaders_color_vertex__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Shaders/color.vertex */ "./Shaders/color.vertex.ts");
  84855. /**
  84856. * Line mesh
  84857. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  84858. */
  84859. var LinesMesh = /** @class */ (function (_super) {
  84860. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LinesMesh, _super);
  84861. /**
  84862. * Creates a new LinesMesh
  84863. * @param name defines the name
  84864. * @param scene defines the hosting scene
  84865. * @param parent defines the parent mesh if any
  84866. * @param source defines the optional source LinesMesh used to clone data from
  84867. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  84868. * When false, achieved by calling a clone(), also passing False.
  84869. * This will make creation of children, recursive.
  84870. * @param useVertexColor defines if this LinesMesh supports vertex color
  84871. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  84872. */
  84873. function LinesMesh(name, scene, parent, source, doNotCloneChildren,
  84874. /**
  84875. * If vertex color should be applied to the mesh
  84876. */
  84877. useVertexColor,
  84878. /**
  84879. * If vertex alpha should be applied to the mesh
  84880. */
  84881. useVertexAlpha) {
  84882. if (scene === void 0) { scene = null; }
  84883. if (parent === void 0) { parent = null; }
  84884. var _this = _super.call(this, name, scene, parent, source, doNotCloneChildren) || this;
  84885. _this.useVertexColor = useVertexColor;
  84886. _this.useVertexAlpha = useVertexAlpha;
  84887. /**
  84888. * Color of the line (Default: White)
  84889. */
  84890. _this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"](1, 1, 1);
  84891. /**
  84892. * Alpha of the line (Default: 1)
  84893. */
  84894. _this.alpha = 1;
  84895. if (source) {
  84896. _this.color = source.color.clone();
  84897. _this.alpha = source.alpha;
  84898. _this.useVertexColor = source.useVertexColor;
  84899. _this.useVertexAlpha = source.useVertexAlpha;
  84900. }
  84901. _this.intersectionThreshold = 0.1;
  84902. var defines = [];
  84903. var options = {
  84904. attributes: [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, "world0", "world1", "world2", "world3"],
  84905. uniforms: ["world", "viewProjection"],
  84906. needAlphaBlending: true,
  84907. defines: defines
  84908. };
  84909. if (useVertexAlpha === false) {
  84910. options.needAlphaBlending = false;
  84911. }
  84912. if (!useVertexColor) {
  84913. options.uniforms.push("color");
  84914. }
  84915. else {
  84916. options.defines.push("#define VERTEXCOLOR");
  84917. options.attributes.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  84918. }
  84919. _this._colorShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__["ShaderMaterial"]("colorShader", _this.getScene(), "color", options);
  84920. return _this;
  84921. }
  84922. /**
  84923. * Returns the string "LineMesh"
  84924. */
  84925. LinesMesh.prototype.getClassName = function () {
  84926. return "LinesMesh";
  84927. };
  84928. Object.defineProperty(LinesMesh.prototype, "material", {
  84929. /**
  84930. * @hidden
  84931. */
  84932. get: function () {
  84933. return this._colorShader;
  84934. },
  84935. /**
  84936. * @hidden
  84937. */
  84938. set: function (value) {
  84939. // Do nothing
  84940. },
  84941. enumerable: true,
  84942. configurable: true
  84943. });
  84944. Object.defineProperty(LinesMesh.prototype, "checkCollisions", {
  84945. /**
  84946. * @hidden
  84947. */
  84948. get: function () {
  84949. return false;
  84950. },
  84951. enumerable: true,
  84952. configurable: true
  84953. });
  84954. /** @hidden */
  84955. LinesMesh.prototype._bind = function (subMesh, effect, fillMode) {
  84956. if (!this._geometry) {
  84957. return this;
  84958. }
  84959. // VBOs
  84960. this._geometry._bind(this._colorShader.getEffect());
  84961. // Color
  84962. if (!this.useVertexColor) {
  84963. this._colorShader.setColor4("color", this.color.toColor4(this.alpha));
  84964. }
  84965. return this;
  84966. };
  84967. /** @hidden */
  84968. LinesMesh.prototype._draw = function (subMesh, fillMode, instancesCount) {
  84969. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  84970. return this;
  84971. }
  84972. var engine = this.getScene().getEngine();
  84973. // Draw order
  84974. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].LineListDrawMode, subMesh.indexStart, subMesh.indexCount, instancesCount);
  84975. return this;
  84976. };
  84977. /**
  84978. * Disposes of the line mesh
  84979. * @param doNotRecurse If children should be disposed
  84980. */
  84981. LinesMesh.prototype.dispose = function (doNotRecurse) {
  84982. this._colorShader.dispose(false, false, true);
  84983. _super.prototype.dispose.call(this, doNotRecurse);
  84984. };
  84985. /**
  84986. * Returns a new LineMesh object cloned from the current one.
  84987. */
  84988. LinesMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  84989. return new LinesMesh(name, this.getScene(), newParent, this, doNotCloneChildren);
  84990. };
  84991. /**
  84992. * Creates a new InstancedLinesMesh object from the mesh model.
  84993. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  84994. * @param name defines the name of the new instance
  84995. * @returns a new InstancedLinesMesh
  84996. */
  84997. LinesMesh.prototype.createInstance = function (name) {
  84998. return new InstancedLinesMesh(name, this);
  84999. };
  85000. return LinesMesh;
  85001. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]));
  85002. /**
  85003. * Creates an instance based on a source LinesMesh
  85004. */
  85005. var InstancedLinesMesh = /** @class */ (function (_super) {
  85006. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InstancedLinesMesh, _super);
  85007. function InstancedLinesMesh(name, source) {
  85008. var _this = _super.call(this, name, source) || this;
  85009. _this.intersectionThreshold = source.intersectionThreshold;
  85010. return _this;
  85011. }
  85012. /**
  85013. * Returns the string "InstancedLinesMesh".
  85014. */
  85015. InstancedLinesMesh.prototype.getClassName = function () {
  85016. return "InstancedLinesMesh";
  85017. };
  85018. return InstancedLinesMesh;
  85019. }(_Meshes_instancedMesh__WEBPACK_IMPORTED_MODULE_4__["InstancedMesh"]));
  85020. /***/ }),
  85021. /***/ "./Meshes/mesh.ts":
  85022. /*!************************!*\
  85023. !*** ./Meshes/mesh.ts ***!
  85024. \************************/
  85025. /*! exports provided: MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh */
  85026. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  85027. "use strict";
  85028. __webpack_require__.r(__webpack_exports__);
  85029. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return MeshLODLevel; });
  85030. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _CreationDataStorage; });
  85031. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _InstancesBatch; });
  85032. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return Mesh; });
  85033. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  85034. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  85035. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  85036. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  85037. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  85038. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  85039. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  85040. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  85041. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  85042. /* harmony import */ var _geometry__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./geometry */ "./Meshes/geometry.ts");
  85043. /* harmony import */ var _abstractMesh__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./abstractMesh */ "./Meshes/abstractMesh.ts");
  85044. /* harmony import */ var _subMesh__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./subMesh */ "./Meshes/subMesh.ts");
  85045. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  85046. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  85047. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  85048. /* harmony import */ var _Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Loading/sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  85049. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  85050. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  85051. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  85052. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  85053. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  85054. /**
  85055. * Class used to represent a specific level of detail of a mesh
  85056. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  85057. */
  85058. var MeshLODLevel = /** @class */ (function () {
  85059. /**
  85060. * Creates a new LOD level
  85061. * @param distance defines the distance where this level should star being displayed
  85062. * @param mesh defines the mesh to use to render this level
  85063. */
  85064. function MeshLODLevel(
  85065. /** Defines the distance where this level should star being displayed */
  85066. distance,
  85067. /** Defines the mesh to use to render this level */
  85068. mesh) {
  85069. this.distance = distance;
  85070. this.mesh = mesh;
  85071. }
  85072. return MeshLODLevel;
  85073. }());
  85074. /**
  85075. * @hidden
  85076. **/
  85077. var _CreationDataStorage = /** @class */ (function () {
  85078. function _CreationDataStorage() {
  85079. }
  85080. return _CreationDataStorage;
  85081. }());
  85082. /**
  85083. * @hidden
  85084. **/
  85085. var _InstanceDataStorage = /** @class */ (function () {
  85086. function _InstanceDataStorage() {
  85087. this.visibleInstances = {};
  85088. this.renderIdForInstances = new Array();
  85089. this.batchCache = new _InstancesBatch();
  85090. this.instancesBufferSize = 32 * 16 * 4; // let's start with a maximum of 32 instances
  85091. }
  85092. return _InstanceDataStorage;
  85093. }());
  85094. /**
  85095. * @hidden
  85096. **/
  85097. var _InstancesBatch = /** @class */ (function () {
  85098. function _InstancesBatch() {
  85099. this.mustReturn = false;
  85100. this.visibleInstances = new Array();
  85101. this.renderSelf = new Array();
  85102. }
  85103. return _InstancesBatch;
  85104. }());
  85105. /**
  85106. * Class used to represent renderable models
  85107. */
  85108. var Mesh = /** @class */ (function (_super) {
  85109. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Mesh, _super);
  85110. /**
  85111. * @constructor
  85112. * @param name The value used by scene.getMeshByName() to do a lookup.
  85113. * @param scene The scene to add this mesh to.
  85114. * @param parent The parent of this mesh, if it has one
  85115. * @param source An optional Mesh from which geometry is shared, cloned.
  85116. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  85117. * When false, achieved by calling a clone(), also passing False.
  85118. * This will make creation of children, recursive.
  85119. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  85120. */
  85121. function Mesh(name, scene, parent, source, doNotCloneChildren, clonePhysicsImpostor) {
  85122. if (scene === void 0) { scene = null; }
  85123. if (parent === void 0) { parent = null; }
  85124. if (source === void 0) { source = null; }
  85125. if (clonePhysicsImpostor === void 0) { clonePhysicsImpostor = true; }
  85126. var _this = _super.call(this, name, scene) || this;
  85127. // Members
  85128. /**
  85129. * Gets the delay loading state of the mesh (when delay loading is turned on)
  85130. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  85131. */
  85132. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_NONE;
  85133. /**
  85134. * Gets the list of instances created from this mesh
  85135. * it is not supposed to be modified manually.
  85136. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  85137. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  85138. */
  85139. _this.instances = new Array();
  85140. _this._LODLevels = new Array();
  85141. /** @hidden */
  85142. _this._instanceDataStorage = new _InstanceDataStorage();
  85143. // Use by builder only to know what orientation were the mesh build in.
  85144. /** @hidden */
  85145. _this._originalBuilderSideOrientation = Mesh.DEFAULTSIDE;
  85146. /**
  85147. * Use this property to change the original side orientation defined at construction time
  85148. */
  85149. _this.overrideMaterialSideOrientation = null;
  85150. _this._areNormalsFrozen = false; // Will be used by ribbons mainly
  85151. // Will be used to save a source mesh reference, If any
  85152. _this._source = null;
  85153. /** @hidden */
  85154. _this._isMesh = true;
  85155. scene = _this.getScene();
  85156. if (source) {
  85157. // Geometry
  85158. if (source._geometry) {
  85159. source._geometry.applyToMesh(_this);
  85160. }
  85161. // Deep copy
  85162. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(source, _this, ["name", "material", "skeleton", "instances", "parent", "uniqueId",
  85163. "source", "metadata", "hasLODLevels", "geometry", "isBlocked", "areNormalsFrozen",
  85164. "onBeforeDrawObservable", "onBeforeRenderObservable", "onAfterRenderObservable", "onBeforeDraw",
  85165. "onAfterWorldMatrixUpdateObservable", "onCollideObservable", "onCollisionPositionChangeObservable", "onRebuildObservable",
  85166. "onDisposeObservable"
  85167. ], ["_poseMatrix"]);
  85168. // Source mesh
  85169. _this._source = source;
  85170. if (scene.useClonedMeshhMap) {
  85171. if (!source.meshMap) {
  85172. source.meshMap = {};
  85173. }
  85174. source.meshMap[_this.uniqueId] = _this;
  85175. }
  85176. // Construction Params
  85177. // Clone parameters allowing mesh to be updated in case of parametric shapes.
  85178. _this._originalBuilderSideOrientation = source._originalBuilderSideOrientation;
  85179. _this._creationDataStorage = source._creationDataStorage;
  85180. // Animation ranges
  85181. if (_this._source._ranges) {
  85182. var ranges = _this._source._ranges;
  85183. for (var name in ranges) {
  85184. if (!ranges.hasOwnProperty(name)) {
  85185. continue;
  85186. }
  85187. if (!ranges[name]) {
  85188. continue;
  85189. }
  85190. _this.createAnimationRange(name, ranges[name].from, ranges[name].to);
  85191. }
  85192. }
  85193. // Metadata
  85194. if (source.metadata && source.metadata.clone) {
  85195. _this.metadata = source.metadata.clone();
  85196. }
  85197. else {
  85198. _this.metadata = source.metadata;
  85199. }
  85200. // Tags
  85201. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].HasTags(source)) {
  85202. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(_this, _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].GetTags(source, true));
  85203. }
  85204. // Parent
  85205. _this.parent = source.parent;
  85206. // Pivot
  85207. _this.setPivotMatrix(source.getPivotMatrix());
  85208. _this.id = name + "." + source.id;
  85209. // Material
  85210. _this.material = source.material;
  85211. var index;
  85212. if (!doNotCloneChildren) {
  85213. // Children
  85214. var directDescendants = source.getDescendants(true);
  85215. for (var index_1 = 0; index_1 < directDescendants.length; index_1++) {
  85216. var child = directDescendants[index_1];
  85217. if (child.clone) {
  85218. child.clone(name + "." + child.name, _this);
  85219. }
  85220. }
  85221. }
  85222. // Physics clone
  85223. var physicsEngine = _this.getScene().getPhysicsEngine();
  85224. if (clonePhysicsImpostor && physicsEngine) {
  85225. var impostor = physicsEngine.getImpostorForPhysicsObject(source);
  85226. if (impostor) {
  85227. _this.physicsImpostor = impostor.clone(_this);
  85228. }
  85229. }
  85230. // Particles
  85231. for (index = 0; index < scene.particleSystems.length; index++) {
  85232. var system = scene.particleSystems[index];
  85233. if (system.emitter === source) {
  85234. system.clone(system.name, _this);
  85235. }
  85236. }
  85237. _this.refreshBoundingInfo();
  85238. _this.computeWorldMatrix(true);
  85239. }
  85240. // Parent
  85241. if (parent !== null) {
  85242. _this.parent = parent;
  85243. }
  85244. return _this;
  85245. }
  85246. /**
  85247. * Gets the default side orientation.
  85248. * @param orientation the orientation to value to attempt to get
  85249. * @returns the default orientation
  85250. * @hidden
  85251. */
  85252. Mesh._GetDefaultSideOrientation = function (orientation) {
  85253. if (orientation == Mesh.DOUBLESIDE) {
  85254. return Mesh.DOUBLESIDE;
  85255. }
  85256. if (orientation === undefined || orientation === null) {
  85257. return Mesh.FRONTSIDE;
  85258. }
  85259. return orientation;
  85260. };
  85261. Object.defineProperty(Mesh.prototype, "onBeforeRenderObservable", {
  85262. /**
  85263. * An event triggered before rendering the mesh
  85264. */
  85265. get: function () {
  85266. if (!this._onBeforeRenderObservable) {
  85267. this._onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  85268. }
  85269. return this._onBeforeRenderObservable;
  85270. },
  85271. enumerable: true,
  85272. configurable: true
  85273. });
  85274. Object.defineProperty(Mesh.prototype, "onBeforeBindObservable", {
  85275. /**
  85276. * An event triggered before binding the mesh
  85277. */
  85278. get: function () {
  85279. if (!this._onBeforeBindObservable) {
  85280. this._onBeforeBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  85281. }
  85282. return this._onBeforeBindObservable;
  85283. },
  85284. enumerable: true,
  85285. configurable: true
  85286. });
  85287. Object.defineProperty(Mesh.prototype, "onAfterRenderObservable", {
  85288. /**
  85289. * An event triggered after rendering the mesh
  85290. */
  85291. get: function () {
  85292. if (!this._onAfterRenderObservable) {
  85293. this._onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  85294. }
  85295. return this._onAfterRenderObservable;
  85296. },
  85297. enumerable: true,
  85298. configurable: true
  85299. });
  85300. Object.defineProperty(Mesh.prototype, "onBeforeDrawObservable", {
  85301. /**
  85302. * An event triggered before drawing the mesh
  85303. */
  85304. get: function () {
  85305. if (!this._onBeforeDrawObservable) {
  85306. this._onBeforeDrawObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  85307. }
  85308. return this._onBeforeDrawObservable;
  85309. },
  85310. enumerable: true,
  85311. configurable: true
  85312. });
  85313. Object.defineProperty(Mesh.prototype, "onBeforeDraw", {
  85314. /**
  85315. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  85316. */
  85317. set: function (callback) {
  85318. if (this._onBeforeDrawObserver) {
  85319. this.onBeforeDrawObservable.remove(this._onBeforeDrawObserver);
  85320. }
  85321. this._onBeforeDrawObserver = this.onBeforeDrawObservable.add(callback);
  85322. },
  85323. enumerable: true,
  85324. configurable: true
  85325. });
  85326. Object.defineProperty(Mesh.prototype, "morphTargetManager", {
  85327. /**
  85328. * Gets or sets the morph target manager
  85329. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  85330. */
  85331. get: function () {
  85332. return this._morphTargetManager;
  85333. },
  85334. set: function (value) {
  85335. if (this._morphTargetManager === value) {
  85336. return;
  85337. }
  85338. this._morphTargetManager = value;
  85339. this._syncGeometryWithMorphTargetManager();
  85340. },
  85341. enumerable: true,
  85342. configurable: true
  85343. });
  85344. Object.defineProperty(Mesh.prototype, "source", {
  85345. /**
  85346. * Gets the source mesh (the one used to clone this one from)
  85347. */
  85348. get: function () {
  85349. return this._source;
  85350. },
  85351. enumerable: true,
  85352. configurable: true
  85353. });
  85354. Object.defineProperty(Mesh.prototype, "isUnIndexed", {
  85355. /**
  85356. * Gets or sets a boolean indicating that this mesh does not use index buffer
  85357. */
  85358. get: function () {
  85359. return this._unIndexed;
  85360. },
  85361. set: function (value) {
  85362. if (this._unIndexed !== value) {
  85363. this._unIndexed = value;
  85364. this._markSubMeshesAsAttributesDirty();
  85365. }
  85366. },
  85367. enumerable: true,
  85368. configurable: true
  85369. });
  85370. // Methods
  85371. /**
  85372. * Gets the class name
  85373. * @returns the string "Mesh".
  85374. */
  85375. Mesh.prototype.getClassName = function () {
  85376. return "Mesh";
  85377. };
  85378. /**
  85379. * Returns a description of this mesh
  85380. * @param fullDetails define if full details about this mesh must be used
  85381. * @returns a descriptive string representing this mesh
  85382. */
  85383. Mesh.prototype.toString = function (fullDetails) {
  85384. var ret = _super.prototype.toString.call(this, fullDetails);
  85385. ret += ", n vertices: " + this.getTotalVertices();
  85386. ret += ", parent: " + (this._waitingParentId ? this._waitingParentId : (this.parent ? this.parent.name : "NONE"));
  85387. if (this.animations) {
  85388. for (var i = 0; i < this.animations.length; i++) {
  85389. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  85390. }
  85391. }
  85392. if (fullDetails) {
  85393. if (this._geometry) {
  85394. var ib = this.getIndices();
  85395. var vb = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  85396. if (vb && ib) {
  85397. ret += ", flat shading: " + (vb.length / 3 === ib.length ? "YES" : "NO");
  85398. }
  85399. }
  85400. else {
  85401. ret += ", flat shading: UNKNOWN";
  85402. }
  85403. }
  85404. return ret;
  85405. };
  85406. /** @hidden */
  85407. Mesh.prototype._unBindEffect = function () {
  85408. _super.prototype._unBindEffect.call(this);
  85409. for (var _i = 0, _a = this.instances; _i < _a.length; _i++) {
  85410. var instance = _a[_i];
  85411. instance._unBindEffect();
  85412. }
  85413. };
  85414. Object.defineProperty(Mesh.prototype, "hasLODLevels", {
  85415. /**
  85416. * Gets a boolean indicating if this mesh has LOD
  85417. */
  85418. get: function () {
  85419. return this._LODLevels.length > 0;
  85420. },
  85421. enumerable: true,
  85422. configurable: true
  85423. });
  85424. /**
  85425. * Gets the list of MeshLODLevel associated with the current mesh
  85426. * @returns an array of MeshLODLevel
  85427. */
  85428. Mesh.prototype.getLODLevels = function () {
  85429. return this._LODLevels;
  85430. };
  85431. Mesh.prototype._sortLODLevels = function () {
  85432. this._LODLevels.sort(function (a, b) {
  85433. if (a.distance < b.distance) {
  85434. return 1;
  85435. }
  85436. if (a.distance > b.distance) {
  85437. return -1;
  85438. }
  85439. return 0;
  85440. });
  85441. };
  85442. /**
  85443. * Add a mesh as LOD level triggered at the given distance.
  85444. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  85445. * @param distance The distance from the center of the object to show this level
  85446. * @param mesh The mesh to be added as LOD level (can be null)
  85447. * @return This mesh (for chaining)
  85448. */
  85449. Mesh.prototype.addLODLevel = function (distance, mesh) {
  85450. if (mesh && mesh._masterMesh) {
  85451. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("You cannot use a mesh as LOD level twice");
  85452. return this;
  85453. }
  85454. var level = new MeshLODLevel(distance, mesh);
  85455. this._LODLevels.push(level);
  85456. if (mesh) {
  85457. mesh._masterMesh = this;
  85458. }
  85459. this._sortLODLevels();
  85460. return this;
  85461. };
  85462. /**
  85463. * Returns the LOD level mesh at the passed distance or null if not found.
  85464. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  85465. * @param distance The distance from the center of the object to show this level
  85466. * @returns a Mesh or `null`
  85467. */
  85468. Mesh.prototype.getLODLevelAtDistance = function (distance) {
  85469. for (var index = 0; index < this._LODLevels.length; index++) {
  85470. var level = this._LODLevels[index];
  85471. if (level.distance === distance) {
  85472. return level.mesh;
  85473. }
  85474. }
  85475. return null;
  85476. };
  85477. /**
  85478. * Remove a mesh from the LOD array
  85479. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  85480. * @param mesh defines the mesh to be removed
  85481. * @return This mesh (for chaining)
  85482. */
  85483. Mesh.prototype.removeLODLevel = function (mesh) {
  85484. for (var index = 0; index < this._LODLevels.length; index++) {
  85485. if (this._LODLevels[index].mesh === mesh) {
  85486. this._LODLevels.splice(index, 1);
  85487. if (mesh) {
  85488. mesh._masterMesh = null;
  85489. }
  85490. }
  85491. }
  85492. this._sortLODLevels();
  85493. return this;
  85494. };
  85495. /**
  85496. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  85497. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  85498. * @param camera defines the camera to use to compute distance
  85499. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  85500. * @return This mesh (for chaining)
  85501. */
  85502. Mesh.prototype.getLOD = function (camera, boundingSphere) {
  85503. if (!this._LODLevels || this._LODLevels.length === 0) {
  85504. return this;
  85505. }
  85506. var bSphere;
  85507. if (boundingSphere) {
  85508. bSphere = boundingSphere;
  85509. }
  85510. else {
  85511. var boundingInfo = this.getBoundingInfo();
  85512. bSphere = boundingInfo.boundingSphere;
  85513. }
  85514. var distanceToCamera = bSphere.centerWorld.subtract(camera.globalPosition).length();
  85515. if (this._LODLevels[this._LODLevels.length - 1].distance > distanceToCamera) {
  85516. if (this.onLODLevelSelection) {
  85517. this.onLODLevelSelection(distanceToCamera, this, this._LODLevels[this._LODLevels.length - 1].mesh);
  85518. }
  85519. return this;
  85520. }
  85521. for (var index = 0; index < this._LODLevels.length; index++) {
  85522. var level = this._LODLevels[index];
  85523. if (level.distance < distanceToCamera) {
  85524. if (level.mesh) {
  85525. level.mesh._preActivate();
  85526. level.mesh._updateSubMeshesBoundingInfo(this.worldMatrixFromCache);
  85527. }
  85528. if (this.onLODLevelSelection) {
  85529. this.onLODLevelSelection(distanceToCamera, this, level.mesh);
  85530. }
  85531. return level.mesh;
  85532. }
  85533. }
  85534. if (this.onLODLevelSelection) {
  85535. this.onLODLevelSelection(distanceToCamera, this, this);
  85536. }
  85537. return this;
  85538. };
  85539. Object.defineProperty(Mesh.prototype, "geometry", {
  85540. /**
  85541. * Gets the mesh internal Geometry object
  85542. */
  85543. get: function () {
  85544. return this._geometry;
  85545. },
  85546. enumerable: true,
  85547. configurable: true
  85548. });
  85549. /**
  85550. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  85551. * @returns the total number of vertices
  85552. */
  85553. Mesh.prototype.getTotalVertices = function () {
  85554. if (this._geometry === null || this._geometry === undefined) {
  85555. return 0;
  85556. }
  85557. return this._geometry.getTotalVertices();
  85558. };
  85559. /**
  85560. * Returns the content of an associated vertex buffer
  85561. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  85562. * - VertexBuffer.PositionKind
  85563. * - VertexBuffer.UVKind
  85564. * - VertexBuffer.UV2Kind
  85565. * - VertexBuffer.UV3Kind
  85566. * - VertexBuffer.UV4Kind
  85567. * - VertexBuffer.UV5Kind
  85568. * - VertexBuffer.UV6Kind
  85569. * - VertexBuffer.ColorKind
  85570. * - VertexBuffer.MatricesIndicesKind
  85571. * - VertexBuffer.MatricesIndicesExtraKind
  85572. * - VertexBuffer.MatricesWeightsKind
  85573. * - VertexBuffer.MatricesWeightsExtraKind
  85574. * @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
  85575. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  85576. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  85577. */
  85578. Mesh.prototype.getVerticesData = function (kind, copyWhenShared, forceCopy) {
  85579. if (!this._geometry) {
  85580. return null;
  85581. }
  85582. return this._geometry.getVerticesData(kind, copyWhenShared, forceCopy);
  85583. };
  85584. /**
  85585. * Returns the mesh VertexBuffer object from the requested `kind`
  85586. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  85587. * - VertexBuffer.PositionKind
  85588. * - VertexBuffer.UVKind
  85589. * - VertexBuffer.UV2Kind
  85590. * - VertexBuffer.UV3Kind
  85591. * - VertexBuffer.UV4Kind
  85592. * - VertexBuffer.UV5Kind
  85593. * - VertexBuffer.UV6Kind
  85594. * - VertexBuffer.ColorKind
  85595. * - VertexBuffer.MatricesIndicesKind
  85596. * - VertexBuffer.MatricesIndicesExtraKind
  85597. * - VertexBuffer.MatricesWeightsKind
  85598. * - VertexBuffer.MatricesWeightsExtraKind
  85599. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  85600. */
  85601. Mesh.prototype.getVertexBuffer = function (kind) {
  85602. if (!this._geometry) {
  85603. return null;
  85604. }
  85605. return this._geometry.getVertexBuffer(kind);
  85606. };
  85607. /**
  85608. * Tests if a specific vertex buffer is associated with this mesh
  85609. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  85610. * - VertexBuffer.PositionKind
  85611. * - VertexBuffer.UVKind
  85612. * - VertexBuffer.UV2Kind
  85613. * - VertexBuffer.UV3Kind
  85614. * - VertexBuffer.UV4Kind
  85615. * - VertexBuffer.UV5Kind
  85616. * - VertexBuffer.UV6Kind
  85617. * - VertexBuffer.ColorKind
  85618. * - VertexBuffer.MatricesIndicesKind
  85619. * - VertexBuffer.MatricesIndicesExtraKind
  85620. * - VertexBuffer.MatricesWeightsKind
  85621. * - VertexBuffer.MatricesWeightsExtraKind
  85622. * @returns a boolean
  85623. */
  85624. Mesh.prototype.isVerticesDataPresent = function (kind) {
  85625. if (!this._geometry) {
  85626. if (this._delayInfo) {
  85627. return this._delayInfo.indexOf(kind) !== -1;
  85628. }
  85629. return false;
  85630. }
  85631. return this._geometry.isVerticesDataPresent(kind);
  85632. };
  85633. /**
  85634. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  85635. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  85636. * - VertexBuffer.PositionKind
  85637. * - VertexBuffer.UVKind
  85638. * - VertexBuffer.UV2Kind
  85639. * - VertexBuffer.UV3Kind
  85640. * - VertexBuffer.UV4Kind
  85641. * - VertexBuffer.UV5Kind
  85642. * - VertexBuffer.UV6Kind
  85643. * - VertexBuffer.ColorKind
  85644. * - VertexBuffer.MatricesIndicesKind
  85645. * - VertexBuffer.MatricesIndicesExtraKind
  85646. * - VertexBuffer.MatricesWeightsKind
  85647. * - VertexBuffer.MatricesWeightsExtraKind
  85648. * @returns a boolean
  85649. */
  85650. Mesh.prototype.isVertexBufferUpdatable = function (kind) {
  85651. if (!this._geometry) {
  85652. if (this._delayInfo) {
  85653. return this._delayInfo.indexOf(kind) !== -1;
  85654. }
  85655. return false;
  85656. }
  85657. return this._geometry.isVertexBufferUpdatable(kind);
  85658. };
  85659. /**
  85660. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  85661. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  85662. * - VertexBuffer.PositionKind
  85663. * - VertexBuffer.UVKind
  85664. * - VertexBuffer.UV2Kind
  85665. * - VertexBuffer.UV3Kind
  85666. * - VertexBuffer.UV4Kind
  85667. * - VertexBuffer.UV5Kind
  85668. * - VertexBuffer.UV6Kind
  85669. * - VertexBuffer.ColorKind
  85670. * - VertexBuffer.MatricesIndicesKind
  85671. * - VertexBuffer.MatricesIndicesExtraKind
  85672. * - VertexBuffer.MatricesWeightsKind
  85673. * - VertexBuffer.MatricesWeightsExtraKind
  85674. * @returns an array of strings
  85675. */
  85676. Mesh.prototype.getVerticesDataKinds = function () {
  85677. if (!this._geometry) {
  85678. var result = new Array();
  85679. if (this._delayInfo) {
  85680. this._delayInfo.forEach(function (kind) {
  85681. result.push(kind);
  85682. });
  85683. }
  85684. return result;
  85685. }
  85686. return this._geometry.getVerticesDataKinds();
  85687. };
  85688. /**
  85689. * Returns a positive integer : the total number of indices in this mesh geometry.
  85690. * @returns the numner of indices or zero if the mesh has no geometry.
  85691. */
  85692. Mesh.prototype.getTotalIndices = function () {
  85693. if (!this._geometry) {
  85694. return 0;
  85695. }
  85696. return this._geometry.getTotalIndices();
  85697. };
  85698. /**
  85699. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  85700. * @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.
  85701. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85702. * @returns the indices array or an empty array if the mesh has no geometry
  85703. */
  85704. Mesh.prototype.getIndices = function (copyWhenShared, forceCopy) {
  85705. if (!this._geometry) {
  85706. return [];
  85707. }
  85708. return this._geometry.getIndices(copyWhenShared, forceCopy);
  85709. };
  85710. Object.defineProperty(Mesh.prototype, "isBlocked", {
  85711. get: function () {
  85712. return this._masterMesh !== null && this._masterMesh !== undefined;
  85713. },
  85714. enumerable: true,
  85715. configurable: true
  85716. });
  85717. /**
  85718. * Determine if the current mesh is ready to be rendered
  85719. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  85720. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  85721. * @returns true if all associated assets are ready (material, textures, shaders)
  85722. */
  85723. Mesh.prototype.isReady = function (completeCheck, forceInstanceSupport) {
  85724. if (completeCheck === void 0) { completeCheck = false; }
  85725. if (forceInstanceSupport === void 0) { forceInstanceSupport = false; }
  85726. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADING) {
  85727. return false;
  85728. }
  85729. if (!_super.prototype.isReady.call(this, completeCheck)) {
  85730. return false;
  85731. }
  85732. if (!this.subMeshes || this.subMeshes.length === 0) {
  85733. return true;
  85734. }
  85735. if (!completeCheck) {
  85736. return true;
  85737. }
  85738. var engine = this.getEngine();
  85739. var scene = this.getScene();
  85740. var hardwareInstancedRendering = forceInstanceSupport || engine.getCaps().instancedArrays && this.instances.length > 0;
  85741. this.computeWorldMatrix();
  85742. var mat = this.material || scene.defaultMaterial;
  85743. if (mat) {
  85744. if (mat._storeEffectOnSubMeshes) {
  85745. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  85746. var subMesh = _a[_i];
  85747. var effectiveMaterial = subMesh.getMaterial();
  85748. if (effectiveMaterial) {
  85749. if (effectiveMaterial._storeEffectOnSubMeshes) {
  85750. if (!effectiveMaterial.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
  85751. return false;
  85752. }
  85753. }
  85754. else {
  85755. if (!effectiveMaterial.isReady(this, hardwareInstancedRendering)) {
  85756. return false;
  85757. }
  85758. }
  85759. }
  85760. }
  85761. }
  85762. else {
  85763. if (!mat.isReady(this, hardwareInstancedRendering)) {
  85764. return false;
  85765. }
  85766. }
  85767. }
  85768. // Shadows
  85769. for (var _b = 0, _c = this._lightSources; _b < _c.length; _b++) {
  85770. var light = _c[_b];
  85771. var generator = light.getShadowGenerator();
  85772. if (generator) {
  85773. for (var _d = 0, _e = this.subMeshes; _d < _e.length; _d++) {
  85774. var subMesh = _e[_d];
  85775. if (!generator.isReady(subMesh, hardwareInstancedRendering)) {
  85776. return false;
  85777. }
  85778. }
  85779. }
  85780. }
  85781. // LOD
  85782. for (var _f = 0, _g = this._LODLevels; _f < _g.length; _f++) {
  85783. var lod = _g[_f];
  85784. if (lod.mesh && !lod.mesh.isReady(hardwareInstancedRendering)) {
  85785. return false;
  85786. }
  85787. }
  85788. return true;
  85789. };
  85790. Object.defineProperty(Mesh.prototype, "areNormalsFrozen", {
  85791. /**
  85792. * 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.
  85793. */
  85794. get: function () {
  85795. return this._areNormalsFrozen;
  85796. },
  85797. enumerable: true,
  85798. configurable: true
  85799. });
  85800. /**
  85801. * 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.
  85802. * @returns the current mesh
  85803. */
  85804. Mesh.prototype.freezeNormals = function () {
  85805. this._areNormalsFrozen = true;
  85806. return this;
  85807. };
  85808. /**
  85809. * 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
  85810. * @returns the current mesh
  85811. */
  85812. Mesh.prototype.unfreezeNormals = function () {
  85813. this._areNormalsFrozen = false;
  85814. return this;
  85815. };
  85816. Object.defineProperty(Mesh.prototype, "overridenInstanceCount", {
  85817. /**
  85818. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  85819. */
  85820. set: function (count) {
  85821. this._instanceDataStorage.overridenInstanceCount = count;
  85822. },
  85823. enumerable: true,
  85824. configurable: true
  85825. });
  85826. // Methods
  85827. /** @hidden */
  85828. Mesh.prototype._preActivate = function () {
  85829. var sceneRenderId = this.getScene().getRenderId();
  85830. if (this._preActivateId === sceneRenderId) {
  85831. return this;
  85832. }
  85833. this._preActivateId = sceneRenderId;
  85834. this._instanceDataStorage.visibleInstances = null;
  85835. return this;
  85836. };
  85837. /** @hidden */
  85838. Mesh.prototype._preActivateForIntermediateRendering = function (renderId) {
  85839. if (this._instanceDataStorage.visibleInstances) {
  85840. this._instanceDataStorage.visibleInstances.intermediateDefaultRenderId = renderId;
  85841. }
  85842. return this;
  85843. };
  85844. /** @hidden */
  85845. Mesh.prototype._registerInstanceForRenderId = function (instance, renderId) {
  85846. if (!this._instanceDataStorage.visibleInstances) {
  85847. this._instanceDataStorage.visibleInstances = {
  85848. defaultRenderId: renderId,
  85849. selfDefaultRenderId: this._renderId
  85850. };
  85851. }
  85852. if (!this._instanceDataStorage.visibleInstances[renderId]) {
  85853. this._instanceDataStorage.visibleInstances[renderId] = new Array();
  85854. }
  85855. this._instanceDataStorage.visibleInstances[renderId].push(instance);
  85856. return this;
  85857. };
  85858. /**
  85859. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  85860. * This means the mesh underlying bounding box and sphere are recomputed.
  85861. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  85862. * @returns the current mesh
  85863. */
  85864. Mesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  85865. if (applySkeleton === void 0) { applySkeleton = false; }
  85866. if (this._boundingInfo && this._boundingInfo.isLocked) {
  85867. return this;
  85868. }
  85869. var bias = this.geometry ? this.geometry.boundingBias : null;
  85870. this._refreshBoundingInfo(this._getPositionData(applySkeleton), bias);
  85871. return this;
  85872. };
  85873. /** @hidden */
  85874. Mesh.prototype._createGlobalSubMesh = function (force) {
  85875. var totalVertices = this.getTotalVertices();
  85876. if (!totalVertices || !this.getIndices()) {
  85877. return null;
  85878. }
  85879. // Check if we need to recreate the submeshes
  85880. if (this.subMeshes && this.subMeshes.length > 0) {
  85881. var ib = this.getIndices();
  85882. if (!ib) {
  85883. return null;
  85884. }
  85885. var totalIndices = ib.length;
  85886. var needToRecreate = false;
  85887. if (force) {
  85888. needToRecreate = true;
  85889. }
  85890. else {
  85891. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  85892. var submesh = _a[_i];
  85893. if (submesh.indexStart + submesh.indexCount >= totalIndices) {
  85894. needToRecreate = true;
  85895. break;
  85896. }
  85897. if (submesh.verticesStart + submesh.verticesCount >= totalVertices) {
  85898. needToRecreate = true;
  85899. break;
  85900. }
  85901. }
  85902. }
  85903. if (!needToRecreate) {
  85904. return this.subMeshes[0];
  85905. }
  85906. }
  85907. this.releaseSubMeshes();
  85908. return new _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"](0, 0, totalVertices, 0, this.getTotalIndices(), this);
  85909. };
  85910. /**
  85911. * This function will subdivide the mesh into multiple submeshes
  85912. * @param count defines the expected number of submeshes
  85913. */
  85914. Mesh.prototype.subdivide = function (count) {
  85915. if (count < 1) {
  85916. return;
  85917. }
  85918. var totalIndices = this.getTotalIndices();
  85919. var subdivisionSize = (totalIndices / count) | 0;
  85920. var offset = 0;
  85921. // Ensure that subdivisionSize is a multiple of 3
  85922. while (subdivisionSize % 3 !== 0) {
  85923. subdivisionSize++;
  85924. }
  85925. this.releaseSubMeshes();
  85926. for (var index = 0; index < count; index++) {
  85927. if (offset >= totalIndices) {
  85928. break;
  85929. }
  85930. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].CreateFromIndices(0, offset, Math.min(subdivisionSize, totalIndices - offset), this);
  85931. offset += subdivisionSize;
  85932. }
  85933. this.synchronizeInstances();
  85934. };
  85935. /**
  85936. * Copy a FloatArray into a specific associated vertex buffer
  85937. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  85938. * - VertexBuffer.PositionKind
  85939. * - VertexBuffer.UVKind
  85940. * - VertexBuffer.UV2Kind
  85941. * - VertexBuffer.UV3Kind
  85942. * - VertexBuffer.UV4Kind
  85943. * - VertexBuffer.UV5Kind
  85944. * - VertexBuffer.UV6Kind
  85945. * - VertexBuffer.ColorKind
  85946. * - VertexBuffer.MatricesIndicesKind
  85947. * - VertexBuffer.MatricesIndicesExtraKind
  85948. * - VertexBuffer.MatricesWeightsKind
  85949. * - VertexBuffer.MatricesWeightsExtraKind
  85950. * @param data defines the data source
  85951. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  85952. * @param stride defines the data stride size (can be null)
  85953. * @returns the current mesh
  85954. */
  85955. Mesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  85956. if (updatable === void 0) { updatable = false; }
  85957. if (!this._geometry) {
  85958. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"]();
  85959. vertexData.set(data, kind);
  85960. var scene = this.getScene();
  85961. new _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"](_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId(), scene, vertexData, updatable, this);
  85962. }
  85963. else {
  85964. this._geometry.setVerticesData(kind, data, updatable, stride);
  85965. }
  85966. return this;
  85967. };
  85968. /**
  85969. * Flags an associated vertex buffer as updatable
  85970. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  85971. * - VertexBuffer.PositionKind
  85972. * - VertexBuffer.UVKind
  85973. * - VertexBuffer.UV2Kind
  85974. * - VertexBuffer.UV3Kind
  85975. * - VertexBuffer.UV4Kind
  85976. * - VertexBuffer.UV5Kind
  85977. * - VertexBuffer.UV6Kind
  85978. * - VertexBuffer.ColorKind
  85979. * - VertexBuffer.MatricesIndicesKind
  85980. * - VertexBuffer.MatricesIndicesExtraKind
  85981. * - VertexBuffer.MatricesWeightsKind
  85982. * - VertexBuffer.MatricesWeightsExtraKind
  85983. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  85984. */
  85985. Mesh.prototype.markVerticesDataAsUpdatable = function (kind, updatable) {
  85986. if (updatable === void 0) { updatable = true; }
  85987. var vb = this.getVertexBuffer(kind);
  85988. if (!vb || vb.isUpdatable() === updatable) {
  85989. return;
  85990. }
  85991. this.setVerticesData(kind, this.getVerticesData(kind), updatable);
  85992. };
  85993. /**
  85994. * Sets the mesh global Vertex Buffer
  85995. * @param buffer defines the buffer to use
  85996. * @returns the current mesh
  85997. */
  85998. Mesh.prototype.setVerticesBuffer = function (buffer) {
  85999. if (!this._geometry) {
  86000. this._geometry = _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].CreateGeometryForMesh(this);
  86001. }
  86002. this._geometry.setVerticesBuffer(buffer);
  86003. return this;
  86004. };
  86005. /**
  86006. * Update a specific associated vertex buffer
  86007. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  86008. * - VertexBuffer.PositionKind
  86009. * - VertexBuffer.UVKind
  86010. * - VertexBuffer.UV2Kind
  86011. * - VertexBuffer.UV3Kind
  86012. * - VertexBuffer.UV4Kind
  86013. * - VertexBuffer.UV5Kind
  86014. * - VertexBuffer.UV6Kind
  86015. * - VertexBuffer.ColorKind
  86016. * - VertexBuffer.MatricesIndicesKind
  86017. * - VertexBuffer.MatricesIndicesExtraKind
  86018. * - VertexBuffer.MatricesWeightsKind
  86019. * - VertexBuffer.MatricesWeightsExtraKind
  86020. * @param data defines the data source
  86021. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  86022. * @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)
  86023. * @returns the current mesh
  86024. */
  86025. Mesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  86026. if (!this._geometry) {
  86027. return this;
  86028. }
  86029. if (!makeItUnique) {
  86030. this._geometry.updateVerticesData(kind, data, updateExtends);
  86031. }
  86032. else {
  86033. this.makeGeometryUnique();
  86034. this.updateVerticesData(kind, data, updateExtends, false);
  86035. }
  86036. return this;
  86037. };
  86038. /**
  86039. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  86040. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  86041. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  86042. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  86043. * @returns the current mesh
  86044. */
  86045. Mesh.prototype.updateMeshPositions = function (positionFunction, computeNormals) {
  86046. if (computeNormals === void 0) { computeNormals = true; }
  86047. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  86048. if (!positions) {
  86049. return this;
  86050. }
  86051. positionFunction(positions);
  86052. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions, false, false);
  86053. if (computeNormals) {
  86054. var indices = this.getIndices();
  86055. var normals = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  86056. if (!normals) {
  86057. return this;
  86058. }
  86059. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ComputeNormals(positions, indices, normals);
  86060. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals, false, false);
  86061. }
  86062. return this;
  86063. };
  86064. /**
  86065. * Creates a un-shared specific occurence of the geometry for the mesh.
  86066. * @returns the current mesh
  86067. */
  86068. Mesh.prototype.makeGeometryUnique = function () {
  86069. if (!this._geometry) {
  86070. return this;
  86071. }
  86072. var oldGeometry = this._geometry;
  86073. var geometry = this._geometry.copy(_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId());
  86074. oldGeometry.releaseForMesh(this, true);
  86075. geometry.applyToMesh(this);
  86076. return this;
  86077. };
  86078. /**
  86079. * Set the index buffer of this mesh
  86080. * @param indices defines the source data
  86081. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  86082. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  86083. * @returns the current mesh
  86084. */
  86085. Mesh.prototype.setIndices = function (indices, totalVertices, updatable) {
  86086. if (totalVertices === void 0) { totalVertices = null; }
  86087. if (updatable === void 0) { updatable = false; }
  86088. if (!this._geometry) {
  86089. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"]();
  86090. vertexData.indices = indices;
  86091. var scene = this.getScene();
  86092. new _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"](_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId(), scene, vertexData, updatable, this);
  86093. }
  86094. else {
  86095. this._geometry.setIndices(indices, totalVertices, updatable);
  86096. }
  86097. return this;
  86098. };
  86099. /**
  86100. * Update the current index buffer
  86101. * @param indices defines the source data
  86102. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  86103. * @returns the current mesh
  86104. */
  86105. Mesh.prototype.updateIndices = function (indices, offset) {
  86106. if (!this._geometry) {
  86107. return this;
  86108. }
  86109. this._geometry.updateIndices(indices, offset);
  86110. return this;
  86111. };
  86112. /**
  86113. * Invert the geometry to move from a right handed system to a left handed one.
  86114. * @returns the current mesh
  86115. */
  86116. Mesh.prototype.toLeftHanded = function () {
  86117. if (!this._geometry) {
  86118. return this;
  86119. }
  86120. this._geometry.toLeftHanded();
  86121. return this;
  86122. };
  86123. /** @hidden */
  86124. Mesh.prototype._bind = function (subMesh, effect, fillMode) {
  86125. if (!this._geometry) {
  86126. return this;
  86127. }
  86128. var engine = this.getScene().getEngine();
  86129. // Wireframe
  86130. var indexToBind;
  86131. if (this._unIndexed) {
  86132. indexToBind = null;
  86133. }
  86134. else {
  86135. switch (fillMode) {
  86136. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].PointFillMode:
  86137. indexToBind = null;
  86138. break;
  86139. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].WireFrameFillMode:
  86140. indexToBind = subMesh._getLinesIndexBuffer(this.getIndices(), engine);
  86141. break;
  86142. default:
  86143. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].TriangleFillMode:
  86144. indexToBind = this._unIndexed ? null : this._geometry.getIndexBuffer();
  86145. break;
  86146. }
  86147. }
  86148. // VBOs
  86149. this._geometry._bind(effect, indexToBind);
  86150. return this;
  86151. };
  86152. /** @hidden */
  86153. Mesh.prototype._draw = function (subMesh, fillMode, instancesCount, alternate) {
  86154. if (alternate === void 0) { alternate = false; }
  86155. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  86156. return this;
  86157. }
  86158. if (this._onBeforeDrawObservable) {
  86159. this._onBeforeDrawObservable.notifyObservers(this);
  86160. }
  86161. var scene = this.getScene();
  86162. var engine = scene.getEngine();
  86163. if (this._unIndexed || fillMode == _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].PointFillMode) {
  86164. // or triangles as points
  86165. engine.drawArraysType(fillMode, subMesh.verticesStart, subMesh.verticesCount, instancesCount);
  86166. }
  86167. else if (fillMode == _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].WireFrameFillMode) {
  86168. // Triangles as wireframe
  86169. engine.drawElementsType(fillMode, 0, subMesh._linesIndexCount, instancesCount);
  86170. }
  86171. else {
  86172. engine.drawElementsType(fillMode, subMesh.indexStart, subMesh.indexCount, instancesCount);
  86173. }
  86174. if (scene._isAlternateRenderingEnabled && !alternate) {
  86175. var effect = subMesh.effect || this._effectiveMaterial.getEffect();
  86176. if (!effect || !scene.activeCamera) {
  86177. return this;
  86178. }
  86179. scene._switchToAlternateCameraConfiguration(true);
  86180. this._effectiveMaterial.bindView(effect);
  86181. this._effectiveMaterial.bindViewProjection(effect);
  86182. engine.setViewport(scene.activeCamera._alternateCamera.viewport);
  86183. this._draw(subMesh, fillMode, instancesCount, true);
  86184. engine.setViewport(scene.activeCamera.viewport);
  86185. scene._switchToAlternateCameraConfiguration(false);
  86186. this._effectiveMaterial.bindView(effect);
  86187. this._effectiveMaterial.bindViewProjection(effect);
  86188. }
  86189. return this;
  86190. };
  86191. /**
  86192. * Registers for this mesh a javascript function called just before the rendering process
  86193. * @param func defines the function to call before rendering this mesh
  86194. * @returns the current mesh
  86195. */
  86196. Mesh.prototype.registerBeforeRender = function (func) {
  86197. this.onBeforeRenderObservable.add(func);
  86198. return this;
  86199. };
  86200. /**
  86201. * Disposes a previously registered javascript function called before the rendering
  86202. * @param func defines the function to remove
  86203. * @returns the current mesh
  86204. */
  86205. Mesh.prototype.unregisterBeforeRender = function (func) {
  86206. this.onBeforeRenderObservable.removeCallback(func);
  86207. return this;
  86208. };
  86209. /**
  86210. * Registers for this mesh a javascript function called just after the rendering is complete
  86211. * @param func defines the function to call after rendering this mesh
  86212. * @returns the current mesh
  86213. */
  86214. Mesh.prototype.registerAfterRender = function (func) {
  86215. this.onAfterRenderObservable.add(func);
  86216. return this;
  86217. };
  86218. /**
  86219. * Disposes a previously registered javascript function called after the rendering.
  86220. * @param func defines the function to remove
  86221. * @returns the current mesh
  86222. */
  86223. Mesh.prototype.unregisterAfterRender = function (func) {
  86224. this.onAfterRenderObservable.removeCallback(func);
  86225. return this;
  86226. };
  86227. /** @hidden */
  86228. Mesh.prototype._getInstancesRenderList = function (subMeshId) {
  86229. var scene = this.getScene();
  86230. var batchCache = this._instanceDataStorage.batchCache;
  86231. batchCache.mustReturn = false;
  86232. batchCache.renderSelf[subMeshId] = this.isEnabled() && this.isVisible;
  86233. batchCache.visibleInstances[subMeshId] = null;
  86234. if (this._instanceDataStorage.visibleInstances) {
  86235. var visibleInstances = this._instanceDataStorage.visibleInstances;
  86236. var currentRenderId = scene.getRenderId();
  86237. var defaultRenderId = (scene._isInIntermediateRendering() ? visibleInstances.intermediateDefaultRenderId : visibleInstances.defaultRenderId);
  86238. batchCache.visibleInstances[subMeshId] = visibleInstances[currentRenderId];
  86239. var selfRenderId = this._renderId;
  86240. if (!batchCache.visibleInstances[subMeshId] && defaultRenderId) {
  86241. batchCache.visibleInstances[subMeshId] = visibleInstances[defaultRenderId];
  86242. currentRenderId = Math.max(defaultRenderId, currentRenderId);
  86243. selfRenderId = Math.max(visibleInstances.selfDefaultRenderId, currentRenderId);
  86244. }
  86245. var visibleInstancesForSubMesh = batchCache.visibleInstances[subMeshId];
  86246. if (visibleInstancesForSubMesh && visibleInstancesForSubMesh.length) {
  86247. if (this._instanceDataStorage.renderIdForInstances[subMeshId] === currentRenderId) {
  86248. batchCache.mustReturn = true;
  86249. return batchCache;
  86250. }
  86251. if (currentRenderId !== selfRenderId) {
  86252. batchCache.renderSelf[subMeshId] = false;
  86253. }
  86254. }
  86255. this._instanceDataStorage.renderIdForInstances[subMeshId] = currentRenderId;
  86256. }
  86257. return batchCache;
  86258. };
  86259. /** @hidden */
  86260. Mesh.prototype._renderWithInstances = function (subMesh, fillMode, batch, effect, engine) {
  86261. var visibleInstances = batch.visibleInstances[subMesh._id];
  86262. if (!visibleInstances) {
  86263. return this;
  86264. }
  86265. var matricesCount = visibleInstances.length + 1;
  86266. var bufferSize = matricesCount * 16 * 4;
  86267. var instanceStorage = this._instanceDataStorage;
  86268. var currentInstancesBufferSize = instanceStorage.instancesBufferSize;
  86269. var instancesBuffer = instanceStorage.instancesBuffer;
  86270. while (instanceStorage.instancesBufferSize < bufferSize) {
  86271. instanceStorage.instancesBufferSize *= 2;
  86272. }
  86273. if (!instanceStorage.instancesData || currentInstancesBufferSize != instanceStorage.instancesBufferSize) {
  86274. instanceStorage.instancesData = new Float32Array(instanceStorage.instancesBufferSize / 4);
  86275. }
  86276. var offset = 0;
  86277. var instancesCount = 0;
  86278. var world = this.getWorldMatrix();
  86279. if (batch.renderSelf[subMesh._id]) {
  86280. world.copyToArray(instanceStorage.instancesData, offset);
  86281. offset += 16;
  86282. instancesCount++;
  86283. }
  86284. if (visibleInstances) {
  86285. for (var instanceIndex = 0; instanceIndex < visibleInstances.length; instanceIndex++) {
  86286. var instance = visibleInstances[instanceIndex];
  86287. instance.getWorldMatrix().copyToArray(instanceStorage.instancesData, offset);
  86288. offset += 16;
  86289. instancesCount++;
  86290. }
  86291. }
  86292. if (!instancesBuffer || currentInstancesBufferSize != instanceStorage.instancesBufferSize) {
  86293. if (instancesBuffer) {
  86294. instancesBuffer.dispose();
  86295. }
  86296. instancesBuffer = new _buffer__WEBPACK_IMPORTED_MODULE_7__["Buffer"](engine, instanceStorage.instancesData, true, 16, false, true);
  86297. instanceStorage.instancesBuffer = instancesBuffer;
  86298. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world0", 0, 4));
  86299. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world1", 4, 4));
  86300. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world2", 8, 4));
  86301. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world3", 12, 4));
  86302. }
  86303. else {
  86304. instancesBuffer.updateDirectly(instanceStorage.instancesData, 0, instancesCount);
  86305. }
  86306. this._bind(subMesh, effect, fillMode);
  86307. this._draw(subMesh, fillMode, instancesCount);
  86308. engine.unbindInstanceAttributes();
  86309. return this;
  86310. };
  86311. /** @hidden */
  86312. Mesh.prototype._processRendering = function (subMesh, effect, fillMode, batch, hardwareInstancedRendering, onBeforeDraw, effectiveMaterial) {
  86313. var scene = this.getScene();
  86314. var engine = scene.getEngine();
  86315. if (hardwareInstancedRendering) {
  86316. this._renderWithInstances(subMesh, fillMode, batch, effect, engine);
  86317. }
  86318. else {
  86319. if (batch.renderSelf[subMesh._id]) {
  86320. // Draw
  86321. if (onBeforeDraw) {
  86322. onBeforeDraw(false, this.getWorldMatrix(), effectiveMaterial);
  86323. }
  86324. this._draw(subMesh, fillMode, this._instanceDataStorage.overridenInstanceCount);
  86325. }
  86326. var visibleInstancesForSubMesh = batch.visibleInstances[subMesh._id];
  86327. if (visibleInstancesForSubMesh) {
  86328. for (var instanceIndex = 0; instanceIndex < visibleInstancesForSubMesh.length; instanceIndex++) {
  86329. var instance = visibleInstancesForSubMesh[instanceIndex];
  86330. // World
  86331. var world = instance.getWorldMatrix();
  86332. if (onBeforeDraw) {
  86333. onBeforeDraw(true, world, effectiveMaterial);
  86334. }
  86335. // Draw
  86336. this._draw(subMesh, fillMode);
  86337. }
  86338. }
  86339. }
  86340. return this;
  86341. };
  86342. /**
  86343. * 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
  86344. * @param subMesh defines the subMesh to render
  86345. * @param enableAlphaMode defines if alpha mode can be changed
  86346. * @returns the current mesh
  86347. */
  86348. Mesh.prototype.render = function (subMesh, enableAlphaMode) {
  86349. if (this._checkOcclusionQuery()) {
  86350. return this;
  86351. }
  86352. var scene = this.getScene();
  86353. // Managing instances
  86354. var batch = this._getInstancesRenderList(subMesh._id);
  86355. if (batch.mustReturn) {
  86356. return this;
  86357. }
  86358. // Checking geometry state
  86359. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  86360. return this;
  86361. }
  86362. if (this._onBeforeRenderObservable) {
  86363. this._onBeforeRenderObservable.notifyObservers(this);
  86364. }
  86365. var engine = scene.getEngine();
  86366. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  86367. // Material
  86368. var material = subMesh.getMaterial();
  86369. if (!material) {
  86370. return this;
  86371. }
  86372. this._effectiveMaterial = material;
  86373. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  86374. if (!this._effectiveMaterial.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
  86375. return this;
  86376. }
  86377. }
  86378. else if (!this._effectiveMaterial.isReady(this, hardwareInstancedRendering)) {
  86379. return this;
  86380. }
  86381. // Alpha mode
  86382. if (enableAlphaMode) {
  86383. engine.setAlphaMode(this._effectiveMaterial.alphaMode);
  86384. }
  86385. for (var _i = 0, _a = scene._beforeRenderingMeshStage; _i < _a.length; _i++) {
  86386. var step = _a[_i];
  86387. step.action(this, subMesh, batch);
  86388. }
  86389. var effect;
  86390. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  86391. effect = subMesh.effect;
  86392. }
  86393. else {
  86394. effect = this._effectiveMaterial.getEffect();
  86395. }
  86396. if (!effect) {
  86397. return this;
  86398. }
  86399. var effectiveMesh = (this.skeleton && this.skeleton.overrideMesh) || this;
  86400. var sideOrientation = this.overrideMaterialSideOrientation;
  86401. if (sideOrientation == null) {
  86402. sideOrientation = this._effectiveMaterial.sideOrientation;
  86403. if (effectiveMesh._getWorldMatrixDeterminant() < 0) {
  86404. 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);
  86405. }
  86406. }
  86407. var reverse = this._effectiveMaterial._preBind(effect, sideOrientation);
  86408. if (this._effectiveMaterial.forceDepthWrite) {
  86409. engine.setDepthWrite(true);
  86410. }
  86411. // Bind
  86412. 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);
  86413. if (this._onBeforeBindObservable) {
  86414. this._onBeforeBindObservable.notifyObservers(this);
  86415. }
  86416. if (!hardwareInstancedRendering) { // Binding will be done later because we need to add more info to the VB
  86417. this._bind(subMesh, effect, fillMode);
  86418. }
  86419. var world = effectiveMesh.getWorldMatrix();
  86420. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  86421. this._effectiveMaterial.bindForSubMesh(world, this, subMesh);
  86422. }
  86423. else {
  86424. this._effectiveMaterial.bind(world, this);
  86425. }
  86426. if (!this._effectiveMaterial.backFaceCulling && this._effectiveMaterial.separateCullingPass) {
  86427. engine.setState(true, this._effectiveMaterial.zOffset, false, !reverse);
  86428. this._processRendering(subMesh, effect, fillMode, batch, hardwareInstancedRendering, this._onBeforeDraw, this._effectiveMaterial);
  86429. engine.setState(true, this._effectiveMaterial.zOffset, false, reverse);
  86430. }
  86431. // Draw
  86432. this._processRendering(subMesh, effect, fillMode, batch, hardwareInstancedRendering, this._onBeforeDraw, this._effectiveMaterial);
  86433. // Unbind
  86434. this._effectiveMaterial.unbind();
  86435. for (var _b = 0, _c = scene._afterRenderingMeshStage; _b < _c.length; _b++) {
  86436. var step = _c[_b];
  86437. step.action(this, subMesh, batch);
  86438. }
  86439. if (this._onAfterRenderObservable) {
  86440. this._onAfterRenderObservable.notifyObservers(this);
  86441. }
  86442. return this;
  86443. };
  86444. Mesh.prototype._onBeforeDraw = function (isInstance, world, effectiveMaterial) {
  86445. if (isInstance && effectiveMaterial) {
  86446. effectiveMaterial.bindOnlyWorldMatrix(world);
  86447. }
  86448. };
  86449. /**
  86450. * Renormalize the mesh and patch it up if there are no weights
  86451. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  86452. * However in the case of zero weights then we set just a single influence to 1.
  86453. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  86454. */
  86455. Mesh.prototype.cleanMatrixWeights = function () {
  86456. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind)) {
  86457. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind)) {
  86458. this.normalizeSkinWeightsAndExtra();
  86459. }
  86460. else {
  86461. this.normalizeSkinFourWeights();
  86462. }
  86463. }
  86464. };
  86465. // faster 4 weight version.
  86466. Mesh.prototype.normalizeSkinFourWeights = function () {
  86467. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  86468. var numWeights = matricesWeights.length;
  86469. for (var a = 0; a < numWeights; a += 4) {
  86470. // accumulate weights
  86471. var t = matricesWeights[a] + matricesWeights[a + 1] + matricesWeights[a + 2] + matricesWeights[a + 3];
  86472. // check for invalid weight and just set it to 1.
  86473. if (t === 0) {
  86474. matricesWeights[a] = 1;
  86475. }
  86476. else {
  86477. // renormalize so everything adds to 1 use reciprical
  86478. var recip = 1 / t;
  86479. matricesWeights[a] *= recip;
  86480. matricesWeights[a + 1] *= recip;
  86481. matricesWeights[a + 2] *= recip;
  86482. matricesWeights[a + 3] *= recip;
  86483. }
  86484. }
  86485. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeights);
  86486. };
  86487. // handle special case of extra verts. (in theory gltf can handle 12 influences)
  86488. Mesh.prototype.normalizeSkinWeightsAndExtra = function () {
  86489. var matricesWeightsExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind);
  86490. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  86491. var numWeights = matricesWeights.length;
  86492. for (var a = 0; a < numWeights; a += 4) {
  86493. // accumulate weights
  86494. var t = matricesWeights[a] + matricesWeights[a + 1] + matricesWeights[a + 2] + matricesWeights[a + 3];
  86495. t += matricesWeightsExtra[a] + matricesWeightsExtra[a + 1] + matricesWeightsExtra[a + 2] + matricesWeightsExtra[a + 3];
  86496. // check for invalid weight and just set it to 1.
  86497. if (t === 0) {
  86498. matricesWeights[a] = 1;
  86499. }
  86500. else {
  86501. // renormalize so everything adds to 1 use reciprical
  86502. var recip = 1 / t;
  86503. matricesWeights[a] *= recip;
  86504. matricesWeights[a + 1] *= recip;
  86505. matricesWeights[a + 2] *= recip;
  86506. matricesWeights[a + 3] *= recip;
  86507. // same goes for extras
  86508. matricesWeightsExtra[a] *= recip;
  86509. matricesWeightsExtra[a + 1] *= recip;
  86510. matricesWeightsExtra[a + 2] *= recip;
  86511. matricesWeightsExtra[a + 3] *= recip;
  86512. }
  86513. }
  86514. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeights);
  86515. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeightsExtra);
  86516. };
  86517. /**
  86518. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  86519. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  86520. * the user know there was an issue with importing the mesh
  86521. * @returns a validation object with skinned, valid and report string
  86522. */
  86523. Mesh.prototype.validateSkinning = function () {
  86524. var matricesWeightsExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind);
  86525. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  86526. if (matricesWeights === null || this.skeleton == null) {
  86527. return { skinned: false, valid: true, report: "not skinned" };
  86528. }
  86529. var numWeights = matricesWeights.length;
  86530. var numberNotSorted = 0;
  86531. var missingWeights = 0;
  86532. var maxUsedWeights = 0;
  86533. var numberNotNormalized = 0;
  86534. var numInfluences = matricesWeightsExtra === null ? 4 : 8;
  86535. var usedWeightCounts = new Array();
  86536. for (var a = 0; a <= numInfluences; a++) {
  86537. usedWeightCounts[a] = 0;
  86538. }
  86539. var toleranceEpsilon = 0.001;
  86540. for (var a = 0; a < numWeights; a += 4) {
  86541. var lastWeight = matricesWeights[a];
  86542. var t = lastWeight;
  86543. var usedWeights = t === 0 ? 0 : 1;
  86544. for (var b = 1; b < numInfluences; b++) {
  86545. var d = b < 4 ? matricesWeights[a + b] : matricesWeightsExtra[a + b - 4];
  86546. if (d > lastWeight) {
  86547. numberNotSorted++;
  86548. }
  86549. if (d !== 0) {
  86550. usedWeights++;
  86551. }
  86552. t += d;
  86553. lastWeight = d;
  86554. }
  86555. // count the buffer weights usage
  86556. usedWeightCounts[usedWeights]++;
  86557. // max influences
  86558. if (usedWeights > maxUsedWeights) {
  86559. maxUsedWeights = usedWeights;
  86560. }
  86561. // check for invalid weight and just set it to 1.
  86562. if (t === 0) {
  86563. missingWeights++;
  86564. }
  86565. else {
  86566. // renormalize so everything adds to 1 use reciprical
  86567. var recip = 1 / t;
  86568. var tolerance = 0;
  86569. for (b = 0; b < numInfluences; b++) {
  86570. if (b < 4) {
  86571. tolerance += Math.abs(matricesWeights[a + b] - (matricesWeights[a + b] * recip));
  86572. }
  86573. else {
  86574. tolerance += Math.abs(matricesWeightsExtra[a + b - 4] - (matricesWeightsExtra[a + b - 4] * recip));
  86575. }
  86576. }
  86577. // arbitary epsilon value for dicdating not normalized
  86578. if (tolerance > toleranceEpsilon) {
  86579. numberNotNormalized++;
  86580. }
  86581. }
  86582. }
  86583. // validate bone indices are in range of the skeleton
  86584. var numBones = this.skeleton.bones.length;
  86585. var matricesIndices = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  86586. var matricesIndicesExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesExtraKind);
  86587. var numBadBoneIndices = 0;
  86588. for (var a = 0; a < numWeights; a++) {
  86589. for (var b = 0; b < numInfluences; b++) {
  86590. var index = b < 4 ? matricesIndices[b] : matricesIndicesExtra[b - 4];
  86591. if (index >= numBones || index < 0) {
  86592. numBadBoneIndices++;
  86593. }
  86594. }
  86595. }
  86596. // log mesh stats
  86597. var output = "Number of Weights = " + numWeights / 4 + "\nMaximum influences = " + maxUsedWeights +
  86598. "\nMissing Weights = " + missingWeights + "\nNot Sorted = " + numberNotSorted +
  86599. "\nNot Normalized = " + numberNotNormalized + "\nWeightCounts = [" + usedWeightCounts + "]" +
  86600. "\nNumber of bones = " + numBones + "\nBad Bone Indices = " + numBadBoneIndices;
  86601. return { skinned: true, valid: missingWeights === 0 && numberNotNormalized === 0 && numBadBoneIndices === 0, report: output };
  86602. };
  86603. /** @hidden */
  86604. Mesh.prototype._checkDelayState = function () {
  86605. var scene = this.getScene();
  86606. if (this._geometry) {
  86607. this._geometry.load(scene);
  86608. }
  86609. else if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  86610. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADING;
  86611. this._queueLoad(scene);
  86612. }
  86613. return this;
  86614. };
  86615. Mesh.prototype._queueLoad = function (scene) {
  86616. var _this = this;
  86617. scene._addPendingData(this);
  86618. var getBinaryData = (this.delayLoadingFile.indexOf(".babylonbinarymeshdata") !== -1);
  86619. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].LoadFile(this.delayLoadingFile, function (data) {
  86620. if (data instanceof ArrayBuffer) {
  86621. _this._delayLoadingFunction(data, _this);
  86622. }
  86623. else {
  86624. _this._delayLoadingFunction(JSON.parse(data), _this);
  86625. }
  86626. _this.instances.forEach(function (instance) {
  86627. instance._syncSubMeshes();
  86628. });
  86629. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADED;
  86630. scene._removePendingData(_this);
  86631. }, function () { }, scene.offlineProvider, getBinaryData);
  86632. return this;
  86633. };
  86634. /**
  86635. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  86636. * A mesh is in the frustum if its bounding box intersects the frustum
  86637. * @param frustumPlanes defines the frustum to test
  86638. * @returns true if the mesh is in the frustum planes
  86639. */
  86640. Mesh.prototype.isInFrustum = function (frustumPlanes) {
  86641. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADING) {
  86642. return false;
  86643. }
  86644. if (!_super.prototype.isInFrustum.call(this, frustumPlanes)) {
  86645. return false;
  86646. }
  86647. this._checkDelayState();
  86648. return true;
  86649. };
  86650. /**
  86651. * Sets the mesh material by the material or multiMaterial `id` property
  86652. * @param id is a string identifying the material or the multiMaterial
  86653. * @returns the current mesh
  86654. */
  86655. Mesh.prototype.setMaterialByID = function (id) {
  86656. var materials = this.getScene().materials;
  86657. var index;
  86658. for (index = materials.length - 1; index > -1; index--) {
  86659. if (materials[index].id === id) {
  86660. this.material = materials[index];
  86661. return this;
  86662. }
  86663. }
  86664. // Multi
  86665. var multiMaterials = this.getScene().multiMaterials;
  86666. for (index = multiMaterials.length - 1; index > -1; index--) {
  86667. if (multiMaterials[index].id === id) {
  86668. this.material = multiMaterials[index];
  86669. return this;
  86670. }
  86671. }
  86672. return this;
  86673. };
  86674. /**
  86675. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  86676. * @returns an array of IAnimatable
  86677. */
  86678. Mesh.prototype.getAnimatables = function () {
  86679. var results = new Array();
  86680. if (this.material) {
  86681. results.push(this.material);
  86682. }
  86683. if (this.skeleton) {
  86684. results.push(this.skeleton);
  86685. }
  86686. return results;
  86687. };
  86688. /**
  86689. * Modifies the mesh geometry according to the passed transformation matrix.
  86690. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  86691. * The mesh normals are modified using the same transformation.
  86692. * Note that, under the hood, this method sets a new VertexBuffer each call.
  86693. * @param transform defines the transform matrix to use
  86694. * @see http://doc.babylonjs.com/resources/baking_transformations
  86695. * @returns the current mesh
  86696. */
  86697. Mesh.prototype.bakeTransformIntoVertices = function (transform) {
  86698. // Position
  86699. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  86700. return this;
  86701. }
  86702. var submeshes = this.subMeshes.splice(0);
  86703. this._resetPointsArrayCache();
  86704. var data = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  86705. var temp = new Array();
  86706. var index;
  86707. for (index = 0; index < data.length; index += 3) {
  86708. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(data, index), transform).toArray(temp, index);
  86709. }
  86710. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, temp, this.getVertexBuffer(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind).isUpdatable());
  86711. // Normals
  86712. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  86713. data = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  86714. temp = [];
  86715. for (index = 0; index < data.length; index += 3) {
  86716. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormal(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(data, index), transform).normalize().toArray(temp, index);
  86717. }
  86718. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, temp, this.getVertexBuffer(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind).isUpdatable());
  86719. }
  86720. // flip faces?
  86721. if (transform.m[0] * transform.m[5] * transform.m[10] < 0) {
  86722. this.flipFaces();
  86723. }
  86724. // Restore submeshes
  86725. this.releaseSubMeshes();
  86726. this.subMeshes = submeshes;
  86727. return this;
  86728. };
  86729. /**
  86730. * Modifies the mesh geometry according to its own current World Matrix.
  86731. * The mesh World Matrix is then reset.
  86732. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  86733. * Note that, under the hood, this method sets a new VertexBuffer each call.
  86734. * @see http://doc.babylonjs.com/resources/baking_transformations
  86735. * @returns the current mesh
  86736. */
  86737. Mesh.prototype.bakeCurrentTransformIntoVertices = function () {
  86738. this.bakeTransformIntoVertices(this.computeWorldMatrix(true));
  86739. this.scaling.copyFromFloats(1, 1, 1);
  86740. this.position.copyFromFloats(0, 0, 0);
  86741. this.rotation.copyFromFloats(0, 0, 0);
  86742. //only if quaternion is already set
  86743. if (this.rotationQuaternion) {
  86744. this.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].Identity();
  86745. }
  86746. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  86747. return this;
  86748. };
  86749. Object.defineProperty(Mesh.prototype, "_positions", {
  86750. // Cache
  86751. /** @hidden */
  86752. get: function () {
  86753. if (this._geometry) {
  86754. return this._geometry._positions;
  86755. }
  86756. return null;
  86757. },
  86758. enumerable: true,
  86759. configurable: true
  86760. });
  86761. /** @hidden */
  86762. Mesh.prototype._resetPointsArrayCache = function () {
  86763. if (this._geometry) {
  86764. this._geometry._resetPointsArrayCache();
  86765. }
  86766. return this;
  86767. };
  86768. /** @hidden */
  86769. Mesh.prototype._generatePointsArray = function () {
  86770. if (this._geometry) {
  86771. return this._geometry._generatePointsArray();
  86772. }
  86773. return false;
  86774. };
  86775. /**
  86776. * Returns a new Mesh object generated from the current mesh properties.
  86777. * This method must not get confused with createInstance()
  86778. * @param name is a string, the name given to the new mesh
  86779. * @param newParent can be any Node object (default `null`)
  86780. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  86781. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  86782. * @returns a new mesh
  86783. */
  86784. Mesh.prototype.clone = function (name, newParent, doNotCloneChildren, clonePhysicsImpostor) {
  86785. if (name === void 0) { name = ""; }
  86786. if (clonePhysicsImpostor === void 0) { clonePhysicsImpostor = true; }
  86787. return new Mesh(name, this.getScene(), newParent, this, doNotCloneChildren, clonePhysicsImpostor);
  86788. };
  86789. /**
  86790. * Releases resources associated with this mesh.
  86791. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  86792. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  86793. */
  86794. Mesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  86795. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  86796. this.morphTargetManager = null;
  86797. if (this._geometry) {
  86798. this._geometry.releaseForMesh(this, true);
  86799. }
  86800. if (this._onBeforeDrawObservable) {
  86801. this._onBeforeDrawObservable.clear();
  86802. }
  86803. if (this._onBeforeBindObservable) {
  86804. this._onBeforeBindObservable.clear();
  86805. }
  86806. if (this._onBeforeRenderObservable) {
  86807. this._onBeforeRenderObservable.clear();
  86808. }
  86809. if (this._onAfterRenderObservable) {
  86810. this._onAfterRenderObservable.clear();
  86811. }
  86812. // Sources
  86813. if (this._scene.useClonedMeshhMap) {
  86814. if (this.meshMap) {
  86815. for (var uniqueId in this.meshMap) {
  86816. var mesh = this.meshMap[uniqueId];
  86817. if (mesh) {
  86818. mesh._source = null;
  86819. this.meshMap[uniqueId] = undefined;
  86820. }
  86821. }
  86822. }
  86823. if (this._source && this._source.meshMap) {
  86824. this._source.meshMap[this.uniqueId] = undefined;
  86825. }
  86826. }
  86827. else {
  86828. var meshes = this.getScene().meshes;
  86829. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  86830. var abstractMesh = meshes_1[_i];
  86831. var mesh = abstractMesh;
  86832. if (mesh._source && mesh._source === this) {
  86833. mesh._source = null;
  86834. }
  86835. }
  86836. }
  86837. this._source = null;
  86838. // Instances
  86839. if (this._instanceDataStorage.instancesBuffer) {
  86840. this._instanceDataStorage.instancesBuffer.dispose();
  86841. this._instanceDataStorage.instancesBuffer = null;
  86842. }
  86843. while (this.instances.length) {
  86844. this.instances[0].dispose();
  86845. }
  86846. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  86847. };
  86848. /**
  86849. * Modifies the mesh geometry according to a displacement map.
  86850. * 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.
  86851. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  86852. * @param url is a string, the URL from the image file is to be downloaded.
  86853. * @param minHeight is the lower limit of the displacement.
  86854. * @param maxHeight is the upper limit of the displacement.
  86855. * @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.
  86856. * @param uvOffset is an optional vector2 used to offset UV.
  86857. * @param uvScale is an optional vector2 used to scale UV.
  86858. * @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.
  86859. * @returns the Mesh.
  86860. */
  86861. Mesh.prototype.applyDisplacementMap = function (url, minHeight, maxHeight, onSuccess, uvOffset, uvScale, forceUpdate) {
  86862. var _this = this;
  86863. if (forceUpdate === void 0) { forceUpdate = false; }
  86864. var scene = this.getScene();
  86865. var onload = function (img) {
  86866. // Getting height map data
  86867. var canvas = document.createElement("canvas");
  86868. var context = canvas.getContext("2d");
  86869. var heightMapWidth = img.width;
  86870. var heightMapHeight = img.height;
  86871. canvas.width = heightMapWidth;
  86872. canvas.height = heightMapHeight;
  86873. context.drawImage(img, 0, 0);
  86874. // Create VertexData from map data
  86875. //Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949
  86876. var buffer = context.getImageData(0, 0, heightMapWidth, heightMapHeight).data;
  86877. _this.applyDisplacementMapFromBuffer(buffer, heightMapWidth, heightMapHeight, minHeight, maxHeight, uvOffset, uvScale, forceUpdate);
  86878. //execute success callback, if set
  86879. if (onSuccess) {
  86880. onSuccess(_this);
  86881. }
  86882. };
  86883. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].LoadImage(url, onload, function () { }, scene.offlineProvider);
  86884. return this;
  86885. };
  86886. /**
  86887. * Modifies the mesh geometry according to a displacementMap buffer.
  86888. * 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.
  86889. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  86890. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  86891. * @param heightMapWidth is the width of the buffer image.
  86892. * @param heightMapHeight is the height of the buffer image.
  86893. * @param minHeight is the lower limit of the displacement.
  86894. * @param maxHeight is the upper limit of the displacement.
  86895. * @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.
  86896. * @param uvOffset is an optional vector2 used to offset UV.
  86897. * @param uvScale is an optional vector2 used to scale UV.
  86898. * @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.
  86899. * @returns the Mesh.
  86900. */
  86901. Mesh.prototype.applyDisplacementMapFromBuffer = function (buffer, heightMapWidth, heightMapHeight, minHeight, maxHeight, uvOffset, uvScale, forceUpdate) {
  86902. if (forceUpdate === void 0) { forceUpdate = false; }
  86903. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)
  86904. || !this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)
  86905. || !this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind)) {
  86906. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing");
  86907. return this;
  86908. }
  86909. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, true, true);
  86910. var normals = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  86911. var uvs = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  86912. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  86913. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  86914. var uv = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].Zero();
  86915. uvOffset = uvOffset || _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].Zero();
  86916. uvScale = uvScale || new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"](1, 1);
  86917. for (var index = 0; index < positions.length; index += 3) {
  86918. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArrayToRef(positions, index, position);
  86919. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArrayToRef(normals, index, normal);
  86920. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].FromArrayToRef(uvs, (index / 3) * 2, uv);
  86921. // Compute height
  86922. var u = ((Math.abs(uv.x * uvScale.x + uvOffset.x) * heightMapWidth) % heightMapWidth) | 0;
  86923. var v = ((Math.abs(uv.y * uvScale.y + uvOffset.y) * heightMapHeight) % heightMapHeight) | 0;
  86924. var pos = (u + v * heightMapWidth) * 4;
  86925. var r = buffer[pos] / 255.0;
  86926. var g = buffer[pos + 1] / 255.0;
  86927. var b = buffer[pos + 2] / 255.0;
  86928. var gradient = r * 0.3 + g * 0.59 + b * 0.11;
  86929. normal.normalize();
  86930. normal.scaleInPlace(minHeight + (maxHeight - minHeight) * gradient);
  86931. position = position.add(normal);
  86932. position.toArray(positions, index);
  86933. }
  86934. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ComputeNormals(positions, this.getIndices(), normals);
  86935. if (forceUpdate) {
  86936. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions);
  86937. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals);
  86938. }
  86939. else {
  86940. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions);
  86941. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals);
  86942. }
  86943. return this;
  86944. };
  86945. /**
  86946. * Modify the mesh to get a flat shading rendering.
  86947. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  86948. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  86949. * @returns current mesh
  86950. */
  86951. Mesh.prototype.convertToFlatShadedMesh = function () {
  86952. var kinds = this.getVerticesDataKinds();
  86953. var vbs = {};
  86954. var data = {};
  86955. var newdata = {};
  86956. var updatableNormals = false;
  86957. var kindIndex;
  86958. var kind;
  86959. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  86960. kind = kinds[kindIndex];
  86961. var vertexBuffer = this.getVertexBuffer(kind);
  86962. if (kind === _buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind) {
  86963. updatableNormals = vertexBuffer.isUpdatable();
  86964. kinds.splice(kindIndex, 1);
  86965. kindIndex--;
  86966. continue;
  86967. }
  86968. vbs[kind] = vertexBuffer;
  86969. data[kind] = vbs[kind].getData();
  86970. newdata[kind] = [];
  86971. }
  86972. // Save previous submeshes
  86973. var previousSubmeshes = this.subMeshes.slice(0);
  86974. var indices = this.getIndices();
  86975. var totalIndices = this.getTotalIndices();
  86976. // Generating unique vertices per face
  86977. var index;
  86978. for (index = 0; index < totalIndices; index++) {
  86979. var vertexIndex = indices[index];
  86980. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  86981. kind = kinds[kindIndex];
  86982. var stride = vbs[kind].getStrideSize();
  86983. for (var offset = 0; offset < stride; offset++) {
  86984. newdata[kind].push(data[kind][vertexIndex * stride + offset]);
  86985. }
  86986. }
  86987. }
  86988. // Updating faces & normal
  86989. var normals = [];
  86990. var positions = newdata[_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind];
  86991. for (index = 0; index < totalIndices; index += 3) {
  86992. indices[index] = index;
  86993. indices[index + 1] = index + 1;
  86994. indices[index + 2] = index + 2;
  86995. var p1 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, index * 3);
  86996. var p2 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, (index + 1) * 3);
  86997. var p3 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, (index + 2) * 3);
  86998. var p1p2 = p1.subtract(p2);
  86999. var p3p2 = p3.subtract(p2);
  87000. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Cross(p1p2, p3p2));
  87001. // Store same normals for every vertex
  87002. for (var localIndex = 0; localIndex < 3; localIndex++) {
  87003. normals.push(normal.x);
  87004. normals.push(normal.y);
  87005. normals.push(normal.z);
  87006. }
  87007. }
  87008. this.setIndices(indices);
  87009. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals, updatableNormals);
  87010. // Updating vertex buffers
  87011. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  87012. kind = kinds[kindIndex];
  87013. this.setVerticesData(kind, newdata[kind], vbs[kind].isUpdatable());
  87014. }
  87015. // Updating submeshes
  87016. this.releaseSubMeshes();
  87017. for (var submeshIndex = 0; submeshIndex < previousSubmeshes.length; submeshIndex++) {
  87018. var previousOne = previousSubmeshes[submeshIndex];
  87019. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].AddToMesh(previousOne.materialIndex, previousOne.indexStart, previousOne.indexCount, previousOne.indexStart, previousOne.indexCount, this);
  87020. }
  87021. this.synchronizeInstances();
  87022. return this;
  87023. };
  87024. /**
  87025. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  87026. * In other words, more vertices, no more indices and a single bigger VBO.
  87027. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  87028. * @returns current mesh
  87029. */
  87030. Mesh.prototype.convertToUnIndexedMesh = function () {
  87031. var kinds = this.getVerticesDataKinds();
  87032. var vbs = {};
  87033. var data = {};
  87034. var newdata = {};
  87035. var kindIndex;
  87036. var kind;
  87037. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  87038. kind = kinds[kindIndex];
  87039. var vertexBuffer = this.getVertexBuffer(kind);
  87040. vbs[kind] = vertexBuffer;
  87041. data[kind] = vbs[kind].getData();
  87042. newdata[kind] = [];
  87043. }
  87044. // Save previous submeshes
  87045. var previousSubmeshes = this.subMeshes.slice(0);
  87046. var indices = this.getIndices();
  87047. var totalIndices = this.getTotalIndices();
  87048. // Generating unique vertices per face
  87049. var index;
  87050. for (index = 0; index < totalIndices; index++) {
  87051. var vertexIndex = indices[index];
  87052. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  87053. kind = kinds[kindIndex];
  87054. var stride = vbs[kind].getStrideSize();
  87055. for (var offset = 0; offset < stride; offset++) {
  87056. newdata[kind].push(data[kind][vertexIndex * stride + offset]);
  87057. }
  87058. }
  87059. }
  87060. // Updating indices
  87061. for (index = 0; index < totalIndices; index += 3) {
  87062. indices[index] = index;
  87063. indices[index + 1] = index + 1;
  87064. indices[index + 2] = index + 2;
  87065. }
  87066. this.setIndices(indices);
  87067. // Updating vertex buffers
  87068. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  87069. kind = kinds[kindIndex];
  87070. this.setVerticesData(kind, newdata[kind], vbs[kind].isUpdatable());
  87071. }
  87072. // Updating submeshes
  87073. this.releaseSubMeshes();
  87074. for (var submeshIndex = 0; submeshIndex < previousSubmeshes.length; submeshIndex++) {
  87075. var previousOne = previousSubmeshes[submeshIndex];
  87076. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].AddToMesh(previousOne.materialIndex, previousOne.indexStart, previousOne.indexCount, previousOne.indexStart, previousOne.indexCount, this);
  87077. }
  87078. this._unIndexed = true;
  87079. this.synchronizeInstances();
  87080. return this;
  87081. };
  87082. /**
  87083. * Inverses facet orientations.
  87084. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  87085. * @param flipNormals will also inverts the normals
  87086. * @returns current mesh
  87087. */
  87088. Mesh.prototype.flipFaces = function (flipNormals) {
  87089. if (flipNormals === void 0) { flipNormals = false; }
  87090. var vertex_data = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(this);
  87091. var i;
  87092. if (flipNormals && this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind) && vertex_data.normals) {
  87093. for (i = 0; i < vertex_data.normals.length; i++) {
  87094. vertex_data.normals[i] *= -1;
  87095. }
  87096. }
  87097. if (vertex_data.indices) {
  87098. var temp;
  87099. for (i = 0; i < vertex_data.indices.length; i += 3) {
  87100. // reassign indices
  87101. temp = vertex_data.indices[i + 1];
  87102. vertex_data.indices[i + 1] = vertex_data.indices[i + 2];
  87103. vertex_data.indices[i + 2] = temp;
  87104. }
  87105. }
  87106. vertex_data.applyToMesh(this);
  87107. return this;
  87108. };
  87109. // Instances
  87110. /** @hidden */
  87111. Mesh._instancedMeshFactory = function (name, mesh) {
  87112. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("InstancedMesh");
  87113. };
  87114. /** @hidden */
  87115. Mesh._PhysicsImpostorParser = function (scene, physicObject, jsonObject) {
  87116. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("PhysicsImpostor");
  87117. };
  87118. /**
  87119. * Creates a new InstancedMesh object from the mesh model.
  87120. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  87121. * @param name defines the name of the new instance
  87122. * @returns a new InstancedMesh
  87123. */
  87124. Mesh.prototype.createInstance = function (name) {
  87125. return Mesh._instancedMeshFactory(name, this);
  87126. };
  87127. /**
  87128. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  87129. * After this call, all the mesh instances have the same submeshes than the current mesh.
  87130. * @returns the current mesh
  87131. */
  87132. Mesh.prototype.synchronizeInstances = function () {
  87133. for (var instanceIndex = 0; instanceIndex < this.instances.length; instanceIndex++) {
  87134. var instance = this.instances[instanceIndex];
  87135. instance._syncSubMeshes();
  87136. }
  87137. return this;
  87138. };
  87139. /**
  87140. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  87141. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  87142. * This should be used together with the simplification to avoid disappearing triangles.
  87143. * @param successCallback an optional success callback to be called after the optimization finished.
  87144. * @returns the current mesh
  87145. */
  87146. Mesh.prototype.optimizeIndices = function (successCallback) {
  87147. var _this = this;
  87148. var indices = this.getIndices();
  87149. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  87150. if (!positions || !indices) {
  87151. return this;
  87152. }
  87153. var vectorPositions = new Array();
  87154. for (var pos = 0; pos < positions.length; pos = pos + 3) {
  87155. vectorPositions.push(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, pos));
  87156. }
  87157. var dupes = new Array();
  87158. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["AsyncLoop"].SyncAsyncForLoop(vectorPositions.length, 40, function (iteration) {
  87159. var realPos = vectorPositions.length - 1 - iteration;
  87160. var testedPosition = vectorPositions[realPos];
  87161. for (var j = 0; j < realPos; ++j) {
  87162. var againstPosition = vectorPositions[j];
  87163. if (testedPosition.equals(againstPosition)) {
  87164. dupes[realPos] = j;
  87165. break;
  87166. }
  87167. }
  87168. }, function () {
  87169. for (var i = 0; i < indices.length; ++i) {
  87170. indices[i] = dupes[indices[i]] || indices[i];
  87171. }
  87172. //indices are now reordered
  87173. var originalSubMeshes = _this.subMeshes.slice(0);
  87174. _this.setIndices(indices);
  87175. _this.subMeshes = originalSubMeshes;
  87176. if (successCallback) {
  87177. successCallback(_this);
  87178. }
  87179. });
  87180. return this;
  87181. };
  87182. /**
  87183. * Serialize current mesh
  87184. * @param serializationObject defines the object which will receive the serialization data
  87185. */
  87186. Mesh.prototype.serialize = function (serializationObject) {
  87187. serializationObject.name = this.name;
  87188. serializationObject.id = this.id;
  87189. serializationObject.type = this.getClassName();
  87190. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].HasTags(this)) {
  87191. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].GetTags(this);
  87192. }
  87193. serializationObject.position = this.position.asArray();
  87194. if (this.rotationQuaternion) {
  87195. serializationObject.rotationQuaternion = this.rotationQuaternion.asArray();
  87196. }
  87197. else if (this.rotation) {
  87198. serializationObject.rotation = this.rotation.asArray();
  87199. }
  87200. serializationObject.scaling = this.scaling.asArray();
  87201. if (this._postMultiplyPivotMatrix) {
  87202. serializationObject.pivotMatrix = this.getPivotMatrix().asArray();
  87203. }
  87204. else {
  87205. serializationObject.localMatrix = this.getPivotMatrix().asArray();
  87206. }
  87207. serializationObject.isEnabled = this.isEnabled(false);
  87208. serializationObject.isVisible = this.isVisible;
  87209. serializationObject.infiniteDistance = this.infiniteDistance;
  87210. serializationObject.pickable = this.isPickable;
  87211. serializationObject.receiveShadows = this.receiveShadows;
  87212. serializationObject.billboardMode = this.billboardMode;
  87213. serializationObject.visibility = this.visibility;
  87214. serializationObject.checkCollisions = this.checkCollisions;
  87215. serializationObject.isBlocker = this.isBlocker;
  87216. // Parent
  87217. if (this.parent) {
  87218. serializationObject.parentId = this.parent.id;
  87219. }
  87220. // Geometry
  87221. serializationObject.isUnIndexed = this.isUnIndexed;
  87222. var geometry = this._geometry;
  87223. if (geometry) {
  87224. var geometryId = geometry.id;
  87225. serializationObject.geometryId = geometryId;
  87226. // SubMeshes
  87227. serializationObject.subMeshes = [];
  87228. for (var subIndex = 0; subIndex < this.subMeshes.length; subIndex++) {
  87229. var subMesh = this.subMeshes[subIndex];
  87230. serializationObject.subMeshes.push({
  87231. materialIndex: subMesh.materialIndex,
  87232. verticesStart: subMesh.verticesStart,
  87233. verticesCount: subMesh.verticesCount,
  87234. indexStart: subMesh.indexStart,
  87235. indexCount: subMesh.indexCount
  87236. });
  87237. }
  87238. }
  87239. // Material
  87240. if (this.material) {
  87241. serializationObject.materialId = this.material.id;
  87242. }
  87243. else {
  87244. this.material = null;
  87245. }
  87246. // Morph targets
  87247. if (this.morphTargetManager) {
  87248. serializationObject.morphTargetManagerId = this.morphTargetManager.uniqueId;
  87249. }
  87250. // Skeleton
  87251. if (this.skeleton) {
  87252. serializationObject.skeletonId = this.skeleton.id;
  87253. }
  87254. // Physics
  87255. //TODO implement correct serialization for physics impostors.
  87256. var impostor = this.getPhysicsImpostor();
  87257. if (impostor) {
  87258. serializationObject.physicsMass = impostor.getParam("mass");
  87259. serializationObject.physicsFriction = impostor.getParam("friction");
  87260. serializationObject.physicsRestitution = impostor.getParam("mass");
  87261. serializationObject.physicsImpostor = impostor.type;
  87262. }
  87263. // Metadata
  87264. if (this.metadata) {
  87265. serializationObject.metadata = this.metadata;
  87266. }
  87267. // Instances
  87268. serializationObject.instances = [];
  87269. for (var index = 0; index < this.instances.length; index++) {
  87270. var instance = this.instances[index];
  87271. if (instance.doNotSerialize) {
  87272. continue;
  87273. }
  87274. var serializationInstance = {
  87275. name: instance.name,
  87276. id: instance.id,
  87277. position: instance.position.asArray(),
  87278. scaling: instance.scaling.asArray()
  87279. };
  87280. if (instance.parent) {
  87281. serializationInstance.parentId = instance.parent.id;
  87282. }
  87283. if (instance.rotationQuaternion) {
  87284. serializationInstance.rotationQuaternion = instance.rotationQuaternion.asArray();
  87285. }
  87286. else if (instance.rotation) {
  87287. serializationInstance.rotation = instance.rotation.asArray();
  87288. }
  87289. serializationObject.instances.push(serializationInstance);
  87290. // Animations
  87291. _Misc_decorators__WEBPACK_IMPORTED_MODULE_17__["SerializationHelper"].AppendSerializedAnimations(instance, serializationInstance);
  87292. serializationInstance.ranges = instance.serializeAnimationRanges();
  87293. }
  87294. //
  87295. // Animations
  87296. _Misc_decorators__WEBPACK_IMPORTED_MODULE_17__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  87297. serializationObject.ranges = this.serializeAnimationRanges();
  87298. // Layer mask
  87299. serializationObject.layerMask = this.layerMask;
  87300. // Alpha
  87301. serializationObject.alphaIndex = this.alphaIndex;
  87302. serializationObject.hasVertexAlpha = this.hasVertexAlpha;
  87303. // Overlay
  87304. serializationObject.overlayAlpha = this.overlayAlpha;
  87305. serializationObject.overlayColor = this.overlayColor.asArray();
  87306. serializationObject.renderOverlay = this.renderOverlay;
  87307. // Fog
  87308. serializationObject.applyFog = this.applyFog;
  87309. // Action Manager
  87310. if (this.actionManager) {
  87311. serializationObject.actions = this.actionManager.serialize(this.name);
  87312. }
  87313. };
  87314. /** @hidden */
  87315. Mesh.prototype._syncGeometryWithMorphTargetManager = function () {
  87316. if (!this.geometry) {
  87317. return;
  87318. }
  87319. this._markSubMeshesAsAttributesDirty();
  87320. var morphTargetManager = this._morphTargetManager;
  87321. if (morphTargetManager && morphTargetManager.vertexCount) {
  87322. if (morphTargetManager.vertexCount !== this.getTotalVertices()) {
  87323. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Error("Mesh is incompatible with morph targets. Targets and mesh must all have the same vertices count.");
  87324. this.morphTargetManager = null;
  87325. return;
  87326. }
  87327. for (var index = 0; index < morphTargetManager.numInfluencers; index++) {
  87328. var morphTarget = morphTargetManager.getActiveTarget(index);
  87329. var positions = morphTarget.getPositions();
  87330. if (!positions) {
  87331. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Error("Invalid morph target. Target must have positions.");
  87332. return;
  87333. }
  87334. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index, positions, false, 3);
  87335. var normals = morphTarget.getNormals();
  87336. if (normals) {
  87337. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index, normals, false, 3);
  87338. }
  87339. var tangents = morphTarget.getTangents();
  87340. if (tangents) {
  87341. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index, tangents, false, 3);
  87342. }
  87343. }
  87344. }
  87345. else {
  87346. var index = 0;
  87347. // Positions
  87348. while (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index)) {
  87349. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index);
  87350. if (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index)) {
  87351. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index);
  87352. }
  87353. if (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index)) {
  87354. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index);
  87355. }
  87356. index++;
  87357. }
  87358. }
  87359. };
  87360. /**
  87361. * Returns a new Mesh object parsed from the source provided.
  87362. * @param parsedMesh is the source
  87363. * @param scene defines the hosting scene
  87364. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  87365. * @returns a new Mesh
  87366. */
  87367. Mesh.Parse = function (parsedMesh, scene, rootUrl) {
  87368. var mesh;
  87369. if (parsedMesh.type && parsedMesh.type === "GroundMesh") {
  87370. mesh = Mesh._GroundMeshParser(parsedMesh, scene);
  87371. }
  87372. else {
  87373. mesh = new Mesh(parsedMesh.name, scene);
  87374. }
  87375. mesh.id = parsedMesh.id;
  87376. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"]) {
  87377. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(mesh, parsedMesh.tags);
  87378. }
  87379. mesh.position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.position);
  87380. if (parsedMesh.metadata !== undefined) {
  87381. mesh.metadata = parsedMesh.metadata;
  87382. }
  87383. if (parsedMesh.rotationQuaternion) {
  87384. mesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].FromArray(parsedMesh.rotationQuaternion);
  87385. }
  87386. else if (parsedMesh.rotation) {
  87387. mesh.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.rotation);
  87388. }
  87389. mesh.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.scaling);
  87390. if (parsedMesh.localMatrix) {
  87391. mesh.setPreTransformMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromArray(parsedMesh.localMatrix));
  87392. }
  87393. else if (parsedMesh.pivotMatrix) {
  87394. mesh.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromArray(parsedMesh.pivotMatrix));
  87395. }
  87396. mesh.setEnabled(parsedMesh.isEnabled);
  87397. mesh.isVisible = parsedMesh.isVisible;
  87398. mesh.infiniteDistance = parsedMesh.infiniteDistance;
  87399. mesh.showBoundingBox = parsedMesh.showBoundingBox;
  87400. mesh.showSubMeshesBoundingBox = parsedMesh.showSubMeshesBoundingBox;
  87401. if (parsedMesh.applyFog !== undefined) {
  87402. mesh.applyFog = parsedMesh.applyFog;
  87403. }
  87404. if (parsedMesh.pickable !== undefined) {
  87405. mesh.isPickable = parsedMesh.pickable;
  87406. }
  87407. if (parsedMesh.alphaIndex !== undefined) {
  87408. mesh.alphaIndex = parsedMesh.alphaIndex;
  87409. }
  87410. mesh.receiveShadows = parsedMesh.receiveShadows;
  87411. mesh.billboardMode = parsedMesh.billboardMode;
  87412. if (parsedMesh.visibility !== undefined) {
  87413. mesh.visibility = parsedMesh.visibility;
  87414. }
  87415. mesh.checkCollisions = parsedMesh.checkCollisions;
  87416. if (parsedMesh.isBlocker !== undefined) {
  87417. mesh.isBlocker = parsedMesh.isBlocker;
  87418. }
  87419. mesh._shouldGenerateFlatShading = parsedMesh.useFlatShading;
  87420. // freezeWorldMatrix
  87421. if (parsedMesh.freezeWorldMatrix) {
  87422. mesh._waitingFreezeWorldMatrix = parsedMesh.freezeWorldMatrix;
  87423. }
  87424. // Parent
  87425. if (parsedMesh.parentId) {
  87426. mesh._waitingParentId = parsedMesh.parentId;
  87427. }
  87428. // Actions
  87429. if (parsedMesh.actions !== undefined) {
  87430. mesh._waitingActions = parsedMesh.actions;
  87431. }
  87432. // Overlay
  87433. if (parsedMesh.overlayAlpha !== undefined) {
  87434. mesh.overlayAlpha = parsedMesh.overlayAlpha;
  87435. }
  87436. if (parsedMesh.overlayColor !== undefined) {
  87437. mesh.overlayColor = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Color3"].FromArray(parsedMesh.overlayColor);
  87438. }
  87439. if (parsedMesh.renderOverlay !== undefined) {
  87440. mesh.renderOverlay = parsedMesh.renderOverlay;
  87441. }
  87442. // Geometry
  87443. mesh.isUnIndexed = !!parsedMesh.isUnIndexed;
  87444. mesh.hasVertexAlpha = parsedMesh.hasVertexAlpha;
  87445. if (parsedMesh.delayLoadingFile) {
  87446. mesh.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_NOTLOADED;
  87447. mesh.delayLoadingFile = rootUrl + parsedMesh.delayLoadingFile;
  87448. 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));
  87449. if (parsedMesh._binaryInfo) {
  87450. mesh._binaryInfo = parsedMesh._binaryInfo;
  87451. }
  87452. mesh._delayInfo = [];
  87453. if (parsedMesh.hasUVs) {
  87454. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  87455. }
  87456. if (parsedMesh.hasUVs2) {
  87457. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV2Kind);
  87458. }
  87459. if (parsedMesh.hasUVs3) {
  87460. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV3Kind);
  87461. }
  87462. if (parsedMesh.hasUVs4) {
  87463. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV4Kind);
  87464. }
  87465. if (parsedMesh.hasUVs5) {
  87466. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV5Kind);
  87467. }
  87468. if (parsedMesh.hasUVs6) {
  87469. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV6Kind);
  87470. }
  87471. if (parsedMesh.hasColors) {
  87472. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].ColorKind);
  87473. }
  87474. if (parsedMesh.hasMatricesIndices) {
  87475. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  87476. }
  87477. if (parsedMesh.hasMatricesWeights) {
  87478. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  87479. }
  87480. mesh._delayLoadingFunction = _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"]._ImportGeometry;
  87481. if (_Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_15__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental) {
  87482. mesh._checkDelayState();
  87483. }
  87484. }
  87485. else {
  87486. _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"]._ImportGeometry(parsedMesh, mesh);
  87487. }
  87488. // Material
  87489. if (parsedMesh.materialId) {
  87490. mesh.setMaterialByID(parsedMesh.materialId);
  87491. }
  87492. else {
  87493. mesh.material = null;
  87494. }
  87495. // Morph targets
  87496. if (parsedMesh.morphTargetManagerId > -1) {
  87497. mesh.morphTargetManager = scene.getMorphTargetManagerById(parsedMesh.morphTargetManagerId);
  87498. }
  87499. // Skeleton
  87500. if (parsedMesh.skeletonId > -1) {
  87501. mesh.skeleton = scene.getLastSkeletonByID(parsedMesh.skeletonId);
  87502. if (parsedMesh.numBoneInfluencers) {
  87503. mesh.numBoneInfluencers = parsedMesh.numBoneInfluencers;
  87504. }
  87505. }
  87506. // Animations
  87507. if (parsedMesh.animations) {
  87508. for (var animationIndex = 0; animationIndex < parsedMesh.animations.length; animationIndex++) {
  87509. var parsedAnimation = parsedMesh.animations[animationIndex];
  87510. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_19__["_TypeStore"].GetClass("BABYLON.Animation");
  87511. if (internalClass) {
  87512. mesh.animations.push(internalClass.Parse(parsedAnimation));
  87513. }
  87514. }
  87515. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(mesh, parsedMesh, scene);
  87516. }
  87517. if (parsedMesh.autoAnimate) {
  87518. scene.beginAnimation(mesh, parsedMesh.autoAnimateFrom, parsedMesh.autoAnimateTo, parsedMesh.autoAnimateLoop, parsedMesh.autoAnimateSpeed || 1.0);
  87519. }
  87520. // Layer Mask
  87521. if (parsedMesh.layerMask && (!isNaN(parsedMesh.layerMask))) {
  87522. mesh.layerMask = Math.abs(parseInt(parsedMesh.layerMask));
  87523. }
  87524. else {
  87525. mesh.layerMask = 0x0FFFFFFF;
  87526. }
  87527. // Physics
  87528. if (parsedMesh.physicsImpostor) {
  87529. Mesh._PhysicsImpostorParser(scene, mesh, parsedMesh);
  87530. }
  87531. // Instances
  87532. if (parsedMesh.instances) {
  87533. for (var index = 0; index < parsedMesh.instances.length; index++) {
  87534. var parsedInstance = parsedMesh.instances[index];
  87535. var instance = mesh.createInstance(parsedInstance.name);
  87536. if (parsedInstance.id) {
  87537. instance.id = parsedInstance.id;
  87538. }
  87539. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"]) {
  87540. if (parsedInstance.tags) {
  87541. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(instance, parsedInstance.tags);
  87542. }
  87543. else {
  87544. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(instance, parsedMesh.tags);
  87545. }
  87546. }
  87547. instance.position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.position);
  87548. if (parsedInstance.parentId) {
  87549. instance._waitingParentId = parsedInstance.parentId;
  87550. }
  87551. if (parsedInstance.rotationQuaternion) {
  87552. instance.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].FromArray(parsedInstance.rotationQuaternion);
  87553. }
  87554. else if (parsedInstance.rotation) {
  87555. instance.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.rotation);
  87556. }
  87557. instance.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.scaling);
  87558. if (parsedInstance.checkCollisions != undefined && parsedInstance.checkCollisions != null) {
  87559. instance.checkCollisions = parsedInstance.checkCollisions;
  87560. }
  87561. if (parsedInstance.pickable != undefined && parsedInstance.pickable != null) {
  87562. instance.isPickable = parsedInstance.pickable;
  87563. }
  87564. if (parsedInstance.showBoundingBox != undefined && parsedInstance.showBoundingBox != null) {
  87565. instance.showBoundingBox = parsedInstance.showBoundingBox;
  87566. }
  87567. if (parsedInstance.showSubMeshesBoundingBox != undefined && parsedInstance.showSubMeshesBoundingBox != null) {
  87568. instance.showSubMeshesBoundingBox = parsedInstance.showSubMeshesBoundingBox;
  87569. }
  87570. if (parsedInstance.alphaIndex != undefined && parsedInstance.showSubMeshesBoundingBox != null) {
  87571. instance.alphaIndex = parsedInstance.alphaIndex;
  87572. }
  87573. // Physics
  87574. if (parsedInstance.physicsImpostor) {
  87575. Mesh._PhysicsImpostorParser(scene, instance, parsedInstance);
  87576. }
  87577. // Animation
  87578. if (parsedInstance.animations) {
  87579. for (animationIndex = 0; animationIndex < parsedInstance.animations.length; animationIndex++) {
  87580. parsedAnimation = parsedInstance.animations[animationIndex];
  87581. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_19__["_TypeStore"].GetClass("BABYLON.Animation");
  87582. if (internalClass) {
  87583. instance.animations.push(internalClass.Parse(parsedAnimation));
  87584. }
  87585. }
  87586. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(instance, parsedInstance, scene);
  87587. if (parsedInstance.autoAnimate) {
  87588. scene.beginAnimation(instance, parsedInstance.autoAnimateFrom, parsedInstance.autoAnimateTo, parsedInstance.autoAnimateLoop, parsedInstance.autoAnimateSpeed || 1.0);
  87589. }
  87590. }
  87591. }
  87592. }
  87593. return mesh;
  87594. };
  87595. /**
  87596. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  87597. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  87598. * @param name defines the name of the mesh to create
  87599. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  87600. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  87601. * @param closePath creates a seam between the first and the last points of each path of the path array
  87602. * @param offset is taken in account only if the `pathArray` is containing a single path
  87603. * @param scene defines the hosting scene
  87604. * @param updatable defines if the mesh must be flagged as updatable
  87605. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87606. * @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)
  87607. * @returns a new Mesh
  87608. */
  87609. Mesh.CreateRibbon = function (name, pathArray, closeArray, closePath, offset, scene, updatable, sideOrientation, instance) {
  87610. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  87611. };
  87612. /**
  87613. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  87614. * @param name defines the name of the mesh to create
  87615. * @param radius sets the radius size (float) of the polygon (default 0.5)
  87616. * @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
  87617. * @param scene defines the hosting scene
  87618. * @param updatable defines if the mesh must be flagged as updatable
  87619. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87620. * @returns a new Mesh
  87621. */
  87622. Mesh.CreateDisc = function (name, radius, tessellation, scene, updatable, sideOrientation) {
  87623. if (scene === void 0) { scene = null; }
  87624. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  87625. };
  87626. /**
  87627. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  87628. * @param name defines the name of the mesh to create
  87629. * @param size sets the size (float) of each box side (default 1)
  87630. * @param scene defines the hosting scene
  87631. * @param updatable defines if the mesh must be flagged as updatable
  87632. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87633. * @returns a new Mesh
  87634. */
  87635. Mesh.CreateBox = function (name, size, scene, updatable, sideOrientation) {
  87636. if (scene === void 0) { scene = null; }
  87637. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  87638. };
  87639. /**
  87640. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  87641. * @param name defines the name of the mesh to create
  87642. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  87643. * @param diameter sets the diameter size (float) of the sphere (default 1)
  87644. * @param scene defines the hosting scene
  87645. * @param updatable defines if the mesh must be flagged as updatable
  87646. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87647. * @returns a new Mesh
  87648. */
  87649. Mesh.CreateSphere = function (name, segments, diameter, scene, updatable, sideOrientation) {
  87650. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  87651. };
  87652. /**
  87653. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  87654. * @param name defines the name of the mesh to create
  87655. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  87656. * @param diameterTop set the top cap diameter (floats, default 1)
  87657. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  87658. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  87659. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  87660. * @param scene defines the hosting scene
  87661. * @param updatable defines if the mesh must be flagged as updatable
  87662. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87663. * @returns a new Mesh
  87664. */
  87665. Mesh.CreateCylinder = function (name, height, diameterTop, diameterBottom, tessellation, subdivisions, scene, updatable, sideOrientation) {
  87666. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  87667. };
  87668. // Torus (Code from SharpDX.org)
  87669. /**
  87670. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  87671. * @param name defines the name of the mesh to create
  87672. * @param diameter sets the diameter size (float) of the torus (default 1)
  87673. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  87674. * @param tessellation sets the number of torus sides (postive integer, default 16)
  87675. * @param scene defines the hosting scene
  87676. * @param updatable defines if the mesh must be flagged as updatable
  87677. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87678. * @returns a new Mesh
  87679. */
  87680. Mesh.CreateTorus = function (name, diameter, thickness, tessellation, scene, updatable, sideOrientation) {
  87681. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  87682. };
  87683. /**
  87684. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  87685. * @param name defines the name of the mesh to create
  87686. * @param radius sets the global radius size (float) of the torus knot (default 2)
  87687. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  87688. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  87689. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  87690. * @param p the number of windings on X axis (positive integers, default 2)
  87691. * @param q the number of windings on Y axis (positive integers, default 3)
  87692. * @param scene defines the hosting scene
  87693. * @param updatable defines if the mesh must be flagged as updatable
  87694. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87695. * @returns a new Mesh
  87696. */
  87697. Mesh.CreateTorusKnot = function (name, radius, tube, radialSegments, tubularSegments, p, q, scene, updatable, sideOrientation) {
  87698. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  87699. };
  87700. /**
  87701. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  87702. * @param name defines the name of the mesh to create
  87703. * @param points is an array successive Vector3
  87704. * @param scene defines the hosting scene
  87705. * @param updatable defines if the mesh must be flagged as updatable
  87706. * @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).
  87707. * @returns a new Mesh
  87708. */
  87709. Mesh.CreateLines = function (name, points, scene, updatable, instance) {
  87710. if (scene === void 0) { scene = null; }
  87711. if (updatable === void 0) { updatable = false; }
  87712. if (instance === void 0) { instance = null; }
  87713. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  87714. };
  87715. /**
  87716. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  87717. * @param name defines the name of the mesh to create
  87718. * @param points is an array successive Vector3
  87719. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  87720. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  87721. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  87722. * @param scene defines the hosting scene
  87723. * @param updatable defines if the mesh must be flagged as updatable
  87724. * @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)
  87725. * @returns a new Mesh
  87726. */
  87727. Mesh.CreateDashedLines = function (name, points, dashSize, gapSize, dashNb, scene, updatable, instance) {
  87728. if (scene === void 0) { scene = null; }
  87729. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  87730. };
  87731. /**
  87732. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  87733. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  87734. * 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.
  87735. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87736. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  87737. * Remember you can only change the shape positions, not their number when updating a polygon.
  87738. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  87739. * @param name defines the name of the mesh to create
  87740. * @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
  87741. * @param scene defines the hosting scene
  87742. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  87743. * @param updatable defines if the mesh must be flagged as updatable
  87744. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87745. * @param earcutInjection can be used to inject your own earcut reference
  87746. * @returns a new Mesh
  87747. */
  87748. Mesh.CreatePolygon = function (name, shape, scene, holes, updatable, sideOrientation, earcutInjection) {
  87749. if (earcutInjection === void 0) { earcutInjection = earcut; }
  87750. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  87751. };
  87752. /**
  87753. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  87754. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  87755. * @param name defines the name of the mesh to create
  87756. * @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
  87757. * @param depth defines the height of extrusion
  87758. * @param scene defines the hosting scene
  87759. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  87760. * @param updatable defines if the mesh must be flagged as updatable
  87761. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87762. * @param earcutInjection can be used to inject your own earcut reference
  87763. * @returns a new Mesh
  87764. */
  87765. Mesh.ExtrudePolygon = function (name, shape, depth, scene, holes, updatable, sideOrientation, earcutInjection) {
  87766. if (earcutInjection === void 0) { earcutInjection = earcut; }
  87767. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  87768. };
  87769. /**
  87770. * Creates an extruded shape mesh.
  87771. * 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
  87772. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  87773. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  87774. * @param name defines the name of the mesh to create
  87775. * @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
  87776. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  87777. * @param scale is the value to scale the shape
  87778. * @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
  87779. * @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
  87780. * @param scene defines the hosting scene
  87781. * @param updatable defines if the mesh must be flagged as updatable
  87782. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87783. * @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)
  87784. * @returns a new Mesh
  87785. */
  87786. Mesh.ExtrudeShape = function (name, shape, path, scale, rotation, cap, scene, updatable, sideOrientation, instance) {
  87787. if (scene === void 0) { scene = null; }
  87788. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  87789. };
  87790. /**
  87791. * Creates an custom extruded shape mesh.
  87792. * The custom extrusion is a parametric shape.
  87793. * It has no predefined shape. Its final shape will depend on the input parameters.
  87794. * Please consider using the same method from the MeshBuilder class instead
  87795. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  87796. * @param name defines the name of the mesh to create
  87797. * @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
  87798. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  87799. * @param scaleFunction is a custom Javascript function called on each path point
  87800. * @param rotationFunction is a custom Javascript function called on each path point
  87801. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  87802. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  87803. * @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
  87804. * @param scene defines the hosting scene
  87805. * @param updatable defines if the mesh must be flagged as updatable
  87806. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87807. * @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)
  87808. * @returns a new Mesh
  87809. */
  87810. Mesh.ExtrudeShapeCustom = function (name, shape, path, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, cap, scene, updatable, sideOrientation, instance) {
  87811. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  87812. };
  87813. /**
  87814. * Creates lathe mesh.
  87815. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  87816. * Please consider using the same method from the MeshBuilder class instead
  87817. * @param name defines the name of the mesh to create
  87818. * @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
  87819. * @param radius is the radius value of the lathe
  87820. * @param tessellation is the side number of the lathe.
  87821. * @param scene defines the hosting scene
  87822. * @param updatable defines if the mesh must be flagged as updatable
  87823. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87824. * @returns a new Mesh
  87825. */
  87826. Mesh.CreateLathe = function (name, shape, radius, tessellation, scene, updatable, sideOrientation) {
  87827. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  87828. };
  87829. /**
  87830. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  87831. * @param name defines the name of the mesh to create
  87832. * @param size sets the size (float) of both sides of the plane at once (default 1)
  87833. * @param scene defines the hosting scene
  87834. * @param updatable defines if the mesh must be flagged as updatable
  87835. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87836. * @returns a new Mesh
  87837. */
  87838. Mesh.CreatePlane = function (name, size, scene, updatable, sideOrientation) {
  87839. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  87840. };
  87841. /**
  87842. * Creates a ground mesh.
  87843. * Please consider using the same method from the MeshBuilder class instead
  87844. * @param name defines the name of the mesh to create
  87845. * @param width set the width of the ground
  87846. * @param height set the height of the ground
  87847. * @param subdivisions sets the number of subdivisions per side
  87848. * @param scene defines the hosting scene
  87849. * @param updatable defines if the mesh must be flagged as updatable
  87850. * @returns a new Mesh
  87851. */
  87852. Mesh.CreateGround = function (name, width, height, subdivisions, scene, updatable) {
  87853. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  87854. };
  87855. /**
  87856. * Creates a tiled ground mesh.
  87857. * Please consider using the same method from the MeshBuilder class instead
  87858. * @param name defines the name of the mesh to create
  87859. * @param xmin set the ground minimum X coordinate
  87860. * @param zmin set the ground minimum Y coordinate
  87861. * @param xmax set the ground maximum X coordinate
  87862. * @param zmax set the ground maximum Z coordinate
  87863. * @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
  87864. * @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
  87865. * @param scene defines the hosting scene
  87866. * @param updatable defines if the mesh must be flagged as updatable
  87867. * @returns a new Mesh
  87868. */
  87869. Mesh.CreateTiledGround = function (name, xmin, zmin, xmax, zmax, subdivisions, precision, scene, updatable) {
  87870. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  87871. };
  87872. /**
  87873. * Creates a ground mesh from a height map.
  87874. * Please consider using the same method from the MeshBuilder class instead
  87875. * @see http://doc.babylonjs.com/babylon101/height_map
  87876. * @param name defines the name of the mesh to create
  87877. * @param url sets the URL of the height map image resource
  87878. * @param width set the ground width size
  87879. * @param height set the ground height size
  87880. * @param subdivisions sets the number of subdivision per side
  87881. * @param minHeight is the minimum altitude on the ground
  87882. * @param maxHeight is the maximum altitude on the ground
  87883. * @param scene defines the hosting scene
  87884. * @param updatable defines if the mesh must be flagged as updatable
  87885. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  87886. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  87887. * @returns a new Mesh
  87888. */
  87889. Mesh.CreateGroundFromHeightMap = function (name, url, width, height, subdivisions, minHeight, maxHeight, scene, updatable, onReady, alphaFilter) {
  87890. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  87891. };
  87892. /**
  87893. * Creates a tube mesh.
  87894. * The tube is a parametric shape.
  87895. * It has no predefined shape. Its final shape will depend on the input parameters.
  87896. * Please consider using the same method from the MeshBuilder class instead
  87897. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  87898. * @param name defines the name of the mesh to create
  87899. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  87900. * @param radius sets the tube radius size
  87901. * @param tessellation is the number of sides on the tubular surface
  87902. * @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
  87903. * @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
  87904. * @param scene defines the hosting scene
  87905. * @param updatable defines if the mesh must be flagged as updatable
  87906. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87907. * @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)
  87908. * @returns a new Mesh
  87909. */
  87910. Mesh.CreateTube = function (name, path, radius, tessellation, radiusFunction, cap, scene, updatable, sideOrientation, instance) {
  87911. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  87912. };
  87913. /**
  87914. * Creates a polyhedron mesh.
  87915. * Please consider using the same method from the MeshBuilder class instead.
  87916. * * 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
  87917. * * The parameter `size` (positive float, default 1) sets the polygon size
  87918. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  87919. * * 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`
  87920. * * 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
  87921. * * 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)`)
  87922. * * 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
  87923. * * 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
  87924. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87925. * * 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
  87926. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  87927. * @param name defines the name of the mesh to create
  87928. * @param options defines the options used to create the mesh
  87929. * @param scene defines the hosting scene
  87930. * @returns a new Mesh
  87931. */
  87932. Mesh.CreatePolyhedron = function (name, options, scene) {
  87933. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  87934. };
  87935. /**
  87936. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  87937. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  87938. * * 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`)
  87939. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  87940. * * 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
  87941. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87942. * * 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
  87943. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  87944. * @param name defines the name of the mesh
  87945. * @param options defines the options used to create the mesh
  87946. * @param scene defines the hosting scene
  87947. * @returns a new Mesh
  87948. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  87949. */
  87950. Mesh.CreateIcoSphere = function (name, options, scene) {
  87951. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  87952. };
  87953. /**
  87954. * Creates a decal mesh.
  87955. * Please consider using the same method from the MeshBuilder class instead.
  87956. * A decal is a mesh usually applied as a model onto the surface of another mesh
  87957. * @param name defines the name of the mesh
  87958. * @param sourceMesh defines the mesh receiving the decal
  87959. * @param position sets the position of the decal in world coordinates
  87960. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  87961. * @param size sets the decal scaling
  87962. * @param angle sets the angle to rotate the decal
  87963. * @returns a new Mesh
  87964. */
  87965. Mesh.CreateDecal = function (name, sourceMesh, position, normal, size, angle) {
  87966. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  87967. };
  87968. // Skeletons
  87969. /**
  87970. * Prepare internal position array for software CPU skinning
  87971. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  87972. */
  87973. Mesh.prototype.setPositionsForCPUSkinning = function () {
  87974. if (!this._sourcePositions) {
  87975. var source = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  87976. if (!source) {
  87977. return this._sourcePositions;
  87978. }
  87979. this._sourcePositions = new Float32Array(source);
  87980. if (!this.isVertexBufferUpdatable(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  87981. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, source, true);
  87982. }
  87983. }
  87984. return this._sourcePositions;
  87985. };
  87986. /**
  87987. * Prepare internal normal array for software CPU skinning
  87988. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  87989. */
  87990. Mesh.prototype.setNormalsForCPUSkinning = function () {
  87991. if (!this._sourceNormals) {
  87992. var source = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  87993. if (!source) {
  87994. return this._sourceNormals;
  87995. }
  87996. this._sourceNormals = new Float32Array(source);
  87997. if (!this.isVertexBufferUpdatable(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  87998. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, source, true);
  87999. }
  88000. }
  88001. return this._sourceNormals;
  88002. };
  88003. /**
  88004. * Updates the vertex buffer by applying transformation from the bones
  88005. * @param skeleton defines the skeleton to apply to current mesh
  88006. * @returns the current mesh
  88007. */
  88008. Mesh.prototype.applySkeleton = function (skeleton) {
  88009. if (!this.geometry) {
  88010. return this;
  88011. }
  88012. if (this.geometry._softwareSkinningFrameId == this.getScene().getFrameId()) {
  88013. return this;
  88014. }
  88015. this.geometry._softwareSkinningFrameId = this.getScene().getFrameId();
  88016. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  88017. return this;
  88018. }
  88019. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  88020. return this;
  88021. }
  88022. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind)) {
  88023. return this;
  88024. }
  88025. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind)) {
  88026. return this;
  88027. }
  88028. if (!this._sourcePositions) {
  88029. var submeshes = this.subMeshes.slice();
  88030. this.setPositionsForCPUSkinning();
  88031. this.subMeshes = submeshes;
  88032. }
  88033. if (!this._sourceNormals) {
  88034. this.setNormalsForCPUSkinning();
  88035. }
  88036. // positionsData checks for not being Float32Array will only pass at most once
  88037. var positionsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  88038. if (!positionsData) {
  88039. return this;
  88040. }
  88041. if (!(positionsData instanceof Float32Array)) {
  88042. positionsData = new Float32Array(positionsData);
  88043. }
  88044. // normalsData checks for not being Float32Array will only pass at most once
  88045. var normalsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  88046. if (!normalsData) {
  88047. return this;
  88048. }
  88049. if (!(normalsData instanceof Float32Array)) {
  88050. normalsData = new Float32Array(normalsData);
  88051. }
  88052. var matricesIndicesData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  88053. var matricesWeightsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  88054. if (!matricesWeightsData || !matricesIndicesData) {
  88055. return this;
  88056. }
  88057. var needExtras = this.numBoneInfluencers > 4;
  88058. var matricesIndicesExtraData = needExtras ? this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesExtraKind) : null;
  88059. var matricesWeightsExtraData = needExtras ? this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind) : null;
  88060. var skeletonMatrices = skeleton.getTransformMatrices(this);
  88061. var tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  88062. var finalMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  88063. var tempMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  88064. var matWeightIdx = 0;
  88065. var inf;
  88066. for (var index = 0; index < positionsData.length; index += 3, matWeightIdx += 4) {
  88067. var weight;
  88068. for (inf = 0; inf < 4; inf++) {
  88069. weight = matricesWeightsData[matWeightIdx + inf];
  88070. if (weight > 0) {
  88071. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[matWeightIdx + inf] * 16), weight, tempMatrix);
  88072. finalMatrix.addToSelf(tempMatrix);
  88073. }
  88074. }
  88075. if (needExtras) {
  88076. for (inf = 0; inf < 4; inf++) {
  88077. weight = matricesWeightsExtraData[matWeightIdx + inf];
  88078. if (weight > 0) {
  88079. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[matWeightIdx + inf] * 16), weight, tempMatrix);
  88080. finalMatrix.addToSelf(tempMatrix);
  88081. }
  88082. }
  88083. }
  88084. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformCoordinatesFromFloatsToRef(this._sourcePositions[index], this._sourcePositions[index + 1], this._sourcePositions[index + 2], finalMatrix, tempVector3);
  88085. tempVector3.toArray(positionsData, index);
  88086. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormalFromFloatsToRef(this._sourceNormals[index], this._sourceNormals[index + 1], this._sourceNormals[index + 2], finalMatrix, tempVector3);
  88087. tempVector3.toArray(normalsData, index);
  88088. finalMatrix.reset();
  88089. }
  88090. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positionsData);
  88091. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normalsData);
  88092. return this;
  88093. };
  88094. // Tools
  88095. /**
  88096. * 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
  88097. * @param meshes defines the list of meshes to scan
  88098. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  88099. */
  88100. Mesh.MinMax = function (meshes) {
  88101. var minVector = null;
  88102. var maxVector = null;
  88103. meshes.forEach(function (mesh) {
  88104. var boundingInfo = mesh.getBoundingInfo();
  88105. var boundingBox = boundingInfo.boundingBox;
  88106. if (!minVector || !maxVector) {
  88107. minVector = boundingBox.minimumWorld;
  88108. maxVector = boundingBox.maximumWorld;
  88109. }
  88110. else {
  88111. minVector.minimizeInPlace(boundingBox.minimumWorld);
  88112. maxVector.maximizeInPlace(boundingBox.maximumWorld);
  88113. }
  88114. });
  88115. if (!minVector || !maxVector) {
  88116. return {
  88117. min: _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero(),
  88118. max: _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero()
  88119. };
  88120. }
  88121. return {
  88122. min: minVector,
  88123. max: maxVector
  88124. };
  88125. };
  88126. /**
  88127. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  88128. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  88129. * @returns a vector3
  88130. */
  88131. Mesh.Center = function (meshesOrMinMaxVector) {
  88132. var minMaxVector = (meshesOrMinMaxVector instanceof Array) ? Mesh.MinMax(meshesOrMinMaxVector) : meshesOrMinMaxVector;
  88133. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Center(minMaxVector.min, minMaxVector.max);
  88134. };
  88135. /**
  88136. * Merge the array of meshes into a single mesh for performance reasons.
  88137. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  88138. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  88139. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  88140. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  88141. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  88142. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  88143. * @returns a new mesh
  88144. */
  88145. Mesh.MergeMeshes = function (meshes, disposeSource, allow32BitsIndices, meshSubclass, subdivideWithSubMeshes, multiMultiMaterials) {
  88146. if (disposeSource === void 0) { disposeSource = true; }
  88147. var index;
  88148. if (!allow32BitsIndices) {
  88149. var totalVertices = 0;
  88150. // Counting vertices
  88151. for (index = 0; index < meshes.length; index++) {
  88152. if (meshes[index]) {
  88153. totalVertices += meshes[index].getTotalVertices();
  88154. if (totalVertices > 65536) {
  88155. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("Cannot merge meshes because resulting mesh will have more than 65536 vertices. Please use allow32BitsIndices = true to use 32 bits indices");
  88156. return null;
  88157. }
  88158. }
  88159. }
  88160. }
  88161. if (multiMultiMaterials) {
  88162. var newMultiMaterial = null;
  88163. var subIndex;
  88164. var matIndex;
  88165. subdivideWithSubMeshes = false;
  88166. }
  88167. var materialArray = new Array();
  88168. var materialIndexArray = new Array();
  88169. // Merge
  88170. var vertexData = null;
  88171. var otherVertexData;
  88172. var indiceArray = new Array();
  88173. var source = null;
  88174. for (index = 0; index < meshes.length; index++) {
  88175. if (meshes[index]) {
  88176. var mesh = meshes[index];
  88177. var wm = mesh.computeWorldMatrix(true);
  88178. otherVertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(mesh, true, true);
  88179. otherVertexData.transform(wm);
  88180. if (vertexData) {
  88181. vertexData.merge(otherVertexData, allow32BitsIndices);
  88182. }
  88183. else {
  88184. vertexData = otherVertexData;
  88185. source = mesh;
  88186. }
  88187. if (subdivideWithSubMeshes) {
  88188. indiceArray.push(mesh.getTotalIndices());
  88189. }
  88190. if (multiMultiMaterials) {
  88191. if (mesh.material) {
  88192. var material = mesh.material;
  88193. if (material instanceof _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_14__["MultiMaterial"]) {
  88194. for (matIndex = 0; matIndex < material.subMaterials.length; matIndex++) {
  88195. if (materialArray.indexOf(material.subMaterials[matIndex]) < 0) {
  88196. materialArray.push(material.subMaterials[matIndex]);
  88197. }
  88198. }
  88199. for (subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  88200. materialIndexArray.push(materialArray.indexOf(material.subMaterials[mesh.subMeshes[subIndex].materialIndex]));
  88201. indiceArray.push(mesh.subMeshes[subIndex].indexCount);
  88202. }
  88203. }
  88204. else {
  88205. if (materialArray.indexOf(material) < 0) {
  88206. materialArray.push(material);
  88207. }
  88208. for (subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  88209. materialIndexArray.push(materialArray.indexOf(material));
  88210. indiceArray.push(mesh.subMeshes[subIndex].indexCount);
  88211. }
  88212. }
  88213. }
  88214. else {
  88215. for (subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  88216. materialIndexArray.push(0);
  88217. indiceArray.push(mesh.subMeshes[subIndex].indexCount);
  88218. }
  88219. }
  88220. }
  88221. }
  88222. }
  88223. source = source;
  88224. if (!meshSubclass) {
  88225. meshSubclass = new Mesh(source.name + "_merged", source.getScene());
  88226. }
  88227. vertexData.applyToMesh(meshSubclass);
  88228. // Setting properties
  88229. meshSubclass.checkCollisions = source.checkCollisions;
  88230. // Cleaning
  88231. if (disposeSource) {
  88232. for (index = 0; index < meshes.length; index++) {
  88233. if (meshes[index]) {
  88234. meshes[index].dispose();
  88235. }
  88236. }
  88237. }
  88238. // Subdivide
  88239. if (subdivideWithSubMeshes || multiMultiMaterials) {
  88240. //-- removal of global submesh
  88241. meshSubclass.releaseSubMeshes();
  88242. index = 0;
  88243. var offset = 0;
  88244. //-- apply subdivision according to index table
  88245. while (index < indiceArray.length) {
  88246. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].CreateFromIndices(0, offset, indiceArray[index], meshSubclass);
  88247. offset += indiceArray[index];
  88248. index++;
  88249. }
  88250. }
  88251. if (multiMultiMaterials) {
  88252. newMultiMaterial = new _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_14__["MultiMaterial"](source.name + "_merged", source.getScene());
  88253. newMultiMaterial.subMaterials = materialArray;
  88254. for (subIndex = 0; subIndex < meshSubclass.subMeshes.length; subIndex++) {
  88255. meshSubclass.subMeshes[subIndex].materialIndex = materialIndexArray[subIndex];
  88256. }
  88257. meshSubclass.material = newMultiMaterial;
  88258. }
  88259. else {
  88260. meshSubclass.material = source.material;
  88261. }
  88262. return meshSubclass;
  88263. };
  88264. /** @hidden */
  88265. Mesh.prototype.addInstance = function (instance) {
  88266. instance._indexInSourceMeshInstanceArray = this.instances.length;
  88267. this.instances.push(instance);
  88268. };
  88269. /** @hidden */
  88270. Mesh.prototype.removeInstance = function (instance) {
  88271. // Remove from mesh
  88272. var index = instance._indexInSourceMeshInstanceArray;
  88273. if (index != -1) {
  88274. if (index !== this.instances.length - 1) {
  88275. var last = this.instances[this.instances.length - 1];
  88276. this.instances[index] = last;
  88277. last._indexInSourceMeshInstanceArray = index;
  88278. }
  88279. instance._indexInSourceMeshInstanceArray = -1;
  88280. this.instances.pop();
  88281. }
  88282. };
  88283. // Consts
  88284. /**
  88285. * Mesh side orientation : usually the external or front surface
  88286. */
  88287. Mesh.FRONTSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].FRONTSIDE;
  88288. /**
  88289. * Mesh side orientation : usually the internal or back surface
  88290. */
  88291. Mesh.BACKSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].BACKSIDE;
  88292. /**
  88293. * Mesh side orientation : both internal and external or front and back surfaces
  88294. */
  88295. Mesh.DOUBLESIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].DOUBLESIDE;
  88296. /**
  88297. * Mesh side orientation : by default, `FRONTSIDE`
  88298. */
  88299. Mesh.DEFAULTSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].DEFAULTSIDE;
  88300. /**
  88301. * Mesh cap setting : no cap
  88302. */
  88303. Mesh.NO_CAP = 0;
  88304. /**
  88305. * Mesh cap setting : one cap at the beginning of the mesh
  88306. */
  88307. Mesh.CAP_START = 1;
  88308. /**
  88309. * Mesh cap setting : one cap at the end of the mesh
  88310. */
  88311. Mesh.CAP_END = 2;
  88312. /**
  88313. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  88314. */
  88315. Mesh.CAP_ALL = 3;
  88316. // Statics
  88317. /** @hidden */
  88318. Mesh._GroundMeshParser = function (parsedMesh, scene) {
  88319. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("GroundMesh");
  88320. };
  88321. return Mesh;
  88322. }(_abstractMesh__WEBPACK_IMPORTED_MODULE_10__["AbstractMesh"]));
  88323. /***/ }),
  88324. /***/ "./Meshes/mesh.vertexData.ts":
  88325. /*!***********************************!*\
  88326. !*** ./Meshes/mesh.vertexData.ts ***!
  88327. \***********************************/
  88328. /*! exports provided: VertexData */
  88329. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  88330. "use strict";
  88331. __webpack_require__.r(__webpack_exports__);
  88332. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return VertexData; });
  88333. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  88334. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  88335. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  88336. /**
  88337. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  88338. */
  88339. var VertexData = /** @class */ (function () {
  88340. function VertexData() {
  88341. }
  88342. /**
  88343. * Uses the passed data array to set the set the values for the specified kind of data
  88344. * @param data a linear array of floating numbers
  88345. * @param kind the type of data that is being set, eg positions, colors etc
  88346. */
  88347. VertexData.prototype.set = function (data, kind) {
  88348. switch (kind) {
  88349. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind:
  88350. this.positions = data;
  88351. break;
  88352. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind:
  88353. this.normals = data;
  88354. break;
  88355. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind:
  88356. this.tangents = data;
  88357. break;
  88358. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind:
  88359. this.uvs = data;
  88360. break;
  88361. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind:
  88362. this.uvs2 = data;
  88363. break;
  88364. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind:
  88365. this.uvs3 = data;
  88366. break;
  88367. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind:
  88368. this.uvs4 = data;
  88369. break;
  88370. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind:
  88371. this.uvs5 = data;
  88372. break;
  88373. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind:
  88374. this.uvs6 = data;
  88375. break;
  88376. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind:
  88377. this.colors = data;
  88378. break;
  88379. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind:
  88380. this.matricesIndices = data;
  88381. break;
  88382. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind:
  88383. this.matricesWeights = data;
  88384. break;
  88385. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind:
  88386. this.matricesIndicesExtra = data;
  88387. break;
  88388. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind:
  88389. this.matricesWeightsExtra = data;
  88390. break;
  88391. }
  88392. };
  88393. /**
  88394. * Associates the vertexData to the passed Mesh.
  88395. * Sets it as updatable or not (default `false`)
  88396. * @param mesh the mesh the vertexData is applied to
  88397. * @param updatable when used and having the value true allows new data to update the vertexData
  88398. * @returns the VertexData
  88399. */
  88400. VertexData.prototype.applyToMesh = function (mesh, updatable) {
  88401. this._applyTo(mesh, updatable);
  88402. return this;
  88403. };
  88404. /**
  88405. * Associates the vertexData to the passed Geometry.
  88406. * Sets it as updatable or not (default `false`)
  88407. * @param geometry the geometry the vertexData is applied to
  88408. * @param updatable when used and having the value true allows new data to update the vertexData
  88409. * @returns VertexData
  88410. */
  88411. VertexData.prototype.applyToGeometry = function (geometry, updatable) {
  88412. this._applyTo(geometry, updatable);
  88413. return this;
  88414. };
  88415. /**
  88416. * Updates the associated mesh
  88417. * @param mesh the mesh to be updated
  88418. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  88419. * @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
  88420. * @returns VertexData
  88421. */
  88422. VertexData.prototype.updateMesh = function (mesh) {
  88423. this._update(mesh);
  88424. return this;
  88425. };
  88426. /**
  88427. * Updates the associated geometry
  88428. * @param geometry the geometry to be updated
  88429. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  88430. * @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
  88431. * @returns VertexData.
  88432. */
  88433. VertexData.prototype.updateGeometry = function (geometry) {
  88434. this._update(geometry);
  88435. return this;
  88436. };
  88437. VertexData.prototype._applyTo = function (meshOrGeometry, updatable) {
  88438. if (updatable === void 0) { updatable = false; }
  88439. if (this.positions) {
  88440. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions, updatable);
  88441. }
  88442. if (this.normals) {
  88443. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals, updatable);
  88444. }
  88445. if (this.tangents) {
  88446. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents, updatable);
  88447. }
  88448. if (this.uvs) {
  88449. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs, updatable);
  88450. }
  88451. if (this.uvs2) {
  88452. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2, updatable);
  88453. }
  88454. if (this.uvs3) {
  88455. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3, updatable);
  88456. }
  88457. if (this.uvs4) {
  88458. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4, updatable);
  88459. }
  88460. if (this.uvs5) {
  88461. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5, updatable);
  88462. }
  88463. if (this.uvs6) {
  88464. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6, updatable);
  88465. }
  88466. if (this.colors) {
  88467. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors, updatable);
  88468. }
  88469. if (this.matricesIndices) {
  88470. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices, updatable);
  88471. }
  88472. if (this.matricesWeights) {
  88473. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights, updatable);
  88474. }
  88475. if (this.matricesIndicesExtra) {
  88476. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra, updatable);
  88477. }
  88478. if (this.matricesWeightsExtra) {
  88479. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra, updatable);
  88480. }
  88481. if (this.indices) {
  88482. meshOrGeometry.setIndices(this.indices, null, updatable);
  88483. }
  88484. else {
  88485. meshOrGeometry.setIndices([], null);
  88486. }
  88487. return this;
  88488. };
  88489. VertexData.prototype._update = function (meshOrGeometry, updateExtends, makeItUnique) {
  88490. if (this.positions) {
  88491. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions, updateExtends, makeItUnique);
  88492. }
  88493. if (this.normals) {
  88494. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals, updateExtends, makeItUnique);
  88495. }
  88496. if (this.tangents) {
  88497. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents, updateExtends, makeItUnique);
  88498. }
  88499. if (this.uvs) {
  88500. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs, updateExtends, makeItUnique);
  88501. }
  88502. if (this.uvs2) {
  88503. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2, updateExtends, makeItUnique);
  88504. }
  88505. if (this.uvs3) {
  88506. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3, updateExtends, makeItUnique);
  88507. }
  88508. if (this.uvs4) {
  88509. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4, updateExtends, makeItUnique);
  88510. }
  88511. if (this.uvs5) {
  88512. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5, updateExtends, makeItUnique);
  88513. }
  88514. if (this.uvs6) {
  88515. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6, updateExtends, makeItUnique);
  88516. }
  88517. if (this.colors) {
  88518. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors, updateExtends, makeItUnique);
  88519. }
  88520. if (this.matricesIndices) {
  88521. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices, updateExtends, makeItUnique);
  88522. }
  88523. if (this.matricesWeights) {
  88524. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights, updateExtends, makeItUnique);
  88525. }
  88526. if (this.matricesIndicesExtra) {
  88527. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra, updateExtends, makeItUnique);
  88528. }
  88529. if (this.matricesWeightsExtra) {
  88530. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra, updateExtends, makeItUnique);
  88531. }
  88532. if (this.indices) {
  88533. meshOrGeometry.setIndices(this.indices, null);
  88534. }
  88535. return this;
  88536. };
  88537. /**
  88538. * Transforms each position and each normal of the vertexData according to the passed Matrix
  88539. * @param matrix the transforming matrix
  88540. * @returns the VertexData
  88541. */
  88542. VertexData.prototype.transform = function (matrix) {
  88543. var flip = matrix.m[0] * matrix.m[5] * matrix.m[10] < 0;
  88544. var transformed = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  88545. var index;
  88546. if (this.positions) {
  88547. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  88548. for (index = 0; index < this.positions.length; index += 3) {
  88549. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(this.positions, index, position);
  88550. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(position, matrix, transformed);
  88551. this.positions[index] = transformed.x;
  88552. this.positions[index + 1] = transformed.y;
  88553. this.positions[index + 2] = transformed.z;
  88554. }
  88555. }
  88556. if (this.normals) {
  88557. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  88558. for (index = 0; index < this.normals.length; index += 3) {
  88559. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(this.normals, index, normal);
  88560. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(normal, matrix, transformed);
  88561. this.normals[index] = transformed.x;
  88562. this.normals[index + 1] = transformed.y;
  88563. this.normals[index + 2] = transformed.z;
  88564. }
  88565. }
  88566. if (this.tangents) {
  88567. var tangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].Zero();
  88568. var tangentTransformed = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].Zero();
  88569. for (index = 0; index < this.tangents.length; index += 4) {
  88570. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].FromArrayToRef(this.tangents, index, tangent);
  88571. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].TransformNormalToRef(tangent, matrix, tangentTransformed);
  88572. this.tangents[index] = tangentTransformed.x;
  88573. this.tangents[index + 1] = tangentTransformed.y;
  88574. this.tangents[index + 2] = tangentTransformed.z;
  88575. this.tangents[index + 3] = tangentTransformed.w;
  88576. }
  88577. }
  88578. if (flip && this.indices) {
  88579. for (index = 0; index < this.indices.length; index += 3) {
  88580. var tmp = this.indices[index + 1];
  88581. this.indices[index + 1] = this.indices[index + 2];
  88582. this.indices[index + 2] = tmp;
  88583. }
  88584. }
  88585. return this;
  88586. };
  88587. /**
  88588. * Merges the passed VertexData into the current one
  88589. * @param other the VertexData to be merged into the current one
  88590. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  88591. * @returns the modified VertexData
  88592. */
  88593. VertexData.prototype.merge = function (other, use32BitsIndices) {
  88594. if (use32BitsIndices === void 0) { use32BitsIndices = false; }
  88595. this._validate();
  88596. other._validate();
  88597. if (!this.normals !== !other.normals ||
  88598. !this.tangents !== !other.tangents ||
  88599. !this.uvs !== !other.uvs ||
  88600. !this.uvs2 !== !other.uvs2 ||
  88601. !this.uvs3 !== !other.uvs3 ||
  88602. !this.uvs4 !== !other.uvs4 ||
  88603. !this.uvs5 !== !other.uvs5 ||
  88604. !this.uvs6 !== !other.uvs6 ||
  88605. !this.colors !== !other.colors ||
  88606. !this.matricesIndices !== !other.matricesIndices ||
  88607. !this.matricesWeights !== !other.matricesWeights ||
  88608. !this.matricesIndicesExtra !== !other.matricesIndicesExtra ||
  88609. !this.matricesWeightsExtra !== !other.matricesWeightsExtra) {
  88610. throw new Error("Cannot merge vertex data that do not have the same set of attributes");
  88611. }
  88612. if (other.indices) {
  88613. if (!this.indices) {
  88614. this.indices = [];
  88615. }
  88616. var offset = this.positions ? this.positions.length / 3 : 0;
  88617. var isSrcTypedArray = this.indices.BYTES_PER_ELEMENT !== undefined;
  88618. if (isSrcTypedArray) {
  88619. var len = this.indices.length + other.indices.length;
  88620. var temp = use32BitsIndices || this.indices instanceof Uint32Array ? new Uint32Array(len) : new Uint16Array(len);
  88621. temp.set(this.indices);
  88622. var decal = this.indices.length;
  88623. for (var index = 0; index < other.indices.length; index++) {
  88624. temp[decal + index] = other.indices[index] + offset;
  88625. }
  88626. this.indices = temp;
  88627. }
  88628. else {
  88629. for (var index = 0; index < other.indices.length; index++) {
  88630. this.indices.push(other.indices[index] + offset);
  88631. }
  88632. }
  88633. }
  88634. this.positions = this._mergeElement(this.positions, other.positions);
  88635. this.normals = this._mergeElement(this.normals, other.normals);
  88636. this.tangents = this._mergeElement(this.tangents, other.tangents);
  88637. this.uvs = this._mergeElement(this.uvs, other.uvs);
  88638. this.uvs2 = this._mergeElement(this.uvs2, other.uvs2);
  88639. this.uvs3 = this._mergeElement(this.uvs3, other.uvs3);
  88640. this.uvs4 = this._mergeElement(this.uvs4, other.uvs4);
  88641. this.uvs5 = this._mergeElement(this.uvs5, other.uvs5);
  88642. this.uvs6 = this._mergeElement(this.uvs6, other.uvs6);
  88643. this.colors = this._mergeElement(this.colors, other.colors);
  88644. this.matricesIndices = this._mergeElement(this.matricesIndices, other.matricesIndices);
  88645. this.matricesWeights = this._mergeElement(this.matricesWeights, other.matricesWeights);
  88646. this.matricesIndicesExtra = this._mergeElement(this.matricesIndicesExtra, other.matricesIndicesExtra);
  88647. this.matricesWeightsExtra = this._mergeElement(this.matricesWeightsExtra, other.matricesWeightsExtra);
  88648. return this;
  88649. };
  88650. VertexData.prototype._mergeElement = function (source, other) {
  88651. if (!source) {
  88652. return other;
  88653. }
  88654. if (!other) {
  88655. return source;
  88656. }
  88657. var len = other.length + source.length;
  88658. var isSrcTypedArray = source instanceof Float32Array;
  88659. var isOthTypedArray = other instanceof Float32Array;
  88660. // use non-loop method when the source is Float32Array
  88661. if (isSrcTypedArray) {
  88662. var ret32 = new Float32Array(len);
  88663. ret32.set(source);
  88664. ret32.set(other, source.length);
  88665. return ret32;
  88666. // source is number[], when other is also use concat
  88667. }
  88668. else if (!isOthTypedArray) {
  88669. return source.concat(other);
  88670. // source is a number[], but other is a Float32Array, loop required
  88671. }
  88672. else {
  88673. var ret = source.slice(0); // copy source to a separate array
  88674. for (var i = 0, len = other.length; i < len; i++) {
  88675. ret.push(other[i]);
  88676. }
  88677. return ret;
  88678. }
  88679. };
  88680. VertexData.prototype._validate = function () {
  88681. if (!this.positions) {
  88682. throw new Error("Positions are required");
  88683. }
  88684. var getElementCount = function (kind, values) {
  88685. var stride = _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].DeduceStride(kind);
  88686. if ((values.length % stride) !== 0) {
  88687. throw new Error("The " + kind + "s array count must be a multiple of " + stride);
  88688. }
  88689. return values.length / stride;
  88690. };
  88691. var positionsElementCount = getElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions);
  88692. var validateElementCount = function (kind, values) {
  88693. var elementCount = getElementCount(kind, values);
  88694. if (elementCount !== positionsElementCount) {
  88695. throw new Error("The " + kind + "s element count (" + elementCount + ") does not match the positions count (" + positionsElementCount + ")");
  88696. }
  88697. };
  88698. if (this.normals) {
  88699. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals);
  88700. }
  88701. if (this.tangents) {
  88702. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents);
  88703. }
  88704. if (this.uvs) {
  88705. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs);
  88706. }
  88707. if (this.uvs2) {
  88708. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2);
  88709. }
  88710. if (this.uvs3) {
  88711. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3);
  88712. }
  88713. if (this.uvs4) {
  88714. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4);
  88715. }
  88716. if (this.uvs5) {
  88717. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5);
  88718. }
  88719. if (this.uvs6) {
  88720. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6);
  88721. }
  88722. if (this.colors) {
  88723. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors);
  88724. }
  88725. if (this.matricesIndices) {
  88726. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices);
  88727. }
  88728. if (this.matricesWeights) {
  88729. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights);
  88730. }
  88731. if (this.matricesIndicesExtra) {
  88732. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra);
  88733. }
  88734. if (this.matricesWeightsExtra) {
  88735. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra);
  88736. }
  88737. };
  88738. /**
  88739. * Serializes the VertexData
  88740. * @returns a serialized object
  88741. */
  88742. VertexData.prototype.serialize = function () {
  88743. var serializationObject = this.serialize();
  88744. if (this.positions) {
  88745. serializationObject.positions = this.positions;
  88746. }
  88747. if (this.normals) {
  88748. serializationObject.normals = this.normals;
  88749. }
  88750. if (this.tangents) {
  88751. serializationObject.tangents = this.tangents;
  88752. }
  88753. if (this.uvs) {
  88754. serializationObject.uvs = this.uvs;
  88755. }
  88756. if (this.uvs2) {
  88757. serializationObject.uvs2 = this.uvs2;
  88758. }
  88759. if (this.uvs3) {
  88760. serializationObject.uvs3 = this.uvs3;
  88761. }
  88762. if (this.uvs4) {
  88763. serializationObject.uvs4 = this.uvs4;
  88764. }
  88765. if (this.uvs5) {
  88766. serializationObject.uvs5 = this.uvs5;
  88767. }
  88768. if (this.uvs6) {
  88769. serializationObject.uvs6 = this.uvs6;
  88770. }
  88771. if (this.colors) {
  88772. serializationObject.colors = this.colors;
  88773. }
  88774. if (this.matricesIndices) {
  88775. serializationObject.matricesIndices = this.matricesIndices;
  88776. serializationObject.matricesIndices._isExpanded = true;
  88777. }
  88778. if (this.matricesWeights) {
  88779. serializationObject.matricesWeights = this.matricesWeights;
  88780. }
  88781. if (this.matricesIndicesExtra) {
  88782. serializationObject.matricesIndicesExtra = this.matricesIndicesExtra;
  88783. serializationObject.matricesIndicesExtra._isExpanded = true;
  88784. }
  88785. if (this.matricesWeightsExtra) {
  88786. serializationObject.matricesWeightsExtra = this.matricesWeightsExtra;
  88787. }
  88788. serializationObject.indices = this.indices;
  88789. return serializationObject;
  88790. };
  88791. // Statics
  88792. /**
  88793. * Extracts the vertexData from a mesh
  88794. * @param mesh the mesh from which to extract the VertexData
  88795. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  88796. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  88797. * @returns the object VertexData associated to the passed mesh
  88798. */
  88799. VertexData.ExtractFromMesh = function (mesh, copyWhenShared, forceCopy) {
  88800. return VertexData._ExtractFrom(mesh, copyWhenShared, forceCopy);
  88801. };
  88802. /**
  88803. * Extracts the vertexData from the geometry
  88804. * @param geometry the geometry from which to extract the VertexData
  88805. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  88806. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  88807. * @returns the object VertexData associated to the passed mesh
  88808. */
  88809. VertexData.ExtractFromGeometry = function (geometry, copyWhenShared, forceCopy) {
  88810. return VertexData._ExtractFrom(geometry, copyWhenShared, forceCopy);
  88811. };
  88812. VertexData._ExtractFrom = function (meshOrGeometry, copyWhenShared, forceCopy) {
  88813. var result = new VertexData();
  88814. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind)) {
  88815. result.positions = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, copyWhenShared, forceCopy);
  88816. }
  88817. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind)) {
  88818. result.normals = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, copyWhenShared, forceCopy);
  88819. }
  88820. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind)) {
  88821. result.tangents = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, copyWhenShared, forceCopy);
  88822. }
  88823. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  88824. result.uvs = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, copyWhenShared, forceCopy);
  88825. }
  88826. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  88827. result.uvs2 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, copyWhenShared, forceCopy);
  88828. }
  88829. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind)) {
  88830. result.uvs3 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, copyWhenShared, forceCopy);
  88831. }
  88832. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind)) {
  88833. result.uvs4 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, copyWhenShared, forceCopy);
  88834. }
  88835. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind)) {
  88836. result.uvs5 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, copyWhenShared, forceCopy);
  88837. }
  88838. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind)) {
  88839. result.uvs6 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, copyWhenShared, forceCopy);
  88840. }
  88841. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind)) {
  88842. result.colors = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, copyWhenShared, forceCopy);
  88843. }
  88844. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind)) {
  88845. result.matricesIndices = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, copyWhenShared, forceCopy);
  88846. }
  88847. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind)) {
  88848. result.matricesWeights = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, copyWhenShared, forceCopy);
  88849. }
  88850. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind)) {
  88851. result.matricesIndicesExtra = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, copyWhenShared, forceCopy);
  88852. }
  88853. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind)) {
  88854. result.matricesWeightsExtra = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, copyWhenShared, forceCopy);
  88855. }
  88856. result.indices = meshOrGeometry.getIndices(copyWhenShared, forceCopy);
  88857. return result;
  88858. };
  88859. /**
  88860. * Creates the VertexData for a Ribbon
  88861. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  88862. * * pathArray array of paths, each of which an array of successive Vector3
  88863. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  88864. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  88865. * * 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
  88866. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88867. * * 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)
  88868. * * 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)
  88869. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  88870. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  88871. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  88872. * @returns the VertexData of the ribbon
  88873. */
  88874. VertexData.CreateRibbon = function (options) {
  88875. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("ribbonBuilder");
  88876. };
  88877. /**
  88878. * Creates the VertexData for a box
  88879. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88880. * * size sets the width, height and depth of the box to the value of size, optional default 1
  88881. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  88882. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  88883. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  88884. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  88885. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  88886. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88887. * * 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)
  88888. * * 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)
  88889. * @returns the VertexData of the box
  88890. */
  88891. VertexData.CreateBox = function (options) {
  88892. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("boxBuilder");
  88893. };
  88894. /**
  88895. * Creates the VertexData for an ellipsoid, defaults to a sphere
  88896. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88897. * * segments sets the number of horizontal strips optional, default 32
  88898. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  88899. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  88900. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  88901. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  88902. * * 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
  88903. * * 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
  88904. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88905. * * 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)
  88906. * * 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)
  88907. * @returns the VertexData of the ellipsoid
  88908. */
  88909. VertexData.CreateSphere = function (options) {
  88910. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("sphereBuilder");
  88911. };
  88912. /**
  88913. * Creates the VertexData for a cylinder, cone or prism
  88914. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88915. * * height sets the height (y direction) of the cylinder, optional, default 2
  88916. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  88917. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  88918. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  88919. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  88920. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  88921. * * 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
  88922. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88923. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88924. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  88925. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  88926. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88927. * * 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)
  88928. * * 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)
  88929. * @returns the VertexData of the cylinder, cone or prism
  88930. */
  88931. VertexData.CreateCylinder = function (options) {
  88932. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("cylinderBuilder");
  88933. };
  88934. /**
  88935. * Creates the VertexData for a torus
  88936. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88937. * * diameter the diameter of the torus, optional default 1
  88938. * * thickness the diameter of the tube forming the torus, optional default 0.5
  88939. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  88940. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88941. * * 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)
  88942. * * 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)
  88943. * @returns the VertexData of the torus
  88944. */
  88945. VertexData.CreateTorus = function (options) {
  88946. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("torusBuilder");
  88947. };
  88948. /**
  88949. * Creates the VertexData of the LineSystem
  88950. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  88951. * - lines an array of lines, each line being an array of successive Vector3
  88952. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  88953. * @returns the VertexData of the LineSystem
  88954. */
  88955. VertexData.CreateLineSystem = function (options) {
  88956. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("linesBuilder");
  88957. };
  88958. /**
  88959. * Create the VertexData for a DashedLines
  88960. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  88961. * - points an array successive Vector3
  88962. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  88963. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  88964. * - dashNb the intended total number of dashes, optional, default 200
  88965. * @returns the VertexData for the DashedLines
  88966. */
  88967. VertexData.CreateDashedLines = function (options) {
  88968. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("linesBuilder");
  88969. };
  88970. /**
  88971. * Creates the VertexData for a Ground
  88972. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  88973. * - width the width (x direction) of the ground, optional, default 1
  88974. * - height the height (z direction) of the ground, optional, default 1
  88975. * - subdivisions the number of subdivisions per side, optional, default 1
  88976. * @returns the VertexData of the Ground
  88977. */
  88978. VertexData.CreateGround = function (options) {
  88979. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("groundBuilder");
  88980. };
  88981. /**
  88982. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  88983. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  88984. * * xmin the ground minimum X coordinate, optional, default -1
  88985. * * zmin the ground minimum Z coordinate, optional, default -1
  88986. * * xmax the ground maximum X coordinate, optional, default 1
  88987. * * zmax the ground maximum Z coordinate, optional, default 1
  88988. * * 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}
  88989. * * 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}
  88990. * @returns the VertexData of the TiledGround
  88991. */
  88992. VertexData.CreateTiledGround = function (options) {
  88993. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("groundBuilder");
  88994. };
  88995. /**
  88996. * Creates the VertexData of the Ground designed from a heightmap
  88997. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  88998. * * width the width (x direction) of the ground
  88999. * * height the height (z direction) of the ground
  89000. * * subdivisions the number of subdivisions per side
  89001. * * minHeight the minimum altitude on the ground, optional, default 0
  89002. * * maxHeight the maximum altitude on the ground, optional default 1
  89003. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  89004. * * buffer the array holding the image color data
  89005. * * bufferWidth the width of image
  89006. * * bufferHeight the height of image
  89007. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  89008. * @returns the VertexData of the Ground designed from a heightmap
  89009. */
  89010. VertexData.CreateGroundFromHeightMap = function (options) {
  89011. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("groundBuilder");
  89012. };
  89013. /**
  89014. * Creates the VertexData for a Plane
  89015. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  89016. * * size sets the width and height of the plane to the value of size, optional default 1
  89017. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  89018. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  89019. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89020. * * 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)
  89021. * * 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)
  89022. * @returns the VertexData of the box
  89023. */
  89024. VertexData.CreatePlane = function (options) {
  89025. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("planeBuilder");
  89026. };
  89027. /**
  89028. * Creates the VertexData of the Disc or regular Polygon
  89029. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  89030. * * radius the radius of the disc, optional default 0.5
  89031. * * tessellation the number of polygon sides, optional, default 64
  89032. * * 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
  89033. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89034. * * 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)
  89035. * * 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)
  89036. * @returns the VertexData of the box
  89037. */
  89038. VertexData.CreateDisc = function (options) {
  89039. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("discBuilder");
  89040. };
  89041. /**
  89042. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  89043. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  89044. * @param polygon a mesh built from polygonTriangulation.build()
  89045. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89046. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  89047. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  89048. * @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)
  89049. * @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)
  89050. * @returns the VertexData of the Polygon
  89051. */
  89052. VertexData.CreatePolygon = function (polygon, sideOrientation, fUV, fColors, frontUVs, backUVs) {
  89053. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("polygonBuilder");
  89054. };
  89055. /**
  89056. * Creates the VertexData of the IcoSphere
  89057. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  89058. * * radius the radius of the IcoSphere, optional default 1
  89059. * * radiusX allows stretching in the x direction, optional, default radius
  89060. * * radiusY allows stretching in the y direction, optional, default radius
  89061. * * radiusZ allows stretching in the z direction, optional, default radius
  89062. * * flat when true creates a flat shaded mesh, optional, default true
  89063. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  89064. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89065. * * 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)
  89066. * * 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)
  89067. * @returns the VertexData of the IcoSphere
  89068. */
  89069. VertexData.CreateIcoSphere = function (options) {
  89070. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("icoSphereBuilder");
  89071. };
  89072. // inspired from // http://stemkoski.github.io/Three.js/Polyhedra.html
  89073. /**
  89074. * Creates the VertexData for a Polyhedron
  89075. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  89076. * * type provided types are:
  89077. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  89078. * * 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)
  89079. * * size the size of the IcoSphere, optional default 1
  89080. * * sizeX allows stretching in the x direction, optional, default size
  89081. * * sizeY allows stretching in the y direction, optional, default size
  89082. * * sizeZ allows stretching in the z direction, optional, default size
  89083. * * 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
  89084. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  89085. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  89086. * * flat when true creates a flat shaded mesh, optional, default true
  89087. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  89088. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89089. * * 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)
  89090. * * 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)
  89091. * @returns the VertexData of the Polyhedron
  89092. */
  89093. VertexData.CreatePolyhedron = function (options) {
  89094. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("polyhedronBuilder");
  89095. };
  89096. // based on http://code.google.com/p/away3d/source/browse/trunk/fp10/Away3D/src/away3d/primitives/TorusKnot.as?spec=svn2473&r=2473
  89097. /**
  89098. * Creates the VertexData for a TorusKnot
  89099. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  89100. * * radius the radius of the torus knot, optional, default 2
  89101. * * tube the thickness of the tube, optional, default 0.5
  89102. * * radialSegments the number of sides on each tube segments, optional, default 32
  89103. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  89104. * * p the number of windings around the z axis, optional, default 2
  89105. * * q the number of windings around the x axis, optional, default 3
  89106. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89107. * * 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)
  89108. * * 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)
  89109. * @returns the VertexData of the Torus Knot
  89110. */
  89111. VertexData.CreateTorusKnot = function (options) {
  89112. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("torusKnotBuilder");
  89113. };
  89114. // Tools
  89115. /**
  89116. * Compute normals for given positions and indices
  89117. * @param positions an array of vertex positions, [...., x, y, z, ......]
  89118. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  89119. * @param normals an array of vertex normals, [...., x, y, z, ......]
  89120. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  89121. * * facetNormals : optional array of facet normals (vector3)
  89122. * * facetPositions : optional array of facet positions (vector3)
  89123. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  89124. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  89125. * * bInfo : optional bounding info, required for facetPartitioning computation
  89126. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  89127. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  89128. * * useRightHandedSystem: optional boolean to for right handed system computation
  89129. * * depthSort : optional boolean to enable the facet depth sort computation
  89130. * * distanceTo : optional Vector3 to compute the facet depth from this location
  89131. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  89132. */
  89133. VertexData.ComputeNormals = function (positions, indices, normals, options) {
  89134. // temporary scalar variables
  89135. var index = 0; // facet index
  89136. var p1p2x = 0.0; // p1p2 vector x coordinate
  89137. var p1p2y = 0.0; // p1p2 vector y coordinate
  89138. var p1p2z = 0.0; // p1p2 vector z coordinate
  89139. var p3p2x = 0.0; // p3p2 vector x coordinate
  89140. var p3p2y = 0.0; // p3p2 vector y coordinate
  89141. var p3p2z = 0.0; // p3p2 vector z coordinate
  89142. var faceNormalx = 0.0; // facet normal x coordinate
  89143. var faceNormaly = 0.0; // facet normal y coordinate
  89144. var faceNormalz = 0.0; // facet normal z coordinate
  89145. var length = 0.0; // facet normal length before normalization
  89146. var v1x = 0; // vector1 x index in the positions array
  89147. var v1y = 0; // vector1 y index in the positions array
  89148. var v1z = 0; // vector1 z index in the positions array
  89149. var v2x = 0; // vector2 x index in the positions array
  89150. var v2y = 0; // vector2 y index in the positions array
  89151. var v2z = 0; // vector2 z index in the positions array
  89152. var v3x = 0; // vector3 x index in the positions array
  89153. var v3y = 0; // vector3 y index in the positions array
  89154. var v3z = 0; // vector3 z index in the positions array
  89155. var computeFacetNormals = false;
  89156. var computeFacetPositions = false;
  89157. var computeFacetPartitioning = false;
  89158. var computeDepthSort = false;
  89159. var faceNormalSign = 1;
  89160. var ratio = 0;
  89161. var distanceTo = null;
  89162. if (options) {
  89163. computeFacetNormals = (options.facetNormals) ? true : false;
  89164. computeFacetPositions = (options.facetPositions) ? true : false;
  89165. computeFacetPartitioning = (options.facetPartitioning) ? true : false;
  89166. faceNormalSign = (options.useRightHandedSystem === true) ? -1 : 1;
  89167. ratio = options.ratio || 0;
  89168. computeDepthSort = (options.depthSort) ? true : false;
  89169. distanceTo = (options.distanceTo);
  89170. if (computeDepthSort) {
  89171. if (distanceTo === undefined) {
  89172. distanceTo = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  89173. }
  89174. var depthSortedFacets = options.depthSortedFacets;
  89175. }
  89176. }
  89177. // facetPartitioning reinit if needed
  89178. var xSubRatio = 0;
  89179. var ySubRatio = 0;
  89180. var zSubRatio = 0;
  89181. var subSq = 0;
  89182. if (computeFacetPartitioning && options && options.bbSize) {
  89183. var ox = 0; // X partitioning index for facet position
  89184. var oy = 0; // Y partinioning index for facet position
  89185. var oz = 0; // Z partinioning index for facet position
  89186. var b1x = 0; // X partitioning index for facet v1 vertex
  89187. var b1y = 0; // Y partitioning index for facet v1 vertex
  89188. var b1z = 0; // z partitioning index for facet v1 vertex
  89189. var b2x = 0; // X partitioning index for facet v2 vertex
  89190. var b2y = 0; // Y partitioning index for facet v2 vertex
  89191. var b2z = 0; // Z partitioning index for facet v2 vertex
  89192. var b3x = 0; // X partitioning index for facet v3 vertex
  89193. var b3y = 0; // Y partitioning index for facet v3 vertex
  89194. var b3z = 0; // Z partitioning index for facet v3 vertex
  89195. var block_idx_o = 0; // facet barycenter block index
  89196. var block_idx_v1 = 0; // v1 vertex block index
  89197. var block_idx_v2 = 0; // v2 vertex block index
  89198. var block_idx_v3 = 0; // v3 vertex block index
  89199. var bbSizeMax = (options.bbSize.x > options.bbSize.y) ? options.bbSize.x : options.bbSize.y;
  89200. bbSizeMax = (bbSizeMax > options.bbSize.z) ? bbSizeMax : options.bbSize.z;
  89201. xSubRatio = options.subDiv.X * ratio / options.bbSize.x;
  89202. ySubRatio = options.subDiv.Y * ratio / options.bbSize.y;
  89203. zSubRatio = options.subDiv.Z * ratio / options.bbSize.z;
  89204. subSq = options.subDiv.max * options.subDiv.max;
  89205. options.facetPartitioning.length = 0;
  89206. }
  89207. // reset the normals
  89208. for (index = 0; index < positions.length; index++) {
  89209. normals[index] = 0.0;
  89210. }
  89211. // Loop : 1 indice triplet = 1 facet
  89212. var nbFaces = (indices.length / 3) | 0;
  89213. for (index = 0; index < nbFaces; index++) {
  89214. // get the indexes of the coordinates of each vertex of the facet
  89215. v1x = indices[index * 3] * 3;
  89216. v1y = v1x + 1;
  89217. v1z = v1x + 2;
  89218. v2x = indices[index * 3 + 1] * 3;
  89219. v2y = v2x + 1;
  89220. v2z = v2x + 2;
  89221. v3x = indices[index * 3 + 2] * 3;
  89222. v3y = v3x + 1;
  89223. v3z = v3x + 2;
  89224. p1p2x = positions[v1x] - positions[v2x]; // compute two vectors per facet : p1p2 and p3p2
  89225. p1p2y = positions[v1y] - positions[v2y];
  89226. p1p2z = positions[v1z] - positions[v2z];
  89227. p3p2x = positions[v3x] - positions[v2x];
  89228. p3p2y = positions[v3y] - positions[v2y];
  89229. p3p2z = positions[v3z] - positions[v2z];
  89230. // compute the face normal with the cross product
  89231. faceNormalx = faceNormalSign * (p1p2y * p3p2z - p1p2z * p3p2y);
  89232. faceNormaly = faceNormalSign * (p1p2z * p3p2x - p1p2x * p3p2z);
  89233. faceNormalz = faceNormalSign * (p1p2x * p3p2y - p1p2y * p3p2x);
  89234. // normalize this normal and store it in the array facetData
  89235. length = Math.sqrt(faceNormalx * faceNormalx + faceNormaly * faceNormaly + faceNormalz * faceNormalz);
  89236. length = (length === 0) ? 1.0 : length;
  89237. faceNormalx /= length;
  89238. faceNormaly /= length;
  89239. faceNormalz /= length;
  89240. if (computeFacetNormals && options) {
  89241. options.facetNormals[index].x = faceNormalx;
  89242. options.facetNormals[index].y = faceNormaly;
  89243. options.facetNormals[index].z = faceNormalz;
  89244. }
  89245. if (computeFacetPositions && options) {
  89246. // compute and the facet barycenter coordinates in the array facetPositions
  89247. options.facetPositions[index].x = (positions[v1x] + positions[v2x] + positions[v3x]) / 3.0;
  89248. options.facetPositions[index].y = (positions[v1y] + positions[v2y] + positions[v3y]) / 3.0;
  89249. options.facetPositions[index].z = (positions[v1z] + positions[v2z] + positions[v3z]) / 3.0;
  89250. }
  89251. if (computeFacetPartitioning && options) {
  89252. // store the facet indexes in arrays in the main facetPartitioning array :
  89253. // compute each facet vertex (+ facet barycenter) index in the partiniong array
  89254. ox = Math.floor((options.facetPositions[index].x - options.bInfo.minimum.x * ratio) * xSubRatio);
  89255. oy = Math.floor((options.facetPositions[index].y - options.bInfo.minimum.y * ratio) * ySubRatio);
  89256. oz = Math.floor((options.facetPositions[index].z - options.bInfo.minimum.z * ratio) * zSubRatio);
  89257. b1x = Math.floor((positions[v1x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  89258. b1y = Math.floor((positions[v1y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  89259. b1z = Math.floor((positions[v1z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  89260. b2x = Math.floor((positions[v2x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  89261. b2y = Math.floor((positions[v2y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  89262. b2z = Math.floor((positions[v2z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  89263. b3x = Math.floor((positions[v3x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  89264. b3y = Math.floor((positions[v3y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  89265. b3z = Math.floor((positions[v3z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  89266. block_idx_v1 = b1x + options.subDiv.max * b1y + subSq * b1z;
  89267. block_idx_v2 = b2x + options.subDiv.max * b2y + subSq * b2z;
  89268. block_idx_v3 = b3x + options.subDiv.max * b3y + subSq * b3z;
  89269. block_idx_o = ox + options.subDiv.max * oy + subSq * oz;
  89270. options.facetPartitioning[block_idx_o] = options.facetPartitioning[block_idx_o] ? options.facetPartitioning[block_idx_o] : new Array();
  89271. options.facetPartitioning[block_idx_v1] = options.facetPartitioning[block_idx_v1] ? options.facetPartitioning[block_idx_v1] : new Array();
  89272. options.facetPartitioning[block_idx_v2] = options.facetPartitioning[block_idx_v2] ? options.facetPartitioning[block_idx_v2] : new Array();
  89273. options.facetPartitioning[block_idx_v3] = options.facetPartitioning[block_idx_v3] ? options.facetPartitioning[block_idx_v3] : new Array();
  89274. // push each facet index in each block containing the vertex
  89275. options.facetPartitioning[block_idx_v1].push(index);
  89276. if (block_idx_v2 != block_idx_v1) {
  89277. options.facetPartitioning[block_idx_v2].push(index);
  89278. }
  89279. if (!(block_idx_v3 == block_idx_v2 || block_idx_v3 == block_idx_v1)) {
  89280. options.facetPartitioning[block_idx_v3].push(index);
  89281. }
  89282. if (!(block_idx_o == block_idx_v1 || block_idx_o == block_idx_v2 || block_idx_o == block_idx_v3)) {
  89283. options.facetPartitioning[block_idx_o].push(index);
  89284. }
  89285. }
  89286. if (computeDepthSort && options && options.facetPositions) {
  89287. var dsf = depthSortedFacets[index];
  89288. dsf.ind = index * 3;
  89289. dsf.sqDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].DistanceSquared(options.facetPositions[index], distanceTo);
  89290. }
  89291. // compute the normals anyway
  89292. normals[v1x] += faceNormalx; // accumulate all the normals per face
  89293. normals[v1y] += faceNormaly;
  89294. normals[v1z] += faceNormalz;
  89295. normals[v2x] += faceNormalx;
  89296. normals[v2y] += faceNormaly;
  89297. normals[v2z] += faceNormalz;
  89298. normals[v3x] += faceNormalx;
  89299. normals[v3y] += faceNormaly;
  89300. normals[v3z] += faceNormalz;
  89301. }
  89302. // last normalization of each normal
  89303. for (index = 0; index < normals.length / 3; index++) {
  89304. faceNormalx = normals[index * 3];
  89305. faceNormaly = normals[index * 3 + 1];
  89306. faceNormalz = normals[index * 3 + 2];
  89307. length = Math.sqrt(faceNormalx * faceNormalx + faceNormaly * faceNormaly + faceNormalz * faceNormalz);
  89308. length = (length === 0) ? 1.0 : length;
  89309. faceNormalx /= length;
  89310. faceNormaly /= length;
  89311. faceNormalz /= length;
  89312. normals[index * 3] = faceNormalx;
  89313. normals[index * 3 + 1] = faceNormaly;
  89314. normals[index * 3 + 2] = faceNormalz;
  89315. }
  89316. };
  89317. /** @hidden */
  89318. VertexData._ComputeSides = function (sideOrientation, positions, indices, normals, uvs, frontUVs, backUVs) {
  89319. var li = indices.length;
  89320. var ln = normals.length;
  89321. var i;
  89322. var n;
  89323. sideOrientation = sideOrientation || VertexData.DEFAULTSIDE;
  89324. switch (sideOrientation) {
  89325. case VertexData.FRONTSIDE:
  89326. // nothing changed
  89327. break;
  89328. case VertexData.BACKSIDE:
  89329. var tmp;
  89330. // indices
  89331. for (i = 0; i < li; i += 3) {
  89332. tmp = indices[i];
  89333. indices[i] = indices[i + 2];
  89334. indices[i + 2] = tmp;
  89335. }
  89336. // normals
  89337. for (n = 0; n < ln; n++) {
  89338. normals[n] = -normals[n];
  89339. }
  89340. break;
  89341. case VertexData.DOUBLESIDE:
  89342. // positions
  89343. var lp = positions.length;
  89344. var l = lp / 3;
  89345. for (var p = 0; p < lp; p++) {
  89346. positions[lp + p] = positions[p];
  89347. }
  89348. // indices
  89349. for (i = 0; i < li; i += 3) {
  89350. indices[i + li] = indices[i + 2] + l;
  89351. indices[i + 1 + li] = indices[i + 1] + l;
  89352. indices[i + 2 + li] = indices[i] + l;
  89353. }
  89354. // normals
  89355. for (n = 0; n < ln; n++) {
  89356. normals[ln + n] = -normals[n];
  89357. }
  89358. // uvs
  89359. var lu = uvs.length;
  89360. var u = 0;
  89361. for (u = 0; u < lu; u++) {
  89362. uvs[u + lu] = uvs[u];
  89363. }
  89364. frontUVs = frontUVs ? frontUVs : new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  89365. backUVs = backUVs ? backUVs : new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  89366. u = 0;
  89367. for (i = 0; i < lu / 2; i++) {
  89368. uvs[u] = frontUVs.x + (frontUVs.z - frontUVs.x) * uvs[u];
  89369. uvs[u + 1] = frontUVs.y + (frontUVs.w - frontUVs.y) * uvs[u + 1];
  89370. uvs[u + lu] = backUVs.x + (backUVs.z - backUVs.x) * uvs[u + lu];
  89371. uvs[u + lu + 1] = backUVs.y + (backUVs.w - backUVs.y) * uvs[u + lu + 1];
  89372. u += 2;
  89373. }
  89374. break;
  89375. }
  89376. };
  89377. /**
  89378. * Applies VertexData created from the imported parameters to the geometry
  89379. * @param parsedVertexData the parsed data from an imported file
  89380. * @param geometry the geometry to apply the VertexData to
  89381. */
  89382. VertexData.ImportVertexData = function (parsedVertexData, geometry) {
  89383. var vertexData = new VertexData();
  89384. // positions
  89385. var positions = parsedVertexData.positions;
  89386. if (positions) {
  89387. vertexData.set(positions, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  89388. }
  89389. // normals
  89390. var normals = parsedVertexData.normals;
  89391. if (normals) {
  89392. vertexData.set(normals, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  89393. }
  89394. // tangents
  89395. var tangents = parsedVertexData.tangents;
  89396. if (tangents) {
  89397. vertexData.set(tangents, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind);
  89398. }
  89399. // uvs
  89400. var uvs = parsedVertexData.uvs;
  89401. if (uvs) {
  89402. vertexData.set(uvs, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  89403. }
  89404. // uv2s
  89405. var uv2s = parsedVertexData.uv2s;
  89406. if (uv2s) {
  89407. vertexData.set(uv2s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  89408. }
  89409. // uv3s
  89410. var uv3s = parsedVertexData.uv3s;
  89411. if (uv3s) {
  89412. vertexData.set(uv3s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind);
  89413. }
  89414. // uv4s
  89415. var uv4s = parsedVertexData.uv4s;
  89416. if (uv4s) {
  89417. vertexData.set(uv4s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind);
  89418. }
  89419. // uv5s
  89420. var uv5s = parsedVertexData.uv5s;
  89421. if (uv5s) {
  89422. vertexData.set(uv5s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind);
  89423. }
  89424. // uv6s
  89425. var uv6s = parsedVertexData.uv6s;
  89426. if (uv6s) {
  89427. vertexData.set(uv6s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind);
  89428. }
  89429. // colors
  89430. var colors = parsedVertexData.colors;
  89431. if (colors) {
  89432. vertexData.set(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"].CheckColors4(colors, positions.length / 3), _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  89433. }
  89434. // matricesIndices
  89435. var matricesIndices = parsedVertexData.matricesIndices;
  89436. if (matricesIndices) {
  89437. vertexData.set(matricesIndices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  89438. }
  89439. // matricesWeights
  89440. var matricesWeights = parsedVertexData.matricesWeights;
  89441. if (matricesWeights) {
  89442. vertexData.set(matricesWeights, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  89443. }
  89444. // indices
  89445. var indices = parsedVertexData.indices;
  89446. if (indices) {
  89447. vertexData.indices = indices;
  89448. }
  89449. geometry.setAllVerticesData(vertexData, parsedVertexData.updatable);
  89450. };
  89451. /**
  89452. * Mesh side orientation : usually the external or front surface
  89453. */
  89454. VertexData.FRONTSIDE = 0;
  89455. /**
  89456. * Mesh side orientation : usually the internal or back surface
  89457. */
  89458. VertexData.BACKSIDE = 1;
  89459. /**
  89460. * Mesh side orientation : both internal and external or front and back surfaces
  89461. */
  89462. VertexData.DOUBLESIDE = 2;
  89463. /**
  89464. * Mesh side orientation : by default, `FRONTSIDE`
  89465. */
  89466. VertexData.DEFAULTSIDE = 0;
  89467. return VertexData;
  89468. }());
  89469. /***/ }),
  89470. /***/ "./Meshes/meshBuilder.ts":
  89471. /*!*******************************!*\
  89472. !*** ./Meshes/meshBuilder.ts ***!
  89473. \*******************************/
  89474. /*! exports provided: MeshBuilder */
  89475. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  89476. "use strict";
  89477. __webpack_require__.r(__webpack_exports__);
  89478. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return MeshBuilder; });
  89479. /* harmony import */ var _Builders_ribbonBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Builders/ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  89480. /* harmony import */ var _Builders_discBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Builders/discBuilder */ "./Meshes/Builders/discBuilder.ts");
  89481. /* harmony import */ var _Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  89482. /* harmony import */ var _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  89483. /* harmony import */ var _Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  89484. /* harmony import */ var _Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Builders/torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  89485. /* harmony import */ var _Builders_torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Builders/torusKnotBuilder */ "./Meshes/Builders/torusKnotBuilder.ts");
  89486. /* harmony import */ var _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  89487. /* harmony import */ var _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Builders/polygonBuilder */ "./Meshes/Builders/polygonBuilder.ts");
  89488. /* harmony import */ var _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Builders/shapeBuilder */ "./Meshes/Builders/shapeBuilder.ts");
  89489. /* harmony import */ var _Builders_latheBuilder__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Builders/latheBuilder */ "./Meshes/Builders/latheBuilder.ts");
  89490. /* harmony import */ var _Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  89491. /* harmony import */ var _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Builders/groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  89492. /* harmony import */ var _Builders_tubeBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Builders/tubeBuilder */ "./Meshes/Builders/tubeBuilder.ts");
  89493. /* harmony import */ var _Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Builders/polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  89494. /* harmony import */ var _Builders_icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Builders/icoSphereBuilder */ "./Meshes/Builders/icoSphereBuilder.ts");
  89495. /* harmony import */ var _Builders_decalBuilder__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Builders/decalBuilder */ "./Meshes/Builders/decalBuilder.ts");
  89496. /**
  89497. * Class containing static functions to help procedurally build meshes
  89498. */
  89499. var MeshBuilder = /** @class */ (function () {
  89500. function MeshBuilder() {
  89501. }
  89502. /**
  89503. * Creates a box mesh
  89504. * * The parameter `size` sets the size (float) of each box side (default 1)
  89505. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  89506. * * 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)
  89507. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  89508. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  89509. * * 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
  89510. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89511. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  89512. * @param name defines the name of the mesh
  89513. * @param options defines the options used to create the mesh
  89514. * @param scene defines the hosting scene
  89515. * @returns the box mesh
  89516. */
  89517. MeshBuilder.CreateBox = function (name, options, scene) {
  89518. if (scene === void 0) { scene = null; }
  89519. return _Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(name, options, scene);
  89520. };
  89521. /**
  89522. * Creates a sphere mesh
  89523. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  89524. * * 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`)
  89525. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  89526. * * 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
  89527. * * 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)
  89528. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  89529. * * 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
  89530. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89531. * @param name defines the name of the mesh
  89532. * @param options defines the options used to create the mesh
  89533. * @param scene defines the hosting scene
  89534. * @returns the sphere mesh
  89535. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  89536. */
  89537. MeshBuilder.CreateSphere = function (name, options, scene) {
  89538. return _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__["SphereBuilder"].CreateSphere(name, options, scene);
  89539. };
  89540. /**
  89541. * Creates a plane polygonal mesh. By default, this is a disc
  89542. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  89543. * * 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
  89544. * * 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
  89545. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  89546. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  89547. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89548. * @param name defines the name of the mesh
  89549. * @param options defines the options used to create the mesh
  89550. * @param scene defines the hosting scene
  89551. * @returns the plane polygonal mesh
  89552. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  89553. */
  89554. MeshBuilder.CreateDisc = function (name, options, scene) {
  89555. if (scene === void 0) { scene = null; }
  89556. return _Builders_discBuilder__WEBPACK_IMPORTED_MODULE_1__["DiscBuilder"].CreateDisc(name, options, scene);
  89557. };
  89558. /**
  89559. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  89560. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  89561. * * 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`)
  89562. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  89563. * * 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
  89564. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  89565. * * 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
  89566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89567. * @param name defines the name of the mesh
  89568. * @param options defines the options used to create the mesh
  89569. * @param scene defines the hosting scene
  89570. * @returns the icosahedron mesh
  89571. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  89572. */
  89573. MeshBuilder.CreateIcoSphere = function (name, options, scene) {
  89574. return _Builders_icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__["IcoSphereBuilder"].CreateIcoSphere(name, options, scene);
  89575. };
  89576. /**
  89577. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  89578. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  89579. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  89580. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  89581. * * 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
  89582. * * 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
  89583. * * 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
  89584. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  89585. * * 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
  89586. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  89587. * * 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
  89588. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  89589. * * 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
  89590. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  89591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89592. * @param name defines the name of the mesh
  89593. * @param options defines the options used to create the mesh
  89594. * @param scene defines the hosting scene
  89595. * @returns the ribbon mesh
  89596. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  89597. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  89598. */
  89599. MeshBuilder.CreateRibbon = function (name, options, scene) {
  89600. if (scene === void 0) { scene = null; }
  89601. return _Builders_ribbonBuilder__WEBPACK_IMPORTED_MODULE_0__["RibbonBuilder"].CreateRibbon(name, options, scene);
  89602. };
  89603. /**
  89604. * Creates a cylinder or a cone mesh
  89605. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  89606. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  89607. * * 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.
  89608. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  89609. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  89610. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  89611. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  89612. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  89613. * * 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).
  89614. * * 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
  89615. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  89616. * * 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
  89617. * * 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.
  89618. * * If `enclose` is false, a ring surface is one element.
  89619. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  89620. * * 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
  89621. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  89622. * * 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
  89623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  89624. * @param name defines the name of the mesh
  89625. * @param options defines the options used to create the mesh
  89626. * @param scene defines the hosting scene
  89627. * @returns the cylinder mesh
  89628. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  89629. */
  89630. MeshBuilder.CreateCylinder = function (name, options, scene) {
  89631. return _Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder(name, options, scene);
  89632. };
  89633. /**
  89634. * Creates a torus mesh
  89635. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  89636. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  89637. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  89638. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  89639. * * 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
  89640. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  89641. * @param name defines the name of the mesh
  89642. * @param options defines the options used to create the mesh
  89643. * @param scene defines the hosting scene
  89644. * @returns the torus mesh
  89645. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  89646. */
  89647. MeshBuilder.CreateTorus = function (name, options, scene) {
  89648. return _Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_5__["TorusBuilder"].CreateTorus(name, options, scene);
  89649. };
  89650. /**
  89651. * Creates a torus knot mesh
  89652. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  89653. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  89654. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  89655. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  89656. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  89657. * * 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
  89658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  89659. * @param name defines the name of the mesh
  89660. * @param options defines the options used to create the mesh
  89661. * @param scene defines the hosting scene
  89662. * @returns the torus knot mesh
  89663. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  89664. */
  89665. MeshBuilder.CreateTorusKnot = function (name, options, scene) {
  89666. return _Builders_torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__["TorusKnotBuilder"].CreateTorusKnot(name, options, scene);
  89667. };
  89668. /**
  89669. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  89670. * * 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
  89671. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  89672. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  89673. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  89674. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  89675. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  89676. * * 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
  89677. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  89678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89679. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  89680. * @param name defines the name of the new line system
  89681. * @param options defines the options used to create the line system
  89682. * @param scene defines the hosting scene
  89683. * @returns a new line system mesh
  89684. */
  89685. MeshBuilder.CreateLineSystem = function (name, options, scene) {
  89686. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateLineSystem(name, options, scene);
  89687. };
  89688. /**
  89689. * Creates a line mesh
  89690. * 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
  89691. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  89692. * * The parameter `points` is an array successive Vector3
  89693. * * 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
  89694. * * The optional parameter `colors` is an array of successive Color4, one per line point
  89695. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  89696. * * When updating an instance, remember that only point positions can change, not the number of points
  89697. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89698. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  89699. * @param name defines the name of the new line system
  89700. * @param options defines the options used to create the line system
  89701. * @param scene defines the hosting scene
  89702. * @returns a new line mesh
  89703. */
  89704. MeshBuilder.CreateLines = function (name, options, scene) {
  89705. if (scene === void 0) { scene = null; }
  89706. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateLines(name, options, scene);
  89707. };
  89708. /**
  89709. * Creates a dashed line mesh
  89710. * * 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
  89711. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  89712. * * The parameter `points` is an array successive Vector3
  89713. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  89714. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  89715. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  89716. * * 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
  89717. * * When updating an instance, remember that only point positions can change, not the number of points
  89718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89719. * @param name defines the name of the mesh
  89720. * @param options defines the options used to create the mesh
  89721. * @param scene defines the hosting scene
  89722. * @returns the dashed line mesh
  89723. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  89724. */
  89725. MeshBuilder.CreateDashedLines = function (name, options, scene) {
  89726. if (scene === void 0) { scene = null; }
  89727. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateDashedLines(name, options, scene);
  89728. };
  89729. /**
  89730. * 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.
  89731. * * 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.
  89732. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  89733. * * 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.
  89734. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  89735. * * 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
  89736. * * 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
  89737. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  89738. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  89739. * * 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
  89740. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  89741. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  89742. * @param name defines the name of the mesh
  89743. * @param options defines the options used to create the mesh
  89744. * @param scene defines the hosting scene
  89745. * @returns the extruded shape mesh
  89746. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  89747. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  89748. */
  89749. MeshBuilder.ExtrudeShape = function (name, options, scene) {
  89750. if (scene === void 0) { scene = null; }
  89751. return _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__["ShapeBuilder"].ExtrudeShape(name, options, scene);
  89752. };
  89753. /**
  89754. * Creates an custom extruded shape mesh.
  89755. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  89756. * * 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.
  89757. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  89758. * * 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
  89759. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  89760. * * 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
  89761. * * It must returns a float value that will be the scale value applied to the shape on each path point
  89762. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  89763. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  89764. * * 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
  89765. * * 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
  89766. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  89767. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  89768. * * 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
  89769. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  89770. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89771. * @param name defines the name of the mesh
  89772. * @param options defines the options used to create the mesh
  89773. * @param scene defines the hosting scene
  89774. * @returns the custom extruded shape mesh
  89775. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  89776. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  89777. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  89778. */
  89779. MeshBuilder.ExtrudeShapeCustom = function (name, options, scene) {
  89780. return _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__["ShapeBuilder"].ExtrudeShapeCustom(name, options, scene);
  89781. };
  89782. /**
  89783. * Creates lathe mesh.
  89784. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  89785. * * 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
  89786. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  89787. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  89788. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  89789. * * 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
  89790. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  89791. * * 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
  89792. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  89793. * * 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
  89794. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  89795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89796. * @param name defines the name of the mesh
  89797. * @param options defines the options used to create the mesh
  89798. * @param scene defines the hosting scene
  89799. * @returns the lathe mesh
  89800. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  89801. */
  89802. MeshBuilder.CreateLathe = function (name, options, scene) {
  89803. return _Builders_latheBuilder__WEBPACK_IMPORTED_MODULE_10__["LatheBuilder"].CreateLathe(name, options, scene);
  89804. };
  89805. /**
  89806. * Creates a plane mesh
  89807. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  89808. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  89809. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  89810. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  89811. * * 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
  89812. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89813. * @param name defines the name of the mesh
  89814. * @param options defines the options used to create the mesh
  89815. * @param scene defines the hosting scene
  89816. * @returns the plane mesh
  89817. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  89818. */
  89819. MeshBuilder.CreatePlane = function (name, options, scene) {
  89820. return _Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__["PlaneBuilder"].CreatePlane(name, options, scene);
  89821. };
  89822. /**
  89823. * Creates a ground mesh
  89824. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  89825. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  89826. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89827. * @param name defines the name of the mesh
  89828. * @param options defines the options used to create the mesh
  89829. * @param scene defines the hosting scene
  89830. * @returns the ground mesh
  89831. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  89832. */
  89833. MeshBuilder.CreateGround = function (name, options, scene) {
  89834. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateGround(name, options, scene);
  89835. };
  89836. /**
  89837. * Creates a tiled ground mesh
  89838. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  89839. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  89840. * * 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
  89841. * * 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
  89842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  89843. * @param name defines the name of the mesh
  89844. * @param options defines the options used to create the mesh
  89845. * @param scene defines the hosting scene
  89846. * @returns the tiled ground mesh
  89847. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  89848. */
  89849. MeshBuilder.CreateTiledGround = function (name, options, scene) {
  89850. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateTiledGround(name, options, scene);
  89851. };
  89852. /**
  89853. * Creates a ground mesh from a height map
  89854. * * The parameter `url` sets the URL of the height map image resource.
  89855. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  89856. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  89857. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  89858. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  89859. * * 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.
  89860. * * 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).
  89861. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  89862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  89863. * @param name defines the name of the mesh
  89864. * @param url defines the url to the height map
  89865. * @param options defines the options used to create the mesh
  89866. * @param scene defines the hosting scene
  89867. * @returns the ground mesh
  89868. * @see https://doc.babylonjs.com/babylon101/height_map
  89869. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  89870. */
  89871. MeshBuilder.CreateGroundFromHeightMap = function (name, url, options, scene) {
  89872. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateGroundFromHeightMap(name, url, options, scene);
  89873. };
  89874. /**
  89875. * Creates a polygon mesh
  89876. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  89877. * * 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
  89878. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89880. * * 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)
  89881. * * Remember you can only change the shape positions, not their number when updating a polygon
  89882. * @param name defines the name of the mesh
  89883. * @param options defines the options used to create the mesh
  89884. * @param scene defines the hosting scene
  89885. * @param earcutInjection can be used to inject your own earcut reference
  89886. * @returns the polygon mesh
  89887. */
  89888. MeshBuilder.CreatePolygon = function (name, options, scene, earcutInjection) {
  89889. if (earcutInjection === void 0) { earcutInjection = earcut; }
  89890. return _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__["PolygonBuilder"].CreatePolygon(name, options, scene, earcutInjection);
  89891. };
  89892. /**
  89893. * Creates an extruded polygon mesh, with depth in the Y direction.
  89894. * * 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)
  89895. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  89896. * @param name defines the name of the mesh
  89897. * @param options defines the options used to create the mesh
  89898. * @param scene defines the hosting scene
  89899. * @param earcutInjection can be used to inject your own earcut reference
  89900. * @returns the polygon mesh
  89901. */
  89902. MeshBuilder.ExtrudePolygon = function (name, options, scene, earcutInjection) {
  89903. if (earcutInjection === void 0) { earcutInjection = earcut; }
  89904. return _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__["PolygonBuilder"].ExtrudePolygon(name, options, scene, earcutInjection);
  89905. };
  89906. /**
  89907. * Creates a tube mesh.
  89908. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  89909. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  89910. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  89911. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  89912. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  89913. * * 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)
  89914. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  89915. * * 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
  89916. * * 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
  89917. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  89918. * * 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
  89919. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  89920. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89921. * @param name defines the name of the mesh
  89922. * @param options defines the options used to create the mesh
  89923. * @param scene defines the hosting scene
  89924. * @returns the tube mesh
  89925. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  89926. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  89927. */
  89928. MeshBuilder.CreateTube = function (name, options, scene) {
  89929. return _Builders_tubeBuilder__WEBPACK_IMPORTED_MODULE_13__["TubeBuilder"].CreateTube(name, options, scene);
  89930. };
  89931. /**
  89932. * Creates a polyhedron mesh
  89933. * * 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
  89934. * * The parameter `size` (positive float, default 1) sets the polygon size
  89935. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  89936. * * 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`
  89937. * * 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
  89938. * * 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)`)
  89939. * * 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
  89940. * * 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
  89941. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  89942. * * 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
  89943. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89944. * @param name defines the name of the mesh
  89945. * @param options defines the options used to create the mesh
  89946. * @param scene defines the hosting scene
  89947. * @returns the polyhedron mesh
  89948. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  89949. */
  89950. MeshBuilder.CreatePolyhedron = function (name, options, scene) {
  89951. return _Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__["PolyhedronBuilder"].CreatePolyhedron(name, options, scene);
  89952. };
  89953. /**
  89954. * Creates a decal mesh.
  89955. * 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
  89956. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  89957. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  89958. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  89959. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  89960. * @param name defines the name of the mesh
  89961. * @param sourceMesh defines the mesh where the decal must be applied
  89962. * @param options defines the options used to create the mesh
  89963. * @param scene defines the hosting scene
  89964. * @returns the decal mesh
  89965. * @see https://doc.babylonjs.com/how_to/decals
  89966. */
  89967. MeshBuilder.CreateDecal = function (name, sourceMesh, options) {
  89968. return _Builders_decalBuilder__WEBPACK_IMPORTED_MODULE_16__["DecalBuilder"].CreateDecal(name, sourceMesh, options);
  89969. };
  89970. return MeshBuilder;
  89971. }());
  89972. /***/ }),
  89973. /***/ "./Meshes/meshSimplification.ts":
  89974. /*!**************************************!*\
  89975. !*** ./Meshes/meshSimplification.ts ***!
  89976. \**************************************/
  89977. /*! exports provided: SimplificationSettings, SimplificationQueue, SimplificationType */
  89978. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  89979. "use strict";
  89980. __webpack_require__.r(__webpack_exports__);
  89981. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return SimplificationSettings; });
  89982. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return SimplificationQueue; });
  89983. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return SimplificationType; });
  89984. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  89985. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  89986. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  89987. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  89988. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  89989. /**
  89990. * Class used to specify simplification options
  89991. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  89992. */
  89993. var SimplificationSettings = /** @class */ (function () {
  89994. /**
  89995. * Creates a SimplificationSettings
  89996. * @param quality expected quality
  89997. * @param distance distance when this optimized version should be used
  89998. * @param optimizeMesh already optimized mesh
  89999. */
  90000. function SimplificationSettings(
  90001. /** expected quality */
  90002. quality,
  90003. /** distance when this optimized version should be used */
  90004. distance,
  90005. /** already optimized mesh */
  90006. optimizeMesh) {
  90007. this.quality = quality;
  90008. this.distance = distance;
  90009. this.optimizeMesh = optimizeMesh;
  90010. }
  90011. return SimplificationSettings;
  90012. }());
  90013. /**
  90014. * Queue used to order the simplification tasks
  90015. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  90016. */
  90017. var SimplificationQueue = /** @class */ (function () {
  90018. /**
  90019. * Creates a new queue
  90020. */
  90021. function SimplificationQueue() {
  90022. this.running = false;
  90023. this._simplificationArray = [];
  90024. }
  90025. /**
  90026. * Adds a new simplification task
  90027. * @param task defines a task to add
  90028. */
  90029. SimplificationQueue.prototype.addTask = function (task) {
  90030. this._simplificationArray.push(task);
  90031. };
  90032. /**
  90033. * Execute next task
  90034. */
  90035. SimplificationQueue.prototype.executeNext = function () {
  90036. var task = this._simplificationArray.pop();
  90037. if (task) {
  90038. this.running = true;
  90039. this.runSimplification(task);
  90040. }
  90041. else {
  90042. this.running = false;
  90043. }
  90044. };
  90045. /**
  90046. * Execute a simplification task
  90047. * @param task defines the task to run
  90048. */
  90049. SimplificationQueue.prototype.runSimplification = function (task) {
  90050. var _this = this;
  90051. if (task.parallelProcessing) {
  90052. //parallel simplifier
  90053. task.settings.forEach(function (setting) {
  90054. var simplifier = _this.getSimplifier(task);
  90055. simplifier.simplify(setting, function (newMesh) {
  90056. task.mesh.addLODLevel(setting.distance, newMesh);
  90057. newMesh.isVisible = true;
  90058. //check if it is the last
  90059. if (setting.quality === task.settings[task.settings.length - 1].quality && task.successCallback) {
  90060. //all done, run the success callback.
  90061. task.successCallback();
  90062. }
  90063. _this.executeNext();
  90064. });
  90065. });
  90066. }
  90067. else {
  90068. //single simplifier.
  90069. var simplifier = this.getSimplifier(task);
  90070. var runDecimation = function (setting, callback) {
  90071. simplifier.simplify(setting, function (newMesh) {
  90072. task.mesh.addLODLevel(setting.distance, newMesh);
  90073. newMesh.isVisible = true;
  90074. //run the next quality level
  90075. callback();
  90076. });
  90077. };
  90078. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(task.settings.length, function (loop) {
  90079. runDecimation(task.settings[loop.index], function () {
  90080. loop.executeNext();
  90081. });
  90082. }, function () {
  90083. //execution ended, run the success callback.
  90084. if (task.successCallback) {
  90085. task.successCallback();
  90086. }
  90087. _this.executeNext();
  90088. });
  90089. }
  90090. };
  90091. SimplificationQueue.prototype.getSimplifier = function (task) {
  90092. switch (task.simplificationType) {
  90093. case SimplificationType.QUADRATIC:
  90094. default:
  90095. return new QuadraticErrorSimplification(task.mesh);
  90096. }
  90097. };
  90098. return SimplificationQueue;
  90099. }());
  90100. /**
  90101. * The implemented types of simplification
  90102. * At the moment only Quadratic Error Decimation is implemented
  90103. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  90104. */
  90105. var SimplificationType;
  90106. (function (SimplificationType) {
  90107. /** Quadratic error decimation */
  90108. SimplificationType[SimplificationType["QUADRATIC"] = 0] = "QUADRATIC";
  90109. })(SimplificationType || (SimplificationType = {}));
  90110. var DecimationTriangle = /** @class */ (function () {
  90111. function DecimationTriangle(vertices) {
  90112. this.vertices = vertices;
  90113. this.error = new Array(4);
  90114. this.deleted = false;
  90115. this.isDirty = false;
  90116. this.deletePending = false;
  90117. this.borderFactor = 0;
  90118. }
  90119. return DecimationTriangle;
  90120. }());
  90121. var DecimationVertex = /** @class */ (function () {
  90122. function DecimationVertex(position, id) {
  90123. this.position = position;
  90124. this.id = id;
  90125. this.isBorder = true;
  90126. this.q = new QuadraticMatrix();
  90127. this.triangleCount = 0;
  90128. this.triangleStart = 0;
  90129. this.originalOffsets = [];
  90130. }
  90131. DecimationVertex.prototype.updatePosition = function (newPosition) {
  90132. this.position.copyFrom(newPosition);
  90133. };
  90134. return DecimationVertex;
  90135. }());
  90136. var QuadraticMatrix = /** @class */ (function () {
  90137. function QuadraticMatrix(data) {
  90138. this.data = new Array(10);
  90139. for (var i = 0; i < 10; ++i) {
  90140. if (data && data[i]) {
  90141. this.data[i] = data[i];
  90142. }
  90143. else {
  90144. this.data[i] = 0;
  90145. }
  90146. }
  90147. }
  90148. QuadraticMatrix.prototype.det = function (a11, a12, a13, a21, a22, a23, a31, a32, a33) {
  90149. var det = this.data[a11] * this.data[a22] * this.data[a33] + this.data[a13] * this.data[a21] * this.data[a32] +
  90150. this.data[a12] * this.data[a23] * this.data[a31] - this.data[a13] * this.data[a22] * this.data[a31] -
  90151. this.data[a11] * this.data[a23] * this.data[a32] - this.data[a12] * this.data[a21] * this.data[a33];
  90152. return det;
  90153. };
  90154. QuadraticMatrix.prototype.addInPlace = function (matrix) {
  90155. for (var i = 0; i < 10; ++i) {
  90156. this.data[i] += matrix.data[i];
  90157. }
  90158. };
  90159. QuadraticMatrix.prototype.addArrayInPlace = function (data) {
  90160. for (var i = 0; i < 10; ++i) {
  90161. this.data[i] += data[i];
  90162. }
  90163. };
  90164. QuadraticMatrix.prototype.add = function (matrix) {
  90165. var m = new QuadraticMatrix();
  90166. for (var i = 0; i < 10; ++i) {
  90167. m.data[i] = this.data[i] + matrix.data[i];
  90168. }
  90169. return m;
  90170. };
  90171. QuadraticMatrix.FromData = function (a, b, c, d) {
  90172. return new QuadraticMatrix(QuadraticMatrix.DataFromNumbers(a, b, c, d));
  90173. };
  90174. //returning an array to avoid garbage collection
  90175. QuadraticMatrix.DataFromNumbers = function (a, b, c, d) {
  90176. return [a * a, a * b, a * c, a * d, b * b, b * c, b * d, c * c, c * d, d * d];
  90177. };
  90178. return QuadraticMatrix;
  90179. }());
  90180. var Reference = /** @class */ (function () {
  90181. function Reference(vertexId, triangleId) {
  90182. this.vertexId = vertexId;
  90183. this.triangleId = triangleId;
  90184. }
  90185. return Reference;
  90186. }());
  90187. /**
  90188. * An implementation of the Quadratic Error simplification algorithm.
  90189. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  90190. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  90191. * @author RaananW
  90192. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  90193. */
  90194. var QuadraticErrorSimplification = /** @class */ (function () {
  90195. function QuadraticErrorSimplification(_mesh) {
  90196. this._mesh = _mesh;
  90197. this.syncIterations = 5000;
  90198. this.aggressiveness = 7;
  90199. this.decimationIterations = 100;
  90200. this.boundingBoxEpsilon = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Epsilon"];
  90201. }
  90202. QuadraticErrorSimplification.prototype.simplify = function (settings, successCallback) {
  90203. var _this = this;
  90204. this.initDecimatedMesh();
  90205. //iterating through the submeshes array, one after the other.
  90206. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(this._mesh.subMeshes.length, function (loop) {
  90207. _this.initWithMesh(loop.index, function () {
  90208. _this.runDecimation(settings, loop.index, function () {
  90209. loop.executeNext();
  90210. });
  90211. }, settings.optimizeMesh);
  90212. }, function () {
  90213. setTimeout(function () {
  90214. successCallback(_this._reconstructedMesh);
  90215. }, 0);
  90216. });
  90217. };
  90218. QuadraticErrorSimplification.prototype.runDecimation = function (settings, submeshIndex, successCallback) {
  90219. var _this = this;
  90220. var targetCount = ~~(this.triangles.length * settings.quality);
  90221. var deletedTriangles = 0;
  90222. var triangleCount = this.triangles.length;
  90223. var iterationFunction = function (iteration, callback) {
  90224. setTimeout(function () {
  90225. if (iteration % 5 === 0) {
  90226. _this.updateMesh(iteration === 0);
  90227. }
  90228. for (var i = 0; i < _this.triangles.length; ++i) {
  90229. _this.triangles[i].isDirty = false;
  90230. }
  90231. var threshold = 0.000000001 * Math.pow((iteration + 3), _this.aggressiveness);
  90232. var trianglesIterator = function (i) {
  90233. var tIdx = ~~(((_this.triangles.length / 2) + i) % _this.triangles.length);
  90234. var t = _this.triangles[tIdx];
  90235. if (!t) {
  90236. return;
  90237. }
  90238. if (t.error[3] > threshold || t.deleted || t.isDirty) {
  90239. return;
  90240. }
  90241. for (var j = 0; j < 3; ++j) {
  90242. if (t.error[j] < threshold) {
  90243. var deleted0 = [];
  90244. var deleted1 = [];
  90245. var v0 = t.vertices[j];
  90246. var v1 = t.vertices[(j + 1) % 3];
  90247. if (v0.isBorder || v1.isBorder) {
  90248. continue;
  90249. }
  90250. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  90251. // var n = Vector3.Zero();
  90252. // var uv = Vector2.Zero();
  90253. // var color = new Color4(0, 0, 0, 1);
  90254. _this.calculateError(v0, v1, p);
  90255. var delTr = new Array();
  90256. if (_this.isFlipped(v0, v1, p, deleted0, delTr)) {
  90257. continue;
  90258. }
  90259. if (_this.isFlipped(v1, v0, p, deleted1, delTr)) {
  90260. continue;
  90261. }
  90262. if (deleted0.indexOf(true) < 0 || deleted1.indexOf(true) < 0) {
  90263. continue;
  90264. }
  90265. var uniqueArray = new Array();
  90266. delTr.forEach(function (deletedT) {
  90267. if (uniqueArray.indexOf(deletedT) === -1) {
  90268. deletedT.deletePending = true;
  90269. uniqueArray.push(deletedT);
  90270. }
  90271. });
  90272. if (uniqueArray.length % 2 !== 0) {
  90273. continue;
  90274. }
  90275. v0.q = v1.q.add(v0.q);
  90276. v0.updatePosition(p);
  90277. var tStart = _this.references.length;
  90278. deletedTriangles = _this.updateTriangles(v0, v0, deleted0, deletedTriangles);
  90279. deletedTriangles = _this.updateTriangles(v0, v1, deleted1, deletedTriangles);
  90280. var tCount = _this.references.length - tStart;
  90281. if (tCount <= v0.triangleCount) {
  90282. if (tCount) {
  90283. for (var c = 0; c < tCount; c++) {
  90284. _this.references[v0.triangleStart + c] = _this.references[tStart + c];
  90285. }
  90286. }
  90287. }
  90288. else {
  90289. v0.triangleStart = tStart;
  90290. }
  90291. v0.triangleCount = tCount;
  90292. break;
  90293. }
  90294. }
  90295. };
  90296. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(_this.triangles.length, _this.syncIterations, trianglesIterator, callback, function () { return (triangleCount - deletedTriangles <= targetCount); });
  90297. }, 0);
  90298. };
  90299. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(this.decimationIterations, function (loop) {
  90300. if (triangleCount - deletedTriangles <= targetCount) {
  90301. loop.breakLoop();
  90302. }
  90303. else {
  90304. iterationFunction(loop.index, function () {
  90305. loop.executeNext();
  90306. });
  90307. }
  90308. }, function () {
  90309. setTimeout(function () {
  90310. //reconstruct this part of the mesh
  90311. _this.reconstructMesh(submeshIndex);
  90312. successCallback();
  90313. }, 0);
  90314. });
  90315. };
  90316. QuadraticErrorSimplification.prototype.initWithMesh = function (submeshIndex, callback, optimizeMesh) {
  90317. var _this = this;
  90318. this.vertices = [];
  90319. this.triangles = [];
  90320. var positionData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  90321. var indices = this._mesh.getIndices();
  90322. var submesh = this._mesh.subMeshes[submeshIndex];
  90323. var findInVertices = function (positionToSearch) {
  90324. if (optimizeMesh) {
  90325. for (var ii = 0; ii < _this.vertices.length; ++ii) {
  90326. if (_this.vertices[ii].position.equals(positionToSearch)) {
  90327. return _this.vertices[ii];
  90328. }
  90329. }
  90330. }
  90331. return null;
  90332. };
  90333. var vertexReferences = [];
  90334. var vertexInit = function (i) {
  90335. if (!positionData) {
  90336. return;
  90337. }
  90338. var offset = i + submesh.verticesStart;
  90339. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positionData, offset * 3);
  90340. var vertex = findInVertices(position) || new DecimationVertex(position, _this.vertices.length);
  90341. vertex.originalOffsets.push(offset);
  90342. if (vertex.id === _this.vertices.length) {
  90343. _this.vertices.push(vertex);
  90344. }
  90345. vertexReferences.push(vertex.id);
  90346. };
  90347. //var totalVertices = mesh.getTotalVertices();
  90348. var totalVertices = submesh.verticesCount;
  90349. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(totalVertices, (this.syncIterations / 4) >> 0, vertexInit, function () {
  90350. var indicesInit = function (i) {
  90351. if (!indices) {
  90352. return;
  90353. }
  90354. var offset = (submesh.indexStart / 3) + i;
  90355. var pos = (offset * 3);
  90356. var i0 = indices[pos + 0];
  90357. var i1 = indices[pos + 1];
  90358. var i2 = indices[pos + 2];
  90359. var v0 = _this.vertices[vertexReferences[i0 - submesh.verticesStart]];
  90360. var v1 = _this.vertices[vertexReferences[i1 - submesh.verticesStart]];
  90361. var v2 = _this.vertices[vertexReferences[i2 - submesh.verticesStart]];
  90362. var triangle = new DecimationTriangle([v0, v1, v2]);
  90363. triangle.originalOffset = pos;
  90364. _this.triangles.push(triangle);
  90365. };
  90366. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(submesh.indexCount / 3, _this.syncIterations, indicesInit, function () {
  90367. _this.init(callback);
  90368. });
  90369. });
  90370. };
  90371. QuadraticErrorSimplification.prototype.init = function (callback) {
  90372. var _this = this;
  90373. var triangleInit1 = function (i) {
  90374. var t = _this.triangles[i];
  90375. 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();
  90376. for (var j = 0; j < 3; j++) {
  90377. 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))));
  90378. }
  90379. };
  90380. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(this.triangles.length, this.syncIterations, triangleInit1, function () {
  90381. var triangleInit2 = function (i) {
  90382. var t = _this.triangles[i];
  90383. for (var j = 0; j < 3; ++j) {
  90384. t.error[j] = _this.calculateError(t.vertices[j], t.vertices[(j + 1) % 3]);
  90385. }
  90386. t.error[3] = Math.min(t.error[0], t.error[1], t.error[2]);
  90387. };
  90388. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(_this.triangles.length, _this.syncIterations, triangleInit2, function () {
  90389. callback();
  90390. });
  90391. });
  90392. };
  90393. QuadraticErrorSimplification.prototype.reconstructMesh = function (submeshIndex) {
  90394. var newTriangles = [];
  90395. var i;
  90396. for (i = 0; i < this.vertices.length; ++i) {
  90397. this.vertices[i].triangleCount = 0;
  90398. }
  90399. var t;
  90400. var j;
  90401. for (i = 0; i < this.triangles.length; ++i) {
  90402. if (!this.triangles[i].deleted) {
  90403. t = this.triangles[i];
  90404. for (j = 0; j < 3; ++j) {
  90405. t.vertices[j].triangleCount = 1;
  90406. }
  90407. newTriangles.push(t);
  90408. }
  90409. }
  90410. var newPositionData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind) || []);
  90411. var newNormalData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind) || []);
  90412. var newUVsData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind) || []);
  90413. var newColorsData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind) || []);
  90414. var normalData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  90415. var uvs = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  90416. var colorsData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  90417. var vertexCount = 0;
  90418. for (i = 0; i < this.vertices.length; ++i) {
  90419. var vertex = this.vertices[i];
  90420. vertex.id = vertexCount;
  90421. if (vertex.triangleCount) {
  90422. vertex.originalOffsets.forEach(function (originalOffset) {
  90423. if (!normalData) {
  90424. return;
  90425. }
  90426. newPositionData.push(vertex.position.x);
  90427. newPositionData.push(vertex.position.y);
  90428. newPositionData.push(vertex.position.z);
  90429. newNormalData.push(normalData[originalOffset * 3]);
  90430. newNormalData.push(normalData[(originalOffset * 3) + 1]);
  90431. newNormalData.push(normalData[(originalOffset * 3) + 2]);
  90432. if (uvs && uvs.length) {
  90433. newUVsData.push(uvs[(originalOffset * 2)]);
  90434. newUVsData.push(uvs[(originalOffset * 2) + 1]);
  90435. }
  90436. else if (colorsData && colorsData.length) {
  90437. newColorsData.push(colorsData[(originalOffset * 4)]);
  90438. newColorsData.push(colorsData[(originalOffset * 4) + 1]);
  90439. newColorsData.push(colorsData[(originalOffset * 4) + 2]);
  90440. newColorsData.push(colorsData[(originalOffset * 4) + 3]);
  90441. }
  90442. ++vertexCount;
  90443. });
  90444. }
  90445. }
  90446. var startingIndex = this._reconstructedMesh.getTotalIndices();
  90447. var startingVertex = this._reconstructedMesh.getTotalVertices();
  90448. var submeshesArray = this._reconstructedMesh.subMeshes;
  90449. this._reconstructedMesh.subMeshes = [];
  90450. var newIndicesArray = this._reconstructedMesh.getIndices(); //[];
  90451. var originalIndices = this._mesh.getIndices();
  90452. for (i = 0; i < newTriangles.length; ++i) {
  90453. t = newTriangles[i]; //now get the new referencing point for each vertex
  90454. [0, 1, 2].forEach(function (idx) {
  90455. var id = originalIndices[t.originalOffset + idx];
  90456. var offset = t.vertices[idx].originalOffsets.indexOf(id);
  90457. if (offset < 0) {
  90458. offset = 0;
  90459. }
  90460. newIndicesArray.push(t.vertices[idx].id + offset + startingVertex);
  90461. });
  90462. }
  90463. //overwriting the old vertex buffers and indices.
  90464. this._reconstructedMesh.setIndices(newIndicesArray);
  90465. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, newPositionData);
  90466. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, newNormalData);
  90467. if (newUVsData.length > 0) {
  90468. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, newUVsData);
  90469. }
  90470. if (newColorsData.length > 0) {
  90471. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, newColorsData);
  90472. }
  90473. //create submesh
  90474. var originalSubmesh = this._mesh.subMeshes[submeshIndex];
  90475. if (submeshIndex > 0) {
  90476. this._reconstructedMesh.subMeshes = [];
  90477. submeshesArray.forEach(function (submesh) {
  90478. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].AddToMesh(submesh.materialIndex, submesh.verticesStart, submesh.verticesCount, /* 0, newPositionData.length/3, */ submesh.indexStart, submesh.indexCount, submesh.getMesh());
  90479. });
  90480. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].AddToMesh(originalSubmesh.materialIndex, startingVertex, vertexCount, /* 0, newPositionData.length / 3, */ startingIndex, newTriangles.length * 3, this._reconstructedMesh);
  90481. }
  90482. };
  90483. QuadraticErrorSimplification.prototype.initDecimatedMesh = function () {
  90484. this._reconstructedMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](this._mesh.name + "Decimated", this._mesh.getScene());
  90485. this._reconstructedMesh.material = this._mesh.material;
  90486. this._reconstructedMesh.parent = this._mesh.parent;
  90487. this._reconstructedMesh.isVisible = false;
  90488. this._reconstructedMesh.renderingGroupId = this._mesh.renderingGroupId;
  90489. };
  90490. QuadraticErrorSimplification.prototype.isFlipped = function (vertex1, vertex2, point, deletedArray, delTr) {
  90491. for (var i = 0; i < vertex1.triangleCount; ++i) {
  90492. var t = this.triangles[this.references[vertex1.triangleStart + i].triangleId];
  90493. if (t.deleted) {
  90494. continue;
  90495. }
  90496. var s = this.references[vertex1.triangleStart + i].vertexId;
  90497. var v1 = t.vertices[(s + 1) % 3];
  90498. var v2 = t.vertices[(s + 2) % 3];
  90499. if ((v1 === vertex2 || v2 === vertex2)) {
  90500. deletedArray[i] = true;
  90501. delTr.push(t);
  90502. continue;
  90503. }
  90504. var d1 = v1.position.subtract(point);
  90505. d1 = d1.normalize();
  90506. var d2 = v2.position.subtract(point);
  90507. d2 = d2.normalize();
  90508. if (Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(d1, d2)) > 0.999) {
  90509. return true;
  90510. }
  90511. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(d1, d2).normalize();
  90512. deletedArray[i] = false;
  90513. if (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(normal, t.normal) < 0.2) {
  90514. return true;
  90515. }
  90516. }
  90517. return false;
  90518. };
  90519. QuadraticErrorSimplification.prototype.updateTriangles = function (origVertex, vertex, deletedArray, deletedTriangles) {
  90520. var newDeleted = deletedTriangles;
  90521. for (var i = 0; i < vertex.triangleCount; ++i) {
  90522. var ref = this.references[vertex.triangleStart + i];
  90523. var t = this.triangles[ref.triangleId];
  90524. if (t.deleted) {
  90525. continue;
  90526. }
  90527. if (deletedArray[i] && t.deletePending) {
  90528. t.deleted = true;
  90529. newDeleted++;
  90530. continue;
  90531. }
  90532. t.vertices[ref.vertexId] = origVertex;
  90533. t.isDirty = true;
  90534. t.error[0] = this.calculateError(t.vertices[0], t.vertices[1]) + (t.borderFactor / 2);
  90535. t.error[1] = this.calculateError(t.vertices[1], t.vertices[2]) + (t.borderFactor / 2);
  90536. t.error[2] = this.calculateError(t.vertices[2], t.vertices[0]) + (t.borderFactor / 2);
  90537. t.error[3] = Math.min(t.error[0], t.error[1], t.error[2]);
  90538. this.references.push(ref);
  90539. }
  90540. return newDeleted;
  90541. };
  90542. QuadraticErrorSimplification.prototype.identifyBorder = function () {
  90543. for (var i = 0; i < this.vertices.length; ++i) {
  90544. var vCount = [];
  90545. var vId = [];
  90546. var v = this.vertices[i];
  90547. var j;
  90548. for (j = 0; j < v.triangleCount; ++j) {
  90549. var triangle = this.triangles[this.references[v.triangleStart + j].triangleId];
  90550. for (var ii = 0; ii < 3; ii++) {
  90551. var ofs = 0;
  90552. var vv = triangle.vertices[ii];
  90553. while (ofs < vCount.length) {
  90554. if (vId[ofs] === vv.id) {
  90555. break;
  90556. }
  90557. ++ofs;
  90558. }
  90559. if (ofs === vCount.length) {
  90560. vCount.push(1);
  90561. vId.push(vv.id);
  90562. }
  90563. else {
  90564. vCount[ofs]++;
  90565. }
  90566. }
  90567. }
  90568. for (j = 0; j < vCount.length; ++j) {
  90569. if (vCount[j] === 1) {
  90570. this.vertices[vId[j]].isBorder = true;
  90571. }
  90572. else {
  90573. this.vertices[vId[j]].isBorder = false;
  90574. }
  90575. }
  90576. }
  90577. };
  90578. QuadraticErrorSimplification.prototype.updateMesh = function (identifyBorders) {
  90579. if (identifyBorders === void 0) { identifyBorders = false; }
  90580. var i;
  90581. if (!identifyBorders) {
  90582. var newTrianglesVector = [];
  90583. for (i = 0; i < this.triangles.length; ++i) {
  90584. if (!this.triangles[i].deleted) {
  90585. newTrianglesVector.push(this.triangles[i]);
  90586. }
  90587. }
  90588. this.triangles = newTrianglesVector;
  90589. }
  90590. for (i = 0; i < this.vertices.length; ++i) {
  90591. this.vertices[i].triangleCount = 0;
  90592. this.vertices[i].triangleStart = 0;
  90593. }
  90594. var t;
  90595. var j;
  90596. var v;
  90597. for (i = 0; i < this.triangles.length; ++i) {
  90598. t = this.triangles[i];
  90599. for (j = 0; j < 3; ++j) {
  90600. v = t.vertices[j];
  90601. v.triangleCount++;
  90602. }
  90603. }
  90604. var tStart = 0;
  90605. for (i = 0; i < this.vertices.length; ++i) {
  90606. this.vertices[i].triangleStart = tStart;
  90607. tStart += this.vertices[i].triangleCount;
  90608. this.vertices[i].triangleCount = 0;
  90609. }
  90610. var newReferences = new Array(this.triangles.length * 3);
  90611. for (i = 0; i < this.triangles.length; ++i) {
  90612. t = this.triangles[i];
  90613. for (j = 0; j < 3; ++j) {
  90614. v = t.vertices[j];
  90615. newReferences[v.triangleStart + v.triangleCount] = new Reference(j, i);
  90616. v.triangleCount++;
  90617. }
  90618. }
  90619. this.references = newReferences;
  90620. if (identifyBorders) {
  90621. this.identifyBorder();
  90622. }
  90623. };
  90624. QuadraticErrorSimplification.prototype.vertexError = function (q, point) {
  90625. var x = point.x;
  90626. var y = point.y;
  90627. var z = point.z;
  90628. 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
  90629. + 2 * q.data[5] * y * z + 2 * q.data[6] * y + q.data[7] * z * z + 2 * q.data[8] * z + q.data[9];
  90630. };
  90631. QuadraticErrorSimplification.prototype.calculateError = function (vertex1, vertex2, pointResult) {
  90632. var q = vertex1.q.add(vertex2.q);
  90633. var border = vertex1.isBorder && vertex2.isBorder;
  90634. var error = 0;
  90635. var qDet = q.det(0, 1, 2, 1, 4, 5, 2, 5, 7);
  90636. if (qDet !== 0 && !border) {
  90637. if (!pointResult) {
  90638. pointResult = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  90639. }
  90640. pointResult.x = -1 / qDet * (q.det(1, 2, 3, 4, 5, 6, 5, 7, 8));
  90641. pointResult.y = 1 / qDet * (q.det(0, 2, 3, 1, 5, 6, 2, 7, 8));
  90642. pointResult.z = -1 / qDet * (q.det(0, 1, 3, 1, 4, 6, 2, 5, 8));
  90643. error = this.vertexError(q, pointResult);
  90644. }
  90645. else {
  90646. var p3 = (vertex1.position.add(vertex2.position)).divide(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](2, 2, 2));
  90647. //var norm3 = (vertex1.normal.add(vertex2.normal)).divide(new Vector3(2, 2, 2)).normalize();
  90648. var error1 = this.vertexError(q, vertex1.position);
  90649. var error2 = this.vertexError(q, vertex2.position);
  90650. var error3 = this.vertexError(q, p3);
  90651. error = Math.min(error1, error2, error3);
  90652. if (error === error1) {
  90653. if (pointResult) {
  90654. pointResult.copyFrom(vertex1.position);
  90655. }
  90656. }
  90657. else if (error === error2) {
  90658. if (pointResult) {
  90659. pointResult.copyFrom(vertex2.position);
  90660. }
  90661. }
  90662. else {
  90663. if (pointResult) {
  90664. pointResult.copyFrom(p3);
  90665. }
  90666. }
  90667. }
  90668. return error;
  90669. };
  90670. return QuadraticErrorSimplification;
  90671. }());
  90672. /***/ }),
  90673. /***/ "./Meshes/meshSimplificationSceneComponent.ts":
  90674. /*!****************************************************!*\
  90675. !*** ./Meshes/meshSimplificationSceneComponent.ts ***!
  90676. \****************************************************/
  90677. /*! exports provided: SimplicationQueueSceneComponent */
  90678. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  90679. "use strict";
  90680. __webpack_require__.r(__webpack_exports__);
  90681. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return SimplicationQueueSceneComponent; });
  90682. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  90683. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mesh */ "./Meshes/mesh.ts");
  90684. /* harmony import */ var _meshSimplification__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./meshSimplification */ "./Meshes/meshSimplification.ts");
  90685. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  90686. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "simplificationQueue", {
  90687. get: function () {
  90688. if (!this._simplificationQueue) {
  90689. this._simplificationQueue = new _meshSimplification__WEBPACK_IMPORTED_MODULE_2__["SimplificationQueue"]();
  90690. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_SIMPLIFICATIONQUEUE);
  90691. if (!component) {
  90692. component = new SimplicationQueueSceneComponent(this);
  90693. this._addComponent(component);
  90694. }
  90695. }
  90696. return this._simplificationQueue;
  90697. },
  90698. set: function (value) {
  90699. this._simplificationQueue = value;
  90700. },
  90701. enumerable: true,
  90702. configurable: true
  90703. });
  90704. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].prototype.simplify = function (settings, parallelProcessing, simplificationType, successCallback) {
  90705. if (parallelProcessing === void 0) { parallelProcessing = true; }
  90706. if (simplificationType === void 0) { simplificationType = _meshSimplification__WEBPACK_IMPORTED_MODULE_2__["SimplificationType"].QUADRATIC; }
  90707. this.getScene().simplificationQueue.addTask({
  90708. settings: settings,
  90709. parallelProcessing: parallelProcessing,
  90710. mesh: this,
  90711. simplificationType: simplificationType,
  90712. successCallback: successCallback
  90713. });
  90714. return this;
  90715. };
  90716. /**
  90717. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  90718. * created in a scene
  90719. */
  90720. var SimplicationQueueSceneComponent = /** @class */ (function () {
  90721. /**
  90722. * Creates a new instance of the component for the given scene
  90723. * @param scene Defines the scene to register the component in
  90724. */
  90725. function SimplicationQueueSceneComponent(scene) {
  90726. /**
  90727. * The component name helpfull to identify the component in the list of scene components.
  90728. */
  90729. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_SIMPLIFICATIONQUEUE;
  90730. this.scene = scene;
  90731. }
  90732. /**
  90733. * Registers the component in a given scene
  90734. */
  90735. SimplicationQueueSceneComponent.prototype.register = function () {
  90736. this.scene._beforeCameraUpdateStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE, this, this._beforeCameraUpdate);
  90737. };
  90738. /**
  90739. * Rebuilds the elements related to this component in case of
  90740. * context lost for instance.
  90741. */
  90742. SimplicationQueueSceneComponent.prototype.rebuild = function () {
  90743. // Nothing to do for this component
  90744. };
  90745. /**
  90746. * Disposes the component and the associated ressources
  90747. */
  90748. SimplicationQueueSceneComponent.prototype.dispose = function () {
  90749. // Nothing to do for this component
  90750. };
  90751. SimplicationQueueSceneComponent.prototype._beforeCameraUpdate = function () {
  90752. if (this.scene._simplificationQueue && !this.scene._simplificationQueue.running) {
  90753. this.scene._simplificationQueue.executeNext();
  90754. }
  90755. };
  90756. return SimplicationQueueSceneComponent;
  90757. }());
  90758. /***/ }),
  90759. /***/ "./Meshes/polygonMesh.ts":
  90760. /*!*******************************!*\
  90761. !*** ./Meshes/polygonMesh.ts ***!
  90762. \*******************************/
  90763. /*! exports provided: Polygon, PolygonMeshBuilder */
  90764. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  90765. "use strict";
  90766. __webpack_require__.r(__webpack_exports__);
  90767. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return Polygon; });
  90768. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return PolygonMeshBuilder; });
  90769. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  90770. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  90771. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  90772. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  90773. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  90774. /**
  90775. * Vector2 wth index property
  90776. */
  90777. var IndexedVector2 = /** @class */ (function (_super) {
  90778. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](IndexedVector2, _super);
  90779. function IndexedVector2(original,
  90780. /** Index of the vector2 */
  90781. index) {
  90782. var _this = _super.call(this, original.x, original.y) || this;
  90783. _this.index = index;
  90784. return _this;
  90785. }
  90786. return IndexedVector2;
  90787. }(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"]));
  90788. /**
  90789. * Defines points to create a polygon
  90790. */
  90791. var PolygonPoints = /** @class */ (function () {
  90792. function PolygonPoints() {
  90793. this.elements = new Array();
  90794. }
  90795. PolygonPoints.prototype.add = function (originalPoints) {
  90796. var _this = this;
  90797. var result = new Array();
  90798. originalPoints.forEach(function (point) {
  90799. if (result.length === 0 || !point.equalsWithEpsilon(result[0])) {
  90800. var newPoint = new IndexedVector2(point, _this.elements.length);
  90801. result.push(newPoint);
  90802. _this.elements.push(newPoint);
  90803. }
  90804. });
  90805. return result;
  90806. };
  90807. PolygonPoints.prototype.computeBounds = function () {
  90808. var lmin = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](this.elements[0].x, this.elements[0].y);
  90809. var lmax = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](this.elements[0].x, this.elements[0].y);
  90810. this.elements.forEach(function (point) {
  90811. // x
  90812. if (point.x < lmin.x) {
  90813. lmin.x = point.x;
  90814. }
  90815. else if (point.x > lmax.x) {
  90816. lmax.x = point.x;
  90817. }
  90818. // y
  90819. if (point.y < lmin.y) {
  90820. lmin.y = point.y;
  90821. }
  90822. else if (point.y > lmax.y) {
  90823. lmax.y = point.y;
  90824. }
  90825. });
  90826. return {
  90827. min: lmin,
  90828. max: lmax,
  90829. width: lmax.x - lmin.x,
  90830. height: lmax.y - lmin.y
  90831. };
  90832. };
  90833. return PolygonPoints;
  90834. }());
  90835. /**
  90836. * Polygon
  90837. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  90838. */
  90839. var Polygon = /** @class */ (function () {
  90840. function Polygon() {
  90841. }
  90842. /**
  90843. * Creates a rectangle
  90844. * @param xmin bottom X coord
  90845. * @param ymin bottom Y coord
  90846. * @param xmax top X coord
  90847. * @param ymax top Y coord
  90848. * @returns points that make the resulting rectation
  90849. */
  90850. Polygon.Rectangle = function (xmin, ymin, xmax, ymax) {
  90851. return [
  90852. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmin, ymin),
  90853. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmax, ymin),
  90854. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmax, ymax),
  90855. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmin, ymax)
  90856. ];
  90857. };
  90858. /**
  90859. * Creates a circle
  90860. * @param radius radius of circle
  90861. * @param cx scale in x
  90862. * @param cy scale in y
  90863. * @param numberOfSides number of sides that make up the circle
  90864. * @returns points that make the resulting circle
  90865. */
  90866. Polygon.Circle = function (radius, cx, cy, numberOfSides) {
  90867. if (cx === void 0) { cx = 0; }
  90868. if (cy === void 0) { cy = 0; }
  90869. if (numberOfSides === void 0) { numberOfSides = 32; }
  90870. var result = new Array();
  90871. var angle = 0;
  90872. var increment = (Math.PI * 2) / numberOfSides;
  90873. for (var i = 0; i < numberOfSides; i++) {
  90874. result.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](cx + Math.cos(angle) * radius, cy + Math.sin(angle) * radius));
  90875. angle -= increment;
  90876. }
  90877. return result;
  90878. };
  90879. /**
  90880. * Creates a polygon from input string
  90881. * @param input Input polygon data
  90882. * @returns the parsed points
  90883. */
  90884. Polygon.Parse = function (input) {
  90885. var floats = input.split(/[^-+eE\.\d]+/).map(parseFloat).filter(function (val) { return (!isNaN(val)); });
  90886. var i, result = [];
  90887. for (i = 0; i < (floats.length & 0x7FFFFFFE); i += 2) {
  90888. result.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](floats[i], floats[i + 1]));
  90889. }
  90890. return result;
  90891. };
  90892. /**
  90893. * Starts building a polygon from x and y coordinates
  90894. * @param x x coordinate
  90895. * @param y y coordinate
  90896. * @returns the started path2
  90897. */
  90898. Polygon.StartingAt = function (x, y) {
  90899. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Path2"].StartingAt(x, y);
  90900. };
  90901. return Polygon;
  90902. }());
  90903. /**
  90904. * Builds a polygon
  90905. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  90906. */
  90907. var PolygonMeshBuilder = /** @class */ (function () {
  90908. /**
  90909. * Creates a PolygonMeshBuilder
  90910. * @param name name of the builder
  90911. * @param contours Path of the polygon
  90912. * @param scene scene to add to
  90913. * @param earcutInjection can be used to inject your own earcut reference
  90914. */
  90915. function PolygonMeshBuilder(name, contours, scene, earcutInjection) {
  90916. if (earcutInjection === void 0) { earcutInjection = earcut; }
  90917. this._points = new PolygonPoints();
  90918. this._outlinepoints = new PolygonPoints();
  90919. this._holes = new Array();
  90920. this._epoints = new Array();
  90921. this._eholes = new Array();
  90922. this.bjsEarcut = earcutInjection;
  90923. this._name = name;
  90924. this._scene = scene;
  90925. var points;
  90926. if (contours instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Path2"]) {
  90927. points = contours.getPoints();
  90928. }
  90929. else {
  90930. points = contours;
  90931. }
  90932. this._addToepoint(points);
  90933. this._points.add(points);
  90934. this._outlinepoints.add(points);
  90935. if (typeof this.bjsEarcut === 'undefined') {
  90936. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Earcut was not found, the polygon will not be built.");
  90937. }
  90938. }
  90939. PolygonMeshBuilder.prototype._addToepoint = function (points) {
  90940. for (var _i = 0, points_1 = points; _i < points_1.length; _i++) {
  90941. var p = points_1[_i];
  90942. this._epoints.push(p.x, p.y);
  90943. }
  90944. };
  90945. /**
  90946. * Adds a whole within the polygon
  90947. * @param hole Array of points defining the hole
  90948. * @returns this
  90949. */
  90950. PolygonMeshBuilder.prototype.addHole = function (hole) {
  90951. this._points.add(hole);
  90952. var holepoints = new PolygonPoints();
  90953. holepoints.add(hole);
  90954. this._holes.push(holepoints);
  90955. this._eholes.push(this._epoints.length / 2);
  90956. this._addToepoint(hole);
  90957. return this;
  90958. };
  90959. /**
  90960. * Creates the polygon
  90961. * @param updatable If the mesh should be updatable
  90962. * @param depth The depth of the mesh created
  90963. * @returns the created mesh
  90964. */
  90965. PolygonMeshBuilder.prototype.build = function (updatable, depth) {
  90966. var _this = this;
  90967. if (updatable === void 0) { updatable = false; }
  90968. if (depth === void 0) { depth = 0; }
  90969. var result = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"](this._name, this._scene);
  90970. var normals = new Array();
  90971. var positions = new Array();
  90972. var uvs = new Array();
  90973. var bounds = this._points.computeBounds();
  90974. this._points.elements.forEach(function (p) {
  90975. normals.push(0, 1.0, 0);
  90976. positions.push(p.x, 0, p.y);
  90977. uvs.push((p.x - bounds.min.x) / bounds.width, (p.y - bounds.min.y) / bounds.height);
  90978. });
  90979. var indices = new Array();
  90980. var res = this.bjsEarcut(this._epoints, this._eholes, 2);
  90981. for (var i = 0; i < res.length; i++) {
  90982. indices.push(res[i]);
  90983. }
  90984. if (depth > 0) {
  90985. var positionscount = (positions.length / 3); //get the current pointcount
  90986. this._points.elements.forEach(function (p) {
  90987. normals.push(0, -1.0, 0);
  90988. positions.push(p.x, -depth, p.y);
  90989. uvs.push(1 - (p.x - bounds.min.x) / bounds.width, 1 - (p.y - bounds.min.y) / bounds.height);
  90990. });
  90991. var totalCount = indices.length;
  90992. for (var i = 0; i < totalCount; i += 3) {
  90993. var i0 = indices[i + 0];
  90994. var i1 = indices[i + 1];
  90995. var i2 = indices[i + 2];
  90996. indices.push(i2 + positionscount);
  90997. indices.push(i1 + positionscount);
  90998. indices.push(i0 + positionscount);
  90999. }
  91000. //Add the sides
  91001. this.addSide(positions, normals, uvs, indices, bounds, this._outlinepoints, depth, false);
  91002. this._holes.forEach(function (hole) {
  91003. _this.addSide(positions, normals, uvs, indices, bounds, hole, depth, true);
  91004. });
  91005. }
  91006. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, positions, updatable);
  91007. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, normals, updatable);
  91008. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind, uvs, updatable);
  91009. result.setIndices(indices);
  91010. return result;
  91011. };
  91012. /**
  91013. * Adds a side to the polygon
  91014. * @param positions points that make the polygon
  91015. * @param normals normals of the polygon
  91016. * @param uvs uvs of the polygon
  91017. * @param indices indices of the polygon
  91018. * @param bounds bounds of the polygon
  91019. * @param points points of the polygon
  91020. * @param depth depth of the polygon
  91021. * @param flip flip of the polygon
  91022. */
  91023. PolygonMeshBuilder.prototype.addSide = function (positions, normals, uvs, indices, bounds, points, depth, flip) {
  91024. var StartIndex = positions.length / 3;
  91025. var ulength = 0;
  91026. for (var i = 0; i < points.elements.length; i++) {
  91027. var p = points.elements[i];
  91028. var p1;
  91029. if ((i + 1) > points.elements.length - 1) {
  91030. p1 = points.elements[0];
  91031. }
  91032. else {
  91033. p1 = points.elements[i + 1];
  91034. }
  91035. positions.push(p.x, 0, p.y);
  91036. positions.push(p.x, -depth, p.y);
  91037. positions.push(p1.x, 0, p1.y);
  91038. positions.push(p1.x, -depth, p1.y);
  91039. var v1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](p.x, 0, p.y);
  91040. var v2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](p1.x, 0, p1.y);
  91041. var v3 = v2.subtract(v1);
  91042. var v4 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 1, 0);
  91043. var vn = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(v3, v4);
  91044. vn = vn.normalize();
  91045. uvs.push(ulength / bounds.width, 0);
  91046. uvs.push(ulength / bounds.width, 1);
  91047. ulength += v3.length();
  91048. uvs.push((ulength / bounds.width), 0);
  91049. uvs.push((ulength / bounds.width), 1);
  91050. if (!flip) {
  91051. normals.push(-vn.x, -vn.y, -vn.z);
  91052. normals.push(-vn.x, -vn.y, -vn.z);
  91053. normals.push(-vn.x, -vn.y, -vn.z);
  91054. normals.push(-vn.x, -vn.y, -vn.z);
  91055. indices.push(StartIndex);
  91056. indices.push(StartIndex + 1);
  91057. indices.push(StartIndex + 2);
  91058. indices.push(StartIndex + 1);
  91059. indices.push(StartIndex + 3);
  91060. indices.push(StartIndex + 2);
  91061. }
  91062. else {
  91063. normals.push(vn.x, vn.y, vn.z);
  91064. normals.push(vn.x, vn.y, vn.z);
  91065. normals.push(vn.x, vn.y, vn.z);
  91066. normals.push(vn.x, vn.y, vn.z);
  91067. indices.push(StartIndex);
  91068. indices.push(StartIndex + 2);
  91069. indices.push(StartIndex + 1);
  91070. indices.push(StartIndex + 1);
  91071. indices.push(StartIndex + 2);
  91072. indices.push(StartIndex + 3);
  91073. }
  91074. StartIndex += 4;
  91075. }
  91076. };
  91077. return PolygonMeshBuilder;
  91078. }());
  91079. /***/ }),
  91080. /***/ "./Meshes/subMesh.ts":
  91081. /*!***************************!*\
  91082. !*** ./Meshes/subMesh.ts ***!
  91083. \***************************/
  91084. /*! exports provided: BaseSubMesh, SubMesh */
  91085. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91086. "use strict";
  91087. __webpack_require__.r(__webpack_exports__);
  91088. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return BaseSubMesh; });
  91089. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return SubMesh; });
  91090. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  91091. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  91092. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  91093. /* harmony import */ var _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/intersectionInfo */ "./Collisions/intersectionInfo.ts");
  91094. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  91095. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  91096. /**
  91097. * Base class for submeshes
  91098. */
  91099. var BaseSubMesh = /** @class */ (function () {
  91100. function BaseSubMesh() {
  91101. }
  91102. Object.defineProperty(BaseSubMesh.prototype, "effect", {
  91103. /**
  91104. * Gets associated effect
  91105. */
  91106. get: function () {
  91107. return this._materialEffect;
  91108. },
  91109. enumerable: true,
  91110. configurable: true
  91111. });
  91112. /**
  91113. * Sets associated effect (effect used to render this submesh)
  91114. * @param effect defines the effect to associate with
  91115. * @param defines defines the set of defines used to compile this effect
  91116. */
  91117. BaseSubMesh.prototype.setEffect = function (effect, defines) {
  91118. if (defines === void 0) { defines = null; }
  91119. if (this._materialEffect === effect) {
  91120. if (!effect) {
  91121. this._materialDefines = null;
  91122. }
  91123. return;
  91124. }
  91125. this._materialDefines = defines;
  91126. this._materialEffect = effect;
  91127. };
  91128. return BaseSubMesh;
  91129. }());
  91130. /**
  91131. * Defines a subdivision inside a mesh
  91132. */
  91133. var SubMesh = /** @class */ (function (_super) {
  91134. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SubMesh, _super);
  91135. /**
  91136. * Creates a new submesh
  91137. * @param materialIndex defines the material index to use
  91138. * @param verticesStart defines vertex index start
  91139. * @param verticesCount defines vertices count
  91140. * @param indexStart defines index start
  91141. * @param indexCount defines indices count
  91142. * @param mesh defines the parent mesh
  91143. * @param renderingMesh defines an optional rendering mesh
  91144. * @param createBoundingBox defines if bounding box should be created for this submesh
  91145. */
  91146. function SubMesh(
  91147. /** the material index to use */
  91148. materialIndex,
  91149. /** vertex index start */
  91150. verticesStart,
  91151. /** vertices count */
  91152. verticesCount,
  91153. /** index start */
  91154. indexStart,
  91155. /** indices count */
  91156. indexCount, mesh, renderingMesh, createBoundingBox) {
  91157. if (createBoundingBox === void 0) { createBoundingBox = true; }
  91158. var _this = _super.call(this) || this;
  91159. _this.materialIndex = materialIndex;
  91160. _this.verticesStart = verticesStart;
  91161. _this.verticesCount = verticesCount;
  91162. _this.indexStart = indexStart;
  91163. _this.indexCount = indexCount;
  91164. /** @hidden */
  91165. _this._renderId = 0;
  91166. _this._mesh = mesh;
  91167. _this._renderingMesh = renderingMesh || mesh;
  91168. mesh.subMeshes.push(_this);
  91169. _this._trianglePlanes = [];
  91170. _this._id = mesh.subMeshes.length - 1;
  91171. if (createBoundingBox) {
  91172. _this.refreshBoundingInfo();
  91173. mesh.computeWorldMatrix(true);
  91174. }
  91175. return _this;
  91176. }
  91177. /**
  91178. * Add a new submesh to a mesh
  91179. * @param materialIndex defines the material index to use
  91180. * @param verticesStart defines vertex index start
  91181. * @param verticesCount defines vertices count
  91182. * @param indexStart defines index start
  91183. * @param indexCount defines indices count
  91184. * @param mesh defines the parent mesh
  91185. * @param renderingMesh defines an optional rendering mesh
  91186. * @param createBoundingBox defines if bounding box should be created for this submesh
  91187. * @returns the new submesh
  91188. */
  91189. SubMesh.AddToMesh = function (materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox) {
  91190. if (createBoundingBox === void 0) { createBoundingBox = true; }
  91191. return new SubMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox);
  91192. };
  91193. Object.defineProperty(SubMesh.prototype, "IsGlobal", {
  91194. /**
  91195. * Returns true if this submesh covers the entire parent mesh
  91196. * @ignorenaming
  91197. */
  91198. get: function () {
  91199. return (this.verticesStart === 0 && this.verticesCount === this._mesh.getTotalVertices());
  91200. },
  91201. enumerable: true,
  91202. configurable: true
  91203. });
  91204. /**
  91205. * Returns the submesh BoudingInfo object
  91206. * @returns current bounding info (or mesh's one if the submesh is global)
  91207. */
  91208. SubMesh.prototype.getBoundingInfo = function () {
  91209. if (this.IsGlobal) {
  91210. return this._mesh.getBoundingInfo();
  91211. }
  91212. return this._boundingInfo;
  91213. };
  91214. /**
  91215. * Sets the submesh BoundingInfo
  91216. * @param boundingInfo defines the new bounding info to use
  91217. * @returns the SubMesh
  91218. */
  91219. SubMesh.prototype.setBoundingInfo = function (boundingInfo) {
  91220. this._boundingInfo = boundingInfo;
  91221. return this;
  91222. };
  91223. /**
  91224. * Returns the mesh of the current submesh
  91225. * @return the parent mesh
  91226. */
  91227. SubMesh.prototype.getMesh = function () {
  91228. return this._mesh;
  91229. };
  91230. /**
  91231. * Returns the rendering mesh of the submesh
  91232. * @returns the rendering mesh (could be different from parent mesh)
  91233. */
  91234. SubMesh.prototype.getRenderingMesh = function () {
  91235. return this._renderingMesh;
  91236. };
  91237. /**
  91238. * Returns the submesh material
  91239. * @returns null or the current material
  91240. */
  91241. SubMesh.prototype.getMaterial = function () {
  91242. var rootMaterial = this._renderingMesh.material;
  91243. if (rootMaterial === null || rootMaterial === undefined) {
  91244. return this._mesh.getScene().defaultMaterial;
  91245. }
  91246. else if (rootMaterial.getSubMaterial) {
  91247. var multiMaterial = rootMaterial;
  91248. var effectiveMaterial = multiMaterial.getSubMaterial(this.materialIndex);
  91249. if (this._currentMaterial !== effectiveMaterial) {
  91250. this._currentMaterial = effectiveMaterial;
  91251. this._materialDefines = null;
  91252. }
  91253. return effectiveMaterial;
  91254. }
  91255. return rootMaterial;
  91256. };
  91257. // Methods
  91258. /**
  91259. * Sets a new updated BoundingInfo object to the submesh
  91260. * @returns the SubMesh
  91261. */
  91262. SubMesh.prototype.refreshBoundingInfo = function () {
  91263. this._lastColliderWorldVertices = null;
  91264. if (this.IsGlobal || !this._renderingMesh || !this._renderingMesh.geometry) {
  91265. return this;
  91266. }
  91267. var data = this._renderingMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  91268. if (!data) {
  91269. this._boundingInfo = this._mesh.getBoundingInfo();
  91270. return this;
  91271. }
  91272. var indices = this._renderingMesh.getIndices();
  91273. var extend;
  91274. //is this the only submesh?
  91275. if (this.indexStart === 0 && this.indexCount === indices.length) {
  91276. var boundingInfo = this._renderingMesh.getBoundingInfo();
  91277. //the rendering mesh's bounding info can be used, it is the standard submesh for all indices.
  91278. extend = { minimum: boundingInfo.minimum.clone(), maximum: boundingInfo.maximum.clone() };
  91279. }
  91280. else {
  91281. extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].ExtractMinAndMaxIndexed(data, indices, this.indexStart, this.indexCount, this._renderingMesh.geometry.boundingBias);
  91282. }
  91283. if (this._boundingInfo) {
  91284. this._boundingInfo.reConstruct(extend.minimum, extend.maximum);
  91285. }
  91286. else {
  91287. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](extend.minimum, extend.maximum);
  91288. }
  91289. return this;
  91290. };
  91291. /** @hidden */
  91292. SubMesh.prototype._checkCollision = function (collider) {
  91293. var boundingInfo = this.getBoundingInfo();
  91294. return boundingInfo._checkCollision(collider);
  91295. };
  91296. /**
  91297. * Updates the submesh BoundingInfo
  91298. * @param world defines the world matrix to use to update the bounding info
  91299. * @returns the submesh
  91300. */
  91301. SubMesh.prototype.updateBoundingInfo = function (world) {
  91302. var boundingInfo = this.getBoundingInfo();
  91303. if (!boundingInfo) {
  91304. this.refreshBoundingInfo();
  91305. boundingInfo = this.getBoundingInfo();
  91306. }
  91307. boundingInfo.update(world);
  91308. return this;
  91309. };
  91310. /**
  91311. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  91312. * @param frustumPlanes defines the frustum planes
  91313. * @returns true if the submesh is intersecting with the frustum
  91314. */
  91315. SubMesh.prototype.isInFrustum = function (frustumPlanes) {
  91316. var boundingInfo = this.getBoundingInfo();
  91317. if (!boundingInfo) {
  91318. return false;
  91319. }
  91320. return boundingInfo.isInFrustum(frustumPlanes, this._mesh.cullingStrategy);
  91321. };
  91322. /**
  91323. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  91324. * @param frustumPlanes defines the frustum planes
  91325. * @returns true if the submesh is inside the frustum
  91326. */
  91327. SubMesh.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  91328. var boundingInfo = this.getBoundingInfo();
  91329. if (!boundingInfo) {
  91330. return false;
  91331. }
  91332. return boundingInfo.isCompletelyInFrustum(frustumPlanes);
  91333. };
  91334. /**
  91335. * Renders the submesh
  91336. * @param enableAlphaMode defines if alpha needs to be used
  91337. * @returns the submesh
  91338. */
  91339. SubMesh.prototype.render = function (enableAlphaMode) {
  91340. this._renderingMesh.render(this, enableAlphaMode);
  91341. return this;
  91342. };
  91343. /**
  91344. * @hidden
  91345. */
  91346. SubMesh.prototype._getLinesIndexBuffer = function (indices, engine) {
  91347. if (!this._linesIndexBuffer) {
  91348. var linesIndices = [];
  91349. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {
  91350. linesIndices.push(indices[index], indices[index + 1], indices[index + 1], indices[index + 2], indices[index + 2], indices[index]);
  91351. }
  91352. this._linesIndexBuffer = engine.createIndexBuffer(linesIndices);
  91353. this._linesIndexCount = linesIndices.length;
  91354. }
  91355. return this._linesIndexBuffer;
  91356. };
  91357. /**
  91358. * Checks if the submesh intersects with a ray
  91359. * @param ray defines the ray to test
  91360. * @returns true is the passed ray intersects the submesh bounding box
  91361. */
  91362. SubMesh.prototype.canIntersects = function (ray) {
  91363. var boundingInfo = this.getBoundingInfo();
  91364. if (!boundingInfo) {
  91365. return false;
  91366. }
  91367. return ray.intersectsBox(boundingInfo.boundingBox);
  91368. };
  91369. /**
  91370. * Intersects current submesh with a ray
  91371. * @param ray defines the ray to test
  91372. * @param positions defines mesh's positions array
  91373. * @param indices defines mesh's indices array
  91374. * @param fastCheck defines if only bounding info should be used
  91375. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  91376. * @returns intersection info or null if no intersection
  91377. */
  91378. SubMesh.prototype.intersects = function (ray, positions, indices, fastCheck, trianglePredicate) {
  91379. var material = this.getMaterial();
  91380. if (!material) {
  91381. return null;
  91382. }
  91383. switch (material.fillMode) {
  91384. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_PointListDrawMode:
  91385. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineListDrawMode:
  91386. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineLoopDrawMode:
  91387. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineStripDrawMode:
  91388. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TriangleFanDrawMode:
  91389. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TriangleStripDrawMode:
  91390. return null;
  91391. }
  91392. // LineMesh first as it's also a Mesh...
  91393. if (this._mesh.getClassName() === "InstancedLinesMesh" || this._mesh.getClassName() === "LinesMesh") {
  91394. return this._intersectLines(ray, positions, indices, this._mesh.intersectionThreshold, fastCheck);
  91395. }
  91396. return this._intersectTriangles(ray, positions, indices, fastCheck, trianglePredicate);
  91397. };
  91398. /** @hidden */
  91399. SubMesh.prototype._intersectLines = function (ray, positions, indices, intersectionThreshold, fastCheck) {
  91400. var intersectInfo = null;
  91401. // Line test
  91402. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 2) {
  91403. var p0 = positions[indices[index]];
  91404. var p1 = positions[indices[index + 1]];
  91405. var length = ray.intersectionSegment(p0, p1, intersectionThreshold);
  91406. if (length < 0) {
  91407. continue;
  91408. }
  91409. if (fastCheck || !intersectInfo || length < intersectInfo.distance) {
  91410. intersectInfo = new _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"](null, null, length);
  91411. intersectInfo.faceId = index / 2;
  91412. if (fastCheck) {
  91413. break;
  91414. }
  91415. }
  91416. }
  91417. return intersectInfo;
  91418. };
  91419. /** @hidden */
  91420. SubMesh.prototype._intersectTriangles = function (ray, positions, indices, fastCheck, trianglePredicate) {
  91421. var intersectInfo = null;
  91422. // Triangles test
  91423. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {
  91424. var p0 = positions[indices[index]];
  91425. var p1 = positions[indices[index + 1]];
  91426. var p2 = positions[indices[index + 2]];
  91427. if (trianglePredicate && !trianglePredicate(p0, p1, p2, ray)) {
  91428. continue;
  91429. }
  91430. var currentIntersectInfo = ray.intersectsTriangle(p0, p1, p2);
  91431. if (currentIntersectInfo) {
  91432. if (currentIntersectInfo.distance < 0) {
  91433. continue;
  91434. }
  91435. if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
  91436. intersectInfo = currentIntersectInfo;
  91437. intersectInfo.faceId = index / 3;
  91438. if (fastCheck) {
  91439. break;
  91440. }
  91441. }
  91442. }
  91443. }
  91444. return intersectInfo;
  91445. };
  91446. /** @hidden */
  91447. SubMesh.prototype._rebuild = function () {
  91448. if (this._linesIndexBuffer) {
  91449. this._linesIndexBuffer = null;
  91450. }
  91451. };
  91452. // Clone
  91453. /**
  91454. * Creates a new submesh from the passed mesh
  91455. * @param newMesh defines the new hosting mesh
  91456. * @param newRenderingMesh defines an optional rendering mesh
  91457. * @returns the new submesh
  91458. */
  91459. SubMesh.prototype.clone = function (newMesh, newRenderingMesh) {
  91460. var result = new SubMesh(this.materialIndex, this.verticesStart, this.verticesCount, this.indexStart, this.indexCount, newMesh, newRenderingMesh, false);
  91461. if (!this.IsGlobal) {
  91462. var boundingInfo = this.getBoundingInfo();
  91463. if (!boundingInfo) {
  91464. return result;
  91465. }
  91466. result._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](boundingInfo.minimum, boundingInfo.maximum);
  91467. }
  91468. return result;
  91469. };
  91470. // Dispose
  91471. /**
  91472. * Release associated resources
  91473. */
  91474. SubMesh.prototype.dispose = function () {
  91475. if (this._linesIndexBuffer) {
  91476. this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer);
  91477. this._linesIndexBuffer = null;
  91478. }
  91479. // Remove from mesh
  91480. var index = this._mesh.subMeshes.indexOf(this);
  91481. this._mesh.subMeshes.splice(index, 1);
  91482. };
  91483. /**
  91484. * Gets the class name
  91485. * @returns the string "SubMesh".
  91486. */
  91487. SubMesh.prototype.getClassName = function () {
  91488. return "SubMesh";
  91489. };
  91490. // Statics
  91491. /**
  91492. * Creates a new submesh from indices data
  91493. * @param materialIndex the index of the main mesh material
  91494. * @param startIndex the index where to start the copy in the mesh indices array
  91495. * @param indexCount the number of indices to copy then from the startIndex
  91496. * @param mesh the main mesh to create the submesh from
  91497. * @param renderingMesh the optional rendering mesh
  91498. * @returns a new submesh
  91499. */
  91500. SubMesh.CreateFromIndices = function (materialIndex, startIndex, indexCount, mesh, renderingMesh) {
  91501. var minVertexIndex = Number.MAX_VALUE;
  91502. var maxVertexIndex = -Number.MAX_VALUE;
  91503. var whatWillRender = (renderingMesh || mesh);
  91504. var indices = whatWillRender.getIndices();
  91505. for (var index = startIndex; index < startIndex + indexCount; index++) {
  91506. var vertexIndex = indices[index];
  91507. if (vertexIndex < minVertexIndex) {
  91508. minVertexIndex = vertexIndex;
  91509. }
  91510. if (vertexIndex > maxVertexIndex) {
  91511. maxVertexIndex = vertexIndex;
  91512. }
  91513. }
  91514. return new SubMesh(materialIndex, minVertexIndex, maxVertexIndex - minVertexIndex + 1, startIndex, indexCount, mesh, renderingMesh);
  91515. };
  91516. return SubMesh;
  91517. }(BaseSubMesh));
  91518. /***/ }),
  91519. /***/ "./Meshes/trailMesh.ts":
  91520. /*!*****************************!*\
  91521. !*** ./Meshes/trailMesh.ts ***!
  91522. \*****************************/
  91523. /*! exports provided: TrailMesh */
  91524. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91525. "use strict";
  91526. __webpack_require__.r(__webpack_exports__);
  91527. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TrailMesh", function() { return TrailMesh; });
  91528. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  91529. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  91530. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  91531. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  91532. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  91533. /**
  91534. * Class used to create a trail following a mesh
  91535. */
  91536. var TrailMesh = /** @class */ (function (_super) {
  91537. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TrailMesh, _super);
  91538. /**
  91539. * @constructor
  91540. * @param name The value used by scene.getMeshByName() to do a lookup.
  91541. * @param generator The mesh to generate a trail.
  91542. * @param scene The scene to add this mesh to.
  91543. * @param diameter Diameter of trailing mesh. Default is 1.
  91544. * @param length Length of trailing mesh. Default is 60.
  91545. * @param autoStart Automatically start trailing mesh. Default true.
  91546. */
  91547. function TrailMesh(name, generator, scene, diameter, length, autoStart) {
  91548. if (diameter === void 0) { diameter = 1; }
  91549. if (length === void 0) { length = 60; }
  91550. if (autoStart === void 0) { autoStart = true; }
  91551. var _this = _super.call(this, name, scene) || this;
  91552. _this._sectionPolygonPointsCount = 4;
  91553. _this._running = false;
  91554. _this._autoStart = autoStart;
  91555. _this._generator = generator;
  91556. _this._diameter = diameter;
  91557. _this._length = length;
  91558. _this._sectionVectors = [];
  91559. _this._sectionNormalVectors = [];
  91560. for (var i = 0; i < _this._sectionPolygonPointsCount; i++) {
  91561. _this._sectionVectors[i] = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  91562. _this._sectionNormalVectors[i] = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  91563. }
  91564. _this._createMesh();
  91565. return _this;
  91566. }
  91567. /**
  91568. * "TrailMesh"
  91569. * @returns "TrailMesh"
  91570. */
  91571. TrailMesh.prototype.getClassName = function () {
  91572. return "TrailMesh";
  91573. };
  91574. TrailMesh.prototype._createMesh = function () {
  91575. var data = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_4__["VertexData"]();
  91576. var positions = [];
  91577. var normals = [];
  91578. var indices = [];
  91579. var meshCenter = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  91580. if (this._generator._boundingInfo) {
  91581. meshCenter = this._generator._boundingInfo.boundingBox.centerWorld;
  91582. }
  91583. var alpha = 2 * Math.PI / this._sectionPolygonPointsCount;
  91584. for (var i = 0; i < this._sectionPolygonPointsCount; i++) {
  91585. positions.push(meshCenter.x + Math.cos(i * alpha) * this._diameter, meshCenter.y + Math.sin(i * alpha) * this._diameter, meshCenter.z);
  91586. }
  91587. for (var i = 1; i <= this._length; i++) {
  91588. for (var j = 0; j < this._sectionPolygonPointsCount; j++) {
  91589. positions.push(meshCenter.x + Math.cos(j * alpha) * this._diameter, meshCenter.y + Math.sin(j * alpha) * this._diameter, meshCenter.z);
  91590. }
  91591. var l = positions.length / 3 - 2 * this._sectionPolygonPointsCount;
  91592. for (var j = 0; j < this._sectionPolygonPointsCount - 1; j++) {
  91593. indices.push(l + j, l + j + this._sectionPolygonPointsCount, l + j + this._sectionPolygonPointsCount + 1);
  91594. indices.push(l + j, l + j + this._sectionPolygonPointsCount + 1, l + j + 1);
  91595. }
  91596. indices.push(l + this._sectionPolygonPointsCount - 1, l + this._sectionPolygonPointsCount - 1 + this._sectionPolygonPointsCount, l + this._sectionPolygonPointsCount);
  91597. indices.push(l + this._sectionPolygonPointsCount - 1, l + this._sectionPolygonPointsCount, l);
  91598. }
  91599. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_4__["VertexData"].ComputeNormals(positions, indices, normals);
  91600. data.positions = positions;
  91601. data.normals = normals;
  91602. data.indices = indices;
  91603. data.applyToMesh(this, true);
  91604. if (this._autoStart) {
  91605. this.start();
  91606. }
  91607. };
  91608. /**
  91609. * Start trailing mesh.
  91610. */
  91611. TrailMesh.prototype.start = function () {
  91612. var _this = this;
  91613. if (!this._running) {
  91614. this._running = true;
  91615. this._beforeRenderObserver = this.getScene().onBeforeRenderObservable.add(function () {
  91616. _this.update();
  91617. });
  91618. }
  91619. };
  91620. /**
  91621. * Stop trailing mesh.
  91622. */
  91623. TrailMesh.prototype.stop = function () {
  91624. if (this._beforeRenderObserver && this._running) {
  91625. this._running = false;
  91626. this.getScene().onBeforeRenderObservable.remove(this._beforeRenderObserver);
  91627. }
  91628. };
  91629. /**
  91630. * Update trailing mesh geometry.
  91631. */
  91632. TrailMesh.prototype.update = function () {
  91633. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind);
  91634. var normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind);
  91635. var wm = this._generator.getWorldMatrix();
  91636. if (positions && normals) {
  91637. for (var i = 3 * this._sectionPolygonPointsCount; i < positions.length; i++) {
  91638. positions[i - 3 * this._sectionPolygonPointsCount] = positions[i] - normals[i] / this._length * this._diameter;
  91639. }
  91640. for (var i = 3 * this._sectionPolygonPointsCount; i < normals.length; i++) {
  91641. normals[i - 3 * this._sectionPolygonPointsCount] = normals[i];
  91642. }
  91643. var l = positions.length - 3 * this._sectionPolygonPointsCount;
  91644. var alpha = 2 * Math.PI / this._sectionPolygonPointsCount;
  91645. for (var i = 0; i < this._sectionPolygonPointsCount; i++) {
  91646. this._sectionVectors[i].copyFromFloats(Math.cos(i * alpha) * this._diameter, Math.sin(i * alpha) * this._diameter, 0);
  91647. this._sectionNormalVectors[i].copyFromFloats(Math.cos(i * alpha), Math.sin(i * alpha), 0);
  91648. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this._sectionVectors[i], wm, this._sectionVectors[i]);
  91649. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormalToRef(this._sectionNormalVectors[i], wm, this._sectionNormalVectors[i]);
  91650. }
  91651. for (var i = 0; i < this._sectionPolygonPointsCount; i++) {
  91652. positions[l + 3 * i] = this._sectionVectors[i].x;
  91653. positions[l + 3 * i + 1] = this._sectionVectors[i].y;
  91654. positions[l + 3 * i + 2] = this._sectionVectors[i].z;
  91655. normals[l + 3 * i] = this._sectionNormalVectors[i].x;
  91656. normals[l + 3 * i + 1] = this._sectionNormalVectors[i].y;
  91657. normals[l + 3 * i + 2] = this._sectionNormalVectors[i].z;
  91658. }
  91659. this.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, positions, true, false);
  91660. this.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, normals, true, false);
  91661. }
  91662. };
  91663. /**
  91664. * Returns a new TrailMesh object.
  91665. * @param name is a string, the name given to the new mesh
  91666. * @param newGenerator use new generator object for cloned trail mesh
  91667. * @returns a new mesh
  91668. */
  91669. TrailMesh.prototype.clone = function (name, newGenerator) {
  91670. if (name === void 0) { name = ""; }
  91671. return new TrailMesh(name, (newGenerator === undefined ? this._generator : newGenerator), this.getScene(), this._diameter, this._length, this._autoStart);
  91672. };
  91673. /**
  91674. * Serializes this trail mesh
  91675. * @param serializationObject object to write serialization to
  91676. */
  91677. TrailMesh.prototype.serialize = function (serializationObject) {
  91678. _super.prototype.serialize.call(this, serializationObject);
  91679. };
  91680. /**
  91681. * Parses a serialized trail mesh
  91682. * @param parsedMesh the serialized mesh
  91683. * @param scene the scene to create the trail mesh in
  91684. * @returns the created trail mesh
  91685. */
  91686. TrailMesh.Parse = function (parsedMesh, scene) {
  91687. return new TrailMesh(parsedMesh.name, parsedMesh._generator, scene, parsedMesh._diameter, parsedMesh._length, parsedMesh._autoStart);
  91688. };
  91689. return TrailMesh;
  91690. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]));
  91691. /***/ }),
  91692. /***/ "./Meshes/transformNode.ts":
  91693. /*!*********************************!*\
  91694. !*** ./Meshes/transformNode.ts ***!
  91695. \*********************************/
  91696. /*! exports provided: TransformNode */
  91697. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91698. "use strict";
  91699. __webpack_require__.r(__webpack_exports__);
  91700. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return TransformNode; });
  91701. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  91702. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  91703. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  91704. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  91705. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../node */ "./node.ts");
  91706. /**
  91707. * 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.
  91708. * @see https://doc.babylonjs.com/how_to/transformnode
  91709. */
  91710. var TransformNode = /** @class */ (function (_super) {
  91711. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TransformNode, _super);
  91712. function TransformNode(name, scene, isPure) {
  91713. if (scene === void 0) { scene = null; }
  91714. if (isPure === void 0) { isPure = true; }
  91715. var _this = _super.call(this, name, scene) || this;
  91716. _this._forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 1);
  91717. _this._forwardInverted = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1);
  91718. _this._up = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 1, 0);
  91719. _this._right = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 0, 0);
  91720. _this._rightInverted = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-1, 0, 0);
  91721. // Properties
  91722. _this._position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  91723. _this._rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  91724. _this._scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].One();
  91725. _this._isDirty = false;
  91726. /**
  91727. * Set the billboard mode. Default is 0.
  91728. *
  91729. * | Value | Type | Description |
  91730. * | --- | --- | --- |
  91731. * | 0 | BILLBOARDMODE_NONE | |
  91732. * | 1 | BILLBOARDMODE_X | |
  91733. * | 2 | BILLBOARDMODE_Y | |
  91734. * | 4 | BILLBOARDMODE_Z | |
  91735. * | 7 | BILLBOARDMODE_ALL | |
  91736. *
  91737. */
  91738. _this.billboardMode = TransformNode.BILLBOARDMODE_NONE;
  91739. /**
  91740. * 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
  91741. */
  91742. _this.scalingDeterminant = 1;
  91743. /**
  91744. * Sets the distance of the object to max, often used by skybox
  91745. */
  91746. _this.infiniteDistance = false;
  91747. /**
  91748. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  91749. * By default the system will update normals to compensate
  91750. */
  91751. _this.ignoreNonUniformScaling = false;
  91752. /** @hidden */
  91753. _this._localMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  91754. _this._absolutePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  91755. _this._pivotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  91756. _this._postMultiplyPivotMatrix = false;
  91757. _this._isWorldMatrixFrozen = false;
  91758. /** @hidden */
  91759. _this._indexInSceneTransformNodesArray = -1;
  91760. /**
  91761. * An event triggered after the world matrix is updated
  91762. */
  91763. _this.onAfterWorldMatrixUpdateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  91764. _this._nonUniformScaling = false;
  91765. if (isPure) {
  91766. _this.getScene().addTransformNode(_this);
  91767. }
  91768. return _this;
  91769. }
  91770. /**
  91771. * Gets a string identifying the name of the class
  91772. * @returns "TransformNode" string
  91773. */
  91774. TransformNode.prototype.getClassName = function () {
  91775. return "TransformNode";
  91776. };
  91777. Object.defineProperty(TransformNode.prototype, "position", {
  91778. /**
  91779. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  91780. */
  91781. get: function () {
  91782. return this._position;
  91783. },
  91784. set: function (newPosition) {
  91785. this._position = newPosition;
  91786. this._isDirty = true;
  91787. },
  91788. enumerable: true,
  91789. configurable: true
  91790. });
  91791. Object.defineProperty(TransformNode.prototype, "rotation", {
  91792. /**
  91793. * 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)).
  91794. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  91795. */
  91796. get: function () {
  91797. return this._rotation;
  91798. },
  91799. set: function (newRotation) {
  91800. this._rotation = newRotation;
  91801. this._isDirty = true;
  91802. },
  91803. enumerable: true,
  91804. configurable: true
  91805. });
  91806. Object.defineProperty(TransformNode.prototype, "scaling", {
  91807. /**
  91808. * 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)).
  91809. */
  91810. get: function () {
  91811. return this._scaling;
  91812. },
  91813. set: function (newScaling) {
  91814. this._scaling = newScaling;
  91815. this._isDirty = true;
  91816. },
  91817. enumerable: true,
  91818. configurable: true
  91819. });
  91820. Object.defineProperty(TransformNode.prototype, "rotationQuaternion", {
  91821. /**
  91822. * 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).
  91823. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  91824. */
  91825. get: function () {
  91826. return this._rotationQuaternion;
  91827. },
  91828. set: function (quaternion) {
  91829. this._rotationQuaternion = quaternion;
  91830. //reset the rotation vector.
  91831. if (quaternion) {
  91832. this.rotation.setAll(0.0);
  91833. }
  91834. },
  91835. enumerable: true,
  91836. configurable: true
  91837. });
  91838. Object.defineProperty(TransformNode.prototype, "forward", {
  91839. /**
  91840. * The forward direction of that transform in world space.
  91841. */
  91842. get: function () {
  91843. 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()));
  91844. },
  91845. enumerable: true,
  91846. configurable: true
  91847. });
  91848. Object.defineProperty(TransformNode.prototype, "up", {
  91849. /**
  91850. * The up direction of that transform in world space.
  91851. */
  91852. get: function () {
  91853. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(this._up, this.getWorldMatrix()));
  91854. },
  91855. enumerable: true,
  91856. configurable: true
  91857. });
  91858. Object.defineProperty(TransformNode.prototype, "right", {
  91859. /**
  91860. * The right direction of that transform in world space.
  91861. */
  91862. get: function () {
  91863. 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()));
  91864. },
  91865. enumerable: true,
  91866. configurable: true
  91867. });
  91868. /**
  91869. * Copies the parameter passed Matrix into the mesh Pose matrix.
  91870. * @param matrix the matrix to copy the pose from
  91871. * @returns this TransformNode.
  91872. */
  91873. TransformNode.prototype.updatePoseMatrix = function (matrix) {
  91874. this._poseMatrix.copyFrom(matrix);
  91875. return this;
  91876. };
  91877. /**
  91878. * Returns the mesh Pose matrix.
  91879. * @returns the pose matrix
  91880. */
  91881. TransformNode.prototype.getPoseMatrix = function () {
  91882. return this._poseMatrix;
  91883. };
  91884. /** @hidden */
  91885. TransformNode.prototype._isSynchronized = function () {
  91886. if (this._isDirty) {
  91887. return false;
  91888. }
  91889. if (this.billboardMode !== this._cache.billboardMode || this.billboardMode !== TransformNode.BILLBOARDMODE_NONE) {
  91890. return false;
  91891. }
  91892. if (this._cache.pivotMatrixUpdated) {
  91893. return false;
  91894. }
  91895. if (this.infiniteDistance) {
  91896. return false;
  91897. }
  91898. if (!this._cache.position.equals(this._position)) {
  91899. return false;
  91900. }
  91901. if (this._rotationQuaternion) {
  91902. if (!this._cache.rotationQuaternion.equals(this._rotationQuaternion)) {
  91903. return false;
  91904. }
  91905. }
  91906. if (!this._cache.rotation.equals(this._rotation)) {
  91907. return false;
  91908. }
  91909. if (!this._cache.scaling.equals(this._scaling)) {
  91910. return false;
  91911. }
  91912. return true;
  91913. };
  91914. /** @hidden */
  91915. TransformNode.prototype._initCache = function () {
  91916. _super.prototype._initCache.call(this);
  91917. this._cache.localMatrixUpdated = false;
  91918. this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  91919. this._cache.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  91920. this._cache.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  91921. this._cache.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"](0, 0, 0, 0);
  91922. this._cache.billboardMode = -1;
  91923. this._cache.infiniteDistance = false;
  91924. };
  91925. /**
  91926. * Flag the transform node as dirty (Forcing it to update everything)
  91927. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  91928. * @returns this transform node
  91929. */
  91930. TransformNode.prototype.markAsDirty = function (property) {
  91931. if (property === "rotation") {
  91932. this.rotationQuaternion = null;
  91933. }
  91934. this._currentRenderId = Number.MAX_VALUE;
  91935. this._isDirty = true;
  91936. return this;
  91937. };
  91938. Object.defineProperty(TransformNode.prototype, "absolutePosition", {
  91939. /**
  91940. * Returns the current mesh absolute position.
  91941. * Returns a Vector3.
  91942. */
  91943. get: function () {
  91944. return this._absolutePosition;
  91945. },
  91946. enumerable: true,
  91947. configurable: true
  91948. });
  91949. /**
  91950. * Sets a new matrix to apply before all other transformation
  91951. * @param matrix defines the transform matrix
  91952. * @returns the current TransformNode
  91953. */
  91954. TransformNode.prototype.setPreTransformMatrix = function (matrix) {
  91955. return this.setPivotMatrix(matrix, false);
  91956. };
  91957. /**
  91958. * Sets a new pivot matrix to the current node
  91959. * @param matrix defines the new pivot matrix to use
  91960. * @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
  91961. * @returns the current TransformNode
  91962. */
  91963. TransformNode.prototype.setPivotMatrix = function (matrix, postMultiplyPivotMatrix) {
  91964. if (postMultiplyPivotMatrix === void 0) { postMultiplyPivotMatrix = true; }
  91965. this._pivotMatrix.copyFrom(matrix);
  91966. this._cache.pivotMatrixUpdated = true;
  91967. this._postMultiplyPivotMatrix = postMultiplyPivotMatrix;
  91968. if (this._postMultiplyPivotMatrix) {
  91969. if (!this._pivotMatrixInverse) {
  91970. this._pivotMatrixInverse = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(this._pivotMatrix);
  91971. }
  91972. else {
  91973. this._pivotMatrix.invertToRef(this._pivotMatrixInverse);
  91974. }
  91975. }
  91976. return this;
  91977. };
  91978. /**
  91979. * Returns the mesh pivot matrix.
  91980. * Default : Identity.
  91981. * @returns the matrix
  91982. */
  91983. TransformNode.prototype.getPivotMatrix = function () {
  91984. return this._pivotMatrix;
  91985. };
  91986. /**
  91987. * Prevents the World matrix to be computed any longer.
  91988. * @returns the TransformNode.
  91989. */
  91990. TransformNode.prototype.freezeWorldMatrix = function () {
  91991. this._isWorldMatrixFrozen = false; // no guarantee world is not already frozen, switch off temporarily
  91992. this.computeWorldMatrix(true);
  91993. this._isWorldMatrixFrozen = true;
  91994. return this;
  91995. };
  91996. /**
  91997. * Allows back the World matrix computation.
  91998. * @returns the TransformNode.
  91999. */
  92000. TransformNode.prototype.unfreezeWorldMatrix = function () {
  92001. this._isWorldMatrixFrozen = false;
  92002. this.computeWorldMatrix(true);
  92003. return this;
  92004. };
  92005. Object.defineProperty(TransformNode.prototype, "isWorldMatrixFrozen", {
  92006. /**
  92007. * True if the World matrix has been frozen.
  92008. */
  92009. get: function () {
  92010. return this._isWorldMatrixFrozen;
  92011. },
  92012. enumerable: true,
  92013. configurable: true
  92014. });
  92015. /**
  92016. * Retuns the mesh absolute position in the World.
  92017. * @returns a Vector3.
  92018. */
  92019. TransformNode.prototype.getAbsolutePosition = function () {
  92020. this.computeWorldMatrix();
  92021. return this._absolutePosition;
  92022. };
  92023. /**
  92024. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  92025. * @param absolutePosition the absolute position to set
  92026. * @returns the TransformNode.
  92027. */
  92028. TransformNode.prototype.setAbsolutePosition = function (absolutePosition) {
  92029. if (!absolutePosition) {
  92030. return this;
  92031. }
  92032. var absolutePositionX;
  92033. var absolutePositionY;
  92034. var absolutePositionZ;
  92035. if (absolutePosition.x === undefined) {
  92036. if (arguments.length < 3) {
  92037. return this;
  92038. }
  92039. absolutePositionX = arguments[0];
  92040. absolutePositionY = arguments[1];
  92041. absolutePositionZ = arguments[2];
  92042. }
  92043. else {
  92044. absolutePositionX = absolutePosition.x;
  92045. absolutePositionY = absolutePosition.y;
  92046. absolutePositionZ = absolutePosition.z;
  92047. }
  92048. if (this.parent) {
  92049. var invertParentWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  92050. this.parent.getWorldMatrix().invertToRef(invertParentWorldMatrix);
  92051. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(absolutePositionX, absolutePositionY, absolutePositionZ, invertParentWorldMatrix, this.position);
  92052. }
  92053. else {
  92054. this.position.x = absolutePositionX;
  92055. this.position.y = absolutePositionY;
  92056. this.position.z = absolutePositionZ;
  92057. }
  92058. return this;
  92059. };
  92060. /**
  92061. * Sets the mesh position in its local space.
  92062. * @param vector3 the position to set in localspace
  92063. * @returns the TransformNode.
  92064. */
  92065. TransformNode.prototype.setPositionWithLocalVector = function (vector3) {
  92066. this.computeWorldMatrix();
  92067. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(vector3, this._localMatrix);
  92068. return this;
  92069. };
  92070. /**
  92071. * Returns the mesh position in the local space from the current World matrix values.
  92072. * @returns a new Vector3.
  92073. */
  92074. TransformNode.prototype.getPositionExpressedInLocalSpace = function () {
  92075. this.computeWorldMatrix();
  92076. var invLocalWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  92077. this._localMatrix.invertToRef(invLocalWorldMatrix);
  92078. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(this.position, invLocalWorldMatrix);
  92079. };
  92080. /**
  92081. * Translates the mesh along the passed Vector3 in its local space.
  92082. * @param vector3 the distance to translate in localspace
  92083. * @returns the TransformNode.
  92084. */
  92085. TransformNode.prototype.locallyTranslate = function (vector3) {
  92086. this.computeWorldMatrix(true);
  92087. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(vector3, this._localMatrix);
  92088. return this;
  92089. };
  92090. /**
  92091. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  92092. * @param targetPoint the position (must be in same space as current mesh) to look at
  92093. * @param yawCor optional yaw (y-axis) correction in radians
  92094. * @param pitchCor optional pitch (x-axis) correction in radians
  92095. * @param rollCor optional roll (z-axis) correction in radians
  92096. * @param space the choosen space of the target
  92097. * @returns the TransformNode.
  92098. */
  92099. TransformNode.prototype.lookAt = function (targetPoint, yawCor, pitchCor, rollCor, space) {
  92100. if (yawCor === void 0) { yawCor = 0; }
  92101. if (pitchCor === void 0) { pitchCor = 0; }
  92102. if (rollCor === void 0) { rollCor = 0; }
  92103. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL; }
  92104. var dv = TransformNode._lookAtVectorCache;
  92105. var pos = space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL ? this.position : this.getAbsolutePosition();
  92106. targetPoint.subtractToRef(pos, dv);
  92107. this.setDirection(dv, yawCor, pitchCor, rollCor);
  92108. // Correct for parent's rotation offset
  92109. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].WORLD && this.parent) {
  92110. if (this.rotationQuaternion) {
  92111. // Get local rotation matrix of the looking object
  92112. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  92113. this.rotationQuaternion.toRotationMatrix(rotationMatrix);
  92114. // Offset rotation by parent's inverted rotation matrix to correct in world space
  92115. var parentRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  92116. this.parent.getWorldMatrix().getRotationMatrixToRef(parentRotationMatrix);
  92117. parentRotationMatrix.invert();
  92118. rotationMatrix.multiplyToRef(parentRotationMatrix, rotationMatrix);
  92119. this.rotationQuaternion.fromRotationMatrix(rotationMatrix);
  92120. }
  92121. else {
  92122. // Get local rotation matrix of the looking object
  92123. var quaternionRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  92124. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].FromEulerVectorToRef(this.rotation, quaternionRotation);
  92125. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  92126. quaternionRotation.toRotationMatrix(rotationMatrix);
  92127. // Offset rotation by parent's inverted rotation matrix to correct in world space
  92128. var parentRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  92129. this.parent.getWorldMatrix().getRotationMatrixToRef(parentRotationMatrix);
  92130. parentRotationMatrix.invert();
  92131. rotationMatrix.multiplyToRef(parentRotationMatrix, rotationMatrix);
  92132. quaternionRotation.fromRotationMatrix(rotationMatrix);
  92133. quaternionRotation.toEulerAnglesToRef(this.rotation);
  92134. }
  92135. }
  92136. return this;
  92137. };
  92138. /**
  92139. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  92140. * This Vector3 is expressed in the World space.
  92141. * @param localAxis axis to rotate
  92142. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  92143. */
  92144. TransformNode.prototype.getDirection = function (localAxis) {
  92145. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  92146. this.getDirectionToRef(localAxis, result);
  92147. return result;
  92148. };
  92149. /**
  92150. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  92151. * localAxis is expressed in the mesh local space.
  92152. * result is computed in the Wordl space from the mesh World matrix.
  92153. * @param localAxis axis to rotate
  92154. * @param result the resulting transformnode
  92155. * @returns this TransformNode.
  92156. */
  92157. TransformNode.prototype.getDirectionToRef = function (localAxis, result) {
  92158. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
  92159. return this;
  92160. };
  92161. /**
  92162. * Sets this transform node rotation to the given local axis.
  92163. * @param localAxis the axis in local space
  92164. * @param yawCor optional yaw (y-axis) correction in radians
  92165. * @param pitchCor optional pitch (x-axis) correction in radians
  92166. * @param rollCor optional roll (z-axis) correction in radians
  92167. * @returns this TransformNode
  92168. */
  92169. TransformNode.prototype.setDirection = function (localAxis, yawCor, pitchCor, rollCor) {
  92170. if (yawCor === void 0) { yawCor = 0; }
  92171. if (pitchCor === void 0) { pitchCor = 0; }
  92172. if (rollCor === void 0) { rollCor = 0; }
  92173. var yaw = -Math.atan2(localAxis.z, localAxis.x) + Math.PI / 2;
  92174. var len = Math.sqrt(localAxis.x * localAxis.x + localAxis.z * localAxis.z);
  92175. var pitch = -Math.atan2(localAxis.y, len);
  92176. if (this.rotationQuaternion) {
  92177. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(yaw + yawCor, pitch + pitchCor, rollCor, this.rotationQuaternion);
  92178. }
  92179. else {
  92180. this.rotation.x = pitch + pitchCor;
  92181. this.rotation.y = yaw + yawCor;
  92182. this.rotation.z = rollCor;
  92183. }
  92184. return this;
  92185. };
  92186. /**
  92187. * Sets a new pivot point to the current node
  92188. * @param point defines the new pivot point to use
  92189. * @param space defines if the point is in world or local space (local by default)
  92190. * @returns the current TransformNode
  92191. */
  92192. TransformNode.prototype.setPivotPoint = function (point, space) {
  92193. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL; }
  92194. if (this.getScene().getRenderId() == 0) {
  92195. this.computeWorldMatrix(true);
  92196. }
  92197. var wm = this.getWorldMatrix();
  92198. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].WORLD) {
  92199. var tmat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  92200. wm.invertToRef(tmat);
  92201. point = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(point, tmat);
  92202. }
  92203. return this.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(-point.x, -point.y, -point.z), true);
  92204. };
  92205. /**
  92206. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  92207. * @returns the pivot point
  92208. */
  92209. TransformNode.prototype.getPivotPoint = function () {
  92210. var point = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  92211. this.getPivotPointToRef(point);
  92212. return point;
  92213. };
  92214. /**
  92215. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  92216. * @param result the vector3 to store the result
  92217. * @returns this TransformNode.
  92218. */
  92219. TransformNode.prototype.getPivotPointToRef = function (result) {
  92220. result.x = -this._pivotMatrix.m[12];
  92221. result.y = -this._pivotMatrix.m[13];
  92222. result.z = -this._pivotMatrix.m[14];
  92223. return this;
  92224. };
  92225. /**
  92226. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  92227. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  92228. */
  92229. TransformNode.prototype.getAbsolutePivotPoint = function () {
  92230. var point = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  92231. this.getAbsolutePivotPointToRef(point);
  92232. return point;
  92233. };
  92234. /**
  92235. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  92236. * @param result vector3 to store the result
  92237. * @returns this TransformNode.
  92238. */
  92239. TransformNode.prototype.getAbsolutePivotPointToRef = function (result) {
  92240. result.x = this._pivotMatrix.m[12];
  92241. result.y = this._pivotMatrix.m[13];
  92242. result.z = this._pivotMatrix.m[14];
  92243. this.getPivotPointToRef(result);
  92244. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(result, this.getWorldMatrix(), result);
  92245. return this;
  92246. };
  92247. /**
  92248. * Defines the passed node as the parent of the current node.
  92249. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  92250. * @param node the node ot set as the parent
  92251. * @returns this TransformNode.
  92252. */
  92253. TransformNode.prototype.setParent = function (node) {
  92254. if (!node && !this.parent) {
  92255. return this;
  92256. }
  92257. var quatRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  92258. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  92259. var scale = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  92260. if (!node) {
  92261. if (this.parent && this.parent.computeWorldMatrix) {
  92262. this.parent.computeWorldMatrix(true);
  92263. }
  92264. this.computeWorldMatrix(true);
  92265. this.getWorldMatrix().decompose(scale, quatRotation, position);
  92266. }
  92267. else {
  92268. var diffMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  92269. var invParentMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  92270. this.computeWorldMatrix(true);
  92271. node.computeWorldMatrix(true);
  92272. node.getWorldMatrix().invertToRef(invParentMatrix);
  92273. this.getWorldMatrix().multiplyToRef(invParentMatrix, diffMatrix);
  92274. diffMatrix.decompose(scale, quatRotation, position);
  92275. }
  92276. if (this.rotationQuaternion) {
  92277. this.rotationQuaternion.copyFrom(quatRotation);
  92278. }
  92279. else {
  92280. quatRotation.toEulerAnglesToRef(this.rotation);
  92281. }
  92282. this.scaling.copyFrom(scale);
  92283. this.position.copyFrom(position);
  92284. this.parent = node;
  92285. return this;
  92286. };
  92287. Object.defineProperty(TransformNode.prototype, "nonUniformScaling", {
  92288. /**
  92289. * True if the scaling property of this object is non uniform eg. (1,2,1)
  92290. */
  92291. get: function () {
  92292. return this._nonUniformScaling;
  92293. },
  92294. enumerable: true,
  92295. configurable: true
  92296. });
  92297. /** @hidden */
  92298. TransformNode.prototype._updateNonUniformScalingState = function (value) {
  92299. if (this._nonUniformScaling === value) {
  92300. return false;
  92301. }
  92302. this._nonUniformScaling = value;
  92303. return true;
  92304. };
  92305. /**
  92306. * Attach the current TransformNode to another TransformNode associated with a bone
  92307. * @param bone Bone affecting the TransformNode
  92308. * @param affectedTransformNode TransformNode associated with the bone
  92309. * @returns this object
  92310. */
  92311. TransformNode.prototype.attachToBone = function (bone, affectedTransformNode) {
  92312. this._transformToBoneReferal = affectedTransformNode;
  92313. this.parent = bone;
  92314. if (bone.getWorldMatrix().determinant() < 0) {
  92315. this.scalingDeterminant *= -1;
  92316. }
  92317. return this;
  92318. };
  92319. /**
  92320. * Detach the transform node if its associated with a bone
  92321. * @returns this object
  92322. */
  92323. TransformNode.prototype.detachFromBone = function () {
  92324. if (!this.parent) {
  92325. return this;
  92326. }
  92327. if (this.parent.getWorldMatrix().determinant() < 0) {
  92328. this.scalingDeterminant *= -1;
  92329. }
  92330. this._transformToBoneReferal = null;
  92331. this.parent = null;
  92332. return this;
  92333. };
  92334. /**
  92335. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  92336. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  92337. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  92338. * The passed axis is also normalized.
  92339. * @param axis the axis to rotate around
  92340. * @param amount the amount to rotate in radians
  92341. * @param space Space to rotate in (Default: local)
  92342. * @returns the TransformNode.
  92343. */
  92344. TransformNode.prototype.rotate = function (axis, amount, space) {
  92345. axis.normalize();
  92346. if (!this.rotationQuaternion) {
  92347. this.rotationQuaternion = this.rotation.toQuaternion();
  92348. this.rotation.setAll(0);
  92349. }
  92350. var rotationQuaternion;
  92351. if (!space || space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL) {
  92352. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationAxisToRef(axis, amount, TransformNode._rotationAxisCache);
  92353. this.rotationQuaternion.multiplyToRef(rotationQuaternion, this.rotationQuaternion);
  92354. }
  92355. else {
  92356. if (this.parent) {
  92357. var invertParentWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  92358. this.parent.getWorldMatrix().invertToRef(invertParentWorldMatrix);
  92359. axis = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(axis, invertParentWorldMatrix);
  92360. }
  92361. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationAxisToRef(axis, amount, TransformNode._rotationAxisCache);
  92362. rotationQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  92363. }
  92364. return this;
  92365. };
  92366. /**
  92367. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  92368. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  92369. * The passed axis is also normalized. .
  92370. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  92371. * @param point the point to rotate around
  92372. * @param axis the axis to rotate around
  92373. * @param amount the amount to rotate in radians
  92374. * @returns the TransformNode
  92375. */
  92376. TransformNode.prototype.rotateAround = function (point, axis, amount) {
  92377. axis.normalize();
  92378. if (!this.rotationQuaternion) {
  92379. this.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
  92380. this.rotation.setAll(0);
  92381. }
  92382. var tmpVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  92383. var finalScale = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  92384. var finalTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[2];
  92385. var finalRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  92386. var translationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]; // T
  92387. var translationMatrixInv = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1]; // T'
  92388. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[2]; // R
  92389. var finalMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[3]; // T' x R x T
  92390. point.subtractToRef(this.position, tmpVector);
  92391. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(tmpVector.x, tmpVector.y, tmpVector.z, translationMatrix); // T
  92392. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(-tmpVector.x, -tmpVector.y, -tmpVector.z, translationMatrixInv); // T'
  92393. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationAxisToRef(axis, amount, rotationMatrix); // R
  92394. translationMatrixInv.multiplyToRef(rotationMatrix, finalMatrix); // T' x R
  92395. finalMatrix.multiplyToRef(translationMatrix, finalMatrix); // T' x R x T
  92396. finalMatrix.decompose(finalScale, finalRotation, finalTranslation);
  92397. this.position.addInPlace(finalTranslation);
  92398. finalRotation.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  92399. return this;
  92400. };
  92401. /**
  92402. * Translates the mesh along the axis vector for the passed distance in the given space.
  92403. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  92404. * @param axis the axis to translate in
  92405. * @param distance the distance to translate
  92406. * @param space Space to rotate in (Default: local)
  92407. * @returns the TransformNode.
  92408. */
  92409. TransformNode.prototype.translate = function (axis, distance, space) {
  92410. var displacementVector = axis.scale(distance);
  92411. if (!space || space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL) {
  92412. var tempV3 = this.getPositionExpressedInLocalSpace().add(displacementVector);
  92413. this.setPositionWithLocalVector(tempV3);
  92414. }
  92415. else {
  92416. this.setAbsolutePosition(this.getAbsolutePosition().add(displacementVector));
  92417. }
  92418. return this;
  92419. };
  92420. /**
  92421. * Adds a rotation step to the mesh current rotation.
  92422. * x, y, z are Euler angles expressed in radians.
  92423. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  92424. * This means this rotation is made in the mesh local space only.
  92425. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  92426. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  92427. * ```javascript
  92428. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  92429. * ```
  92430. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  92431. * 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.
  92432. * @param x Rotation to add
  92433. * @param y Rotation to add
  92434. * @param z Rotation to add
  92435. * @returns the TransformNode.
  92436. */
  92437. TransformNode.prototype.addRotation = function (x, y, z) {
  92438. var rotationQuaternion;
  92439. if (this.rotationQuaternion) {
  92440. rotationQuaternion = this.rotationQuaternion;
  92441. }
  92442. else {
  92443. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[1];
  92444. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, rotationQuaternion);
  92445. }
  92446. var accumulation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  92447. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(y, x, z, accumulation);
  92448. rotationQuaternion.multiplyInPlace(accumulation);
  92449. if (!this.rotationQuaternion) {
  92450. rotationQuaternion.toEulerAnglesToRef(this.rotation);
  92451. }
  92452. return this;
  92453. };
  92454. /**
  92455. * Computes the world matrix of the node
  92456. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  92457. * @returns the world matrix
  92458. */
  92459. TransformNode.prototype.computeWorldMatrix = function (force) {
  92460. if (this._isWorldMatrixFrozen) {
  92461. return this._worldMatrix;
  92462. }
  92463. if (!force && this.isSynchronized()) {
  92464. this._currentRenderId = this.getScene().getRenderId();
  92465. return this._worldMatrix;
  92466. }
  92467. this._updateCache();
  92468. this._cache.position.copyFrom(this.position);
  92469. this._cache.scaling.copyFrom(this.scaling);
  92470. this._cache.pivotMatrixUpdated = false;
  92471. this._cache.billboardMode = this.billboardMode;
  92472. this._cache.infiniteDistance = this.infiniteDistance;
  92473. this._currentRenderId = this.getScene().getRenderId();
  92474. this._childRenderId = this.getScene().getRenderId();
  92475. this._isDirty = false;
  92476. // Scaling
  92477. _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]);
  92478. // Rotation
  92479. //rotate, if quaternion is set and rotation was used
  92480. if (this.rotationQuaternion) {
  92481. var len = this.rotation.length();
  92482. if (len) {
  92483. this.rotationQuaternion.multiplyInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z));
  92484. this.rotation.copyFromFloats(0, 0, 0);
  92485. }
  92486. }
  92487. if (this.rotationQuaternion) {
  92488. this.rotationQuaternion.toRotationMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  92489. this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion);
  92490. }
  92491. else {
  92492. _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]);
  92493. this._cache.rotation.copyFrom(this.rotation);
  92494. }
  92495. // Translation
  92496. var camera = this.getScene().activeCamera;
  92497. if (this.infiniteDistance && !this.parent && camera) {
  92498. var cameraWorldMatrix = camera.getWorldMatrix();
  92499. var cameraGlobalPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](cameraWorldMatrix.m[12], cameraWorldMatrix.m[13], cameraWorldMatrix.m[14]);
  92500. _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]);
  92501. }
  92502. else {
  92503. _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]);
  92504. }
  92505. // Composing transformations
  92506. this._pivotMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1], _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[4]);
  92507. _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]);
  92508. // Billboarding (testing PG:http://www.babylonjs-playground.com/#UJEIL#13)
  92509. if (this.billboardMode !== TransformNode.BILLBOARDMODE_NONE && camera) {
  92510. if ((this.billboardMode & TransformNode.BILLBOARDMODE_ALL) !== TransformNode.BILLBOARDMODE_ALL) {
  92511. // Need to decompose each rotation here
  92512. var currentPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[3];
  92513. if (this.parent && this.parent.getWorldMatrix) {
  92514. if (this._transformToBoneReferal) {
  92515. this.parent.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6]);
  92516. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this.position, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6], currentPosition);
  92517. }
  92518. else {
  92519. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), currentPosition);
  92520. }
  92521. }
  92522. else {
  92523. currentPosition.copyFrom(this.position);
  92524. }
  92525. currentPosition.subtractInPlace(camera.globalPosition);
  92526. var finalEuler = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[4].copyFromFloats(0, 0, 0);
  92527. if ((this.billboardMode & TransformNode.BILLBOARDMODE_X) === TransformNode.BILLBOARDMODE_X) {
  92528. finalEuler.x = Math.atan2(-currentPosition.y, currentPosition.z);
  92529. }
  92530. if ((this.billboardMode & TransformNode.BILLBOARDMODE_Y) === TransformNode.BILLBOARDMODE_Y) {
  92531. finalEuler.y = Math.atan2(currentPosition.x, currentPosition.z);
  92532. }
  92533. if ((this.billboardMode & TransformNode.BILLBOARDMODE_Z) === TransformNode.BILLBOARDMODE_Z) {
  92534. finalEuler.z = Math.atan2(currentPosition.y, currentPosition.x);
  92535. }
  92536. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(finalEuler.y, finalEuler.x, finalEuler.z, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  92537. }
  92538. else {
  92539. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].copyFrom(camera.getViewMatrix());
  92540. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].setTranslationFromFloats(0, 0, 0);
  92541. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  92542. }
  92543. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5]);
  92544. _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]);
  92545. }
  92546. // Post multiply inverse of pivotMatrix
  92547. if (this._postMultiplyPivotMatrix) {
  92548. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5].multiplyToRef(this._pivotMatrixInverse, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5]);
  92549. }
  92550. // Local world
  92551. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5].multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[2], this._localMatrix);
  92552. // Parent
  92553. if (this.parent && this.parent.getWorldMatrix) {
  92554. if (this.billboardMode !== TransformNode.BILLBOARDMODE_NONE) {
  92555. if (this._transformToBoneReferal) {
  92556. this.parent.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6]);
  92557. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5].copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6]);
  92558. }
  92559. else {
  92560. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5].copyFrom(this.parent.getWorldMatrix());
  92561. }
  92562. this._localMatrix.getTranslationToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[5]);
  92563. _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]);
  92564. this._worldMatrix.copyFrom(this._localMatrix);
  92565. this._worldMatrix.setTranslation(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[5]);
  92566. }
  92567. else {
  92568. if (this._transformToBoneReferal) {
  92569. this._localMatrix.multiplyToRef(this.parent.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6]);
  92570. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), this._worldMatrix);
  92571. }
  92572. else {
  92573. this._localMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);
  92574. }
  92575. }
  92576. this._markSyncedWithParent();
  92577. }
  92578. else {
  92579. this._worldMatrix.copyFrom(this._localMatrix);
  92580. }
  92581. // Normal matrix
  92582. if (!this.ignoreNonUniformScaling) {
  92583. if (this.scaling.isNonUniform) {
  92584. this._updateNonUniformScalingState(true);
  92585. }
  92586. else if (this.parent && this.parent._nonUniformScaling) {
  92587. this._updateNonUniformScalingState(this.parent._nonUniformScaling);
  92588. }
  92589. else {
  92590. this._updateNonUniformScalingState(false);
  92591. }
  92592. }
  92593. else {
  92594. this._updateNonUniformScalingState(false);
  92595. }
  92596. this._afterComputeWorldMatrix();
  92597. // Absolute position
  92598. this._absolutePosition.copyFromFloats(this._worldMatrix.m[12], this._worldMatrix.m[13], this._worldMatrix.m[14]);
  92599. // Callbacks
  92600. this.onAfterWorldMatrixUpdateObservable.notifyObservers(this);
  92601. if (!this._poseMatrix) {
  92602. this._poseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(this._worldMatrix);
  92603. }
  92604. // Cache the determinant
  92605. this._worldMatrixDeterminant = this._worldMatrix.determinant();
  92606. return this._worldMatrix;
  92607. };
  92608. TransformNode.prototype._afterComputeWorldMatrix = function () {
  92609. };
  92610. /**
  92611. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  92612. * @param func callback function to add
  92613. *
  92614. * @returns the TransformNode.
  92615. */
  92616. TransformNode.prototype.registerAfterWorldMatrixUpdate = function (func) {
  92617. this.onAfterWorldMatrixUpdateObservable.add(func);
  92618. return this;
  92619. };
  92620. /**
  92621. * Removes a registered callback function.
  92622. * @param func callback function to remove
  92623. * @returns the TransformNode.
  92624. */
  92625. TransformNode.prototype.unregisterAfterWorldMatrixUpdate = function (func) {
  92626. this.onAfterWorldMatrixUpdateObservable.removeCallback(func);
  92627. return this;
  92628. };
  92629. /**
  92630. * Gets the position of the current mesh in camera space
  92631. * @param camera defines the camera to use
  92632. * @returns a position
  92633. */
  92634. TransformNode.prototype.getPositionInCameraSpace = function (camera) {
  92635. if (camera === void 0) { camera = null; }
  92636. if (!camera) {
  92637. camera = this.getScene().activeCamera;
  92638. }
  92639. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(this.absolutePosition, camera.getViewMatrix());
  92640. };
  92641. /**
  92642. * Returns the distance from the mesh to the active camera
  92643. * @param camera defines the camera to use
  92644. * @returns the distance
  92645. */
  92646. TransformNode.prototype.getDistanceToCamera = function (camera) {
  92647. if (camera === void 0) { camera = null; }
  92648. if (!camera) {
  92649. camera = this.getScene().activeCamera;
  92650. }
  92651. return this.absolutePosition.subtract(camera.position).length();
  92652. };
  92653. /**
  92654. * Clone the current transform node
  92655. * @param name Name of the new clone
  92656. * @param newParent New parent for the clone
  92657. * @param doNotCloneChildren Do not clone children hierarchy
  92658. * @returns the new transform node
  92659. */
  92660. TransformNode.prototype.clone = function (name, newParent, doNotCloneChildren) {
  92661. var _this = this;
  92662. var result = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new TransformNode(name, _this.getScene()); }, this);
  92663. result.name = name;
  92664. result.id = name;
  92665. if (newParent) {
  92666. result.parent = newParent;
  92667. }
  92668. if (!doNotCloneChildren) {
  92669. // Children
  92670. var directDescendants = this.getDescendants(true);
  92671. for (var index = 0; index < directDescendants.length; index++) {
  92672. var child = directDescendants[index];
  92673. if (child.clone) {
  92674. child.clone(name + "." + child.name, result);
  92675. }
  92676. }
  92677. }
  92678. return result;
  92679. };
  92680. /**
  92681. * Serializes the objects information.
  92682. * @param currentSerializationObject defines the object to serialize in
  92683. * @returns the serialized object
  92684. */
  92685. TransformNode.prototype.serialize = function (currentSerializationObject) {
  92686. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this, currentSerializationObject);
  92687. serializationObject.type = this.getClassName();
  92688. // Parent
  92689. if (this.parent) {
  92690. serializationObject.parentId = this.parent.id;
  92691. }
  92692. serializationObject.localMatrix = this.getPivotMatrix().asArray();
  92693. serializationObject.isEnabled = this.isEnabled();
  92694. // Parent
  92695. if (this.parent) {
  92696. serializationObject.parentId = this.parent.id;
  92697. }
  92698. return serializationObject;
  92699. };
  92700. // Statics
  92701. /**
  92702. * Returns a new TransformNode object parsed from the source provided.
  92703. * @param parsedTransformNode is the source.
  92704. * @param scene the scne the object belongs to
  92705. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  92706. * @returns a new TransformNode object parsed from the source provided.
  92707. */
  92708. TransformNode.Parse = function (parsedTransformNode, scene, rootUrl) {
  92709. var transformNode = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new TransformNode(parsedTransformNode.name, scene); }, parsedTransformNode, scene, rootUrl);
  92710. if (parsedTransformNode.localMatrix) {
  92711. transformNode.setPreTransformMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromArray(parsedTransformNode.localMatrix));
  92712. }
  92713. else if (parsedTransformNode.pivotMatrix) {
  92714. transformNode.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromArray(parsedTransformNode.pivotMatrix));
  92715. }
  92716. transformNode.setEnabled(parsedTransformNode.isEnabled);
  92717. // Parent
  92718. if (parsedTransformNode.parentId) {
  92719. transformNode._waitingParentId = parsedTransformNode.parentId;
  92720. }
  92721. return transformNode;
  92722. };
  92723. /**
  92724. * Get all child-transformNodes of this node
  92725. * @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
  92726. * @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
  92727. * @returns an array of TransformNode
  92728. */
  92729. TransformNode.prototype.getChildTransformNodes = function (directDescendantsOnly, predicate) {
  92730. var results = [];
  92731. this._getDescendants(results, directDescendantsOnly, function (node) {
  92732. return ((!predicate || predicate(node)) && (node instanceof TransformNode));
  92733. });
  92734. return results;
  92735. };
  92736. /**
  92737. * Releases resources associated with this transform node.
  92738. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92739. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92740. */
  92741. TransformNode.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  92742. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  92743. // Animations
  92744. this.getScene().stopAnimation(this);
  92745. // Remove from scene
  92746. this.getScene().removeTransformNode(this);
  92747. this.onAfterWorldMatrixUpdateObservable.clear();
  92748. if (doNotRecurse) {
  92749. var transformNodes = this.getChildTransformNodes(true);
  92750. for (var _i = 0, transformNodes_1 = transformNodes; _i < transformNodes_1.length; _i++) {
  92751. var transformNode = transformNodes_1[_i];
  92752. transformNode.parent = null;
  92753. transformNode.computeWorldMatrix(true);
  92754. }
  92755. }
  92756. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  92757. };
  92758. // Statics
  92759. /**
  92760. * Object will not rotate to face the camera
  92761. */
  92762. TransformNode.BILLBOARDMODE_NONE = 0;
  92763. /**
  92764. * Object will rotate to face the camera but only on the x axis
  92765. */
  92766. TransformNode.BILLBOARDMODE_X = 1;
  92767. /**
  92768. * Object will rotate to face the camera but only on the y axis
  92769. */
  92770. TransformNode.BILLBOARDMODE_Y = 2;
  92771. /**
  92772. * Object will rotate to face the camera but only on the z axis
  92773. */
  92774. TransformNode.BILLBOARDMODE_Z = 4;
  92775. /**
  92776. * Object will rotate to face the camera
  92777. */
  92778. TransformNode.BILLBOARDMODE_ALL = 7;
  92779. TransformNode._lookAtVectorCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  92780. TransformNode._rotationAxisCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  92781. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  92782. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("position")
  92783. ], TransformNode.prototype, "_position", void 0);
  92784. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  92785. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("rotation")
  92786. ], TransformNode.prototype, "_rotation", void 0);
  92787. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  92788. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsQuaternion"])("rotationQuaternion")
  92789. ], TransformNode.prototype, "_rotationQuaternion", void 0);
  92790. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  92791. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("scaling")
  92792. ], TransformNode.prototype, "_scaling", void 0);
  92793. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  92794. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  92795. ], TransformNode.prototype, "billboardMode", void 0);
  92796. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  92797. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  92798. ], TransformNode.prototype, "scalingDeterminant", void 0);
  92799. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  92800. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  92801. ], TransformNode.prototype, "infiniteDistance", void 0);
  92802. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  92803. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  92804. ], TransformNode.prototype, "ignoreNonUniformScaling", void 0);
  92805. return TransformNode;
  92806. }(_node__WEBPACK_IMPORTED_MODULE_4__["Node"]));
  92807. /***/ }),
  92808. /***/ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts":
  92809. /*!***************************************************************!*\
  92810. !*** ./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts ***!
  92811. \***************************************************************/
  92812. /*! exports provided: CubeMapToSphericalPolynomialTools */
  92813. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92814. "use strict";
  92815. __webpack_require__.r(__webpack_exports__);
  92816. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return CubeMapToSphericalPolynomialTools; });
  92817. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  92818. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  92819. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  92820. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  92821. var FileFaceOrientation = /** @class */ (function () {
  92822. function FileFaceOrientation(name, worldAxisForNormal, worldAxisForFileX, worldAxisForFileY) {
  92823. this.name = name;
  92824. this.worldAxisForNormal = worldAxisForNormal;
  92825. this.worldAxisForFileX = worldAxisForFileX;
  92826. this.worldAxisForFileY = worldAxisForFileY;
  92827. }
  92828. return FileFaceOrientation;
  92829. }());
  92830. /**
  92831. * Helper class dealing with the extraction of spherical polynomial dataArray
  92832. * from a cube map.
  92833. */
  92834. var CubeMapToSphericalPolynomialTools = /** @class */ (function () {
  92835. function CubeMapToSphericalPolynomialTools() {
  92836. }
  92837. /**
  92838. * Converts a texture to the according Spherical Polynomial data.
  92839. * This extracts the first 3 orders only as they are the only one used in the lighting.
  92840. *
  92841. * @param texture The texture to extract the information from.
  92842. * @return The Spherical Polynomial data.
  92843. */
  92844. CubeMapToSphericalPolynomialTools.ConvertCubeMapTextureToSphericalPolynomial = function (texture) {
  92845. if (!texture.isCube) {
  92846. // Only supports cube Textures currently.
  92847. return null;
  92848. }
  92849. var size = texture.getSize().width;
  92850. var right = texture.readPixels(0);
  92851. var left = texture.readPixels(1);
  92852. var up;
  92853. var down;
  92854. if (texture.isRenderTarget) {
  92855. up = texture.readPixels(3);
  92856. down = texture.readPixels(2);
  92857. }
  92858. else {
  92859. up = texture.readPixels(2);
  92860. down = texture.readPixels(3);
  92861. }
  92862. var front = texture.readPixels(4);
  92863. var back = texture.readPixels(5);
  92864. var gammaSpace = texture.gammaSpace;
  92865. // Always read as RGBA.
  92866. var format = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA;
  92867. var type = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  92868. if (texture.textureType && texture.textureType !== _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  92869. type = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_FLOAT;
  92870. }
  92871. var cubeInfo = {
  92872. size: size,
  92873. right: right,
  92874. left: left,
  92875. up: up,
  92876. down: down,
  92877. front: front,
  92878. back: back,
  92879. format: format,
  92880. type: type,
  92881. gammaSpace: gammaSpace,
  92882. };
  92883. return this.ConvertCubeMapToSphericalPolynomial(cubeInfo);
  92884. };
  92885. /**
  92886. * Converts a cubemap to the according Spherical Polynomial data.
  92887. * This extracts the first 3 orders only as they are the only one used in the lighting.
  92888. *
  92889. * @param cubeInfo The Cube map to extract the information from.
  92890. * @return The Spherical Polynomial data.
  92891. */
  92892. CubeMapToSphericalPolynomialTools.ConvertCubeMapToSphericalPolynomial = function (cubeInfo) {
  92893. var sphericalHarmonics = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalHarmonics"]();
  92894. var totalSolidAngle = 0.0;
  92895. // The (u,v) range is [-1,+1], so the distance between each texel is 2/Size.
  92896. var du = 2.0 / cubeInfo.size;
  92897. var dv = du;
  92898. // The (u,v) of the first texel is half a texel from the corner (-1,-1).
  92899. var minUV = du * 0.5 - 1.0;
  92900. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  92901. var fileFace = this.FileFaces[faceIndex];
  92902. var dataArray = cubeInfo[fileFace.name];
  92903. var v = minUV;
  92904. // TODO: we could perform the summation directly into a SphericalPolynomial (SP), which is more efficient than SphericalHarmonic (SH).
  92905. // This is possible because during the summation we do not need the SH-specific properties, e.g. orthogonality.
  92906. // Because SP is still linear, so summation is fine in that basis.
  92907. var stride = cubeInfo.format === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA ? 4 : 3;
  92908. for (var y = 0; y < cubeInfo.size; y++) {
  92909. var u = minUV;
  92910. for (var x = 0; x < cubeInfo.size; x++) {
  92911. // World direction (not normalised)
  92912. var worldDirection = fileFace.worldAxisForFileX.scale(u).add(fileFace.worldAxisForFileY.scale(v)).add(fileFace.worldAxisForNormal);
  92913. worldDirection.normalize();
  92914. var deltaSolidAngle = Math.pow(1.0 + u * u + v * v, -3.0 / 2.0);
  92915. var r = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 0];
  92916. var g = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 1];
  92917. var b = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 2];
  92918. // Handle Integer types.
  92919. if (cubeInfo.type === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  92920. r /= 255;
  92921. g /= 255;
  92922. b /= 255;
  92923. }
  92924. // Handle Gamma space textures.
  92925. if (cubeInfo.gammaSpace) {
  92926. r = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(r), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  92927. g = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(g), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  92928. b = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(b), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  92929. }
  92930. var color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](r, g, b);
  92931. sphericalHarmonics.addLight(worldDirection, color, deltaSolidAngle);
  92932. totalSolidAngle += deltaSolidAngle;
  92933. u += du;
  92934. }
  92935. v += dv;
  92936. }
  92937. }
  92938. // Solid angle for entire sphere is 4*pi
  92939. var sphereSolidAngle = 4.0 * Math.PI;
  92940. // Adjust the solid angle to allow for how many faces we processed.
  92941. var facesProcessed = 6.0;
  92942. var expectedSolidAngle = sphereSolidAngle * facesProcessed / 6.0;
  92943. // Adjust the harmonics so that the accumulated solid angle matches the expected solid angle.
  92944. // This is needed because the numerical integration over the cube uses a
  92945. // small angle approximation of solid angle for each texel (see deltaSolidAngle),
  92946. // and also to compensate for accumulative error due to float precision in the summation.
  92947. var correctionFactor = expectedSolidAngle / totalSolidAngle;
  92948. sphericalHarmonics.scale(correctionFactor);
  92949. sphericalHarmonics.convertIncidentRadianceToIrradiance();
  92950. sphericalHarmonics.convertIrradianceToLambertianRadiance();
  92951. return _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalPolynomial"].FromHarmonics(sphericalHarmonics);
  92952. };
  92953. CubeMapToSphericalPolynomialTools.FileFaces = [
  92954. 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)),
  92955. 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)),
  92956. 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)),
  92957. 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)),
  92958. 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)),
  92959. 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
  92960. ];
  92961. return CubeMapToSphericalPolynomialTools;
  92962. }());
  92963. /***/ }),
  92964. /***/ "./Misc/HighDynamicRange/hdr.ts":
  92965. /*!**************************************!*\
  92966. !*** ./Misc/HighDynamicRange/hdr.ts ***!
  92967. \**************************************/
  92968. /*! exports provided: HDRTools */
  92969. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92970. "use strict";
  92971. __webpack_require__.r(__webpack_exports__);
  92972. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return HDRTools; });
  92973. /* harmony import */ var _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  92974. /**
  92975. * This groups tools to convert HDR texture to native colors array.
  92976. */
  92977. var HDRTools = /** @class */ (function () {
  92978. function HDRTools() {
  92979. }
  92980. HDRTools.Ldexp = function (mantissa, exponent) {
  92981. if (exponent > 1023) {
  92982. return mantissa * Math.pow(2, 1023) * Math.pow(2, exponent - 1023);
  92983. }
  92984. if (exponent < -1074) {
  92985. return mantissa * Math.pow(2, -1074) * Math.pow(2, exponent + 1074);
  92986. }
  92987. return mantissa * Math.pow(2, exponent);
  92988. };
  92989. HDRTools.Rgbe2float = function (float32array, red, green, blue, exponent, index) {
  92990. if (exponent > 0) { /*nonzero pixel*/
  92991. exponent = this.Ldexp(1.0, exponent - (128 + 8));
  92992. float32array[index + 0] = red * exponent;
  92993. float32array[index + 1] = green * exponent;
  92994. float32array[index + 2] = blue * exponent;
  92995. }
  92996. else {
  92997. float32array[index + 0] = 0;
  92998. float32array[index + 1] = 0;
  92999. float32array[index + 2] = 0;
  93000. }
  93001. };
  93002. HDRTools.readStringLine = function (uint8array, startIndex) {
  93003. var line = "";
  93004. var character = "";
  93005. for (var i = startIndex; i < uint8array.length - startIndex; i++) {
  93006. character = String.fromCharCode(uint8array[i]);
  93007. if (character == "\n") {
  93008. break;
  93009. }
  93010. line += character;
  93011. }
  93012. return line;
  93013. };
  93014. /**
  93015. * Reads header information from an RGBE texture stored in a native array.
  93016. * More information on this format are available here:
  93017. * https://en.wikipedia.org/wiki/RGBE_image_format
  93018. *
  93019. * @param uint8array The binary file stored in native array.
  93020. * @return The header information.
  93021. */
  93022. HDRTools.RGBE_ReadHeader = function (uint8array) {
  93023. var height = 0;
  93024. var width = 0;
  93025. var line = this.readStringLine(uint8array, 0);
  93026. if (line[0] != '#' || line[1] != '?') {
  93027. throw "Bad HDR Format.";
  93028. }
  93029. var endOfHeader = false;
  93030. var findFormat = false;
  93031. var lineIndex = 0;
  93032. do {
  93033. lineIndex += (line.length + 1);
  93034. line = this.readStringLine(uint8array, lineIndex);
  93035. if (line == "FORMAT=32-bit_rle_rgbe") {
  93036. findFormat = true;
  93037. }
  93038. else if (line.length == 0) {
  93039. endOfHeader = true;
  93040. }
  93041. } while (!endOfHeader);
  93042. if (!findFormat) {
  93043. throw "HDR Bad header format, unsupported FORMAT";
  93044. }
  93045. lineIndex += (line.length + 1);
  93046. line = this.readStringLine(uint8array, lineIndex);
  93047. var sizeRegexp = /^\-Y (.*) \+X (.*)$/g;
  93048. var match = sizeRegexp.exec(line);
  93049. // TODO. Support +Y and -X if needed.
  93050. if (!match || match.length < 3) {
  93051. throw "HDR Bad header format, no size";
  93052. }
  93053. width = parseInt(match[2]);
  93054. height = parseInt(match[1]);
  93055. if (width < 8 || width > 0x7fff) {
  93056. throw "HDR Bad header format, unsupported size";
  93057. }
  93058. lineIndex += (line.length + 1);
  93059. return {
  93060. height: height,
  93061. width: width,
  93062. dataPosition: lineIndex
  93063. };
  93064. };
  93065. /**
  93066. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  93067. * This RGBE texture needs to store the information as a panorama.
  93068. *
  93069. * More information on this format are available here:
  93070. * https://en.wikipedia.org/wiki/RGBE_image_format
  93071. *
  93072. * @param buffer The binary file stored in an array buffer.
  93073. * @param size The expected size of the extracted cubemap.
  93074. * @return The Cube Map information.
  93075. */
  93076. HDRTools.GetCubeMapTextureData = function (buffer, size) {
  93077. var uint8array = new Uint8Array(buffer);
  93078. var hdrInfo = this.RGBE_ReadHeader(uint8array);
  93079. var data = this.RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  93080. var cubeMapData = _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_0__["PanoramaToCubeMapTools"].ConvertPanoramaToCubemap(data, hdrInfo.width, hdrInfo.height, size);
  93081. return cubeMapData;
  93082. };
  93083. /**
  93084. * Returns the pixels data extracted from an RGBE texture.
  93085. * This pixels will be stored left to right up to down in the R G B order in one array.
  93086. *
  93087. * More information on this format are available here:
  93088. * https://en.wikipedia.org/wiki/RGBE_image_format
  93089. *
  93090. * @param uint8array The binary file stored in an array buffer.
  93091. * @param hdrInfo The header information of the file.
  93092. * @return The pixels data in RGB right to left up to down order.
  93093. */
  93094. HDRTools.RGBE_ReadPixels = function (uint8array, hdrInfo) {
  93095. // Keep for multi format supports.
  93096. return this.RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  93097. };
  93098. HDRTools.RGBE_ReadPixels_RLE = function (uint8array, hdrInfo) {
  93099. var num_scanlines = hdrInfo.height;
  93100. var scanline_width = hdrInfo.width;
  93101. var a, b, c, d, count;
  93102. var dataIndex = hdrInfo.dataPosition;
  93103. var index = 0, endIndex = 0, i = 0;
  93104. var scanLineArrayBuffer = new ArrayBuffer(scanline_width * 4); // four channel R G B E
  93105. var scanLineArray = new Uint8Array(scanLineArrayBuffer);
  93106. // 3 channels of 4 bytes per pixel in float.
  93107. var resultBuffer = new ArrayBuffer(hdrInfo.width * hdrInfo.height * 4 * 3);
  93108. var resultArray = new Float32Array(resultBuffer);
  93109. // read in each successive scanline
  93110. while (num_scanlines > 0) {
  93111. a = uint8array[dataIndex++];
  93112. b = uint8array[dataIndex++];
  93113. c = uint8array[dataIndex++];
  93114. d = uint8array[dataIndex++];
  93115. if (a != 2 || b != 2 || (c & 0x80)) {
  93116. // this file is not run length encoded
  93117. throw "HDR Bad header format, not RLE";
  93118. }
  93119. if (((c << 8) | d) != scanline_width) {
  93120. throw "HDR Bad header format, wrong scan line width";
  93121. }
  93122. index = 0;
  93123. // read each of the four channels for the scanline into the buffer
  93124. for (i = 0; i < 4; i++) {
  93125. endIndex = (i + 1) * scanline_width;
  93126. while (index < endIndex) {
  93127. a = uint8array[dataIndex++];
  93128. b = uint8array[dataIndex++];
  93129. if (a > 128) {
  93130. // a run of the same value
  93131. count = a - 128;
  93132. if ((count == 0) || (count > endIndex - index)) {
  93133. throw "HDR Bad Format, bad scanline data (run)";
  93134. }
  93135. while (count-- > 0) {
  93136. scanLineArray[index++] = b;
  93137. }
  93138. }
  93139. else {
  93140. // a non-run
  93141. count = a;
  93142. if ((count == 0) || (count > endIndex - index)) {
  93143. throw "HDR Bad Format, bad scanline data (non-run)";
  93144. }
  93145. scanLineArray[index++] = b;
  93146. if (--count > 0) {
  93147. for (var j = 0; j < count; j++) {
  93148. scanLineArray[index++] = uint8array[dataIndex++];
  93149. }
  93150. }
  93151. }
  93152. }
  93153. }
  93154. // now convert data from buffer into floats
  93155. for (i = 0; i < scanline_width; i++) {
  93156. a = scanLineArray[i];
  93157. b = scanLineArray[i + scanline_width];
  93158. c = scanLineArray[i + 2 * scanline_width];
  93159. d = scanLineArray[i + 3 * scanline_width];
  93160. this.Rgbe2float(resultArray, a, b, c, d, (hdrInfo.height - num_scanlines) * scanline_width * 3 + i * 3);
  93161. }
  93162. num_scanlines--;
  93163. }
  93164. return resultArray;
  93165. };
  93166. return HDRTools;
  93167. }());
  93168. /***/ }),
  93169. /***/ "./Misc/HighDynamicRange/index.ts":
  93170. /*!****************************************!*\
  93171. !*** ./Misc/HighDynamicRange/index.ts ***!
  93172. \****************************************/
  93173. /*! exports provided: CubeMapToSphericalPolynomialTools, HDRTools, PanoramaToCubeMapTools */
  93174. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93175. "use strict";
  93176. __webpack_require__.r(__webpack_exports__);
  93177. /* harmony import */ var _cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  93178. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__["CubeMapToSphericalPolynomialTools"]; });
  93179. /* harmony import */ var _hdr__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hdr */ "./Misc/HighDynamicRange/hdr.ts");
  93180. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _hdr__WEBPACK_IMPORTED_MODULE_1__["HDRTools"]; });
  93181. /* harmony import */ var _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  93182. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_2__["PanoramaToCubeMapTools"]; });
  93183. /***/ }),
  93184. /***/ "./Misc/HighDynamicRange/panoramaToCubemap.ts":
  93185. /*!****************************************************!*\
  93186. !*** ./Misc/HighDynamicRange/panoramaToCubemap.ts ***!
  93187. \****************************************************/
  93188. /*! exports provided: PanoramaToCubeMapTools */
  93189. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93190. "use strict";
  93191. __webpack_require__.r(__webpack_exports__);
  93192. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return PanoramaToCubeMapTools; });
  93193. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  93194. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  93195. /**
  93196. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  93197. */
  93198. var PanoramaToCubeMapTools = /** @class */ (function () {
  93199. function PanoramaToCubeMapTools() {
  93200. }
  93201. /**
  93202. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  93203. *
  93204. * @param float32Array The source data.
  93205. * @param inputWidth The width of the input panorama.
  93206. * @param inputHeight The height of the input panorama.
  93207. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  93208. * @return The cubemap data
  93209. */
  93210. PanoramaToCubeMapTools.ConvertPanoramaToCubemap = function (float32Array, inputWidth, inputHeight, size) {
  93211. if (!float32Array) {
  93212. throw "ConvertPanoramaToCubemap: input cannot be null";
  93213. }
  93214. if (float32Array.length != inputWidth * inputHeight * 3) {
  93215. throw "ConvertPanoramaToCubemap: input size is wrong";
  93216. }
  93217. var textureFront = this.CreateCubemapTexture(size, this.FACE_FRONT, float32Array, inputWidth, inputHeight);
  93218. var textureBack = this.CreateCubemapTexture(size, this.FACE_BACK, float32Array, inputWidth, inputHeight);
  93219. var textureLeft = this.CreateCubemapTexture(size, this.FACE_LEFT, float32Array, inputWidth, inputHeight);
  93220. var textureRight = this.CreateCubemapTexture(size, this.FACE_RIGHT, float32Array, inputWidth, inputHeight);
  93221. var textureUp = this.CreateCubemapTexture(size, this.FACE_UP, float32Array, inputWidth, inputHeight);
  93222. var textureDown = this.CreateCubemapTexture(size, this.FACE_DOWN, float32Array, inputWidth, inputHeight);
  93223. return {
  93224. front: textureFront,
  93225. back: textureBack,
  93226. left: textureLeft,
  93227. right: textureRight,
  93228. up: textureUp,
  93229. down: textureDown,
  93230. size: size,
  93231. type: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_FLOAT,
  93232. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTUREFORMAT_RGB,
  93233. gammaSpace: false,
  93234. };
  93235. };
  93236. PanoramaToCubeMapTools.CreateCubemapTexture = function (texSize, faceData, float32Array, inputWidth, inputHeight) {
  93237. var buffer = new ArrayBuffer(texSize * texSize * 4 * 3);
  93238. var textureArray = new Float32Array(buffer);
  93239. var rotDX1 = faceData[1].subtract(faceData[0]).scale(1 / texSize);
  93240. var rotDX2 = faceData[3].subtract(faceData[2]).scale(1 / texSize);
  93241. var dy = 1 / texSize;
  93242. var fy = 0;
  93243. for (var y = 0; y < texSize; y++) {
  93244. var xv1 = faceData[0];
  93245. var xv2 = faceData[2];
  93246. for (var x = 0; x < texSize; x++) {
  93247. var v = xv2.subtract(xv1).scale(fy).add(xv1);
  93248. v.normalize();
  93249. var color = this.CalcProjectionSpherical(v, float32Array, inputWidth, inputHeight);
  93250. // 3 channels per pixels
  93251. textureArray[y * texSize * 3 + (x * 3) + 0] = color.r;
  93252. textureArray[y * texSize * 3 + (x * 3) + 1] = color.g;
  93253. textureArray[y * texSize * 3 + (x * 3) + 2] = color.b;
  93254. xv1 = xv1.add(rotDX1);
  93255. xv2 = xv2.add(rotDX2);
  93256. }
  93257. fy += dy;
  93258. }
  93259. return textureArray;
  93260. };
  93261. PanoramaToCubeMapTools.CalcProjectionSpherical = function (vDir, float32Array, inputWidth, inputHeight) {
  93262. var theta = Math.atan2(vDir.z, vDir.x);
  93263. var phi = Math.acos(vDir.y);
  93264. while (theta < -Math.PI) {
  93265. theta += 2 * Math.PI;
  93266. }
  93267. while (theta > Math.PI) {
  93268. theta -= 2 * Math.PI;
  93269. }
  93270. var dx = theta / Math.PI;
  93271. var dy = phi / Math.PI;
  93272. // recenter.
  93273. dx = dx * 0.5 + 0.5;
  93274. var px = Math.round(dx * inputWidth);
  93275. if (px < 0) {
  93276. px = 0;
  93277. }
  93278. else if (px >= inputWidth) {
  93279. px = inputWidth - 1;
  93280. }
  93281. var py = Math.round(dy * inputHeight);
  93282. if (py < 0) {
  93283. py = 0;
  93284. }
  93285. else if (py >= inputHeight) {
  93286. py = inputHeight - 1;
  93287. }
  93288. var inputY = (inputHeight - py - 1);
  93289. var r = float32Array[inputY * inputWidth * 3 + (px * 3) + 0];
  93290. var g = float32Array[inputY * inputWidth * 3 + (px * 3) + 1];
  93291. var b = float32Array[inputY * inputWidth * 3 + (px * 3) + 2];
  93292. return {
  93293. r: r,
  93294. g: g,
  93295. b: b
  93296. };
  93297. };
  93298. PanoramaToCubeMapTools.FACE_FRONT = [
  93299. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  93300. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0),
  93301. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0),
  93302. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0)
  93303. ];
  93304. PanoramaToCubeMapTools.FACE_BACK = [
  93305. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  93306. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  93307. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0),
  93308. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0)
  93309. ];
  93310. PanoramaToCubeMapTools.FACE_RIGHT = [
  93311. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0),
  93312. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  93313. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0),
  93314. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0)
  93315. ];
  93316. PanoramaToCubeMapTools.FACE_LEFT = [
  93317. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  93318. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  93319. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0),
  93320. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0)
  93321. ];
  93322. PanoramaToCubeMapTools.FACE_DOWN = [
  93323. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0),
  93324. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0),
  93325. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0),
  93326. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0)
  93327. ];
  93328. PanoramaToCubeMapTools.FACE_UP = [
  93329. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  93330. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  93331. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  93332. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0)
  93333. ];
  93334. return PanoramaToCubeMapTools;
  93335. }());
  93336. /***/ }),
  93337. /***/ "./Misc/andOrNotEvaluator.ts":
  93338. /*!***********************************!*\
  93339. !*** ./Misc/andOrNotEvaluator.ts ***!
  93340. \***********************************/
  93341. /*! exports provided: AndOrNotEvaluator */
  93342. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93343. "use strict";
  93344. __webpack_require__.r(__webpack_exports__);
  93345. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return AndOrNotEvaluator; });
  93346. /**
  93347. * Class used to evalaute queries containing `and` and `or` operators
  93348. */
  93349. var AndOrNotEvaluator = /** @class */ (function () {
  93350. function AndOrNotEvaluator() {
  93351. }
  93352. /**
  93353. * Evaluate a query
  93354. * @param query defines the query to evaluate
  93355. * @param evaluateCallback defines the callback used to filter result
  93356. * @returns true if the query matches
  93357. */
  93358. AndOrNotEvaluator.Eval = function (query, evaluateCallback) {
  93359. if (!query.match(/\([^\(\)]*\)/g)) {
  93360. query = AndOrNotEvaluator._HandleParenthesisContent(query, evaluateCallback);
  93361. }
  93362. else {
  93363. query = query.replace(/\([^\(\)]*\)/g, function (r) {
  93364. // remove parenthesis
  93365. r = r.slice(1, r.length - 1);
  93366. return AndOrNotEvaluator._HandleParenthesisContent(r, evaluateCallback);
  93367. });
  93368. }
  93369. if (query === "true") {
  93370. return true;
  93371. }
  93372. if (query === "false") {
  93373. return false;
  93374. }
  93375. return AndOrNotEvaluator.Eval(query, evaluateCallback);
  93376. };
  93377. AndOrNotEvaluator._HandleParenthesisContent = function (parenthesisContent, evaluateCallback) {
  93378. evaluateCallback = evaluateCallback || (function (r) {
  93379. return r === "true" ? true : false;
  93380. });
  93381. var result;
  93382. var or = parenthesisContent.split("||");
  93383. for (var i in or) {
  93384. if (or.hasOwnProperty(i)) {
  93385. var ori = AndOrNotEvaluator._SimplifyNegation(or[i].trim());
  93386. var and = ori.split("&&");
  93387. if (and.length > 1) {
  93388. for (var j = 0; j < and.length; ++j) {
  93389. var andj = AndOrNotEvaluator._SimplifyNegation(and[j].trim());
  93390. if (andj !== "true" && andj !== "false") {
  93391. if (andj[0] === "!") {
  93392. result = !evaluateCallback(andj.substring(1));
  93393. }
  93394. else {
  93395. result = evaluateCallback(andj);
  93396. }
  93397. }
  93398. else {
  93399. result = andj === "true" ? true : false;
  93400. }
  93401. if (!result) { // no need to continue since 'false && ... && ...' will always return false
  93402. ori = "false";
  93403. break;
  93404. }
  93405. }
  93406. }
  93407. if (result || ori === "true") { // no need to continue since 'true || ... || ...' will always return true
  93408. result = true;
  93409. break;
  93410. }
  93411. // result equals false (or undefined)
  93412. if (ori !== "true" && ori !== "false") {
  93413. if (ori[0] === "!") {
  93414. result = !evaluateCallback(ori.substring(1));
  93415. }
  93416. else {
  93417. result = evaluateCallback(ori);
  93418. }
  93419. }
  93420. else {
  93421. result = ori === "true" ? true : false;
  93422. }
  93423. }
  93424. }
  93425. // the whole parenthesis scope is replaced by 'true' or 'false'
  93426. return result ? "true" : "false";
  93427. };
  93428. AndOrNotEvaluator._SimplifyNegation = function (booleanString) {
  93429. booleanString = booleanString.replace(/^[\s!]+/, function (r) {
  93430. // remove whitespaces
  93431. r = r.replace(/[\s]/g, function () { return ""; });
  93432. return r.length % 2 ? "!" : "";
  93433. });
  93434. booleanString = booleanString.trim();
  93435. if (booleanString === "!true") {
  93436. booleanString = "false";
  93437. }
  93438. else if (booleanString === "!false") {
  93439. booleanString = "true";
  93440. }
  93441. return booleanString;
  93442. };
  93443. return AndOrNotEvaluator;
  93444. }());
  93445. /***/ }),
  93446. /***/ "./Misc/arrayTools.ts":
  93447. /*!****************************!*\
  93448. !*** ./Misc/arrayTools.ts ***!
  93449. \****************************/
  93450. /*! exports provided: ArrayTools */
  93451. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93452. "use strict";
  93453. __webpack_require__.r(__webpack_exports__);
  93454. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArrayTools", function() { return ArrayTools; });
  93455. /**
  93456. * Class containing a set of static utilities functions for arrays.
  93457. */
  93458. var ArrayTools = /** @class */ (function () {
  93459. function ArrayTools() {
  93460. }
  93461. /**
  93462. * Returns an array of the given size filled with element built from the given constructor and the paramters
  93463. * @param size the number of element to construct and put in the array
  93464. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  93465. * @returns a new array filled with new objects
  93466. */
  93467. ArrayTools.BuildArray = function (size, itemBuilder) {
  93468. var a = [];
  93469. for (var i = 0; i < size; ++i) {
  93470. a.push(itemBuilder());
  93471. }
  93472. return a;
  93473. };
  93474. return ArrayTools;
  93475. }());
  93476. /***/ }),
  93477. /***/ "./Misc/assetsManager.ts":
  93478. /*!*******************************!*\
  93479. !*** ./Misc/assetsManager.ts ***!
  93480. \*******************************/
  93481. /*! exports provided: AssetTaskState, AbstractAssetTask, AssetsProgressEvent, MeshAssetTask, TextFileAssetTask, BinaryFileAssetTask, ImageAssetTask, TextureAssetTask, CubeTextureAssetTask, HDRCubeTextureAssetTask, AssetsManager */
  93482. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93483. "use strict";
  93484. __webpack_require__.r(__webpack_exports__);
  93485. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return AssetTaskState; });
  93486. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return AbstractAssetTask; });
  93487. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return AssetsProgressEvent; });
  93488. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return MeshAssetTask; });
  93489. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return TextFileAssetTask; });
  93490. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return BinaryFileAssetTask; });
  93491. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return ImageAssetTask; });
  93492. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return TextureAssetTask; });
  93493. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return CubeTextureAssetTask; });
  93494. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return HDRCubeTextureAssetTask; });
  93495. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return AssetsManager; });
  93496. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  93497. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  93498. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  93499. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  93500. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  93501. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  93502. /* harmony import */ var _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  93503. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  93504. /**
  93505. * Defines the list of states available for a task inside a AssetsManager
  93506. */
  93507. var AssetTaskState;
  93508. (function (AssetTaskState) {
  93509. /**
  93510. * Initialization
  93511. */
  93512. AssetTaskState[AssetTaskState["INIT"] = 0] = "INIT";
  93513. /**
  93514. * Running
  93515. */
  93516. AssetTaskState[AssetTaskState["RUNNING"] = 1] = "RUNNING";
  93517. /**
  93518. * Done
  93519. */
  93520. AssetTaskState[AssetTaskState["DONE"] = 2] = "DONE";
  93521. /**
  93522. * Error
  93523. */
  93524. AssetTaskState[AssetTaskState["ERROR"] = 3] = "ERROR";
  93525. })(AssetTaskState || (AssetTaskState = {}));
  93526. /**
  93527. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  93528. */
  93529. var AbstractAssetTask = /** @class */ (function () {
  93530. /**
  93531. * Creates a new AssetsManager
  93532. * @param name defines the name of the task
  93533. */
  93534. function AbstractAssetTask(
  93535. /**
  93536. * Task name
  93537. */ name) {
  93538. this.name = name;
  93539. this._isCompleted = false;
  93540. this._taskState = AssetTaskState.INIT;
  93541. }
  93542. Object.defineProperty(AbstractAssetTask.prototype, "isCompleted", {
  93543. /**
  93544. * Get if the task is completed
  93545. */
  93546. get: function () {
  93547. return this._isCompleted;
  93548. },
  93549. enumerable: true,
  93550. configurable: true
  93551. });
  93552. Object.defineProperty(AbstractAssetTask.prototype, "taskState", {
  93553. /**
  93554. * Gets the current state of the task
  93555. */
  93556. get: function () {
  93557. return this._taskState;
  93558. },
  93559. enumerable: true,
  93560. configurable: true
  93561. });
  93562. Object.defineProperty(AbstractAssetTask.prototype, "errorObject", {
  93563. /**
  93564. * Gets the current error object (if task is in error)
  93565. */
  93566. get: function () {
  93567. return this._errorObject;
  93568. },
  93569. enumerable: true,
  93570. configurable: true
  93571. });
  93572. /**
  93573. * Internal only
  93574. * @hidden
  93575. */
  93576. AbstractAssetTask.prototype._setErrorObject = function (message, exception) {
  93577. if (this._errorObject) {
  93578. return;
  93579. }
  93580. this._errorObject = {
  93581. message: message,
  93582. exception: exception
  93583. };
  93584. };
  93585. /**
  93586. * Execute the current task
  93587. * @param scene defines the scene where you want your assets to be loaded
  93588. * @param onSuccess is a callback called when the task is successfully executed
  93589. * @param onError is a callback called if an error occurs
  93590. */
  93591. AbstractAssetTask.prototype.run = function (scene, onSuccess, onError) {
  93592. var _this = this;
  93593. this._taskState = AssetTaskState.RUNNING;
  93594. this.runTask(scene, function () {
  93595. _this.onDoneCallback(onSuccess, onError);
  93596. }, function (msg, exception) {
  93597. _this.onErrorCallback(onError, msg, exception);
  93598. });
  93599. };
  93600. /**
  93601. * Execute the current task
  93602. * @param scene defines the scene where you want your assets to be loaded
  93603. * @param onSuccess is a callback called when the task is successfully executed
  93604. * @param onError is a callback called if an error occurs
  93605. */
  93606. AbstractAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  93607. throw new Error("runTask is not implemented");
  93608. };
  93609. /**
  93610. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  93611. * This can be used with failed tasks that have the reason for failure fixed.
  93612. */
  93613. AbstractAssetTask.prototype.reset = function () {
  93614. this._taskState = AssetTaskState.INIT;
  93615. };
  93616. AbstractAssetTask.prototype.onErrorCallback = function (onError, message, exception) {
  93617. this._taskState = AssetTaskState.ERROR;
  93618. this._errorObject = {
  93619. message: message,
  93620. exception: exception
  93621. };
  93622. if (this.onError) {
  93623. this.onError(this, message, exception);
  93624. }
  93625. onError();
  93626. };
  93627. AbstractAssetTask.prototype.onDoneCallback = function (onSuccess, onError) {
  93628. try {
  93629. this._taskState = AssetTaskState.DONE;
  93630. this._isCompleted = true;
  93631. if (this.onSuccess) {
  93632. this.onSuccess(this);
  93633. }
  93634. onSuccess();
  93635. }
  93636. catch (e) {
  93637. this.onErrorCallback(onError, "Task is done, error executing success callback(s)", e);
  93638. }
  93639. };
  93640. return AbstractAssetTask;
  93641. }());
  93642. /**
  93643. * Class used to share progress information about assets loading
  93644. */
  93645. var AssetsProgressEvent = /** @class */ (function () {
  93646. /**
  93647. * Creates a AssetsProgressEvent
  93648. * @param remainingCount defines the number of remaining tasks to process
  93649. * @param totalCount defines the total number of tasks
  93650. * @param task defines the task that was just processed
  93651. */
  93652. function AssetsProgressEvent(remainingCount, totalCount, task) {
  93653. this.remainingCount = remainingCount;
  93654. this.totalCount = totalCount;
  93655. this.task = task;
  93656. }
  93657. return AssetsProgressEvent;
  93658. }());
  93659. /**
  93660. * Define a task used by AssetsManager to load meshes
  93661. */
  93662. var MeshAssetTask = /** @class */ (function (_super) {
  93663. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MeshAssetTask, _super);
  93664. /**
  93665. * Creates a new MeshAssetTask
  93666. * @param name defines the name of the task
  93667. * @param meshesNames defines the list of mesh's names you want to load
  93668. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  93669. * @param sceneFilename defines the filename of the scene to load from
  93670. */
  93671. function MeshAssetTask(
  93672. /**
  93673. * Defines the name of the task
  93674. */
  93675. name,
  93676. /**
  93677. * Defines the list of mesh's names you want to load
  93678. */
  93679. meshesNames,
  93680. /**
  93681. * Defines the root url to use as a base to load your meshes and associated resources
  93682. */
  93683. rootUrl,
  93684. /**
  93685. * Defines the filename of the scene to load from
  93686. */
  93687. sceneFilename) {
  93688. var _this = _super.call(this, name) || this;
  93689. _this.name = name;
  93690. _this.meshesNames = meshesNames;
  93691. _this.rootUrl = rootUrl;
  93692. _this.sceneFilename = sceneFilename;
  93693. return _this;
  93694. }
  93695. /**
  93696. * Execute the current task
  93697. * @param scene defines the scene where you want your assets to be loaded
  93698. * @param onSuccess is a callback called when the task is successfully executed
  93699. * @param onError is a callback called if an error occurs
  93700. */
  93701. MeshAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  93702. var _this = this;
  93703. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh(this.meshesNames, this.rootUrl, this.sceneFilename, scene, function (meshes, particleSystems, skeletons, animationGroups) {
  93704. _this.loadedMeshes = meshes;
  93705. _this.loadedParticleSystems = particleSystems;
  93706. _this.loadedSkeletons = skeletons;
  93707. _this.loadedAnimationGroups = animationGroups;
  93708. onSuccess();
  93709. }, null, function (scene, message, exception) {
  93710. onError(message, exception);
  93711. });
  93712. };
  93713. return MeshAssetTask;
  93714. }(AbstractAssetTask));
  93715. /**
  93716. * Define a task used by AssetsManager to load text content
  93717. */
  93718. var TextFileAssetTask = /** @class */ (function (_super) {
  93719. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextFileAssetTask, _super);
  93720. /**
  93721. * Creates a new TextFileAssetTask object
  93722. * @param name defines the name of the task
  93723. * @param url defines the location of the file to load
  93724. */
  93725. function TextFileAssetTask(
  93726. /**
  93727. * Defines the name of the task
  93728. */
  93729. name,
  93730. /**
  93731. * Defines the location of the file to load
  93732. */
  93733. url) {
  93734. var _this = _super.call(this, name) || this;
  93735. _this.name = name;
  93736. _this.url = url;
  93737. return _this;
  93738. }
  93739. /**
  93740. * Execute the current task
  93741. * @param scene defines the scene where you want your assets to be loaded
  93742. * @param onSuccess is a callback called when the task is successfully executed
  93743. * @param onError is a callback called if an error occurs
  93744. */
  93745. TextFileAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  93746. var _this = this;
  93747. scene._loadFile(this.url, function (data) {
  93748. _this.text = data;
  93749. onSuccess();
  93750. }, undefined, false, false, function (request, exception) {
  93751. if (request) {
  93752. onError(request.status + " " + request.statusText, exception);
  93753. }
  93754. });
  93755. };
  93756. return TextFileAssetTask;
  93757. }(AbstractAssetTask));
  93758. /**
  93759. * Define a task used by AssetsManager to load binary data
  93760. */
  93761. var BinaryFileAssetTask = /** @class */ (function (_super) {
  93762. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BinaryFileAssetTask, _super);
  93763. /**
  93764. * Creates a new BinaryFileAssetTask object
  93765. * @param name defines the name of the new task
  93766. * @param url defines the location of the file to load
  93767. */
  93768. function BinaryFileAssetTask(
  93769. /**
  93770. * Defines the name of the task
  93771. */
  93772. name,
  93773. /**
  93774. * Defines the location of the file to load
  93775. */
  93776. url) {
  93777. var _this = _super.call(this, name) || this;
  93778. _this.name = name;
  93779. _this.url = url;
  93780. return _this;
  93781. }
  93782. /**
  93783. * Execute the current task
  93784. * @param scene defines the scene where you want your assets to be loaded
  93785. * @param onSuccess is a callback called when the task is successfully executed
  93786. * @param onError is a callback called if an error occurs
  93787. */
  93788. BinaryFileAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  93789. var _this = this;
  93790. scene._loadFile(this.url, function (data) {
  93791. _this.data = data;
  93792. onSuccess();
  93793. }, undefined, true, true, function (request, exception) {
  93794. if (request) {
  93795. onError(request.status + " " + request.statusText, exception);
  93796. }
  93797. });
  93798. };
  93799. return BinaryFileAssetTask;
  93800. }(AbstractAssetTask));
  93801. /**
  93802. * Define a task used by AssetsManager to load images
  93803. */
  93804. var ImageAssetTask = /** @class */ (function (_super) {
  93805. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageAssetTask, _super);
  93806. /**
  93807. * Creates a new ImageAssetTask
  93808. * @param name defines the name of the task
  93809. * @param url defines the location of the image to load
  93810. */
  93811. function ImageAssetTask(
  93812. /**
  93813. * Defines the name of the task
  93814. */
  93815. name,
  93816. /**
  93817. * Defines the location of the image to load
  93818. */
  93819. url) {
  93820. var _this = _super.call(this, name) || this;
  93821. _this.name = name;
  93822. _this.url = url;
  93823. return _this;
  93824. }
  93825. /**
  93826. * Execute the current task
  93827. * @param scene defines the scene where you want your assets to be loaded
  93828. * @param onSuccess is a callback called when the task is successfully executed
  93829. * @param onError is a callback called if an error occurs
  93830. */
  93831. ImageAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  93832. var _this = this;
  93833. var img = new Image();
  93834. _tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(this.url, img);
  93835. img.onload = function () {
  93836. _this.image = img;
  93837. onSuccess();
  93838. };
  93839. img.onerror = function (err) {
  93840. onError("Error loading image", err);
  93841. };
  93842. img.src = this.url;
  93843. };
  93844. return ImageAssetTask;
  93845. }(AbstractAssetTask));
  93846. /**
  93847. * Define a task used by AssetsManager to load 2D textures
  93848. */
  93849. var TextureAssetTask = /** @class */ (function (_super) {
  93850. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextureAssetTask, _super);
  93851. /**
  93852. * Creates a new TextureAssetTask object
  93853. * @param name defines the name of the task
  93854. * @param url defines the location of the file to load
  93855. * @param noMipmap defines if mipmap should not be generated (default is false)
  93856. * @param invertY defines if texture must be inverted on Y axis (default is false)
  93857. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  93858. */
  93859. function TextureAssetTask(
  93860. /**
  93861. * Defines the name of the task
  93862. */
  93863. name,
  93864. /**
  93865. * Defines the location of the file to load
  93866. */
  93867. url,
  93868. /**
  93869. * Defines if mipmap should not be generated (default is false)
  93870. */
  93871. noMipmap,
  93872. /**
  93873. * Defines if texture must be inverted on Y axis (default is false)
  93874. */
  93875. invertY,
  93876. /**
  93877. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  93878. */
  93879. samplingMode) {
  93880. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  93881. var _this = _super.call(this, name) || this;
  93882. _this.name = name;
  93883. _this.url = url;
  93884. _this.noMipmap = noMipmap;
  93885. _this.invertY = invertY;
  93886. _this.samplingMode = samplingMode;
  93887. return _this;
  93888. }
  93889. /**
  93890. * Execute the current task
  93891. * @param scene defines the scene where you want your assets to be loaded
  93892. * @param onSuccess is a callback called when the task is successfully executed
  93893. * @param onError is a callback called if an error occurs
  93894. */
  93895. TextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  93896. var onload = function () {
  93897. onSuccess();
  93898. };
  93899. var onerror = function (message, exception) {
  93900. onError(message, exception);
  93901. };
  93902. this.texture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"](this.url, scene, this.noMipmap, this.invertY, this.samplingMode, onload, onerror);
  93903. };
  93904. return TextureAssetTask;
  93905. }(AbstractAssetTask));
  93906. /**
  93907. * Define a task used by AssetsManager to load cube textures
  93908. */
  93909. var CubeTextureAssetTask = /** @class */ (function (_super) {
  93910. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubeTextureAssetTask, _super);
  93911. /**
  93912. * Creates a new CubeTextureAssetTask
  93913. * @param name defines the name of the task
  93914. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  93915. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  93916. * @param noMipmap defines if mipmaps should not be generated (default is false)
  93917. * @param files defines the explicit list of files (undefined by default)
  93918. */
  93919. function CubeTextureAssetTask(
  93920. /**
  93921. * Defines the name of the task
  93922. */
  93923. name,
  93924. /**
  93925. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  93926. */
  93927. url,
  93928. /**
  93929. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  93930. */
  93931. extensions,
  93932. /**
  93933. * Defines if mipmaps should not be generated (default is false)
  93934. */
  93935. noMipmap,
  93936. /**
  93937. * Defines the explicit list of files (undefined by default)
  93938. */
  93939. files) {
  93940. var _this = _super.call(this, name) || this;
  93941. _this.name = name;
  93942. _this.url = url;
  93943. _this.extensions = extensions;
  93944. _this.noMipmap = noMipmap;
  93945. _this.files = files;
  93946. return _this;
  93947. }
  93948. /**
  93949. * Execute the current task
  93950. * @param scene defines the scene where you want your assets to be loaded
  93951. * @param onSuccess is a callback called when the task is successfully executed
  93952. * @param onError is a callback called if an error occurs
  93953. */
  93954. CubeTextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  93955. var onload = function () {
  93956. onSuccess();
  93957. };
  93958. var onerror = function (message, exception) {
  93959. onError(message, exception);
  93960. };
  93961. this.texture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_5__["CubeTexture"](this.url, scene, this.extensions, this.noMipmap, this.files, onload, onerror);
  93962. };
  93963. return CubeTextureAssetTask;
  93964. }(AbstractAssetTask));
  93965. /**
  93966. * Define a task used by AssetsManager to load HDR cube textures
  93967. */
  93968. var HDRCubeTextureAssetTask = /** @class */ (function (_super) {
  93969. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HDRCubeTextureAssetTask, _super);
  93970. /**
  93971. * Creates a new HDRCubeTextureAssetTask object
  93972. * @param name defines the name of the task
  93973. * @param url defines the location of the file to load
  93974. * @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.
  93975. * @param noMipmap defines if mipmaps should not be generated (default is false)
  93976. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  93977. * @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)
  93978. * @param reserved Internal use only
  93979. */
  93980. function HDRCubeTextureAssetTask(
  93981. /**
  93982. * Defines the name of the task
  93983. */
  93984. name,
  93985. /**
  93986. * Defines the location of the file to load
  93987. */
  93988. url,
  93989. /**
  93990. * Defines the desired size (the more it increases the longer the generation will be)
  93991. */
  93992. size,
  93993. /**
  93994. * Defines if mipmaps should not be generated (default is false)
  93995. */
  93996. noMipmap,
  93997. /**
  93998. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  93999. */
  94000. generateHarmonics,
  94001. /**
  94002. * 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)
  94003. */
  94004. gammaSpace,
  94005. /**
  94006. * Internal Use Only
  94007. */
  94008. reserved) {
  94009. if (noMipmap === void 0) { noMipmap = false; }
  94010. if (generateHarmonics === void 0) { generateHarmonics = true; }
  94011. if (gammaSpace === void 0) { gammaSpace = false; }
  94012. if (reserved === void 0) { reserved = false; }
  94013. var _this = _super.call(this, name) || this;
  94014. _this.name = name;
  94015. _this.url = url;
  94016. _this.size = size;
  94017. _this.noMipmap = noMipmap;
  94018. _this.generateHarmonics = generateHarmonics;
  94019. _this.gammaSpace = gammaSpace;
  94020. _this.reserved = reserved;
  94021. return _this;
  94022. }
  94023. /**
  94024. * Execute the current task
  94025. * @param scene defines the scene where you want your assets to be loaded
  94026. * @param onSuccess is a callback called when the task is successfully executed
  94027. * @param onError is a callback called if an error occurs
  94028. */
  94029. HDRCubeTextureAssetTask.prototype.run = function (scene, onSuccess, onError) {
  94030. var onload = function () {
  94031. onSuccess();
  94032. };
  94033. var onerror = function (message, exception) {
  94034. onError(message, exception);
  94035. };
  94036. 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);
  94037. };
  94038. return HDRCubeTextureAssetTask;
  94039. }(AbstractAssetTask));
  94040. /**
  94041. * This class can be used to easily import assets into a scene
  94042. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  94043. */
  94044. var AssetsManager = /** @class */ (function () {
  94045. /**
  94046. * Creates a new AssetsManager
  94047. * @param scene defines the scene to work on
  94048. */
  94049. function AssetsManager(scene) {
  94050. this._isLoading = false;
  94051. this._tasks = new Array();
  94052. this._waitingTasksCount = 0;
  94053. this._totalTasksCount = 0;
  94054. /**
  94055. * Observable called when all tasks are processed
  94056. */
  94057. this.onTaskSuccessObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  94058. /**
  94059. * Observable called when a task had an error
  94060. */
  94061. this.onTaskErrorObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  94062. /**
  94063. * Observable called when a task is successful
  94064. */
  94065. this.onTasksDoneObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  94066. /**
  94067. * Observable called when a task is done (whatever the result is)
  94068. */
  94069. this.onProgressObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  94070. /**
  94071. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  94072. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  94073. */
  94074. this.useDefaultLoadingScreen = true;
  94075. this._scene = scene;
  94076. }
  94077. /**
  94078. * Add a MeshAssetTask to the list of active tasks
  94079. * @param taskName defines the name of the new task
  94080. * @param meshesNames defines the name of meshes to load
  94081. * @param rootUrl defines the root url to use to locate files
  94082. * @param sceneFilename defines the filename of the scene file
  94083. * @returns a new MeshAssetTask object
  94084. */
  94085. AssetsManager.prototype.addMeshTask = function (taskName, meshesNames, rootUrl, sceneFilename) {
  94086. var task = new MeshAssetTask(taskName, meshesNames, rootUrl, sceneFilename);
  94087. this._tasks.push(task);
  94088. return task;
  94089. };
  94090. /**
  94091. * Add a TextFileAssetTask to the list of active tasks
  94092. * @param taskName defines the name of the new task
  94093. * @param url defines the url of the file to load
  94094. * @returns a new TextFileAssetTask object
  94095. */
  94096. AssetsManager.prototype.addTextFileTask = function (taskName, url) {
  94097. var task = new TextFileAssetTask(taskName, url);
  94098. this._tasks.push(task);
  94099. return task;
  94100. };
  94101. /**
  94102. * Add a BinaryFileAssetTask to the list of active tasks
  94103. * @param taskName defines the name of the new task
  94104. * @param url defines the url of the file to load
  94105. * @returns a new BinaryFileAssetTask object
  94106. */
  94107. AssetsManager.prototype.addBinaryFileTask = function (taskName, url) {
  94108. var task = new BinaryFileAssetTask(taskName, url);
  94109. this._tasks.push(task);
  94110. return task;
  94111. };
  94112. /**
  94113. * Add a ImageAssetTask to the list of active tasks
  94114. * @param taskName defines the name of the new task
  94115. * @param url defines the url of the file to load
  94116. * @returns a new ImageAssetTask object
  94117. */
  94118. AssetsManager.prototype.addImageTask = function (taskName, url) {
  94119. var task = new ImageAssetTask(taskName, url);
  94120. this._tasks.push(task);
  94121. return task;
  94122. };
  94123. /**
  94124. * Add a TextureAssetTask to the list of active tasks
  94125. * @param taskName defines the name of the new task
  94126. * @param url defines the url of the file to load
  94127. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  94128. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  94129. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  94130. * @returns a new TextureAssetTask object
  94131. */
  94132. AssetsManager.prototype.addTextureTask = function (taskName, url, noMipmap, invertY, samplingMode) {
  94133. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  94134. var task = new TextureAssetTask(taskName, url, noMipmap, invertY, samplingMode);
  94135. this._tasks.push(task);
  94136. return task;
  94137. };
  94138. /**
  94139. * Add a CubeTextureAssetTask to the list of active tasks
  94140. * @param taskName defines the name of the new task
  94141. * @param url defines the url of the file to load
  94142. * @param extensions defines the extension to use to load the cube map (can be null)
  94143. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  94144. * @param files defines the list of files to load (can be null)
  94145. * @returns a new CubeTextureAssetTask object
  94146. */
  94147. AssetsManager.prototype.addCubeTextureTask = function (taskName, url, extensions, noMipmap, files) {
  94148. var task = new CubeTextureAssetTask(taskName, url, extensions, noMipmap, files);
  94149. this._tasks.push(task);
  94150. return task;
  94151. };
  94152. /**
  94153. *
  94154. * Add a HDRCubeTextureAssetTask to the list of active tasks
  94155. * @param taskName defines the name of the new task
  94156. * @param url defines the url of the file to load
  94157. * @param size defines the size you want for the cubemap (can be null)
  94158. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  94159. * @param generateHarmonics defines if you want to automatically generate (true by default)
  94160. * @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)
  94161. * @param reserved Internal use only
  94162. * @returns a new HDRCubeTextureAssetTask object
  94163. */
  94164. AssetsManager.prototype.addHDRCubeTextureTask = function (taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved) {
  94165. if (noMipmap === void 0) { noMipmap = false; }
  94166. if (generateHarmonics === void 0) { generateHarmonics = true; }
  94167. if (gammaSpace === void 0) { gammaSpace = false; }
  94168. if (reserved === void 0) { reserved = false; }
  94169. var task = new HDRCubeTextureAssetTask(taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved);
  94170. this._tasks.push(task);
  94171. return task;
  94172. };
  94173. /**
  94174. * Remove a task from the assets manager.
  94175. * @param task the task to remove
  94176. */
  94177. AssetsManager.prototype.removeTask = function (task) {
  94178. var index = this._tasks.indexOf(task);
  94179. if (index > -1) {
  94180. this._tasks.splice(index, 1);
  94181. }
  94182. };
  94183. AssetsManager.prototype._decreaseWaitingTasksCount = function (task) {
  94184. this._waitingTasksCount--;
  94185. try {
  94186. if (this.onProgress) {
  94187. this.onProgress(this._waitingTasksCount, this._totalTasksCount, task);
  94188. }
  94189. this.onProgressObservable.notifyObservers(new AssetsProgressEvent(this._waitingTasksCount, this._totalTasksCount, task));
  94190. }
  94191. catch (e) {
  94192. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("Error running progress callbacks.");
  94193. console.log(e);
  94194. }
  94195. if (this._waitingTasksCount === 0) {
  94196. try {
  94197. if (this.onFinish) {
  94198. this.onFinish(this._tasks);
  94199. }
  94200. // Let's remove successfull tasks
  94201. var currentTasks = this._tasks.slice();
  94202. for (var _i = 0, currentTasks_1 = currentTasks; _i < currentTasks_1.length; _i++) {
  94203. var task = currentTasks_1[_i];
  94204. if (task.taskState === AssetTaskState.DONE) {
  94205. var index = this._tasks.indexOf(task);
  94206. if (index > -1) {
  94207. this._tasks.splice(index, 1);
  94208. }
  94209. }
  94210. }
  94211. this.onTasksDoneObservable.notifyObservers(this._tasks);
  94212. }
  94213. catch (e) {
  94214. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("Error running tasks-done callbacks.");
  94215. console.log(e);
  94216. }
  94217. this._isLoading = false;
  94218. this._scene.getEngine().hideLoadingUI();
  94219. }
  94220. };
  94221. AssetsManager.prototype._runTask = function (task) {
  94222. var _this = this;
  94223. var done = function () {
  94224. try {
  94225. if (_this.onTaskSuccess) {
  94226. _this.onTaskSuccess(task);
  94227. }
  94228. _this.onTaskSuccessObservable.notifyObservers(task);
  94229. _this._decreaseWaitingTasksCount(task);
  94230. }
  94231. catch (e) {
  94232. error("Error executing task success callbacks", e);
  94233. }
  94234. };
  94235. var error = function (message, exception) {
  94236. task._setErrorObject(message, exception);
  94237. if (_this.onTaskError) {
  94238. _this.onTaskError(task);
  94239. }
  94240. _this.onTaskErrorObservable.notifyObservers(task);
  94241. _this._decreaseWaitingTasksCount(task);
  94242. };
  94243. task.run(this._scene, done, error);
  94244. };
  94245. /**
  94246. * Reset the AssetsManager and remove all tasks
  94247. * @return the current instance of the AssetsManager
  94248. */
  94249. AssetsManager.prototype.reset = function () {
  94250. this._isLoading = false;
  94251. this._tasks = new Array();
  94252. return this;
  94253. };
  94254. /**
  94255. * Start the loading process
  94256. * @return the current instance of the AssetsManager
  94257. */
  94258. AssetsManager.prototype.load = function () {
  94259. if (this._isLoading) {
  94260. return this;
  94261. }
  94262. this._isLoading = true;
  94263. this._waitingTasksCount = this._tasks.length;
  94264. this._totalTasksCount = this._tasks.length;
  94265. if (this._waitingTasksCount === 0) {
  94266. this._isLoading = false;
  94267. if (this.onFinish) {
  94268. this.onFinish(this._tasks);
  94269. }
  94270. this.onTasksDoneObservable.notifyObservers(this._tasks);
  94271. return this;
  94272. }
  94273. if (this.useDefaultLoadingScreen) {
  94274. this._scene.getEngine().displayLoadingUI();
  94275. }
  94276. for (var index = 0; index < this._tasks.length; index++) {
  94277. var task = this._tasks[index];
  94278. if (task.taskState === AssetTaskState.INIT) {
  94279. this._runTask(task);
  94280. }
  94281. }
  94282. return this;
  94283. };
  94284. return AssetsManager;
  94285. }());
  94286. /***/ }),
  94287. /***/ "./Misc/dds.ts":
  94288. /*!*********************!*\
  94289. !*** ./Misc/dds.ts ***!
  94290. \*********************/
  94291. /*! exports provided: DDSTools */
  94292. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94293. "use strict";
  94294. __webpack_require__.r(__webpack_exports__);
  94295. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return DDSTools; });
  94296. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  94297. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  94298. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  94299. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  94300. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  94301. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  94302. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  94303. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  94304. // Based on demo done by Brandon Jones - http://media.tojicode.com/webgl-samples/dds.html
  94305. // All values and structures referenced from:
  94306. // http://msdn.microsoft.com/en-us/library/bb943991.aspx/
  94307. var DDS_MAGIC = 0x20534444;
  94308. var
  94309. //DDSD_CAPS = 0x1,
  94310. //DDSD_HEIGHT = 0x2,
  94311. //DDSD_WIDTH = 0x4,
  94312. //DDSD_PITCH = 0x8,
  94313. //DDSD_PIXELFORMAT = 0x1000,
  94314. DDSD_MIPMAPCOUNT = 0x20000;
  94315. //DDSD_LINEARSIZE = 0x80000,
  94316. //DDSD_DEPTH = 0x800000;
  94317. // var DDSCAPS_COMPLEX = 0x8,
  94318. // DDSCAPS_MIPMAP = 0x400000,
  94319. // DDSCAPS_TEXTURE = 0x1000;
  94320. var DDSCAPS2_CUBEMAP = 0x200;
  94321. // DDSCAPS2_CUBEMAP_POSITIVEX = 0x400,
  94322. // DDSCAPS2_CUBEMAP_NEGATIVEX = 0x800,
  94323. // DDSCAPS2_CUBEMAP_POSITIVEY = 0x1000,
  94324. // DDSCAPS2_CUBEMAP_NEGATIVEY = 0x2000,
  94325. // DDSCAPS2_CUBEMAP_POSITIVEZ = 0x4000,
  94326. // DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x8000,
  94327. // DDSCAPS2_VOLUME = 0x200000;
  94328. var
  94329. //DDPF_ALPHAPIXELS = 0x1,
  94330. //DDPF_ALPHA = 0x2,
  94331. DDPF_FOURCC = 0x4, DDPF_RGB = 0x40,
  94332. //DDPF_YUV = 0x200,
  94333. DDPF_LUMINANCE = 0x20000;
  94334. function FourCCToInt32(value) {
  94335. return value.charCodeAt(0) +
  94336. (value.charCodeAt(1) << 8) +
  94337. (value.charCodeAt(2) << 16) +
  94338. (value.charCodeAt(3) << 24);
  94339. }
  94340. function Int32ToFourCC(value) {
  94341. return String.fromCharCode(value & 0xff, (value >> 8) & 0xff, (value >> 16) & 0xff, (value >> 24) & 0xff);
  94342. }
  94343. var FOURCC_DXT1 = FourCCToInt32("DXT1");
  94344. var FOURCC_DXT3 = FourCCToInt32("DXT3");
  94345. var FOURCC_DXT5 = FourCCToInt32("DXT5");
  94346. var FOURCC_DX10 = FourCCToInt32("DX10");
  94347. var FOURCC_D3DFMT_R16G16B16A16F = 113;
  94348. var FOURCC_D3DFMT_R32G32B32A32F = 116;
  94349. var DXGI_FORMAT_R16G16B16A16_FLOAT = 10;
  94350. var DXGI_FORMAT_B8G8R8X8_UNORM = 88;
  94351. var headerLengthInt = 31; // The header length in 32 bit ints
  94352. // Offsets into the header array
  94353. var off_magic = 0;
  94354. var off_size = 1;
  94355. var off_flags = 2;
  94356. var off_height = 3;
  94357. var off_width = 4;
  94358. var off_mipmapCount = 7;
  94359. var off_pfFlags = 20;
  94360. var off_pfFourCC = 21;
  94361. var off_RGBbpp = 22;
  94362. var off_RMask = 23;
  94363. var off_GMask = 24;
  94364. var off_BMask = 25;
  94365. var off_AMask = 26;
  94366. // var off_caps1 = 27;
  94367. var off_caps2 = 28;
  94368. // var off_caps3 = 29;
  94369. // var off_caps4 = 30;
  94370. var off_dxgiFormat = 32;
  94371. /**
  94372. * Class used to provide DDS decompression tools
  94373. */
  94374. var DDSTools = /** @class */ (function () {
  94375. function DDSTools() {
  94376. }
  94377. /**
  94378. * Gets DDS information from an array buffer
  94379. * @param arrayBuffer defines the array buffer to read data from
  94380. * @returns the DDS information
  94381. */
  94382. DDSTools.GetDDSInfo = function (arrayBuffer) {
  94383. var header = new Int32Array(arrayBuffer, 0, headerLengthInt);
  94384. var extendedHeader = new Int32Array(arrayBuffer, 0, headerLengthInt + 4);
  94385. var mipmapCount = 1;
  94386. if (header[off_flags] & DDSD_MIPMAPCOUNT) {
  94387. mipmapCount = Math.max(1, header[off_mipmapCount]);
  94388. }
  94389. var fourCC = header[off_pfFourCC];
  94390. var dxgiFormat = (fourCC === FOURCC_DX10) ? extendedHeader[off_dxgiFormat] : 0;
  94391. var textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  94392. switch (fourCC) {
  94393. case FOURCC_D3DFMT_R16G16B16A16F:
  94394. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  94395. break;
  94396. case FOURCC_D3DFMT_R32G32B32A32F:
  94397. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  94398. break;
  94399. case FOURCC_DX10:
  94400. if (dxgiFormat === DXGI_FORMAT_R16G16B16A16_FLOAT) {
  94401. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  94402. break;
  94403. }
  94404. }
  94405. return {
  94406. width: header[off_width],
  94407. height: header[off_height],
  94408. mipmapCount: mipmapCount,
  94409. isFourCC: (header[off_pfFlags] & DDPF_FOURCC) === DDPF_FOURCC,
  94410. isRGB: (header[off_pfFlags] & DDPF_RGB) === DDPF_RGB,
  94411. isLuminance: (header[off_pfFlags] & DDPF_LUMINANCE) === DDPF_LUMINANCE,
  94412. isCube: (header[off_caps2] & DDSCAPS2_CUBEMAP) === DDSCAPS2_CUBEMAP,
  94413. isCompressed: (fourCC === FOURCC_DXT1 || fourCC === FOURCC_DXT3 || fourCC === FOURCC_DXT5),
  94414. dxgiFormat: dxgiFormat,
  94415. textureType: textureType
  94416. };
  94417. };
  94418. DDSTools._ToHalfFloat = function (value) {
  94419. if (!DDSTools._FloatView) {
  94420. DDSTools._FloatView = new Float32Array(1);
  94421. DDSTools._Int32View = new Int32Array(DDSTools._FloatView.buffer);
  94422. }
  94423. DDSTools._FloatView[0] = value;
  94424. var x = DDSTools._Int32View[0];
  94425. var bits = (x >> 16) & 0x8000; /* Get the sign */
  94426. var m = (x >> 12) & 0x07ff; /* Keep one extra bit for rounding */
  94427. var e = (x >> 23) & 0xff; /* Using int is faster here */
  94428. /* If zero, or denormal, or exponent underflows too much for a denormal
  94429. * half, return signed zero. */
  94430. if (e < 103) {
  94431. return bits;
  94432. }
  94433. /* If NaN, return NaN. If Inf or exponent overflow, return Inf. */
  94434. if (e > 142) {
  94435. bits |= 0x7c00;
  94436. /* If exponent was 0xff and one mantissa bit was set, it means NaN,
  94437. * not Inf, so make sure we set one mantissa bit too. */
  94438. bits |= ((e == 255) ? 0 : 1) && (x & 0x007fffff);
  94439. return bits;
  94440. }
  94441. /* If exponent underflows but not too much, return a denormal */
  94442. if (e < 113) {
  94443. m |= 0x0800;
  94444. /* Extra rounding may overflow and set mantissa to 0 and exponent
  94445. * to 1, which is OK. */
  94446. bits |= (m >> (114 - e)) + ((m >> (113 - e)) & 1);
  94447. return bits;
  94448. }
  94449. bits |= ((e - 112) << 10) | (m >> 1);
  94450. bits += m & 1;
  94451. return bits;
  94452. };
  94453. DDSTools._FromHalfFloat = function (value) {
  94454. var s = (value & 0x8000) >> 15;
  94455. var e = (value & 0x7C00) >> 10;
  94456. var f = value & 0x03FF;
  94457. if (e === 0) {
  94458. return (s ? -1 : 1) * Math.pow(2, -14) * (f / Math.pow(2, 10));
  94459. }
  94460. else if (e == 0x1F) {
  94461. return f ? NaN : ((s ? -1 : 1) * Infinity);
  94462. }
  94463. return (s ? -1 : 1) * Math.pow(2, e - 15) * (1 + (f / Math.pow(2, 10)));
  94464. };
  94465. DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  94466. var destArray = new Float32Array(dataLength);
  94467. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  94468. var index = 0;
  94469. for (var y = 0; y < height; y++) {
  94470. for (var x = 0; x < width; x++) {
  94471. var srcPos = (x + y * width) * 4;
  94472. destArray[index] = DDSTools._FromHalfFloat(srcData[srcPos]);
  94473. destArray[index + 1] = DDSTools._FromHalfFloat(srcData[srcPos + 1]);
  94474. destArray[index + 2] = DDSTools._FromHalfFloat(srcData[srcPos + 2]);
  94475. if (DDSTools.StoreLODInAlphaChannel) {
  94476. destArray[index + 3] = lod;
  94477. }
  94478. else {
  94479. destArray[index + 3] = DDSTools._FromHalfFloat(srcData[srcPos + 3]);
  94480. }
  94481. index += 4;
  94482. }
  94483. }
  94484. return destArray;
  94485. };
  94486. DDSTools._GetHalfFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  94487. if (DDSTools.StoreLODInAlphaChannel) {
  94488. var destArray = new Uint16Array(dataLength);
  94489. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  94490. var index = 0;
  94491. for (var y = 0; y < height; y++) {
  94492. for (var x = 0; x < width; x++) {
  94493. var srcPos = (x + y * width) * 4;
  94494. destArray[index] = srcData[srcPos];
  94495. destArray[index + 1] = srcData[srcPos + 1];
  94496. destArray[index + 2] = srcData[srcPos + 2];
  94497. destArray[index + 3] = DDSTools._ToHalfFloat(lod);
  94498. index += 4;
  94499. }
  94500. }
  94501. return destArray;
  94502. }
  94503. return new Uint16Array(arrayBuffer, dataOffset, dataLength);
  94504. };
  94505. DDSTools._GetFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  94506. if (DDSTools.StoreLODInAlphaChannel) {
  94507. var destArray = new Float32Array(dataLength);
  94508. var srcData = new Float32Array(arrayBuffer, dataOffset);
  94509. var index = 0;
  94510. for (var y = 0; y < height; y++) {
  94511. for (var x = 0; x < width; x++) {
  94512. var srcPos = (x + y * width) * 4;
  94513. destArray[index] = srcData[srcPos];
  94514. destArray[index + 1] = srcData[srcPos + 1];
  94515. destArray[index + 2] = srcData[srcPos + 2];
  94516. destArray[index + 3] = lod;
  94517. index += 4;
  94518. }
  94519. }
  94520. return destArray;
  94521. }
  94522. return new Float32Array(arrayBuffer, dataOffset, dataLength);
  94523. };
  94524. DDSTools._GetFloatAsUIntRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  94525. var destArray = new Uint8Array(dataLength);
  94526. var srcData = new Float32Array(arrayBuffer, dataOffset);
  94527. var index = 0;
  94528. for (var y = 0; y < height; y++) {
  94529. for (var x = 0; x < width; x++) {
  94530. var srcPos = (x + y * width) * 4;
  94531. destArray[index] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos]) * 255;
  94532. destArray[index + 1] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 1]) * 255;
  94533. destArray[index + 2] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 2]) * 255;
  94534. if (DDSTools.StoreLODInAlphaChannel) {
  94535. destArray[index + 3] = lod;
  94536. }
  94537. else {
  94538. destArray[index + 3] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 3]) * 255;
  94539. }
  94540. index += 4;
  94541. }
  94542. }
  94543. return destArray;
  94544. };
  94545. DDSTools._GetHalfFloatAsUIntRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  94546. var destArray = new Uint8Array(dataLength);
  94547. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  94548. var index = 0;
  94549. for (var y = 0; y < height; y++) {
  94550. for (var x = 0; x < width; x++) {
  94551. var srcPos = (x + y * width) * 4;
  94552. destArray[index] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos])) * 255;
  94553. destArray[index + 1] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 1])) * 255;
  94554. destArray[index + 2] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 2])) * 255;
  94555. if (DDSTools.StoreLODInAlphaChannel) {
  94556. destArray[index + 3] = lod;
  94557. }
  94558. else {
  94559. destArray[index + 3] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 3])) * 255;
  94560. }
  94561. index += 4;
  94562. }
  94563. }
  94564. return destArray;
  94565. };
  94566. DDSTools._GetRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset) {
  94567. var byteArray = new Uint8Array(dataLength);
  94568. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  94569. var index = 0;
  94570. for (var y = 0; y < height; y++) {
  94571. for (var x = 0; x < width; x++) {
  94572. var srcPos = (x + y * width) * 4;
  94573. byteArray[index] = srcData[srcPos + rOffset];
  94574. byteArray[index + 1] = srcData[srcPos + gOffset];
  94575. byteArray[index + 2] = srcData[srcPos + bOffset];
  94576. byteArray[index + 3] = srcData[srcPos + aOffset];
  94577. index += 4;
  94578. }
  94579. }
  94580. return byteArray;
  94581. };
  94582. DDSTools._ExtractLongWordOrder = function (value) {
  94583. if (value === 0 || value === 255 || value === -16777216) {
  94584. return 0;
  94585. }
  94586. return 1 + DDSTools._ExtractLongWordOrder(value >> 8);
  94587. };
  94588. DDSTools._GetRGBArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset) {
  94589. var byteArray = new Uint8Array(dataLength);
  94590. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  94591. var index = 0;
  94592. for (var y = 0; y < height; y++) {
  94593. for (var x = 0; x < width; x++) {
  94594. var srcPos = (x + y * width) * 3;
  94595. byteArray[index] = srcData[srcPos + rOffset];
  94596. byteArray[index + 1] = srcData[srcPos + gOffset];
  94597. byteArray[index + 2] = srcData[srcPos + bOffset];
  94598. index += 3;
  94599. }
  94600. }
  94601. return byteArray;
  94602. };
  94603. DDSTools._GetLuminanceArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer) {
  94604. var byteArray = new Uint8Array(dataLength);
  94605. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  94606. var index = 0;
  94607. for (var y = 0; y < height; y++) {
  94608. for (var x = 0; x < width; x++) {
  94609. var srcPos = (x + y * width);
  94610. byteArray[index] = srcData[srcPos];
  94611. index++;
  94612. }
  94613. }
  94614. return byteArray;
  94615. };
  94616. /**
  94617. * Uploads DDS Levels to a Babylon Texture
  94618. * @hidden
  94619. */
  94620. DDSTools.UploadDDSLevels = function (engine, texture, arrayBuffer, info, loadMipmaps, faces, lodIndex, currentFace) {
  94621. if (lodIndex === void 0) { lodIndex = -1; }
  94622. var sphericalPolynomialFaces = null;
  94623. if (info.sphericalPolynomial) {
  94624. sphericalPolynomialFaces = new Array();
  94625. }
  94626. var ext = engine.getCaps().s3tc;
  94627. var header = new Int32Array(arrayBuffer, 0, headerLengthInt);
  94628. var fourCC, width, height, dataLength = 0, dataOffset;
  94629. var byteArray, mipmapCount, mip;
  94630. var internalCompressedFormat = 0;
  94631. var blockBytes = 1;
  94632. if (header[off_magic] !== DDS_MAGIC) {
  94633. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Invalid magic number in DDS header");
  94634. return;
  94635. }
  94636. if (!info.isFourCC && !info.isRGB && !info.isLuminance) {
  94637. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");
  94638. return;
  94639. }
  94640. if (info.isCompressed && !ext) {
  94641. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Compressed textures are not supported on this platform.");
  94642. return;
  94643. }
  94644. var bpp = header[off_RGBbpp];
  94645. dataOffset = header[off_size] + 4;
  94646. var computeFormats = false;
  94647. if (info.isFourCC) {
  94648. fourCC = header[off_pfFourCC];
  94649. switch (fourCC) {
  94650. case FOURCC_DXT1:
  94651. blockBytes = 8;
  94652. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT1_EXT;
  94653. break;
  94654. case FOURCC_DXT3:
  94655. blockBytes = 16;
  94656. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT3_EXT;
  94657. break;
  94658. case FOURCC_DXT5:
  94659. blockBytes = 16;
  94660. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT5_EXT;
  94661. break;
  94662. case FOURCC_D3DFMT_R16G16B16A16F:
  94663. computeFormats = true;
  94664. break;
  94665. case FOURCC_D3DFMT_R32G32B32A32F:
  94666. computeFormats = true;
  94667. break;
  94668. case FOURCC_DX10:
  94669. // There is an additionnal header so dataOffset need to be changed
  94670. dataOffset += 5 * 4; // 5 uints
  94671. var supported = false;
  94672. switch (info.dxgiFormat) {
  94673. case DXGI_FORMAT_R16G16B16A16_FLOAT:
  94674. computeFormats = true;
  94675. supported = true;
  94676. break;
  94677. case DXGI_FORMAT_B8G8R8X8_UNORM:
  94678. info.isRGB = true;
  94679. info.isFourCC = false;
  94680. bpp = 32;
  94681. supported = true;
  94682. break;
  94683. }
  94684. if (supported) {
  94685. break;
  94686. }
  94687. default:
  94688. console.error("Unsupported FourCC code:", Int32ToFourCC(fourCC));
  94689. return;
  94690. }
  94691. }
  94692. var rOffset = DDSTools._ExtractLongWordOrder(header[off_RMask]);
  94693. var gOffset = DDSTools._ExtractLongWordOrder(header[off_GMask]);
  94694. var bOffset = DDSTools._ExtractLongWordOrder(header[off_BMask]);
  94695. var aOffset = DDSTools._ExtractLongWordOrder(header[off_AMask]);
  94696. if (computeFormats) {
  94697. internalCompressedFormat = engine._getRGBABufferInternalSizedFormat(info.textureType);
  94698. }
  94699. mipmapCount = 1;
  94700. if (header[off_flags] & DDSD_MIPMAPCOUNT && loadMipmaps !== false) {
  94701. mipmapCount = Math.max(1, header[off_mipmapCount]);
  94702. }
  94703. for (var face = 0; face < faces; face++) {
  94704. width = header[off_width];
  94705. height = header[off_height];
  94706. for (mip = 0; mip < mipmapCount; ++mip) {
  94707. if (lodIndex === -1 || lodIndex === mip) {
  94708. // In case of fixed LOD, if the lod has just been uploaded, early exit.
  94709. var i = (lodIndex === -1) ? mip : 0;
  94710. if (!info.isCompressed && info.isFourCC) {
  94711. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA;
  94712. dataLength = width * height * 4;
  94713. var floatArray = null;
  94714. if (engine._badOS || engine._badDesktopOS || (!engine.getCaps().textureHalfFloat && !engine.getCaps().textureFloat)) { // Required because iOS has many issues with float and half float generation
  94715. if (bpp === 128) {
  94716. floatArray = DDSTools._GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  94717. if (sphericalPolynomialFaces && i == 0) {
  94718. sphericalPolynomialFaces.push(DDSTools._GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  94719. }
  94720. }
  94721. else if (bpp === 64) {
  94722. floatArray = DDSTools._GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  94723. if (sphericalPolynomialFaces && i == 0) {
  94724. sphericalPolynomialFaces.push(DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  94725. }
  94726. }
  94727. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  94728. }
  94729. else {
  94730. if (bpp === 128) {
  94731. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  94732. floatArray = DDSTools._GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  94733. if (sphericalPolynomialFaces && i == 0) {
  94734. sphericalPolynomialFaces.push(floatArray);
  94735. }
  94736. }
  94737. else if (bpp === 64 && !engine.getCaps().textureHalfFloat) {
  94738. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  94739. floatArray = DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  94740. if (sphericalPolynomialFaces && i == 0) {
  94741. sphericalPolynomialFaces.push(floatArray);
  94742. }
  94743. }
  94744. else { // 64
  94745. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  94746. floatArray = DDSTools._GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  94747. if (sphericalPolynomialFaces && i == 0) {
  94748. sphericalPolynomialFaces.push(DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  94749. }
  94750. }
  94751. }
  94752. if (floatArray) {
  94753. engine._uploadDataToTextureDirectly(texture, floatArray, face, i);
  94754. }
  94755. }
  94756. else if (info.isRGB) {
  94757. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  94758. if (bpp === 24) {
  94759. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGB;
  94760. dataLength = width * height * 3;
  94761. byteArray = DDSTools._GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  94762. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  94763. }
  94764. else { // 32
  94765. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA;
  94766. dataLength = width * height * 4;
  94767. byteArray = DDSTools._GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  94768. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  94769. }
  94770. }
  94771. else if (info.isLuminance) {
  94772. var unpackAlignment = engine._getUnpackAlignement();
  94773. var unpaddedRowSize = width;
  94774. var paddedRowSize = Math.floor((width + unpackAlignment - 1) / unpackAlignment) * unpackAlignment;
  94775. dataLength = paddedRowSize * (height - 1) + unpaddedRowSize;
  94776. byteArray = DDSTools._GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  94777. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE;
  94778. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  94779. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  94780. }
  94781. else {
  94782. dataLength = Math.max(4, width) / 4 * Math.max(4, height) / 4 * blockBytes;
  94783. byteArray = new Uint8Array(arrayBuffer, dataOffset, dataLength);
  94784. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  94785. engine._uploadCompressedDataToTextureDirectly(texture, internalCompressedFormat, width, height, byteArray, face, i);
  94786. }
  94787. }
  94788. dataOffset += bpp ? (width * height * (bpp / 8)) : dataLength;
  94789. width *= 0.5;
  94790. height *= 0.5;
  94791. width = Math.max(1.0, width);
  94792. height = Math.max(1.0, height);
  94793. }
  94794. if (currentFace !== undefined) {
  94795. // Loading a single face
  94796. break;
  94797. }
  94798. }
  94799. if (sphericalPolynomialFaces && sphericalPolynomialFaces.length > 0) {
  94800. info.sphericalPolynomial = _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_6__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapToSphericalPolynomial({
  94801. size: header[off_width],
  94802. right: sphericalPolynomialFaces[0],
  94803. left: sphericalPolynomialFaces[1],
  94804. up: sphericalPolynomialFaces[2],
  94805. down: sphericalPolynomialFaces[3],
  94806. front: sphericalPolynomialFaces[4],
  94807. back: sphericalPolynomialFaces[5],
  94808. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA,
  94809. type: _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT,
  94810. gammaSpace: false,
  94811. });
  94812. }
  94813. else {
  94814. info.sphericalPolynomial = undefined;
  94815. }
  94816. };
  94817. /**
  94818. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  94819. */
  94820. DDSTools.StoreLODInAlphaChannel = false;
  94821. return DDSTools;
  94822. }());
  94823. /**
  94824. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  94825. * @param rootUrl defines the url where the file to load is located
  94826. * @param scene defines the current scene
  94827. * @param lodScale defines scale to apply to the mip map selection
  94828. * @param lodOffset defines offset to apply to the mip map selection
  94829. * @param onLoad defines an optional callback raised when the texture is loaded
  94830. * @param onError defines an optional callback raised if there is an issue to load the texture
  94831. * @param format defines the format of the data
  94832. * @param forcedExtension defines the extension to use to pick the right loader
  94833. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  94834. * @returns the cube texture as an InternalTexture
  94835. */
  94836. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].prototype.createPrefilteredCubeTexture = function (rootUrl, scene, lodScale, lodOffset, onLoad, onError, format, forcedExtension, createPolynomials) {
  94837. var _this = this;
  94838. if (onLoad === void 0) { onLoad = null; }
  94839. if (onError === void 0) { onError = null; }
  94840. if (forcedExtension === void 0) { forcedExtension = null; }
  94841. if (createPolynomials === void 0) { createPolynomials = true; }
  94842. var callback = function (loadData) {
  94843. if (!loadData) {
  94844. if (onLoad) {
  94845. onLoad(null);
  94846. }
  94847. return;
  94848. }
  94849. var texture = loadData.texture;
  94850. if (!createPolynomials) {
  94851. texture._sphericalPolynomial = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_1__["SphericalPolynomial"]();
  94852. }
  94853. else if (loadData.info.sphericalPolynomial) {
  94854. texture._sphericalPolynomial = loadData.info.sphericalPolynomial;
  94855. }
  94856. texture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_CUBEPREFILTERED;
  94857. if (_this.getCaps().textureLOD) {
  94858. // Do not add extra process if texture lod is supported.
  94859. if (onLoad) {
  94860. onLoad(texture);
  94861. }
  94862. return;
  94863. }
  94864. var mipSlices = 3;
  94865. var gl = _this._gl;
  94866. var width = loadData.width;
  94867. if (!width) {
  94868. return;
  94869. }
  94870. var textures = [];
  94871. for (var i = 0; i < mipSlices; i++) {
  94872. //compute LOD from even spacing in smoothness (matching shader calculation)
  94873. var smoothness = i / (mipSlices - 1);
  94874. var roughness = 1 - smoothness;
  94875. var minLODIndex = lodOffset; // roughness = 0
  94876. var maxLODIndex = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Log2(width) * lodScale + lodOffset; // roughness = 1
  94877. var lodIndex = minLODIndex + (maxLODIndex - minLODIndex) * roughness;
  94878. var mipmapIndex = Math.round(Math.min(Math.max(lodIndex, 0), maxLODIndex));
  94879. var glTextureFromLod = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](_this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_TEMP);
  94880. glTextureFromLod.type = texture.type;
  94881. glTextureFromLod.format = texture.format;
  94882. glTextureFromLod.width = Math.pow(2, Math.max(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Log2(width) - mipmapIndex, 0));
  94883. glTextureFromLod.height = glTextureFromLod.width;
  94884. glTextureFromLod.isCube = true;
  94885. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, glTextureFromLod, true);
  94886. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  94887. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
  94888. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  94889. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  94890. if (loadData.isDDS) {
  94891. var info = loadData.info;
  94892. var data = loadData.data;
  94893. _this._unpackFlipY(info.isCompressed);
  94894. DDSTools.UploadDDSLevels(_this, glTextureFromLod, data, info, true, 6, mipmapIndex);
  94895. }
  94896. else {
  94897. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Warn("DDS is the only prefiltered cube map supported so far.");
  94898. }
  94899. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  94900. // Wrap in a base texture for easy binding.
  94901. var lodTexture = new _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_7__["BaseTexture"](scene);
  94902. lodTexture.isCube = true;
  94903. lodTexture._texture = glTextureFromLod;
  94904. glTextureFromLod.isReady = true;
  94905. textures.push(lodTexture);
  94906. }
  94907. texture._lodTextureHigh = textures[2];
  94908. texture._lodTextureMid = textures[1];
  94909. texture._lodTextureLow = textures[0];
  94910. if (onLoad) {
  94911. onLoad(texture);
  94912. }
  94913. };
  94914. return this.createCubeTexture(rootUrl, scene, null, false, callback, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset);
  94915. };
  94916. /***/ }),
  94917. /***/ "./Misc/decorators.ts":
  94918. /*!****************************!*\
  94919. !*** ./Misc/decorators.ts ***!
  94920. \****************************/
  94921. /*! exports provided: expandToProperty, serialize, serializeAsTexture, serializeAsColor3, serializeAsFresnelParameters, serializeAsVector2, serializeAsVector3, serializeAsMeshReference, serializeAsColorCurves, serializeAsColor4, serializeAsImageProcessingConfiguration, serializeAsQuaternion, serializeAsCameraReference, SerializationHelper */
  94922. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94923. "use strict";
  94924. __webpack_require__.r(__webpack_exports__);
  94925. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return expandToProperty; });
  94926. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return serialize; });
  94927. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return serializeAsTexture; });
  94928. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return serializeAsColor3; });
  94929. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return serializeAsFresnelParameters; });
  94930. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return serializeAsVector2; });
  94931. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return serializeAsVector3; });
  94932. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return serializeAsMeshReference; });
  94933. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return serializeAsColorCurves; });
  94934. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return serializeAsColor4; });
  94935. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return serializeAsImageProcessingConfiguration; });
  94936. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return serializeAsQuaternion; });
  94937. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return serializeAsCameraReference; });
  94938. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return SerializationHelper; });
  94939. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  94940. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  94941. /* harmony import */ var _devTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./devTools */ "./Misc/devTools.ts");
  94942. var __decoratorInitialStore = {};
  94943. var __mergedStore = {};
  94944. var _copySource = function (creationFunction, source, instanciate) {
  94945. var destination = creationFunction();
  94946. // Tags
  94947. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  94948. _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].AddTagsTo(destination, source.tags);
  94949. }
  94950. var classStore = getMergedStore(destination);
  94951. // Properties
  94952. for (var property in classStore) {
  94953. var propertyDescriptor = classStore[property];
  94954. var sourceProperty = source[property];
  94955. var propertyType = propertyDescriptor.type;
  94956. if (sourceProperty !== undefined && sourceProperty !== null && property !== "uniqueId") {
  94957. switch (propertyType) {
  94958. case 0: // Value
  94959. case 6: // Mesh reference
  94960. case 11: // Camera reference
  94961. destination[property] = sourceProperty;
  94962. break;
  94963. case 1: // Texture
  94964. destination[property] = (instanciate || sourceProperty.isRenderTarget) ? sourceProperty : sourceProperty.clone();
  94965. break;
  94966. case 2: // Color3
  94967. case 3: // FresnelParameters
  94968. case 4: // Vector2
  94969. case 5: // Vector3
  94970. case 7: // Color Curves
  94971. case 10: // Quaternion
  94972. destination[property] = instanciate ? sourceProperty : sourceProperty.clone();
  94973. break;
  94974. }
  94975. }
  94976. }
  94977. return destination;
  94978. };
  94979. function getDirectStore(target) {
  94980. var classKey = target.getClassName();
  94981. if (!__decoratorInitialStore[classKey]) {
  94982. __decoratorInitialStore[classKey] = {};
  94983. }
  94984. return __decoratorInitialStore[classKey];
  94985. }
  94986. /**
  94987. * Return the list of properties flagged as serializable
  94988. * @param target: host object
  94989. */
  94990. function getMergedStore(target) {
  94991. var classKey = target.getClassName();
  94992. if (__mergedStore[classKey]) {
  94993. return __mergedStore[classKey];
  94994. }
  94995. __mergedStore[classKey] = {};
  94996. var store = __mergedStore[classKey];
  94997. var currentTarget = target;
  94998. var currentKey = classKey;
  94999. while (currentKey) {
  95000. var initialStore = __decoratorInitialStore[currentKey];
  95001. for (var property in initialStore) {
  95002. store[property] = initialStore[property];
  95003. }
  95004. var parent_1 = void 0;
  95005. var done = false;
  95006. do {
  95007. parent_1 = Object.getPrototypeOf(currentTarget);
  95008. if (!parent_1.getClassName) {
  95009. done = true;
  95010. break;
  95011. }
  95012. if (parent_1.getClassName() !== currentKey) {
  95013. break;
  95014. }
  95015. currentTarget = parent_1;
  95016. } while (parent_1);
  95017. if (done) {
  95018. break;
  95019. }
  95020. currentKey = parent_1.getClassName();
  95021. currentTarget = parent_1;
  95022. }
  95023. return store;
  95024. }
  95025. function generateSerializableMember(type, sourceName) {
  95026. return function (target, propertyKey) {
  95027. var classStore = getDirectStore(target);
  95028. if (!classStore[propertyKey]) {
  95029. classStore[propertyKey] = { type: type, sourceName: sourceName };
  95030. }
  95031. };
  95032. }
  95033. function generateExpandMember(setCallback, targetKey) {
  95034. if (targetKey === void 0) { targetKey = null; }
  95035. return function (target, propertyKey) {
  95036. var key = targetKey || ("_" + propertyKey);
  95037. Object.defineProperty(target, propertyKey, {
  95038. get: function () {
  95039. return this[key];
  95040. },
  95041. set: function (value) {
  95042. if (this[key] === value) {
  95043. return;
  95044. }
  95045. this[key] = value;
  95046. target[setCallback].apply(this);
  95047. },
  95048. enumerable: true,
  95049. configurable: true
  95050. });
  95051. };
  95052. }
  95053. function expandToProperty(callback, targetKey) {
  95054. if (targetKey === void 0) { targetKey = null; }
  95055. return generateExpandMember(callback, targetKey);
  95056. }
  95057. function serialize(sourceName) {
  95058. return generateSerializableMember(0, sourceName); // value member
  95059. }
  95060. function serializeAsTexture(sourceName) {
  95061. return generateSerializableMember(1, sourceName); // texture member
  95062. }
  95063. function serializeAsColor3(sourceName) {
  95064. return generateSerializableMember(2, sourceName); // color3 member
  95065. }
  95066. function serializeAsFresnelParameters(sourceName) {
  95067. return generateSerializableMember(3, sourceName); // fresnel parameters member
  95068. }
  95069. function serializeAsVector2(sourceName) {
  95070. return generateSerializableMember(4, sourceName); // vector2 member
  95071. }
  95072. function serializeAsVector3(sourceName) {
  95073. return generateSerializableMember(5, sourceName); // vector3 member
  95074. }
  95075. function serializeAsMeshReference(sourceName) {
  95076. return generateSerializableMember(6, sourceName); // mesh reference member
  95077. }
  95078. function serializeAsColorCurves(sourceName) {
  95079. return generateSerializableMember(7, sourceName); // color curves
  95080. }
  95081. function serializeAsColor4(sourceName) {
  95082. return generateSerializableMember(8, sourceName); // color 4
  95083. }
  95084. function serializeAsImageProcessingConfiguration(sourceName) {
  95085. return generateSerializableMember(9, sourceName); // image processing
  95086. }
  95087. function serializeAsQuaternion(sourceName) {
  95088. return generateSerializableMember(10, sourceName); // quaternion member
  95089. }
  95090. /**
  95091. * Decorator used to define property that can be serialized as reference to a camera
  95092. * @param sourceName defines the name of the property to decorate
  95093. */
  95094. function serializeAsCameraReference(sourceName) {
  95095. return generateSerializableMember(11, sourceName); // camera reference member
  95096. }
  95097. /**
  95098. * Class used to help serialization objects
  95099. */
  95100. var SerializationHelper = /** @class */ (function () {
  95101. function SerializationHelper() {
  95102. }
  95103. /**
  95104. * Appends the serialized animations from the source animations
  95105. * @param source Source containing the animations
  95106. * @param destination Target to store the animations
  95107. */
  95108. SerializationHelper.AppendSerializedAnimations = function (source, destination) {
  95109. if (source.animations) {
  95110. destination.animations = [];
  95111. for (var animationIndex = 0; animationIndex < source.animations.length; animationIndex++) {
  95112. var animation = source.animations[animationIndex];
  95113. destination.animations.push(animation.serialize());
  95114. }
  95115. }
  95116. };
  95117. /**
  95118. * Static function used to serialized a specific entity
  95119. * @param entity defines the entity to serialize
  95120. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  95121. * @returns a JSON compatible object representing the serialization of the entity
  95122. */
  95123. SerializationHelper.Serialize = function (entity, serializationObject) {
  95124. if (!serializationObject) {
  95125. serializationObject = {};
  95126. }
  95127. // Tags
  95128. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  95129. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].GetTags(entity);
  95130. }
  95131. var serializedProperties = getMergedStore(entity);
  95132. // Properties
  95133. for (var property in serializedProperties) {
  95134. var propertyDescriptor = serializedProperties[property];
  95135. var targetPropertyName = propertyDescriptor.sourceName || property;
  95136. var propertyType = propertyDescriptor.type;
  95137. var sourceProperty = entity[property];
  95138. if (sourceProperty !== undefined && sourceProperty !== null) {
  95139. switch (propertyType) {
  95140. case 0: // Value
  95141. serializationObject[targetPropertyName] = sourceProperty;
  95142. break;
  95143. case 1: // Texture
  95144. serializationObject[targetPropertyName] = sourceProperty.serialize();
  95145. break;
  95146. case 2: // Color3
  95147. serializationObject[targetPropertyName] = sourceProperty.asArray();
  95148. break;
  95149. case 3: // FresnelParameters
  95150. serializationObject[targetPropertyName] = sourceProperty.serialize();
  95151. break;
  95152. case 4: // Vector2
  95153. serializationObject[targetPropertyName] = sourceProperty.asArray();
  95154. break;
  95155. case 5: // Vector3
  95156. serializationObject[targetPropertyName] = sourceProperty.asArray();
  95157. break;
  95158. case 6: // Mesh reference
  95159. serializationObject[targetPropertyName] = sourceProperty.id;
  95160. break;
  95161. case 7: // Color Curves
  95162. serializationObject[targetPropertyName] = sourceProperty.serialize();
  95163. break;
  95164. case 8: // Color 4
  95165. serializationObject[targetPropertyName] = sourceProperty.asArray();
  95166. break;
  95167. case 9: // Image Processing
  95168. serializationObject[targetPropertyName] = sourceProperty.serialize();
  95169. break;
  95170. case 10: // Quaternion
  95171. serializationObject[targetPropertyName] = sourceProperty.asArray();
  95172. break;
  95173. case 11: // Camera reference
  95174. serializationObject[targetPropertyName] = sourceProperty.id;
  95175. break;
  95176. }
  95177. }
  95178. }
  95179. return serializationObject;
  95180. };
  95181. /**
  95182. * Creates a new entity from a serialization data object
  95183. * @param creationFunction defines a function used to instanciated the new entity
  95184. * @param source defines the source serialization data
  95185. * @param scene defines the hosting scene
  95186. * @param rootUrl defines the root url for resources
  95187. * @returns a new entity
  95188. */
  95189. SerializationHelper.Parse = function (creationFunction, source, scene, rootUrl) {
  95190. if (rootUrl === void 0) { rootUrl = null; }
  95191. var destination = creationFunction();
  95192. if (!rootUrl) {
  95193. rootUrl = "";
  95194. }
  95195. // Tags
  95196. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  95197. _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].AddTagsTo(destination, source.tags);
  95198. }
  95199. var classStore = getMergedStore(destination);
  95200. // Properties
  95201. for (var property in classStore) {
  95202. var propertyDescriptor = classStore[property];
  95203. var sourceProperty = source[propertyDescriptor.sourceName || property];
  95204. var propertyType = propertyDescriptor.type;
  95205. if (sourceProperty !== undefined && sourceProperty !== null) {
  95206. var dest = destination;
  95207. switch (propertyType) {
  95208. case 0: // Value
  95209. dest[property] = sourceProperty;
  95210. break;
  95211. case 1: // Texture
  95212. if (scene) {
  95213. dest[property] = SerializationHelper._TextureParser(sourceProperty, scene, rootUrl);
  95214. }
  95215. break;
  95216. case 2: // Color3
  95217. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(sourceProperty);
  95218. break;
  95219. case 3: // FresnelParameters
  95220. dest[property] = SerializationHelper._FresnelParametersParser(sourceProperty);
  95221. break;
  95222. case 4: // Vector2
  95223. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"].FromArray(sourceProperty);
  95224. break;
  95225. case 5: // Vector3
  95226. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(sourceProperty);
  95227. break;
  95228. case 6: // Mesh reference
  95229. if (scene) {
  95230. dest[property] = scene.getLastMeshByID(sourceProperty);
  95231. }
  95232. break;
  95233. case 7: // Color Curves
  95234. dest[property] = SerializationHelper._ColorCurvesParser(sourceProperty);
  95235. break;
  95236. case 8: // Color 4
  95237. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].FromArray(sourceProperty);
  95238. break;
  95239. case 9: // Image Processing
  95240. dest[property] = SerializationHelper._ImageProcessingConfigurationParser(sourceProperty);
  95241. break;
  95242. case 10: // Quaternion
  95243. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromArray(sourceProperty);
  95244. break;
  95245. case 11: // Camera reference
  95246. if (scene) {
  95247. dest[property] = scene.getCameraByID(sourceProperty);
  95248. }
  95249. break;
  95250. }
  95251. }
  95252. }
  95253. return destination;
  95254. };
  95255. /**
  95256. * Clones an object
  95257. * @param creationFunction defines the function used to instanciate the new object
  95258. * @param source defines the source object
  95259. * @returns the cloned object
  95260. */
  95261. SerializationHelper.Clone = function (creationFunction, source) {
  95262. return _copySource(creationFunction, source, false);
  95263. };
  95264. /**
  95265. * Instanciates a new object based on a source one (some data will be shared between both object)
  95266. * @param creationFunction defines the function used to instanciate the new object
  95267. * @param source defines the source object
  95268. * @returns the new object
  95269. */
  95270. SerializationHelper.Instanciate = function (creationFunction, source) {
  95271. return _copySource(creationFunction, source, true);
  95272. };
  95273. /** hidden */
  95274. SerializationHelper._ImageProcessingConfigurationParser = function (sourceProperty) {
  95275. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("ImageProcessingConfiguration");
  95276. };
  95277. /** hidden */
  95278. SerializationHelper._FresnelParametersParser = function (sourceProperty) {
  95279. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("FresnelParameters");
  95280. };
  95281. /** hidden */
  95282. SerializationHelper._ColorCurvesParser = function (sourceProperty) {
  95283. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("ColorCurves");
  95284. };
  95285. /** hidden */
  95286. SerializationHelper._TextureParser = function (sourceProperty, scene, rootUrl) {
  95287. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("Texture");
  95288. };
  95289. return SerializationHelper;
  95290. }());
  95291. /***/ }),
  95292. /***/ "./Misc/deepCopier.ts":
  95293. /*!****************************!*\
  95294. !*** ./Misc/deepCopier.ts ***!
  95295. \****************************/
  95296. /*! exports provided: DeepCopier */
  95297. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95298. "use strict";
  95299. __webpack_require__.r(__webpack_exports__);
  95300. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return DeepCopier; });
  95301. var cloneValue = function (source, destinationObject) {
  95302. if (!source) {
  95303. return null;
  95304. }
  95305. if (source.getClassName && source.getClassName() === "Mesh") {
  95306. return null;
  95307. }
  95308. if (source.getClassName && source.getClassName() === "SubMesh") {
  95309. return source.clone(destinationObject);
  95310. }
  95311. else if (source.clone) {
  95312. return source.clone();
  95313. }
  95314. return null;
  95315. };
  95316. /**
  95317. * Class containing a set of static utilities functions for deep copy.
  95318. */
  95319. var DeepCopier = /** @class */ (function () {
  95320. function DeepCopier() {
  95321. }
  95322. /**
  95323. * Tries to copy an object by duplicating every property
  95324. * @param source defines the source object
  95325. * @param destination defines the target object
  95326. * @param doNotCopyList defines a list of properties to avoid
  95327. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  95328. */
  95329. DeepCopier.DeepCopy = function (source, destination, doNotCopyList, mustCopyList) {
  95330. for (var prop in source) {
  95331. if (prop[0] === "_" && (!mustCopyList || mustCopyList.indexOf(prop) === -1)) {
  95332. continue;
  95333. }
  95334. if (doNotCopyList && doNotCopyList.indexOf(prop) !== -1) {
  95335. continue;
  95336. }
  95337. var sourceValue = source[prop];
  95338. var typeOfSourceValue = typeof sourceValue;
  95339. if (typeOfSourceValue === "function") {
  95340. continue;
  95341. }
  95342. try {
  95343. if (typeOfSourceValue === "object") {
  95344. if (sourceValue instanceof Array) {
  95345. destination[prop] = [];
  95346. if (sourceValue.length > 0) {
  95347. if (typeof sourceValue[0] == "object") {
  95348. for (var index = 0; index < sourceValue.length; index++) {
  95349. var clonedValue = cloneValue(sourceValue[index], destination);
  95350. if (destination[prop].indexOf(clonedValue) === -1) { // Test if auto inject was not done
  95351. destination[prop].push(clonedValue);
  95352. }
  95353. }
  95354. }
  95355. else {
  95356. destination[prop] = sourceValue.slice(0);
  95357. }
  95358. }
  95359. }
  95360. else {
  95361. destination[prop] = cloneValue(sourceValue, destination);
  95362. }
  95363. }
  95364. else {
  95365. destination[prop] = sourceValue;
  95366. }
  95367. }
  95368. catch (e) {
  95369. // Just ignore error (it could be because of a read-only property)
  95370. }
  95371. }
  95372. };
  95373. return DeepCopier;
  95374. }());
  95375. /***/ }),
  95376. /***/ "./Misc/deferred.ts":
  95377. /*!**************************!*\
  95378. !*** ./Misc/deferred.ts ***!
  95379. \**************************/
  95380. /*! exports provided: Deferred */
  95381. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95382. "use strict";
  95383. __webpack_require__.r(__webpack_exports__);
  95384. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return Deferred; });
  95385. /**
  95386. * Wrapper class for promise with external resolve and reject.
  95387. */
  95388. var Deferred = /** @class */ (function () {
  95389. /**
  95390. * Constructor for this deferred object.
  95391. */
  95392. function Deferred() {
  95393. var _this = this;
  95394. this.promise = new Promise(function (resolve, reject) {
  95395. _this._resolve = resolve;
  95396. _this._reject = reject;
  95397. });
  95398. }
  95399. Object.defineProperty(Deferred.prototype, "resolve", {
  95400. /**
  95401. * The resolve method of the promise associated with this deferred object.
  95402. */
  95403. get: function () {
  95404. return this._resolve;
  95405. },
  95406. enumerable: true,
  95407. configurable: true
  95408. });
  95409. Object.defineProperty(Deferred.prototype, "reject", {
  95410. /**
  95411. * The reject method of the promise associated with this deferred object.
  95412. */
  95413. get: function () {
  95414. return this._reject;
  95415. },
  95416. enumerable: true,
  95417. configurable: true
  95418. });
  95419. return Deferred;
  95420. }());
  95421. /***/ }),
  95422. /***/ "./Misc/devTools.ts":
  95423. /*!**************************!*\
  95424. !*** ./Misc/devTools.ts ***!
  95425. \**************************/
  95426. /*! exports provided: _DevTools */
  95427. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95428. "use strict";
  95429. __webpack_require__.r(__webpack_exports__);
  95430. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DevTools", function() { return _DevTools; });
  95431. /** @hidden */
  95432. var _DevTools = /** @class */ (function () {
  95433. function _DevTools() {
  95434. }
  95435. _DevTools.WarnImport = function (name) {
  95436. return name + " needs to be imported before as it contains a side-effect required by your code.";
  95437. };
  95438. return _DevTools;
  95439. }());
  95440. /***/ }),
  95441. /***/ "./Misc/domManagement.ts":
  95442. /*!*******************************!*\
  95443. !*** ./Misc/domManagement.ts ***!
  95444. \*******************************/
  95445. /*! exports provided: DomManagement */
  95446. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95447. "use strict";
  95448. __webpack_require__.r(__webpack_exports__);
  95449. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DomManagement", function() { return DomManagement; });
  95450. /**
  95451. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  95452. * Babylon.js
  95453. */
  95454. var DomManagement = /** @class */ (function () {
  95455. function DomManagement() {
  95456. }
  95457. /**
  95458. * Checks if the window object exists
  95459. * @returns true if the window object exists
  95460. */
  95461. DomManagement.IsWindowObjectExist = function () {
  95462. return (typeof window) !== "undefined";
  95463. };
  95464. /**
  95465. * Extracts text content from a DOM element hierarchy
  95466. * @param element defines the root element
  95467. * @returns a string
  95468. */
  95469. DomManagement.GetDOMTextContent = function (element) {
  95470. var result = "";
  95471. var child = element.firstChild;
  95472. while (child) {
  95473. if (child.nodeType === 3) {
  95474. result += child.textContent;
  95475. }
  95476. child = (child.nextSibling);
  95477. }
  95478. return result;
  95479. };
  95480. return DomManagement;
  95481. }());
  95482. /***/ }),
  95483. /***/ "./Misc/environmentTextureTools.ts":
  95484. /*!*****************************************!*\
  95485. !*** ./Misc/environmentTextureTools.ts ***!
  95486. \*****************************************/
  95487. /*! exports provided: EnvironmentTextureTools */
  95488. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95489. "use strict";
  95490. __webpack_require__.r(__webpack_exports__);
  95491. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return EnvironmentTextureTools; });
  95492. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  95493. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  95494. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  95495. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  95496. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  95497. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  95498. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  95499. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  95500. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  95501. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  95502. /* harmony import */ var _Shaders_rgbdEncode_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/rgbdEncode.fragment */ "./Shaders/rgbdEncode.fragment.ts");
  95503. /* harmony import */ var _Shaders_rgbdDecode_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/rgbdDecode.fragment */ "./Shaders/rgbdDecode.fragment.ts");
  95504. /**
  95505. * Sets of helpers addressing the serialization and deserialization of environment texture
  95506. * stored in a BabylonJS env file.
  95507. * Those files are usually stored as .env files.
  95508. */
  95509. var EnvironmentTextureTools = /** @class */ (function () {
  95510. function EnvironmentTextureTools() {
  95511. }
  95512. /**
  95513. * Gets the environment info from an env file.
  95514. * @param data The array buffer containing the .env bytes.
  95515. * @returns the environment file info (the json header) if successfully parsed.
  95516. */
  95517. EnvironmentTextureTools.GetEnvInfo = function (data) {
  95518. var dataView = new DataView(data);
  95519. var pos = 0;
  95520. for (var i = 0; i < EnvironmentTextureTools._MagicBytes.length; i++) {
  95521. if (dataView.getUint8(pos++) !== EnvironmentTextureTools._MagicBytes[i]) {
  95522. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Error('Not a babylon environment map');
  95523. return null;
  95524. }
  95525. }
  95526. // Read json manifest - collect characters up to null terminator
  95527. var manifestString = '';
  95528. var charCode = 0x00;
  95529. while ((charCode = dataView.getUint8(pos++))) {
  95530. manifestString += String.fromCharCode(charCode);
  95531. }
  95532. var manifest = JSON.parse(manifestString);
  95533. if (manifest.specular) {
  95534. // Extend the header with the position of the payload.
  95535. manifest.specular.specularDataPosition = pos;
  95536. // Fallback to 0.8 exactly if lodGenerationScale is not defined for backward compatibility.
  95537. manifest.specular.lodGenerationScale = manifest.specular.lodGenerationScale || 0.8;
  95538. }
  95539. return manifest;
  95540. };
  95541. /**
  95542. * Creates an environment texture from a loaded cube texture.
  95543. * @param texture defines the cube texture to convert in env file
  95544. * @return a promise containing the environment data if succesfull.
  95545. */
  95546. EnvironmentTextureTools.CreateEnvTextureAsync = function (texture) {
  95547. var _this = this;
  95548. var internalTexture = texture.getInternalTexture();
  95549. if (!internalTexture) {
  95550. return Promise.reject("The cube texture is invalid.");
  95551. }
  95552. if (!texture._prefiltered) {
  95553. return Promise.reject("The cube texture is invalid (not prefiltered).");
  95554. }
  95555. var engine = internalTexture.getEngine();
  95556. if (engine && engine.premultipliedAlpha) {
  95557. return Promise.reject("Env texture can only be created when the engine is created with the premultipliedAlpha option set to false.");
  95558. }
  95559. if (texture.textureType === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  95560. return Promise.reject("The cube texture should allow HDR (Full Float or Half Float).");
  95561. }
  95562. var canvas = engine.getRenderingCanvas();
  95563. if (!canvas) {
  95564. return Promise.reject("Env texture can only be created when the engine is associated to a canvas.");
  95565. }
  95566. var textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT;
  95567. if (!engine.getCaps().textureFloatRender) {
  95568. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT;
  95569. if (!engine.getCaps().textureHalfFloatRender) {
  95570. return Promise.reject("Env texture can only be created when the browser supports half float or full float rendering.");
  95571. }
  95572. }
  95573. var cubeWidth = internalTexture.width;
  95574. var hostingScene = new _scene__WEBPACK_IMPORTED_MODULE_7__["Scene"](engine);
  95575. var specularTextures = {};
  95576. var promises = [];
  95577. // Read and collect all mipmaps data from the cube.
  95578. var mipmapsCount = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(internalTexture.width);
  95579. mipmapsCount = Math.round(mipmapsCount);
  95580. var _loop_1 = function (i) {
  95581. var faceWidth = Math.pow(2, mipmapsCount - i);
  95582. var _loop_2 = function (face) {
  95583. var data = texture.readPixels(face, i);
  95584. // Creates a temp texture with the face data.
  95585. 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);
  95586. // And rgbdEncode them.
  95587. var promise = new Promise(function (resolve, reject) {
  95588. 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);
  95589. rgbdPostProcess.getEffect().executeWhenCompiled(function () {
  95590. rgbdPostProcess.onApply = function (effect) {
  95591. effect._bindTexture("textureSampler", tempTexture);
  95592. };
  95593. // As the process needs to happen on the main canvas, keep track of the current size
  95594. var currentW = engine.getRenderWidth();
  95595. var currentH = engine.getRenderHeight();
  95596. // Set the desired size for the texture
  95597. engine.setSize(faceWidth, faceWidth);
  95598. hostingScene.postProcessManager.directRender([rgbdPostProcess], null);
  95599. // Reading datas from WebGL
  95600. _tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].ToBlob(canvas, function (blob) {
  95601. var fileReader = new FileReader();
  95602. fileReader.onload = function (event) {
  95603. var arrayBuffer = event.target.result;
  95604. specularTextures[i * 6 + face] = arrayBuffer;
  95605. resolve();
  95606. };
  95607. fileReader.readAsArrayBuffer(blob);
  95608. });
  95609. // Reapply the previous canvas size
  95610. engine.setSize(currentW, currentH);
  95611. });
  95612. });
  95613. promises.push(promise);
  95614. };
  95615. // All faces of the cube.
  95616. for (var face = 0; face < 6; face++) {
  95617. _loop_2(face);
  95618. }
  95619. };
  95620. for (var i = 0; i <= mipmapsCount; i++) {
  95621. _loop_1(i);
  95622. }
  95623. // Once all the textures haves been collected as RGBD stored in PNGs
  95624. return Promise.all(promises).then(function () {
  95625. // We can delete the hosting scene keeping track of all the creation objects
  95626. hostingScene.dispose();
  95627. // Creates the json header for the env texture
  95628. var info = {
  95629. version: 1,
  95630. width: cubeWidth,
  95631. irradiance: _this._CreateEnvTextureIrradiance(texture),
  95632. specular: {
  95633. mipmaps: [],
  95634. lodGenerationScale: texture.lodGenerationScale
  95635. }
  95636. };
  95637. // Sets the specular image data information
  95638. var position = 0;
  95639. for (var i = 0; i <= mipmapsCount; i++) {
  95640. for (var face = 0; face < 6; face++) {
  95641. var byteLength = specularTextures[i * 6 + face].byteLength;
  95642. info.specular.mipmaps.push({
  95643. length: byteLength,
  95644. position: position
  95645. });
  95646. position += byteLength;
  95647. }
  95648. }
  95649. // Encode the JSON as an array buffer
  95650. var infoString = JSON.stringify(info);
  95651. var infoBuffer = new ArrayBuffer(infoString.length + 1);
  95652. var infoView = new Uint8Array(infoBuffer); // Limited to ascii subset matching unicode.
  95653. for (var i = 0, strLen = infoString.length; i < strLen; i++) {
  95654. infoView[i] = infoString.charCodeAt(i);
  95655. }
  95656. // Ends up with a null terminator for easier parsing
  95657. infoView[infoString.length] = 0x00;
  95658. // Computes the final required size and creates the storage
  95659. var totalSize = EnvironmentTextureTools._MagicBytes.length + position + infoBuffer.byteLength;
  95660. var finalBuffer = new ArrayBuffer(totalSize);
  95661. var finalBufferView = new Uint8Array(finalBuffer);
  95662. var dataView = new DataView(finalBuffer);
  95663. // Copy the magic bytes identifying the file in
  95664. var pos = 0;
  95665. for (var i = 0; i < EnvironmentTextureTools._MagicBytes.length; i++) {
  95666. dataView.setUint8(pos++, EnvironmentTextureTools._MagicBytes[i]);
  95667. }
  95668. // Add the json info
  95669. finalBufferView.set(new Uint8Array(infoBuffer), pos);
  95670. pos += infoBuffer.byteLength;
  95671. // Finally inserts the texture data
  95672. for (var i = 0; i <= mipmapsCount; i++) {
  95673. for (var face = 0; face < 6; face++) {
  95674. var dataBuffer = specularTextures[i * 6 + face];
  95675. finalBufferView.set(new Uint8Array(dataBuffer), pos);
  95676. pos += dataBuffer.byteLength;
  95677. }
  95678. }
  95679. // Voila
  95680. return finalBuffer;
  95681. });
  95682. };
  95683. /**
  95684. * Creates a JSON representation of the spherical data.
  95685. * @param texture defines the texture containing the polynomials
  95686. * @return the JSON representation of the spherical info
  95687. */
  95688. EnvironmentTextureTools._CreateEnvTextureIrradiance = function (texture) {
  95689. var polynmials = texture.sphericalPolynomial;
  95690. if (polynmials == null) {
  95691. return null;
  95692. }
  95693. return {
  95694. x: [polynmials.x.x, polynmials.x.y, polynmials.x.z],
  95695. y: [polynmials.y.x, polynmials.y.y, polynmials.y.z],
  95696. z: [polynmials.z.x, polynmials.z.y, polynmials.z.z],
  95697. xx: [polynmials.xx.x, polynmials.xx.y, polynmials.xx.z],
  95698. yy: [polynmials.yy.x, polynmials.yy.y, polynmials.yy.z],
  95699. zz: [polynmials.zz.x, polynmials.zz.y, polynmials.zz.z],
  95700. yz: [polynmials.yz.x, polynmials.yz.y, polynmials.yz.z],
  95701. zx: [polynmials.zx.x, polynmials.zx.y, polynmials.zx.z],
  95702. xy: [polynmials.xy.x, polynmials.xy.y, polynmials.xy.z]
  95703. };
  95704. };
  95705. /**
  95706. * Uploads the texture info contained in the env file to the GPU.
  95707. * @param texture defines the internal texture to upload to
  95708. * @param arrayBuffer defines the buffer cotaining the data to load
  95709. * @param info defines the texture info retrieved through the GetEnvInfo method
  95710. * @returns a promise
  95711. */
  95712. EnvironmentTextureTools.UploadEnvLevelsAsync = function (texture, arrayBuffer, info) {
  95713. if (info.version !== 1) {
  95714. throw new Error("Unsupported babylon environment map version \"" + info.version + "\"");
  95715. }
  95716. var specularInfo = info.specular;
  95717. if (!specularInfo) {
  95718. // Nothing else parsed so far
  95719. return Promise.resolve();
  95720. }
  95721. // Double checks the enclosed info
  95722. var mipmapsCount = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(info.width);
  95723. mipmapsCount = Math.round(mipmapsCount) + 1;
  95724. if (specularInfo.mipmaps.length !== 6 * mipmapsCount) {
  95725. throw new Error("Unsupported specular mipmaps number \"" + specularInfo.mipmaps.length + "\"");
  95726. }
  95727. texture._lodGenerationScale = specularInfo.lodGenerationScale;
  95728. var imageData = new Array(mipmapsCount);
  95729. for (var i = 0; i < mipmapsCount; i++) {
  95730. imageData[i] = new Array(6);
  95731. for (var face = 0; face < 6; face++) {
  95732. var imageInfo = specularInfo.mipmaps[i * 6 + face];
  95733. imageData[i][face] = new Uint8Array(arrayBuffer, specularInfo.specularDataPosition + imageInfo.position, imageInfo.length);
  95734. }
  95735. }
  95736. return EnvironmentTextureTools.UploadLevelsAsync(texture, imageData);
  95737. };
  95738. /**
  95739. * Uploads the levels of image data to the GPU.
  95740. * @param texture defines the internal texture to upload to
  95741. * @param imageData defines the array buffer views of image data [mipmap][face]
  95742. * @returns a promise
  95743. */
  95744. EnvironmentTextureTools.UploadLevelsAsync = function (texture, imageData) {
  95745. if (!_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].IsExponentOfTwo(texture.width)) {
  95746. throw new Error("Texture size must be a power of two");
  95747. }
  95748. var mipmapsCount = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(texture.width)) + 1;
  95749. // Gets everything ready.
  95750. var engine = texture.getEngine();
  95751. var expandTexture = false;
  95752. var generateNonLODTextures = false;
  95753. var rgbdPostProcess = null;
  95754. var cubeRtt = null;
  95755. var lodTextures = null;
  95756. var caps = engine.getCaps();
  95757. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA;
  95758. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  95759. texture.generateMipMaps = true;
  95760. engine.updateTextureSamplingMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE, texture);
  95761. // Add extra process if texture lod is not supported
  95762. if (!caps.textureLOD) {
  95763. expandTexture = false;
  95764. generateNonLODTextures = true;
  95765. lodTextures = {};
  95766. }
  95767. // in webgl 1 there are no ways to either render or copy lod level information for float textures.
  95768. else if (engine.webGLVersion < 2) {
  95769. expandTexture = false;
  95770. }
  95771. // If half float available we can uncompress the texture
  95772. else if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  95773. expandTexture = true;
  95774. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT;
  95775. }
  95776. // If full float available we can uncompress the texture
  95777. else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  95778. expandTexture = true;
  95779. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT;
  95780. }
  95781. // Expand the texture if possible
  95782. if (expandTexture) {
  95783. // Simply run through the decode PP
  95784. 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);
  95785. texture._isRGBD = false;
  95786. texture.invertY = false;
  95787. cubeRtt = engine.createRenderTargetCubeTexture(texture.width, {
  95788. generateDepthBuffer: false,
  95789. generateMipMaps: true,
  95790. generateStencilBuffer: false,
  95791. samplingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE,
  95792. type: texture.type,
  95793. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA
  95794. });
  95795. }
  95796. else {
  95797. texture._isRGBD = true;
  95798. texture.invertY = true;
  95799. // In case of missing support, applies the same patch than DDS files.
  95800. if (generateNonLODTextures) {
  95801. var mipSlices = 3;
  95802. var scale = texture._lodGenerationScale;
  95803. var offset = texture._lodGenerationOffset;
  95804. for (var i = 0; i < mipSlices; i++) {
  95805. //compute LOD from even spacing in smoothness (matching shader calculation)
  95806. var smoothness = i / (mipSlices - 1);
  95807. var roughness = 1 - smoothness;
  95808. var minLODIndex = offset; // roughness = 0
  95809. var maxLODIndex = (mipmapsCount - 1) * scale + offset; // roughness = 1 (mipmaps start from 0)
  95810. var lodIndex = minLODIndex + (maxLODIndex - minLODIndex) * roughness;
  95811. var mipmapIndex = Math.round(Math.min(Math.max(lodIndex, 0), maxLODIndex));
  95812. var glTextureFromLod = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](engine, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_TEMP);
  95813. glTextureFromLod.isCube = true;
  95814. glTextureFromLod.invertY = true;
  95815. glTextureFromLod.generateMipMaps = false;
  95816. engine.updateTextureSamplingMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_LINEAR, glTextureFromLod);
  95817. // Wrap in a base texture for easy binding.
  95818. var lodTexture = new _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"](null);
  95819. lodTexture.isCube = true;
  95820. lodTexture._texture = glTextureFromLod;
  95821. lodTextures[mipmapIndex] = lodTexture;
  95822. switch (i) {
  95823. case 0:
  95824. texture._lodTextureLow = lodTexture;
  95825. break;
  95826. case 1:
  95827. texture._lodTextureMid = lodTexture;
  95828. break;
  95829. case 2:
  95830. texture._lodTextureHigh = lodTexture;
  95831. break;
  95832. }
  95833. }
  95834. }
  95835. }
  95836. var promises = [];
  95837. var _loop_3 = function (i) {
  95838. var _loop_4 = function (face) {
  95839. // Constructs an image element from image data
  95840. var bytes = imageData[i][face];
  95841. var blob = new Blob([bytes], { type: 'image/png' });
  95842. var url = URL.createObjectURL(blob);
  95843. var image = new Image();
  95844. image.src = url;
  95845. // Enqueue promise to upload to the texture.
  95846. var promise = new Promise(function (resolve, reject) {
  95847. image.onload = function () {
  95848. if (expandTexture) {
  95849. var tempTexture_1 = engine.createTexture(null, true, true, null, _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE, null, function (message) {
  95850. reject(message);
  95851. }, image);
  95852. rgbdPostProcess.getEffect().executeWhenCompiled(function () {
  95853. // Uncompress the data to a RTT
  95854. rgbdPostProcess.onApply = function (effect) {
  95855. effect._bindTexture("textureSampler", tempTexture_1);
  95856. effect.setFloat2("scale", 1, 1);
  95857. };
  95858. engine.scenes[0].postProcessManager.directRender([rgbdPostProcess], cubeRtt, true, face, i);
  95859. // Cleanup
  95860. engine.restoreDefaultFramebuffer();
  95861. tempTexture_1.dispose();
  95862. window.URL.revokeObjectURL(url);
  95863. resolve();
  95864. });
  95865. }
  95866. else {
  95867. engine._uploadImageToTexture(texture, image, face, i);
  95868. // Upload the face to the non lod texture support
  95869. if (generateNonLODTextures) {
  95870. var lodTexture = lodTextures[i];
  95871. if (lodTexture) {
  95872. engine._uploadImageToTexture(lodTexture._texture, image, face, 0);
  95873. }
  95874. }
  95875. resolve();
  95876. }
  95877. };
  95878. image.onerror = function (error) {
  95879. reject(error);
  95880. };
  95881. });
  95882. promises.push(promise);
  95883. };
  95884. // All faces
  95885. for (var face = 0; face < 6; face++) {
  95886. _loop_4(face);
  95887. }
  95888. };
  95889. // All mipmaps up to provided number of images
  95890. for (var i = 0; i < imageData.length; i++) {
  95891. _loop_3(i);
  95892. }
  95893. // Fill remaining mipmaps with black textures.
  95894. if (imageData.length < mipmapsCount) {
  95895. var data = void 0;
  95896. var size = Math.pow(2, mipmapsCount - 1 - imageData.length);
  95897. var dataLength = size * size * 4;
  95898. switch (texture.type) {
  95899. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT: {
  95900. data = new Uint8Array(dataLength);
  95901. break;
  95902. }
  95903. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT: {
  95904. data = new Uint16Array(dataLength);
  95905. break;
  95906. }
  95907. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT: {
  95908. data = new Float32Array(dataLength);
  95909. break;
  95910. }
  95911. }
  95912. for (var i = imageData.length; i < mipmapsCount; i++) {
  95913. for (var face = 0; face < 6; face++) {
  95914. engine._uploadArrayBufferViewToTexture(texture, data, face, i);
  95915. }
  95916. }
  95917. }
  95918. // Once all done, finishes the cleanup and return
  95919. return Promise.all(promises).then(function () {
  95920. // Release temp RTT.
  95921. if (cubeRtt) {
  95922. engine._releaseFramebufferObjects(cubeRtt);
  95923. cubeRtt._swapAndDie(texture);
  95924. }
  95925. // Release temp Post Process.
  95926. if (rgbdPostProcess) {
  95927. rgbdPostProcess.dispose();
  95928. }
  95929. // Flag internal texture as ready in case they are in use.
  95930. if (generateNonLODTextures) {
  95931. if (texture._lodTextureHigh && texture._lodTextureHigh._texture) {
  95932. texture._lodTextureHigh._texture.isReady = true;
  95933. }
  95934. if (texture._lodTextureMid && texture._lodTextureMid._texture) {
  95935. texture._lodTextureMid._texture.isReady = true;
  95936. }
  95937. if (texture._lodTextureLow && texture._lodTextureLow._texture) {
  95938. texture._lodTextureLow._texture.isReady = true;
  95939. }
  95940. }
  95941. });
  95942. };
  95943. /**
  95944. * Uploads spherical polynomials information to the texture.
  95945. * @param texture defines the texture we are trying to upload the information to
  95946. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  95947. */
  95948. EnvironmentTextureTools.UploadEnvSpherical = function (texture, info) {
  95949. if (info.version !== 1) {
  95950. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Warn('Unsupported babylon environment map version "' + info.version + '"');
  95951. }
  95952. var irradianceInfo = info.irradiance;
  95953. if (!irradianceInfo) {
  95954. return;
  95955. }
  95956. var sp = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_3__["SphericalPolynomial"]();
  95957. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.x, 0, sp.x);
  95958. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.y, 0, sp.y);
  95959. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.z, 0, sp.z);
  95960. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.xx, 0, sp.xx);
  95961. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.yy, 0, sp.yy);
  95962. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.zz, 0, sp.zz);
  95963. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.yz, 0, sp.yz);
  95964. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.zx, 0, sp.zx);
  95965. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.xy, 0, sp.xy);
  95966. texture._sphericalPolynomial = sp;
  95967. };
  95968. /** @hidden */
  95969. EnvironmentTextureTools._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  95970. internalTexture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_CUBERAW_RGBD;
  95971. internalTexture._bufferViewArrayArray = data;
  95972. internalTexture._lodGenerationScale = lodScale;
  95973. internalTexture._lodGenerationOffset = lodOffset;
  95974. internalTexture._sphericalPolynomial = sphericalPolynomial;
  95975. return EnvironmentTextureTools.UploadLevelsAsync(internalTexture, data).then(function () {
  95976. internalTexture.isReady = true;
  95977. });
  95978. };
  95979. /**
  95980. * Magic number identifying the env file.
  95981. */
  95982. EnvironmentTextureTools._MagicBytes = [0x86, 0x16, 0x87, 0x96, 0xf6, 0xd6, 0x96, 0x36];
  95983. return EnvironmentTextureTools;
  95984. }());
  95985. // References the dependencies.
  95986. _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"]._UpdateRGBDAsync = EnvironmentTextureTools._UpdateRGBDAsync;
  95987. /***/ }),
  95988. /***/ "./Misc/filesInput.ts":
  95989. /*!****************************!*\
  95990. !*** ./Misc/filesInput.ts ***!
  95991. \****************************/
  95992. /*! exports provided: FilesInput */
  95993. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95994. "use strict";
  95995. __webpack_require__.r(__webpack_exports__);
  95996. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return FilesInput; });
  95997. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  95998. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  95999. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  96000. /**
  96001. * Class used to help managing file picking and drag'n'drop
  96002. */
  96003. var FilesInput = /** @class */ (function () {
  96004. /**
  96005. * Creates a new FilesInput
  96006. * @param engine defines the rendering engine
  96007. * @param scene defines the hosting scene
  96008. * @param sceneLoadedCallback callback called when scene is loaded
  96009. * @param progressCallback callback called to track progress
  96010. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  96011. * @param textureLoadingCallback callback called when a texture is loading
  96012. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  96013. * @param onReloadCallback callback called when a reload is requested
  96014. * @param errorCallback callback call if an error occurs
  96015. */
  96016. function FilesInput(engine, scene, sceneLoadedCallback, progressCallback, additionalRenderLoopLogicCallback, textureLoadingCallback, startingProcessingFilesCallback, onReloadCallback, errorCallback) {
  96017. /**
  96018. * Callback called when a file is processed
  96019. */
  96020. this.onProcessFileCallback = function () { return true; };
  96021. this._engine = engine;
  96022. this._currentScene = scene;
  96023. this._sceneLoadedCallback = sceneLoadedCallback;
  96024. this._progressCallback = progressCallback;
  96025. this._additionalRenderLoopLogicCallback = additionalRenderLoopLogicCallback;
  96026. this._textureLoadingCallback = textureLoadingCallback;
  96027. this._startingProcessingFilesCallback = startingProcessingFilesCallback;
  96028. this._onReloadCallback = onReloadCallback;
  96029. this._errorCallback = errorCallback;
  96030. }
  96031. Object.defineProperty(FilesInput, "FilesToLoad", {
  96032. /**
  96033. * List of files ready to be loaded
  96034. */
  96035. get: function () {
  96036. return _filesInputStore__WEBPACK_IMPORTED_MODULE_2__["FilesInputStore"].FilesToLoad;
  96037. },
  96038. enumerable: true,
  96039. configurable: true
  96040. });
  96041. /**
  96042. * Calls this function to listen to drag'n'drop events on a specific DOM element
  96043. * @param elementToMonitor defines the DOM element to track
  96044. */
  96045. FilesInput.prototype.monitorElementForDragNDrop = function (elementToMonitor) {
  96046. var _this = this;
  96047. if (elementToMonitor) {
  96048. this._elementToMonitor = elementToMonitor;
  96049. this._dragEnterHandler = function (e) { _this.drag(e); };
  96050. this._dragOverHandler = function (e) { _this.drag(e); };
  96051. this._dropHandler = function (e) { _this.drop(e); };
  96052. this._elementToMonitor.addEventListener("dragenter", this._dragEnterHandler, false);
  96053. this._elementToMonitor.addEventListener("dragover", this._dragOverHandler, false);
  96054. this._elementToMonitor.addEventListener("drop", this._dropHandler, false);
  96055. }
  96056. };
  96057. /**
  96058. * Release all associated resources
  96059. */
  96060. FilesInput.prototype.dispose = function () {
  96061. if (!this._elementToMonitor) {
  96062. return;
  96063. }
  96064. this._elementToMonitor.removeEventListener("dragenter", this._dragEnterHandler);
  96065. this._elementToMonitor.removeEventListener("dragover", this._dragOverHandler);
  96066. this._elementToMonitor.removeEventListener("drop", this._dropHandler);
  96067. };
  96068. FilesInput.prototype.renderFunction = function () {
  96069. if (this._additionalRenderLoopLogicCallback) {
  96070. this._additionalRenderLoopLogicCallback();
  96071. }
  96072. if (this._currentScene) {
  96073. if (this._textureLoadingCallback) {
  96074. var remaining = this._currentScene.getWaitingItemsCount();
  96075. if (remaining > 0) {
  96076. this._textureLoadingCallback(remaining);
  96077. }
  96078. }
  96079. this._currentScene.render();
  96080. }
  96081. };
  96082. FilesInput.prototype.drag = function (e) {
  96083. e.stopPropagation();
  96084. e.preventDefault();
  96085. };
  96086. FilesInput.prototype.drop = function (eventDrop) {
  96087. eventDrop.stopPropagation();
  96088. eventDrop.preventDefault();
  96089. this.loadFiles(eventDrop);
  96090. };
  96091. FilesInput.prototype._traverseFolder = function (folder, files, remaining, callback) {
  96092. var _this = this;
  96093. var reader = folder.createReader();
  96094. var relativePath = folder.fullPath.replace(/^\//, "").replace(/(.+?)\/?$/, "$1/");
  96095. reader.readEntries(function (entries) {
  96096. remaining.count += entries.length;
  96097. for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
  96098. var entry = entries_1[_i];
  96099. if (entry.isFile) {
  96100. entry.file(function (file) {
  96101. file.correctName = relativePath + file.name;
  96102. files.push(file);
  96103. if (--remaining.count === 0) {
  96104. callback();
  96105. }
  96106. });
  96107. }
  96108. else if (entry.isDirectory) {
  96109. _this._traverseFolder(entry, files, remaining, callback);
  96110. }
  96111. }
  96112. if (--remaining.count) {
  96113. callback();
  96114. }
  96115. });
  96116. };
  96117. FilesInput.prototype._processFiles = function (files) {
  96118. for (var i = 0; i < files.length; i++) {
  96119. var name = files[i].correctName.toLowerCase();
  96120. var extension = name.split('.').pop();
  96121. if (!this.onProcessFileCallback(files[i], name, extension)) {
  96122. continue;
  96123. }
  96124. if ((extension === "babylon" || extension === "stl" || extension === "obj" || extension === "gltf" || extension === "glb")
  96125. && name.indexOf(".binary.babylon") === -1 && name.indexOf(".incremental.babylon") === -1) {
  96126. this._sceneFileToLoad = files[i];
  96127. }
  96128. FilesInput.FilesToLoad[name] = files[i];
  96129. }
  96130. };
  96131. /**
  96132. * Load files from a drop event
  96133. * @param event defines the drop event to use as source
  96134. */
  96135. FilesInput.prototype.loadFiles = function (event) {
  96136. var _this = this;
  96137. // Handling data transfer via drag'n'drop
  96138. if (event && event.dataTransfer && event.dataTransfer.files) {
  96139. this._filesToLoad = event.dataTransfer.files;
  96140. }
  96141. // Handling files from input files
  96142. if (event && event.target && event.target.files) {
  96143. this._filesToLoad = event.target.files;
  96144. }
  96145. if (!this._filesToLoad || this._filesToLoad.length === 0) {
  96146. return;
  96147. }
  96148. if (this._startingProcessingFilesCallback) {
  96149. this._startingProcessingFilesCallback(this._filesToLoad);
  96150. }
  96151. if (this._filesToLoad && this._filesToLoad.length > 0) {
  96152. var files_1 = new Array();
  96153. var folders = [];
  96154. var items = event.dataTransfer ? event.dataTransfer.items : null;
  96155. for (var i = 0; i < this._filesToLoad.length; i++) {
  96156. var fileToLoad = this._filesToLoad[i];
  96157. var name_1 = fileToLoad.name.toLowerCase();
  96158. var entry = void 0;
  96159. fileToLoad.correctName = name_1;
  96160. if (items) {
  96161. var item = items[i];
  96162. if (item.getAsEntry) {
  96163. entry = item.getAsEntry();
  96164. }
  96165. else if (item.webkitGetAsEntry) {
  96166. entry = item.webkitGetAsEntry();
  96167. }
  96168. }
  96169. if (!entry) {
  96170. files_1.push(fileToLoad);
  96171. }
  96172. else {
  96173. if (entry.isDirectory) {
  96174. folders.push(entry);
  96175. }
  96176. else {
  96177. files_1.push(fileToLoad);
  96178. }
  96179. }
  96180. }
  96181. if (folders.length === 0) {
  96182. this._processFiles(files_1);
  96183. this._processReload();
  96184. }
  96185. else {
  96186. var remaining = { count: folders.length };
  96187. for (var _i = 0, folders_1 = folders; _i < folders_1.length; _i++) {
  96188. var folder = folders_1[_i];
  96189. this._traverseFolder(folder, files_1, remaining, function () {
  96190. _this._processFiles(files_1);
  96191. if (remaining.count === 0) {
  96192. _this._processReload();
  96193. }
  96194. });
  96195. }
  96196. }
  96197. }
  96198. };
  96199. FilesInput.prototype._processReload = function () {
  96200. if (this._onReloadCallback) {
  96201. this._onReloadCallback(this._sceneFileToLoad);
  96202. }
  96203. else {
  96204. this.reload();
  96205. }
  96206. };
  96207. /**
  96208. * Reload the current scene from the loaded files
  96209. */
  96210. FilesInput.prototype.reload = function () {
  96211. var _this = this;
  96212. // If a scene file has been provided
  96213. if (this._sceneFileToLoad) {
  96214. if (this._currentScene) {
  96215. if (_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].errorsCount > 0) {
  96216. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].ClearLogCache();
  96217. }
  96218. this._engine.stopRenderLoop();
  96219. }
  96220. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"].LoadAsync("file:", this._sceneFileToLoad, this._engine, function (progress) {
  96221. if (_this._progressCallback) {
  96222. _this._progressCallback(progress);
  96223. }
  96224. }).then(function (scene) {
  96225. if (_this._currentScene) {
  96226. _this._currentScene.dispose();
  96227. }
  96228. _this._currentScene = scene;
  96229. if (_this._sceneLoadedCallback) {
  96230. _this._sceneLoadedCallback(_this._sceneFileToLoad, _this._currentScene);
  96231. }
  96232. // Wait for textures and shaders to be ready
  96233. _this._currentScene.executeWhenReady(function () {
  96234. _this._engine.runRenderLoop(function () {
  96235. _this.renderFunction();
  96236. });
  96237. });
  96238. }).catch(function (error) {
  96239. if (_this._errorCallback) {
  96240. _this._errorCallback(_this._sceneFileToLoad, _this._currentScene, error.message);
  96241. }
  96242. });
  96243. }
  96244. else {
  96245. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Please provide a valid .babylon file.");
  96246. }
  96247. };
  96248. return FilesInput;
  96249. }());
  96250. /***/ }),
  96251. /***/ "./Misc/filesInputStore.ts":
  96252. /*!*********************************!*\
  96253. !*** ./Misc/filesInputStore.ts ***!
  96254. \*********************************/
  96255. /*! exports provided: FilesInputStore */
  96256. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96257. "use strict";
  96258. __webpack_require__.r(__webpack_exports__);
  96259. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return FilesInputStore; });
  96260. /**
  96261. * Class used to help managing file picking and drag'n'drop
  96262. * File Storage
  96263. */
  96264. var FilesInputStore = /** @class */ (function () {
  96265. function FilesInputStore() {
  96266. }
  96267. /**
  96268. * List of files ready to be loaded
  96269. */
  96270. FilesInputStore.FilesToLoad = {};
  96271. return FilesInputStore;
  96272. }());
  96273. /***/ }),
  96274. /***/ "./Misc/index.ts":
  96275. /*!***********************!*\
  96276. !*** ./Misc/index.ts ***!
  96277. \***********************/
  96278. /*! 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 */
  96279. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96280. "use strict";
  96281. __webpack_require__.r(__webpack_exports__);
  96282. /* harmony import */ var _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./andOrNotEvaluator */ "./Misc/andOrNotEvaluator.ts");
  96283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_0__["AndOrNotEvaluator"]; });
  96284. /* harmony import */ var _assetsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./assetsManager */ "./Misc/assetsManager.ts");
  96285. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetTaskState"]; });
  96286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AbstractAssetTask"]; });
  96287. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetsProgressEvent"]; });
  96288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["MeshAssetTask"]; });
  96289. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["TextFileAssetTask"]; });
  96290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["BinaryFileAssetTask"]; });
  96291. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["ImageAssetTask"]; });
  96292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["TextureAssetTask"]; });
  96293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["CubeTextureAssetTask"]; });
  96294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["HDRCubeTextureAssetTask"]; });
  96295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetsManager"]; });
  96296. /* harmony import */ var _dds__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./dds */ "./Misc/dds.ts");
  96297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"]; });
  96298. /* harmony import */ var _decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./decorators */ "./Misc/decorators.ts");
  96299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["expandToProperty"]; });
  96300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serialize"]; });
  96301. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsTexture"]; });
  96302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColor3"]; });
  96303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsFresnelParameters"]; });
  96304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsVector2"]; });
  96305. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsVector3"]; });
  96306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsMeshReference"]; });
  96307. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColorCurves"]; });
  96308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColor4"]; });
  96309. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsImageProcessingConfiguration"]; });
  96310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsQuaternion"]; });
  96311. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsCameraReference"]; });
  96312. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"]; });
  96313. /* harmony import */ var _deferred__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./deferred */ "./Misc/deferred.ts");
  96314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _deferred__WEBPACK_IMPORTED_MODULE_4__["Deferred"]; });
  96315. /* harmony import */ var _environmentTextureTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  96316. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _environmentTextureTools__WEBPACK_IMPORTED_MODULE_5__["EnvironmentTextureTools"]; });
  96317. /* harmony import */ var _filesInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./filesInput */ "./Misc/filesInput.ts");
  96318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _filesInput__WEBPACK_IMPORTED_MODULE_6__["FilesInput"]; });
  96319. /* harmony import */ var _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./HighDynamicRange/index */ "./Misc/HighDynamicRange/index.ts");
  96320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_7__["CubeMapToSphericalPolynomialTools"]; });
  96321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_7__["HDRTools"]; });
  96322. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_7__["PanoramaToCubeMapTools"]; });
  96323. /* harmony import */ var _khronosTextureContainer__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./khronosTextureContainer */ "./Misc/khronosTextureContainer.ts");
  96324. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _khronosTextureContainer__WEBPACK_IMPORTED_MODULE_8__["KhronosTextureContainer"]; });
  96325. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  96326. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _observable__WEBPACK_IMPORTED_MODULE_9__["EventState"]; });
  96327. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _observable__WEBPACK_IMPORTED_MODULE_9__["Observer"]; });
  96328. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _observable__WEBPACK_IMPORTED_MODULE_9__["MultiObserver"]; });
  96329. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _observable__WEBPACK_IMPORTED_MODULE_9__["Observable"]; });
  96330. /* harmony import */ var _performanceMonitor__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./performanceMonitor */ "./Misc/performanceMonitor.ts");
  96331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _performanceMonitor__WEBPACK_IMPORTED_MODULE_10__["PerformanceMonitor"]; });
  96332. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _performanceMonitor__WEBPACK_IMPORTED_MODULE_10__["RollingAverage"]; });
  96333. /* harmony import */ var _promise__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./promise */ "./Misc/promise.ts");
  96334. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _promise__WEBPACK_IMPORTED_MODULE_11__["PromisePolyfill"]; });
  96335. /* harmony import */ var _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./sceneOptimizer */ "./Misc/sceneOptimizer.ts");
  96336. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["SceneOptimization"]; });
  96337. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["TextureOptimization"]; });
  96338. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["HardwareScalingOptimization"]; });
  96339. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["ShadowsOptimization"]; });
  96340. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["PostProcessesOptimization"]; });
  96341. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["LensFlaresOptimization"]; });
  96342. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["CustomOptimization"]; });
  96343. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["ParticlesOptimization"]; });
  96344. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["RenderTargetsOptimization"]; });
  96345. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["MergeMeshesOptimization"]; });
  96346. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["SceneOptimizerOptions"]; });
  96347. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["SceneOptimizer"]; });
  96348. /* harmony import */ var _sceneSerializer__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./sceneSerializer */ "./Misc/sceneSerializer.ts");
  96349. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _sceneSerializer__WEBPACK_IMPORTED_MODULE_13__["SceneSerializer"]; });
  96350. /* harmony import */ var _smartArray__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./smartArray */ "./Misc/smartArray.ts");
  96351. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _smartArray__WEBPACK_IMPORTED_MODULE_14__["SmartArray"]; });
  96352. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _smartArray__WEBPACK_IMPORTED_MODULE_14__["SmartArrayNoDuplicate"]; });
  96353. /* harmony import */ var _stringDictionary__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./stringDictionary */ "./Misc/stringDictionary.ts");
  96354. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _stringDictionary__WEBPACK_IMPORTED_MODULE_15__["StringDictionary"]; });
  96355. /* harmony import */ var _tags__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./tags */ "./Misc/tags.ts");
  96356. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _tags__WEBPACK_IMPORTED_MODULE_16__["Tags"]; });
  96357. /* harmony import */ var _textureTools__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./textureTools */ "./Misc/textureTools.ts");
  96358. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _textureTools__WEBPACK_IMPORTED_MODULE_17__["TextureTools"]; });
  96359. /* harmony import */ var _tga__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./tga */ "./Misc/tga.ts");
  96360. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _tga__WEBPACK_IMPORTED_MODULE_18__["TGATools"]; });
  96361. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  96362. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["ColorGradient"]; });
  96363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["Color3Gradient"]; });
  96364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["FactorGradient"]; });
  96365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["LoadFileError"]; });
  96366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["RetryStrategy"]; });
  96367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["Tools"]; });
  96368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["PerfCounter"]; });
  96369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["className"]; });
  96370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["AsyncLoop"]; });
  96371. /* harmony import */ var _videoRecorder__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./videoRecorder */ "./Misc/videoRecorder.ts");
  96372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _videoRecorder__WEBPACK_IMPORTED_MODULE_20__["VideoRecorder"]; });
  96373. /* harmony import */ var _virtualJoystick__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./virtualJoystick */ "./Misc/virtualJoystick.ts");
  96374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _virtualJoystick__WEBPACK_IMPORTED_MODULE_21__["JoystickAxis"]; });
  96375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _virtualJoystick__WEBPACK_IMPORTED_MODULE_21__["VirtualJoystick"]; });
  96376. /* harmony import */ var _workerPool__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./workerPool */ "./Misc/workerPool.ts");
  96377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _workerPool__WEBPACK_IMPORTED_MODULE_22__["WorkerPool"]; });
  96378. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  96379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _logger__WEBPACK_IMPORTED_MODULE_23__["Logger"]; });
  96380. /* harmony import */ var _typeStore__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./typeStore */ "./Misc/typeStore.ts");
  96381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _typeStore__WEBPACK_IMPORTED_MODULE_24__["_TypeStore"]; });
  96382. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  96383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _filesInputStore__WEBPACK_IMPORTED_MODULE_25__["FilesInputStore"]; });
  96384. /* harmony import */ var _deepCopier__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./deepCopier */ "./Misc/deepCopier.ts");
  96385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _deepCopier__WEBPACK_IMPORTED_MODULE_26__["DeepCopier"]; });
  96386. /* harmony import */ var _pivotTools__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./pivotTools */ "./Misc/pivotTools.ts");
  96387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _pivotTools__WEBPACK_IMPORTED_MODULE_27__["PivotTools"]; });
  96388. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  96389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _precisionDate__WEBPACK_IMPORTED_MODULE_28__["PrecisionDate"]; });
  96390. /* harmony import */ var _screenshotTools__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./screenshotTools */ "./Misc/screenshotTools.ts");
  96391. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _screenshotTools__WEBPACK_IMPORTED_MODULE_29__["ScreenshotTools"]; });
  96392. /* empty/unused harmony star reexport */
  96393. /***/ }),
  96394. /***/ "./Misc/khronosTextureContainer.ts":
  96395. /*!*****************************************!*\
  96396. !*** ./Misc/khronosTextureContainer.ts ***!
  96397. \*****************************************/
  96398. /*! exports provided: KhronosTextureContainer */
  96399. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96400. "use strict";
  96401. __webpack_require__.r(__webpack_exports__);
  96402. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return KhronosTextureContainer; });
  96403. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  96404. /**
  96405. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  96406. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  96407. */
  96408. var KhronosTextureContainer = /** @class */ (function () {
  96409. /**
  96410. * Creates a new KhronosTextureContainer
  96411. * @param arrayBuffer contents of the KTX container file
  96412. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  96413. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  96414. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  96415. */
  96416. function KhronosTextureContainer(
  96417. /** contents of the KTX container file */
  96418. arrayBuffer, facesExpected, threeDExpected, textureArrayExpected) {
  96419. this.arrayBuffer = arrayBuffer;
  96420. /**
  96421. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  96422. */
  96423. this.isInvalid = false;
  96424. // Test that it is a ktx formatted file, based on the first 12 bytes, character representation is:
  96425. // '�', 'K', 'T', 'X', ' ', '1', '1', '�', '\r', '\n', '\x1A', '\n'
  96426. // 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A
  96427. var identifier = new Uint8Array(this.arrayBuffer, 0, 12);
  96428. if (identifier[0] !== 0xAB || identifier[1] !== 0x4B || identifier[2] !== 0x54 || identifier[3] !== 0x58 || identifier[4] !== 0x20 || identifier[5] !== 0x31 ||
  96429. identifier[6] !== 0x31 || identifier[7] !== 0xBB || identifier[8] !== 0x0D || identifier[9] !== 0x0A || identifier[10] !== 0x1A || identifier[11] !== 0x0A) {
  96430. this.isInvalid = true;
  96431. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("texture missing KTX identifier");
  96432. return;
  96433. }
  96434. // load the reset of the header in native 32 bit uint
  96435. var dataSize = Uint32Array.BYTES_PER_ELEMENT;
  96436. var headerDataView = new DataView(this.arrayBuffer, 12, 13 * dataSize);
  96437. var endianness = headerDataView.getUint32(0, true);
  96438. var littleEndian = endianness === 0x04030201;
  96439. this.glType = headerDataView.getUint32(1 * dataSize, littleEndian); // must be 0 for compressed textures
  96440. this.glTypeSize = headerDataView.getUint32(2 * dataSize, littleEndian); // must be 1 for compressed textures
  96441. this.glFormat = headerDataView.getUint32(3 * dataSize, littleEndian); // must be 0 for compressed textures
  96442. this.glInternalFormat = headerDataView.getUint32(4 * dataSize, littleEndian); // the value of arg passed to gl.compressedTexImage2D(,,x,,,,)
  96443. this.glBaseInternalFormat = headerDataView.getUint32(5 * dataSize, littleEndian); // specify GL_RGB, GL_RGBA, GL_ALPHA, etc (un-compressed only)
  96444. this.pixelWidth = headerDataView.getUint32(6 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,x,,,)
  96445. this.pixelHeight = headerDataView.getUint32(7 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,,x,,)
  96446. this.pixelDepth = headerDataView.getUint32(8 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage3D(,,,,,x,,)
  96447. this.numberOfArrayElements = headerDataView.getUint32(9 * dataSize, littleEndian); // used for texture arrays
  96448. this.numberOfFaces = headerDataView.getUint32(10 * dataSize, littleEndian); // used for cubemap textures, should either be 1 or 6
  96449. this.numberOfMipmapLevels = headerDataView.getUint32(11 * dataSize, littleEndian); // number of levels; disregard possibility of 0 for compressed textures
  96450. this.bytesOfKeyValueData = headerDataView.getUint32(12 * dataSize, littleEndian); // the amount of space after the header for meta-data
  96451. // Make sure we have a compressed type. Not only reduces work, but probably better to let dev know they are not compressing.
  96452. if (this.glType !== 0) {
  96453. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("only compressed formats currently supported");
  96454. return;
  96455. }
  96456. else {
  96457. // value of zero is an indication to generate mipmaps @ runtime. Not usually allowed for compressed, so disregard.
  96458. this.numberOfMipmapLevels = Math.max(1, this.numberOfMipmapLevels);
  96459. }
  96460. if (this.pixelHeight === 0 || this.pixelDepth !== 0) {
  96461. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("only 2D textures currently supported");
  96462. return;
  96463. }
  96464. if (this.numberOfArrayElements !== 0) {
  96465. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("texture arrays not currently supported");
  96466. return;
  96467. }
  96468. if (this.numberOfFaces !== facesExpected) {
  96469. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("number of faces expected" + facesExpected + ", but found " + this.numberOfFaces);
  96470. return;
  96471. }
  96472. // we now have a completely validated file, so could use existence of loadType as success
  96473. // would need to make this more elaborate & adjust checks above to support more than one load type
  96474. this.loadType = KhronosTextureContainer.COMPRESSED_2D;
  96475. }
  96476. /**
  96477. * Uploads KTX content to a Babylon Texture.
  96478. * It is assumed that the texture has already been created & is currently bound
  96479. * @hidden
  96480. */
  96481. KhronosTextureContainer.prototype.uploadLevels = function (texture, loadMipmaps) {
  96482. switch (this.loadType) {
  96483. case KhronosTextureContainer.COMPRESSED_2D:
  96484. this._upload2DCompressedLevels(texture, loadMipmaps);
  96485. break;
  96486. case KhronosTextureContainer.TEX_2D:
  96487. case KhronosTextureContainer.COMPRESSED_3D:
  96488. case KhronosTextureContainer.TEX_3D:
  96489. }
  96490. };
  96491. KhronosTextureContainer.prototype._upload2DCompressedLevels = function (texture, loadMipmaps) {
  96492. // initialize width & height for level 1
  96493. var dataOffset = KhronosTextureContainer.HEADER_LEN + this.bytesOfKeyValueData;
  96494. var width = this.pixelWidth;
  96495. var height = this.pixelHeight;
  96496. var mipmapCount = loadMipmaps ? this.numberOfMipmapLevels : 1;
  96497. for (var level = 0; level < mipmapCount; level++) {
  96498. var imageSize = new Int32Array(this.arrayBuffer, dataOffset, 1)[0]; // size per face, since not supporting array cubemaps
  96499. dataOffset += 4; //image data starts from next multiple of 4 offset. Each face refers to same imagesize field above.
  96500. for (var face = 0; face < this.numberOfFaces; face++) {
  96501. var byteArray = new Uint8Array(this.arrayBuffer, dataOffset, imageSize);
  96502. var engine = texture.getEngine();
  96503. engine._uploadCompressedDataToTextureDirectly(texture, this.glInternalFormat, width, height, byteArray, face, level);
  96504. dataOffset += imageSize; // add size of the image for the next face/mipmap
  96505. dataOffset += 3 - ((imageSize + 3) % 4); // add padding for odd sized image
  96506. }
  96507. width = Math.max(1.0, width * 0.5);
  96508. height = Math.max(1.0, height * 0.5);
  96509. }
  96510. };
  96511. KhronosTextureContainer.HEADER_LEN = 12 + (13 * 4); // identifier + header elements (not including key value meta-data pairs)
  96512. // load types
  96513. KhronosTextureContainer.COMPRESSED_2D = 0; // uses a gl.compressedTexImage2D()
  96514. KhronosTextureContainer.COMPRESSED_3D = 1; // uses a gl.compressedTexImage3D()
  96515. KhronosTextureContainer.TEX_2D = 2; // uses a gl.texImage2D()
  96516. KhronosTextureContainer.TEX_3D = 3; // uses a gl.texImage3D()
  96517. return KhronosTextureContainer;
  96518. }());
  96519. /***/ }),
  96520. /***/ "./Misc/logger.ts":
  96521. /*!************************!*\
  96522. !*** ./Misc/logger.ts ***!
  96523. \************************/
  96524. /*! exports provided: Logger */
  96525. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96526. "use strict";
  96527. __webpack_require__.r(__webpack_exports__);
  96528. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return Logger; });
  96529. /**
  96530. * Logger used througouht the application to allow configuration of
  96531. * the log level required for the messages.
  96532. */
  96533. var Logger = /** @class */ (function () {
  96534. function Logger() {
  96535. }
  96536. Logger._AddLogEntry = function (entry) {
  96537. Logger._LogCache = entry + Logger._LogCache;
  96538. if (Logger.OnNewCacheEntry) {
  96539. Logger.OnNewCacheEntry(entry);
  96540. }
  96541. };
  96542. Logger._FormatMessage = function (message) {
  96543. var padStr = function (i) { return (i < 10) ? "0" + i : "" + i; };
  96544. var date = new Date();
  96545. return "[" + padStr(date.getHours()) + ":" + padStr(date.getMinutes()) + ":" + padStr(date.getSeconds()) + "]: " + message;
  96546. };
  96547. Logger._LogDisabled = function (message) {
  96548. // nothing to do
  96549. };
  96550. Logger._LogEnabled = function (message) {
  96551. var formattedMessage = Logger._FormatMessage(message);
  96552. console.log("BJS - " + formattedMessage);
  96553. var entry = "<div style='color:white'>" + formattedMessage + "</div><br>";
  96554. Logger._AddLogEntry(entry);
  96555. };
  96556. Logger._WarnDisabled = function (message) {
  96557. // nothing to do
  96558. };
  96559. Logger._WarnEnabled = function (message) {
  96560. var formattedMessage = Logger._FormatMessage(message);
  96561. console.warn("BJS - " + formattedMessage);
  96562. var entry = "<div style='color:orange'>" + formattedMessage + "</div><br>";
  96563. Logger._AddLogEntry(entry);
  96564. };
  96565. Logger._ErrorDisabled = function (message) {
  96566. // nothing to do
  96567. };
  96568. Logger._ErrorEnabled = function (message) {
  96569. Logger.errorsCount++;
  96570. var formattedMessage = Logger._FormatMessage(message);
  96571. console.error("BJS - " + formattedMessage);
  96572. var entry = "<div style='color:red'>" + formattedMessage + "</div><br>";
  96573. Logger._AddLogEntry(entry);
  96574. };
  96575. Object.defineProperty(Logger, "LogCache", {
  96576. /**
  96577. * Gets current log cache (list of logs)
  96578. */
  96579. get: function () {
  96580. return Logger._LogCache;
  96581. },
  96582. enumerable: true,
  96583. configurable: true
  96584. });
  96585. /**
  96586. * Clears the log cache
  96587. */
  96588. Logger.ClearLogCache = function () {
  96589. Logger._LogCache = "";
  96590. Logger.errorsCount = 0;
  96591. };
  96592. Object.defineProperty(Logger, "LogLevels", {
  96593. /**
  96594. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  96595. */
  96596. set: function (level) {
  96597. if ((level & Logger.MessageLogLevel) === Logger.MessageLogLevel) {
  96598. Logger.Log = Logger._LogEnabled;
  96599. }
  96600. else {
  96601. Logger.Log = Logger._LogDisabled;
  96602. }
  96603. if ((level & Logger.WarningLogLevel) === Logger.WarningLogLevel) {
  96604. Logger.Warn = Logger._WarnEnabled;
  96605. }
  96606. else {
  96607. Logger.Warn = Logger._WarnDisabled;
  96608. }
  96609. if ((level & Logger.ErrorLogLevel) === Logger.ErrorLogLevel) {
  96610. Logger.Error = Logger._ErrorEnabled;
  96611. }
  96612. else {
  96613. Logger.Error = Logger._ErrorDisabled;
  96614. }
  96615. },
  96616. enumerable: true,
  96617. configurable: true
  96618. });
  96619. /**
  96620. * No log
  96621. */
  96622. Logger.NoneLogLevel = 0;
  96623. /**
  96624. * Only message logs
  96625. */
  96626. Logger.MessageLogLevel = 1;
  96627. /**
  96628. * Only warning logs
  96629. */
  96630. Logger.WarningLogLevel = 2;
  96631. /**
  96632. * Only error logs
  96633. */
  96634. Logger.ErrorLogLevel = 4;
  96635. /**
  96636. * All logs
  96637. */
  96638. Logger.AllLogLevel = 7;
  96639. Logger._LogCache = "";
  96640. /**
  96641. * Gets a value indicating the number of loading errors
  96642. * @ignorenaming
  96643. */
  96644. Logger.errorsCount = 0;
  96645. /**
  96646. * Log a message to the console
  96647. */
  96648. Logger.Log = Logger._LogEnabled;
  96649. /**
  96650. * Write a warning message to the console
  96651. */
  96652. Logger.Warn = Logger._WarnEnabled;
  96653. /**
  96654. * Write an error message to the console
  96655. */
  96656. Logger.Error = Logger._ErrorEnabled;
  96657. return Logger;
  96658. }());
  96659. /***/ }),
  96660. /***/ "./Misc/observable.ts":
  96661. /*!****************************!*\
  96662. !*** ./Misc/observable.ts ***!
  96663. \****************************/
  96664. /*! exports provided: EventState, Observer, MultiObserver, Observable */
  96665. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96666. "use strict";
  96667. __webpack_require__.r(__webpack_exports__);
  96668. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return EventState; });
  96669. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return Observer; });
  96670. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return MultiObserver; });
  96671. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return Observable; });
  96672. /**
  96673. * A class serves as a medium between the observable and its observers
  96674. */
  96675. var EventState = /** @class */ (function () {
  96676. /**
  96677. * Create a new EventState
  96678. * @param mask defines the mask associated with this state
  96679. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  96680. * @param target defines the original target of the state
  96681. * @param currentTarget defines the current target of the state
  96682. */
  96683. function EventState(mask, skipNextObservers, target, currentTarget) {
  96684. if (skipNextObservers === void 0) { skipNextObservers = false; }
  96685. this.initalize(mask, skipNextObservers, target, currentTarget);
  96686. }
  96687. /**
  96688. * Initialize the current event state
  96689. * @param mask defines the mask associated with this state
  96690. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  96691. * @param target defines the original target of the state
  96692. * @param currentTarget defines the current target of the state
  96693. * @returns the current event state
  96694. */
  96695. EventState.prototype.initalize = function (mask, skipNextObservers, target, currentTarget) {
  96696. if (skipNextObservers === void 0) { skipNextObservers = false; }
  96697. this.mask = mask;
  96698. this.skipNextObservers = skipNextObservers;
  96699. this.target = target;
  96700. this.currentTarget = currentTarget;
  96701. return this;
  96702. };
  96703. return EventState;
  96704. }());
  96705. /**
  96706. * Represent an Observer registered to a given Observable object.
  96707. */
  96708. var Observer = /** @class */ (function () {
  96709. /**
  96710. * Creates a new observer
  96711. * @param callback defines the callback to call when the observer is notified
  96712. * @param mask defines the mask of the observer (used to filter notifications)
  96713. * @param scope defines the current scope used to restore the JS context
  96714. */
  96715. function Observer(
  96716. /**
  96717. * Defines the callback to call when the observer is notified
  96718. */
  96719. callback,
  96720. /**
  96721. * Defines the mask of the observer (used to filter notifications)
  96722. */
  96723. mask,
  96724. /**
  96725. * Defines the current scope used to restore the JS context
  96726. */
  96727. scope) {
  96728. if (scope === void 0) { scope = null; }
  96729. this.callback = callback;
  96730. this.mask = mask;
  96731. this.scope = scope;
  96732. /** @hidden */
  96733. this._willBeUnregistered = false;
  96734. /**
  96735. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  96736. */
  96737. this.unregisterOnNextCall = false;
  96738. }
  96739. return Observer;
  96740. }());
  96741. /**
  96742. * Represent a list of observers registered to multiple Observables object.
  96743. */
  96744. var MultiObserver = /** @class */ (function () {
  96745. function MultiObserver() {
  96746. }
  96747. /**
  96748. * Release associated resources
  96749. */
  96750. MultiObserver.prototype.dispose = function () {
  96751. if (this._observers && this._observables) {
  96752. for (var index = 0; index < this._observers.length; index++) {
  96753. this._observables[index].remove(this._observers[index]);
  96754. }
  96755. }
  96756. this._observers = null;
  96757. this._observables = null;
  96758. };
  96759. /**
  96760. * Raise a callback when one of the observable will notify
  96761. * @param observables defines a list of observables to watch
  96762. * @param callback defines the callback to call on notification
  96763. * @param mask defines the mask used to filter notifications
  96764. * @param scope defines the current scope used to restore the JS context
  96765. * @returns the new MultiObserver
  96766. */
  96767. MultiObserver.Watch = function (observables, callback, mask, scope) {
  96768. if (mask === void 0) { mask = -1; }
  96769. if (scope === void 0) { scope = null; }
  96770. var result = new MultiObserver();
  96771. result._observers = new Array();
  96772. result._observables = observables;
  96773. for (var _i = 0, observables_1 = observables; _i < observables_1.length; _i++) {
  96774. var observable = observables_1[_i];
  96775. var observer = observable.add(callback, mask, false, scope);
  96776. if (observer) {
  96777. result._observers.push(observer);
  96778. }
  96779. }
  96780. return result;
  96781. };
  96782. return MultiObserver;
  96783. }());
  96784. /**
  96785. * The Observable class is a simple implementation of the Observable pattern.
  96786. *
  96787. * 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.
  96788. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  96789. * 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).
  96790. * 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.
  96791. */
  96792. var Observable = /** @class */ (function () {
  96793. /**
  96794. * Creates a new observable
  96795. * @param onObserverAdded defines a callback to call when a new observer is added
  96796. */
  96797. function Observable(onObserverAdded) {
  96798. this._observers = new Array();
  96799. this._eventState = new EventState(0);
  96800. if (onObserverAdded) {
  96801. this._onObserverAdded = onObserverAdded;
  96802. }
  96803. }
  96804. /**
  96805. * Create a new Observer with the specified callback
  96806. * @param callback the callback that will be executed for that Observer
  96807. * @param mask the mask used to filter observers
  96808. * @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.
  96809. * @param scope optional scope for the callback to be called from
  96810. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  96811. * @returns the new observer created for the callback
  96812. */
  96813. Observable.prototype.add = function (callback, mask, insertFirst, scope, unregisterOnFirstCall) {
  96814. if (mask === void 0) { mask = -1; }
  96815. if (insertFirst === void 0) { insertFirst = false; }
  96816. if (scope === void 0) { scope = null; }
  96817. if (unregisterOnFirstCall === void 0) { unregisterOnFirstCall = false; }
  96818. if (!callback) {
  96819. return null;
  96820. }
  96821. var observer = new Observer(callback, mask, scope);
  96822. observer.unregisterOnNextCall = unregisterOnFirstCall;
  96823. if (insertFirst) {
  96824. this._observers.unshift(observer);
  96825. }
  96826. else {
  96827. this._observers.push(observer);
  96828. }
  96829. if (this._onObserverAdded) {
  96830. this._onObserverAdded(observer);
  96831. }
  96832. return observer;
  96833. };
  96834. /**
  96835. * Create a new Observer with the specified callback and unregisters after the next notification
  96836. * @param callback the callback that will be executed for that Observer
  96837. * @returns the new observer created for the callback
  96838. */
  96839. Observable.prototype.addOnce = function (callback) {
  96840. return this.add(callback, undefined, undefined, undefined, true);
  96841. };
  96842. /**
  96843. * Remove an Observer from the Observable object
  96844. * @param observer the instance of the Observer to remove
  96845. * @returns false if it doesn't belong to this Observable
  96846. */
  96847. Observable.prototype.remove = function (observer) {
  96848. if (!observer) {
  96849. return false;
  96850. }
  96851. var index = this._observers.indexOf(observer);
  96852. if (index !== -1) {
  96853. this._deferUnregister(observer);
  96854. return true;
  96855. }
  96856. return false;
  96857. };
  96858. /**
  96859. * Remove a callback from the Observable object
  96860. * @param callback the callback to remove
  96861. * @param scope optional scope. If used only the callbacks with this scope will be removed
  96862. * @returns false if it doesn't belong to this Observable
  96863. */
  96864. Observable.prototype.removeCallback = function (callback, scope) {
  96865. for (var index = 0; index < this._observers.length; index++) {
  96866. if (this._observers[index].callback === callback && (!scope || scope === this._observers[index].scope)) {
  96867. this._deferUnregister(this._observers[index]);
  96868. return true;
  96869. }
  96870. }
  96871. return false;
  96872. };
  96873. Observable.prototype._deferUnregister = function (observer) {
  96874. var _this = this;
  96875. observer.unregisterOnNextCall = false;
  96876. observer._willBeUnregistered = true;
  96877. setTimeout(function () {
  96878. _this._remove(observer);
  96879. }, 0);
  96880. };
  96881. // This should only be called when not iterating over _observers to avoid callback skipping.
  96882. // Removes an observer from the _observer Array.
  96883. Observable.prototype._remove = function (observer) {
  96884. if (!observer) {
  96885. return false;
  96886. }
  96887. var index = this._observers.indexOf(observer);
  96888. if (index !== -1) {
  96889. this._observers.splice(index, 1);
  96890. return true;
  96891. }
  96892. return false;
  96893. };
  96894. /**
  96895. * Notify all Observers by calling their respective callback with the given data
  96896. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  96897. * @param eventData defines the data to send to all observers
  96898. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  96899. * @param target defines the original target of the state
  96900. * @param currentTarget defines the current target of the state
  96901. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  96902. */
  96903. Observable.prototype.notifyObservers = function (eventData, mask, target, currentTarget) {
  96904. if (mask === void 0) { mask = -1; }
  96905. if (!this._observers.length) {
  96906. return true;
  96907. }
  96908. var state = this._eventState;
  96909. state.mask = mask;
  96910. state.target = target;
  96911. state.currentTarget = currentTarget;
  96912. state.skipNextObservers = false;
  96913. state.lastReturnValue = eventData;
  96914. for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
  96915. var obs = _a[_i];
  96916. if (obs._willBeUnregistered) {
  96917. continue;
  96918. }
  96919. if (obs.mask & mask) {
  96920. if (obs.scope) {
  96921. state.lastReturnValue = obs.callback.apply(obs.scope, [eventData, state]);
  96922. }
  96923. else {
  96924. state.lastReturnValue = obs.callback(eventData, state);
  96925. }
  96926. if (obs.unregisterOnNextCall) {
  96927. this._deferUnregister(obs);
  96928. }
  96929. }
  96930. if (state.skipNextObservers) {
  96931. return false;
  96932. }
  96933. }
  96934. return true;
  96935. };
  96936. /**
  96937. * Calling this will execute each callback, expecting it to be a promise or return a value.
  96938. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  96939. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  96940. * and it is crucial that all callbacks will be executed.
  96941. * The order of the callbacks is kept, callbacks are not executed parallel.
  96942. *
  96943. * @param eventData The data to be sent to each callback
  96944. * @param mask is used to filter observers defaults to -1
  96945. * @param target defines the callback target (see EventState)
  96946. * @param currentTarget defines he current object in the bubbling phase
  96947. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  96948. */
  96949. Observable.prototype.notifyObserversWithPromise = function (eventData, mask, target, currentTarget) {
  96950. var _this = this;
  96951. if (mask === void 0) { mask = -1; }
  96952. // create an empty promise
  96953. var p = Promise.resolve(eventData);
  96954. // no observers? return this promise.
  96955. if (!this._observers.length) {
  96956. return p;
  96957. }
  96958. var state = this._eventState;
  96959. state.mask = mask;
  96960. state.target = target;
  96961. state.currentTarget = currentTarget;
  96962. state.skipNextObservers = false;
  96963. // execute one callback after another (not using Promise.all, the order is important)
  96964. this._observers.forEach(function (obs) {
  96965. if (state.skipNextObservers) {
  96966. return;
  96967. }
  96968. if (obs._willBeUnregistered) {
  96969. return;
  96970. }
  96971. if (obs.mask & mask) {
  96972. if (obs.scope) {
  96973. p = p.then(function (lastReturnedValue) {
  96974. state.lastReturnValue = lastReturnedValue;
  96975. return obs.callback.apply(obs.scope, [eventData, state]);
  96976. });
  96977. }
  96978. else {
  96979. p = p.then(function (lastReturnedValue) {
  96980. state.lastReturnValue = lastReturnedValue;
  96981. return obs.callback(eventData, state);
  96982. });
  96983. }
  96984. if (obs.unregisterOnNextCall) {
  96985. _this._deferUnregister(obs);
  96986. }
  96987. }
  96988. });
  96989. // return the eventData
  96990. return p.then(function () { return eventData; });
  96991. };
  96992. /**
  96993. * Notify a specific observer
  96994. * @param observer defines the observer to notify
  96995. * @param eventData defines the data to be sent to each callback
  96996. * @param mask is used to filter observers defaults to -1
  96997. */
  96998. Observable.prototype.notifyObserver = function (observer, eventData, mask) {
  96999. if (mask === void 0) { mask = -1; }
  97000. var state = this._eventState;
  97001. state.mask = mask;
  97002. state.skipNextObservers = false;
  97003. observer.callback(eventData, state);
  97004. };
  97005. /**
  97006. * Gets a boolean indicating if the observable has at least one observer
  97007. * @returns true is the Observable has at least one Observer registered
  97008. */
  97009. Observable.prototype.hasObservers = function () {
  97010. return this._observers.length > 0;
  97011. };
  97012. /**
  97013. * Clear the list of observers
  97014. */
  97015. Observable.prototype.clear = function () {
  97016. this._observers = new Array();
  97017. this._onObserverAdded = null;
  97018. };
  97019. /**
  97020. * Clone the current observable
  97021. * @returns a new observable
  97022. */
  97023. Observable.prototype.clone = function () {
  97024. var result = new Observable();
  97025. result._observers = this._observers.slice(0);
  97026. return result;
  97027. };
  97028. /**
  97029. * Does this observable handles observer registered with a given mask
  97030. * @param mask defines the mask to be tested
  97031. * @return whether or not one observer registered with the given mask is handeled
  97032. **/
  97033. Observable.prototype.hasSpecificMask = function (mask) {
  97034. if (mask === void 0) { mask = -1; }
  97035. for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
  97036. var obs = _a[_i];
  97037. if (obs.mask & mask || obs.mask === mask) {
  97038. return true;
  97039. }
  97040. }
  97041. return false;
  97042. };
  97043. return Observable;
  97044. }());
  97045. /***/ }),
  97046. /***/ "./Misc/performanceMonitor.ts":
  97047. /*!************************************!*\
  97048. !*** ./Misc/performanceMonitor.ts ***!
  97049. \************************************/
  97050. /*! exports provided: PerformanceMonitor, RollingAverage */
  97051. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97052. "use strict";
  97053. __webpack_require__.r(__webpack_exports__);
  97054. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return PerformanceMonitor; });
  97055. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return RollingAverage; });
  97056. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  97057. /**
  97058. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  97059. */
  97060. var PerformanceMonitor = /** @class */ (function () {
  97061. /**
  97062. * constructor
  97063. * @param frameSampleSize The number of samples required to saturate the sliding window
  97064. */
  97065. function PerformanceMonitor(frameSampleSize) {
  97066. if (frameSampleSize === void 0) { frameSampleSize = 30; }
  97067. this._enabled = true;
  97068. this._rollingFrameTime = new RollingAverage(frameSampleSize);
  97069. }
  97070. /**
  97071. * Samples current frame
  97072. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  97073. */
  97074. PerformanceMonitor.prototype.sampleFrame = function (timeMs) {
  97075. if (timeMs === void 0) { timeMs = _precisionDate__WEBPACK_IMPORTED_MODULE_0__["PrecisionDate"].Now; }
  97076. if (!this._enabled) {
  97077. return;
  97078. }
  97079. if (this._lastFrameTimeMs != null) {
  97080. var dt = timeMs - this._lastFrameTimeMs;
  97081. this._rollingFrameTime.add(dt);
  97082. }
  97083. this._lastFrameTimeMs = timeMs;
  97084. };
  97085. Object.defineProperty(PerformanceMonitor.prototype, "averageFrameTime", {
  97086. /**
  97087. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  97088. */
  97089. get: function () {
  97090. return this._rollingFrameTime.average;
  97091. },
  97092. enumerable: true,
  97093. configurable: true
  97094. });
  97095. Object.defineProperty(PerformanceMonitor.prototype, "averageFrameTimeVariance", {
  97096. /**
  97097. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  97098. */
  97099. get: function () {
  97100. return this._rollingFrameTime.variance;
  97101. },
  97102. enumerable: true,
  97103. configurable: true
  97104. });
  97105. Object.defineProperty(PerformanceMonitor.prototype, "instantaneousFrameTime", {
  97106. /**
  97107. * Returns the frame time of the most recent frame
  97108. */
  97109. get: function () {
  97110. return this._rollingFrameTime.history(0);
  97111. },
  97112. enumerable: true,
  97113. configurable: true
  97114. });
  97115. Object.defineProperty(PerformanceMonitor.prototype, "averageFPS", {
  97116. /**
  97117. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  97118. */
  97119. get: function () {
  97120. return 1000.0 / this._rollingFrameTime.average;
  97121. },
  97122. enumerable: true,
  97123. configurable: true
  97124. });
  97125. Object.defineProperty(PerformanceMonitor.prototype, "instantaneousFPS", {
  97126. /**
  97127. * Returns the average framerate in frames per second using the most recent frame time
  97128. */
  97129. get: function () {
  97130. var history = this._rollingFrameTime.history(0);
  97131. if (history === 0) {
  97132. return 0;
  97133. }
  97134. return 1000.0 / history;
  97135. },
  97136. enumerable: true,
  97137. configurable: true
  97138. });
  97139. Object.defineProperty(PerformanceMonitor.prototype, "isSaturated", {
  97140. /**
  97141. * Returns true if enough samples have been taken to completely fill the sliding window
  97142. */
  97143. get: function () {
  97144. return this._rollingFrameTime.isSaturated();
  97145. },
  97146. enumerable: true,
  97147. configurable: true
  97148. });
  97149. /**
  97150. * Enables contributions to the sliding window sample set
  97151. */
  97152. PerformanceMonitor.prototype.enable = function () {
  97153. this._enabled = true;
  97154. };
  97155. /**
  97156. * Disables contributions to the sliding window sample set
  97157. * Samples will not be interpolated over the disabled period
  97158. */
  97159. PerformanceMonitor.prototype.disable = function () {
  97160. this._enabled = false;
  97161. //clear last sample to avoid interpolating over the disabled period when next enabled
  97162. this._lastFrameTimeMs = null;
  97163. };
  97164. Object.defineProperty(PerformanceMonitor.prototype, "isEnabled", {
  97165. /**
  97166. * Returns true if sampling is enabled
  97167. */
  97168. get: function () {
  97169. return this._enabled;
  97170. },
  97171. enumerable: true,
  97172. configurable: true
  97173. });
  97174. /**
  97175. * Resets performance monitor
  97176. */
  97177. PerformanceMonitor.prototype.reset = function () {
  97178. //clear last sample to avoid interpolating over the disabled period when next enabled
  97179. this._lastFrameTimeMs = null;
  97180. //wipe record
  97181. this._rollingFrameTime.reset();
  97182. };
  97183. return PerformanceMonitor;
  97184. }());
  97185. /**
  97186. * RollingAverage
  97187. *
  97188. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  97189. */
  97190. var RollingAverage = /** @class */ (function () {
  97191. /**
  97192. * constructor
  97193. * @param length The number of samples required to saturate the sliding window
  97194. */
  97195. function RollingAverage(length) {
  97196. this._samples = new Array(length);
  97197. this.reset();
  97198. }
  97199. /**
  97200. * Adds a sample to the sample set
  97201. * @param v The sample value
  97202. */
  97203. RollingAverage.prototype.add = function (v) {
  97204. //http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
  97205. var delta;
  97206. //we need to check if we've already wrapped round
  97207. if (this.isSaturated()) {
  97208. //remove bottom of stack from mean
  97209. var bottomValue = this._samples[this._pos];
  97210. delta = bottomValue - this.average;
  97211. this.average -= delta / (this._sampleCount - 1);
  97212. this._m2 -= delta * (bottomValue - this.average);
  97213. }
  97214. else {
  97215. this._sampleCount++;
  97216. }
  97217. //add new value to mean
  97218. delta = v - this.average;
  97219. this.average += delta / (this._sampleCount);
  97220. this._m2 += delta * (v - this.average);
  97221. //set the new variance
  97222. this.variance = this._m2 / (this._sampleCount - 1);
  97223. this._samples[this._pos] = v;
  97224. this._pos++;
  97225. this._pos %= this._samples.length; //positive wrap around
  97226. };
  97227. /**
  97228. * Returns previously added values or null if outside of history or outside the sliding window domain
  97229. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  97230. * @return Value previously recorded with add() or null if outside of range
  97231. */
  97232. RollingAverage.prototype.history = function (i) {
  97233. if ((i >= this._sampleCount) || (i >= this._samples.length)) {
  97234. return 0;
  97235. }
  97236. var i0 = this._wrapPosition(this._pos - 1.0);
  97237. return this._samples[this._wrapPosition(i0 - i)];
  97238. };
  97239. /**
  97240. * Returns true if enough samples have been taken to completely fill the sliding window
  97241. * @return true if sample-set saturated
  97242. */
  97243. RollingAverage.prototype.isSaturated = function () {
  97244. return this._sampleCount >= this._samples.length;
  97245. };
  97246. /**
  97247. * Resets the rolling average (equivalent to 0 samples taken so far)
  97248. */
  97249. RollingAverage.prototype.reset = function () {
  97250. this.average = 0;
  97251. this.variance = 0;
  97252. this._sampleCount = 0;
  97253. this._pos = 0;
  97254. this._m2 = 0;
  97255. };
  97256. /**
  97257. * Wraps a value around the sample range boundaries
  97258. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  97259. * @return Wrapped position in sample range
  97260. */
  97261. RollingAverage.prototype._wrapPosition = function (i) {
  97262. var max = this._samples.length;
  97263. return ((i % max) + max) % max;
  97264. };
  97265. return RollingAverage;
  97266. }());
  97267. /***/ }),
  97268. /***/ "./Misc/pivotTools.ts":
  97269. /*!****************************!*\
  97270. !*** ./Misc/pivotTools.ts ***!
  97271. \****************************/
  97272. /*! exports provided: PivotTools */
  97273. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97274. "use strict";
  97275. __webpack_require__.r(__webpack_exports__);
  97276. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return PivotTools; });
  97277. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  97278. /**
  97279. * Class containing a set of static utilities functions for managing Pivots
  97280. * @hidden
  97281. */
  97282. var PivotTools = /** @class */ (function () {
  97283. function PivotTools() {
  97284. }
  97285. /** @hidden */
  97286. PivotTools._RemoveAndStorePivotPoint = function (mesh) {
  97287. if (mesh && PivotTools._PivotCached === 0) {
  97288. // Save old pivot and set pivot to 0,0,0
  97289. mesh.getPivotPointToRef(PivotTools._OldPivotPoint);
  97290. if (!PivotTools._OldPivotPoint.equalsToFloats(0, 0, 0)) {
  97291. mesh.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityReadOnly);
  97292. PivotTools._OldPivotPoint.subtractToRef(mesh.getPivotPoint(), PivotTools._PivotTranslation);
  97293. PivotTools._PivotTmpVector.copyFromFloats(1, 1, 1);
  97294. PivotTools._PivotTmpVector.subtractInPlace(mesh.scaling);
  97295. PivotTools._PivotTmpVector.multiplyInPlace(PivotTools._PivotTranslation);
  97296. mesh.position.addInPlace(PivotTools._PivotTmpVector);
  97297. }
  97298. }
  97299. PivotTools._PivotCached++;
  97300. };
  97301. /** @hidden */
  97302. PivotTools._RestorePivotPoint = function (mesh) {
  97303. if (mesh && !PivotTools._OldPivotPoint.equalsToFloats(0, 0, 0) && PivotTools._PivotCached === 1) {
  97304. mesh.setPivotPoint(PivotTools._OldPivotPoint);
  97305. PivotTools._PivotTmpVector.copyFromFloats(1, 1, 1);
  97306. PivotTools._PivotTmpVector.subtractInPlace(mesh.scaling);
  97307. PivotTools._PivotTmpVector.multiplyInPlace(PivotTools._PivotTranslation);
  97308. mesh.position.subtractInPlace(PivotTools._PivotTmpVector);
  97309. }
  97310. this._PivotCached--;
  97311. };
  97312. // Stores the state of the pivot cache (_oldPivotPoint, _pivotTranslation)
  97313. // store/remove pivot point should only be applied during their outermost calls
  97314. PivotTools._PivotCached = 0;
  97315. PivotTools._OldPivotPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  97316. PivotTools._PivotTranslation = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  97317. PivotTools._PivotTmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  97318. return PivotTools;
  97319. }());
  97320. /***/ }),
  97321. /***/ "./Misc/precisionDate.ts":
  97322. /*!*******************************!*\
  97323. !*** ./Misc/precisionDate.ts ***!
  97324. \*******************************/
  97325. /*! exports provided: PrecisionDate */
  97326. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97327. "use strict";
  97328. __webpack_require__.r(__webpack_exports__);
  97329. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return PrecisionDate; });
  97330. /* harmony import */ var _domManagement__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./domManagement */ "./Misc/domManagement.ts");
  97331. /**
  97332. * Class containing a set of static utilities functions for precision date
  97333. */
  97334. var PrecisionDate = /** @class */ (function () {
  97335. function PrecisionDate() {
  97336. }
  97337. Object.defineProperty(PrecisionDate, "Now", {
  97338. /**
  97339. * Gets either window.performance.now() if supported or Date.now() else
  97340. */
  97341. get: function () {
  97342. if (_domManagement__WEBPACK_IMPORTED_MODULE_0__["DomManagement"].IsWindowObjectExist() && window.performance && window.performance.now) {
  97343. return window.performance.now();
  97344. }
  97345. return Date.now();
  97346. },
  97347. enumerable: true,
  97348. configurable: true
  97349. });
  97350. return PrecisionDate;
  97351. }());
  97352. /***/ }),
  97353. /***/ "./Misc/promise.ts":
  97354. /*!*************************!*\
  97355. !*** ./Misc/promise.ts ***!
  97356. \*************************/
  97357. /*! exports provided: PromisePolyfill */
  97358. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97359. "use strict";
  97360. __webpack_require__.r(__webpack_exports__);
  97361. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return PromisePolyfill; });
  97362. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  97363. var PromiseStates;
  97364. (function (PromiseStates) {
  97365. PromiseStates[PromiseStates["Pending"] = 0] = "Pending";
  97366. PromiseStates[PromiseStates["Fulfilled"] = 1] = "Fulfilled";
  97367. PromiseStates[PromiseStates["Rejected"] = 2] = "Rejected";
  97368. })(PromiseStates || (PromiseStates = {}));
  97369. var FulFillmentAgregator = /** @class */ (function () {
  97370. function FulFillmentAgregator() {
  97371. this.count = 0;
  97372. this.target = 0;
  97373. this.results = [];
  97374. }
  97375. return FulFillmentAgregator;
  97376. }());
  97377. var InternalPromise = /** @class */ (function () {
  97378. function InternalPromise(resolver) {
  97379. var _this = this;
  97380. this._state = PromiseStates.Pending;
  97381. this._children = new Array();
  97382. this._rejectWasConsumed = false;
  97383. if (!resolver) {
  97384. return;
  97385. }
  97386. try {
  97387. resolver(function (value) {
  97388. _this._resolve(value);
  97389. }, function (reason) {
  97390. _this._reject(reason);
  97391. });
  97392. }
  97393. catch (e) {
  97394. this._reject(e);
  97395. }
  97396. }
  97397. Object.defineProperty(InternalPromise.prototype, "_result", {
  97398. get: function () {
  97399. return this._resultValue;
  97400. },
  97401. set: function (value) {
  97402. this._resultValue = value;
  97403. if (this._parent && this._parent._result === undefined) {
  97404. this._parent._result = value;
  97405. }
  97406. },
  97407. enumerable: true,
  97408. configurable: true
  97409. });
  97410. InternalPromise.prototype.catch = function (onRejected) {
  97411. return this.then(undefined, onRejected);
  97412. };
  97413. InternalPromise.prototype.then = function (onFulfilled, onRejected) {
  97414. var _this = this;
  97415. var newPromise = new InternalPromise();
  97416. newPromise._onFulfilled = onFulfilled;
  97417. newPromise._onRejected = onRejected;
  97418. // Composition
  97419. this._children.push(newPromise);
  97420. newPromise._parent = this;
  97421. if (this._state !== PromiseStates.Pending) {
  97422. _tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetImmediate(function () {
  97423. if (_this._state === PromiseStates.Fulfilled || _this._rejectWasConsumed) {
  97424. var returnedValue = newPromise._resolve(_this._result);
  97425. if (returnedValue !== undefined && returnedValue !== null) {
  97426. if (returnedValue._state !== undefined) {
  97427. var returnedPromise = returnedValue;
  97428. newPromise._children.push(returnedPromise);
  97429. returnedPromise._parent = newPromise;
  97430. newPromise = returnedPromise;
  97431. }
  97432. else {
  97433. newPromise._result = returnedValue;
  97434. }
  97435. }
  97436. }
  97437. else {
  97438. newPromise._reject(_this._reason);
  97439. }
  97440. });
  97441. }
  97442. return newPromise;
  97443. };
  97444. InternalPromise.prototype._moveChildren = function (children) {
  97445. var _this = this;
  97446. var _a;
  97447. (_a = this._children).push.apply(_a, children.splice(0, children.length));
  97448. this._children.forEach(function (child) {
  97449. child._parent = _this;
  97450. });
  97451. if (this._state === PromiseStates.Fulfilled) {
  97452. for (var _i = 0, _b = this._children; _i < _b.length; _i++) {
  97453. var child = _b[_i];
  97454. child._resolve(this._result);
  97455. }
  97456. }
  97457. else if (this._state === PromiseStates.Rejected) {
  97458. for (var _c = 0, _d = this._children; _c < _d.length; _c++) {
  97459. var child = _d[_c];
  97460. child._reject(this._reason);
  97461. }
  97462. }
  97463. };
  97464. InternalPromise.prototype._resolve = function (value) {
  97465. try {
  97466. this._state = PromiseStates.Fulfilled;
  97467. var returnedValue = null;
  97468. if (this._onFulfilled) {
  97469. returnedValue = this._onFulfilled(value);
  97470. }
  97471. if (returnedValue !== undefined && returnedValue !== null) {
  97472. if (returnedValue._state !== undefined) {
  97473. // Transmit children
  97474. var returnedPromise = returnedValue;
  97475. returnedPromise._parent = this;
  97476. returnedPromise._moveChildren(this._children);
  97477. value = returnedPromise._result;
  97478. }
  97479. else {
  97480. value = returnedValue;
  97481. }
  97482. }
  97483. this._result = value;
  97484. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  97485. var child = _a[_i];
  97486. child._resolve(value);
  97487. }
  97488. this._children.length = 0;
  97489. delete this._onFulfilled;
  97490. delete this._onRejected;
  97491. }
  97492. catch (e) {
  97493. this._reject(e, true);
  97494. }
  97495. };
  97496. InternalPromise.prototype._reject = function (reason, onLocalThrow) {
  97497. if (onLocalThrow === void 0) { onLocalThrow = false; }
  97498. this._state = PromiseStates.Rejected;
  97499. this._reason = reason;
  97500. if (this._onRejected && !onLocalThrow) {
  97501. try {
  97502. this._onRejected(reason);
  97503. this._rejectWasConsumed = true;
  97504. }
  97505. catch (e) {
  97506. reason = e;
  97507. }
  97508. }
  97509. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  97510. var child = _a[_i];
  97511. if (this._rejectWasConsumed) {
  97512. child._resolve(null);
  97513. }
  97514. else {
  97515. child._reject(reason);
  97516. }
  97517. }
  97518. this._children.length = 0;
  97519. delete this._onFulfilled;
  97520. delete this._onRejected;
  97521. };
  97522. InternalPromise.resolve = function (value) {
  97523. var newPromise = new InternalPromise();
  97524. newPromise._resolve(value);
  97525. return newPromise;
  97526. };
  97527. InternalPromise._RegisterForFulfillment = function (promise, agregator, index) {
  97528. promise.then(function (value) {
  97529. agregator.results[index] = value;
  97530. agregator.count++;
  97531. if (agregator.count === agregator.target) {
  97532. agregator.rootPromise._resolve(agregator.results);
  97533. }
  97534. return null;
  97535. }, function (reason) {
  97536. if (agregator.rootPromise._state !== PromiseStates.Rejected) {
  97537. agregator.rootPromise._reject(reason);
  97538. }
  97539. });
  97540. };
  97541. InternalPromise.all = function (promises) {
  97542. var newPromise = new InternalPromise();
  97543. var agregator = new FulFillmentAgregator();
  97544. agregator.target = promises.length;
  97545. agregator.rootPromise = newPromise;
  97546. if (promises.length) {
  97547. for (var index = 0; index < promises.length; index++) {
  97548. InternalPromise._RegisterForFulfillment(promises[index], agregator, index);
  97549. }
  97550. }
  97551. else {
  97552. newPromise._resolve([]);
  97553. }
  97554. return newPromise;
  97555. };
  97556. InternalPromise.race = function (promises) {
  97557. var newPromise = new InternalPromise();
  97558. if (promises.length) {
  97559. for (var _i = 0, promises_1 = promises; _i < promises_1.length; _i++) {
  97560. var promise = promises_1[_i];
  97561. promise.then(function (value) {
  97562. if (newPromise) {
  97563. newPromise._resolve(value);
  97564. newPromise = null;
  97565. }
  97566. return null;
  97567. }, function (reason) {
  97568. if (newPromise) {
  97569. newPromise._reject(reason);
  97570. newPromise = null;
  97571. }
  97572. });
  97573. }
  97574. }
  97575. return newPromise;
  97576. };
  97577. return InternalPromise;
  97578. }());
  97579. /**
  97580. * Helper class that provides a small promise polyfill
  97581. */
  97582. var PromisePolyfill = /** @class */ (function () {
  97583. function PromisePolyfill() {
  97584. }
  97585. /**
  97586. * Static function used to check if the polyfill is required
  97587. * If this is the case then the function will inject the polyfill to window.Promise
  97588. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  97589. */
  97590. PromisePolyfill.Apply = function (force) {
  97591. if (force === void 0) { force = false; }
  97592. if (force || typeof Promise === 'undefined') {
  97593. var root = window;
  97594. root.Promise = InternalPromise;
  97595. }
  97596. };
  97597. return PromisePolyfill;
  97598. }());
  97599. /***/ }),
  97600. /***/ "./Misc/sceneOptimizer.ts":
  97601. /*!********************************!*\
  97602. !*** ./Misc/sceneOptimizer.ts ***!
  97603. \********************************/
  97604. /*! exports provided: SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer */
  97605. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97606. "use strict";
  97607. __webpack_require__.r(__webpack_exports__);
  97608. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return SceneOptimization; });
  97609. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return TextureOptimization; });
  97610. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return HardwareScalingOptimization; });
  97611. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return ShadowsOptimization; });
  97612. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return PostProcessesOptimization; });
  97613. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return LensFlaresOptimization; });
  97614. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return CustomOptimization; });
  97615. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return ParticlesOptimization; });
  97616. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return RenderTargetsOptimization; });
  97617. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return MergeMeshesOptimization; });
  97618. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return SceneOptimizerOptions; });
  97619. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return SceneOptimizer; });
  97620. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  97621. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  97622. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  97623. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  97624. /**
  97625. * Defines the root class used to create scene optimization to use with SceneOptimizer
  97626. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  97627. */
  97628. var SceneOptimization = /** @class */ (function () {
  97629. /**
  97630. * Creates the SceneOptimization object
  97631. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  97632. * @param desc defines the description associated with the optimization
  97633. */
  97634. function SceneOptimization(
  97635. /**
  97636. * Defines the priority of this optimization (0 by default which means first in the list)
  97637. */
  97638. priority) {
  97639. if (priority === void 0) { priority = 0; }
  97640. this.priority = priority;
  97641. }
  97642. /**
  97643. * Gets a string describing the action executed by the current optimization
  97644. * @returns description string
  97645. */
  97646. SceneOptimization.prototype.getDescription = function () {
  97647. return "";
  97648. };
  97649. /**
  97650. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  97651. * @param scene defines the current scene where to apply this optimization
  97652. * @param optimizer defines the current optimizer
  97653. * @returns true if everything that can be done was applied
  97654. */
  97655. SceneOptimization.prototype.apply = function (scene, optimizer) {
  97656. return true;
  97657. };
  97658. return SceneOptimization;
  97659. }());
  97660. /**
  97661. * Defines an optimization used to reduce the size of render target textures
  97662. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  97663. */
  97664. var TextureOptimization = /** @class */ (function (_super) {
  97665. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextureOptimization, _super);
  97666. /**
  97667. * Creates the TextureOptimization object
  97668. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  97669. * @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
  97670. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  97671. */
  97672. function TextureOptimization(
  97673. /**
  97674. * Defines the priority of this optimization (0 by default which means first in the list)
  97675. */
  97676. priority,
  97677. /**
  97678. * 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
  97679. */
  97680. maximumSize,
  97681. /**
  97682. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  97683. */
  97684. step) {
  97685. if (priority === void 0) { priority = 0; }
  97686. if (maximumSize === void 0) { maximumSize = 1024; }
  97687. if (step === void 0) { step = 0.5; }
  97688. var _this = _super.call(this, priority) || this;
  97689. _this.priority = priority;
  97690. _this.maximumSize = maximumSize;
  97691. _this.step = step;
  97692. return _this;
  97693. }
  97694. /**
  97695. * Gets a string describing the action executed by the current optimization
  97696. * @returns description string
  97697. */
  97698. TextureOptimization.prototype.getDescription = function () {
  97699. return "Reducing render target texture size to " + this.maximumSize;
  97700. };
  97701. /**
  97702. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  97703. * @param scene defines the current scene where to apply this optimization
  97704. * @param optimizer defines the current optimizer
  97705. * @returns true if everything that can be done was applied
  97706. */
  97707. TextureOptimization.prototype.apply = function (scene, optimizer) {
  97708. var allDone = true;
  97709. for (var index = 0; index < scene.textures.length; index++) {
  97710. var texture = scene.textures[index];
  97711. if (!texture.canRescale || texture.getContext) {
  97712. continue;
  97713. }
  97714. var currentSize = texture.getSize();
  97715. var maxDimension = Math.max(currentSize.width, currentSize.height);
  97716. if (maxDimension > this.maximumSize) {
  97717. texture.scale(this.step);
  97718. allDone = false;
  97719. }
  97720. }
  97721. return allDone;
  97722. };
  97723. return TextureOptimization;
  97724. }(SceneOptimization));
  97725. /**
  97726. * Defines an optimization used to increase or decrease the rendering resolution
  97727. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  97728. */
  97729. var HardwareScalingOptimization = /** @class */ (function (_super) {
  97730. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HardwareScalingOptimization, _super);
  97731. /**
  97732. * Creates the HardwareScalingOptimization object
  97733. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  97734. * @param maximumScale defines the maximum scale to use (2 by default)
  97735. * @param step defines the step to use between two passes (0.5 by default)
  97736. */
  97737. function HardwareScalingOptimization(
  97738. /**
  97739. * Defines the priority of this optimization (0 by default which means first in the list)
  97740. */
  97741. priority,
  97742. /**
  97743. * Defines the maximum scale to use (2 by default)
  97744. */
  97745. maximumScale,
  97746. /**
  97747. * Defines the step to use between two passes (0.5 by default)
  97748. */
  97749. step) {
  97750. if (priority === void 0) { priority = 0; }
  97751. if (maximumScale === void 0) { maximumScale = 2; }
  97752. if (step === void 0) { step = 0.25; }
  97753. var _this = _super.call(this, priority) || this;
  97754. _this.priority = priority;
  97755. _this.maximumScale = maximumScale;
  97756. _this.step = step;
  97757. _this._currentScale = -1;
  97758. _this._directionOffset = 1;
  97759. return _this;
  97760. }
  97761. /**
  97762. * Gets a string describing the action executed by the current optimization
  97763. * @return description string
  97764. */
  97765. HardwareScalingOptimization.prototype.getDescription = function () {
  97766. return "Setting hardware scaling level to " + this._currentScale;
  97767. };
  97768. /**
  97769. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  97770. * @param scene defines the current scene where to apply this optimization
  97771. * @param optimizer defines the current optimizer
  97772. * @returns true if everything that can be done was applied
  97773. */
  97774. HardwareScalingOptimization.prototype.apply = function (scene, optimizer) {
  97775. if (this._currentScale === -1) {
  97776. this._currentScale = scene.getEngine().getHardwareScalingLevel();
  97777. if (this._currentScale > this.maximumScale) {
  97778. this._directionOffset = -1;
  97779. }
  97780. }
  97781. this._currentScale += this._directionOffset * this.step;
  97782. scene.getEngine().setHardwareScalingLevel(this._currentScale);
  97783. return this._directionOffset === 1 ? this._currentScale >= this.maximumScale : this._currentScale <= this.maximumScale;
  97784. };
  97785. return HardwareScalingOptimization;
  97786. }(SceneOptimization));
  97787. /**
  97788. * Defines an optimization used to remove shadows
  97789. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  97790. */
  97791. var ShadowsOptimization = /** @class */ (function (_super) {
  97792. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShadowsOptimization, _super);
  97793. function ShadowsOptimization() {
  97794. return _super !== null && _super.apply(this, arguments) || this;
  97795. }
  97796. /**
  97797. * Gets a string describing the action executed by the current optimization
  97798. * @return description string
  97799. */
  97800. ShadowsOptimization.prototype.getDescription = function () {
  97801. return "Turning shadows on/off";
  97802. };
  97803. /**
  97804. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  97805. * @param scene defines the current scene where to apply this optimization
  97806. * @param optimizer defines the current optimizer
  97807. * @returns true if everything that can be done was applied
  97808. */
  97809. ShadowsOptimization.prototype.apply = function (scene, optimizer) {
  97810. scene.shadowsEnabled = optimizer.isInImprovementMode;
  97811. return true;
  97812. };
  97813. return ShadowsOptimization;
  97814. }(SceneOptimization));
  97815. /**
  97816. * Defines an optimization used to turn post-processes off
  97817. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  97818. */
  97819. var PostProcessesOptimization = /** @class */ (function (_super) {
  97820. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PostProcessesOptimization, _super);
  97821. function PostProcessesOptimization() {
  97822. return _super !== null && _super.apply(this, arguments) || this;
  97823. }
  97824. /**
  97825. * Gets a string describing the action executed by the current optimization
  97826. * @return description string
  97827. */
  97828. PostProcessesOptimization.prototype.getDescription = function () {
  97829. return "Turning post-processes on/off";
  97830. };
  97831. /**
  97832. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  97833. * @param scene defines the current scene where to apply this optimization
  97834. * @param optimizer defines the current optimizer
  97835. * @returns true if everything that can be done was applied
  97836. */
  97837. PostProcessesOptimization.prototype.apply = function (scene, optimizer) {
  97838. scene.postProcessesEnabled = optimizer.isInImprovementMode;
  97839. return true;
  97840. };
  97841. return PostProcessesOptimization;
  97842. }(SceneOptimization));
  97843. /**
  97844. * Defines an optimization used to turn lens flares off
  97845. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  97846. */
  97847. var LensFlaresOptimization = /** @class */ (function (_super) {
  97848. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LensFlaresOptimization, _super);
  97849. function LensFlaresOptimization() {
  97850. return _super !== null && _super.apply(this, arguments) || this;
  97851. }
  97852. /**
  97853. * Gets a string describing the action executed by the current optimization
  97854. * @return description string
  97855. */
  97856. LensFlaresOptimization.prototype.getDescription = function () {
  97857. return "Turning lens flares on/off";
  97858. };
  97859. /**
  97860. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  97861. * @param scene defines the current scene where to apply this optimization
  97862. * @param optimizer defines the current optimizer
  97863. * @returns true if everything that can be done was applied
  97864. */
  97865. LensFlaresOptimization.prototype.apply = function (scene, optimizer) {
  97866. scene.lensFlaresEnabled = optimizer.isInImprovementMode;
  97867. return true;
  97868. };
  97869. return LensFlaresOptimization;
  97870. }(SceneOptimization));
  97871. /**
  97872. * Defines an optimization based on user defined callback.
  97873. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  97874. */
  97875. var CustomOptimization = /** @class */ (function (_super) {
  97876. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CustomOptimization, _super);
  97877. function CustomOptimization() {
  97878. return _super !== null && _super.apply(this, arguments) || this;
  97879. }
  97880. /**
  97881. * Gets a string describing the action executed by the current optimization
  97882. * @returns description string
  97883. */
  97884. CustomOptimization.prototype.getDescription = function () {
  97885. if (this.onGetDescription) {
  97886. return this.onGetDescription();
  97887. }
  97888. return "Running user defined callback";
  97889. };
  97890. /**
  97891. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  97892. * @param scene defines the current scene where to apply this optimization
  97893. * @param optimizer defines the current optimizer
  97894. * @returns true if everything that can be done was applied
  97895. */
  97896. CustomOptimization.prototype.apply = function (scene, optimizer) {
  97897. if (this.onApply) {
  97898. return this.onApply(scene, optimizer);
  97899. }
  97900. return true;
  97901. };
  97902. return CustomOptimization;
  97903. }(SceneOptimization));
  97904. /**
  97905. * Defines an optimization used to turn particles off
  97906. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  97907. */
  97908. var ParticlesOptimization = /** @class */ (function (_super) {
  97909. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ParticlesOptimization, _super);
  97910. function ParticlesOptimization() {
  97911. return _super !== null && _super.apply(this, arguments) || this;
  97912. }
  97913. /**
  97914. * Gets a string describing the action executed by the current optimization
  97915. * @return description string
  97916. */
  97917. ParticlesOptimization.prototype.getDescription = function () {
  97918. return "Turning particles on/off";
  97919. };
  97920. /**
  97921. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  97922. * @param scene defines the current scene where to apply this optimization
  97923. * @param optimizer defines the current optimizer
  97924. * @returns true if everything that can be done was applied
  97925. */
  97926. ParticlesOptimization.prototype.apply = function (scene, optimizer) {
  97927. scene.particlesEnabled = optimizer.isInImprovementMode;
  97928. return true;
  97929. };
  97930. return ParticlesOptimization;
  97931. }(SceneOptimization));
  97932. /**
  97933. * Defines an optimization used to turn render targets off
  97934. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  97935. */
  97936. var RenderTargetsOptimization = /** @class */ (function (_super) {
  97937. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RenderTargetsOptimization, _super);
  97938. function RenderTargetsOptimization() {
  97939. return _super !== null && _super.apply(this, arguments) || this;
  97940. }
  97941. /**
  97942. * Gets a string describing the action executed by the current optimization
  97943. * @return description string
  97944. */
  97945. RenderTargetsOptimization.prototype.getDescription = function () {
  97946. return "Turning render targets off";
  97947. };
  97948. /**
  97949. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  97950. * @param scene defines the current scene where to apply this optimization
  97951. * @param optimizer defines the current optimizer
  97952. * @returns true if everything that can be done was applied
  97953. */
  97954. RenderTargetsOptimization.prototype.apply = function (scene, optimizer) {
  97955. scene.renderTargetsEnabled = optimizer.isInImprovementMode;
  97956. return true;
  97957. };
  97958. return RenderTargetsOptimization;
  97959. }(SceneOptimization));
  97960. /**
  97961. * Defines an optimization used to merge meshes with compatible materials
  97962. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  97963. */
  97964. var MergeMeshesOptimization = /** @class */ (function (_super) {
  97965. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MergeMeshesOptimization, _super);
  97966. function MergeMeshesOptimization() {
  97967. var _this = _super !== null && _super.apply(this, arguments) || this;
  97968. _this._canBeMerged = function (abstractMesh) {
  97969. if (!(abstractMesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"])) {
  97970. return false;
  97971. }
  97972. var mesh = abstractMesh;
  97973. if (mesh.isDisposed()) {
  97974. return false;
  97975. }
  97976. if (!mesh.isVisible || !mesh.isEnabled()) {
  97977. return false;
  97978. }
  97979. if (mesh.instances.length > 0) {
  97980. return false;
  97981. }
  97982. if (mesh.skeleton || mesh.hasLODLevels) {
  97983. return false;
  97984. }
  97985. return true;
  97986. };
  97987. return _this;
  97988. }
  97989. Object.defineProperty(MergeMeshesOptimization, "UpdateSelectionTree", {
  97990. /**
  97991. * Gets or sets a boolean which defines if optimization octree has to be updated
  97992. */
  97993. get: function () {
  97994. return MergeMeshesOptimization._UpdateSelectionTree;
  97995. },
  97996. /**
  97997. * Gets or sets a boolean which defines if optimization octree has to be updated
  97998. */
  97999. set: function (value) {
  98000. MergeMeshesOptimization._UpdateSelectionTree = value;
  98001. },
  98002. enumerable: true,
  98003. configurable: true
  98004. });
  98005. /**
  98006. * Gets a string describing the action executed by the current optimization
  98007. * @return description string
  98008. */
  98009. MergeMeshesOptimization.prototype.getDescription = function () {
  98010. return "Merging similar meshes together";
  98011. };
  98012. /**
  98013. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  98014. * @param scene defines the current scene where to apply this optimization
  98015. * @param optimizer defines the current optimizer
  98016. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  98017. * @returns true if everything that can be done was applied
  98018. */
  98019. MergeMeshesOptimization.prototype.apply = function (scene, optimizer, updateSelectionTree) {
  98020. var globalPool = scene.meshes.slice(0);
  98021. var globalLength = globalPool.length;
  98022. for (var index = 0; index < globalLength; index++) {
  98023. var currentPool = new Array();
  98024. var current = globalPool[index];
  98025. // Checks
  98026. if (!this._canBeMerged(current)) {
  98027. continue;
  98028. }
  98029. currentPool.push(current);
  98030. // Find compatible meshes
  98031. for (var subIndex = index + 1; subIndex < globalLength; subIndex++) {
  98032. var otherMesh = globalPool[subIndex];
  98033. if (!this._canBeMerged(otherMesh)) {
  98034. continue;
  98035. }
  98036. if (otherMesh.material !== current.material) {
  98037. continue;
  98038. }
  98039. if (otherMesh.checkCollisions !== current.checkCollisions) {
  98040. continue;
  98041. }
  98042. currentPool.push(otherMesh);
  98043. globalLength--;
  98044. globalPool.splice(subIndex, 1);
  98045. subIndex--;
  98046. }
  98047. if (currentPool.length < 2) {
  98048. continue;
  98049. }
  98050. // Merge meshes
  98051. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"].MergeMeshes(currentPool, undefined, true);
  98052. }
  98053. // Call the octree system optimization if it is defined.
  98054. var sceneAsAny = scene;
  98055. if (sceneAsAny.createOrUpdateSelectionOctree) {
  98056. if (updateSelectionTree != undefined) {
  98057. if (updateSelectionTree) {
  98058. sceneAsAny.createOrUpdateSelectionOctree();
  98059. }
  98060. }
  98061. else if (MergeMeshesOptimization.UpdateSelectionTree) {
  98062. sceneAsAny.createOrUpdateSelectionOctree();
  98063. }
  98064. }
  98065. return true;
  98066. };
  98067. MergeMeshesOptimization._UpdateSelectionTree = false;
  98068. return MergeMeshesOptimization;
  98069. }(SceneOptimization));
  98070. /**
  98071. * Defines a list of options used by SceneOptimizer
  98072. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  98073. */
  98074. var SceneOptimizerOptions = /** @class */ (function () {
  98075. /**
  98076. * Creates a new list of options used by SceneOptimizer
  98077. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  98078. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  98079. */
  98080. function SceneOptimizerOptions(
  98081. /**
  98082. * Defines the target frame rate to reach (60 by default)
  98083. */
  98084. targetFrameRate,
  98085. /**
  98086. * Defines the interval between two checkes (2000ms by default)
  98087. */
  98088. trackerDuration) {
  98089. if (targetFrameRate === void 0) { targetFrameRate = 60; }
  98090. if (trackerDuration === void 0) { trackerDuration = 2000; }
  98091. this.targetFrameRate = targetFrameRate;
  98092. this.trackerDuration = trackerDuration;
  98093. /**
  98094. * Gets the list of optimizations to apply
  98095. */
  98096. this.optimizations = new Array();
  98097. }
  98098. /**
  98099. * Add a new optimization
  98100. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  98101. * @returns the current SceneOptimizerOptions
  98102. */
  98103. SceneOptimizerOptions.prototype.addOptimization = function (optimization) {
  98104. this.optimizations.push(optimization);
  98105. return this;
  98106. };
  98107. /**
  98108. * Add a new custom optimization
  98109. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  98110. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  98111. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  98112. * @returns the current SceneOptimizerOptions
  98113. */
  98114. SceneOptimizerOptions.prototype.addCustomOptimization = function (onApply, onGetDescription, priority) {
  98115. if (priority === void 0) { priority = 0; }
  98116. var optimization = new CustomOptimization(priority);
  98117. optimization.onApply = onApply;
  98118. optimization.onGetDescription = onGetDescription;
  98119. this.optimizations.push(optimization);
  98120. return this;
  98121. };
  98122. /**
  98123. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  98124. * @param targetFrameRate defines the target frame rate (60 by default)
  98125. * @returns a SceneOptimizerOptions object
  98126. */
  98127. SceneOptimizerOptions.LowDegradationAllowed = function (targetFrameRate) {
  98128. var result = new SceneOptimizerOptions(targetFrameRate);
  98129. var priority = 0;
  98130. result.addOptimization(new MergeMeshesOptimization(priority));
  98131. result.addOptimization(new ShadowsOptimization(priority));
  98132. result.addOptimization(new LensFlaresOptimization(priority));
  98133. // Next priority
  98134. priority++;
  98135. result.addOptimization(new PostProcessesOptimization(priority));
  98136. result.addOptimization(new ParticlesOptimization(priority));
  98137. // Next priority
  98138. priority++;
  98139. result.addOptimization(new TextureOptimization(priority, 1024));
  98140. return result;
  98141. };
  98142. /**
  98143. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  98144. * @param targetFrameRate defines the target frame rate (60 by default)
  98145. * @returns a SceneOptimizerOptions object
  98146. */
  98147. SceneOptimizerOptions.ModerateDegradationAllowed = function (targetFrameRate) {
  98148. var result = new SceneOptimizerOptions(targetFrameRate);
  98149. var priority = 0;
  98150. result.addOptimization(new MergeMeshesOptimization(priority));
  98151. result.addOptimization(new ShadowsOptimization(priority));
  98152. result.addOptimization(new LensFlaresOptimization(priority));
  98153. // Next priority
  98154. priority++;
  98155. result.addOptimization(new PostProcessesOptimization(priority));
  98156. result.addOptimization(new ParticlesOptimization(priority));
  98157. // Next priority
  98158. priority++;
  98159. result.addOptimization(new TextureOptimization(priority, 512));
  98160. // Next priority
  98161. priority++;
  98162. result.addOptimization(new RenderTargetsOptimization(priority));
  98163. // Next priority
  98164. priority++;
  98165. result.addOptimization(new HardwareScalingOptimization(priority, 2));
  98166. return result;
  98167. };
  98168. /**
  98169. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  98170. * @param targetFrameRate defines the target frame rate (60 by default)
  98171. * @returns a SceneOptimizerOptions object
  98172. */
  98173. SceneOptimizerOptions.HighDegradationAllowed = function (targetFrameRate) {
  98174. var result = new SceneOptimizerOptions(targetFrameRate);
  98175. var priority = 0;
  98176. result.addOptimization(new MergeMeshesOptimization(priority));
  98177. result.addOptimization(new ShadowsOptimization(priority));
  98178. result.addOptimization(new LensFlaresOptimization(priority));
  98179. // Next priority
  98180. priority++;
  98181. result.addOptimization(new PostProcessesOptimization(priority));
  98182. result.addOptimization(new ParticlesOptimization(priority));
  98183. // Next priority
  98184. priority++;
  98185. result.addOptimization(new TextureOptimization(priority, 256));
  98186. // Next priority
  98187. priority++;
  98188. result.addOptimization(new RenderTargetsOptimization(priority));
  98189. // Next priority
  98190. priority++;
  98191. result.addOptimization(new HardwareScalingOptimization(priority, 4));
  98192. return result;
  98193. };
  98194. return SceneOptimizerOptions;
  98195. }());
  98196. /**
  98197. * Class used to run optimizations in order to reach a target frame rate
  98198. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  98199. */
  98200. var SceneOptimizer = /** @class */ (function () {
  98201. /**
  98202. * Creates a new SceneOptimizer
  98203. * @param scene defines the scene to work on
  98204. * @param options defines the options to use with the SceneOptimizer
  98205. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  98206. * @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)
  98207. */
  98208. function SceneOptimizer(scene, options, autoGeneratePriorities, improvementMode) {
  98209. if (autoGeneratePriorities === void 0) { autoGeneratePriorities = true; }
  98210. if (improvementMode === void 0) { improvementMode = false; }
  98211. var _this = this;
  98212. this._isRunning = false;
  98213. this._currentPriorityLevel = 0;
  98214. this._targetFrameRate = 60;
  98215. this._trackerDuration = 2000;
  98216. this._currentFrameRate = 0;
  98217. this._improvementMode = false;
  98218. /**
  98219. * Defines an observable called when the optimizer reaches the target frame rate
  98220. */
  98221. this.onSuccessObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  98222. /**
  98223. * Defines an observable called when the optimizer enables an optimization
  98224. */
  98225. this.onNewOptimizationAppliedObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  98226. /**
  98227. * Defines an observable called when the optimizer is not able to reach the target frame rate
  98228. */
  98229. this.onFailureObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  98230. if (!options) {
  98231. this._options = new SceneOptimizerOptions();
  98232. }
  98233. else {
  98234. this._options = options;
  98235. }
  98236. if (this._options.targetFrameRate) {
  98237. this._targetFrameRate = this._options.targetFrameRate;
  98238. }
  98239. if (this._options.trackerDuration) {
  98240. this._trackerDuration = this._options.trackerDuration;
  98241. }
  98242. if (autoGeneratePriorities) {
  98243. var priority = 0;
  98244. for (var _i = 0, _a = this._options.optimizations; _i < _a.length; _i++) {
  98245. var optim = _a[_i];
  98246. optim.priority = priority++;
  98247. }
  98248. }
  98249. this._improvementMode = improvementMode;
  98250. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__["EngineStore"].LastCreatedScene;
  98251. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  98252. _this._sceneDisposeObserver = null;
  98253. _this.dispose();
  98254. });
  98255. }
  98256. Object.defineProperty(SceneOptimizer.prototype, "isInImprovementMode", {
  98257. /**
  98258. * Gets a boolean indicating if the optimizer is in improvement mode
  98259. */
  98260. get: function () {
  98261. return this._improvementMode;
  98262. },
  98263. enumerable: true,
  98264. configurable: true
  98265. });
  98266. Object.defineProperty(SceneOptimizer.prototype, "currentPriorityLevel", {
  98267. /**
  98268. * Gets the current priority level (0 at start)
  98269. */
  98270. get: function () {
  98271. return this._currentPriorityLevel;
  98272. },
  98273. enumerable: true,
  98274. configurable: true
  98275. });
  98276. Object.defineProperty(SceneOptimizer.prototype, "currentFrameRate", {
  98277. /**
  98278. * Gets the current frame rate checked by the SceneOptimizer
  98279. */
  98280. get: function () {
  98281. return this._currentFrameRate;
  98282. },
  98283. enumerable: true,
  98284. configurable: true
  98285. });
  98286. Object.defineProperty(SceneOptimizer.prototype, "targetFrameRate", {
  98287. /**
  98288. * Gets or sets the current target frame rate (60 by default)
  98289. */
  98290. get: function () {
  98291. return this._targetFrameRate;
  98292. },
  98293. /**
  98294. * Gets or sets the current target frame rate (60 by default)
  98295. */
  98296. set: function (value) {
  98297. this._targetFrameRate = value;
  98298. },
  98299. enumerable: true,
  98300. configurable: true
  98301. });
  98302. Object.defineProperty(SceneOptimizer.prototype, "trackerDuration", {
  98303. /**
  98304. * Gets or sets the current interval between two checks (every 2000ms by default)
  98305. */
  98306. get: function () {
  98307. return this._trackerDuration;
  98308. },
  98309. /**
  98310. * Gets or sets the current interval between two checks (every 2000ms by default)
  98311. */
  98312. set: function (value) {
  98313. this._trackerDuration = value;
  98314. },
  98315. enumerable: true,
  98316. configurable: true
  98317. });
  98318. Object.defineProperty(SceneOptimizer.prototype, "optimizations", {
  98319. /**
  98320. * Gets the list of active optimizations
  98321. */
  98322. get: function () {
  98323. return this._options.optimizations;
  98324. },
  98325. enumerable: true,
  98326. configurable: true
  98327. });
  98328. /**
  98329. * Stops the current optimizer
  98330. */
  98331. SceneOptimizer.prototype.stop = function () {
  98332. this._isRunning = false;
  98333. };
  98334. /**
  98335. * Reset the optimizer to initial step (current priority level = 0)
  98336. */
  98337. SceneOptimizer.prototype.reset = function () {
  98338. this._currentPriorityLevel = 0;
  98339. };
  98340. /**
  98341. * Start the optimizer. By default it will try to reach a specific framerate
  98342. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  98343. */
  98344. SceneOptimizer.prototype.start = function () {
  98345. var _this = this;
  98346. if (this._isRunning) {
  98347. return;
  98348. }
  98349. this._isRunning = true;
  98350. // Let's wait for the scene to be ready before running our check
  98351. this._scene.executeWhenReady(function () {
  98352. setTimeout(function () {
  98353. _this._checkCurrentState();
  98354. }, _this._trackerDuration);
  98355. });
  98356. };
  98357. SceneOptimizer.prototype._checkCurrentState = function () {
  98358. var _this = this;
  98359. if (!this._isRunning) {
  98360. return;
  98361. }
  98362. var scene = this._scene;
  98363. var options = this._options;
  98364. this._currentFrameRate = Math.round(scene.getEngine().getFps());
  98365. if (this._improvementMode && this._currentFrameRate <= this._targetFrameRate ||
  98366. !this._improvementMode && this._currentFrameRate >= this._targetFrameRate) {
  98367. this._isRunning = false;
  98368. this.onSuccessObservable.notifyObservers(this);
  98369. return;
  98370. }
  98371. // Apply current level of optimizations
  98372. var allDone = true;
  98373. var noOptimizationApplied = true;
  98374. for (var index = 0; index < options.optimizations.length; index++) {
  98375. var optimization = options.optimizations[index];
  98376. if (optimization.priority === this._currentPriorityLevel) {
  98377. noOptimizationApplied = false;
  98378. allDone = allDone && optimization.apply(scene, this);
  98379. this.onNewOptimizationAppliedObservable.notifyObservers(optimization);
  98380. }
  98381. }
  98382. // If no optimization was applied, this is a failure :(
  98383. if (noOptimizationApplied) {
  98384. this._isRunning = false;
  98385. this.onFailureObservable.notifyObservers(this);
  98386. return;
  98387. }
  98388. // If all optimizations were done, move to next level
  98389. if (allDone) {
  98390. this._currentPriorityLevel++;
  98391. }
  98392. // Let's the system running for a specific amount of time before checking FPS
  98393. scene.executeWhenReady(function () {
  98394. setTimeout(function () {
  98395. _this._checkCurrentState();
  98396. }, _this._trackerDuration);
  98397. });
  98398. };
  98399. /**
  98400. * Release all resources
  98401. */
  98402. SceneOptimizer.prototype.dispose = function () {
  98403. this.stop();
  98404. this.onSuccessObservable.clear();
  98405. this.onFailureObservable.clear();
  98406. this.onNewOptimizationAppliedObservable.clear();
  98407. if (this._sceneDisposeObserver) {
  98408. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  98409. }
  98410. };
  98411. /**
  98412. * Helper function to create a SceneOptimizer with one single line of code
  98413. * @param scene defines the scene to work on
  98414. * @param options defines the options to use with the SceneOptimizer
  98415. * @param onSuccess defines a callback to call on success
  98416. * @param onFailure defines a callback to call on failure
  98417. * @returns the new SceneOptimizer object
  98418. */
  98419. SceneOptimizer.OptimizeAsync = function (scene, options, onSuccess, onFailure) {
  98420. var optimizer = new SceneOptimizer(scene, options || SceneOptimizerOptions.ModerateDegradationAllowed(), false);
  98421. if (onSuccess) {
  98422. optimizer.onSuccessObservable.add(function () {
  98423. onSuccess();
  98424. });
  98425. }
  98426. if (onFailure) {
  98427. optimizer.onFailureObservable.add(function () {
  98428. onFailure();
  98429. });
  98430. }
  98431. optimizer.start();
  98432. return optimizer;
  98433. };
  98434. return SceneOptimizer;
  98435. }());
  98436. /***/ }),
  98437. /***/ "./Misc/sceneSerializer.ts":
  98438. /*!*********************************!*\
  98439. !*** ./Misc/sceneSerializer.ts ***!
  98440. \*********************************/
  98441. /*! exports provided: SceneSerializer */
  98442. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98443. "use strict";
  98444. __webpack_require__.r(__webpack_exports__);
  98445. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return SceneSerializer; });
  98446. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  98447. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  98448. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  98449. /* harmony import */ var _decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./decorators */ "./Misc/decorators.ts");
  98450. var serializedGeometries = [];
  98451. var serializeGeometry = function (geometry, serializationGeometries) {
  98452. if (serializedGeometries[geometry.id]) {
  98453. return;
  98454. }
  98455. if (geometry.doNotSerialize) {
  98456. return;
  98457. }
  98458. serializationGeometries.vertexData.push(geometry.serializeVerticeData());
  98459. serializedGeometries[geometry.id] = true;
  98460. };
  98461. var serializeMesh = function (mesh, serializationScene) {
  98462. var serializationObject = {};
  98463. // Geometry
  98464. var geometry = mesh._geometry;
  98465. if (geometry) {
  98466. if (!mesh.getScene().getGeometryByID(geometry.id)) {
  98467. // 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
  98468. serializeGeometry(geometry, serializationScene.geometries);
  98469. }
  98470. }
  98471. // Custom
  98472. if (mesh.serialize) {
  98473. mesh.serialize(serializationObject);
  98474. }
  98475. return serializationObject;
  98476. };
  98477. var finalizeSingleMesh = function (mesh, serializationObject) {
  98478. //only works if the mesh is already loaded
  98479. if (mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_LOADED || mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_NONE) {
  98480. //serialize material
  98481. if (mesh.material) {
  98482. if (mesh.material instanceof _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_2__["MultiMaterial"]) {
  98483. serializationObject.multiMaterials = serializationObject.multiMaterials || [];
  98484. serializationObject.materials = serializationObject.materials || [];
  98485. if (!serializationObject.multiMaterials.some(function (mat) { return (mat.id === mesh.material.id); })) {
  98486. serializationObject.multiMaterials.push(mesh.material.serialize());
  98487. var _loop_1 = function (submaterial) {
  98488. if (submaterial) {
  98489. if (!serializationObject.materials.some(function (mat) { return (mat.id === submaterial.id); })) {
  98490. serializationObject.materials.push(submaterial.serialize());
  98491. }
  98492. }
  98493. };
  98494. for (var _i = 0, _a = mesh.material.subMaterials; _i < _a.length; _i++) {
  98495. var submaterial = _a[_i];
  98496. _loop_1(submaterial);
  98497. }
  98498. }
  98499. }
  98500. else {
  98501. serializationObject.materials = serializationObject.materials || [];
  98502. if (!serializationObject.materials.some(function (mat) { return (mat.id === mesh.material.id); })) {
  98503. serializationObject.materials.push(mesh.material.serialize());
  98504. }
  98505. }
  98506. }
  98507. //serialize geometry
  98508. var geometry = mesh._geometry;
  98509. if (geometry) {
  98510. if (!serializationObject.geometries) {
  98511. serializationObject.geometries = {};
  98512. serializationObject.geometries.boxes = [];
  98513. serializationObject.geometries.spheres = [];
  98514. serializationObject.geometries.cylinders = [];
  98515. serializationObject.geometries.toruses = [];
  98516. serializationObject.geometries.grounds = [];
  98517. serializationObject.geometries.planes = [];
  98518. serializationObject.geometries.torusKnots = [];
  98519. serializationObject.geometries.vertexData = [];
  98520. }
  98521. serializeGeometry(geometry, serializationObject.geometries);
  98522. }
  98523. // Skeletons
  98524. if (mesh.skeleton) {
  98525. serializationObject.skeletons = serializationObject.skeletons || [];
  98526. serializationObject.skeletons.push(mesh.skeleton.serialize());
  98527. }
  98528. //serialize the actual mesh
  98529. serializationObject.meshes = serializationObject.meshes || [];
  98530. serializationObject.meshes.push(serializeMesh(mesh, serializationObject));
  98531. }
  98532. };
  98533. /**
  98534. * Class used to serialize a scene into a string
  98535. */
  98536. var SceneSerializer = /** @class */ (function () {
  98537. function SceneSerializer() {
  98538. }
  98539. /**
  98540. * Clear cache used by a previous serialization
  98541. */
  98542. SceneSerializer.ClearCache = function () {
  98543. serializedGeometries = [];
  98544. };
  98545. /**
  98546. * Serialize a scene into a JSON compatible object
  98547. * @param scene defines the scene to serialize
  98548. * @returns a JSON compatible object
  98549. */
  98550. SceneSerializer.Serialize = function (scene) {
  98551. var serializationObject = {};
  98552. SceneSerializer.ClearCache();
  98553. // Scene
  98554. serializationObject.useDelayedTextureLoading = scene.useDelayedTextureLoading;
  98555. serializationObject.autoClear = scene.autoClear;
  98556. serializationObject.clearColor = scene.clearColor.asArray();
  98557. serializationObject.ambientColor = scene.ambientColor.asArray();
  98558. serializationObject.gravity = scene.gravity.asArray();
  98559. serializationObject.collisionsEnabled = scene.collisionsEnabled;
  98560. // Fog
  98561. if (scene.fogMode && scene.fogMode !== 0) {
  98562. serializationObject.fogMode = scene.fogMode;
  98563. serializationObject.fogColor = scene.fogColor.asArray();
  98564. serializationObject.fogStart = scene.fogStart;
  98565. serializationObject.fogEnd = scene.fogEnd;
  98566. serializationObject.fogDensity = scene.fogDensity;
  98567. }
  98568. //Physics
  98569. if (scene.isPhysicsEnabled()) {
  98570. var physicEngine = scene.getPhysicsEngine();
  98571. if (physicEngine) {
  98572. serializationObject.physicsEnabled = true;
  98573. serializationObject.physicsGravity = physicEngine.gravity.asArray();
  98574. serializationObject.physicsEngine = physicEngine.getPhysicsPluginName();
  98575. }
  98576. }
  98577. // Metadata
  98578. if (scene.metadata) {
  98579. serializationObject.metadata = scene.metadata;
  98580. }
  98581. // Morph targets
  98582. serializationObject.morphTargetManagers = [];
  98583. for (var _i = 0, _a = scene.meshes; _i < _a.length; _i++) {
  98584. var abstractMesh = _a[_i];
  98585. var manager = abstractMesh.morphTargetManager;
  98586. if (manager) {
  98587. serializationObject.morphTargetManagers.push(manager.serialize());
  98588. }
  98589. }
  98590. // Lights
  98591. serializationObject.lights = [];
  98592. var index;
  98593. var light;
  98594. for (index = 0; index < scene.lights.length; index++) {
  98595. light = scene.lights[index];
  98596. if (!light.doNotSerialize) {
  98597. serializationObject.lights.push(light.serialize());
  98598. }
  98599. }
  98600. // Cameras
  98601. serializationObject.cameras = [];
  98602. for (index = 0; index < scene.cameras.length; index++) {
  98603. var camera = scene.cameras[index];
  98604. if (!camera.doNotSerialize) {
  98605. serializationObject.cameras.push(camera.serialize());
  98606. }
  98607. }
  98608. if (scene.activeCamera) {
  98609. serializationObject.activeCameraID = scene.activeCamera.id;
  98610. }
  98611. // Animations
  98612. _decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"].AppendSerializedAnimations(scene, serializationObject);
  98613. // Reflection probes
  98614. if (scene.reflectionProbes && scene.reflectionProbes.length > 0) {
  98615. serializationObject.reflectionProbes = [];
  98616. for (index = 0; index < scene.reflectionProbes.length; index++) {
  98617. var reflectionProbe = scene.reflectionProbes[index];
  98618. serializationObject.reflectionProbes.push(reflectionProbe.serialize());
  98619. }
  98620. }
  98621. // Materials
  98622. serializationObject.materials = [];
  98623. serializationObject.multiMaterials = [];
  98624. var material;
  98625. for (index = 0; index < scene.materials.length; index++) {
  98626. material = scene.materials[index];
  98627. if (!material.doNotSerialize) {
  98628. serializationObject.materials.push(material.serialize());
  98629. }
  98630. }
  98631. // MultiMaterials
  98632. serializationObject.multiMaterials = [];
  98633. for (index = 0; index < scene.multiMaterials.length; index++) {
  98634. var multiMaterial = scene.multiMaterials[index];
  98635. serializationObject.multiMaterials.push(multiMaterial.serialize());
  98636. }
  98637. // Environment texture
  98638. if (scene.environmentTexture) {
  98639. serializationObject.environmentTexture = scene.environmentTexture.name;
  98640. }
  98641. // Skeletons
  98642. serializationObject.skeletons = [];
  98643. for (index = 0; index < scene.skeletons.length; index++) {
  98644. var skeleton = scene.skeletons[index];
  98645. if (!skeleton.doNotSerialize) {
  98646. serializationObject.skeletons.push(skeleton.serialize());
  98647. }
  98648. }
  98649. // Transform nodes
  98650. serializationObject.transformNodes = [];
  98651. for (index = 0; index < scene.transformNodes.length; index++) {
  98652. serializationObject.transformNodes.push(scene.transformNodes[index].serialize());
  98653. }
  98654. // Geometries
  98655. serializationObject.geometries = {};
  98656. serializationObject.geometries.boxes = [];
  98657. serializationObject.geometries.spheres = [];
  98658. serializationObject.geometries.cylinders = [];
  98659. serializationObject.geometries.toruses = [];
  98660. serializationObject.geometries.grounds = [];
  98661. serializationObject.geometries.planes = [];
  98662. serializationObject.geometries.torusKnots = [];
  98663. serializationObject.geometries.vertexData = [];
  98664. serializedGeometries = [];
  98665. var geometries = scene.getGeometries();
  98666. for (index = 0; index < geometries.length; index++) {
  98667. var geometry = geometries[index];
  98668. if (geometry.isReady()) {
  98669. serializeGeometry(geometry, serializationObject.geometries);
  98670. }
  98671. }
  98672. // Meshes
  98673. serializationObject.meshes = [];
  98674. for (index = 0; index < scene.meshes.length; index++) {
  98675. var abstractMesh = scene.meshes[index];
  98676. if (abstractMesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]) {
  98677. var mesh = abstractMesh;
  98678. if (!mesh.doNotSerialize) {
  98679. if (mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_LOADED || mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_NONE) {
  98680. serializationObject.meshes.push(serializeMesh(mesh, serializationObject));
  98681. }
  98682. }
  98683. }
  98684. }
  98685. // Particles Systems
  98686. serializationObject.particleSystems = [];
  98687. for (index = 0; index < scene.particleSystems.length; index++) {
  98688. serializationObject.particleSystems.push(scene.particleSystems[index].serialize());
  98689. }
  98690. // Action Manager
  98691. if (scene.actionManager) {
  98692. serializationObject.actions = scene.actionManager.serialize("scene");
  98693. }
  98694. // Components
  98695. for (var _b = 0, _c = scene._serializableComponents; _b < _c.length; _b++) {
  98696. var component = _c[_b];
  98697. component.serialize(serializationObject);
  98698. }
  98699. return serializationObject;
  98700. };
  98701. /**
  98702. * Serialize a mesh into a JSON compatible object
  98703. * @param toSerialize defines the mesh to serialize
  98704. * @param withParents defines if parents must be serialized as well
  98705. * @param withChildren defines if children must be serialized as well
  98706. * @returns a JSON compatible object
  98707. */
  98708. SceneSerializer.SerializeMesh = function (toSerialize /* Mesh || Mesh[] */, withParents, withChildren) {
  98709. if (withParents === void 0) { withParents = false; }
  98710. if (withChildren === void 0) { withChildren = false; }
  98711. var serializationObject = {};
  98712. SceneSerializer.ClearCache();
  98713. toSerialize = (toSerialize instanceof Array) ? toSerialize : [toSerialize];
  98714. if (withParents || withChildren) {
  98715. //deliberate for loop! not for each, appended should be processed as well.
  98716. for (var i = 0; i < toSerialize.length; ++i) {
  98717. if (withChildren) {
  98718. toSerialize[i].getDescendants().forEach(function (node) {
  98719. if (node instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"] && (toSerialize.indexOf(node) < 0)) {
  98720. toSerialize.push(node);
  98721. }
  98722. });
  98723. }
  98724. //make sure the array doesn't contain the object already
  98725. if (withParents && toSerialize[i].parent && (toSerialize.indexOf(toSerialize[i].parent) < 0)) {
  98726. toSerialize.push(toSerialize[i].parent);
  98727. }
  98728. }
  98729. }
  98730. toSerialize.forEach(function (mesh) {
  98731. finalizeSingleMesh(mesh, serializationObject);
  98732. });
  98733. return serializationObject;
  98734. };
  98735. return SceneSerializer;
  98736. }());
  98737. /***/ }),
  98738. /***/ "./Misc/screenshotTools.ts":
  98739. /*!*********************************!*\
  98740. !*** ./Misc/screenshotTools.ts ***!
  98741. \*********************************/
  98742. /*! exports provided: ScreenshotTools */
  98743. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98744. "use strict";
  98745. __webpack_require__.r(__webpack_exports__);
  98746. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return ScreenshotTools; });
  98747. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  98748. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  98749. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  98750. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  98751. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  98752. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  98753. /**
  98754. * Class containing a set of static utilities functions for screenshots
  98755. */
  98756. var ScreenshotTools = /** @class */ (function () {
  98757. function ScreenshotTools() {
  98758. }
  98759. /**
  98760. * Captures a screenshot of the current rendering
  98761. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98762. * @param engine defines the rendering engine
  98763. * @param camera defines the source camera
  98764. * @param size This parameter can be set to a single number or to an object with the
  98765. * following (optional) properties: precision, width, height. If a single number is passed,
  98766. * it will be used for both width and height. If an object is passed, the screenshot size
  98767. * will be derived from the parameters. The precision property is a multiplier allowing
  98768. * rendering at a higher or lower resolution
  98769. * @param successCallback defines the callback receives a single parameter which contains the
  98770. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  98771. * src parameter of an <img> to display it
  98772. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  98773. * Check your browser for supported MIME types
  98774. */
  98775. ScreenshotTools.CreateScreenshot = function (engine, camera, size, successCallback, mimeType) {
  98776. if (mimeType === void 0) { mimeType = "image/png"; }
  98777. var width;
  98778. var height;
  98779. // If a precision value is specified
  98780. if (size.precision) {
  98781. width = Math.round(engine.getRenderWidth() * size.precision);
  98782. height = Math.round(width / engine.getAspectRatio(camera));
  98783. }
  98784. else if (size.width && size.height) {
  98785. width = size.width;
  98786. height = size.height;
  98787. }
  98788. //If passing only width, computing height to keep display canvas ratio.
  98789. else if (size.width && !size.height) {
  98790. width = size.width;
  98791. height = Math.round(width / engine.getAspectRatio(camera));
  98792. }
  98793. //If passing only height, computing width to keep display canvas ratio.
  98794. else if (size.height && !size.width) {
  98795. height = size.height;
  98796. width = Math.round(height * engine.getAspectRatio(camera));
  98797. }
  98798. //Assuming here that "size" parameter is a number
  98799. else if (!isNaN(size)) {
  98800. height = size;
  98801. width = size;
  98802. }
  98803. else {
  98804. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Invalid 'size' parameter !");
  98805. return;
  98806. }
  98807. if (!_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas) {
  98808. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas = document.createElement('canvas');
  98809. }
  98810. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas.width = width;
  98811. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas.height = height;
  98812. var renderContext = _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas.getContext("2d");
  98813. var ratio = engine.getRenderWidth() / engine.getRenderHeight();
  98814. var newWidth = width;
  98815. var newHeight = newWidth / ratio;
  98816. if (newHeight > height) {
  98817. newHeight = height;
  98818. newWidth = newHeight * ratio;
  98819. }
  98820. var offsetX = Math.max(0, width - newWidth) / 2;
  98821. var offsetY = Math.max(0, height - newHeight) / 2;
  98822. var renderingCanvas = engine.getRenderingCanvas();
  98823. if (renderContext && renderingCanvas) {
  98824. renderContext.drawImage(renderingCanvas, offsetX, offsetY, newWidth, newHeight);
  98825. }
  98826. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].EncodeScreenshotCanvasData(successCallback, mimeType);
  98827. };
  98828. /**
  98829. * Generates an image screenshot from the specified camera.
  98830. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98831. * @param engine The engine to use for rendering
  98832. * @param camera The camera to use for rendering
  98833. * @param size This parameter can be set to a single number or to an object with the
  98834. * following (optional) properties: precision, width, height. If a single number is passed,
  98835. * it will be used for both width and height. If an object is passed, the screenshot size
  98836. * will be derived from the parameters. The precision property is a multiplier allowing
  98837. * rendering at a higher or lower resolution
  98838. * @param successCallback The callback receives a single parameter which contains the
  98839. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  98840. * src parameter of an <img> to display it
  98841. * @param mimeType The MIME type of the screenshot image (default: image/png).
  98842. * Check your browser for supported MIME types
  98843. * @param samples Texture samples (default: 1)
  98844. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  98845. * @param fileName A name for for the downloaded file.
  98846. */
  98847. ScreenshotTools.CreateScreenshotUsingRenderTarget = function (engine, camera, size, successCallback, mimeType, samples, antialiasing, fileName) {
  98848. if (mimeType === void 0) { mimeType = "image/png"; }
  98849. if (samples === void 0) { samples = 1; }
  98850. if (antialiasing === void 0) { antialiasing = false; }
  98851. var width;
  98852. var height;
  98853. //If a precision value is specified
  98854. if (size.precision) {
  98855. width = Math.round(engine.getRenderWidth() * size.precision);
  98856. height = Math.round(width / engine.getAspectRatio(camera));
  98857. size = { width: width, height: height };
  98858. }
  98859. else if (size.width && size.height) {
  98860. width = size.width;
  98861. height = size.height;
  98862. }
  98863. //If passing only width, computing height to keep display canvas ratio.
  98864. else if (size.width && !size.height) {
  98865. width = size.width;
  98866. height = Math.round(width / engine.getAspectRatio(camera));
  98867. size = { width: width, height: height };
  98868. }
  98869. //If passing only height, computing width to keep display canvas ratio.
  98870. else if (size.height && !size.width) {
  98871. height = size.height;
  98872. width = Math.round(height * engine.getAspectRatio(camera));
  98873. size = { width: width, height: height };
  98874. }
  98875. //Assuming here that "size" parameter is a number
  98876. else if (!isNaN(size)) {
  98877. height = size;
  98878. width = size;
  98879. }
  98880. else {
  98881. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Invalid 'size' parameter !");
  98882. return;
  98883. }
  98884. var scene = camera.getScene();
  98885. var previousCamera = null;
  98886. if (scene.activeCamera !== camera) {
  98887. previousCamera = scene.activeCamera;
  98888. scene.activeCamera = camera;
  98889. }
  98890. var renderCanvas = engine.getRenderingCanvas();
  98891. if (!renderCanvas) {
  98892. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("No rendering canvas found !");
  98893. return;
  98894. }
  98895. var originalSize = { width: renderCanvas.width, height: renderCanvas.height };
  98896. engine.setSize(width, height);
  98897. scene.render();
  98898. // At this point size can be a number, or an object (according to engine.prototype.createRenderTargetTexture method)
  98899. 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);
  98900. texture.renderList = null;
  98901. texture.samples = samples;
  98902. if (antialiasing) {
  98903. texture.addPostProcess(new _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_2__["FxaaPostProcess"]('antialiasing', 1.0, scene.activeCamera));
  98904. }
  98905. texture.onAfterRenderObservable.add(function () {
  98906. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].DumpFramebuffer(width, height, engine, successCallback, mimeType, fileName);
  98907. });
  98908. scene.incrementRenderId();
  98909. scene.resetCachedMaterial();
  98910. texture.render(true);
  98911. texture.dispose();
  98912. if (previousCamera) {
  98913. scene.activeCamera = previousCamera;
  98914. }
  98915. engine.setSize(originalSize.width, originalSize.height);
  98916. camera.getProjectionMatrix(true); // Force cache refresh;
  98917. };
  98918. return ScreenshotTools;
  98919. }());
  98920. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].CreateScreenshot = ScreenshotTools.CreateScreenshot;
  98921. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].CreateScreenshotUsingRenderTarget = ScreenshotTools.CreateScreenshotUsingRenderTarget;
  98922. /***/ }),
  98923. /***/ "./Misc/smartArray.ts":
  98924. /*!****************************!*\
  98925. !*** ./Misc/smartArray.ts ***!
  98926. \****************************/
  98927. /*! exports provided: SmartArray, SmartArrayNoDuplicate */
  98928. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98929. "use strict";
  98930. __webpack_require__.r(__webpack_exports__);
  98931. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return SmartArray; });
  98932. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return SmartArrayNoDuplicate; });
  98933. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  98934. /**
  98935. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  98936. */
  98937. var SmartArray = /** @class */ (function () {
  98938. /**
  98939. * Instantiates a Smart Array.
  98940. * @param capacity defines the default capacity of the array.
  98941. */
  98942. function SmartArray(capacity) {
  98943. /**
  98944. * The active length of the array.
  98945. */
  98946. this.length = 0;
  98947. this.data = new Array(capacity);
  98948. this._id = SmartArray._GlobalId++;
  98949. }
  98950. /**
  98951. * Pushes a value at the end of the active data.
  98952. * @param value defines the object to push in the array.
  98953. */
  98954. SmartArray.prototype.push = function (value) {
  98955. this.data[this.length++] = value;
  98956. if (this.length > this.data.length) {
  98957. this.data.length *= 2;
  98958. }
  98959. };
  98960. /**
  98961. * Iterates over the active data and apply the lambda to them.
  98962. * @param func defines the action to apply on each value.
  98963. */
  98964. SmartArray.prototype.forEach = function (func) {
  98965. for (var index = 0; index < this.length; index++) {
  98966. func(this.data[index]);
  98967. }
  98968. };
  98969. /**
  98970. * Sorts the full sets of data.
  98971. * @param compareFn defines the comparison function to apply.
  98972. */
  98973. SmartArray.prototype.sort = function (compareFn) {
  98974. this.data.sort(compareFn);
  98975. };
  98976. /**
  98977. * Resets the active data to an empty array.
  98978. */
  98979. SmartArray.prototype.reset = function () {
  98980. this.length = 0;
  98981. };
  98982. /**
  98983. * Releases all the data from the array as well as the array.
  98984. */
  98985. SmartArray.prototype.dispose = function () {
  98986. this.reset();
  98987. if (this.data) {
  98988. this.data.length = 0;
  98989. this.data = [];
  98990. }
  98991. };
  98992. /**
  98993. * Concats the active data with a given array.
  98994. * @param array defines the data to concatenate with.
  98995. */
  98996. SmartArray.prototype.concat = function (array) {
  98997. if (array.length === 0) {
  98998. return;
  98999. }
  99000. if (this.length + array.length > this.data.length) {
  99001. this.data.length = (this.length + array.length) * 2;
  99002. }
  99003. for (var index = 0; index < array.length; index++) {
  99004. this.data[this.length++] = (array.data || array)[index];
  99005. }
  99006. };
  99007. /**
  99008. * Returns the position of a value in the active data.
  99009. * @param value defines the value to find the index for
  99010. * @returns the index if found in the active data otherwise -1
  99011. */
  99012. SmartArray.prototype.indexOf = function (value) {
  99013. var position = this.data.indexOf(value);
  99014. if (position >= this.length) {
  99015. return -1;
  99016. }
  99017. return position;
  99018. };
  99019. /**
  99020. * Returns whether an element is part of the active data.
  99021. * @param value defines the value to look for
  99022. * @returns true if found in the active data otherwise false
  99023. */
  99024. SmartArray.prototype.contains = function (value) {
  99025. return this.indexOf(value) !== -1;
  99026. };
  99027. // Statics
  99028. SmartArray._GlobalId = 0;
  99029. return SmartArray;
  99030. }());
  99031. /**
  99032. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  99033. * The data in this array can only be present once
  99034. */
  99035. var SmartArrayNoDuplicate = /** @class */ (function (_super) {
  99036. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SmartArrayNoDuplicate, _super);
  99037. function SmartArrayNoDuplicate() {
  99038. var _this = _super !== null && _super.apply(this, arguments) || this;
  99039. _this._duplicateId = 0;
  99040. return _this;
  99041. }
  99042. /**
  99043. * Pushes a value at the end of the active data.
  99044. * THIS DOES NOT PREVENT DUPPLICATE DATA
  99045. * @param value defines the object to push in the array.
  99046. */
  99047. SmartArrayNoDuplicate.prototype.push = function (value) {
  99048. _super.prototype.push.call(this, value);
  99049. if (!value.__smartArrayFlags) {
  99050. value.__smartArrayFlags = {};
  99051. }
  99052. value.__smartArrayFlags[this._id] = this._duplicateId;
  99053. };
  99054. /**
  99055. * Pushes a value at the end of the active data.
  99056. * If the data is already present, it won t be added again
  99057. * @param value defines the object to push in the array.
  99058. * @returns true if added false if it was already present
  99059. */
  99060. SmartArrayNoDuplicate.prototype.pushNoDuplicate = function (value) {
  99061. if (value.__smartArrayFlags && value.__smartArrayFlags[this._id] === this._duplicateId) {
  99062. return false;
  99063. }
  99064. this.push(value);
  99065. return true;
  99066. };
  99067. /**
  99068. * Resets the active data to an empty array.
  99069. */
  99070. SmartArrayNoDuplicate.prototype.reset = function () {
  99071. _super.prototype.reset.call(this);
  99072. this._duplicateId++;
  99073. };
  99074. /**
  99075. * Concats the active data with a given array.
  99076. * This ensures no dupplicate will be present in the result.
  99077. * @param array defines the data to concatenate with.
  99078. */
  99079. SmartArrayNoDuplicate.prototype.concatWithNoDuplicate = function (array) {
  99080. if (array.length === 0) {
  99081. return;
  99082. }
  99083. if (this.length + array.length > this.data.length) {
  99084. this.data.length = (this.length + array.length) * 2;
  99085. }
  99086. for (var index = 0; index < array.length; index++) {
  99087. var item = (array.data || array)[index];
  99088. this.pushNoDuplicate(item);
  99089. }
  99090. };
  99091. return SmartArrayNoDuplicate;
  99092. }(SmartArray));
  99093. /***/ }),
  99094. /***/ "./Misc/stringDictionary.ts":
  99095. /*!**********************************!*\
  99096. !*** ./Misc/stringDictionary.ts ***!
  99097. \**********************************/
  99098. /*! exports provided: StringDictionary */
  99099. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99100. "use strict";
  99101. __webpack_require__.r(__webpack_exports__);
  99102. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return StringDictionary; });
  99103. /**
  99104. * This class implement a typical dictionary using a string as key and the generic type T as value.
  99105. * The underlying implementation relies on an associative array to ensure the best performances.
  99106. * The value can be anything including 'null' but except 'undefined'
  99107. */
  99108. var StringDictionary = /** @class */ (function () {
  99109. function StringDictionary() {
  99110. this._count = 0;
  99111. this._data = {};
  99112. }
  99113. /**
  99114. * This will clear this dictionary and copy the content from the 'source' one.
  99115. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  99116. * @param source the dictionary to take the content from and copy to this dictionary
  99117. */
  99118. StringDictionary.prototype.copyFrom = function (source) {
  99119. var _this = this;
  99120. this.clear();
  99121. source.forEach(function (t, v) { return _this.add(t, v); });
  99122. };
  99123. /**
  99124. * Get a value based from its key
  99125. * @param key the given key to get the matching value from
  99126. * @return the value if found, otherwise undefined is returned
  99127. */
  99128. StringDictionary.prototype.get = function (key) {
  99129. var val = this._data[key];
  99130. if (val !== undefined) {
  99131. return val;
  99132. }
  99133. return undefined;
  99134. };
  99135. /**
  99136. * Get a value from its key or add it if it doesn't exist.
  99137. * This method will ensure you that a given key/data will be present in the dictionary.
  99138. * @param key the given key to get the matching value from
  99139. * @param factory the factory that will create the value if the key is not present in the dictionary.
  99140. * The factory will only be invoked if there's no data for the given key.
  99141. * @return the value corresponding to the key.
  99142. */
  99143. StringDictionary.prototype.getOrAddWithFactory = function (key, factory) {
  99144. var val = this.get(key);
  99145. if (val !== undefined) {
  99146. return val;
  99147. }
  99148. val = factory(key);
  99149. if (val) {
  99150. this.add(key, val);
  99151. }
  99152. return val;
  99153. };
  99154. /**
  99155. * Get a value from its key if present in the dictionary otherwise add it
  99156. * @param key the key to get the value from
  99157. * @param val if there's no such key/value pair in the dictionary add it with this value
  99158. * @return the value corresponding to the key
  99159. */
  99160. StringDictionary.prototype.getOrAdd = function (key, val) {
  99161. var curVal = this.get(key);
  99162. if (curVal !== undefined) {
  99163. return curVal;
  99164. }
  99165. this.add(key, val);
  99166. return val;
  99167. };
  99168. /**
  99169. * Check if there's a given key in the dictionary
  99170. * @param key the key to check for
  99171. * @return true if the key is present, false otherwise
  99172. */
  99173. StringDictionary.prototype.contains = function (key) {
  99174. return this._data[key] !== undefined;
  99175. };
  99176. /**
  99177. * Add a new key and its corresponding value
  99178. * @param key the key to add
  99179. * @param value the value corresponding to the key
  99180. * @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
  99181. */
  99182. StringDictionary.prototype.add = function (key, value) {
  99183. if (this._data[key] !== undefined) {
  99184. return false;
  99185. }
  99186. this._data[key] = value;
  99187. ++this._count;
  99188. return true;
  99189. };
  99190. /**
  99191. * Update a specific value associated to a key
  99192. * @param key defines the key to use
  99193. * @param value defines the value to store
  99194. * @returns true if the value was updated (or false if the key was not found)
  99195. */
  99196. StringDictionary.prototype.set = function (key, value) {
  99197. if (this._data[key] === undefined) {
  99198. return false;
  99199. }
  99200. this._data[key] = value;
  99201. return true;
  99202. };
  99203. /**
  99204. * Get the element of the given key and remove it from the dictionary
  99205. * @param key defines the key to search
  99206. * @returns the value associated with the key or null if not found
  99207. */
  99208. StringDictionary.prototype.getAndRemove = function (key) {
  99209. var val = this.get(key);
  99210. if (val !== undefined) {
  99211. delete this._data[key];
  99212. --this._count;
  99213. return val;
  99214. }
  99215. return null;
  99216. };
  99217. /**
  99218. * Remove a key/value from the dictionary.
  99219. * @param key the key to remove
  99220. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  99221. */
  99222. StringDictionary.prototype.remove = function (key) {
  99223. if (this.contains(key)) {
  99224. delete this._data[key];
  99225. --this._count;
  99226. return true;
  99227. }
  99228. return false;
  99229. };
  99230. /**
  99231. * Clear the whole content of the dictionary
  99232. */
  99233. StringDictionary.prototype.clear = function () {
  99234. this._data = {};
  99235. this._count = 0;
  99236. };
  99237. Object.defineProperty(StringDictionary.prototype, "count", {
  99238. /**
  99239. * Gets the current count
  99240. */
  99241. get: function () {
  99242. return this._count;
  99243. },
  99244. enumerable: true,
  99245. configurable: true
  99246. });
  99247. /**
  99248. * Execute a callback on each key/val of the dictionary.
  99249. * Note that you can remove any element in this dictionary in the callback implementation
  99250. * @param callback the callback to execute on a given key/value pair
  99251. */
  99252. StringDictionary.prototype.forEach = function (callback) {
  99253. for (var cur in this._data) {
  99254. var val = this._data[cur];
  99255. callback(cur, val);
  99256. }
  99257. };
  99258. /**
  99259. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  99260. * If the callback returns null or undefined the method will iterate to the next key/value pair
  99261. * Note that you can remove any element in this dictionary in the callback implementation
  99262. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  99263. * @returns the first item
  99264. */
  99265. StringDictionary.prototype.first = function (callback) {
  99266. for (var cur in this._data) {
  99267. var val = this._data[cur];
  99268. var res = callback(cur, val);
  99269. if (res) {
  99270. return res;
  99271. }
  99272. }
  99273. return null;
  99274. };
  99275. return StringDictionary;
  99276. }());
  99277. /***/ }),
  99278. /***/ "./Misc/tags.ts":
  99279. /*!**********************!*\
  99280. !*** ./Misc/tags.ts ***!
  99281. \**********************/
  99282. /*! exports provided: Tags */
  99283. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99284. "use strict";
  99285. __webpack_require__.r(__webpack_exports__);
  99286. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return Tags; });
  99287. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  99288. /* harmony import */ var _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./andOrNotEvaluator */ "./Misc/andOrNotEvaluator.ts");
  99289. /**
  99290. * Class used to store custom tags
  99291. */
  99292. var Tags = /** @class */ (function () {
  99293. function Tags() {
  99294. }
  99295. /**
  99296. * Adds support for tags on the given object
  99297. * @param obj defines the object to use
  99298. */
  99299. Tags.EnableFor = function (obj) {
  99300. obj._tags = obj._tags || {};
  99301. obj.hasTags = function () {
  99302. return Tags.HasTags(obj);
  99303. };
  99304. obj.addTags = function (tagsString) {
  99305. return Tags.AddTagsTo(obj, tagsString);
  99306. };
  99307. obj.removeTags = function (tagsString) {
  99308. return Tags.RemoveTagsFrom(obj, tagsString);
  99309. };
  99310. obj.matchesTagsQuery = function (tagsQuery) {
  99311. return Tags.MatchesQuery(obj, tagsQuery);
  99312. };
  99313. };
  99314. /**
  99315. * Removes tags support
  99316. * @param obj defines the object to use
  99317. */
  99318. Tags.DisableFor = function (obj) {
  99319. delete obj._tags;
  99320. delete obj.hasTags;
  99321. delete obj.addTags;
  99322. delete obj.removeTags;
  99323. delete obj.matchesTagsQuery;
  99324. };
  99325. /**
  99326. * Gets a boolean indicating if the given object has tags
  99327. * @param obj defines the object to use
  99328. * @returns a boolean
  99329. */
  99330. Tags.HasTags = function (obj) {
  99331. if (!obj._tags) {
  99332. return false;
  99333. }
  99334. return !_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].IsEmpty(obj._tags);
  99335. };
  99336. /**
  99337. * Gets the tags available on a given object
  99338. * @param obj defines the object to use
  99339. * @param asString defines if the tags must be returned as a string instead of an array of strings
  99340. * @returns the tags
  99341. */
  99342. Tags.GetTags = function (obj, asString) {
  99343. if (asString === void 0) { asString = true; }
  99344. if (!obj._tags) {
  99345. return null;
  99346. }
  99347. if (asString) {
  99348. var tagsArray = [];
  99349. for (var tag in obj._tags) {
  99350. if (obj._tags.hasOwnProperty(tag) && obj._tags[tag] === true) {
  99351. tagsArray.push(tag);
  99352. }
  99353. }
  99354. return tagsArray.join(" ");
  99355. }
  99356. else {
  99357. return obj._tags;
  99358. }
  99359. };
  99360. /**
  99361. * Adds tags to an object
  99362. * @param obj defines the object to use
  99363. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  99364. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  99365. */
  99366. Tags.AddTagsTo = function (obj, tagsString) {
  99367. if (!tagsString) {
  99368. return;
  99369. }
  99370. if (typeof tagsString !== "string") {
  99371. return;
  99372. }
  99373. var tags = tagsString.split(" ");
  99374. tags.forEach(function (tag, index, array) {
  99375. Tags._AddTagTo(obj, tag);
  99376. });
  99377. };
  99378. /**
  99379. * @hidden
  99380. */
  99381. Tags._AddTagTo = function (obj, tag) {
  99382. tag = tag.trim();
  99383. if (tag === "" || tag === "true" || tag === "false") {
  99384. return;
  99385. }
  99386. if (tag.match(/[\s]/) || tag.match(/^([!]|([|]|[&]){2})/)) {
  99387. return;
  99388. }
  99389. Tags.EnableFor(obj);
  99390. obj._tags[tag] = true;
  99391. };
  99392. /**
  99393. * Removes specific tags from a specific object
  99394. * @param obj defines the object to use
  99395. * @param tagsString defines the tags to remove
  99396. */
  99397. Tags.RemoveTagsFrom = function (obj, tagsString) {
  99398. if (!Tags.HasTags(obj)) {
  99399. return;
  99400. }
  99401. var tags = tagsString.split(" ");
  99402. for (var t in tags) {
  99403. Tags._RemoveTagFrom(obj, tags[t]);
  99404. }
  99405. };
  99406. /**
  99407. * @hidden
  99408. */
  99409. Tags._RemoveTagFrom = function (obj, tag) {
  99410. delete obj._tags[tag];
  99411. };
  99412. /**
  99413. * Defines if tags hosted on an object match a given query
  99414. * @param obj defines the object to use
  99415. * @param tagsQuery defines the tag query
  99416. * @returns a boolean
  99417. */
  99418. Tags.MatchesQuery = function (obj, tagsQuery) {
  99419. if (tagsQuery === undefined) {
  99420. return true;
  99421. }
  99422. if (tagsQuery === "") {
  99423. return Tags.HasTags(obj);
  99424. }
  99425. return _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_1__["AndOrNotEvaluator"].Eval(tagsQuery, function (r) { return Tags.HasTags(obj) && obj._tags[r]; });
  99426. };
  99427. return Tags;
  99428. }());
  99429. /***/ }),
  99430. /***/ "./Misc/textureTools.ts":
  99431. /*!******************************!*\
  99432. !*** ./Misc/textureTools.ts ***!
  99433. \******************************/
  99434. /*! exports provided: TextureTools */
  99435. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99436. "use strict";
  99437. __webpack_require__.r(__webpack_exports__);
  99438. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return TextureTools; });
  99439. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  99440. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  99441. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  99442. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  99443. /**
  99444. * Class used to host texture specific utilities
  99445. */
  99446. var TextureTools = /** @class */ (function () {
  99447. function TextureTools() {
  99448. }
  99449. /**
  99450. * Uses the GPU to create a copy texture rescaled at a given size
  99451. * @param texture Texture to copy from
  99452. * @param width defines the desired width
  99453. * @param height defines the desired height
  99454. * @param useBilinearMode defines if bilinear mode has to be used
  99455. * @return the generated texture
  99456. */
  99457. TextureTools.CreateResizedCopy = function (texture, width, height, useBilinearMode) {
  99458. if (useBilinearMode === void 0) { useBilinearMode = true; }
  99459. var scene = texture.getScene();
  99460. var engine = scene.getEngine();
  99461. 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);
  99462. rtt.wrapU = texture.wrapU;
  99463. rtt.wrapV = texture.wrapV;
  99464. rtt.uOffset = texture.uOffset;
  99465. rtt.vOffset = texture.vOffset;
  99466. rtt.uScale = texture.uScale;
  99467. rtt.vScale = texture.vScale;
  99468. rtt.uAng = texture.uAng;
  99469. rtt.vAng = texture.vAng;
  99470. rtt.wAng = texture.wAng;
  99471. rtt.coordinatesIndex = texture.coordinatesIndex;
  99472. rtt.level = texture.level;
  99473. rtt.anisotropicFilteringLevel = texture.anisotropicFilteringLevel;
  99474. rtt._texture.isReady = false;
  99475. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  99476. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  99477. 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);
  99478. passPostProcess.getEffect().executeWhenCompiled(function () {
  99479. passPostProcess.onApply = function (effect) {
  99480. effect.setTexture("textureSampler", texture);
  99481. };
  99482. var internalTexture = rtt.getInternalTexture();
  99483. if (internalTexture) {
  99484. scene.postProcessManager.directRender([passPostProcess], internalTexture);
  99485. engine.unBindFramebuffer(internalTexture);
  99486. rtt.disposeFramebufferObjects();
  99487. passPostProcess.dispose();
  99488. internalTexture.isReady = true;
  99489. }
  99490. });
  99491. return rtt;
  99492. };
  99493. /**
  99494. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  99495. * @param scene defines the hosting scene
  99496. * @returns the environment BRDF texture
  99497. */
  99498. TextureTools.GetEnvironmentBRDFTexture = function (scene) {
  99499. if (!scene._environmentBRDFTexture) {
  99500. var texture = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CreateFromBase64String(this._environmentBRDFBase64Texture, "EnvironmentBRDFTexture", scene, true, true, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].BILINEAR_SAMPLINGMODE);
  99501. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  99502. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  99503. scene._environmentBRDFTexture = texture;
  99504. }
  99505. return scene._environmentBRDFTexture;
  99506. };
  99507. TextureTools._environmentBRDFBase64Texture = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAIAAADTED8xAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAEZ3SURBVHhe7b1rm2TLrpW3q/fmfLG52MY3jME2GJuLb2CwDXzx//9H5zyczZCGpFAoLjPmzKzuXqvrfVSaQ0OKyKzKmJVZvfaBj//kL//wh//whz//B8lZdPqvJf6sWeLPXqrI+c/IxXTHWl427dENrAKMk2rudBK2NjlzwVzKO1keyPUkg7sm2PvgcACMAhx2wX7gchVYafBgDJxPAne+2dX5sOsan/i4HM0DZfj6YQawZFxVzKnuhaRFS6CYlqu84nBVMcvkpgtWAvmBAFOx0uTEvKXBqkU9bYGxtSqBl3YD5FZQTV/TQcez9WMszcsNk0rREW4YuRVBVNtWvWnlqAchsneqYI5gucqLQNKvlKdRWrfKMWLgljiPB0t+7rCPQPkDT/0UhI8rHvVTkGbqnNtHFDouuo8u0UrRDUSA4iCQBqeKqalC1qoYW5ZL+TS3ByoZXJpgWoK9D54JcLcLPluDwxa4WdaPQB28S0bcrE3WeVUW/M0dcCzCPbvkyCRTUpTqNAFGMwl7JqW1KZ/m9mZVggMlirkqQ7w9Pm/nnzWGdwD8Yl6/CbQ/fF3Ib7gwkV00P5nm906JNsAAxUG4acNeLvVCyHIVlkfxpixXajAOgE1ZTLAS55Pk8Rj4nhpsyvNJMJQf/+lftqMf535+A2Ax7wHX5iQtOUzXJrysRzwHhnEtJkOf7ui0YS2rvhJynfldnpqHGeQbYGi1DB6U4EUB7nbBrQFwuRYcLgfPJkEp8R5wcQPQxLn02L0JZIFXfWYy7NQOfoQNgGRaFBMp6eyfCFmbytJ9Y+Z10gIPSvB2Ad5lgpUGL46Bx5Ogd/wGwFmc/uKnhojgyVYReXoPdCYjt66imwG57J3uEGd9KTS35cz78jCDwbQHAkNLmJbgmQ9CgNfHwH4S3NXg9RZ4oexuADv3ceizZmBxfhPw3DkM+kmXkNbMj0DKpUUxvfzce+DFDLyU62C2DKZdsB8DtwS42wV7E9zV4PUWeKGUGwAHsZ17iuTIMeU9gJXIGu34MuOldRFOZzJyK8x12AxIZnVc1+FLwexCrqns8tQsGRwMiBzMlsG0BHsfPBPgXSa4q8FhCzybJOuB2Q2AYzpqrIFm4IXUTN05jKTrPZBi05IAmBmcean64T3AjOV9aeLFDHrT7M0MeNEHIcBbuuB8AKw0eDAGPqesN0DWckDdFF+zLGZJgexidBh2LpMT0Z3vWSDlUutFiTQz54K5L2W5ii5PzZLBnQF7ILCeEVbicgCMAtztgmcDYKXBgzHwSgkWA3YDyHH3sx7CTBXi8wQjq2glsgt5acNxf3nKNy3g2maSU8ukpSrmSuTsQq6DeS+DgwGRqTSGMWPvg1sCvMsEdzV4vQX2JTgb6G+AENMbAAugERR4FZOmaAc6TA2bnMXyHmDoE20zWraIMkScrWwWwVxK5liecylLBvdbkliC3AXTErxdgL0JzgfASoMHY+CNJZgNTG4A0UUga7QTr6Id6yS6A+3+5JTHktLlM+sDKZfdzEyL7B0TzCvfsz0fL29kcNwye9oFl+JkEtztgmcDYKXB6y1wqwSXDv9LsJzF1bmPG0NDTgY1BV5Fai/FSdqCk9npY9Pis0TIjGuLXIZW0Q0XwVxK5lS2HZhLGRncaoFUSpp2QRGXA2AjwAMTnA+ArMGDMfB5JRicj7/5l+24x4ef7lOQd+0ca24lNXISdqDD91j5wFqrkAmfUZ39qlXIsIrWYl75OWN5Lg8zuG+aMfjGuwQ47ILzAbDS4PUWeKUEV878BmjnPnyeWmgXkeWoscxORLSKP8SkC/qyzeRW6F7IsIrWYt6Xntty5lyC0i0ZbMretAcC30GAByZYafDiEnA+Cc63IlunuwHyua9mBA6WZmpkO5QsXbeTmmPqA9fzVXkg6ew33Qs7W7nFXMoxq2jLLzO4NMFsxh4F9P5DAe52wd4EKw1eHAOvlODuAHBHbgA5l+UGoEMzujziKF1IpuPCHA0xe4dhw7PoWmBW2nEZ/KmwDekw78shy3XdnWdwsxRZuuBFAd5lgpUGr7fAG0tw7CxvgIlGYI3m5T2QzHrQVz6fikftIvKAaplRkc1OhEbqy9K9bLXH2mRwaYJtaQ8EFgPCagaMAhx2wX4VyBpcriWHLXCrBHcHwMypN0DW7QagifU8xCgpwolbIkLLyWnWWPmMduZyhKPCdlDdidFE6suWp+aQ5bru1gwelCA/EDgR4PEYuNSrAXC5lnxeCe4OgMH5+Jt/tT735R7QLFtontwDSUdMTYQdSgQIrdFaiNxNWqrBbLoIpJnZ8tRMWa6rLrg0wd7XLKn44ESAu13wGRoctsCtEtwdAKMDknlwA3hpJ95zd7JV2MENU6M7zSlWvgTS4Ixa5GAuBdLMPM9t+SaDkxIsfHsUsBgQRvNBF3yGBp9XgktnHADrVe0GyEffboYww8cyaM+tZHAgR4zNwnyQzAjpllaULrqZlWDGcC5znpqzbA8HFgOWwbQEB76k1QAYBZjq80nwigaHLXCrBJ/nAPwN8Lf+avK7P4TouBnoY6OU5UywZIz3gMbUREx8fVqM1k1m0ypkRsXYasKzbejlgyzXVReclOBqwL4pcCLAAxO8S4PPK8G7HDCYww2gQs5xnPvwNeS1gUBWYUcqHJ7IVDZzEUi5bIE0OKOwmeR0gjmVMk+dzPMsadGyDKYl2PvAhT1JcEuAvQnepcFhC9wqwd0B8misuwHkQA9CdNwMOK+aqSnaMXWzHlwNWwiKn8tpN5uhk7AdktMJ5lS2PVeZAsy6cs0O6AeMaQlWoi8llQEQAjwwwbs02JT7SfD6ALhcRbam3ADtd3x5ExiELIsTX8qI0fFY+ngivSPhpq3ysmlmFXWmCOZUyrzrGxmoWC4H0xLcHcD1YEbYm2A6AC7nweES8EoJPs8BUxPwb4Drc0/NwF484tQa0nVtDvLUROgDl1i21LGulxOBNPVD5IwNc7nJYNGStGgJRax8sBUmNzNgb4LLAXC5lhyuAqUEdwfAMwccm3YDyJnGeQ2hOoTk8LELXhgKL5uTop3aFFMTVF+sFmJEGboIpIU/KZEG5yKD3pTromVMu+BYSAoHLMaM/SQ40WBTnk+CfQne5YCnZn8DIMZ3g+xjsWc7bSzzyR6dPuox9WgnMoc7tUvN7KLNMO9LpMGZZLAwRQ5my2BagjvCniQIAR6Y4ESD83I/Ce4OgBMHHI6B7fJ2A8iZRp7eDB75HjDtpTgsU4wOYmICFa3lTi6tq7oJZhcyo8JyKZlTafMgmcsMetPszQyYliAE2HTLo5BxDOxNsNLgsAVeKcG7HHBugoX/8bfjX4Gm576/B/INgGj3gJvj4R4dRD3KEUh9WXRdSMHsQq6ptFzKlOW67hprU54SmXVrCW4JoFrSuitMTXCiwWEL7EtwdwCcOOBFEwz+/AZomsIHpMQWCGgV3T0QB3RqgtFkpNZkuNd1gILZhVxTabmUKcuVGswGWgZDKXLdbRmMAmy6LuQ6dsHeBCsNHoyBUoK7A+DEAYdj4KkvN0D+NR/3QDjNDI3FCBVyHMPR6E72wmGID7KpZZvXctRSZTNnF3JN5SSn0p4JSKZlcGniuu3eE2DWbf39EnCiwWELvFKS0TxxwLkJ7vp2A+BYlzcBxOoewCuhWYJl0ox2gqcOWJvUmxaydFWE02UXck3lPss1O6AfMNalpGkX7H1yYFq1nwQnGhy2wL4EdwfIZ5hg5YOhZTfA5E0g3RXZlC1QIjOy9jCHwyCbfSDlMoYRUrnOPvXJPdBmmEs5ZLlSg9wCuSwmUGEPB7ZjwkaArdkeBbyiwWELlBLcHQCjA85NcGsYHLR2N0DT+a8CrMRZcSGxuQdWDnBtfnJC24s9+BRdlyJnFW3mLE/mwUkJ8JQ0G0WMPlgNk5m2Z0he0WBTlhbYrwXPHHBuklXrrq/4DaCnfLwHQnQaO+LFdjEtxelLUB0GUtInfgg7Ddkfcps5yzYPcgtMS9D7F8vBRoC9CXibkfVMY6XBKyV45oDDMXDXB5sWGLoff+ev/GTv3wSyxi48WK6bsy4ZzQSh+aJGmbRUrpufhB247A9ZrviatWoGMR8ZFLH1JW0HjNUM2WpJqwGwam3GwK0SjA54PAamJrjrg02L+EC6ATTGv4brDYCVzDzNrq3sY3IPIBUHgZR0EdIazBAiR3/Icl13x8xrZ4JpOXPacyYnYqVnplynwyBrcNgau+DuAHk8Ru764FlLkRvATnYc8V5MNDZljiNeyhTmgEszyuyrbucpmZZjYc6l1CzXmV8zUNEelBSx8oEKSVczwijAgbanR1YaHLbIfmCcB5ebkKkJbg2DTQvc79YbIOvlPYCNGFl7XDtIg0MhvusmVNuSMHsh1zDH7EKupUVGk8MqWgbTEgzCvhdwIsBUZxP0M62ariWHLXJ3AIwOODfBygfPWmDfBT5gN4Ac5Tjfg6gaiyNKyUM8dcDeVF39JDYtZLmGuc6yieuLjGtfVhElmM2YnLWMUYATDbQ072rMKC2wGSbPHDA1wV0fbFpg3wXbgckNkHU1sRc1REQp4xAzQHFGU8vQ5oeZxKaFLNcwF1muqy4YTEnZBHeEPGEyCnBugtmMXWct45USnDhgaoJbw2DTAq90yTDz8Z+lP4L3576ZKHGSXIh2IV2QHY96dmn2Jbt2aJKzazG7kGtpDVmu2QH9QMuA8ypaBicClOVgMWZMTZA1SKX9TIJXSvDMAVMT3PXBpgX2XXIyo8xvANPYZTTp8yy6trKP6iD1JYWZXlKIqeKoxexCrqVFUtk2mWbQlzYPpmNgFMB1Ww7OlggnGvBbDoZux74EowMej5GVDzYtsO+CywGyHpMboJ3sLLBmMLFRvQc4lksPe9WvTDGiDI00OF0rlaWLLFdqEN0+t00ig7UpqXcEitEHSdtjgf3k1ARZg6HsjKvhjlKS0TwcA1OTPGuRywFwMhP4cL0BRKNHEQ6F+vkGQNgxZXAtAqjougikvqQQ03XzkXLZi24JBbMK64LS7bOkRUsYSpNlAGwEUC1pMIWpCU408NKupQsW840TB5ybYOWDTQvsu+ByIDibtBugnWwe4t7BXk3HALKGHdNBdw7ITiqp65gLkdlhVtEtGbJcV13gpVwXrZaBCkm9I2wESGazFwONlQbrUmTpgv1ycOKQqX9rONh3weUAOJnJzOY//vPyNwCG8s3gTjM5gMzIWqMrwcZRHSEGdS9WvqS+LFmuow960+zeNIbSZBkAowCDlrQdMFYarEuRpQv2y8HogKkJbg2DTYu8PhCcTyb6GwBb5LOOwEvuursZIFLYwlwCL+dOLl13YxSam8+cSmmlsmS5UoPZAOn2B9vShkEIMJrTLuR0AFz6YNNS2uZkGJg44EWTPGsF75opXC2RG8AOt57g8bhHq2rkFLsSqS8p7NXq/c6kQOrL627KvE5aIM8MpjErJYUD+q4w7QLVZmxnjKzBQdl5ZYCM5uEYWflg0wL7bnA4Rm4NF3Tt+gZAe695WD2ybg4fJsreETmYUmWTOXwvTWi2Vm/mzGtngr5szzYyKCJKyNUM2ZpynQ6DrMFhi6jT2eMMeNEkz1rkcoAcjhVurrIbIJ/s/e/+ZmrYMLULCaRcFkcKCTtGK5PZhVwHk3nTIt2eYFbaDJh1hV5IGltgbyrtscCJBvsSuNM64wx40Qxe6YLLgcLd+ZHZDpMbIOvuZgiTArkc+lUJshOlijqjYhxjlutgMltrnW1PkFsgz7gQki8Mom5IpjqbQEvzpvNgtqRj65gcZ8C5CVY+2XfB5QA5HBt5vND5+C/ij2CcoSLyXZFM02hp2Amelkh9iWyOaoo2M5p0UpbrvrXOkrIJhtLkdAz0QlI4YKqzCVIp32NmupzsS9A7Vo1jYGqCu37w+kDh7vzI8Q5yA8hB54FeicFENq3RnXKWYFGKE6WL0ZFrdlKW6741zbj2ZRVlDPT+VIRM6lTnqi/Wq0ApwejQm/lzE6x8sGkF75qZ8njhFX4D4AH0oI83QNel4AByil2JlDSFOK4pRkdMiiG34SHLddXF1UXxi5C0HRBcyDVMcEfbNbfArRIsnNEW5q7yrBWczAS3hqe8vkPcANgrftNvBHK7MeBDpMhl0yAc11KGTsJWJQdZrmGm3DYcslxHH6ioXTATJrczRgyDps40q965V4KFM9ozK/FKN3M+Se7Ov0L/WB9/l38DwE2HeyI0S+DFdlM0hEfWUmL7KFWX891OcAikXLqQa5TAddthyHKlBsPApAsGYfuDk2H7ck404bMNysC+BKMD3KzN6XCw75KTGXI+ueL1Ha64uAGQRYegGfcDMnzNTYNcJqd0RWbHhcjsaG6TfV75yLxOWqB0wUyczDRiHvR+I2uQSpNlAKyXGKMDkln70/lg3wWXA1Oerbrk5W3lBmgHOp3s/blvJkAJ7ZG1lDpggeRi4yCLqcKyimp6nvjgqiXXwXk2I6g2Y/Ab65ZUZRg8c0Aya386H+y7weHYyOOFn4PdAHhacaab0NxEmmlaQwZSWAmmpYulg9SX0RWfZZ/NB6vWdCC6pMwAFZIWLSPp+YZk0wL8OWRmM5XRIb3fVaslweVAcD654S2bPOXgBtiYyB5Zg2UphZYqJg4zT0MqTSAlHZnXYjLL1dp9C6iYDJBkmlx0G6onw2AY63CndcYZsF5Y6f2uWi3JnMwEt4bv8nmbf8jmH/9l/htAM7Q4IfrWRHsghZaSwk0pXcvVReekElmuqWQ2s2RcR9OzjWQTJNENgBDAte1PtpNgPkxKCXpHqnEGnJtg8JuxWjJyPhk8WPJDkRsgn+l64metpjmJbajhu7AytUS6oCMyO0h9iSyOipzlOvq4jua0BQZhAyAE6E2r9pNgOkxKCQanPZPC1L8z3LzVqpHzyRWv7/CZ2A2AZ8kzvf+VP78HoF00DbIfpYqJwwynL+UaZcpyzQ5QMRkGuQVmXbsOppDMZk8HQNLtEUkpwcIZ7Zm1MMHCb/Zq4Yq788945VHweeYR9QaYHvdwum6Y1BFIqRQtlgaSi7mjWa692TZJWa7ZASq6YZBKSdMuiIF2UYZJuU4HwKCbkVuglCSZy4WZVWu9xDqbPTc8W/Vz8/Ffrf4GCKdvdWNhloPO0p2spXRRnZTbbp5HR8aSNlTYMMhdtlwIMxEyqapPZrprboFSksEUYzpJHrVaZ7P8hBeX/0D69wq5AexMI1b3wOgUE0DT9xB71DGpojl9KSnplYMs1+wAFTYMhq7JMgBU1C4YtKRsgvV8GRzqmQPGhZld76Jrzf0OD3j7hoc8/fBD9AbAU/eDzgwnjnvTyYwxMTV3GmQ/ShV08iRzG/BcHcxECdyfmpZSKbjodgYhADckvd9YzYDZkuUwGB0wLszM3cR2oDUv93mdw4d47RC/wsd/jY9AeJar3/R0XJjZd22AgRSavlgaSC6s68IcpKSb05typQYbEyyGiT0WGEXukly6luvBGKkbkgOzjkyXZC4HYuRg8vfA9u5qNwB+HJujP74J5K5pEJqB5MJaLui0VZ7zPhRyDVNzc8DGBPRVtAxUSOodI7rtomQNYnMwtDq07LwyEAy+Gav5kYPJNnK+7U/O438Fwg2An8Kto29nuh8D5muIMdM2Fs5QIss1TM07B2RTRcug+OCkBaJL+lYgsptbls0uA8HCtx/RCceTNni+8w/k7R+Q0oZ2A9ix7s/05uiHkC61hmmw1pK2JbJczx2QTRWGC3kI4pNGLAFlRhGZSmEoO2M7LFUZIFOTaGvTbxwNGW32zqrP5TMP+oqP/2b8COSi3gA6Zod1cw9g171WMS9TvucAF3bWVz7YtMCgm5FbIJUiSxfM5uvUuCrj3f3UVXtOt+jRDke8/VhPefoocgPgmy+/48ejHwOi1ZncA0Ad87WsWgXzvpSUHYAZzdTM1swmri7CoZB00gJZo+rL0hXimZDZQNDkOBYMrfnsZocr3rzh9zno4JUHGtbaDVCP/uw3/SiQm8aVmqbUXoZGctFK6lJ6njguIvPambi6CIdCUjggdZs9G7BrbpEyANYzQXt6I+vW7iEecb1NTHy385158UEPln/8t/mfQe8LZNMappHClEJLFaIppiVS0lOH1zxQTaBCUu8Ii2Fij0WyBrEwqHW/nIwOGLcic7dh/auxc96305t4fOKfLfzQGwA/Bv7il9fvRKgO0UwKMGi5uuhamuUaTi6BijJvqTd59YsJSb0jxDBoyrSkbAIv7Vq6pMyA6RgYJ8FqeMB+FO/j3fud8fr7yYMdZku6G2AukOOU5+Me90DWSGH2GllKFZJCl1KzXLMzDFjKJq592cbapQkbJkmvfIFPLFNrQbyZP5pmTIdHfOxw/JD37nbBK+f+TSe+8PH3Vh+B8GLvbwbVMSwa+6kWc6bl6kJamqklJT12zVERWVIq5eoiHAiT4QDVkgbTrtkHqTRZBoibtTkdBvHcNgwT10tu8vYNO77nob81r8NyA8jLMD3WlzcDIt8DYSKFGVqUhEgvs64lU3Q185pNSamUq4twIEJm01MyQfZBboHSJbUWzJu1jOlWmXVvt+o+793NeHzuP//QZ7obQARy3AzprhgHolXvAexKIaqadFoLKWlpJS2JGuQBFZElpVKuLoStCdHsPFDmQena14K8bWFoTCY3OzsHIzd4z24/4aG/mvz47/gRCC9YHOv+rLM7+k33XWBmEjLgorVY9lomk5ZEDfKAisiSzF06dg0TnPjtklBntItVByYLjNZZzxSOB494abef7dzfuT3kBsB3L4ds/cmnlM0pXReisXuYoSlmZddCoga5TKbJ5EtKA5bCAWG2ixK7gdU86QrBjMEPpLPuNvJzOObBkhVPtvo+5/7OaT4lTdoNIC9APs1+D0h+dg8gDcIGVDDLdaYlJS3XvoQwmXxJacBTMkEsBMm3/UnWrHpHcGfsGJcD5HBsxoMlG27s9tlH/8H+J0tmMx9/f/wIhJyOdSlFlHsAkd80kAG1C7m6mPgsQ4OhJde+hDB54oCm0gMB13bdtEDuKp0xdMHMuzO5RZbkZY+P5uGjP9v/7qrD+XeMyQ2Ab10OxOrj/lBOnc7ExjSRNO/8tZbrtoQwuXEgkw5frtkHsRaUFozBiZmxU5CByyFlPrVdu2vePHkXz/HuOQ7OF55MHu52OaYDdgMgeHzlZU5lOKf3QBaA2oVcR19z07i6yWz2tAQnDmTSgpbjGKiTwJ3WGWY2LbKwK5f7jBwNnh2a660OD19wPn92Xq+5uc/Hf+8fgeIdoJThTO4B5P62aRrJhZkqRFNoXmlLuaWCuSvB6ECmbrumASEWkjzZLokyH6g7byUmA7M1l/uM3F6yOCUX+xweQXI+fPPIznk6IzcAvm85Luko29k9vAcQadJMkIQkdrWUq5fdjIuuBWIJYanCCAe4asuB6nEGdGMk70a87vxh4bhTQ3u7gcThWHB3XlicmOVWJycsOBx+emo7Xhv4+AfxRzByuQf63+7mr+6BJJpGciGm5uaznGowlCJLqSIoa+2aBqBz1Y21iyFV75D2KCNl/4F9Nzgcy9xesjgWy31ODit449jlzDsG5AbANy0vKnJ/uCW/eA8ACM16aWbzNTeNq5skl5LchwgZyoaJajOS382QvBXJa0newa7OpjVwOUAOx4K786vDMd/n5LyCk7G3zLxvwG4AhByL4888HB79TiNlIRcJkV7ONa5uknmpNB1d+1JUWBXmzAFS9Q6YmiA/h8K8k1yT2xdpvf2S20sWT2Cyz+V5At9tZj9ws/vxD+OPYBzBO7/vy6rsmAYQmvVyYVrykle/dGNydSGMw/blxADR4sQhRz5xa9JK7LvB9Vj/ch5u21iclck++1MFLgfA65vsBx4tlxsA37GcJ0T5hyAX1/fAIJpG0mwmRTanGnBYBXNX5kkQXaCqDINuHuQlTp1xlr59TVjYxr4bHI4J+uremCezM1E3eXSwKi9u8mnLP/6H/Ecw4uk9kHUTeIQsNO9MRZYTFbk0GZP2pUQXqCqlXZsrWJXMJqeTgdbVTGxa5HIAnMxk/nx5UAqL+e5xXzx8YD/wqcuvNpcbAN8uj6zk9CmIedU9EkiazVEhKUzNc63Cri4mLfsy2iSIYaJFc1ztZhJizhoTz63pPpk2sH6dLjcpyPzlkQoWk92DvnbCfuTyg+7H/9i/A5Tf9My1HP5W7gR2nTpIdLQMM+tqqrCri0nLvow2qZSyLQ9GJ/YrW9m1Uh8ise4Iy27/yu03Kdjw/rUPFmPdIx4cox2Pl3/ezsC7cgPg2+XRtHxyD9wSSJrF0XytVViy2jcB/Uy75tI1KCWYO8RV3zfMHHrTYbJpgX1X+DiY6bH5ywME1jPtQd9xzuZsuvuF4E1rP/6n8g6APP5jaF9e+p3Ag2ShObSMFQ3yMK+hywxRZWVMdpdagibLTGJcBcYxsvJBe9oZfxk2CwObuXxplbbhyfxi5nSTTfeTFoL3PajcAPheeV4tz94BmEex8k2ALDQXHd2qXcjVBWiamxBVpyXIax1z+sY4Bqrp9XQYrHxi3e0r1+1weT7y/OXwYuB0h033t7DQbgCEHKzIdz4FlVIENp46SJqLjq5pFZas9mFlpdtyUsoyLP18Eco8GcfAbnLGpgW67uJVrDtsX+w2vD8TYD1gm+x32HQ/Y+HjPcGs+/GPxncA5kd/CSDlsgkkzUXLlY4LM1VYstpXKSvdljtdV/r5UodBmScz74ZJNi0w6fYv2OVAphveHwuwGLBN9ss33e/ZAo+6dgMg5IUv+fweAIsxEdqVpLno6JoOYYVPKivd1ipdS5r50k2CMgwGQxhNcWaj0+VA/PWLtFqVl8xnFnu24f3JILMZ22G/fNP9ni3wqPvxj1fvAJrLfxczkwLXXM4EEsumkTRPHJBNF3KNgbUGXau7xFXhoyRK11PH6ICpCe76fHmWXbAfmL263fD+cIDNDvu1m+6q9fYNyaOFH//z+K9AfX5WgrkjF63ohPCWpV7I1QXotH0ZtRXwQROtVFW64MQB5ya5aF29xpvl49pueL8zmA2cPKUlq9bbNySPFsoNgO9Szs063y6x8crRR20OEq3UkmRF8rNZtH0ZJvWSbGE+6bTSVRkAowOqqT/u6SRY+aR1F6+ZDBy/0tMntmTWtR2OH7Hje7bAo4Uf/+TmO8DUbAKp+GK5o9ocpOyokGRFE20gmxyP4e7S5kFeAvrqogtOHHBq6isxHQ667uyVs4HVi5r81RNYMnQvHgu8vQVW3WeryKIrNwC+SzkH67wvm4n9iq9OHUCKll5zS66DaJMgaRExbFdTrQw9TirLcjGPH2V1xhnnwp+9KpMl/Vg3sHrV3b/crWNoteVXDzThWQt8xz0//pe3vAMg5ZJC3ORHSaFXE1Z4N0SMgYU24fV8PvvKcpWyL8loNif9rKdrQfX7l2e+arXt6oVX/3KryuaZbB9ozhuXkHcvlBsA32U7pn0+amGbXGoWj4KOzlC0UjPpzKkAKy1Vu5z44JUSjA6Ym4sf/XSYr9O8RVYD00fZ/NG8eFZCanXLV0vOtqo82A08eywyG/j4X9fvAFOztrDHYIo3K8XReXMUE2wthKdkKrEJaLLM2FXIM54at0rQHP/JjjOk89PLsJoHF//L/unJXiyZb7XZv2+tnnzH8W6NB0vI44VgGJAbAN8iD2g7pgdZBDbIZTLnZcxT6LUKLcaWp2Qqor0+9RObFtgMk7kz/JTHMWH7b5rWWr+iyztk+ujT4fXmuVWf5AtbVVatzRLwSpekmY9/evBH8JhFYPXWjNIcXLMvtQq29sIvoU0okwGl06nIPlgtAaUEnaM/x4sZsBgj4i9es7ZkNmDd6drePJ/s8FZ95qslB1tNeLAb2HfB8cDHP7v6I3jMJnBdm7V0QVOEZktXwq5h6sU7QqdTsZyxq5A12JdgOZB+6PNVs1dlupx0m9xcK4zP52qsw/3uaZCrJRMetDZLyH7gcjn40BsA32I7nVfZBK5jqzdbKcp91RRW7oV9CaHdaGMgyaT56M6JBvPSf6ClCybO7Kffxvput3zTAscLDTdXD91YL6/Pgdzah7y9RfYDV8s//vmdd4BWYmlpIaVSjChVU3TDcmHl5UyAZtqXrSJL07mrwY1Sf8RlAJjTvwDjQjCu3bVA2nO6YYeadZ/1ZOXlf0fq2CwBDzYMnu788S/0BpATNstTE6k41VRtJa6qQ9AUodnSKPRiAtJVnVHGMTAdACcaWOk/u3nXKcOkm9FWWWWsDtl2Cand/gkY033WkwVZOB0GKx88a4HPWEhmA3ID4FtsR/Mk4zo40wEpozUTVorBr17oxQSkq7EF2phdhU6nosn+8GUNli39UW6GpwPC4qyLuXj99v/aM32IKaf/GDob2zw94Xu2wCtd0A98/G/3/whGCm0C10FLGZNJWJfCcyfsqxdKN6OEA5ppV+G5Hg7rvEw/0DIAxmM3riLiz168lS+oPz7ovX0OzNVz7th0V63HG4JXusAHPv737UegScYi11OT2kpci8nJvrTEUuFaEfa1aCkmyphdhanOJn4cl/PC1S0xDgBx+tejzSR/ahJrLV7Uw/8gsNvkymzPjaweEaxaD5aQxwvB5QBGcAPg+7Nj2ufRFIFFpVUcXFWHEJkEZ1qp2VIIZF4GH8wd54EJsgZS+o9v0gJnXdAGzk1wNZw5uQdWmzfWm3RryWoYvL0FXumC9cDH/3H3IxCuG8e1lFL0JsW0VORKR1Lv68WNJEJl065NZD018TOa+0o+YaVVFoKu1IWXS1ZjQWvNXkvpznzDW93+q/np/neGjbe3XuySYebj/0w3QIhdxqKNo9pKXLPZl8X0yhaK8Iv5mqMEVehl2VXihexMuwpNb471qpV+uHVgfG3GewAsTFD9fsPWHR+ITDcB0/nBlIXbnedsWuAzFpLLAeAzcgPg+7Oj2eepCVaOlFL0Y8lZlpo9eddLG1DmA0mA0dx3gWj/iUyGtZV9kJeArjs7x2UejA6YmnTqnutHX3HvF/l0/1s7kE0LPF4IXh/AyP/lN4CcqpOM68YJLSo5Q9nMlC2xVEwMzsono9l1/ecyXQJEr2bSz7S11MyToJy2MkzMHCd7h8yPr5vl0YVhfrWzcGvz7fCcx939QvLCzMe/XPwNMDUlY9HGCY1rcqzcmJ5F2BeTZdANKN0At3W6Gf3mO8dpuv+13en0s1vNAykXk6Sb75+SMI6l3UDZv7C/Pchq58Zik+55kls7BJ/XJSczII19/KurfwatJq4rR1Snaytla/XZuuzTl2QZFB9MBpzR7IT/FCZLVjeDLula/U88lpOyEOS1426bhWTlA2kNppH8zQ7GzF9ufmeTjs3A5VrwrhlM4QbA92fH1HMpu4xrMcVqLa0XrT63gZQ9zUqlE2kAUEQJSgs/lOooovXnVU0w+v1PdjWWH8uY/Sqd/OZe/8YdNwxaa9wQuLnZoaP3DzefsGmBV7qZk8nFzMf/vf0bYGqCzpG694uTs3ebqV8TU2ldhaKU4HIATIbTD6Xrut8tH4fVyTNwurJfRSYOvnoz75+Z3i1Be+hxjKxvrTneqqvW+y/ZtMC+Cy4HgsNJH/v418PfAKWctLAut3AtfnGGLGmRQ3hlonVTBisx+kC0fudjd3ozYLguB/0OZQaUYyrdcfPFwwXjGJncA0DN8jTGtWC+HKx8ML1twKOtrrmcOdmEHEx+/Jur/w4wMbEuOa3EtQzQ8dxaJZcBL6mBNw0RPglWIl7scQCI1oHaPTBBPeWpzEtAKUHbZ9hWGM315o2z3+7L5cGsJatuLhEeLClcjh3uEwzzH//P7I/gUtYWZDal7v3iTLN+5dyZuPJinS6DaQmOBvSnEA4YzXBAmxzfEMrMbAnIq8omwuzsTn5Vz7bKSGtcBZI5PvSccedgtQSc7TbhcgCczJDzScz+v/0NECLniYkUZWhRySm+GEM3sn1NhkUMGRQx99PZWg2YcMb3jbwJWP2yX82D+naBrysHzM3ByTP2uOMMULM8MWM6D9yfrFotIZvufiF510ywHpYbAN+fHDXNIS5KXHvdmaI8hy/V0BXbuiG6lmbQWkrX9QM3745ielekn5GYWnZjPmBmPwD2p3xSgpsO2dwDtoSMY8pkOVn5myVk0328sHA5eb5VoEs+/r/FvwLtS9BMKZrZHJabbF9tXq6DA6yVMjgt9fssPpi3egfEa2/megDMZ/YlOHaI+ckxhnceYRhbLg9WS8idhR37LrgcIIdj4GDy498ON4CI9P8tgHzzpcuM6zhD8zLrV8vZwVUvWYsYMpiUw2/3Uo4DoJ7y0dFy7ILpQC37JcJwWMcBUGYmZr/KWmUr4uZ0zzmrJWSzEOy74PWB4HwS9MMf/278Z1D9/xhGRPi45pJdcb0MjWuUm4yrXjon6+gqucwZ8Ny0MmUgYnri8TVbWIfLTPrZxTyIgbwclDNdS3xtB8DogInpTn70srkx3HiN6bwyPtXKvks+e4fM8eTHvy//DJp/92cBWXyxmu7MPksrspuWszPTnpYZTMrh0Fs59fWH1fm9U1f5D7eZ6cedB8BkflGCE4fkbTPTG6ZMrvZsTB8us1kL9l1yOXOySXBrGKT5b9BjgOJ8/Fly5+tPpZpe5lyCJr4u9Yd8tXKagZW4RLgpqGPd8FnSd6M6WmrDSV1raYgXWgrFHYOtddmCqF7OLEyze9OYmqD4iExpMTKlhSiULiNTWoyRMpBjSpnJkehvAD3lOUArU7fzvWSemjm30BdsEu5zHl88B82JHC2tc8tMXwVYWliSS/jVsdQ5Qu5SaylE6U57ULItyzMU9k6Y4Jm58RlB8SMKpYsolC5ipAww9pRhxB4fm78DjGFLyh3ibwLFN7MPmpL10jn61fm4+Ils2Q9iy8p8QMmmlcgs85g7NkF6p62SwoOkh5Aquu5EaYaXxqrcOCCb4U9NcGlmH5QWIlNaOQqlixgpA4gVZSzHijIW4dgNAFaiBD4Pmih+NvsZ5giWlv1MWNZL18WFOft9lotG1xpNllp3pTqkrXIzHKPX3XLqsaQzK28sJ6OZnTDBiZ/Jfm4VnzFSBiIypRUxUgYiNpTJiD14Cf7/+C/B+uevCM0bAVophZZFRMY1Ccn6Zc5QWh6ds4xvqZr6U8glNTDTf0zN3ztpQ7D6C9gG+uH86EIp+93I6NQ9SXncYNyQl3FbMvPbnqtVhfeOBXfng/XC049AOfDzaKX+bMwPM0UxWeIrtISWDJr44m9HydlfZZ+3EllLLhdSaV48RF967TqcrIGXZnhprEtJqTTcMc/LqdO4NF/xQWkhCqUbMVIGGBvKJGNDmSyx5skNIKH3ACgOgz5zMUvZsl7YYrCUrPVF5iS/GJa6AYFl1KtSHRNpoDlWe7BKZdMcTqWh2sYIdZRg49wysw9O/NICpYsolG6OFWUsYkUZizihLNGwG+BbZ3rgTEeUVh+Lzc1nLiZe+FxK1lqyOhEsrzMufi4ls9SaZR44LA3qqcMql1mDUoLiRHnLAecmyH5urXxyq4tYUcZyrChjEXvKcIkZ63eAcujH2yDK5IMicsncTD1wrYysdeRSLrNc03LVgpYhpRU9bR2W3HbqGOwm7UUq1ZGUSuOWE2Z2wgQrH6x8kFt3u6AMROwpw4w9ZTjiHF/iN8DqcPcRn/5jhxCr6Aa0zia+cmnmkCNYTjLPpZ9O8+kkbWUMa0su29LWEu+a45qPGyWJBxXNr+QIMyevEqIMB4wOCHPjn7eAmvJX+LrbxYoyVmJDmYzYUCZX4dR3APkstDj9Frkbmn8Ka9n9iZxCBqaln57OTKVkrW1ymjnGHD6dXutFUV1bLENrGZrDJuikrhZCW05WpTv14UDvmN2bxqWZfbBpgVe6pMwwLinzEZeUecRN5AaY/wGwif0d4gGK2JValNxKufqkC8vDKvOR6Wy1XKLkcm1MS4usWYIYTs6uBMWJMhxw35SnkXHfovBKF5QBxJ4yHHFCWcJ4QL/D8DfA2eHOv/ubmWPml0ePMkQumUuJL7zAPGqWo4WcfLNA6ORL4qRr+iKpp2VszqQ6HJYt6KVSkpfiE3ca4WxNu/amEWbxQW7d7YLLgUwZRlxS5nMcUlaN0fMt//qfaxzls7sCrEQLvPbJD1FKCmaeIcthUuSWWvSrSc2Oai8spPIlRi5VcCtqi7EEqrtHAaty44BLc+Vnsl9aYN8FlwNBmURsKJMR55SFETdZ/ysQIh996nwnuLYP/TnnUAewHEUpTegZ4jHKvmSa7A6m1LqkM9XeaL0oqtkyn7u5pqS2MUi2ksOyBSklcKd5LOkHLIsJ7vogty67iA2Hk2WMcU5ZGPGMskn+CJT//M26xso/D32Bo7RnpQVbIsKnCF9rmlZmM8p+0pyiY3LQFkhJj6Xpseyd5aqNAy7NE58ctsZupkwiVhyOZcqSHK9QtkIM2A2QP/xIpFM++VwU3YObBMyFFsgmcsuFZA5kX5X4LPWLZilbJlp2AgyaVWwopP2FXFJECbysjzuYtkk4IJxLE6x8kFulu2llyhhiw/kkKMOMFym7RRyg/wrUn+N6M0yjHP3hTgDFuRd6Pnhc6OArO61EFm9SivKQ0k2VC63CXTWpQS5VS6mV+b3TgmQnTHBm2nXwjeyXFti0SB5gOPV/WgfKJGLPreGRsnwaj8FHoHLcpUyn2UqGm11kfzXjoY94JfQw7Rx1WQIrvV6WblJLSFG1yaTpW+maMpdClIPDhzbctAimJrjrg9wau+RygOQxxp4yjDikrIp4I2VnBN8BLP5cf/fXmyHdBqX1StgT0wK5OXrpHHW7lvamJR2RoRmKmUWrcLdpSa4Fai/Lzq0bDrg0/ckIvd+x8sGmRfLAagYcjoEyyTikrEK8hbJniRntbwA7/Ysjbt3eZJRPUOMAKA6imXo6i4kvmuaoO2mpZktrK0XSp+ZXDNMctciJtgKklvmpZcPhhWO16WqCcIoPNi2waYHcnQ4ED8b2k4WyEPGMsskY95GPQO1weyxPP8to5bM+nPtpgFbqabgw1WWLFxGqpUXJNlvqs2Vr2S2lOiaowV5z/yiZqLU07jjx3Az3Jy2QuhaFfTcoY4gVh2NBmY+4S1ke8XbG/xJs98P69FucHfdl8AVOjuhi6oVaxKBFqlavzbMOX3teqraSw6GlsK42TNhCL1X1mtfeaeXGISsf5NZlF7EizUz+78sKafiCPMl4RtkE8UbKziVwvEPL0R+OtX3uTzF/N2DOYhV6pKqJSCa+ogwtJC1ClYzJVxKc4YAoF6qjjK61aNJImr4XpqOyltflgQR3shdm7/Z+aYF9l5QZxoYyidhzPrki78C4RVl7GVfYR6DuWOshnt8P3pWY/tG8CT1zECBM0cW/1DpPRKhugl8cplDfRCpzV5I7Wii9tuVeMkoZcBjRPHeSpax8kFtjl5zMBGUYsUX+DfTOfEdZGHGXF5df4e8A6azL0e+dZjL8DrFyH3p0JIrPyL5edhoZFzdNF+HaBL90uUj6Q8lakm8iOTtEW+oqpQQnDghz45cWKQOIge7/gL3EhjIZcc7jhSPv2ueA7l+BulOewj4IFQciZVmYZqb71IiD6NrK0Hr4QjPJcaTWbhZZm+ByCs64L5FKMwn16ASxGynLAcvsADeLHf6EaK0GgjKJWFHGGLcoaxkPKDtEfAblITyGfwXqzzQOevsgBOG+OR5Hxz2Hnpgo8ZV9e7ZxUGJYvrylvRCd7k1ZwKTaOpxJJaOZ7lgo1vWydIXRAXuz+GDTInkgYkUZQ1xS5sd4QNmB8RbKnqtYkP4VSD/T57CboY/uftAsk32MThd6wpqOMglczFEBosuaXcIxVT4v7c5U1wVnpJ6XrCX52tjBSKVcWarjdmc2piYIf2yB3J0OBGUSsacMM16nbIh4L+/buf0R3E6tn2wrNbqZ1KqrsuPROX7aQjPwZdpF50itDk02Zi1tMzUtxCQk26mVy+haTbI5+hmfaXY4zVLCdL/r00/dOXlsP0mO5yf/KyBSdpjG65QNS7yP/r8D9Cfbgp+CGDHp3ezQLE4XeiwQMuZahGrQmVJLWDlzdM3QWmhBh02yndZaKOzGTCP5sZXAsZmTPcH9OfsuiIFbYxG3KGsZ76VsHvG96N4BWsRZ7w89yzbQj8G3MoWZelzCxJfpLKSRJr2lXzuHRWuphdaopaJQ34RqM1iyID5j2VyFkwxLndOx8kG0pl1wOQDyzGZsz1s2yZQNx/j+9I/bvwMg8olP2m4MRB7ou8VEmKnnpkWUMwGag+xCLltH3eaQom2AX1ylWMvrVrrTyhyZqQlWPti0yH4gupuZKWVhjgeUHUr8QMoziSBezt4B+Ndw/pu4HHqWmiddDS4UreesRZQrwWLmS0uf+uiImR2w0CKSb8GqlPxKjhGmR3sgRaroFsIfW2Q/sO9OSUvs/4WfV0i7Wfw8PHpiwztACRzuOO5+0O2uiCPeR+fzXIb2Eo/azNxKvqBF8aXDQkW0zMHVTS26JdA0m4bUUqKU6tAuZtD5OQorn0T3cuCEGD5fMqXsw/ixlCdT4hH6DqB/5lrwBFNEGaFOedwIzjRHT96o7fTrEexaU589oKL5LqIlVzhmiWMD0S1aLzGfuwbLZMqVSzzPYSvHlMPuaiDIk5fDI2W5xvX/Zu4V+se6EZ/A4j+EbSLeELTMN4kNMPTwZW1j9KMbZfbXpVyAitKSLnFTGzS0q1pKas5I7cGkuu1GOFBMEH6OPfuxfTeIscvJkbz2wfK7lIdD/EzYR6A4xBL+619ayBpiprMeweU19GwhZAZ/Z3DSz2V0dyXyqnQhFxAidYsZGkLKwFvmeRnY2t40Z/TD8G5bnsNHGkN3zuHYlFfW3iI/EOPnZvYfwhB6+pe/3f3XfxMeMV9X8dSOInIpNcsFsEy+iXDc5LCEO2YClq5ZWqWlOGY0x8q4JLMjWquBkfP5w7FCrHqwdqTstonfFuX/KD6f3ey34I2xDpnRk2RBHU6U2U8mn1NkmiJlQhzLIDsu6lZAu7aJl7zy0iYBu9kBbhY7fDZqF6QBeZQSe84nM89WTclbvb7bd6M87cvAoZWPNzy++iFHjjh/r9NX08LHbHmIHHpQOh3OptSMr9GUfCy0kO9KUN0MV3Kl1tLQHVzaxcZ6aMYwaJLzETPEzjOrOMD+pwr9quX/fuGEfqufjvz0VnGf9hGIO8QpZ46dJaYnPpYg/ON+aBwUG6OIXEo8kdxixIAKgcVegFiu2pUg+7gGVibHyuSYHHxw3QLRjXgL93eb3xuxT9rqpbvodfJTyvE5+Eeg+AWfHhERZo1xPg5r0jaTb4bIpVwMaCFPtPhNRCuZukDDYavRlyJ1PjwTajY3CH9sgX33MW/ZNm/yyj63KA+6j++L/CuQHVM+gfRRh1l+8cfv/sWbAI9d1RSeZbfeiUDdTM+qvMxdtojVSYCkbW1p6T4Gu61WfCwwOfiNaE27I3n+MB7zlk1ukR/xuz3oI7qPQN2hh6PZBtKv/F3EpyAe1iGvfMkReF7ZVKGu5qFlYqYbdNvVlGlF5ltbMDn4jU2rEJOH86/wPR+LfP9HfBN6A/Cg+xEXncowl+8D+cwlYTcDzZR394BmXEoJpAxfHS1UgJUGXtqVF3fs4g658MHQmhNjl5Mr8g4RI5cDn8H3f8RPoL0DMHC4850gZz2/D4wRv/KTIwtT5kx2NhmI1lK/WilddczUKrrqtgFBS3pi28Ww3dxpnd7vUF8W7tnssCFW5ZhSZhDvY/cX8Kc96A/E/gjmoZfTr4fYDn28CYRwbT+EdLxMa7a7IjnIsgpaQ1qzACI045KXy0WTOGpqIabgZhvw0l3OKdrN5LG+I8gwY4PPlJ0v8FUSn8nzf9j5Xs/wR9H/DZBFPuiI/mMPJ1v4iUe2k6e53gN9OckuQJT61Qa8YFKHJsgaTEvuGbg5YjvPWsDs7cyEmL+16nv+0+TTZ/gboHxrGjiTfoh54pE1OEBtAz5jwUOPMZ5Fz2yFI2MQjGF4kvsSl/D5PVgrvh9eR1+Uo2W1vWgONf3sFmJgM5O5O38X3/zh/4TTl1v81infSykH7B0AXcl+vlm2464i9pFI58lmNKLF2yPOZdwSYcZdgYYIPBfNzRGriTamWkq9+kVJvgSXxCSJtldG74/I0xgGclWXzuZfIjYskSmtk/iNUr6LiEwpZ9Q/ghFYJWI49DHQRf8rfywpLEdks28BmlOBS9ZS8spLUEoymFLRVD83TevDxcCK1ozh7fwpebe3bPhb5xN+Gn4D6L/2QMRHoKY5oDMmeMoxwPOnuZhy9LMYb4ZVVoGvpRg0lV29bNAZTOxQzWC6ZEUMH85vyFu9vtt9fvD/CGLKJ/9A9F+B4mSn4z43EXryKMRMWVobEaXmEiCyBMsipG1dHe00w6/JLORVCXE4P/am3BreEPvc2epnPKmvk38UEZ9M9xEIDyfH3d8NwpTgP4zOgucJOW6DLKKVy0lOJb4g5BqCX+yqtsmiCSfVbEGnTJIYciYzDnYow0+ITfp98rH+fR7xIP8EIn4E7SOQhT4TmpNDrye7CT1PVvLADUKyO11OPpCspWXOuKBpwn3qIAY66BSTpNa034jJi7ktb9nk+5CfaolnlE0QPw12A+ApUUjwNuCbAHMJPf08iKJZuqaILoXkEmrikssi2JWrTqqhuK9SvxjtmlUP/dSaTgl8FG0vZ/ZwuW/yo9i9meRnGLGhTCKmnMz8HHQfgeQc59MfwdIPOsMcPak4KKElU3uYo2McnmQV+IKQq7i9I6mVKvVLx9xzp9UOh0Z/gA99Mjknlj/e4fPIz43xOmVDxm8HvQHi0POg96ffvik/Z3LQmXmmQ+uA5KJjrZYRsER4tyuldlOk674UR0siq1JtFS/JL1gnxtaTO15c/knkZ8X4YuBbPfT83M+bITRbEXqsEThzonnK1acTGkIyzShzxsVLfFmpjpRhUo8lpJaswzRHx5o5kNfeJtY+W/6A/IgncZPf+Z/dC9JHoP4ffxD4GZrWI15FBCZVWNYudJjycrhjQSf8KFXgkgWQrJOkleq43ZkZehY6wxiZeU7bYr72DaSHmMQXn0D9G8B+9+sPvPMRetYlx0HXwGngQc9ZhLaaw9JNBAqWWYDm6FOMUjS/WMTVd/NqBgfmvTkyG6vuLMzs1uXNGS/wa/7+fp1vf8QXD70GXgU5uH4bSOhRbponO3QKnEJpTcUqu5CLOyIkySWXHDOtOQZUNpqGYpwTS26tOiHv/PbNv3jE8h2ghh7lpj1w/iKjZUKdXeiknAE9ClbqmaAWkwOpZLc4Utq1Ceu2+godvrfkEu6W44ufD78BeO716OOVMrNEOtxZWPYBlPJyc0YFyy5HoMSzcAFHayb1+9JiSnR9YDVoDPMvkXdjfPFbYPYOEDnCT3NXpsDLLdnDzEUIEDwnNNVpJgfoeylOlDmzxdr9oJQctugZjEa06gz3YfysfP1tsEdvAP3dj8/99q9A5fRHxIlPJU4etQjvytnV8zrPKrSQZxCOVuab1i6LcBr9ZFAc24FxzHw2bzWf+BS+wyH+Ze8TewfAq0kxOf1xsvuIJThh5pyEzmdhSO1+KolfrSW+TmZKKTVjbA3sBmKfy11mfP0C/slJ/yFMA6+ynfsx0ukvwaPM42slDsw0F9FrQVUrk4+x5iY6T2dksme2bo1uYvE5vHJjfN1Ub8Q/AvGIU+cyH/RS6jkrDiJMOdYROEvMeMw4VVY7MWm1IFqtMClyFjjT6tRyRoeIr8tbfPHLMPlXoEmk813CzjcDhycJLCymFkzeCs2BBM3ilhlfb9Ul3aAuHB/iO/P16/zH4v8hzM5DOvQIPeJ/RPxBchx6BM5NLhk8sl1gT8+48CGiJdAq6ECmjnBVckPWyQIf2p/AxfAn8HXcfzaGd4DyJjCc8oh2khg+LAcrsguQHdbWzZEHFPoELdZ0cp5iLV1i8cUvznAY0t8As6Mv7w9+4vkmgFMYTo44u5EBzRD2oFkTWaDRE/PTbqHrx5KrVV/cJv9sc/zMTJ+klvavQNP/AnDjYw/mQ+fAzi6ErPUJdN2EtNpFiBmKKDt0HhsG87Ernq36XaE/yXlM+Qk/210+Z4AzbOeeocPi8Pe9ioi4H+zUanQllnvWzZvAF1vEWlHTiQjlJNkhvu5c5n81Xjp+8f+DfI5D8MCMn4T734L/DaBLuncAP/TlfaAEDp+s5fmOcAc0Rx+PLRZhGqw7S8hG04vhL3bEDy3HA36ec//y9yI3gP2Pn/W/gsmHfn74SR+B/vhNBbMHTzaFZOzjB70IYJmul0Q89wvFtjF9xCkL+5fEf1ZdvEIc+h977t/4HSn6NwD/V0Dx6x8HevgDAIFjx8wwjadRsj4tyeqI1i/zWXqOmlevmhByIzEYjdzajP203Dtj/OGUeJ184u89ofdRvinEu/GPQHH6GX7oy22AQxxCNJ6Sa3l6kSn0AaChTGsWaLpfMFNnYmI6+csRP5Mca+6d23zc7618B+WbYnw+/kewPhxPPw49z7188vnm90D6/IODy2yBtS7w1Z65mnpNWduajBAGe72bqzLPspi/E/BdlXgvP+rEl2+K8YOQj0D2P4Tmm4Cfcvvcjxg++jPL0y5ZhZB0yzLkukc67I69X4T49nO8l3LcEZ9N+XYifib8HcA/AvHXv70DxLn3ewDHlDkL+Y70u5LvLpz0zcKJgYyUbM26wcr/rRLfco63U8464vMo30vEbwG5Afhs5fRr5omX04+8+OQjq/Sgs7TvV76EVmqX8Noyu1oG6nXsy0OerXoP/JZyLHjpiOaDzng75bvI8VvG/hUoPv+0d4D+I5Acep51PbVdpgiNXe3CJFCwhUnJ6oAQgfYtVqxamyWfTjzpHJ9BOeuIN1Kef8TvFH0H8M8/dtwZPP1+7plF6Bi1UH46WtILW0SxPp/Pfaj4dnJ8BuWgM16kPO0Svxjf+Bcw74H49S/R3wa8B7qjjx9XOusSXmZkWK3ig3DG1s8Fv4Ucn0E55YzHlCec44uEfwTir3+NOPq4DT6+yQmmb+dbf4Ki/biLYZcOzpi2q4lhduKM7Fed7HANdhnjvZQjHvGA8jxzfHEGjrr/+uc7gB/98uvfjrv+ZE3reiqWFj5/wtnUBc83sWec4r2UI864RXl6Jb54GfsIxHcAnH4GTz9+/bfTz8CPnRlLw+FOoCsa4c2ajX03cz7ZgWUl3kg55YxDyrPK8cUn0z4CydFf/e7nQdeXxF6XEErMjIwmnenwhrvzsqDEWyhHPGJPeSYlvvhx6DsAf/3z84//F4DuNsDL5Cc+bgPCox/YTIog6xUnM3Pi8SJepJzviA3lCeR4gf1jfvEi9hGIpz9//pFzz8Ar6CeeZ71pqnZ9wpO1fOgcr5DPd8SK8rg5vvgNIjfA/A+A/vSzBJKydrIe2XcvkYfL8Zhyyhkj5eFyfPH7wm6AdvT565/3AF5xfcnjuMtVfZaRz7lcKya+StylHPGITHmIHF/8Mnz7+Gu5Af4Uv/7jww9OQr4H+OWnf8qqtVli6M4tblGOOCOje8p3UeKLL+wdgJ9//uhvAv3pZ8ZFk0GRM8n6AoxGnFMOOiLIG+b4CchP84ufim9/+Gv5C/hP+fSnEDTngzQeqk23lVA5LsmnPAKUfSJ+Dfgz+OJdfMNPlB9+5Aboj76cK+j7p6vNc/HVFtLMp5zBBp9Mji++eB/yDiC//v8ov/75v/yxQ784beFRTEZ0YeyTaWU56whdxbCHRnzx+eBn/ysjfwPEDVD+/B1ZnsnLU5vPOiKGI7744kcgH4HsDwAefXh+HFl61QQQHe3cCPJxB3l4Ov/FFz8C/N7/w5/+JDeA/NZnDEe0c1iUCZCPO4ixcfKLL34avuEXP94B4vQvmZ7mfOinA1988XPzTf75H38A+OmPA9xOcjnW01/zX3zx2+TbX/xJ//1HP/l05MM9Hvovvvhd8O0v/kL/DtAzzYMtbwVUce7D+eKL3xdyA7Rf//noQ36d+y9+73z7G38jnf78OeeLL34Bvv0Rn38A3wS+zv0Xvxjf+I8/X3zxa6K//7/ugS9+Tf7wh/8IWJPIB1GI308AAAAASUVORK5CYII=";
  99508. return TextureTools;
  99509. }());
  99510. /***/ }),
  99511. /***/ "./Misc/tga.ts":
  99512. /*!*********************!*\
  99513. !*** ./Misc/tga.ts ***!
  99514. \*********************/
  99515. /*! exports provided: TGATools */
  99516. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99517. "use strict";
  99518. __webpack_require__.r(__webpack_exports__);
  99519. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return TGATools; });
  99520. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  99521. /**
  99522. * Based on jsTGALoader - Javascript loader for TGA file
  99523. * By Vincent Thibault
  99524. * @see http://blog.robrowser.com/javascript-tga-loader.html
  99525. */
  99526. var TGATools = /** @class */ (function () {
  99527. function TGATools() {
  99528. }
  99529. /**
  99530. * Gets the header of a TGA file
  99531. * @param data defines the TGA data
  99532. * @returns the header
  99533. */
  99534. TGATools.GetTGAHeader = function (data) {
  99535. var offset = 0;
  99536. var header = {
  99537. id_length: data[offset++],
  99538. colormap_type: data[offset++],
  99539. image_type: data[offset++],
  99540. colormap_index: data[offset++] | data[offset++] << 8,
  99541. colormap_length: data[offset++] | data[offset++] << 8,
  99542. colormap_size: data[offset++],
  99543. origin: [
  99544. data[offset++] | data[offset++] << 8,
  99545. data[offset++] | data[offset++] << 8
  99546. ],
  99547. width: data[offset++] | data[offset++] << 8,
  99548. height: data[offset++] | data[offset++] << 8,
  99549. pixel_size: data[offset++],
  99550. flags: data[offset++]
  99551. };
  99552. return header;
  99553. };
  99554. /**
  99555. * Uploads TGA content to a Babylon Texture
  99556. * @hidden
  99557. */
  99558. TGATools.UploadContent = function (texture, data) {
  99559. // Not enough data to contain header ?
  99560. if (data.length < 19) {
  99561. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Unable to load TGA file - Not enough data to contain header");
  99562. return;
  99563. }
  99564. // Read Header
  99565. var offset = 18;
  99566. var header = TGATools.GetTGAHeader(data);
  99567. // Assume it's a valid Targa file.
  99568. if (header.id_length + offset > data.length) {
  99569. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Unable to load TGA file - Not enough data");
  99570. return;
  99571. }
  99572. // Skip not needed data
  99573. offset += header.id_length;
  99574. var use_rle = false;
  99575. var use_pal = false;
  99576. var use_grey = false;
  99577. // Get some informations.
  99578. switch (header.image_type) {
  99579. case TGATools._TYPE_RLE_INDEXED:
  99580. use_rle = true;
  99581. case TGATools._TYPE_INDEXED:
  99582. use_pal = true;
  99583. break;
  99584. case TGATools._TYPE_RLE_RGB:
  99585. use_rle = true;
  99586. case TGATools._TYPE_RGB:
  99587. // use_rgb = true;
  99588. break;
  99589. case TGATools._TYPE_RLE_GREY:
  99590. use_rle = true;
  99591. case TGATools._TYPE_GREY:
  99592. use_grey = true;
  99593. break;
  99594. }
  99595. var pixel_data;
  99596. // var numAlphaBits = header.flags & 0xf;
  99597. var pixel_size = header.pixel_size >> 3;
  99598. var pixel_total = header.width * header.height * pixel_size;
  99599. // Read palettes
  99600. var palettes;
  99601. if (use_pal) {
  99602. palettes = data.subarray(offset, offset += header.colormap_length * (header.colormap_size >> 3));
  99603. }
  99604. // Read LRE
  99605. if (use_rle) {
  99606. pixel_data = new Uint8Array(pixel_total);
  99607. var c, count, i;
  99608. var localOffset = 0;
  99609. var pixels = new Uint8Array(pixel_size);
  99610. while (offset < pixel_total && localOffset < pixel_total) {
  99611. c = data[offset++];
  99612. count = (c & 0x7f) + 1;
  99613. // RLE pixels
  99614. if (c & 0x80) {
  99615. // Bind pixel tmp array
  99616. for (i = 0; i < pixel_size; ++i) {
  99617. pixels[i] = data[offset++];
  99618. }
  99619. // Copy pixel array
  99620. for (i = 0; i < count; ++i) {
  99621. pixel_data.set(pixels, localOffset + i * pixel_size);
  99622. }
  99623. localOffset += pixel_size * count;
  99624. }
  99625. // Raw pixels
  99626. else {
  99627. count *= pixel_size;
  99628. for (i = 0; i < count; ++i) {
  99629. pixel_data[localOffset + i] = data[offset++];
  99630. }
  99631. localOffset += count;
  99632. }
  99633. }
  99634. }
  99635. // RAW Pixels
  99636. else {
  99637. pixel_data = data.subarray(offset, offset += (use_pal ? header.width * header.height : pixel_total));
  99638. }
  99639. // Load to texture
  99640. var x_start, y_start, x_step, y_step, y_end, x_end;
  99641. switch ((header.flags & TGATools._ORIGIN_MASK) >> TGATools._ORIGIN_SHIFT) {
  99642. default:
  99643. case TGATools._ORIGIN_UL:
  99644. x_start = 0;
  99645. x_step = 1;
  99646. x_end = header.width;
  99647. y_start = 0;
  99648. y_step = 1;
  99649. y_end = header.height;
  99650. break;
  99651. case TGATools._ORIGIN_BL:
  99652. x_start = 0;
  99653. x_step = 1;
  99654. x_end = header.width;
  99655. y_start = header.height - 1;
  99656. y_step = -1;
  99657. y_end = -1;
  99658. break;
  99659. case TGATools._ORIGIN_UR:
  99660. x_start = header.width - 1;
  99661. x_step = -1;
  99662. x_end = -1;
  99663. y_start = 0;
  99664. y_step = 1;
  99665. y_end = header.height;
  99666. break;
  99667. case TGATools._ORIGIN_BR:
  99668. x_start = header.width - 1;
  99669. x_step = -1;
  99670. x_end = -1;
  99671. y_start = header.height - 1;
  99672. y_step = -1;
  99673. y_end = -1;
  99674. break;
  99675. }
  99676. // Load the specify method
  99677. var func = '_getImageData' + (use_grey ? 'Grey' : '') + (header.pixel_size) + 'bits';
  99678. var imageData = TGATools[func](header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end);
  99679. var engine = texture.getEngine();
  99680. engine._uploadDataToTextureDirectly(texture, imageData);
  99681. };
  99682. /** @hidden */
  99683. TGATools._getImageData8bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  99684. var image = pixel_data, colormap = palettes;
  99685. var width = header.width, height = header.height;
  99686. var color, i = 0, x, y;
  99687. var imageData = new Uint8Array(width * height * 4);
  99688. for (y = y_start; y !== y_end; y += y_step) {
  99689. for (x = x_start; x !== x_end; x += x_step, i++) {
  99690. color = image[i];
  99691. imageData[(x + width * y) * 4 + 3] = 255;
  99692. imageData[(x + width * y) * 4 + 2] = colormap[(color * 3) + 0];
  99693. imageData[(x + width * y) * 4 + 1] = colormap[(color * 3) + 1];
  99694. imageData[(x + width * y) * 4 + 0] = colormap[(color * 3) + 2];
  99695. }
  99696. }
  99697. return imageData;
  99698. };
  99699. /** @hidden */
  99700. TGATools._getImageData16bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  99701. var image = pixel_data;
  99702. var width = header.width, height = header.height;
  99703. var color, i = 0, x, y;
  99704. var imageData = new Uint8Array(width * height * 4);
  99705. for (y = y_start; y !== y_end; y += y_step) {
  99706. for (x = x_start; x !== x_end; x += x_step, i += 2) {
  99707. color = image[i + 0] + (image[i + 1] << 8); // Inversed ?
  99708. var r = (((color & 0x7C00) >> 10) * 255) / 0x1F | 0;
  99709. var g = (((color & 0x03E0) >> 5) * 255) / 0x1F | 0;
  99710. var b = ((color & 0x001F) * 255) / 0x1F | 0;
  99711. imageData[(x + width * y) * 4 + 0] = r;
  99712. imageData[(x + width * y) * 4 + 1] = g;
  99713. imageData[(x + width * y) * 4 + 2] = b;
  99714. imageData[(x + width * y) * 4 + 3] = (color & 0x8000) ? 0 : 255;
  99715. }
  99716. }
  99717. return imageData;
  99718. };
  99719. /** @hidden */
  99720. TGATools._getImageData24bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  99721. var image = pixel_data;
  99722. var width = header.width, height = header.height;
  99723. var i = 0, x, y;
  99724. var imageData = new Uint8Array(width * height * 4);
  99725. for (y = y_start; y !== y_end; y += y_step) {
  99726. for (x = x_start; x !== x_end; x += x_step, i += 3) {
  99727. imageData[(x + width * y) * 4 + 3] = 255;
  99728. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  99729. imageData[(x + width * y) * 4 + 1] = image[i + 1];
  99730. imageData[(x + width * y) * 4 + 0] = image[i + 2];
  99731. }
  99732. }
  99733. return imageData;
  99734. };
  99735. /** @hidden */
  99736. TGATools._getImageData32bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  99737. var image = pixel_data;
  99738. var width = header.width, height = header.height;
  99739. var i = 0, x, y;
  99740. var imageData = new Uint8Array(width * height * 4);
  99741. for (y = y_start; y !== y_end; y += y_step) {
  99742. for (x = x_start; x !== x_end; x += x_step, i += 4) {
  99743. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  99744. imageData[(x + width * y) * 4 + 1] = image[i + 1];
  99745. imageData[(x + width * y) * 4 + 0] = image[i + 2];
  99746. imageData[(x + width * y) * 4 + 3] = image[i + 3];
  99747. }
  99748. }
  99749. return imageData;
  99750. };
  99751. /** @hidden */
  99752. TGATools._getImageDataGrey8bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  99753. var image = pixel_data;
  99754. var width = header.width, height = header.height;
  99755. var color, i = 0, x, y;
  99756. var imageData = new Uint8Array(width * height * 4);
  99757. for (y = y_start; y !== y_end; y += y_step) {
  99758. for (x = x_start; x !== x_end; x += x_step, i++) {
  99759. color = image[i];
  99760. imageData[(x + width * y) * 4 + 0] = color;
  99761. imageData[(x + width * y) * 4 + 1] = color;
  99762. imageData[(x + width * y) * 4 + 2] = color;
  99763. imageData[(x + width * y) * 4 + 3] = 255;
  99764. }
  99765. }
  99766. return imageData;
  99767. };
  99768. /** @hidden */
  99769. TGATools._getImageDataGrey16bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  99770. var image = pixel_data;
  99771. var width = header.width, height = header.height;
  99772. var i = 0, x, y;
  99773. var imageData = new Uint8Array(width * height * 4);
  99774. for (y = y_start; y !== y_end; y += y_step) {
  99775. for (x = x_start; x !== x_end; x += x_step, i += 2) {
  99776. imageData[(x + width * y) * 4 + 0] = image[i + 0];
  99777. imageData[(x + width * y) * 4 + 1] = image[i + 0];
  99778. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  99779. imageData[(x + width * y) * 4 + 3] = image[i + 1];
  99780. }
  99781. }
  99782. return imageData;
  99783. };
  99784. //private static _TYPE_NO_DATA = 0;
  99785. TGATools._TYPE_INDEXED = 1;
  99786. TGATools._TYPE_RGB = 2;
  99787. TGATools._TYPE_GREY = 3;
  99788. TGATools._TYPE_RLE_INDEXED = 9;
  99789. TGATools._TYPE_RLE_RGB = 10;
  99790. TGATools._TYPE_RLE_GREY = 11;
  99791. TGATools._ORIGIN_MASK = 0x30;
  99792. TGATools._ORIGIN_SHIFT = 0x04;
  99793. TGATools._ORIGIN_BL = 0x00;
  99794. TGATools._ORIGIN_BR = 0x01;
  99795. TGATools._ORIGIN_UL = 0x02;
  99796. TGATools._ORIGIN_UR = 0x03;
  99797. return TGATools;
  99798. }());
  99799. /***/ }),
  99800. /***/ "./Misc/tools.ts":
  99801. /*!***********************!*\
  99802. !*** ./Misc/tools.ts ***!
  99803. \***********************/
  99804. /*! exports provided: ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop */
  99805. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99806. "use strict";
  99807. __webpack_require__.r(__webpack_exports__);
  99808. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return ColorGradient; });
  99809. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return Color3Gradient; });
  99810. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return FactorGradient; });
  99811. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return LoadFileError; });
  99812. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return RetryStrategy; });
  99813. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return Tools; });
  99814. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return PerfCounter; });
  99815. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "className", function() { return className; });
  99816. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return AsyncLoop; });
  99817. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  99818. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  99819. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  99820. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  99821. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  99822. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  99823. /* harmony import */ var _domManagement__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./domManagement */ "./Misc/domManagement.ts");
  99824. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  99825. /* harmony import */ var _typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./typeStore */ "./Misc/typeStore.ts");
  99826. /* harmony import */ var _deepCopier__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./deepCopier */ "./Misc/deepCopier.ts");
  99827. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  99828. /* harmony import */ var _devTools__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./devTools */ "./Misc/devTools.ts");
  99829. /** Class used to store color4 gradient */
  99830. var ColorGradient = /** @class */ (function () {
  99831. function ColorGradient() {
  99832. }
  99833. /**
  99834. * Will get a color picked randomly between color1 and color2.
  99835. * If color2 is undefined then color1 will be used
  99836. * @param result defines the target Color4 to store the result in
  99837. */
  99838. ColorGradient.prototype.getColorToRef = function (result) {
  99839. if (!this.color2) {
  99840. result.copyFrom(this.color1);
  99841. return;
  99842. }
  99843. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].LerpToRef(this.color1, this.color2, Math.random(), result);
  99844. };
  99845. return ColorGradient;
  99846. }());
  99847. /** Class used to store color 3 gradient */
  99848. var Color3Gradient = /** @class */ (function () {
  99849. function Color3Gradient() {
  99850. }
  99851. return Color3Gradient;
  99852. }());
  99853. /** Class used to store factor gradient */
  99854. var FactorGradient = /** @class */ (function () {
  99855. function FactorGradient() {
  99856. }
  99857. /**
  99858. * Will get a number picked randomly between factor1 and factor2.
  99859. * If factor2 is undefined then factor1 will be used
  99860. * @returns the picked number
  99861. */
  99862. FactorGradient.prototype.getFactor = function () {
  99863. if (this.factor2 === undefined) {
  99864. return this.factor1;
  99865. }
  99866. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Lerp(this.factor1, this.factor2, Math.random());
  99867. };
  99868. return FactorGradient;
  99869. }());
  99870. /**
  99871. * @ignore
  99872. * Application error to support additional information when loading a file
  99873. */
  99874. var LoadFileError = /** @class */ (function (_super) {
  99875. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LoadFileError, _super);
  99876. /**
  99877. * Creates a new LoadFileError
  99878. * @param message defines the message of the error
  99879. * @param request defines the optional XHR request
  99880. */
  99881. function LoadFileError(message,
  99882. /** defines the optional XHR request */
  99883. request) {
  99884. var _this = _super.call(this, message) || this;
  99885. _this.request = request;
  99886. _this.name = "LoadFileError";
  99887. LoadFileError._setPrototypeOf(_this, LoadFileError.prototype);
  99888. return _this;
  99889. }
  99890. // See https://stackoverflow.com/questions/12915412/how-do-i-extend-a-host-object-e-g-error-in-typescript
  99891. // and https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
  99892. // Polyfill for Object.setPrototypeOf if necessary.
  99893. LoadFileError._setPrototypeOf = Object.setPrototypeOf || (function (o, proto) { o.__proto__ = proto; return o; });
  99894. return LoadFileError;
  99895. }(Error));
  99896. /**
  99897. * Class used to define a retry strategy when error happens while loading assets
  99898. */
  99899. var RetryStrategy = /** @class */ (function () {
  99900. function RetryStrategy() {
  99901. }
  99902. /**
  99903. * Function used to defines an exponential back off strategy
  99904. * @param maxRetries defines the maximum number of retries (3 by default)
  99905. * @param baseInterval defines the interval between retries
  99906. * @returns the strategy function to use
  99907. */
  99908. RetryStrategy.ExponentialBackoff = function (maxRetries, baseInterval) {
  99909. if (maxRetries === void 0) { maxRetries = 3; }
  99910. if (baseInterval === void 0) { baseInterval = 500; }
  99911. return function (url, request, retryIndex) {
  99912. if (request.status !== 0 || retryIndex >= maxRetries || url.indexOf("file:") !== -1) {
  99913. return -1;
  99914. }
  99915. return Math.pow(2, retryIndex) * baseInterval;
  99916. };
  99917. };
  99918. return RetryStrategy;
  99919. }());
  99920. /**
  99921. * Class containing a set of static utilities functions
  99922. */
  99923. var Tools = /** @class */ (function () {
  99924. function Tools() {
  99925. }
  99926. /**
  99927. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  99928. * @param u defines the coordinate on X axis
  99929. * @param v defines the coordinate on Y axis
  99930. * @param width defines the width of the source data
  99931. * @param height defines the height of the source data
  99932. * @param pixels defines the source byte array
  99933. * @param color defines the output color
  99934. */
  99935. Tools.FetchToRef = function (u, v, width, height, pixels, color) {
  99936. var wrappedU = ((Math.abs(u) * width) % width) | 0;
  99937. var wrappedV = ((Math.abs(v) * height) % height) | 0;
  99938. var position = (wrappedU + wrappedV * width) * 4;
  99939. color.r = pixels[position] / 255;
  99940. color.g = pixels[position + 1] / 255;
  99941. color.b = pixels[position + 2] / 255;
  99942. color.a = pixels[position + 3] / 255;
  99943. };
  99944. /**
  99945. * Interpolates between a and b via alpha
  99946. * @param a The lower value (returned when alpha = 0)
  99947. * @param b The upper value (returned when alpha = 1)
  99948. * @param alpha The interpolation-factor
  99949. * @return The mixed value
  99950. */
  99951. Tools.Mix = function (a, b, alpha) {
  99952. return a * (1 - alpha) + b * alpha;
  99953. };
  99954. /**
  99955. * Tries to instantiate a new object from a given class name
  99956. * @param className defines the class name to instantiate
  99957. * @returns the new object or null if the system was not able to do the instantiation
  99958. */
  99959. Tools.Instantiate = function (className) {
  99960. if (Tools.RegisteredExternalClasses && Tools.RegisteredExternalClasses[className]) {
  99961. return Tools.RegisteredExternalClasses[className];
  99962. }
  99963. var internalClass = _typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass(className);
  99964. if (internalClass) {
  99965. return internalClass;
  99966. }
  99967. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Warn(className + " not found, you may have missed an import.");
  99968. var arr = className.split(".");
  99969. var fn = (window || this);
  99970. for (var i = 0, len = arr.length; i < len; i++) {
  99971. fn = fn[arr[i]];
  99972. }
  99973. if (typeof fn !== "function") {
  99974. return null;
  99975. }
  99976. return fn;
  99977. };
  99978. /**
  99979. * Provides a slice function that will work even on IE
  99980. * @param data defines the array to slice
  99981. * @param start defines the start of the data (optional)
  99982. * @param end defines the end of the data (optional)
  99983. * @returns the new sliced array
  99984. */
  99985. Tools.Slice = function (data, start, end) {
  99986. if (data.slice) {
  99987. return data.slice(start, end);
  99988. }
  99989. return Array.prototype.slice.call(data, start, end);
  99990. };
  99991. /**
  99992. * Polyfill for setImmediate
  99993. * @param action defines the action to execute after the current execution block
  99994. */
  99995. Tools.SetImmediate = function (action) {
  99996. if (_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() && window.setImmediate) {
  99997. window.setImmediate(action);
  99998. }
  99999. else {
  100000. setTimeout(action, 1);
  100001. }
  100002. };
  100003. /**
  100004. * Function indicating if a number is an exponent of 2
  100005. * @param value defines the value to test
  100006. * @returns true if the value is an exponent of 2
  100007. */
  100008. Tools.IsExponentOfTwo = function (value) {
  100009. var count = 1;
  100010. do {
  100011. count *= 2;
  100012. } while (count < value);
  100013. return count === value;
  100014. };
  100015. /**
  100016. * Returns the nearest 32-bit single precision float representation of a Number
  100017. * @param value A Number. If the parameter is of a different type, it will get converted
  100018. * to a number or to NaN if it cannot be converted
  100019. * @returns number
  100020. */
  100021. Tools.FloatRound = function (value) {
  100022. if (Math.fround) {
  100023. return Math.fround(value);
  100024. }
  100025. return (Tools._tmpFloatArray[0] = value);
  100026. };
  100027. /**
  100028. * Find the next highest power of two.
  100029. * @param x Number to start search from.
  100030. * @return Next highest power of two.
  100031. */
  100032. Tools.CeilingPOT = function (x) {
  100033. x--;
  100034. x |= x >> 1;
  100035. x |= x >> 2;
  100036. x |= x >> 4;
  100037. x |= x >> 8;
  100038. x |= x >> 16;
  100039. x++;
  100040. return x;
  100041. };
  100042. /**
  100043. * Find the next lowest power of two.
  100044. * @param x Number to start search from.
  100045. * @return Next lowest power of two.
  100046. */
  100047. Tools.FloorPOT = function (x) {
  100048. x = x | (x >> 1);
  100049. x = x | (x >> 2);
  100050. x = x | (x >> 4);
  100051. x = x | (x >> 8);
  100052. x = x | (x >> 16);
  100053. return x - (x >> 1);
  100054. };
  100055. /**
  100056. * Find the nearest power of two.
  100057. * @param x Number to start search from.
  100058. * @return Next nearest power of two.
  100059. */
  100060. Tools.NearestPOT = function (x) {
  100061. var c = Tools.CeilingPOT(x);
  100062. var f = Tools.FloorPOT(x);
  100063. return (c - x) > (x - f) ? f : c;
  100064. };
  100065. /**
  100066. * Get the closest exponent of two
  100067. * @param value defines the value to approximate
  100068. * @param max defines the maximum value to return
  100069. * @param mode defines how to define the closest value
  100070. * @returns closest exponent of two of the given value
  100071. */
  100072. Tools.GetExponentOfTwo = function (value, max, mode) {
  100073. if (mode === void 0) { mode = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_NEAREST; }
  100074. var pot;
  100075. switch (mode) {
  100076. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_FLOOR:
  100077. pot = Tools.FloorPOT(value);
  100078. break;
  100079. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_NEAREST:
  100080. pot = Tools.NearestPOT(value);
  100081. break;
  100082. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_CEILING:
  100083. default:
  100084. pot = Tools.CeilingPOT(value);
  100085. break;
  100086. }
  100087. return Math.min(pot, max);
  100088. };
  100089. /**
  100090. * Extracts the filename from a path
  100091. * @param path defines the path to use
  100092. * @returns the filename
  100093. */
  100094. Tools.GetFilename = function (path) {
  100095. var index = path.lastIndexOf("/");
  100096. if (index < 0) {
  100097. return path;
  100098. }
  100099. return path.substring(index + 1);
  100100. };
  100101. /**
  100102. * Extracts the "folder" part of a path (everything before the filename).
  100103. * @param uri The URI to extract the info from
  100104. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  100105. * @returns The "folder" part of the path
  100106. */
  100107. Tools.GetFolderPath = function (uri, returnUnchangedIfNoSlash) {
  100108. if (returnUnchangedIfNoSlash === void 0) { returnUnchangedIfNoSlash = false; }
  100109. var index = uri.lastIndexOf("/");
  100110. if (index < 0) {
  100111. if (returnUnchangedIfNoSlash) {
  100112. return uri;
  100113. }
  100114. return "";
  100115. }
  100116. return uri.substring(0, index + 1);
  100117. };
  100118. /**
  100119. * Convert an angle in radians to degrees
  100120. * @param angle defines the angle to convert
  100121. * @returns the angle in degrees
  100122. */
  100123. Tools.ToDegrees = function (angle) {
  100124. return angle * 180 / Math.PI;
  100125. };
  100126. /**
  100127. * Convert an angle in degrees to radians
  100128. * @param angle defines the angle to convert
  100129. * @returns the angle in radians
  100130. */
  100131. Tools.ToRadians = function (angle) {
  100132. return angle * Math.PI / 180;
  100133. };
  100134. /**
  100135. * Encode a buffer to a base64 string
  100136. * @param buffer defines the buffer to encode
  100137. * @returns the encoded string
  100138. */
  100139. Tools.EncodeArrayBufferTobase64 = function (buffer) {
  100140. var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  100141. var output = "";
  100142. var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
  100143. var i = 0;
  100144. var bytes = new Uint8Array(buffer);
  100145. while (i < bytes.length) {
  100146. chr1 = bytes[i++];
  100147. chr2 = i < bytes.length ? bytes[i++] : Number.NaN; // Not sure if the index
  100148. chr3 = i < bytes.length ? bytes[i++] : Number.NaN; // checks are needed here
  100149. enc1 = chr1 >> 2;
  100150. enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
  100151. enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
  100152. enc4 = chr3 & 63;
  100153. if (isNaN(chr2)) {
  100154. enc3 = enc4 = 64;
  100155. }
  100156. else if (isNaN(chr3)) {
  100157. enc4 = 64;
  100158. }
  100159. output += keyStr.charAt(enc1) + keyStr.charAt(enc2) +
  100160. keyStr.charAt(enc3) + keyStr.charAt(enc4);
  100161. }
  100162. return "data:image/png;base64," + output;
  100163. };
  100164. /**
  100165. * Extracts minimum and maximum values from a list of indexed positions
  100166. * @param positions defines the positions to use
  100167. * @param indices defines the indices to the positions
  100168. * @param indexStart defines the start index
  100169. * @param indexCount defines the end index
  100170. * @param bias defines bias value to add to the result
  100171. * @return minimum and maximum values
  100172. */
  100173. Tools.ExtractMinAndMaxIndexed = function (positions, indices, indexStart, indexCount, bias) {
  100174. if (bias === void 0) { bias = null; }
  100175. var minimum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  100176. var maximum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  100177. for (var index = indexStart; index < indexStart + indexCount; index++) {
  100178. var offset = indices[index] * 3;
  100179. var x = positions[offset];
  100180. var y = positions[offset + 1];
  100181. var z = positions[offset + 2];
  100182. minimum.minimizeInPlaceFromFloats(x, y, z);
  100183. maximum.maximizeInPlaceFromFloats(x, y, z);
  100184. }
  100185. if (bias) {
  100186. minimum.x -= minimum.x * bias.x + bias.y;
  100187. minimum.y -= minimum.y * bias.x + bias.y;
  100188. minimum.z -= minimum.z * bias.x + bias.y;
  100189. maximum.x += maximum.x * bias.x + bias.y;
  100190. maximum.y += maximum.y * bias.x + bias.y;
  100191. maximum.z += maximum.z * bias.x + bias.y;
  100192. }
  100193. return {
  100194. minimum: minimum,
  100195. maximum: maximum
  100196. };
  100197. };
  100198. /**
  100199. * Extracts minimum and maximum values from a list of positions
  100200. * @param positions defines the positions to use
  100201. * @param start defines the start index in the positions array
  100202. * @param count defines the number of positions to handle
  100203. * @param bias defines bias value to add to the result
  100204. * @param stride defines the stride size to use (distance between two positions in the positions array)
  100205. * @return minimum and maximum values
  100206. */
  100207. Tools.ExtractMinAndMax = function (positions, start, count, bias, stride) {
  100208. if (bias === void 0) { bias = null; }
  100209. var minimum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  100210. var maximum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  100211. if (!stride) {
  100212. stride = 3;
  100213. }
  100214. for (var index = start, offset = start * stride; index < start + count; index++, offset += stride) {
  100215. var x = positions[offset];
  100216. var y = positions[offset + 1];
  100217. var z = positions[offset + 2];
  100218. minimum.minimizeInPlaceFromFloats(x, y, z);
  100219. maximum.maximizeInPlaceFromFloats(x, y, z);
  100220. }
  100221. if (bias) {
  100222. minimum.x -= minimum.x * bias.x + bias.y;
  100223. minimum.y -= minimum.y * bias.x + bias.y;
  100224. minimum.z -= minimum.z * bias.x + bias.y;
  100225. maximum.x += maximum.x * bias.x + bias.y;
  100226. maximum.y += maximum.y * bias.x + bias.y;
  100227. maximum.z += maximum.z * bias.x + bias.y;
  100228. }
  100229. return {
  100230. minimum: minimum,
  100231. maximum: maximum
  100232. };
  100233. };
  100234. /**
  100235. * Returns an array if obj is not an array
  100236. * @param obj defines the object to evaluate as an array
  100237. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  100238. * @returns either obj directly if obj is an array or a new array containing obj
  100239. */
  100240. Tools.MakeArray = function (obj, allowsNullUndefined) {
  100241. if (allowsNullUndefined !== true && (obj === undefined || obj == null)) {
  100242. return null;
  100243. }
  100244. return Array.isArray(obj) ? obj : [obj];
  100245. };
  100246. /**
  100247. * Gets the pointer prefix to use
  100248. * @returns "pointer" if touch is enabled. Else returns "mouse"
  100249. */
  100250. Tools.GetPointerPrefix = function () {
  100251. var eventPrefix = "pointer";
  100252. // Check if pointer events are supported
  100253. if (_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() && !window.PointerEvent && !navigator.pointerEnabled) {
  100254. eventPrefix = "mouse";
  100255. }
  100256. return eventPrefix;
  100257. };
  100258. /**
  100259. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  100260. * @param func - the function to be called
  100261. * @param requester - the object that will request the next frame. Falls back to window.
  100262. * @returns frame number
  100263. */
  100264. Tools.QueueNewFrame = function (func, requester) {
  100265. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  100266. return setTimeout(func, 16);
  100267. }
  100268. if (!requester) {
  100269. requester = window;
  100270. }
  100271. if (requester.requestAnimationFrame) {
  100272. return requester.requestAnimationFrame(func);
  100273. }
  100274. else if (requester.msRequestAnimationFrame) {
  100275. return requester.msRequestAnimationFrame(func);
  100276. }
  100277. else if (requester.webkitRequestAnimationFrame) {
  100278. return requester.webkitRequestAnimationFrame(func);
  100279. }
  100280. else if (requester.mozRequestAnimationFrame) {
  100281. return requester.mozRequestAnimationFrame(func);
  100282. }
  100283. else if (requester.oRequestAnimationFrame) {
  100284. return requester.oRequestAnimationFrame(func);
  100285. }
  100286. else {
  100287. return window.setTimeout(func, 16);
  100288. }
  100289. };
  100290. /**
  100291. * Ask the browser to promote the current element to fullscreen rendering mode
  100292. * @param element defines the DOM element to promote
  100293. */
  100294. Tools.RequestFullscreen = function (element) {
  100295. var requestFunction = element.requestFullscreen || element.msRequestFullscreen || element.webkitRequestFullscreen || element.mozRequestFullScreen;
  100296. if (!requestFunction) {
  100297. return;
  100298. }
  100299. requestFunction.call(element);
  100300. };
  100301. /**
  100302. * Asks the browser to exit fullscreen mode
  100303. */
  100304. Tools.ExitFullscreen = function () {
  100305. if (document.exitFullscreen) {
  100306. document.exitFullscreen();
  100307. }
  100308. else if (document.mozCancelFullScreen) {
  100309. document.mozCancelFullScreen();
  100310. }
  100311. else if (document.webkitCancelFullScreen) {
  100312. document.webkitCancelFullScreen();
  100313. }
  100314. else if (document.msCancelFullScreen) {
  100315. document.msCancelFullScreen();
  100316. }
  100317. };
  100318. /**
  100319. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  100320. * @param url define the url we are trying
  100321. * @param element define the dom element where to configure the cors policy
  100322. */
  100323. Tools.SetCorsBehavior = function (url, element) {
  100324. if (url && url.indexOf("data:") === 0) {
  100325. return;
  100326. }
  100327. if (Tools.CorsBehavior) {
  100328. if (typeof (Tools.CorsBehavior) === 'string' || Tools.CorsBehavior instanceof String) {
  100329. element.crossOrigin = Tools.CorsBehavior;
  100330. }
  100331. else {
  100332. var result = Tools.CorsBehavior(url);
  100333. if (result) {
  100334. element.crossOrigin = result;
  100335. }
  100336. }
  100337. }
  100338. };
  100339. // External files
  100340. /**
  100341. * Removes unwanted characters from an url
  100342. * @param url defines the url to clean
  100343. * @returns the cleaned url
  100344. */
  100345. Tools.CleanUrl = function (url) {
  100346. url = url.replace(/#/mg, "%23");
  100347. return url;
  100348. };
  100349. /**
  100350. * Loads an image as an HTMLImageElement.
  100351. * @param input url string, ArrayBuffer, or Blob to load
  100352. * @param onLoad callback called when the image successfully loads
  100353. * @param onError callback called when the image fails to load
  100354. * @param offlineProvider offline provider for caching
  100355. * @returns the HTMLImageElement of the loaded image
  100356. */
  100357. Tools.LoadImage = function (input, onLoad, onError, offlineProvider) {
  100358. var url;
  100359. var usingObjectURL = false;
  100360. if (input instanceof ArrayBuffer) {
  100361. url = URL.createObjectURL(new Blob([input]));
  100362. usingObjectURL = true;
  100363. }
  100364. else if (input instanceof Blob) {
  100365. url = URL.createObjectURL(input);
  100366. usingObjectURL = true;
  100367. }
  100368. else {
  100369. url = Tools.CleanUrl(input);
  100370. url = Tools.PreprocessUrl(input);
  100371. }
  100372. var img = new Image();
  100373. Tools.SetCorsBehavior(url, img);
  100374. var loadHandler = function () {
  100375. img.removeEventListener("load", loadHandler);
  100376. img.removeEventListener("error", errorHandler);
  100377. onLoad(img);
  100378. // Must revoke the URL after calling onLoad to avoid security exceptions in
  100379. // certain scenarios (e.g. when hosted in vscode).
  100380. if (usingObjectURL && img.src) {
  100381. URL.revokeObjectURL(img.src);
  100382. }
  100383. };
  100384. var errorHandler = function (err) {
  100385. img.removeEventListener("load", loadHandler);
  100386. img.removeEventListener("error", errorHandler);
  100387. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("Error while trying to load image: " + input);
  100388. if (onError) {
  100389. onError("Error while trying to load image: " + input, err);
  100390. }
  100391. if (usingObjectURL && img.src) {
  100392. URL.revokeObjectURL(img.src);
  100393. }
  100394. };
  100395. img.addEventListener("load", loadHandler);
  100396. img.addEventListener("error", errorHandler);
  100397. var noOfflineSupport = function () {
  100398. img.src = url;
  100399. };
  100400. var loadFromOfflineSupport = function () {
  100401. if (offlineProvider) {
  100402. offlineProvider.loadImage(url, img);
  100403. }
  100404. };
  100405. if (url.substr(0, 5) !== "data:" && offlineProvider && offlineProvider.enableTexturesOffline) {
  100406. offlineProvider.open(loadFromOfflineSupport, noOfflineSupport);
  100407. }
  100408. else {
  100409. if (url.indexOf("file:") !== -1) {
  100410. var textureName = decodeURIComponent(url.substring(5).toLowerCase());
  100411. if (_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]) {
  100412. try {
  100413. var blobURL;
  100414. try {
  100415. blobURL = URL.createObjectURL(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]);
  100416. }
  100417. catch (ex) {
  100418. // Chrome doesn't support oneTimeOnly parameter
  100419. blobURL = URL.createObjectURL(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]);
  100420. }
  100421. img.src = blobURL;
  100422. usingObjectURL = true;
  100423. }
  100424. catch (e) {
  100425. img.src = "";
  100426. }
  100427. return img;
  100428. }
  100429. }
  100430. noOfflineSupport();
  100431. }
  100432. return img;
  100433. };
  100434. /**
  100435. * Loads a file
  100436. * @param url url string, ArrayBuffer, or Blob to load
  100437. * @param onSuccess callback called when the file successfully loads
  100438. * @param onProgress callback called while file is loading (if the server supports this mode)
  100439. * @param offlineProvider defines the offline provider for caching
  100440. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  100441. * @param onError callback called when the file fails to load
  100442. * @returns a file request object
  100443. */
  100444. Tools.LoadFile = function (url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {
  100445. url = Tools.CleanUrl(url);
  100446. url = Tools.PreprocessUrl(url);
  100447. // If file and file input are set
  100448. if (url.indexOf("file:") !== -1) {
  100449. var fileName = decodeURIComponent(url.substring(5).toLowerCase());
  100450. if (_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[fileName]) {
  100451. return Tools.ReadFile(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[fileName], onSuccess, onProgress, useArrayBuffer);
  100452. }
  100453. }
  100454. var loadUrl = Tools.BaseUrl + url;
  100455. var aborted = false;
  100456. var fileRequest = {
  100457. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  100458. abort: function () { return aborted = true; },
  100459. };
  100460. var requestFile = function () {
  100461. var request = new XMLHttpRequest();
  100462. var retryHandle = null;
  100463. fileRequest.abort = function () {
  100464. aborted = true;
  100465. if (request.readyState !== (XMLHttpRequest.DONE || 4)) {
  100466. request.abort();
  100467. }
  100468. if (retryHandle !== null) {
  100469. clearTimeout(retryHandle);
  100470. retryHandle = null;
  100471. }
  100472. };
  100473. var retryLoop = function (retryIndex) {
  100474. request.open('GET', loadUrl, true);
  100475. if (useArrayBuffer) {
  100476. request.responseType = "arraybuffer";
  100477. }
  100478. if (onProgress) {
  100479. request.addEventListener("progress", onProgress);
  100480. }
  100481. var onLoadEnd = function () {
  100482. request.removeEventListener("loadend", onLoadEnd);
  100483. fileRequest.onCompleteObservable.notifyObservers(fileRequest);
  100484. fileRequest.onCompleteObservable.clear();
  100485. };
  100486. request.addEventListener("loadend", onLoadEnd);
  100487. var onReadyStateChange = function () {
  100488. if (aborted) {
  100489. return;
  100490. }
  100491. // In case of undefined state in some browsers.
  100492. if (request.readyState === (XMLHttpRequest.DONE || 4)) {
  100493. // Some browsers have issues where onreadystatechange can be called multiple times with the same value.
  100494. request.removeEventListener("readystatechange", onReadyStateChange);
  100495. if ((request.status >= 200 && request.status < 300) || (request.status === 0 && (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() || Tools.IsFileURL()))) {
  100496. onSuccess(!useArrayBuffer ? request.responseText : request.response, request.responseURL);
  100497. return;
  100498. }
  100499. var retryStrategy = Tools.DefaultRetryStrategy;
  100500. if (retryStrategy) {
  100501. var waitTime = retryStrategy(loadUrl, request, retryIndex);
  100502. if (waitTime !== -1) {
  100503. // Prevent the request from completing for retry.
  100504. request.removeEventListener("loadend", onLoadEnd);
  100505. request = new XMLHttpRequest();
  100506. retryHandle = setTimeout(function () { return retryLoop(retryIndex + 1); }, waitTime);
  100507. return;
  100508. }
  100509. }
  100510. var e = new LoadFileError("Error status: " + request.status + " " + request.statusText + " - Unable to load " + loadUrl, request);
  100511. if (onError) {
  100512. onError(request, e);
  100513. }
  100514. else {
  100515. throw e;
  100516. }
  100517. }
  100518. };
  100519. request.addEventListener("readystatechange", onReadyStateChange);
  100520. if (Tools.UseCustomRequestHeaders) {
  100521. Tools.InjectCustomRequestHeaders(request);
  100522. }
  100523. request.send();
  100524. };
  100525. retryLoop(0);
  100526. };
  100527. // Caching all files
  100528. if (offlineProvider && offlineProvider.enableSceneOffline) {
  100529. var noOfflineSupport_1 = function (request) {
  100530. if (request && request.status > 400) {
  100531. if (onError) {
  100532. onError(request);
  100533. }
  100534. }
  100535. else {
  100536. if (!aborted) {
  100537. requestFile();
  100538. }
  100539. }
  100540. };
  100541. var loadFromOfflineSupport = function () {
  100542. // TODO: database needs to support aborting and should return a IFileRequest
  100543. if (aborted) {
  100544. return;
  100545. }
  100546. if (offlineProvider) {
  100547. offlineProvider.loadFile(url, function (data) {
  100548. if (!aborted) {
  100549. onSuccess(data);
  100550. }
  100551. fileRequest.onCompleteObservable.notifyObservers(fileRequest);
  100552. }, onProgress ? function (event) {
  100553. if (!aborted) {
  100554. onProgress(event);
  100555. }
  100556. } : undefined, noOfflineSupport_1, useArrayBuffer);
  100557. }
  100558. };
  100559. offlineProvider.open(loadFromOfflineSupport, noOfflineSupport_1);
  100560. }
  100561. else {
  100562. requestFile();
  100563. }
  100564. return fileRequest;
  100565. };
  100566. /**
  100567. * Load a script (identified by an url). When the url returns, the
  100568. * content of this file is added into a new script element, attached to the DOM (body element)
  100569. * @param scriptUrl defines the url of the script to laod
  100570. * @param onSuccess defines the callback called when the script is loaded
  100571. * @param onError defines the callback to call if an error occurs
  100572. */
  100573. Tools.LoadScript = function (scriptUrl, onSuccess, onError) {
  100574. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  100575. return;
  100576. }
  100577. var head = document.getElementsByTagName('head')[0];
  100578. var script = document.createElement('script');
  100579. script.type = 'text/javascript';
  100580. script.src = scriptUrl;
  100581. script.onload = function () {
  100582. if (onSuccess) {
  100583. onSuccess();
  100584. }
  100585. };
  100586. script.onerror = function (e) {
  100587. if (onError) {
  100588. onError("Unable to load script '" + scriptUrl + "'", e);
  100589. }
  100590. };
  100591. head.appendChild(script);
  100592. };
  100593. /**
  100594. * Loads a file from a blob
  100595. * @param fileToLoad defines the blob to use
  100596. * @param callback defines the callback to call when data is loaded
  100597. * @param progressCallback defines the callback to call during loading process
  100598. * @returns a file request object
  100599. */
  100600. Tools.ReadFileAsDataURL = function (fileToLoad, callback, progressCallback) {
  100601. var reader = new FileReader();
  100602. var request = {
  100603. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  100604. abort: function () { return reader.abort(); },
  100605. };
  100606. reader.onloadend = function (e) {
  100607. request.onCompleteObservable.notifyObservers(request);
  100608. };
  100609. reader.onload = function (e) {
  100610. //target doesn't have result from ts 1.3
  100611. callback(e.target['result']);
  100612. };
  100613. reader.onprogress = progressCallback;
  100614. reader.readAsDataURL(fileToLoad);
  100615. return request;
  100616. };
  100617. /**
  100618. * Loads a file
  100619. * @param fileToLoad defines the file to load
  100620. * @param callback defines the callback to call when data is loaded
  100621. * @param progressCallBack defines the callback to call during loading process
  100622. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  100623. * @returns a file request object
  100624. */
  100625. Tools.ReadFile = function (fileToLoad, callback, progressCallBack, useArrayBuffer) {
  100626. var reader = new FileReader();
  100627. var request = {
  100628. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  100629. abort: function () { return reader.abort(); },
  100630. };
  100631. reader.onloadend = function (e) { return request.onCompleteObservable.notifyObservers(request); };
  100632. reader.onerror = function (e) {
  100633. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Log("Error while reading file: " + fileToLoad.name);
  100634. callback(JSON.stringify({ autoClear: true, clearColor: [1, 0, 0], ambientColor: [0, 0, 0], gravity: [0, -9.807, 0], meshes: [], cameras: [], lights: [] }));
  100635. };
  100636. reader.onload = function (e) {
  100637. //target doesn't have result from ts 1.3
  100638. callback(e.target['result']);
  100639. };
  100640. if (progressCallBack) {
  100641. reader.onprogress = progressCallBack;
  100642. }
  100643. if (!useArrayBuffer) {
  100644. // Asynchronous read
  100645. reader.readAsText(fileToLoad);
  100646. }
  100647. else {
  100648. reader.readAsArrayBuffer(fileToLoad);
  100649. }
  100650. return request;
  100651. };
  100652. /**
  100653. * Creates a data url from a given string content
  100654. * @param content defines the content to convert
  100655. * @returns the new data url link
  100656. */
  100657. Tools.FileAsURL = function (content) {
  100658. var fileBlob = new Blob([content]);
  100659. var url = window.URL || window.webkitURL;
  100660. var link = url.createObjectURL(fileBlob);
  100661. return link;
  100662. };
  100663. /**
  100664. * Format the given number to a specific decimal format
  100665. * @param value defines the number to format
  100666. * @param decimals defines the number of decimals to use
  100667. * @returns the formatted string
  100668. */
  100669. Tools.Format = function (value, decimals) {
  100670. if (decimals === void 0) { decimals = 2; }
  100671. return value.toFixed(decimals);
  100672. };
  100673. /**
  100674. * Checks if a given vector is inside a specific range
  100675. * @param v defines the vector to test
  100676. * @param min defines the minimum range
  100677. * @param max defines the maximum range
  100678. */
  100679. Tools.CheckExtends = function (v, min, max) {
  100680. min.minimizeInPlace(v);
  100681. max.maximizeInPlace(v);
  100682. };
  100683. /**
  100684. * Tries to copy an object by duplicating every property
  100685. * @param source defines the source object
  100686. * @param destination defines the target object
  100687. * @param doNotCopyList defines a list of properties to avoid
  100688. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  100689. */
  100690. Tools.DeepCopy = function (source, destination, doNotCopyList, mustCopyList) {
  100691. _deepCopier__WEBPACK_IMPORTED_MODULE_9__["DeepCopier"].DeepCopy(source, destination, doNotCopyList, mustCopyList);
  100692. };
  100693. /**
  100694. * Gets a boolean indicating if the given object has no own property
  100695. * @param obj defines the object to test
  100696. * @returns true if object has no own property
  100697. */
  100698. Tools.IsEmpty = function (obj) {
  100699. for (var i in obj) {
  100700. if (obj.hasOwnProperty(i)) {
  100701. return false;
  100702. }
  100703. }
  100704. return true;
  100705. };
  100706. /**
  100707. * Function used to register events at window level
  100708. * @param events defines the events to register
  100709. */
  100710. Tools.RegisterTopRootEvents = function (events) {
  100711. for (var index = 0; index < events.length; index++) {
  100712. var event = events[index];
  100713. window.addEventListener(event.name, event.handler, false);
  100714. try {
  100715. if (window.parent) {
  100716. window.parent.addEventListener(event.name, event.handler, false);
  100717. }
  100718. }
  100719. catch (e) {
  100720. // Silently fails...
  100721. }
  100722. }
  100723. };
  100724. /**
  100725. * Function used to unregister events from window level
  100726. * @param events defines the events to unregister
  100727. */
  100728. Tools.UnregisterTopRootEvents = function (events) {
  100729. for (var index = 0; index < events.length; index++) {
  100730. var event = events[index];
  100731. window.removeEventListener(event.name, event.handler);
  100732. try {
  100733. if (window.parent) {
  100734. window.parent.removeEventListener(event.name, event.handler);
  100735. }
  100736. }
  100737. catch (e) {
  100738. // Silently fails...
  100739. }
  100740. }
  100741. };
  100742. /**
  100743. * Dumps the current bound framebuffer
  100744. * @param width defines the rendering width
  100745. * @param height defines the rendering height
  100746. * @param engine defines the hosting engine
  100747. * @param successCallback defines the callback triggered once the data are available
  100748. * @param mimeType defines the mime type of the result
  100749. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  100750. */
  100751. Tools.DumpFramebuffer = function (width, height, engine, successCallback, mimeType, fileName) {
  100752. if (mimeType === void 0) { mimeType = "image/png"; }
  100753. // Read the contents of the framebuffer
  100754. var numberOfChannelsByLine = width * 4;
  100755. var halfHeight = height / 2;
  100756. //Reading datas from WebGL
  100757. var data = engine.readPixels(0, 0, width, height);
  100758. //To flip image on Y axis.
  100759. for (var i = 0; i < halfHeight; i++) {
  100760. for (var j = 0; j < numberOfChannelsByLine; j++) {
  100761. var currentCell = j + i * numberOfChannelsByLine;
  100762. var targetLine = height - i - 1;
  100763. var targetCell = j + targetLine * numberOfChannelsByLine;
  100764. var temp = data[currentCell];
  100765. data[currentCell] = data[targetCell];
  100766. data[targetCell] = temp;
  100767. }
  100768. }
  100769. // Create a 2D canvas to store the result
  100770. if (!Tools._ScreenshotCanvas) {
  100771. Tools._ScreenshotCanvas = document.createElement('canvas');
  100772. }
  100773. Tools._ScreenshotCanvas.width = width;
  100774. Tools._ScreenshotCanvas.height = height;
  100775. var context = Tools._ScreenshotCanvas.getContext('2d');
  100776. if (context) {
  100777. // Copy the pixels to a 2D canvas
  100778. var imageData = context.createImageData(width, height);
  100779. var castData = (imageData.data);
  100780. castData.set(data);
  100781. context.putImageData(imageData, 0, 0);
  100782. Tools.EncodeScreenshotCanvasData(successCallback, mimeType, fileName);
  100783. }
  100784. };
  100785. /**
  100786. * Converts the canvas data to blob.
  100787. * This acts as a polyfill for browsers not supporting the to blob function.
  100788. * @param canvas Defines the canvas to extract the data from
  100789. * @param successCallback Defines the callback triggered once the data are available
  100790. * @param mimeType Defines the mime type of the result
  100791. */
  100792. Tools.ToBlob = function (canvas, successCallback, mimeType) {
  100793. if (mimeType === void 0) { mimeType = "image/png"; }
  100794. // We need HTMLCanvasElement.toBlob for HD screenshots
  100795. if (!canvas.toBlob) {
  100796. // low performance polyfill based on toDataURL (https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob)
  100797. canvas.toBlob = function (callback, type, quality) {
  100798. var _this = this;
  100799. setTimeout(function () {
  100800. var binStr = atob(_this.toDataURL(type, quality).split(',')[1]), len = binStr.length, arr = new Uint8Array(len);
  100801. for (var i = 0; i < len; i++) {
  100802. arr[i] = binStr.charCodeAt(i);
  100803. }
  100804. callback(new Blob([arr]));
  100805. });
  100806. };
  100807. }
  100808. canvas.toBlob(function (blob) {
  100809. successCallback(blob);
  100810. }, mimeType);
  100811. };
  100812. /**
  100813. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  100814. * @param successCallback defines the callback triggered once the data are available
  100815. * @param mimeType defines the mime type of the result
  100816. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  100817. */
  100818. Tools.EncodeScreenshotCanvasData = function (successCallback, mimeType, fileName) {
  100819. if (mimeType === void 0) { mimeType = "image/png"; }
  100820. if (successCallback) {
  100821. var base64Image = Tools._ScreenshotCanvas.toDataURL(mimeType);
  100822. successCallback(base64Image);
  100823. }
  100824. else {
  100825. this.ToBlob(Tools._ScreenshotCanvas, function (blob) {
  100826. //Creating a link if the browser have the download attribute on the a tag, to automatically start download generated image.
  100827. if (("download" in document.createElement("a"))) {
  100828. if (!fileName) {
  100829. var date = new Date();
  100830. var stringDate = (date.getFullYear() + "-" + (date.getMonth() + 1)).slice(2) + "-" + date.getDate() + "_" + date.getHours() + "-" + ('0' + date.getMinutes()).slice(-2);
  100831. fileName = "screenshot_" + stringDate + ".png";
  100832. }
  100833. Tools.Download(blob, fileName);
  100834. }
  100835. else {
  100836. var url = URL.createObjectURL(blob);
  100837. var newWindow = window.open("");
  100838. if (!newWindow) {
  100839. return;
  100840. }
  100841. var img = newWindow.document.createElement("img");
  100842. img.onload = function () {
  100843. // no longer need to read the blob so it's revoked
  100844. URL.revokeObjectURL(url);
  100845. };
  100846. img.src = url;
  100847. newWindow.document.body.appendChild(img);
  100848. }
  100849. }, mimeType);
  100850. }
  100851. };
  100852. /**
  100853. * Downloads a blob in the browser
  100854. * @param blob defines the blob to download
  100855. * @param fileName defines the name of the downloaded file
  100856. */
  100857. Tools.Download = function (blob, fileName) {
  100858. if (navigator && navigator.msSaveBlob) {
  100859. navigator.msSaveBlob(blob, fileName);
  100860. return;
  100861. }
  100862. var url = window.URL.createObjectURL(blob);
  100863. var a = document.createElement("a");
  100864. document.body.appendChild(a);
  100865. a.style.display = "none";
  100866. a.href = url;
  100867. a.download = fileName;
  100868. a.addEventListener("click", function () {
  100869. if (a.parentElement) {
  100870. a.parentElement.removeChild(a);
  100871. }
  100872. });
  100873. a.click();
  100874. window.URL.revokeObjectURL(url);
  100875. };
  100876. /**
  100877. * Captures a screenshot of the current rendering
  100878. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100879. * @param engine defines the rendering engine
  100880. * @param camera defines the source camera
  100881. * @param size This parameter can be set to a single number or to an object with the
  100882. * following (optional) properties: precision, width, height. If a single number is passed,
  100883. * it will be used for both width and height. If an object is passed, the screenshot size
  100884. * will be derived from the parameters. The precision property is a multiplier allowing
  100885. * rendering at a higher or lower resolution
  100886. * @param successCallback defines the callback receives a single parameter which contains the
  100887. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  100888. * src parameter of an <img> to display it
  100889. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  100890. * Check your browser for supported MIME types
  100891. */
  100892. Tools.CreateScreenshot = function (engine, camera, size, successCallback, mimeType) {
  100893. if (mimeType === void 0) { mimeType = "image/png"; }
  100894. throw _devTools__WEBPACK_IMPORTED_MODULE_11__["_DevTools"].WarnImport("ScreenshotTools");
  100895. };
  100896. /**
  100897. * Generates an image screenshot from the specified camera.
  100898. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100899. * @param engine The engine to use for rendering
  100900. * @param camera The camera to use for rendering
  100901. * @param size This parameter can be set to a single number or to an object with the
  100902. * following (optional) properties: precision, width, height. If a single number is passed,
  100903. * it will be used for both width and height. If an object is passed, the screenshot size
  100904. * will be derived from the parameters. The precision property is a multiplier allowing
  100905. * rendering at a higher or lower resolution
  100906. * @param successCallback The callback receives a single parameter which contains the
  100907. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  100908. * src parameter of an <img> to display it
  100909. * @param mimeType The MIME type of the screenshot image (default: image/png).
  100910. * Check your browser for supported MIME types
  100911. * @param samples Texture samples (default: 1)
  100912. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  100913. * @param fileName A name for for the downloaded file.
  100914. */
  100915. Tools.CreateScreenshotUsingRenderTarget = function (engine, camera, size, successCallback, mimeType, samples, antialiasing, fileName) {
  100916. if (mimeType === void 0) { mimeType = "image/png"; }
  100917. if (samples === void 0) { samples = 1; }
  100918. if (antialiasing === void 0) { antialiasing = false; }
  100919. throw _devTools__WEBPACK_IMPORTED_MODULE_11__["_DevTools"].WarnImport("ScreenshotTools");
  100920. };
  100921. /**
  100922. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  100923. * Be aware Math.random() could cause collisions, but:
  100924. * "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"
  100925. * @returns a pseudo random id
  100926. */
  100927. Tools.RandomId = function () {
  100928. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  100929. var r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);
  100930. return v.toString(16);
  100931. });
  100932. };
  100933. /**
  100934. * Test if the given uri is a base64 string
  100935. * @param uri The uri to test
  100936. * @return True if the uri is a base64 string or false otherwise
  100937. */
  100938. Tools.IsBase64 = function (uri) {
  100939. return uri.length < 5 ? false : uri.substr(0, 5) === "data:";
  100940. };
  100941. /**
  100942. * Decode the given base64 uri.
  100943. * @param uri The uri to decode
  100944. * @return The decoded base64 data.
  100945. */
  100946. Tools.DecodeBase64 = function (uri) {
  100947. var decodedString = atob(uri.split(",")[1]);
  100948. var bufferLength = decodedString.length;
  100949. var bufferView = new Uint8Array(new ArrayBuffer(bufferLength));
  100950. for (var i = 0; i < bufferLength; i++) {
  100951. bufferView[i] = decodedString.charCodeAt(i);
  100952. }
  100953. return bufferView.buffer;
  100954. };
  100955. Object.defineProperty(Tools, "errorsCount", {
  100956. /**
  100957. * Gets a value indicating the number of loading errors
  100958. * @ignorenaming
  100959. */
  100960. get: function () {
  100961. return _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].errorsCount;
  100962. },
  100963. enumerable: true,
  100964. configurable: true
  100965. });
  100966. /**
  100967. * Log a message to the console
  100968. * @param message defines the message to log
  100969. */
  100970. Tools.Log = function (message) {
  100971. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Log(message);
  100972. };
  100973. /**
  100974. * Write a warning message to the console
  100975. * @param message defines the message to log
  100976. */
  100977. Tools.Warn = function (message) {
  100978. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Warn(message);
  100979. };
  100980. /**
  100981. * Write an error message to the console
  100982. * @param message defines the message to log
  100983. */
  100984. Tools.Error = function (message) {
  100985. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error(message);
  100986. };
  100987. Object.defineProperty(Tools, "LogCache", {
  100988. /**
  100989. * Gets current log cache (list of logs)
  100990. */
  100991. get: function () {
  100992. return _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].LogCache;
  100993. },
  100994. enumerable: true,
  100995. configurable: true
  100996. });
  100997. /**
  100998. * Clears the log cache
  100999. */
  101000. Tools.ClearLogCache = function () {
  101001. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].ClearLogCache();
  101002. };
  101003. Object.defineProperty(Tools, "LogLevels", {
  101004. /**
  101005. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  101006. */
  101007. set: function (level) {
  101008. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].LogLevels = level;
  101009. },
  101010. enumerable: true,
  101011. configurable: true
  101012. });
  101013. /**
  101014. * Checks if the loaded document was accessed via `file:`-Protocol.
  101015. * @returns boolean
  101016. */
  101017. Tools.IsFileURL = function () {
  101018. return location.protocol === "file:";
  101019. };
  101020. Object.defineProperty(Tools, "PerformanceLogLevel", {
  101021. /**
  101022. * Sets the current performance log level
  101023. */
  101024. set: function (level) {
  101025. if ((level & Tools.PerformanceUserMarkLogLevel) === Tools.PerformanceUserMarkLogLevel) {
  101026. Tools.StartPerformanceCounter = Tools._StartUserMark;
  101027. Tools.EndPerformanceCounter = Tools._EndUserMark;
  101028. return;
  101029. }
  101030. if ((level & Tools.PerformanceConsoleLogLevel) === Tools.PerformanceConsoleLogLevel) {
  101031. Tools.StartPerformanceCounter = Tools._StartPerformanceConsole;
  101032. Tools.EndPerformanceCounter = Tools._EndPerformanceConsole;
  101033. return;
  101034. }
  101035. Tools.StartPerformanceCounter = Tools._StartPerformanceCounterDisabled;
  101036. Tools.EndPerformanceCounter = Tools._EndPerformanceCounterDisabled;
  101037. },
  101038. enumerable: true,
  101039. configurable: true
  101040. });
  101041. Tools._StartPerformanceCounterDisabled = function (counterName, condition) {
  101042. };
  101043. Tools._EndPerformanceCounterDisabled = function (counterName, condition) {
  101044. };
  101045. Tools._StartUserMark = function (counterName, condition) {
  101046. if (condition === void 0) { condition = true; }
  101047. if (!Tools._performance) {
  101048. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  101049. return;
  101050. }
  101051. Tools._performance = window.performance;
  101052. }
  101053. if (!condition || !Tools._performance.mark) {
  101054. return;
  101055. }
  101056. Tools._performance.mark(counterName + "-Begin");
  101057. };
  101058. Tools._EndUserMark = function (counterName, condition) {
  101059. if (condition === void 0) { condition = true; }
  101060. if (!condition || !Tools._performance.mark) {
  101061. return;
  101062. }
  101063. Tools._performance.mark(counterName + "-End");
  101064. Tools._performance.measure(counterName, counterName + "-Begin", counterName + "-End");
  101065. };
  101066. Tools._StartPerformanceConsole = function (counterName, condition) {
  101067. if (condition === void 0) { condition = true; }
  101068. if (!condition) {
  101069. return;
  101070. }
  101071. Tools._StartUserMark(counterName, condition);
  101072. if (console.time) {
  101073. console.time(counterName);
  101074. }
  101075. };
  101076. Tools._EndPerformanceConsole = function (counterName, condition) {
  101077. if (condition === void 0) { condition = true; }
  101078. if (!condition) {
  101079. return;
  101080. }
  101081. Tools._EndUserMark(counterName, condition);
  101082. if (console.time) {
  101083. console.timeEnd(counterName);
  101084. }
  101085. };
  101086. /**
  101087. * Injects the @see CustomRequestHeaders into the given request
  101088. * @param request the request that should be used for injection
  101089. */
  101090. Tools.InjectCustomRequestHeaders = function (request) {
  101091. for (var key in Tools.CustomRequestHeaders) {
  101092. var val = Tools.CustomRequestHeaders[key];
  101093. if (val) {
  101094. request.setRequestHeader(key, val);
  101095. }
  101096. }
  101097. };
  101098. Object.defineProperty(Tools, "Now", {
  101099. /**
  101100. * Gets either window.performance.now() if supported or Date.now() else
  101101. */
  101102. get: function () {
  101103. return _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  101104. },
  101105. enumerable: true,
  101106. configurable: true
  101107. });
  101108. /**
  101109. * This method will return the name of the class used to create the instance of the given object.
  101110. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  101111. * @param object the object to get the class name from
  101112. * @param isType defines if the object is actually a type
  101113. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  101114. */
  101115. Tools.GetClassName = function (object, isType) {
  101116. if (isType === void 0) { isType = false; }
  101117. var name = null;
  101118. if (!isType && object.getClassName) {
  101119. name = object.getClassName();
  101120. }
  101121. else {
  101122. if (object instanceof Object) {
  101123. var classObj = isType ? object : Object.getPrototypeOf(object);
  101124. name = classObj.constructor["__bjsclassName__"];
  101125. }
  101126. if (!name) {
  101127. name = typeof object;
  101128. }
  101129. }
  101130. return name;
  101131. };
  101132. /**
  101133. * Gets the first element of an array satisfying a given predicate
  101134. * @param array defines the array to browse
  101135. * @param predicate defines the predicate to use
  101136. * @returns null if not found or the element
  101137. */
  101138. Tools.First = function (array, predicate) {
  101139. for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
  101140. var el = array_1[_i];
  101141. if (predicate(el)) {
  101142. return el;
  101143. }
  101144. }
  101145. return null;
  101146. };
  101147. /**
  101148. * This method will return the name of the full name of the class, including its owning module (if any).
  101149. * 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).
  101150. * @param object the object to get the class name from
  101151. * @param isType defines if the object is actually a type
  101152. * @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.
  101153. * @ignorenaming
  101154. */
  101155. Tools.getFullClassName = function (object, isType) {
  101156. if (isType === void 0) { isType = false; }
  101157. var className = null;
  101158. var moduleName = null;
  101159. if (!isType && object.getClassName) {
  101160. className = object.getClassName();
  101161. }
  101162. else {
  101163. if (object instanceof Object) {
  101164. var classObj = isType ? object : Object.getPrototypeOf(object);
  101165. className = classObj.constructor["__bjsclassName__"];
  101166. moduleName = classObj.constructor["__bjsmoduleName__"];
  101167. }
  101168. if (!className) {
  101169. className = typeof object;
  101170. }
  101171. }
  101172. if (!className) {
  101173. return null;
  101174. }
  101175. return ((moduleName != null) ? (moduleName + ".") : "") + className;
  101176. };
  101177. /**
  101178. * Returns a promise that resolves after the given amount of time.
  101179. * @param delay Number of milliseconds to delay
  101180. * @returns Promise that resolves after the given amount of time
  101181. */
  101182. Tools.DelayAsync = function (delay) {
  101183. return new Promise(function (resolve) {
  101184. setTimeout(function () {
  101185. resolve();
  101186. }, delay);
  101187. });
  101188. };
  101189. /**
  101190. * Gets the current gradient from an array of IValueGradient
  101191. * @param ratio defines the current ratio to get
  101192. * @param gradients defines the array of IValueGradient
  101193. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  101194. */
  101195. Tools.GetCurrentGradient = function (ratio, gradients, updateFunc) {
  101196. for (var gradientIndex = 0; gradientIndex < gradients.length - 1; gradientIndex++) {
  101197. var currentGradient = gradients[gradientIndex];
  101198. var nextGradient = gradients[gradientIndex + 1];
  101199. if (ratio >= currentGradient.gradient && ratio <= nextGradient.gradient) {
  101200. var scale = (ratio - currentGradient.gradient) / (nextGradient.gradient - currentGradient.gradient);
  101201. updateFunc(currentGradient, nextGradient, scale);
  101202. return;
  101203. }
  101204. }
  101205. // Use last index if over
  101206. var lastIndex = gradients.length - 1;
  101207. updateFunc(gradients[lastIndex], gradients[lastIndex], 1.0);
  101208. };
  101209. /**
  101210. * Gets or sets the base URL to use to load assets
  101211. */
  101212. Tools.BaseUrl = "";
  101213. /**
  101214. * Enable/Disable Custom HTTP Request Headers globally.
  101215. * default = false
  101216. * @see CustomRequestHeaders
  101217. */
  101218. Tools.UseCustomRequestHeaders = false;
  101219. /**
  101220. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  101221. * i.e. when loading files, where the server/service expects an Authorization header.
  101222. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  101223. */
  101224. Tools.CustomRequestHeaders = {};
  101225. /**
  101226. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  101227. */
  101228. Tools.DefaultRetryStrategy = RetryStrategy.ExponentialBackoff();
  101229. /**
  101230. * Default behaviour for cors in the application.
  101231. * It can be a string if the expected behavior is identical in the entire app.
  101232. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  101233. */
  101234. Tools.CorsBehavior = "anonymous";
  101235. /**
  101236. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  101237. * @ignorenaming
  101238. */
  101239. Tools.UseFallbackTexture = true;
  101240. /**
  101241. * Use this object to register external classes like custom textures or material
  101242. * to allow the laoders to instantiate them
  101243. */
  101244. Tools.RegisteredExternalClasses = {};
  101245. /**
  101246. * Texture content used if a texture cannot loaded
  101247. * @ignorenaming
  101248. */
  101249. 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";
  101250. Tools._tmpFloatArray = new Float32Array(1);
  101251. /**
  101252. * Extracts text content from a DOM element hierarchy
  101253. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  101254. */
  101255. Tools.GetDOMTextContent = _domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].GetDOMTextContent;
  101256. /**
  101257. * Gets or sets a function used to pre-process url before using them to load assets
  101258. */
  101259. Tools.PreprocessUrl = function (url) {
  101260. return url;
  101261. };
  101262. // Logs
  101263. /**
  101264. * No log
  101265. */
  101266. Tools.NoneLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].NoneLogLevel;
  101267. /**
  101268. * Only message logs
  101269. */
  101270. Tools.MessageLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].MessageLogLevel;
  101271. /**
  101272. * Only warning logs
  101273. */
  101274. Tools.WarningLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].WarningLogLevel;
  101275. /**
  101276. * Only error logs
  101277. */
  101278. Tools.ErrorLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].ErrorLogLevel;
  101279. /**
  101280. * All logs
  101281. */
  101282. Tools.AllLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].AllLogLevel;
  101283. /**
  101284. * Checks if the window object exists
  101285. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  101286. */
  101287. Tools.IsWindowObjectExist = _domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist;
  101288. // Performances
  101289. /**
  101290. * No performance log
  101291. */
  101292. Tools.PerformanceNoneLogLevel = 0;
  101293. /**
  101294. * Use user marks to log performance
  101295. */
  101296. Tools.PerformanceUserMarkLogLevel = 1;
  101297. /**
  101298. * Log performance to the console
  101299. */
  101300. Tools.PerformanceConsoleLogLevel = 2;
  101301. /**
  101302. * Starts a performance counter
  101303. */
  101304. Tools.StartPerformanceCounter = Tools._StartPerformanceCounterDisabled;
  101305. /**
  101306. * Ends a specific performance coutner
  101307. */
  101308. Tools.EndPerformanceCounter = Tools._EndPerformanceCounterDisabled;
  101309. return Tools;
  101310. }());
  101311. /**
  101312. * This class is used to track a performance counter which is number based.
  101313. * The user has access to many properties which give statistics of different nature.
  101314. *
  101315. * The implementer can track two kinds of Performance Counter: time and count.
  101316. * 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.
  101317. * 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.
  101318. */
  101319. var PerfCounter = /** @class */ (function () {
  101320. /**
  101321. * Creates a new counter
  101322. */
  101323. function PerfCounter() {
  101324. this._startMonitoringTime = 0;
  101325. this._min = 0;
  101326. this._max = 0;
  101327. this._average = 0;
  101328. this._lastSecAverage = 0;
  101329. this._current = 0;
  101330. this._totalValueCount = 0;
  101331. this._totalAccumulated = 0;
  101332. this._lastSecAccumulated = 0;
  101333. this._lastSecTime = 0;
  101334. this._lastSecValueCount = 0;
  101335. }
  101336. Object.defineProperty(PerfCounter.prototype, "min", {
  101337. /**
  101338. * Returns the smallest value ever
  101339. */
  101340. get: function () {
  101341. return this._min;
  101342. },
  101343. enumerable: true,
  101344. configurable: true
  101345. });
  101346. Object.defineProperty(PerfCounter.prototype, "max", {
  101347. /**
  101348. * Returns the biggest value ever
  101349. */
  101350. get: function () {
  101351. return this._max;
  101352. },
  101353. enumerable: true,
  101354. configurable: true
  101355. });
  101356. Object.defineProperty(PerfCounter.prototype, "average", {
  101357. /**
  101358. * Returns the average value since the performance counter is running
  101359. */
  101360. get: function () {
  101361. return this._average;
  101362. },
  101363. enumerable: true,
  101364. configurable: true
  101365. });
  101366. Object.defineProperty(PerfCounter.prototype, "lastSecAverage", {
  101367. /**
  101368. * Returns the average value of the last second the counter was monitored
  101369. */
  101370. get: function () {
  101371. return this._lastSecAverage;
  101372. },
  101373. enumerable: true,
  101374. configurable: true
  101375. });
  101376. Object.defineProperty(PerfCounter.prototype, "current", {
  101377. /**
  101378. * Returns the current value
  101379. */
  101380. get: function () {
  101381. return this._current;
  101382. },
  101383. enumerable: true,
  101384. configurable: true
  101385. });
  101386. Object.defineProperty(PerfCounter.prototype, "total", {
  101387. /**
  101388. * Gets the accumulated total
  101389. */
  101390. get: function () {
  101391. return this._totalAccumulated;
  101392. },
  101393. enumerable: true,
  101394. configurable: true
  101395. });
  101396. Object.defineProperty(PerfCounter.prototype, "count", {
  101397. /**
  101398. * Gets the total value count
  101399. */
  101400. get: function () {
  101401. return this._totalValueCount;
  101402. },
  101403. enumerable: true,
  101404. configurable: true
  101405. });
  101406. /**
  101407. * Call this method to start monitoring a new frame.
  101408. * 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.
  101409. */
  101410. PerfCounter.prototype.fetchNewFrame = function () {
  101411. this._totalValueCount++;
  101412. this._current = 0;
  101413. this._lastSecValueCount++;
  101414. };
  101415. /**
  101416. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  101417. * @param newCount the count value to add to the monitored count
  101418. * @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.
  101419. */
  101420. PerfCounter.prototype.addCount = function (newCount, fetchResult) {
  101421. if (!PerfCounter.Enabled) {
  101422. return;
  101423. }
  101424. this._current += newCount;
  101425. if (fetchResult) {
  101426. this._fetchResult();
  101427. }
  101428. };
  101429. /**
  101430. * Start monitoring this performance counter
  101431. */
  101432. PerfCounter.prototype.beginMonitoring = function () {
  101433. if (!PerfCounter.Enabled) {
  101434. return;
  101435. }
  101436. this._startMonitoringTime = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  101437. };
  101438. /**
  101439. * Compute the time lapsed since the previous beginMonitoring() call.
  101440. * @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
  101441. */
  101442. PerfCounter.prototype.endMonitoring = function (newFrame) {
  101443. if (newFrame === void 0) { newFrame = true; }
  101444. if (!PerfCounter.Enabled) {
  101445. return;
  101446. }
  101447. if (newFrame) {
  101448. this.fetchNewFrame();
  101449. }
  101450. var currentTime = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  101451. this._current = currentTime - this._startMonitoringTime;
  101452. if (newFrame) {
  101453. this._fetchResult();
  101454. }
  101455. };
  101456. PerfCounter.prototype._fetchResult = function () {
  101457. this._totalAccumulated += this._current;
  101458. this._lastSecAccumulated += this._current;
  101459. // Min/Max update
  101460. this._min = Math.min(this._min, this._current);
  101461. this._max = Math.max(this._max, this._current);
  101462. this._average = this._totalAccumulated / this._totalValueCount;
  101463. // Reset last sec?
  101464. var now = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  101465. if ((now - this._lastSecTime) > 1000) {
  101466. this._lastSecAverage = this._lastSecAccumulated / this._lastSecValueCount;
  101467. this._lastSecTime = now;
  101468. this._lastSecAccumulated = 0;
  101469. this._lastSecValueCount = 0;
  101470. }
  101471. };
  101472. /**
  101473. * Gets or sets a global boolean to turn on and off all the counters
  101474. */
  101475. PerfCounter.Enabled = true;
  101476. return PerfCounter;
  101477. }());
  101478. /**
  101479. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  101480. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  101481. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  101482. * @param name The name of the class, case should be preserved
  101483. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  101484. */
  101485. function className(name, module) {
  101486. return function (target) {
  101487. target["__bjsclassName__"] = name;
  101488. target["__bjsmoduleName__"] = (module != null) ? module : null;
  101489. };
  101490. }
  101491. /**
  101492. * An implementation of a loop for asynchronous functions.
  101493. */
  101494. var AsyncLoop = /** @class */ (function () {
  101495. /**
  101496. * Constructor.
  101497. * @param iterations the number of iterations.
  101498. * @param func the function to run each iteration
  101499. * @param successCallback the callback that will be called upon succesful execution
  101500. * @param offset starting offset.
  101501. */
  101502. function AsyncLoop(
  101503. /**
  101504. * Defines the number of iterations for the loop
  101505. */
  101506. iterations, func, successCallback, offset) {
  101507. if (offset === void 0) { offset = 0; }
  101508. this.iterations = iterations;
  101509. this.index = offset - 1;
  101510. this._done = false;
  101511. this._fn = func;
  101512. this._successCallback = successCallback;
  101513. }
  101514. /**
  101515. * Execute the next iteration. Must be called after the last iteration was finished.
  101516. */
  101517. AsyncLoop.prototype.executeNext = function () {
  101518. if (!this._done) {
  101519. if (this.index + 1 < this.iterations) {
  101520. ++this.index;
  101521. this._fn(this);
  101522. }
  101523. else {
  101524. this.breakLoop();
  101525. }
  101526. }
  101527. };
  101528. /**
  101529. * Break the loop and run the success callback.
  101530. */
  101531. AsyncLoop.prototype.breakLoop = function () {
  101532. this._done = true;
  101533. this._successCallback();
  101534. };
  101535. /**
  101536. * Create and run an async loop.
  101537. * @param iterations the number of iterations.
  101538. * @param fn the function to run each iteration
  101539. * @param successCallback the callback that will be called upon succesful execution
  101540. * @param offset starting offset.
  101541. * @returns the created async loop object
  101542. */
  101543. AsyncLoop.Run = function (iterations, fn, successCallback, offset) {
  101544. if (offset === void 0) { offset = 0; }
  101545. var loop = new AsyncLoop(iterations, fn, successCallback, offset);
  101546. loop.executeNext();
  101547. return loop;
  101548. };
  101549. /**
  101550. * A for-loop that will run a given number of iterations synchronous and the rest async.
  101551. * @param iterations total number of iterations
  101552. * @param syncedIterations number of synchronous iterations in each async iteration.
  101553. * @param fn the function to call each iteration.
  101554. * @param callback a success call back that will be called when iterating stops.
  101555. * @param breakFunction a break condition (optional)
  101556. * @param timeout timeout settings for the setTimeout function. default - 0.
  101557. * @returns the created async loop object
  101558. */
  101559. AsyncLoop.SyncAsyncForLoop = function (iterations, syncedIterations, fn, callback, breakFunction, timeout) {
  101560. if (timeout === void 0) { timeout = 0; }
  101561. return AsyncLoop.Run(Math.ceil(iterations / syncedIterations), function (loop) {
  101562. if (breakFunction && breakFunction()) {
  101563. loop.breakLoop();
  101564. }
  101565. else {
  101566. setTimeout(function () {
  101567. for (var i = 0; i < syncedIterations; ++i) {
  101568. var iteration = (loop.index * syncedIterations) + i;
  101569. if (iteration >= iterations) {
  101570. break;
  101571. }
  101572. fn(iteration);
  101573. if (breakFunction && breakFunction()) {
  101574. loop.breakLoop();
  101575. break;
  101576. }
  101577. }
  101578. loop.executeNext();
  101579. }, timeout);
  101580. }
  101581. }, callback);
  101582. };
  101583. return AsyncLoop;
  101584. }());
  101585. /***/ }),
  101586. /***/ "./Misc/typeStore.ts":
  101587. /*!***************************!*\
  101588. !*** ./Misc/typeStore.ts ***!
  101589. \***************************/
  101590. /*! exports provided: _TypeStore */
  101591. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101592. "use strict";
  101593. __webpack_require__.r(__webpack_exports__);
  101594. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _TypeStore; });
  101595. /** @hidden */
  101596. var _TypeStore = /** @class */ (function () {
  101597. function _TypeStore() {
  101598. }
  101599. /** @hidden */
  101600. _TypeStore.GetClass = function (fqdn) {
  101601. if (this.RegisteredTypes && this.RegisteredTypes[fqdn]) {
  101602. return this.RegisteredTypes[fqdn];
  101603. }
  101604. return null;
  101605. };
  101606. /** @hidden */
  101607. _TypeStore.RegisteredTypes = {};
  101608. return _TypeStore;
  101609. }());
  101610. /***/ }),
  101611. /***/ "./Misc/videoRecorder.ts":
  101612. /*!*******************************!*\
  101613. !*** ./Misc/videoRecorder.ts ***!
  101614. \*******************************/
  101615. /*! exports provided: VideoRecorder */
  101616. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101617. "use strict";
  101618. __webpack_require__.r(__webpack_exports__);
  101619. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return VideoRecorder; });
  101620. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  101621. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  101622. /**
  101623. * This can helps recording videos from BabylonJS.
  101624. * This is based on the available WebRTC functionalities of the browser.
  101625. *
  101626. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  101627. */
  101628. var VideoRecorder = /** @class */ (function () {
  101629. /**
  101630. * Create a new VideoCapture object which can help converting what you see in Babylon to
  101631. * a video file.
  101632. * @param engine Defines the BabylonJS Engine you wish to record
  101633. * @param options Defines options that can be used to customized the capture
  101634. */
  101635. function VideoRecorder(engine, options) {
  101636. if (options === void 0) { options = null; }
  101637. if (!VideoRecorder.IsSupported(engine)) {
  101638. throw "Your browser does not support recording so far.";
  101639. }
  101640. var canvas = engine.getRenderingCanvas();
  101641. if (!canvas) {
  101642. throw "The babylon engine must have a canvas to be recorded";
  101643. }
  101644. this._canvas = canvas;
  101645. this._canvas.isRecording = false;
  101646. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, VideoRecorder._defaultOptions, options);
  101647. var stream = this._canvas.captureStream(this._options.fps);
  101648. if (this._options.audioTracks) {
  101649. for (var _i = 0, _a = this._options.audioTracks; _i < _a.length; _i++) {
  101650. var track = _a[_i];
  101651. stream.addTrack(track);
  101652. }
  101653. }
  101654. this._mediaRecorder = new MediaRecorder(stream, { mimeType: this._options.mimeType });
  101655. this._mediaRecorder.ondataavailable = this._handleDataAvailable.bind(this);
  101656. this._mediaRecorder.onerror = this._handleError.bind(this);
  101657. this._mediaRecorder.onstop = this._handleStop.bind(this);
  101658. }
  101659. /**
  101660. * Returns wehther or not the VideoRecorder is available in your browser.
  101661. * @param engine Defines the Babylon Engine to check the support for
  101662. * @returns true if supported otherwise false
  101663. */
  101664. VideoRecorder.IsSupported = function (engine) {
  101665. var canvas = engine.getRenderingCanvas();
  101666. return (!!canvas && typeof canvas.captureStream === "function");
  101667. };
  101668. Object.defineProperty(VideoRecorder.prototype, "isRecording", {
  101669. /**
  101670. * True wether a recording is already in progress.
  101671. */
  101672. get: function () {
  101673. return !!this._canvas && this._canvas.isRecording;
  101674. },
  101675. enumerable: true,
  101676. configurable: true
  101677. });
  101678. /**
  101679. * Stops the current recording before the default capture timeout passed in the startRecording
  101680. * functions.
  101681. */
  101682. VideoRecorder.prototype.stopRecording = function () {
  101683. if (!this._canvas || !this._mediaRecorder) {
  101684. return;
  101685. }
  101686. if (!this.isRecording) {
  101687. return;
  101688. }
  101689. this._canvas.isRecording = false;
  101690. this._mediaRecorder.stop();
  101691. };
  101692. /**
  101693. * Starts recording the canvas for a max duration specified in parameters.
  101694. * @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.
  101695. * @param maxDuration Defines the maximum recording time in seconds.
  101696. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  101697. * @return a promise callback at the end of the recording with the video data in Blob.
  101698. */
  101699. VideoRecorder.prototype.startRecording = function (fileName, maxDuration) {
  101700. var _this = this;
  101701. if (fileName === void 0) { fileName = "babylonjs.webm"; }
  101702. if (maxDuration === void 0) { maxDuration = 7; }
  101703. if (!this._canvas || !this._mediaRecorder) {
  101704. throw "Recorder has already been disposed";
  101705. }
  101706. if (this.isRecording) {
  101707. throw "Recording already in progress";
  101708. }
  101709. if (maxDuration > 0) {
  101710. setTimeout(function () {
  101711. _this.stopRecording();
  101712. }, maxDuration * 1000);
  101713. }
  101714. this._fileName = fileName;
  101715. this._recordedChunks = [];
  101716. this._resolve = null;
  101717. this._reject = null;
  101718. this._canvas.isRecording = true;
  101719. this._mediaRecorder.start(this._options.recordChunckSize);
  101720. return new Promise(function (resolve, reject) {
  101721. _this._resolve = resolve;
  101722. _this._reject = reject;
  101723. });
  101724. };
  101725. /**
  101726. * Releases internal resources used during the recording.
  101727. */
  101728. VideoRecorder.prototype.dispose = function () {
  101729. this._canvas = null;
  101730. this._mediaRecorder = null;
  101731. this._recordedChunks = [];
  101732. this._fileName = null;
  101733. this._resolve = null;
  101734. this._reject = null;
  101735. };
  101736. VideoRecorder.prototype._handleDataAvailable = function (event) {
  101737. if (event.data.size > 0) {
  101738. this._recordedChunks.push(event.data);
  101739. }
  101740. };
  101741. VideoRecorder.prototype._handleError = function (event) {
  101742. this.stopRecording();
  101743. if (this._reject) {
  101744. this._reject(event.error);
  101745. }
  101746. else {
  101747. throw new event.error();
  101748. }
  101749. };
  101750. VideoRecorder.prototype._handleStop = function () {
  101751. this.stopRecording();
  101752. var superBuffer = new Blob(this._recordedChunks);
  101753. if (this._resolve) {
  101754. this._resolve(superBuffer);
  101755. }
  101756. window.URL.createObjectURL(superBuffer);
  101757. if (this._fileName) {
  101758. _tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Download(superBuffer, this._fileName);
  101759. }
  101760. };
  101761. VideoRecorder._defaultOptions = {
  101762. mimeType: "video/webm",
  101763. fps: 25,
  101764. recordChunckSize: 3000
  101765. };
  101766. return VideoRecorder;
  101767. }());
  101768. /***/ }),
  101769. /***/ "./Misc/virtualJoystick.ts":
  101770. /*!*********************************!*\
  101771. !*** ./Misc/virtualJoystick.ts ***!
  101772. \*********************************/
  101773. /*! exports provided: JoystickAxis, VirtualJoystick */
  101774. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101775. "use strict";
  101776. __webpack_require__.r(__webpack_exports__);
  101777. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return JoystickAxis; });
  101778. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return VirtualJoystick; });
  101779. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  101780. /* harmony import */ var _stringDictionary__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stringDictionary */ "./Misc/stringDictionary.ts");
  101781. // Mainly based on these 2 articles :
  101782. // 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
  101783. // & on Seb Lee-Delisle original work: http://seb.ly/2011/04/multi-touch-game-controller-in-javascripthtml5-for-ipad/
  101784. /**
  101785. * Defines the potential axis of a Joystick
  101786. */
  101787. var JoystickAxis;
  101788. (function (JoystickAxis) {
  101789. /** X axis */
  101790. JoystickAxis[JoystickAxis["X"] = 0] = "X";
  101791. /** Y axis */
  101792. JoystickAxis[JoystickAxis["Y"] = 1] = "Y";
  101793. /** Z axis */
  101794. JoystickAxis[JoystickAxis["Z"] = 2] = "Z";
  101795. })(JoystickAxis || (JoystickAxis = {}));
  101796. /**
  101797. * Class used to define virtual joystick (used in touch mode)
  101798. */
  101799. var VirtualJoystick = /** @class */ (function () {
  101800. /**
  101801. * Creates a new virtual joystick
  101802. * @param leftJoystick defines that the joystick is for left hand (false by default)
  101803. */
  101804. function VirtualJoystick(leftJoystick) {
  101805. var _this = this;
  101806. if (leftJoystick) {
  101807. this._leftJoystick = true;
  101808. }
  101809. else {
  101810. this._leftJoystick = false;
  101811. }
  101812. VirtualJoystick._globalJoystickIndex++;
  101813. // By default left & right arrow keys are moving the X
  101814. // and up & down keys are moving the Y
  101815. this._axisTargetedByLeftAndRight = JoystickAxis.X;
  101816. this._axisTargetedByUpAndDown = JoystickAxis.Y;
  101817. this.reverseLeftRight = false;
  101818. this.reverseUpDown = false;
  101819. // collections of pointers
  101820. this._touches = new _stringDictionary__WEBPACK_IMPORTED_MODULE_1__["StringDictionary"]();
  101821. this.deltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  101822. this._joystickSensibility = 25;
  101823. this._inversedSensibility = 1 / (this._joystickSensibility / 1000);
  101824. this._onResize = function (evt) {
  101825. VirtualJoystick.vjCanvasWidth = window.innerWidth;
  101826. VirtualJoystick.vjCanvasHeight = window.innerHeight;
  101827. if (VirtualJoystick.Canvas) {
  101828. VirtualJoystick.Canvas.width = VirtualJoystick.vjCanvasWidth;
  101829. VirtualJoystick.Canvas.height = VirtualJoystick.vjCanvasHeight;
  101830. }
  101831. VirtualJoystick.halfWidth = VirtualJoystick.vjCanvasWidth / 2;
  101832. };
  101833. // injecting a canvas element on top of the canvas 3D game
  101834. if (!VirtualJoystick.Canvas) {
  101835. window.addEventListener("resize", this._onResize, false);
  101836. VirtualJoystick.Canvas = document.createElement("canvas");
  101837. VirtualJoystick.vjCanvasWidth = window.innerWidth;
  101838. VirtualJoystick.vjCanvasHeight = window.innerHeight;
  101839. VirtualJoystick.Canvas.width = window.innerWidth;
  101840. VirtualJoystick.Canvas.height = window.innerHeight;
  101841. VirtualJoystick.Canvas.style.width = "100%";
  101842. VirtualJoystick.Canvas.style.height = "100%";
  101843. VirtualJoystick.Canvas.style.position = "absolute";
  101844. VirtualJoystick.Canvas.style.backgroundColor = "transparent";
  101845. VirtualJoystick.Canvas.style.top = "0px";
  101846. VirtualJoystick.Canvas.style.left = "0px";
  101847. VirtualJoystick.Canvas.style.zIndex = "5";
  101848. VirtualJoystick.Canvas.style.msTouchAction = "none";
  101849. // Support for jQuery PEP polyfill
  101850. VirtualJoystick.Canvas.setAttribute("touch-action", "none");
  101851. var context = VirtualJoystick.Canvas.getContext('2d');
  101852. if (!context) {
  101853. throw new Error("Unable to create canvas for virtual joystick");
  101854. }
  101855. VirtualJoystick.vjCanvasContext = context;
  101856. VirtualJoystick.vjCanvasContext.strokeStyle = "#ffffff";
  101857. VirtualJoystick.vjCanvasContext.lineWidth = 2;
  101858. document.body.appendChild(VirtualJoystick.Canvas);
  101859. }
  101860. VirtualJoystick.halfWidth = VirtualJoystick.Canvas.width / 2;
  101861. this.pressed = false;
  101862. // default joystick color
  101863. this._joystickColor = "cyan";
  101864. this._joystickPointerID = -1;
  101865. // current joystick position
  101866. this._joystickPointerPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  101867. this._joystickPreviousPointerPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  101868. // origin joystick position
  101869. this._joystickPointerStartPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  101870. this._deltaJoystickVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  101871. this._onPointerDownHandlerRef = function (evt) {
  101872. _this._onPointerDown(evt);
  101873. };
  101874. this._onPointerMoveHandlerRef = function (evt) {
  101875. _this._onPointerMove(evt);
  101876. };
  101877. this._onPointerUpHandlerRef = function (evt) {
  101878. _this._onPointerUp(evt);
  101879. };
  101880. VirtualJoystick.Canvas.addEventListener('pointerdown', this._onPointerDownHandlerRef, false);
  101881. VirtualJoystick.Canvas.addEventListener('pointermove', this._onPointerMoveHandlerRef, false);
  101882. VirtualJoystick.Canvas.addEventListener('pointerup', this._onPointerUpHandlerRef, false);
  101883. VirtualJoystick.Canvas.addEventListener('pointerout', this._onPointerUpHandlerRef, false);
  101884. VirtualJoystick.Canvas.addEventListener("contextmenu", function (evt) {
  101885. evt.preventDefault(); // Disables system menu
  101886. }, false);
  101887. requestAnimationFrame(function () { _this._drawVirtualJoystick(); });
  101888. }
  101889. /**
  101890. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  101891. * @param newJoystickSensibility defines the new sensibility
  101892. */
  101893. VirtualJoystick.prototype.setJoystickSensibility = function (newJoystickSensibility) {
  101894. this._joystickSensibility = newJoystickSensibility;
  101895. this._inversedSensibility = 1 / (this._joystickSensibility / 1000);
  101896. };
  101897. VirtualJoystick.prototype._onPointerDown = function (e) {
  101898. var positionOnScreenCondition;
  101899. e.preventDefault();
  101900. if (this._leftJoystick === true) {
  101901. positionOnScreenCondition = (e.clientX < VirtualJoystick.halfWidth);
  101902. }
  101903. else {
  101904. positionOnScreenCondition = (e.clientX > VirtualJoystick.halfWidth);
  101905. }
  101906. if (positionOnScreenCondition && this._joystickPointerID < 0) {
  101907. // First contact will be dedicated to the virtual joystick
  101908. this._joystickPointerID = e.pointerId;
  101909. this._joystickPointerStartPos.x = e.clientX;
  101910. this._joystickPointerStartPos.y = e.clientY;
  101911. this._joystickPointerPos = this._joystickPointerStartPos.clone();
  101912. this._joystickPreviousPointerPos = this._joystickPointerStartPos.clone();
  101913. this._deltaJoystickVector.x = 0;
  101914. this._deltaJoystickVector.y = 0;
  101915. this.pressed = true;
  101916. this._touches.add(e.pointerId.toString(), e);
  101917. }
  101918. else {
  101919. // You can only trigger the action buttons with a joystick declared
  101920. if (VirtualJoystick._globalJoystickIndex < 2 && this._action) {
  101921. this._action();
  101922. this._touches.add(e.pointerId.toString(), { x: e.clientX, y: e.clientY, prevX: e.clientX, prevY: e.clientY });
  101923. }
  101924. }
  101925. };
  101926. VirtualJoystick.prototype._onPointerMove = function (e) {
  101927. // If the current pointer is the one associated to the joystick (first touch contact)
  101928. if (this._joystickPointerID == e.pointerId) {
  101929. this._joystickPointerPos.x = e.clientX;
  101930. this._joystickPointerPos.y = e.clientY;
  101931. this._deltaJoystickVector = this._joystickPointerPos.clone();
  101932. this._deltaJoystickVector = this._deltaJoystickVector.subtract(this._joystickPointerStartPos);
  101933. var directionLeftRight = this.reverseLeftRight ? -1 : 1;
  101934. var deltaJoystickX = directionLeftRight * this._deltaJoystickVector.x / this._inversedSensibility;
  101935. switch (this._axisTargetedByLeftAndRight) {
  101936. case JoystickAxis.X:
  101937. this.deltaPosition.x = Math.min(1, Math.max(-1, deltaJoystickX));
  101938. break;
  101939. case JoystickAxis.Y:
  101940. this.deltaPosition.y = Math.min(1, Math.max(-1, deltaJoystickX));
  101941. break;
  101942. case JoystickAxis.Z:
  101943. this.deltaPosition.z = Math.min(1, Math.max(-1, deltaJoystickX));
  101944. break;
  101945. }
  101946. var directionUpDown = this.reverseUpDown ? 1 : -1;
  101947. var deltaJoystickY = directionUpDown * this._deltaJoystickVector.y / this._inversedSensibility;
  101948. switch (this._axisTargetedByUpAndDown) {
  101949. case JoystickAxis.X:
  101950. this.deltaPosition.x = Math.min(1, Math.max(-1, deltaJoystickY));
  101951. break;
  101952. case JoystickAxis.Y:
  101953. this.deltaPosition.y = Math.min(1, Math.max(-1, deltaJoystickY));
  101954. break;
  101955. case JoystickAxis.Z:
  101956. this.deltaPosition.z = Math.min(1, Math.max(-1, deltaJoystickY));
  101957. break;
  101958. }
  101959. }
  101960. else {
  101961. var data = this._touches.get(e.pointerId.toString());
  101962. if (data) {
  101963. data.x = e.clientX;
  101964. data.y = e.clientY;
  101965. }
  101966. }
  101967. };
  101968. VirtualJoystick.prototype._onPointerUp = function (e) {
  101969. if (this._joystickPointerID == e.pointerId) {
  101970. VirtualJoystick.vjCanvasContext.clearRect(this._joystickPointerStartPos.x - 64, this._joystickPointerStartPos.y - 64, 128, 128);
  101971. VirtualJoystick.vjCanvasContext.clearRect(this._joystickPreviousPointerPos.x - 42, this._joystickPreviousPointerPos.y - 42, 84, 84);
  101972. this._joystickPointerID = -1;
  101973. this.pressed = false;
  101974. }
  101975. else {
  101976. var touch = this._touches.get(e.pointerId.toString());
  101977. if (touch) {
  101978. VirtualJoystick.vjCanvasContext.clearRect(touch.prevX - 44, touch.prevY - 44, 88, 88);
  101979. }
  101980. }
  101981. this._deltaJoystickVector.x = 0;
  101982. this._deltaJoystickVector.y = 0;
  101983. this._touches.remove(e.pointerId.toString());
  101984. };
  101985. /**
  101986. * Change the color of the virtual joystick
  101987. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  101988. */
  101989. VirtualJoystick.prototype.setJoystickColor = function (newColor) {
  101990. this._joystickColor = newColor;
  101991. };
  101992. /**
  101993. * Defines a callback to call when the joystick is touched
  101994. * @param action defines the callback
  101995. */
  101996. VirtualJoystick.prototype.setActionOnTouch = function (action) {
  101997. this._action = action;
  101998. };
  101999. /**
  102000. * Defines which axis you'd like to control for left & right
  102001. * @param axis defines the axis to use
  102002. */
  102003. VirtualJoystick.prototype.setAxisForLeftRight = function (axis) {
  102004. switch (axis) {
  102005. case JoystickAxis.X:
  102006. case JoystickAxis.Y:
  102007. case JoystickAxis.Z:
  102008. this._axisTargetedByLeftAndRight = axis;
  102009. break;
  102010. default:
  102011. this._axisTargetedByLeftAndRight = JoystickAxis.X;
  102012. break;
  102013. }
  102014. };
  102015. /**
  102016. * Defines which axis you'd like to control for up & down
  102017. * @param axis defines the axis to use
  102018. */
  102019. VirtualJoystick.prototype.setAxisForUpDown = function (axis) {
  102020. switch (axis) {
  102021. case JoystickAxis.X:
  102022. case JoystickAxis.Y:
  102023. case JoystickAxis.Z:
  102024. this._axisTargetedByUpAndDown = axis;
  102025. break;
  102026. default:
  102027. this._axisTargetedByUpAndDown = JoystickAxis.Y;
  102028. break;
  102029. }
  102030. };
  102031. VirtualJoystick.prototype._drawVirtualJoystick = function () {
  102032. var _this = this;
  102033. if (this.pressed) {
  102034. this._touches.forEach(function (key, touch) {
  102035. if (touch.pointerId === _this._joystickPointerID) {
  102036. VirtualJoystick.vjCanvasContext.clearRect(_this._joystickPointerStartPos.x - 64, _this._joystickPointerStartPos.y - 64, 128, 128);
  102037. VirtualJoystick.vjCanvasContext.clearRect(_this._joystickPreviousPointerPos.x - 42, _this._joystickPreviousPointerPos.y - 42, 84, 84);
  102038. VirtualJoystick.vjCanvasContext.beginPath();
  102039. VirtualJoystick.vjCanvasContext.lineWidth = 6;
  102040. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  102041. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerStartPos.x, _this._joystickPointerStartPos.y, 40, 0, Math.PI * 2, true);
  102042. VirtualJoystick.vjCanvasContext.stroke();
  102043. VirtualJoystick.vjCanvasContext.closePath();
  102044. VirtualJoystick.vjCanvasContext.beginPath();
  102045. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  102046. VirtualJoystick.vjCanvasContext.lineWidth = 2;
  102047. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerStartPos.x, _this._joystickPointerStartPos.y, 60, 0, Math.PI * 2, true);
  102048. VirtualJoystick.vjCanvasContext.stroke();
  102049. VirtualJoystick.vjCanvasContext.closePath();
  102050. VirtualJoystick.vjCanvasContext.beginPath();
  102051. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  102052. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerPos.x, _this._joystickPointerPos.y, 40, 0, Math.PI * 2, true);
  102053. VirtualJoystick.vjCanvasContext.stroke();
  102054. VirtualJoystick.vjCanvasContext.closePath();
  102055. _this._joystickPreviousPointerPos = _this._joystickPointerPos.clone();
  102056. }
  102057. else {
  102058. VirtualJoystick.vjCanvasContext.clearRect(touch.prevX - 44, touch.prevY - 44, 88, 88);
  102059. VirtualJoystick.vjCanvasContext.beginPath();
  102060. VirtualJoystick.vjCanvasContext.fillStyle = "white";
  102061. VirtualJoystick.vjCanvasContext.beginPath();
  102062. VirtualJoystick.vjCanvasContext.strokeStyle = "red";
  102063. VirtualJoystick.vjCanvasContext.lineWidth = 6;
  102064. VirtualJoystick.vjCanvasContext.arc(touch.x, touch.y, 40, 0, Math.PI * 2, true);
  102065. VirtualJoystick.vjCanvasContext.stroke();
  102066. VirtualJoystick.vjCanvasContext.closePath();
  102067. touch.prevX = touch.x;
  102068. touch.prevY = touch.y;
  102069. }
  102070. });
  102071. }
  102072. requestAnimationFrame(function () { _this._drawVirtualJoystick(); });
  102073. };
  102074. /**
  102075. * Release internal HTML canvas
  102076. */
  102077. VirtualJoystick.prototype.releaseCanvas = function () {
  102078. if (VirtualJoystick.Canvas) {
  102079. VirtualJoystick.Canvas.removeEventListener('pointerdown', this._onPointerDownHandlerRef);
  102080. VirtualJoystick.Canvas.removeEventListener('pointermove', this._onPointerMoveHandlerRef);
  102081. VirtualJoystick.Canvas.removeEventListener('pointerup', this._onPointerUpHandlerRef);
  102082. VirtualJoystick.Canvas.removeEventListener('pointerout', this._onPointerUpHandlerRef);
  102083. window.removeEventListener("resize", this._onResize);
  102084. document.body.removeChild(VirtualJoystick.Canvas);
  102085. VirtualJoystick.Canvas = null;
  102086. }
  102087. };
  102088. // Used to draw the virtual joystick inside a 2D canvas on top of the WebGL rendering canvas
  102089. VirtualJoystick._globalJoystickIndex = 0;
  102090. return VirtualJoystick;
  102091. }());
  102092. /***/ }),
  102093. /***/ "./Misc/workerPool.ts":
  102094. /*!****************************!*\
  102095. !*** ./Misc/workerPool.ts ***!
  102096. \****************************/
  102097. /*! exports provided: WorkerPool */
  102098. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102099. "use strict";
  102100. __webpack_require__.r(__webpack_exports__);
  102101. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return WorkerPool; });
  102102. /**
  102103. * Helper class to push actions to a pool of workers.
  102104. */
  102105. var WorkerPool = /** @class */ (function () {
  102106. /**
  102107. * Constructor
  102108. * @param workers Array of workers to use for actions
  102109. */
  102110. function WorkerPool(workers) {
  102111. this._pendingActions = new Array();
  102112. this._workerInfos = workers.map(function (worker) { return ({
  102113. worker: worker,
  102114. active: false
  102115. }); });
  102116. }
  102117. /**
  102118. * Terminates all workers and clears any pending actions.
  102119. */
  102120. WorkerPool.prototype.dispose = function () {
  102121. for (var _i = 0, _a = this._workerInfos; _i < _a.length; _i++) {
  102122. var workerInfo = _a[_i];
  102123. workerInfo.worker.terminate();
  102124. }
  102125. delete this._workerInfos;
  102126. delete this._pendingActions;
  102127. };
  102128. /**
  102129. * Pushes an action to the worker pool. If all the workers are active, the action will be
  102130. * pended until a worker has completed its action.
  102131. * @param action The action to perform. Call onComplete when the action is complete.
  102132. */
  102133. WorkerPool.prototype.push = function (action) {
  102134. for (var _i = 0, _a = this._workerInfos; _i < _a.length; _i++) {
  102135. var workerInfo = _a[_i];
  102136. if (!workerInfo.active) {
  102137. this._execute(workerInfo, action);
  102138. return;
  102139. }
  102140. }
  102141. this._pendingActions.push(action);
  102142. };
  102143. WorkerPool.prototype._execute = function (workerInfo, action) {
  102144. var _this = this;
  102145. workerInfo.active = true;
  102146. action(workerInfo.worker, function () {
  102147. workerInfo.active = false;
  102148. var nextAction = _this._pendingActions.shift();
  102149. if (nextAction) {
  102150. _this._execute(workerInfo, nextAction);
  102151. }
  102152. });
  102153. };
  102154. return WorkerPool;
  102155. }());
  102156. /***/ }),
  102157. /***/ "./Morph/index.ts":
  102158. /*!************************!*\
  102159. !*** ./Morph/index.ts ***!
  102160. \************************/
  102161. /*! exports provided: MorphTarget, MorphTargetManager */
  102162. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102163. "use strict";
  102164. __webpack_require__.r(__webpack_exports__);
  102165. /* harmony import */ var _morphTarget__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./morphTarget */ "./Morph/morphTarget.ts");
  102166. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _morphTarget__WEBPACK_IMPORTED_MODULE_0__["MorphTarget"]; });
  102167. /* harmony import */ var _morphTargetManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./morphTargetManager */ "./Morph/morphTargetManager.ts");
  102168. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _morphTargetManager__WEBPACK_IMPORTED_MODULE_1__["MorphTargetManager"]; });
  102169. /***/ }),
  102170. /***/ "./Morph/morphTarget.ts":
  102171. /*!******************************!*\
  102172. !*** ./Morph/morphTarget.ts ***!
  102173. \******************************/
  102174. /*! exports provided: MorphTarget */
  102175. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102176. "use strict";
  102177. __webpack_require__.r(__webpack_exports__);
  102178. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return MorphTarget; });
  102179. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  102180. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  102181. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  102182. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  102183. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  102184. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  102185. /**
  102186. * Defines a target to use with MorphTargetManager
  102187. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  102188. */
  102189. var MorphTarget = /** @class */ (function () {
  102190. /**
  102191. * Creates a new MorphTarget
  102192. * @param name defines the name of the target
  102193. * @param influence defines the influence to use
  102194. * @param scene defines the scene the morphtarget belongs to
  102195. */
  102196. function MorphTarget(
  102197. /** defines the name of the target */
  102198. name, influence, scene) {
  102199. if (influence === void 0) { influence = 0; }
  102200. if (scene === void 0) { scene = null; }
  102201. this.name = name;
  102202. /**
  102203. * Gets or sets the list of animations
  102204. */
  102205. this.animations = new Array();
  102206. this._positions = null;
  102207. this._normals = null;
  102208. this._tangents = null;
  102209. /**
  102210. * Observable raised when the influence changes
  102211. */
  102212. this.onInfluenceChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  102213. /** @hidden */
  102214. this._onDataLayoutChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  102215. this._animationPropertiesOverride = null;
  102216. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  102217. this.influence = influence;
  102218. }
  102219. Object.defineProperty(MorphTarget.prototype, "influence", {
  102220. /**
  102221. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  102222. */
  102223. get: function () {
  102224. return this._influence;
  102225. },
  102226. set: function (influence) {
  102227. if (this._influence === influence) {
  102228. return;
  102229. }
  102230. var previous = this._influence;
  102231. this._influence = influence;
  102232. if (this.onInfluenceChanged.hasObservers) {
  102233. this.onInfluenceChanged.notifyObservers(previous === 0 || influence === 0);
  102234. }
  102235. },
  102236. enumerable: true,
  102237. configurable: true
  102238. });
  102239. Object.defineProperty(MorphTarget.prototype, "animationPropertiesOverride", {
  102240. /**
  102241. * Gets or sets the animation properties override
  102242. */
  102243. get: function () {
  102244. if (!this._animationPropertiesOverride && this._scene) {
  102245. return this._scene.animationPropertiesOverride;
  102246. }
  102247. return this._animationPropertiesOverride;
  102248. },
  102249. set: function (value) {
  102250. this._animationPropertiesOverride = value;
  102251. },
  102252. enumerable: true,
  102253. configurable: true
  102254. });
  102255. Object.defineProperty(MorphTarget.prototype, "hasPositions", {
  102256. /**
  102257. * Gets a boolean defining if the target contains position data
  102258. */
  102259. get: function () {
  102260. return !!this._positions;
  102261. },
  102262. enumerable: true,
  102263. configurable: true
  102264. });
  102265. Object.defineProperty(MorphTarget.prototype, "hasNormals", {
  102266. /**
  102267. * Gets a boolean defining if the target contains normal data
  102268. */
  102269. get: function () {
  102270. return !!this._normals;
  102271. },
  102272. enumerable: true,
  102273. configurable: true
  102274. });
  102275. Object.defineProperty(MorphTarget.prototype, "hasTangents", {
  102276. /**
  102277. * Gets a boolean defining if the target contains tangent data
  102278. */
  102279. get: function () {
  102280. return !!this._tangents;
  102281. },
  102282. enumerable: true,
  102283. configurable: true
  102284. });
  102285. /**
  102286. * Affects position data to this target
  102287. * @param data defines the position data to use
  102288. */
  102289. MorphTarget.prototype.setPositions = function (data) {
  102290. var hadPositions = this.hasPositions;
  102291. this._positions = data;
  102292. if (hadPositions !== this.hasPositions) {
  102293. this._onDataLayoutChanged.notifyObservers(undefined);
  102294. }
  102295. };
  102296. /**
  102297. * Gets the position data stored in this target
  102298. * @returns a FloatArray containing the position data (or null if not present)
  102299. */
  102300. MorphTarget.prototype.getPositions = function () {
  102301. return this._positions;
  102302. };
  102303. /**
  102304. * Affects normal data to this target
  102305. * @param data defines the normal data to use
  102306. */
  102307. MorphTarget.prototype.setNormals = function (data) {
  102308. var hadNormals = this.hasNormals;
  102309. this._normals = data;
  102310. if (hadNormals !== this.hasNormals) {
  102311. this._onDataLayoutChanged.notifyObservers(undefined);
  102312. }
  102313. };
  102314. /**
  102315. * Gets the normal data stored in this target
  102316. * @returns a FloatArray containing the normal data (or null if not present)
  102317. */
  102318. MorphTarget.prototype.getNormals = function () {
  102319. return this._normals;
  102320. };
  102321. /**
  102322. * Affects tangent data to this target
  102323. * @param data defines the tangent data to use
  102324. */
  102325. MorphTarget.prototype.setTangents = function (data) {
  102326. var hadTangents = this.hasTangents;
  102327. this._tangents = data;
  102328. if (hadTangents !== this.hasTangents) {
  102329. this._onDataLayoutChanged.notifyObservers(undefined);
  102330. }
  102331. };
  102332. /**
  102333. * Gets the tangent data stored in this target
  102334. * @returns a FloatArray containing the tangent data (or null if not present)
  102335. */
  102336. MorphTarget.prototype.getTangents = function () {
  102337. return this._tangents;
  102338. };
  102339. /**
  102340. * Serializes the current target into a Serialization object
  102341. * @returns the serialized object
  102342. */
  102343. MorphTarget.prototype.serialize = function () {
  102344. var serializationObject = {};
  102345. serializationObject.name = this.name;
  102346. serializationObject.influence = this.influence;
  102347. serializationObject.positions = Array.prototype.slice.call(this.getPositions());
  102348. if (this.id != null) {
  102349. serializationObject.id = this.id;
  102350. }
  102351. if (this.hasNormals) {
  102352. serializationObject.normals = Array.prototype.slice.call(this.getNormals());
  102353. }
  102354. if (this.hasTangents) {
  102355. serializationObject.tangents = Array.prototype.slice.call(this.getTangents());
  102356. }
  102357. // Animations
  102358. _Misc_decorators__WEBPACK_IMPORTED_MODULE_4__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  102359. return serializationObject;
  102360. };
  102361. /**
  102362. * Returns the string "MorphTarget"
  102363. * @returns "MorphTarget"
  102364. */
  102365. MorphTarget.prototype.getClassName = function () {
  102366. return "MorphTarget";
  102367. };
  102368. // Statics
  102369. /**
  102370. * Creates a new target from serialized data
  102371. * @param serializationObject defines the serialized data to use
  102372. * @returns a new MorphTarget
  102373. */
  102374. MorphTarget.Parse = function (serializationObject) {
  102375. var result = new MorphTarget(serializationObject.name, serializationObject.influence);
  102376. result.setPositions(serializationObject.positions);
  102377. if (serializationObject.id != null) {
  102378. result.id = serializationObject.id;
  102379. }
  102380. if (serializationObject.normals) {
  102381. result.setNormals(serializationObject.normals);
  102382. }
  102383. if (serializationObject.tangents) {
  102384. result.setTangents(serializationObject.tangents);
  102385. }
  102386. // Animations
  102387. if (serializationObject.animations) {
  102388. for (var animationIndex = 0; animationIndex < serializationObject.animations.length; animationIndex++) {
  102389. var parsedAnimation = serializationObject.animations[animationIndex];
  102390. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].GetClass("BABYLON.Animation");
  102391. if (internalClass) {
  102392. result.animations.push(internalClass.Parse(parsedAnimation));
  102393. }
  102394. }
  102395. }
  102396. return result;
  102397. };
  102398. /**
  102399. * Creates a MorphTarget from mesh data
  102400. * @param mesh defines the source mesh
  102401. * @param name defines the name to use for the new target
  102402. * @param influence defines the influence to attach to the target
  102403. * @returns a new MorphTarget
  102404. */
  102405. MorphTarget.FromMesh = function (mesh, name, influence) {
  102406. if (!name) {
  102407. name = mesh.name;
  102408. }
  102409. var result = new MorphTarget(name, influence, mesh.getScene());
  102410. result.setPositions(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind));
  102411. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind)) {
  102412. result.setNormals(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind));
  102413. }
  102414. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind)) {
  102415. result.setTangents(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind));
  102416. }
  102417. return result;
  102418. };
  102419. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  102420. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_4__["serialize"])()
  102421. ], MorphTarget.prototype, "id", void 0);
  102422. return MorphTarget;
  102423. }());
  102424. /***/ }),
  102425. /***/ "./Morph/morphTargetManager.ts":
  102426. /*!*************************************!*\
  102427. !*** ./Morph/morphTargetManager.ts ***!
  102428. \*************************************/
  102429. /*! exports provided: MorphTargetManager */
  102430. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102431. "use strict";
  102432. __webpack_require__.r(__webpack_exports__);
  102433. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return MorphTargetManager; });
  102434. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  102435. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  102436. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  102437. /* harmony import */ var _morphTarget__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./morphTarget */ "./Morph/morphTarget.ts");
  102438. /**
  102439. * This class is used to deform meshes using morphing between different targets
  102440. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  102441. */
  102442. var MorphTargetManager = /** @class */ (function () {
  102443. /**
  102444. * Creates a new MorphTargetManager
  102445. * @param scene defines the current scene
  102446. */
  102447. function MorphTargetManager(scene) {
  102448. if (scene === void 0) { scene = null; }
  102449. this._targets = new Array();
  102450. this._targetInfluenceChangedObservers = new Array();
  102451. this._targetDataLayoutChangedObservers = new Array();
  102452. this._activeTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](16);
  102453. this._supportsNormals = false;
  102454. this._supportsTangents = false;
  102455. this._vertexCount = 0;
  102456. this._uniqueId = 0;
  102457. this._tempInfluences = new Array();
  102458. if (!scene) {
  102459. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  102460. }
  102461. this._scene = scene;
  102462. if (this._scene) {
  102463. this._scene.morphTargetManagers.push(this);
  102464. this._uniqueId = this._scene.getUniqueId();
  102465. }
  102466. }
  102467. Object.defineProperty(MorphTargetManager.prototype, "uniqueId", {
  102468. /**
  102469. * Gets the unique ID of this manager
  102470. */
  102471. get: function () {
  102472. return this._uniqueId;
  102473. },
  102474. enumerable: true,
  102475. configurable: true
  102476. });
  102477. Object.defineProperty(MorphTargetManager.prototype, "vertexCount", {
  102478. /**
  102479. * Gets the number of vertices handled by this manager
  102480. */
  102481. get: function () {
  102482. return this._vertexCount;
  102483. },
  102484. enumerable: true,
  102485. configurable: true
  102486. });
  102487. Object.defineProperty(MorphTargetManager.prototype, "supportsNormals", {
  102488. /**
  102489. * Gets a boolean indicating if this manager supports morphing of normals
  102490. */
  102491. get: function () {
  102492. return this._supportsNormals;
  102493. },
  102494. enumerable: true,
  102495. configurable: true
  102496. });
  102497. Object.defineProperty(MorphTargetManager.prototype, "supportsTangents", {
  102498. /**
  102499. * Gets a boolean indicating if this manager supports morphing of tangents
  102500. */
  102501. get: function () {
  102502. return this._supportsTangents;
  102503. },
  102504. enumerable: true,
  102505. configurable: true
  102506. });
  102507. Object.defineProperty(MorphTargetManager.prototype, "numTargets", {
  102508. /**
  102509. * Gets the number of targets stored in this manager
  102510. */
  102511. get: function () {
  102512. return this._targets.length;
  102513. },
  102514. enumerable: true,
  102515. configurable: true
  102516. });
  102517. Object.defineProperty(MorphTargetManager.prototype, "numInfluencers", {
  102518. /**
  102519. * Gets the number of influencers (ie. the number of targets with influences > 0)
  102520. */
  102521. get: function () {
  102522. return this._activeTargets.length;
  102523. },
  102524. enumerable: true,
  102525. configurable: true
  102526. });
  102527. Object.defineProperty(MorphTargetManager.prototype, "influences", {
  102528. /**
  102529. * Gets the list of influences (one per target)
  102530. */
  102531. get: function () {
  102532. return this._influences;
  102533. },
  102534. enumerable: true,
  102535. configurable: true
  102536. });
  102537. /**
  102538. * Gets the active target at specified index. An active target is a target with an influence > 0
  102539. * @param index defines the index to check
  102540. * @returns the requested target
  102541. */
  102542. MorphTargetManager.prototype.getActiveTarget = function (index) {
  102543. return this._activeTargets.data[index];
  102544. };
  102545. /**
  102546. * Gets the target at specified index
  102547. * @param index defines the index to check
  102548. * @returns the requested target
  102549. */
  102550. MorphTargetManager.prototype.getTarget = function (index) {
  102551. return this._targets[index];
  102552. };
  102553. /**
  102554. * Add a new target to this manager
  102555. * @param target defines the target to add
  102556. */
  102557. MorphTargetManager.prototype.addTarget = function (target) {
  102558. var _this = this;
  102559. this._targets.push(target);
  102560. this._targetInfluenceChangedObservers.push(target.onInfluenceChanged.add(function (needUpdate) {
  102561. _this._syncActiveTargets(needUpdate);
  102562. }));
  102563. this._targetDataLayoutChangedObservers.push(target._onDataLayoutChanged.add(function () {
  102564. _this._syncActiveTargets(true);
  102565. }));
  102566. this._syncActiveTargets(true);
  102567. };
  102568. /**
  102569. * Removes a target from the manager
  102570. * @param target defines the target to remove
  102571. */
  102572. MorphTargetManager.prototype.removeTarget = function (target) {
  102573. var index = this._targets.indexOf(target);
  102574. if (index >= 0) {
  102575. this._targets.splice(index, 1);
  102576. target.onInfluenceChanged.remove(this._targetInfluenceChangedObservers.splice(index, 1)[0]);
  102577. target._onDataLayoutChanged.remove(this._targetDataLayoutChangedObservers.splice(index, 1)[0]);
  102578. this._syncActiveTargets(true);
  102579. }
  102580. };
  102581. /**
  102582. * Serializes the current manager into a Serialization object
  102583. * @returns the serialized object
  102584. */
  102585. MorphTargetManager.prototype.serialize = function () {
  102586. var serializationObject = {};
  102587. serializationObject.id = this.uniqueId;
  102588. serializationObject.targets = [];
  102589. for (var _i = 0, _a = this._targets; _i < _a.length; _i++) {
  102590. var target = _a[_i];
  102591. serializationObject.targets.push(target.serialize());
  102592. }
  102593. return serializationObject;
  102594. };
  102595. MorphTargetManager.prototype._syncActiveTargets = function (needUpdate) {
  102596. var influenceCount = 0;
  102597. this._activeTargets.reset();
  102598. this._supportsNormals = true;
  102599. this._supportsTangents = true;
  102600. this._vertexCount = 0;
  102601. for (var _i = 0, _a = this._targets; _i < _a.length; _i++) {
  102602. var target = _a[_i];
  102603. if (target.influence === 0) {
  102604. continue;
  102605. }
  102606. this._activeTargets.push(target);
  102607. this._tempInfluences[influenceCount++] = target.influence;
  102608. this._supportsNormals = this._supportsNormals && target.hasNormals;
  102609. this._supportsTangents = this._supportsTangents && target.hasTangents;
  102610. var positions = target.getPositions();
  102611. if (positions) {
  102612. var vertexCount = positions.length / 3;
  102613. if (this._vertexCount === 0) {
  102614. this._vertexCount = vertexCount;
  102615. }
  102616. else if (this._vertexCount !== vertexCount) {
  102617. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Incompatible target. Targets must all have the same vertices count.");
  102618. return;
  102619. }
  102620. }
  102621. }
  102622. if (!this._influences || this._influences.length !== influenceCount) {
  102623. this._influences = new Float32Array(influenceCount);
  102624. }
  102625. for (var index = 0; index < influenceCount; index++) {
  102626. this._influences[index] = this._tempInfluences[index];
  102627. }
  102628. if (needUpdate) {
  102629. this.synchronize();
  102630. }
  102631. };
  102632. /**
  102633. * Syncrhonize the targets with all the meshes using this morph target manager
  102634. */
  102635. MorphTargetManager.prototype.synchronize = function () {
  102636. if (!this._scene) {
  102637. return;
  102638. }
  102639. // Flag meshes as dirty to resync with the active targets
  102640. for (var _i = 0, _a = this._scene.meshes; _i < _a.length; _i++) {
  102641. var mesh = _a[_i];
  102642. if (mesh.morphTargetManager === this) {
  102643. mesh._syncGeometryWithMorphTargetManager();
  102644. }
  102645. }
  102646. };
  102647. // Statics
  102648. /**
  102649. * Creates a new MorphTargetManager from serialized data
  102650. * @param serializationObject defines the serialized data
  102651. * @param scene defines the hosting scene
  102652. * @returns the new MorphTargetManager
  102653. */
  102654. MorphTargetManager.Parse = function (serializationObject, scene) {
  102655. var result = new MorphTargetManager(scene);
  102656. result._uniqueId = serializationObject.id;
  102657. for (var _i = 0, _a = serializationObject.targets; _i < _a.length; _i++) {
  102658. var targetData = _a[_i];
  102659. result.addTarget(_morphTarget__WEBPACK_IMPORTED_MODULE_3__["MorphTarget"].Parse(targetData));
  102660. }
  102661. return result;
  102662. };
  102663. return MorphTargetManager;
  102664. }());
  102665. /***/ }),
  102666. /***/ "./Offline/database.ts":
  102667. /*!*****************************!*\
  102668. !*** ./Offline/database.ts ***!
  102669. \*****************************/
  102670. /*! exports provided: Database */
  102671. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102672. "use strict";
  102673. __webpack_require__.r(__webpack_exports__);
  102674. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return Database; });
  102675. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  102676. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  102677. /* harmony import */ var _Misc_tga__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tga */ "./Misc/tga.ts");
  102678. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  102679. // Sets the default offline provider to Babylon.js
  102680. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].OfflineProviderFactory = function (urlToScene, callbackManifestChecked, disableManifestCheck) {
  102681. if (disableManifestCheck === void 0) { disableManifestCheck = false; }
  102682. return new Database(urlToScene, callbackManifestChecked, disableManifestCheck);
  102683. };
  102684. /**
  102685. * Class used to enable access to IndexedDB
  102686. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  102687. */
  102688. var Database = /** @class */ (function () {
  102689. /**
  102690. * Creates a new Database
  102691. * @param urlToScene defines the url to load the scene
  102692. * @param callbackManifestChecked defines the callback to use when manifest is checked
  102693. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  102694. */
  102695. function Database(urlToScene, callbackManifestChecked, disableManifestCheck) {
  102696. if (disableManifestCheck === void 0) { disableManifestCheck = false; }
  102697. var _this = this;
  102698. // Handling various flavors of prefixed version of IndexedDB
  102699. this._idbFactory = (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB);
  102700. this._callbackManifestChecked = callbackManifestChecked;
  102701. this._currentSceneUrl = Database._ReturnFullUrlLocation(urlToScene);
  102702. this._db = null;
  102703. this._enableSceneOffline = false;
  102704. this._enableTexturesOffline = false;
  102705. this._manifestVersionFound = 0;
  102706. this._mustUpdateRessources = false;
  102707. this._hasReachedQuota = false;
  102708. if (!Database.IDBStorageEnabled) {
  102709. this._callbackManifestChecked(true);
  102710. }
  102711. else {
  102712. if (disableManifestCheck) {
  102713. this._enableSceneOffline = true;
  102714. this._enableTexturesOffline = true;
  102715. this._manifestVersionFound = 1;
  102716. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetImmediate(function () {
  102717. _this._callbackManifestChecked(true);
  102718. });
  102719. }
  102720. else {
  102721. this._checkManifestFile();
  102722. }
  102723. }
  102724. }
  102725. Object.defineProperty(Database.prototype, "enableSceneOffline", {
  102726. /**
  102727. * Gets a boolean indicating if scene must be saved in the database
  102728. */
  102729. get: function () {
  102730. return this._enableSceneOffline;
  102731. },
  102732. enumerable: true,
  102733. configurable: true
  102734. });
  102735. Object.defineProperty(Database.prototype, "enableTexturesOffline", {
  102736. /**
  102737. * Gets a boolean indicating if textures must be saved in the database
  102738. */
  102739. get: function () {
  102740. return this._enableTexturesOffline;
  102741. },
  102742. enumerable: true,
  102743. configurable: true
  102744. });
  102745. Database.prototype._checkManifestFile = function () {
  102746. var _this = this;
  102747. var noManifestFile = function () {
  102748. _this._enableSceneOffline = false;
  102749. _this._enableTexturesOffline = false;
  102750. _this._callbackManifestChecked(false);
  102751. };
  102752. var timeStampUsed = false;
  102753. var manifestURL = this._currentSceneUrl + ".manifest";
  102754. var xhr = new XMLHttpRequest();
  102755. if (navigator.onLine) {
  102756. // Adding a timestamp to by-pass browsers' cache
  102757. timeStampUsed = true;
  102758. manifestURL = manifestURL + (manifestURL.match(/\?/) == null ? "?" : "&") + Date.now();
  102759. }
  102760. xhr.open("GET", manifestURL, true);
  102761. xhr.addEventListener("load", function () {
  102762. if (xhr.status === 200 || Database._ValidateXHRData(xhr, 1)) {
  102763. try {
  102764. var manifestFile = JSON.parse(xhr.response);
  102765. _this._enableSceneOffline = manifestFile.enableSceneOffline;
  102766. _this._enableTexturesOffline = manifestFile.enableTexturesOffline && Database.IsUASupportingBlobStorage;
  102767. if (manifestFile.version && !isNaN(parseInt(manifestFile.version))) {
  102768. _this._manifestVersionFound = manifestFile.version;
  102769. }
  102770. if (_this._callbackManifestChecked) {
  102771. _this._callbackManifestChecked(true);
  102772. }
  102773. }
  102774. catch (ex) {
  102775. noManifestFile();
  102776. }
  102777. }
  102778. else {
  102779. noManifestFile();
  102780. }
  102781. }, false);
  102782. xhr.addEventListener("error", function () {
  102783. if (timeStampUsed) {
  102784. timeStampUsed = false;
  102785. // Let's retry without the timeStamp
  102786. // It could fail when coupled with HTML5 Offline API
  102787. var retryManifestURL = _this._currentSceneUrl + ".manifest";
  102788. xhr.open("GET", retryManifestURL, true);
  102789. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].UseCustomRequestHeaders) {
  102790. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].InjectCustomRequestHeaders(xhr);
  102791. }
  102792. xhr.send();
  102793. }
  102794. else {
  102795. noManifestFile();
  102796. }
  102797. }, false);
  102798. try {
  102799. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].UseCustomRequestHeaders) {
  102800. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].InjectCustomRequestHeaders(xhr);
  102801. }
  102802. xhr.send();
  102803. }
  102804. catch (ex) {
  102805. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error on XHR send request.");
  102806. this._callbackManifestChecked(false);
  102807. }
  102808. };
  102809. /**
  102810. * Open the database and make it available
  102811. * @param successCallback defines the callback to call on success
  102812. * @param errorCallback defines the callback to call on error
  102813. */
  102814. Database.prototype.open = function (successCallback, errorCallback) {
  102815. var _this = this;
  102816. var handleError = function () {
  102817. _this._isSupported = false;
  102818. if (errorCallback) {
  102819. errorCallback();
  102820. }
  102821. };
  102822. if (!this._idbFactory || !(this._enableSceneOffline || this._enableTexturesOffline)) {
  102823. // Your browser doesn't support IndexedDB
  102824. this._isSupported = false;
  102825. if (errorCallback) {
  102826. errorCallback();
  102827. }
  102828. }
  102829. else {
  102830. // If the DB hasn't been opened or created yet
  102831. if (!this._db) {
  102832. this._hasReachedQuota = false;
  102833. this._isSupported = true;
  102834. var request = this._idbFactory.open("babylonjs", 1);
  102835. // Could occur if user is blocking the quota for the DB and/or doesn't grant access to IndexedDB
  102836. request.onerror = function () {
  102837. handleError();
  102838. };
  102839. // executes when a version change transaction cannot complete due to other active transactions
  102840. request.onblocked = function () {
  102841. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("IDB request blocked. Please reload the page.");
  102842. handleError();
  102843. };
  102844. // DB has been opened successfully
  102845. request.onsuccess = function () {
  102846. _this._db = request.result;
  102847. successCallback();
  102848. };
  102849. // Initialization of the DB. Creating Scenes & Textures stores
  102850. request.onupgradeneeded = function (event) {
  102851. _this._db = (event.target).result;
  102852. if (_this._db) {
  102853. try {
  102854. _this._db.createObjectStore("scenes", { keyPath: "sceneUrl" });
  102855. _this._db.createObjectStore("versions", { keyPath: "sceneUrl" });
  102856. _this._db.createObjectStore("textures", { keyPath: "textureUrl" });
  102857. }
  102858. catch (ex) {
  102859. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while creating object stores. Exception: " + ex.message);
  102860. handleError();
  102861. }
  102862. }
  102863. };
  102864. }
  102865. // DB has already been created and opened
  102866. else {
  102867. if (successCallback) {
  102868. successCallback();
  102869. }
  102870. }
  102871. }
  102872. };
  102873. /**
  102874. * Loads an image from the database
  102875. * @param url defines the url to load from
  102876. * @param image defines the target DOM image
  102877. */
  102878. Database.prototype.loadImage = function (url, image) {
  102879. var _this = this;
  102880. var completeURL = Database._ReturnFullUrlLocation(url);
  102881. var saveAndLoadImage = function () {
  102882. if (!_this._hasReachedQuota && _this._db !== null) {
  102883. // the texture is not yet in the DB, let's try to save it
  102884. _this._saveImageIntoDBAsync(completeURL, image);
  102885. }
  102886. // If the texture is not in the DB and we've reached the DB quota limit
  102887. // let's load it directly from the web
  102888. else {
  102889. image.src = url;
  102890. }
  102891. };
  102892. if (!this._mustUpdateRessources) {
  102893. this._loadImageFromDBAsync(completeURL, image, saveAndLoadImage);
  102894. }
  102895. // First time we're download the images or update requested in the manifest file by a version change
  102896. else {
  102897. saveAndLoadImage();
  102898. }
  102899. };
  102900. Database.prototype._loadImageFromDBAsync = function (url, image, notInDBCallback) {
  102901. if (this._isSupported && this._db !== null) {
  102902. var texture;
  102903. var transaction = this._db.transaction(["textures"]);
  102904. transaction.onabort = function () {
  102905. image.src = url;
  102906. };
  102907. transaction.oncomplete = function () {
  102908. var blobTextureURL;
  102909. if (texture) {
  102910. var URL = window.URL || window.webkitURL;
  102911. blobTextureURL = URL.createObjectURL(texture.data);
  102912. image.onerror = function () {
  102913. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading image from blob URL: " + blobTextureURL + " switching back to web url: " + url);
  102914. image.src = url;
  102915. };
  102916. image.src = blobTextureURL;
  102917. }
  102918. else {
  102919. notInDBCallback();
  102920. }
  102921. };
  102922. var getRequest = transaction.objectStore("textures").get(url);
  102923. getRequest.onsuccess = function (event) {
  102924. texture = (event.target).result;
  102925. };
  102926. getRequest.onerror = function () {
  102927. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading texture " + url + " from DB.");
  102928. image.src = url;
  102929. };
  102930. }
  102931. else {
  102932. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  102933. image.src = url;
  102934. }
  102935. };
  102936. Database.prototype._saveImageIntoDBAsync = function (url, image) {
  102937. var _this = this;
  102938. if (this._isSupported) {
  102939. // In case of error (type not supported or quota exceeded), we're at least sending back XHR data to allow texture loading later on
  102940. var generateBlobUrl = function () {
  102941. var blobTextureURL;
  102942. if (blob) {
  102943. var URL = window.URL || window.webkitURL;
  102944. try {
  102945. blobTextureURL = URL.createObjectURL(blob);
  102946. }
  102947. // Chrome is raising a type error if we're setting the oneTimeOnly parameter
  102948. catch (ex) {
  102949. blobTextureURL = URL.createObjectURL(blob);
  102950. }
  102951. }
  102952. if (blobTextureURL) {
  102953. image.src = blobTextureURL;
  102954. }
  102955. };
  102956. if (Database.IsUASupportingBlobStorage) { // Create XHR
  102957. var xhr = new XMLHttpRequest(), blob;
  102958. xhr.open("GET", url, true);
  102959. xhr.responseType = "blob";
  102960. xhr.addEventListener("load", function () {
  102961. if (xhr.status === 200 && _this._db) {
  102962. // Blob as response (XHR2)
  102963. blob = xhr.response;
  102964. var transaction = _this._db.transaction(["textures"], "readwrite");
  102965. // the transaction could abort because of a QuotaExceededError error
  102966. transaction.onabort = function (event) {
  102967. try {
  102968. //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  102969. var srcElement = (event.srcElement || event.target);
  102970. var error = srcElement.error;
  102971. if (error && error.name === "QuotaExceededError") {
  102972. _this._hasReachedQuota = true;
  102973. }
  102974. }
  102975. catch (ex) { }
  102976. generateBlobUrl();
  102977. };
  102978. transaction.oncomplete = function () {
  102979. generateBlobUrl();
  102980. };
  102981. var newTexture = { textureUrl: url, data: blob };
  102982. try {
  102983. // Put the blob into the dabase
  102984. var addRequest = transaction.objectStore("textures").put(newTexture);
  102985. addRequest.onsuccess = function () {
  102986. };
  102987. addRequest.onerror = function () {
  102988. generateBlobUrl();
  102989. };
  102990. }
  102991. catch (ex) {
  102992. // "DataCloneError" generated by Chrome when you try to inject blob into IndexedDB
  102993. if (ex.code === 25) {
  102994. Database.IsUASupportingBlobStorage = false;
  102995. _this._enableTexturesOffline = false;
  102996. }
  102997. image.src = url;
  102998. }
  102999. }
  103000. else {
  103001. image.src = url;
  103002. }
  103003. }, false);
  103004. xhr.addEventListener("error", function () {
  103005. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in XHR request in BABYLON.Database.");
  103006. image.src = url;
  103007. }, false);
  103008. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].CustomRequestHeaders) {
  103009. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].InjectCustomRequestHeaders(xhr);
  103010. }
  103011. xhr.send();
  103012. }
  103013. else {
  103014. image.src = url;
  103015. }
  103016. }
  103017. else {
  103018. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  103019. image.src = url;
  103020. }
  103021. };
  103022. Database.prototype._checkVersionFromDB = function (url, versionLoaded) {
  103023. var _this = this;
  103024. var updateVersion = function () {
  103025. // the version is not yet in the DB or we need to update it
  103026. _this._saveVersionIntoDBAsync(url, versionLoaded);
  103027. };
  103028. this._loadVersionFromDBAsync(url, versionLoaded, updateVersion);
  103029. };
  103030. Database.prototype._loadVersionFromDBAsync = function (url, callback, updateInDBCallback) {
  103031. var _this = this;
  103032. if (this._isSupported && this._db) {
  103033. var version;
  103034. try {
  103035. var transaction = this._db.transaction(["versions"]);
  103036. transaction.oncomplete = function () {
  103037. if (version) {
  103038. // If the version in the JSON file is different from the version in DB
  103039. if (_this._manifestVersionFound !== version.data) {
  103040. _this._mustUpdateRessources = true;
  103041. updateInDBCallback();
  103042. }
  103043. else {
  103044. callback(version.data);
  103045. }
  103046. }
  103047. // version was not found in DB
  103048. else {
  103049. _this._mustUpdateRessources = true;
  103050. updateInDBCallback();
  103051. }
  103052. };
  103053. transaction.onabort = function () {
  103054. callback(-1);
  103055. };
  103056. var getRequest = transaction.objectStore("versions").get(url);
  103057. getRequest.onsuccess = function (event) {
  103058. version = (event.target).result;
  103059. };
  103060. getRequest.onerror = function () {
  103061. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading version for scene " + url + " from DB.");
  103062. callback(-1);
  103063. };
  103064. }
  103065. catch (ex) {
  103066. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while accessing 'versions' object store (READ OP). Exception: " + ex.message);
  103067. callback(-1);
  103068. }
  103069. }
  103070. else {
  103071. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  103072. callback(-1);
  103073. }
  103074. };
  103075. Database.prototype._saveVersionIntoDBAsync = function (url, callback) {
  103076. var _this = this;
  103077. if (this._isSupported && !this._hasReachedQuota && this._db) {
  103078. try {
  103079. // Open a transaction to the database
  103080. var transaction = this._db.transaction(["versions"], "readwrite");
  103081. // the transaction could abort because of a QuotaExceededError error
  103082. transaction.onabort = function (event) {
  103083. try { //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  103084. var error = event.srcElement['error'];
  103085. if (error && error.name === "QuotaExceededError") {
  103086. _this._hasReachedQuota = true;
  103087. }
  103088. }
  103089. catch (ex) { }
  103090. callback(-1);
  103091. };
  103092. transaction.oncomplete = function () {
  103093. callback(_this._manifestVersionFound);
  103094. };
  103095. var newVersion = { sceneUrl: url, data: this._manifestVersionFound };
  103096. // Put the scene into the database
  103097. var addRequest = transaction.objectStore("versions").put(newVersion);
  103098. addRequest.onsuccess = function () {
  103099. };
  103100. addRequest.onerror = function () {
  103101. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in DB add version request in BABYLON.Database.");
  103102. };
  103103. }
  103104. catch (ex) {
  103105. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while accessing 'versions' object store (WRITE OP). Exception: " + ex.message);
  103106. callback(-1);
  103107. }
  103108. }
  103109. else {
  103110. callback(-1);
  103111. }
  103112. };
  103113. /**
  103114. * Loads a file from database
  103115. * @param url defines the URL to load from
  103116. * @param sceneLoaded defines a callback to call on success
  103117. * @param progressCallBack defines a callback to call when progress changed
  103118. * @param errorCallback defines a callback to call on error
  103119. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  103120. */
  103121. Database.prototype.loadFile = function (url, sceneLoaded, progressCallBack, errorCallback, useArrayBuffer) {
  103122. var _this = this;
  103123. var completeUrl = Database._ReturnFullUrlLocation(url);
  103124. var saveAndLoadFile = function () {
  103125. // the scene is not yet in the DB, let's try to save it
  103126. _this._saveFileAsync(completeUrl, sceneLoaded, progressCallBack, useArrayBuffer, errorCallback);
  103127. };
  103128. this._checkVersionFromDB(completeUrl, function (version) {
  103129. if (version !== -1) {
  103130. if (!_this._mustUpdateRessources) {
  103131. _this._loadFileAsync(completeUrl, sceneLoaded, saveAndLoadFile);
  103132. }
  103133. else {
  103134. _this._saveFileAsync(completeUrl, sceneLoaded, progressCallBack, useArrayBuffer, errorCallback);
  103135. }
  103136. }
  103137. else {
  103138. if (errorCallback) {
  103139. errorCallback();
  103140. }
  103141. }
  103142. });
  103143. };
  103144. Database.prototype._loadFileAsync = function (url, callback, notInDBCallback) {
  103145. if (this._isSupported && this._db) {
  103146. var targetStore;
  103147. if (url.indexOf(".babylon") !== -1) {
  103148. targetStore = "scenes";
  103149. }
  103150. else {
  103151. targetStore = "textures";
  103152. }
  103153. var file;
  103154. var transaction = this._db.transaction([targetStore]);
  103155. transaction.oncomplete = function () {
  103156. if (file) {
  103157. callback(file.data);
  103158. }
  103159. // file was not found in DB
  103160. else {
  103161. notInDBCallback();
  103162. }
  103163. };
  103164. transaction.onabort = function () {
  103165. notInDBCallback();
  103166. };
  103167. var getRequest = transaction.objectStore(targetStore).get(url);
  103168. getRequest.onsuccess = function (event) {
  103169. file = (event.target).result;
  103170. };
  103171. getRequest.onerror = function () {
  103172. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading file " + url + " from DB.");
  103173. notInDBCallback();
  103174. };
  103175. }
  103176. else {
  103177. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  103178. callback();
  103179. }
  103180. };
  103181. Database.prototype._saveFileAsync = function (url, callback, progressCallback, useArrayBuffer, errorCallback) {
  103182. var _this = this;
  103183. if (this._isSupported) {
  103184. var targetStore;
  103185. if (url.indexOf(".babylon") !== -1) {
  103186. targetStore = "scenes";
  103187. }
  103188. else {
  103189. targetStore = "textures";
  103190. }
  103191. // Create XHR
  103192. var xhr = new XMLHttpRequest();
  103193. var fileData;
  103194. xhr.open("GET", url + "?" + Date.now(), true);
  103195. if (useArrayBuffer) {
  103196. xhr.responseType = "arraybuffer";
  103197. }
  103198. if (progressCallback) {
  103199. xhr.onprogress = progressCallback;
  103200. }
  103201. xhr.addEventListener("load", function () {
  103202. if (xhr.status === 200 || (xhr.status < 400 && Database._ValidateXHRData(xhr, !useArrayBuffer ? 1 : 6))) {
  103203. // Blob as response (XHR2)
  103204. fileData = !useArrayBuffer ? xhr.responseText : xhr.response;
  103205. if (!_this._hasReachedQuota && _this._db) {
  103206. // Open a transaction to the database
  103207. var transaction = _this._db.transaction([targetStore], "readwrite");
  103208. // the transaction could abort because of a QuotaExceededError error
  103209. transaction.onabort = function (event) {
  103210. try {
  103211. //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  103212. var error = event.srcElement['error'];
  103213. if (error && error.name === "QuotaExceededError") {
  103214. _this._hasReachedQuota = true;
  103215. }
  103216. }
  103217. catch (ex) { }
  103218. callback(fileData);
  103219. };
  103220. transaction.oncomplete = function () {
  103221. callback(fileData);
  103222. };
  103223. var newFile;
  103224. if (targetStore === "scenes") {
  103225. newFile = { sceneUrl: url, data: fileData, version: _this._manifestVersionFound };
  103226. }
  103227. else {
  103228. newFile = { textureUrl: url, data: fileData };
  103229. }
  103230. try {
  103231. // Put the scene into the database
  103232. var addRequest = transaction.objectStore(targetStore).put(newFile);
  103233. addRequest.onsuccess = function () {
  103234. };
  103235. addRequest.onerror = function () {
  103236. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in DB add file request in BABYLON.Database.");
  103237. };
  103238. }
  103239. catch (ex) {
  103240. callback(fileData);
  103241. }
  103242. }
  103243. else {
  103244. callback(fileData);
  103245. }
  103246. }
  103247. else {
  103248. if (xhr.status >= 400 && errorCallback) {
  103249. errorCallback(xhr);
  103250. }
  103251. else {
  103252. callback();
  103253. }
  103254. }
  103255. }, false);
  103256. xhr.addEventListener("error", function () {
  103257. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("error on XHR request.");
  103258. callback();
  103259. }, false);
  103260. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].UseCustomRequestHeaders) {
  103261. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].InjectCustomRequestHeaders(xhr);
  103262. }
  103263. xhr.send();
  103264. }
  103265. else {
  103266. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or Babylon.js Database is not open.");
  103267. callback();
  103268. }
  103269. };
  103270. /**
  103271. * Validates if xhr data is correct
  103272. * @param xhr defines the request to validate
  103273. * @param dataType defines the expected data type
  103274. * @returns true if data is correct
  103275. */
  103276. Database._ValidateXHRData = function (xhr, dataType) {
  103277. // 1 for text (.babylon, manifest and shaders), 2 for TGA, 4 for DDS, 7 for all
  103278. if (dataType === void 0) { dataType = 7; }
  103279. try {
  103280. if (dataType & 1) {
  103281. if (xhr.responseText && xhr.responseText.length > 0) {
  103282. return true;
  103283. }
  103284. else if (dataType === 1) {
  103285. return false;
  103286. }
  103287. }
  103288. if (dataType & 2) {
  103289. // Check header width and height since there is no "TGA" magic number
  103290. var tgaHeader = _Misc_tga__WEBPACK_IMPORTED_MODULE_2__["TGATools"].GetTGAHeader(xhr.response);
  103291. if (tgaHeader.width && tgaHeader.height && tgaHeader.width > 0 && tgaHeader.height > 0) {
  103292. return true;
  103293. }
  103294. else if (dataType === 2) {
  103295. return false;
  103296. }
  103297. }
  103298. if (dataType & 4) {
  103299. // Check for the "DDS" magic number
  103300. var ddsHeader = new Uint8Array(xhr.response, 0, 3);
  103301. if (ddsHeader[0] === 68 && ddsHeader[1] === 68 && ddsHeader[2] === 83) {
  103302. return true;
  103303. }
  103304. else {
  103305. return false;
  103306. }
  103307. }
  103308. }
  103309. catch (e) {
  103310. // Global protection
  103311. }
  103312. return false;
  103313. };
  103314. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  103315. Database.IsUASupportingBlobStorage = true;
  103316. /**
  103317. * Gets a boolean indicating if Database storate is enabled (off by default)
  103318. */
  103319. Database.IDBStorageEnabled = false;
  103320. Database._ParseURL = function (url) {
  103321. var a = document.createElement('a');
  103322. a.href = url;
  103323. var urlWithoutHash = url.substring(0, url.lastIndexOf("#"));
  103324. var fileName = url.substring(urlWithoutHash.lastIndexOf("/") + 1, url.length);
  103325. var absLocation = url.substring(0, url.indexOf(fileName, 0));
  103326. return absLocation;
  103327. };
  103328. Database._ReturnFullUrlLocation = function (url) {
  103329. if (url.indexOf("http:/") === -1 && url.indexOf("https:/") === -1) {
  103330. return (Database._ParseURL(window.location.href) + url);
  103331. }
  103332. else {
  103333. return url;
  103334. }
  103335. };
  103336. return Database;
  103337. }());
  103338. /***/ }),
  103339. /***/ "./Offline/index.ts":
  103340. /*!**************************!*\
  103341. !*** ./Offline/index.ts ***!
  103342. \**************************/
  103343. /*! exports provided: Database */
  103344. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103345. "use strict";
  103346. __webpack_require__.r(__webpack_exports__);
  103347. /* harmony import */ var _database__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./database */ "./Offline/database.ts");
  103348. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _database__WEBPACK_IMPORTED_MODULE_0__["Database"]; });
  103349. /***/ }),
  103350. /***/ "./Particles/EmitterTypes/boxParticleEmitter.ts":
  103351. /*!******************************************************!*\
  103352. !*** ./Particles/EmitterTypes/boxParticleEmitter.ts ***!
  103353. \******************************************************/
  103354. /*! exports provided: BoxParticleEmitter */
  103355. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103356. "use strict";
  103357. __webpack_require__.r(__webpack_exports__);
  103358. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return BoxParticleEmitter; });
  103359. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  103360. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  103361. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  103362. /**
  103363. * Particle emitter emitting particles from the inside of a box.
  103364. * It emits the particles randomly between 2 given directions.
  103365. */
  103366. var BoxParticleEmitter = /** @class */ (function () {
  103367. /**
  103368. * Creates a new instance BoxParticleEmitter
  103369. */
  103370. function BoxParticleEmitter() {
  103371. /**
  103372. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  103373. */
  103374. this.direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  103375. /**
  103376. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  103377. */
  103378. this.direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  103379. /**
  103380. * 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.
  103381. */
  103382. this.minEmitBox = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-0.5, -0.5, -0.5);
  103383. /**
  103384. * 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.
  103385. */
  103386. this.maxEmitBox = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0.5, 0.5, 0.5);
  103387. }
  103388. /**
  103389. * Called by the particle System when the direction is computed for the created particle.
  103390. * @param worldMatrix is the world matrix of the particle system
  103391. * @param directionToUpdate is the direction vector to update with the result
  103392. * @param particle is the particle we are computed the direction for
  103393. */
  103394. BoxParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  103395. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  103396. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  103397. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  103398. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  103399. };
  103400. /**
  103401. * Called by the particle System when the position is computed for the created particle.
  103402. * @param worldMatrix is the world matrix of the particle system
  103403. * @param positionToUpdate is the position vector to update with the result
  103404. * @param particle is the particle we are computed the position for
  103405. */
  103406. BoxParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  103407. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.x, this.maxEmitBox.x);
  103408. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.y, this.maxEmitBox.y);
  103409. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.z, this.maxEmitBox.z);
  103410. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  103411. };
  103412. /**
  103413. * Clones the current emitter and returns a copy of it
  103414. * @returns the new emitter
  103415. */
  103416. BoxParticleEmitter.prototype.clone = function () {
  103417. var newOne = new BoxParticleEmitter();
  103418. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  103419. return newOne;
  103420. };
  103421. /**
  103422. * Called by the GPUParticleSystem to setup the update shader
  103423. * @param effect defines the update shader
  103424. */
  103425. BoxParticleEmitter.prototype.applyToShader = function (effect) {
  103426. effect.setVector3("direction1", this.direction1);
  103427. effect.setVector3("direction2", this.direction2);
  103428. effect.setVector3("minEmitBox", this.minEmitBox);
  103429. effect.setVector3("maxEmitBox", this.maxEmitBox);
  103430. };
  103431. /**
  103432. * Returns a string to use to update the GPU particles update shader
  103433. * @returns a string containng the defines string
  103434. */
  103435. BoxParticleEmitter.prototype.getEffectDefines = function () {
  103436. return "#define BOXEMITTER";
  103437. };
  103438. /**
  103439. * Returns the string "BoxParticleEmitter"
  103440. * @returns a string containing the class name
  103441. */
  103442. BoxParticleEmitter.prototype.getClassName = function () {
  103443. return "BoxParticleEmitter";
  103444. };
  103445. /**
  103446. * Serializes the particle system to a JSON object.
  103447. * @returns the JSON object
  103448. */
  103449. BoxParticleEmitter.prototype.serialize = function () {
  103450. var serializationObject = {};
  103451. serializationObject.type = this.getClassName();
  103452. serializationObject.direction1 = this.direction1.asArray();
  103453. serializationObject.direction2 = this.direction2.asArray();
  103454. serializationObject.minEmitBox = this.minEmitBox.asArray();
  103455. serializationObject.maxEmitBox = this.maxEmitBox.asArray();
  103456. return serializationObject;
  103457. };
  103458. /**
  103459. * Parse properties from a JSON object
  103460. * @param serializationObject defines the JSON object
  103461. */
  103462. BoxParticleEmitter.prototype.parse = function (serializationObject) {
  103463. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction1, 0, this.direction1);
  103464. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction2, 0, this.direction2);
  103465. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.minEmitBox, 0, this.minEmitBox);
  103466. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.maxEmitBox, 0, this.maxEmitBox);
  103467. };
  103468. return BoxParticleEmitter;
  103469. }());
  103470. /***/ }),
  103471. /***/ "./Particles/EmitterTypes/coneParticleEmitter.ts":
  103472. /*!*******************************************************!*\
  103473. !*** ./Particles/EmitterTypes/coneParticleEmitter.ts ***!
  103474. \*******************************************************/
  103475. /*! exports provided: ConeParticleEmitter */
  103476. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103477. "use strict";
  103478. __webpack_require__.r(__webpack_exports__);
  103479. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return ConeParticleEmitter; });
  103480. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  103481. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  103482. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  103483. /**
  103484. * Particle emitter emitting particles from the inside of a cone.
  103485. * It emits the particles alongside the cone volume from the base to the particle.
  103486. * The emission direction might be randomized.
  103487. */
  103488. var ConeParticleEmitter = /** @class */ (function () {
  103489. /**
  103490. * Creates a new instance ConeParticleEmitter
  103491. * @param radius the radius of the emission cone (1 by default)
  103492. * @param angle the cone base angle (PI by default)
  103493. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  103494. */
  103495. function ConeParticleEmitter(radius, angle,
  103496. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  103497. directionRandomizer) {
  103498. if (radius === void 0) { radius = 1; }
  103499. if (angle === void 0) { angle = Math.PI; }
  103500. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  103501. this.directionRandomizer = directionRandomizer;
  103502. /**
  103503. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  103504. */
  103505. this.radiusRange = 1;
  103506. /**
  103507. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  103508. */
  103509. this.heightRange = 1;
  103510. /**
  103511. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  103512. */
  103513. this.emitFromSpawnPointOnly = false;
  103514. this.angle = angle;
  103515. this.radius = radius;
  103516. }
  103517. Object.defineProperty(ConeParticleEmitter.prototype, "radius", {
  103518. /**
  103519. * Gets or sets the radius of the emission cone
  103520. */
  103521. get: function () {
  103522. return this._radius;
  103523. },
  103524. set: function (value) {
  103525. this._radius = value;
  103526. this._buildHeight();
  103527. },
  103528. enumerable: true,
  103529. configurable: true
  103530. });
  103531. Object.defineProperty(ConeParticleEmitter.prototype, "angle", {
  103532. /**
  103533. * Gets or sets the angle of the emission cone
  103534. */
  103535. get: function () {
  103536. return this._angle;
  103537. },
  103538. set: function (value) {
  103539. this._angle = value;
  103540. this._buildHeight();
  103541. },
  103542. enumerable: true,
  103543. configurable: true
  103544. });
  103545. ConeParticleEmitter.prototype._buildHeight = function () {
  103546. if (this._angle !== 0) {
  103547. this._height = this._radius / Math.tan(this._angle / 2);
  103548. }
  103549. else {
  103550. this._height = 1;
  103551. }
  103552. };
  103553. /**
  103554. * Called by the particle System when the direction is computed for the created particle.
  103555. * @param worldMatrix is the world matrix of the particle system
  103556. * @param directionToUpdate is the direction vector to update with the result
  103557. * @param particle is the particle we are computed the direction for
  103558. */
  103559. ConeParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  103560. if (Math.abs(Math.cos(this._angle)) === 1.0) {
  103561. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(0, 1.0, 0, worldMatrix, directionToUpdate);
  103562. }
  103563. else {
  103564. // measure the direction Vector from the emitter to the particle.
  103565. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  103566. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  103567. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  103568. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  103569. direction.x += randX;
  103570. direction.y += randY;
  103571. direction.z += randZ;
  103572. direction.normalize();
  103573. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  103574. }
  103575. };
  103576. /**
  103577. * Called by the particle System when the position is computed for the created particle.
  103578. * @param worldMatrix is the world matrix of the particle system
  103579. * @param positionToUpdate is the position vector to update with the result
  103580. * @param particle is the particle we are computed the position for
  103581. */
  103582. ConeParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  103583. var s = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, Math.PI * 2);
  103584. var h;
  103585. if (!this.emitFromSpawnPointOnly) {
  103586. h = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.heightRange);
  103587. // Better distribution in a cone at normal angles.
  103588. h = 1 - h * h;
  103589. }
  103590. else {
  103591. h = 0.0001;
  103592. }
  103593. var radius = this._radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this._radius * this.radiusRange);
  103594. radius = radius * h;
  103595. var randX = radius * Math.sin(s);
  103596. var randZ = radius * Math.cos(s);
  103597. var randY = h * this._height;
  103598. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  103599. };
  103600. /**
  103601. * Clones the current emitter and returns a copy of it
  103602. * @returns the new emitter
  103603. */
  103604. ConeParticleEmitter.prototype.clone = function () {
  103605. var newOne = new ConeParticleEmitter(this._radius, this._angle, this.directionRandomizer);
  103606. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  103607. return newOne;
  103608. };
  103609. /**
  103610. * Called by the GPUParticleSystem to setup the update shader
  103611. * @param effect defines the update shader
  103612. */
  103613. ConeParticleEmitter.prototype.applyToShader = function (effect) {
  103614. effect.setFloat2("radius", this._radius, this.radiusRange);
  103615. effect.setFloat("coneAngle", this._angle);
  103616. effect.setFloat2("height", this._height, this.heightRange);
  103617. effect.setFloat("directionRandomizer", this.directionRandomizer);
  103618. };
  103619. /**
  103620. * Returns a string to use to update the GPU particles update shader
  103621. * @returns a string containng the defines string
  103622. */
  103623. ConeParticleEmitter.prototype.getEffectDefines = function () {
  103624. var defines = "#define CONEEMITTER";
  103625. if (this.emitFromSpawnPointOnly) {
  103626. defines += "\n#define CONEEMITTERSPAWNPOINT";
  103627. }
  103628. return defines;
  103629. };
  103630. /**
  103631. * Returns the string "ConeParticleEmitter"
  103632. * @returns a string containing the class name
  103633. */
  103634. ConeParticleEmitter.prototype.getClassName = function () {
  103635. return "ConeParticleEmitter";
  103636. };
  103637. /**
  103638. * Serializes the particle system to a JSON object.
  103639. * @returns the JSON object
  103640. */
  103641. ConeParticleEmitter.prototype.serialize = function () {
  103642. var serializationObject = {};
  103643. serializationObject.type = this.getClassName();
  103644. serializationObject.radius = this._radius;
  103645. serializationObject.angle = this._angle;
  103646. serializationObject.directionRandomizer = this.directionRandomizer;
  103647. return serializationObject;
  103648. };
  103649. /**
  103650. * Parse properties from a JSON object
  103651. * @param serializationObject defines the JSON object
  103652. */
  103653. ConeParticleEmitter.prototype.parse = function (serializationObject) {
  103654. this.radius = serializationObject.radius;
  103655. this.angle = serializationObject.angle;
  103656. this.directionRandomizer = serializationObject.directionRandomizer;
  103657. };
  103658. return ConeParticleEmitter;
  103659. }());
  103660. /***/ }),
  103661. /***/ "./Particles/EmitterTypes/cylinderParticleEmitter.ts":
  103662. /*!***********************************************************!*\
  103663. !*** ./Particles/EmitterTypes/cylinderParticleEmitter.ts ***!
  103664. \***********************************************************/
  103665. /*! exports provided: CylinderParticleEmitter, CylinderDirectedParticleEmitter */
  103666. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103667. "use strict";
  103668. __webpack_require__.r(__webpack_exports__);
  103669. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return CylinderParticleEmitter; });
  103670. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return CylinderDirectedParticleEmitter; });
  103671. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  103672. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  103673. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  103674. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  103675. /**
  103676. * Particle emitter emitting particles from the inside of a cylinder.
  103677. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  103678. */
  103679. var CylinderParticleEmitter = /** @class */ (function () {
  103680. /**
  103681. * Creates a new instance CylinderParticleEmitter
  103682. * @param radius the radius of the emission cylinder (1 by default)
  103683. * @param height the height of the emission cylinder (1 by default)
  103684. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  103685. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  103686. */
  103687. function CylinderParticleEmitter(
  103688. /**
  103689. * The radius of the emission cylinder.
  103690. */
  103691. radius,
  103692. /**
  103693. * The height of the emission cylinder.
  103694. */
  103695. height,
  103696. /**
  103697. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  103698. */
  103699. radiusRange,
  103700. /**
  103701. * How much to randomize the particle direction [0-1].
  103702. */
  103703. directionRandomizer) {
  103704. if (radius === void 0) { radius = 1; }
  103705. if (height === void 0) { height = 1; }
  103706. if (radiusRange === void 0) { radiusRange = 1; }
  103707. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  103708. this.radius = radius;
  103709. this.height = height;
  103710. this.radiusRange = radiusRange;
  103711. this.directionRandomizer = directionRandomizer;
  103712. }
  103713. /**
  103714. * Called by the particle System when the direction is computed for the created particle.
  103715. * @param worldMatrix is the world matrix of the particle system
  103716. * @param directionToUpdate is the direction vector to update with the result
  103717. * @param particle is the particle we are computed the direction for
  103718. */
  103719. CylinderParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  103720. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  103721. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-this.directionRandomizer / 2, this.directionRandomizer / 2);
  103722. var angle = Math.atan2(direction.x, direction.z);
  103723. angle += _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-Math.PI / 2, Math.PI / 2) * this.directionRandomizer;
  103724. direction.y = randY; // set direction y to rand y to mirror normal of cylinder surface
  103725. direction.x = Math.sin(angle);
  103726. direction.z = Math.cos(angle);
  103727. direction.normalize();
  103728. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  103729. };
  103730. /**
  103731. * Called by the particle System when the position is computed for the created particle.
  103732. * @param worldMatrix is the world matrix of the particle system
  103733. * @param positionToUpdate is the position vector to update with the result
  103734. * @param particle is the particle we are computed the position for
  103735. */
  103736. CylinderParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  103737. var yPos = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-this.height / 2, this.height / 2);
  103738. var angle = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  103739. // Pick a properly distributed point within the circle https://programming.guide/random-point-within-circle.html
  103740. var radiusDistribution = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange((1 - this.radiusRange) * (1 - this.radiusRange), 1);
  103741. var positionRadius = Math.sqrt(radiusDistribution) * this.radius;
  103742. var xPos = positionRadius * Math.cos(angle);
  103743. var zPos = positionRadius * Math.sin(angle);
  103744. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(xPos, yPos, zPos, worldMatrix, positionToUpdate);
  103745. };
  103746. /**
  103747. * Clones the current emitter and returns a copy of it
  103748. * @returns the new emitter
  103749. */
  103750. CylinderParticleEmitter.prototype.clone = function () {
  103751. var newOne = new CylinderParticleEmitter(this.radius, this.directionRandomizer);
  103752. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  103753. return newOne;
  103754. };
  103755. /**
  103756. * Called by the GPUParticleSystem to setup the update shader
  103757. * @param effect defines the update shader
  103758. */
  103759. CylinderParticleEmitter.prototype.applyToShader = function (effect) {
  103760. effect.setFloat("radius", this.radius);
  103761. effect.setFloat("height", this.height);
  103762. effect.setFloat("radiusRange", this.radiusRange);
  103763. effect.setFloat("directionRandomizer", this.directionRandomizer);
  103764. };
  103765. /**
  103766. * Returns a string to use to update the GPU particles update shader
  103767. * @returns a string containng the defines string
  103768. */
  103769. CylinderParticleEmitter.prototype.getEffectDefines = function () {
  103770. return "#define CYLINDEREMITTER";
  103771. };
  103772. /**
  103773. * Returns the string "CylinderParticleEmitter"
  103774. * @returns a string containing the class name
  103775. */
  103776. CylinderParticleEmitter.prototype.getClassName = function () {
  103777. return "CylinderParticleEmitter";
  103778. };
  103779. /**
  103780. * Serializes the particle system to a JSON object.
  103781. * @returns the JSON object
  103782. */
  103783. CylinderParticleEmitter.prototype.serialize = function () {
  103784. var serializationObject = {};
  103785. serializationObject.type = this.getClassName();
  103786. serializationObject.radius = this.radius;
  103787. serializationObject.height = this.height;
  103788. serializationObject.radiusRange = this.radiusRange;
  103789. serializationObject.directionRandomizer = this.directionRandomizer;
  103790. return serializationObject;
  103791. };
  103792. /**
  103793. * Parse properties from a JSON object
  103794. * @param serializationObject defines the JSON object
  103795. */
  103796. CylinderParticleEmitter.prototype.parse = function (serializationObject) {
  103797. this.radius = serializationObject.radius;
  103798. this.height = serializationObject.height;
  103799. this.radiusRange = serializationObject.radiusRange;
  103800. this.directionRandomizer = serializationObject.directionRandomizer;
  103801. };
  103802. return CylinderParticleEmitter;
  103803. }());
  103804. /**
  103805. * Particle emitter emitting particles from the inside of a cylinder.
  103806. * It emits the particles randomly between two vectors.
  103807. */
  103808. var CylinderDirectedParticleEmitter = /** @class */ (function (_super) {
  103809. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CylinderDirectedParticleEmitter, _super);
  103810. /**
  103811. * Creates a new instance CylinderDirectedParticleEmitter
  103812. * @param radius the radius of the emission cylinder (1 by default)
  103813. * @param height the height of the emission cylinder (1 by default)
  103814. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  103815. * @param direction1 the min limit of the emission direction (up vector by default)
  103816. * @param direction2 the max limit of the emission direction (up vector by default)
  103817. */
  103818. function CylinderDirectedParticleEmitter(radius, height, radiusRange,
  103819. /**
  103820. * The min limit of the emission direction.
  103821. */
  103822. direction1,
  103823. /**
  103824. * The max limit of the emission direction.
  103825. */
  103826. direction2) {
  103827. if (radius === void 0) { radius = 1; }
  103828. if (height === void 0) { height = 1; }
  103829. if (radiusRange === void 0) { radiusRange = 1; }
  103830. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  103831. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  103832. var _this = _super.call(this, radius, height, radiusRange) || this;
  103833. _this.direction1 = direction1;
  103834. _this.direction2 = direction2;
  103835. return _this;
  103836. }
  103837. /**
  103838. * Called by the particle System when the direction is computed for the created particle.
  103839. * @param worldMatrix is the world matrix of the particle system
  103840. * @param directionToUpdate is the direction vector to update with the result
  103841. * @param particle is the particle we are computed the direction for
  103842. */
  103843. CylinderDirectedParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  103844. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  103845. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  103846. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  103847. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  103848. };
  103849. /**
  103850. * Clones the current emitter and returns a copy of it
  103851. * @returns the new emitter
  103852. */
  103853. CylinderDirectedParticleEmitter.prototype.clone = function () {
  103854. var newOne = new CylinderDirectedParticleEmitter(this.radius, this.height, this.radiusRange, this.direction1, this.direction2);
  103855. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  103856. return newOne;
  103857. };
  103858. /**
  103859. * Called by the GPUParticleSystem to setup the update shader
  103860. * @param effect defines the update shader
  103861. */
  103862. CylinderDirectedParticleEmitter.prototype.applyToShader = function (effect) {
  103863. effect.setFloat("radius", this.radius);
  103864. effect.setFloat("height", this.height);
  103865. effect.setFloat("radiusRange", this.radiusRange);
  103866. effect.setVector3("direction1", this.direction1);
  103867. effect.setVector3("direction2", this.direction2);
  103868. };
  103869. /**
  103870. * Returns a string to use to update the GPU particles update shader
  103871. * @returns a string containng the defines string
  103872. */
  103873. CylinderDirectedParticleEmitter.prototype.getEffectDefines = function () {
  103874. return "#define CYLINDEREMITTER\n#define DIRECTEDCYLINDEREMITTER";
  103875. };
  103876. /**
  103877. * Returns the string "CylinderDirectedParticleEmitter"
  103878. * @returns a string containing the class name
  103879. */
  103880. CylinderDirectedParticleEmitter.prototype.getClassName = function () {
  103881. return "CylinderDirectedParticleEmitter";
  103882. };
  103883. /**
  103884. * Serializes the particle system to a JSON object.
  103885. * @returns the JSON object
  103886. */
  103887. CylinderDirectedParticleEmitter.prototype.serialize = function () {
  103888. var serializationObject = _super.prototype.serialize.call(this);
  103889. serializationObject.direction1 = this.direction1.asArray();
  103890. serializationObject.direction2 = this.direction2.asArray();
  103891. return serializationObject;
  103892. };
  103893. /**
  103894. * Parse properties from a JSON object
  103895. * @param serializationObject defines the JSON object
  103896. */
  103897. CylinderDirectedParticleEmitter.prototype.parse = function (serializationObject) {
  103898. _super.prototype.parse.call(this, serializationObject);
  103899. this.direction1.copyFrom(serializationObject.direction1);
  103900. this.direction2.copyFrom(serializationObject.direction2);
  103901. };
  103902. return CylinderDirectedParticleEmitter;
  103903. }(CylinderParticleEmitter));
  103904. /***/ }),
  103905. /***/ "./Particles/EmitterTypes/hemisphericParticleEmitter.ts":
  103906. /*!**************************************************************!*\
  103907. !*** ./Particles/EmitterTypes/hemisphericParticleEmitter.ts ***!
  103908. \**************************************************************/
  103909. /*! exports provided: HemisphericParticleEmitter */
  103910. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103911. "use strict";
  103912. __webpack_require__.r(__webpack_exports__);
  103913. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return HemisphericParticleEmitter; });
  103914. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  103915. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  103916. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  103917. /**
  103918. * Particle emitter emitting particles from the inside of a hemisphere.
  103919. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  103920. */
  103921. var HemisphericParticleEmitter = /** @class */ (function () {
  103922. /**
  103923. * Creates a new instance HemisphericParticleEmitter
  103924. * @param radius the radius of the emission hemisphere (1 by default)
  103925. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  103926. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  103927. */
  103928. function HemisphericParticleEmitter(
  103929. /**
  103930. * The radius of the emission hemisphere.
  103931. */
  103932. radius,
  103933. /**
  103934. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  103935. */
  103936. radiusRange,
  103937. /**
  103938. * How much to randomize the particle direction [0-1].
  103939. */
  103940. directionRandomizer) {
  103941. if (radius === void 0) { radius = 1; }
  103942. if (radiusRange === void 0) { radiusRange = 1; }
  103943. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  103944. this.radius = radius;
  103945. this.radiusRange = radiusRange;
  103946. this.directionRandomizer = directionRandomizer;
  103947. }
  103948. /**
  103949. * Called by the particle System when the direction is computed for the created particle.
  103950. * @param worldMatrix is the world matrix of the particle system
  103951. * @param directionToUpdate is the direction vector to update with the result
  103952. * @param particle is the particle we are computed the direction for
  103953. */
  103954. HemisphericParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  103955. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  103956. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  103957. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  103958. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  103959. direction.x += randX;
  103960. direction.y += randY;
  103961. direction.z += randZ;
  103962. direction.normalize();
  103963. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  103964. };
  103965. /**
  103966. * Called by the particle System when the position is computed for the created particle.
  103967. * @param worldMatrix is the world matrix of the particle system
  103968. * @param positionToUpdate is the position vector to update with the result
  103969. * @param particle is the particle we are computed the position for
  103970. */
  103971. HemisphericParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  103972. var randRadius = this.radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.radius * this.radiusRange);
  103973. var v = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 1.0);
  103974. var phi = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  103975. var theta = Math.acos(2 * v - 1);
  103976. var randX = randRadius * Math.cos(phi) * Math.sin(theta);
  103977. var randY = randRadius * Math.cos(theta);
  103978. var randZ = randRadius * Math.sin(phi) * Math.sin(theta);
  103979. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, Math.abs(randY), randZ, worldMatrix, positionToUpdate);
  103980. };
  103981. /**
  103982. * Clones the current emitter and returns a copy of it
  103983. * @returns the new emitter
  103984. */
  103985. HemisphericParticleEmitter.prototype.clone = function () {
  103986. var newOne = new HemisphericParticleEmitter(this.radius, this.directionRandomizer);
  103987. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  103988. return newOne;
  103989. };
  103990. /**
  103991. * Called by the GPUParticleSystem to setup the update shader
  103992. * @param effect defines the update shader
  103993. */
  103994. HemisphericParticleEmitter.prototype.applyToShader = function (effect) {
  103995. effect.setFloat("radius", this.radius);
  103996. effect.setFloat("radiusRange", this.radiusRange);
  103997. effect.setFloat("directionRandomizer", this.directionRandomizer);
  103998. };
  103999. /**
  104000. * Returns a string to use to update the GPU particles update shader
  104001. * @returns a string containng the defines string
  104002. */
  104003. HemisphericParticleEmitter.prototype.getEffectDefines = function () {
  104004. return "#define HEMISPHERICEMITTER";
  104005. };
  104006. /**
  104007. * Returns the string "HemisphericParticleEmitter"
  104008. * @returns a string containing the class name
  104009. */
  104010. HemisphericParticleEmitter.prototype.getClassName = function () {
  104011. return "HemisphericParticleEmitter";
  104012. };
  104013. /**
  104014. * Serializes the particle system to a JSON object.
  104015. * @returns the JSON object
  104016. */
  104017. HemisphericParticleEmitter.prototype.serialize = function () {
  104018. var serializationObject = {};
  104019. serializationObject.type = this.getClassName();
  104020. serializationObject.radius = this.radius;
  104021. serializationObject.radiusRange = this.radiusRange;
  104022. serializationObject.directionRandomizer = this.directionRandomizer;
  104023. return serializationObject;
  104024. };
  104025. /**
  104026. * Parse properties from a JSON object
  104027. * @param serializationObject defines the JSON object
  104028. */
  104029. HemisphericParticleEmitter.prototype.parse = function (serializationObject) {
  104030. this.radius = serializationObject.radius;
  104031. this.radiusRange = serializationObject.radiusRange;
  104032. this.directionRandomizer = serializationObject.directionRandomizer;
  104033. };
  104034. return HemisphericParticleEmitter;
  104035. }());
  104036. /***/ }),
  104037. /***/ "./Particles/EmitterTypes/index.ts":
  104038. /*!*****************************************!*\
  104039. !*** ./Particles/EmitterTypes/index.ts ***!
  104040. \*****************************************/
  104041. /*! exports provided: BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter */
  104042. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104043. "use strict";
  104044. __webpack_require__.r(__webpack_exports__);
  104045. /* harmony import */ var _boxParticleEmitter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boxParticleEmitter */ "./Particles/EmitterTypes/boxParticleEmitter.ts");
  104046. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _boxParticleEmitter__WEBPACK_IMPORTED_MODULE_0__["BoxParticleEmitter"]; });
  104047. /* harmony import */ var _coneParticleEmitter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./coneParticleEmitter */ "./Particles/EmitterTypes/coneParticleEmitter.ts");
  104048. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _coneParticleEmitter__WEBPACK_IMPORTED_MODULE_1__["ConeParticleEmitter"]; });
  104049. /* harmony import */ var _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./cylinderParticleEmitter */ "./Particles/EmitterTypes/cylinderParticleEmitter.ts");
  104050. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__["CylinderParticleEmitter"]; });
  104051. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__["CylinderDirectedParticleEmitter"]; });
  104052. /* harmony import */ var _hemisphericParticleEmitter__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hemisphericParticleEmitter */ "./Particles/EmitterTypes/hemisphericParticleEmitter.ts");
  104053. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _hemisphericParticleEmitter__WEBPACK_IMPORTED_MODULE_3__["HemisphericParticleEmitter"]; });
  104054. /* harmony import */ var _pointParticleEmitter__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pointParticleEmitter */ "./Particles/EmitterTypes/pointParticleEmitter.ts");
  104055. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _pointParticleEmitter__WEBPACK_IMPORTED_MODULE_4__["PointParticleEmitter"]; });
  104056. /* harmony import */ var _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./sphereParticleEmitter */ "./Particles/EmitterTypes/sphereParticleEmitter.ts");
  104057. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__["SphereParticleEmitter"]; });
  104058. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__["SphereDirectedParticleEmitter"]; });
  104059. /***/ }),
  104060. /***/ "./Particles/EmitterTypes/pointParticleEmitter.ts":
  104061. /*!********************************************************!*\
  104062. !*** ./Particles/EmitterTypes/pointParticleEmitter.ts ***!
  104063. \********************************************************/
  104064. /*! exports provided: PointParticleEmitter */
  104065. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104066. "use strict";
  104067. __webpack_require__.r(__webpack_exports__);
  104068. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return PointParticleEmitter; });
  104069. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  104070. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  104071. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  104072. /**
  104073. * Particle emitter emitting particles from a point.
  104074. * It emits the particles randomly between 2 given directions.
  104075. */
  104076. var PointParticleEmitter = /** @class */ (function () {
  104077. /**
  104078. * Creates a new instance PointParticleEmitter
  104079. */
  104080. function PointParticleEmitter() {
  104081. /**
  104082. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  104083. */
  104084. this.direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  104085. /**
  104086. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  104087. */
  104088. this.direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  104089. }
  104090. /**
  104091. * Called by the particle System when the direction is computed for the created particle.
  104092. * @param worldMatrix is the world matrix of the particle system
  104093. * @param directionToUpdate is the direction vector to update with the result
  104094. * @param particle is the particle we are computed the direction for
  104095. */
  104096. PointParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  104097. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  104098. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  104099. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  104100. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  104101. };
  104102. /**
  104103. * Called by the particle System when the position is computed for the created particle.
  104104. * @param worldMatrix is the world matrix of the particle system
  104105. * @param positionToUpdate is the position vector to update with the result
  104106. * @param particle is the particle we are computed the position for
  104107. */
  104108. PointParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  104109. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(0, 0, 0, worldMatrix, positionToUpdate);
  104110. };
  104111. /**
  104112. * Clones the current emitter and returns a copy of it
  104113. * @returns the new emitter
  104114. */
  104115. PointParticleEmitter.prototype.clone = function () {
  104116. var newOne = new PointParticleEmitter();
  104117. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  104118. return newOne;
  104119. };
  104120. /**
  104121. * Called by the GPUParticleSystem to setup the update shader
  104122. * @param effect defines the update shader
  104123. */
  104124. PointParticleEmitter.prototype.applyToShader = function (effect) {
  104125. effect.setVector3("direction1", this.direction1);
  104126. effect.setVector3("direction2", this.direction2);
  104127. };
  104128. /**
  104129. * Returns a string to use to update the GPU particles update shader
  104130. * @returns a string containng the defines string
  104131. */
  104132. PointParticleEmitter.prototype.getEffectDefines = function () {
  104133. return "#define POINTEMITTER";
  104134. };
  104135. /**
  104136. * Returns the string "PointParticleEmitter"
  104137. * @returns a string containing the class name
  104138. */
  104139. PointParticleEmitter.prototype.getClassName = function () {
  104140. return "PointParticleEmitter";
  104141. };
  104142. /**
  104143. * Serializes the particle system to a JSON object.
  104144. * @returns the JSON object
  104145. */
  104146. PointParticleEmitter.prototype.serialize = function () {
  104147. var serializationObject = {};
  104148. serializationObject.type = this.getClassName();
  104149. serializationObject.direction1 = this.direction1.asArray();
  104150. serializationObject.direction2 = this.direction2.asArray();
  104151. return serializationObject;
  104152. };
  104153. /**
  104154. * Parse properties from a JSON object
  104155. * @param serializationObject defines the JSON object
  104156. */
  104157. PointParticleEmitter.prototype.parse = function (serializationObject) {
  104158. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction1, 0, this.direction1);
  104159. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction2, 0, this.direction2);
  104160. };
  104161. return PointParticleEmitter;
  104162. }());
  104163. /***/ }),
  104164. /***/ "./Particles/EmitterTypes/sphereParticleEmitter.ts":
  104165. /*!*********************************************************!*\
  104166. !*** ./Particles/EmitterTypes/sphereParticleEmitter.ts ***!
  104167. \*********************************************************/
  104168. /*! exports provided: SphereParticleEmitter, SphereDirectedParticleEmitter */
  104169. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104170. "use strict";
  104171. __webpack_require__.r(__webpack_exports__);
  104172. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return SphereParticleEmitter; });
  104173. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return SphereDirectedParticleEmitter; });
  104174. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  104175. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  104176. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  104177. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  104178. /**
  104179. * Particle emitter emitting particles from the inside of a sphere.
  104180. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  104181. */
  104182. var SphereParticleEmitter = /** @class */ (function () {
  104183. /**
  104184. * Creates a new instance SphereParticleEmitter
  104185. * @param radius the radius of the emission sphere (1 by default)
  104186. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  104187. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  104188. */
  104189. function SphereParticleEmitter(
  104190. /**
  104191. * The radius of the emission sphere.
  104192. */
  104193. radius,
  104194. /**
  104195. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  104196. */
  104197. radiusRange,
  104198. /**
  104199. * How much to randomize the particle direction [0-1].
  104200. */
  104201. directionRandomizer) {
  104202. if (radius === void 0) { radius = 1; }
  104203. if (radiusRange === void 0) { radiusRange = 1; }
  104204. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  104205. this.radius = radius;
  104206. this.radiusRange = radiusRange;
  104207. this.directionRandomizer = directionRandomizer;
  104208. }
  104209. /**
  104210. * Called by the particle System when the direction is computed for the created particle.
  104211. * @param worldMatrix is the world matrix of the particle system
  104212. * @param directionToUpdate is the direction vector to update with the result
  104213. * @param particle is the particle we are computed the direction for
  104214. */
  104215. SphereParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  104216. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  104217. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  104218. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  104219. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  104220. direction.x += randX;
  104221. direction.y += randY;
  104222. direction.z += randZ;
  104223. direction.normalize();
  104224. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  104225. };
  104226. /**
  104227. * Called by the particle System when the position is computed for the created particle.
  104228. * @param worldMatrix is the world matrix of the particle system
  104229. * @param positionToUpdate is the position vector to update with the result
  104230. * @param particle is the particle we are computed the position for
  104231. */
  104232. SphereParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  104233. var randRadius = this.radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.radius * this.radiusRange);
  104234. var v = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 1.0);
  104235. var phi = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  104236. var theta = Math.acos(2 * v - 1);
  104237. var randX = randRadius * Math.cos(phi) * Math.sin(theta);
  104238. var randY = randRadius * Math.cos(theta);
  104239. var randZ = randRadius * Math.sin(phi) * Math.sin(theta);
  104240. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  104241. };
  104242. /**
  104243. * Clones the current emitter and returns a copy of it
  104244. * @returns the new emitter
  104245. */
  104246. SphereParticleEmitter.prototype.clone = function () {
  104247. var newOne = new SphereParticleEmitter(this.radius, this.directionRandomizer);
  104248. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  104249. return newOne;
  104250. };
  104251. /**
  104252. * Called by the GPUParticleSystem to setup the update shader
  104253. * @param effect defines the update shader
  104254. */
  104255. SphereParticleEmitter.prototype.applyToShader = function (effect) {
  104256. effect.setFloat("radius", this.radius);
  104257. effect.setFloat("radiusRange", this.radiusRange);
  104258. effect.setFloat("directionRandomizer", this.directionRandomizer);
  104259. };
  104260. /**
  104261. * Returns a string to use to update the GPU particles update shader
  104262. * @returns a string containng the defines string
  104263. */
  104264. SphereParticleEmitter.prototype.getEffectDefines = function () {
  104265. return "#define SPHEREEMITTER";
  104266. };
  104267. /**
  104268. * Returns the string "SphereParticleEmitter"
  104269. * @returns a string containing the class name
  104270. */
  104271. SphereParticleEmitter.prototype.getClassName = function () {
  104272. return "SphereParticleEmitter";
  104273. };
  104274. /**
  104275. * Serializes the particle system to a JSON object.
  104276. * @returns the JSON object
  104277. */
  104278. SphereParticleEmitter.prototype.serialize = function () {
  104279. var serializationObject = {};
  104280. serializationObject.type = this.getClassName();
  104281. serializationObject.radius = this.radius;
  104282. serializationObject.radiusRange = this.radiusRange;
  104283. serializationObject.directionRandomizer = this.directionRandomizer;
  104284. return serializationObject;
  104285. };
  104286. /**
  104287. * Parse properties from a JSON object
  104288. * @param serializationObject defines the JSON object
  104289. */
  104290. SphereParticleEmitter.prototype.parse = function (serializationObject) {
  104291. this.radius = serializationObject.radius;
  104292. this.radiusRange = serializationObject.radiusRange;
  104293. this.directionRandomizer = serializationObject.directionRandomizer;
  104294. };
  104295. return SphereParticleEmitter;
  104296. }());
  104297. /**
  104298. * Particle emitter emitting particles from the inside of a sphere.
  104299. * It emits the particles randomly between two vectors.
  104300. */
  104301. var SphereDirectedParticleEmitter = /** @class */ (function (_super) {
  104302. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SphereDirectedParticleEmitter, _super);
  104303. /**
  104304. * Creates a new instance SphereDirectedParticleEmitter
  104305. * @param radius the radius of the emission sphere (1 by default)
  104306. * @param direction1 the min limit of the emission direction (up vector by default)
  104307. * @param direction2 the max limit of the emission direction (up vector by default)
  104308. */
  104309. function SphereDirectedParticleEmitter(radius,
  104310. /**
  104311. * The min limit of the emission direction.
  104312. */
  104313. direction1,
  104314. /**
  104315. * The max limit of the emission direction.
  104316. */
  104317. direction2) {
  104318. if (radius === void 0) { radius = 1; }
  104319. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  104320. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  104321. var _this = _super.call(this, radius) || this;
  104322. _this.direction1 = direction1;
  104323. _this.direction2 = direction2;
  104324. return _this;
  104325. }
  104326. /**
  104327. * Called by the particle System when the direction is computed for the created particle.
  104328. * @param worldMatrix is the world matrix of the particle system
  104329. * @param directionToUpdate is the direction vector to update with the result
  104330. * @param particle is the particle we are computed the direction for
  104331. */
  104332. SphereDirectedParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  104333. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  104334. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  104335. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  104336. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  104337. };
  104338. /**
  104339. * Clones the current emitter and returns a copy of it
  104340. * @returns the new emitter
  104341. */
  104342. SphereDirectedParticleEmitter.prototype.clone = function () {
  104343. var newOne = new SphereDirectedParticleEmitter(this.radius, this.direction1, this.direction2);
  104344. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  104345. return newOne;
  104346. };
  104347. /**
  104348. * Called by the GPUParticleSystem to setup the update shader
  104349. * @param effect defines the update shader
  104350. */
  104351. SphereDirectedParticleEmitter.prototype.applyToShader = function (effect) {
  104352. effect.setFloat("radius", this.radius);
  104353. effect.setFloat("radiusRange", this.radiusRange);
  104354. effect.setVector3("direction1", this.direction1);
  104355. effect.setVector3("direction2", this.direction2);
  104356. };
  104357. /**
  104358. * Returns a string to use to update the GPU particles update shader
  104359. * @returns a string containng the defines string
  104360. */
  104361. SphereDirectedParticleEmitter.prototype.getEffectDefines = function () {
  104362. return "#define SPHEREEMITTER\n#define DIRECTEDSPHEREEMITTER";
  104363. };
  104364. /**
  104365. * Returns the string "SphereDirectedParticleEmitter"
  104366. * @returns a string containing the class name
  104367. */
  104368. SphereDirectedParticleEmitter.prototype.getClassName = function () {
  104369. return "SphereDirectedParticleEmitter";
  104370. };
  104371. /**
  104372. * Serializes the particle system to a JSON object.
  104373. * @returns the JSON object
  104374. */
  104375. SphereDirectedParticleEmitter.prototype.serialize = function () {
  104376. var serializationObject = _super.prototype.serialize.call(this);
  104377. serializationObject.direction1 = this.direction1.asArray();
  104378. serializationObject.direction2 = this.direction2.asArray();
  104379. return serializationObject;
  104380. };
  104381. /**
  104382. * Parse properties from a JSON object
  104383. * @param serializationObject defines the JSON object
  104384. */
  104385. SphereDirectedParticleEmitter.prototype.parse = function (serializationObject) {
  104386. _super.prototype.parse.call(this, serializationObject);
  104387. this.direction1.copyFrom(serializationObject.direction1);
  104388. this.direction2.copyFrom(serializationObject.direction2);
  104389. };
  104390. return SphereDirectedParticleEmitter;
  104391. }(SphereParticleEmitter));
  104392. /***/ }),
  104393. /***/ "./Particles/baseParticleSystem.ts":
  104394. /*!*****************************************!*\
  104395. !*** ./Particles/baseParticleSystem.ts ***!
  104396. \*****************************************/
  104397. /*! exports provided: BaseParticleSystem */
  104398. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104399. "use strict";
  104400. __webpack_require__.r(__webpack_exports__);
  104401. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return BaseParticleSystem; });
  104402. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  104403. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  104404. /* harmony import */ var _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Particles/EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  104405. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  104406. /**
  104407. * This represents the base class for particle system in Babylon.
  104408. * 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.
  104409. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  104410. * @example https://doc.babylonjs.com/babylon101/particles
  104411. */
  104412. var BaseParticleSystem = /** @class */ (function () {
  104413. /**
  104414. * Instantiates a particle system.
  104415. * 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.
  104416. * @param name The name of the particle system
  104417. */
  104418. function BaseParticleSystem(name) {
  104419. /**
  104420. * List of animations used by the particle system.
  104421. */
  104422. this.animations = [];
  104423. /**
  104424. * The rendering group used by the Particle system to chose when to render.
  104425. */
  104426. this.renderingGroupId = 0;
  104427. /**
  104428. * The emitter represents the Mesh or position we are attaching the particle system to.
  104429. */
  104430. this.emitter = null;
  104431. /**
  104432. * The maximum number of particles to emit per frame
  104433. */
  104434. this.emitRate = 10;
  104435. /**
  104436. * If you want to launch only a few particles at once, that can be done, as well.
  104437. */
  104438. this.manualEmitCount = -1;
  104439. /**
  104440. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  104441. */
  104442. this.updateSpeed = 0.01;
  104443. /**
  104444. * The amount of time the particle system is running (depends of the overall update speed).
  104445. */
  104446. this.targetStopDuration = 0;
  104447. /**
  104448. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  104449. */
  104450. this.disposeOnStop = false;
  104451. /**
  104452. * Minimum power of emitting particles.
  104453. */
  104454. this.minEmitPower = 1;
  104455. /**
  104456. * Maximum power of emitting particles.
  104457. */
  104458. this.maxEmitPower = 1;
  104459. /**
  104460. * Minimum life time of emitting particles.
  104461. */
  104462. this.minLifeTime = 1;
  104463. /**
  104464. * Maximum life time of emitting particles.
  104465. */
  104466. this.maxLifeTime = 1;
  104467. /**
  104468. * Minimum Size of emitting particles.
  104469. */
  104470. this.minSize = 1;
  104471. /**
  104472. * Maximum Size of emitting particles.
  104473. */
  104474. this.maxSize = 1;
  104475. /**
  104476. * Minimum scale of emitting particles on X axis.
  104477. */
  104478. this.minScaleX = 1;
  104479. /**
  104480. * Maximum scale of emitting particles on X axis.
  104481. */
  104482. this.maxScaleX = 1;
  104483. /**
  104484. * Minimum scale of emitting particles on Y axis.
  104485. */
  104486. this.minScaleY = 1;
  104487. /**
  104488. * Maximum scale of emitting particles on Y axis.
  104489. */
  104490. this.maxScaleY = 1;
  104491. /**
  104492. * Gets or sets the minimal initial rotation in radians.
  104493. */
  104494. this.minInitialRotation = 0;
  104495. /**
  104496. * Gets or sets the maximal initial rotation in radians.
  104497. */
  104498. this.maxInitialRotation = 0;
  104499. /**
  104500. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  104501. */
  104502. this.minAngularSpeed = 0;
  104503. /**
  104504. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  104505. */
  104506. this.maxAngularSpeed = 0;
  104507. /**
  104508. * The layer mask we are rendering the particles through.
  104509. */
  104510. this.layerMask = 0x0FFFFFFF;
  104511. /**
  104512. * This can help using your own shader to render the particle system.
  104513. * The according effect will be created
  104514. */
  104515. this.customShader = null;
  104516. /**
  104517. * By default particle system starts as soon as they are created. This prevents the
  104518. * automatic start to happen and let you decide when to start emitting particles.
  104519. */
  104520. this.preventAutoStart = false;
  104521. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  104522. this.noiseStrength = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](10, 10, 10);
  104523. /**
  104524. * Callback triggered when the particle animation is ending.
  104525. */
  104526. this.onAnimationEnd = null;
  104527. /**
  104528. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  104529. */
  104530. this.blendMode = BaseParticleSystem.BLENDMODE_ONEONE;
  104531. /**
  104532. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  104533. * to override the particles.
  104534. */
  104535. this.forceDepthWrite = false;
  104536. /** 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 */
  104537. this.preWarmCycles = 0;
  104538. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  104539. this.preWarmStepOffset = 1;
  104540. /**
  104541. * 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)
  104542. */
  104543. this.spriteCellChangeSpeed = 1;
  104544. /**
  104545. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  104546. */
  104547. this.startSpriteCellID = 0;
  104548. /**
  104549. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  104550. */
  104551. this.endSpriteCellID = 0;
  104552. /**
  104553. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  104554. */
  104555. this.spriteCellWidth = 0;
  104556. /**
  104557. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  104558. */
  104559. this.spriteCellHeight = 0;
  104560. /**
  104561. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  104562. */
  104563. this.spriteRandomStartCell = false;
  104564. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  104565. this.translationPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  104566. /**
  104567. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  104568. */
  104569. this.beginAnimationOnStart = false;
  104570. /**
  104571. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  104572. */
  104573. this.beginAnimationFrom = 0;
  104574. /**
  104575. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  104576. */
  104577. this.beginAnimationTo = 60;
  104578. /**
  104579. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  104580. */
  104581. this.beginAnimationLoop = false;
  104582. /**
  104583. * Gets or sets a world offset applied to all particles
  104584. */
  104585. this.worldOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  104586. /**
  104587. * You can use gravity if you want to give an orientation to your particles.
  104588. */
  104589. this.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  104590. this._colorGradients = null;
  104591. this._sizeGradients = null;
  104592. this._lifeTimeGradients = null;
  104593. this._angularSpeedGradients = null;
  104594. this._velocityGradients = null;
  104595. this._limitVelocityGradients = null;
  104596. this._dragGradients = null;
  104597. this._emitRateGradients = null;
  104598. this._startSizeGradients = null;
  104599. this._rampGradients = null;
  104600. this._colorRemapGradients = null;
  104601. this._alphaRemapGradients = null;
  104602. /**
  104603. * Defines the delay in milliseconds before starting the system (0 by default)
  104604. */
  104605. this.startDelay = 0;
  104606. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  104607. this.limitVelocityDamping = 0.4;
  104608. /**
  104609. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  104610. */
  104611. this.color1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  104612. /**
  104613. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  104614. */
  104615. this.color2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  104616. /**
  104617. * Color the particle will have at the end of its lifetime
  104618. */
  104619. this.colorDead = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 1.0);
  104620. /**
  104621. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  104622. */
  104623. this.textureMask = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  104624. /** @hidden */
  104625. this._isSubEmitter = false;
  104626. /**
  104627. * Gets or sets the billboard mode to use when isBillboardBased = true.
  104628. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  104629. */
  104630. this.billboardMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].PARTICLES_BILLBOARDMODE_ALL;
  104631. this._isBillboardBased = true;
  104632. /**
  104633. * Local cache of defines for image processing.
  104634. */
  104635. this._imageProcessingConfigurationDefines = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_1__["ImageProcessingConfigurationDefines"]();
  104636. this.id = name;
  104637. this.name = name;
  104638. }
  104639. Object.defineProperty(BaseParticleSystem.prototype, "noiseTexture", {
  104640. /**
  104641. * Gets or sets a texture used to add random noise to particle positions
  104642. */
  104643. get: function () {
  104644. return this._noiseTexture;
  104645. },
  104646. set: function (value) {
  104647. if (this._noiseTexture === value) {
  104648. return;
  104649. }
  104650. this._noiseTexture = value;
  104651. this._reset();
  104652. },
  104653. enumerable: true,
  104654. configurable: true
  104655. });
  104656. Object.defineProperty(BaseParticleSystem.prototype, "isAnimationSheetEnabled", {
  104657. /**
  104658. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  104659. */
  104660. get: function () {
  104661. return this._isAnimationSheetEnabled;
  104662. },
  104663. set: function (value) {
  104664. if (this._isAnimationSheetEnabled == value) {
  104665. return;
  104666. }
  104667. this._isAnimationSheetEnabled = value;
  104668. this._reset();
  104669. },
  104670. enumerable: true,
  104671. configurable: true
  104672. });
  104673. /**
  104674. * Get hosting scene
  104675. * @returns the scene
  104676. */
  104677. BaseParticleSystem.prototype.getScene = function () {
  104678. return this._scene;
  104679. };
  104680. BaseParticleSystem.prototype._hasTargetStopDurationDependantGradient = function () {
  104681. return (this._startSizeGradients && this._startSizeGradients.length > 0)
  104682. || (this._emitRateGradients && this._emitRateGradients.length > 0)
  104683. || (this._lifeTimeGradients && this._lifeTimeGradients.length > 0);
  104684. };
  104685. /**
  104686. * Gets the current list of drag gradients.
  104687. * You must use addDragGradient and removeDragGradient to udpate this list
  104688. * @returns the list of drag gradients
  104689. */
  104690. BaseParticleSystem.prototype.getDragGradients = function () {
  104691. return this._dragGradients;
  104692. };
  104693. /**
  104694. * Gets the current list of limit velocity gradients.
  104695. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  104696. * @returns the list of limit velocity gradients
  104697. */
  104698. BaseParticleSystem.prototype.getLimitVelocityGradients = function () {
  104699. return this._limitVelocityGradients;
  104700. };
  104701. /**
  104702. * Gets the current list of color gradients.
  104703. * You must use addColorGradient and removeColorGradient to udpate this list
  104704. * @returns the list of color gradients
  104705. */
  104706. BaseParticleSystem.prototype.getColorGradients = function () {
  104707. return this._colorGradients;
  104708. };
  104709. /**
  104710. * Gets the current list of size gradients.
  104711. * You must use addSizeGradient and removeSizeGradient to udpate this list
  104712. * @returns the list of size gradients
  104713. */
  104714. BaseParticleSystem.prototype.getSizeGradients = function () {
  104715. return this._sizeGradients;
  104716. };
  104717. /**
  104718. * Gets the current list of color remap gradients.
  104719. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  104720. * @returns the list of color remap gradients
  104721. */
  104722. BaseParticleSystem.prototype.getColorRemapGradients = function () {
  104723. return this._colorRemapGradients;
  104724. };
  104725. /**
  104726. * Gets the current list of alpha remap gradients.
  104727. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  104728. * @returns the list of alpha remap gradients
  104729. */
  104730. BaseParticleSystem.prototype.getAlphaRemapGradients = function () {
  104731. return this._alphaRemapGradients;
  104732. };
  104733. /**
  104734. * Gets the current list of life time gradients.
  104735. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  104736. * @returns the list of life time gradients
  104737. */
  104738. BaseParticleSystem.prototype.getLifeTimeGradients = function () {
  104739. return this._lifeTimeGradients;
  104740. };
  104741. /**
  104742. * Gets the current list of angular speed gradients.
  104743. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  104744. * @returns the list of angular speed gradients
  104745. */
  104746. BaseParticleSystem.prototype.getAngularSpeedGradients = function () {
  104747. return this._angularSpeedGradients;
  104748. };
  104749. /**
  104750. * Gets the current list of velocity gradients.
  104751. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  104752. * @returns the list of velocity gradients
  104753. */
  104754. BaseParticleSystem.prototype.getVelocityGradients = function () {
  104755. return this._velocityGradients;
  104756. };
  104757. /**
  104758. * Gets the current list of start size gradients.
  104759. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  104760. * @returns the list of start size gradients
  104761. */
  104762. BaseParticleSystem.prototype.getStartSizeGradients = function () {
  104763. return this._startSizeGradients;
  104764. };
  104765. /**
  104766. * Gets the current list of emit rate gradients.
  104767. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  104768. * @returns the list of emit rate gradients
  104769. */
  104770. BaseParticleSystem.prototype.getEmitRateGradients = function () {
  104771. return this._emitRateGradients;
  104772. };
  104773. Object.defineProperty(BaseParticleSystem.prototype, "direction1", {
  104774. /**
  104775. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  104776. * This only works when particleEmitterTyps is a BoxParticleEmitter
  104777. */
  104778. get: function () {
  104779. if (this.particleEmitterType.direction1) {
  104780. return this.particleEmitterType.direction1;
  104781. }
  104782. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  104783. },
  104784. set: function (value) {
  104785. if (this.particleEmitterType.direction1) {
  104786. this.particleEmitterType.direction1 = value;
  104787. }
  104788. },
  104789. enumerable: true,
  104790. configurable: true
  104791. });
  104792. Object.defineProperty(BaseParticleSystem.prototype, "direction2", {
  104793. /**
  104794. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  104795. * This only works when particleEmitterTyps is a BoxParticleEmitter
  104796. */
  104797. get: function () {
  104798. if (this.particleEmitterType.direction2) {
  104799. return this.particleEmitterType.direction2;
  104800. }
  104801. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  104802. },
  104803. set: function (value) {
  104804. if (this.particleEmitterType.direction2) {
  104805. this.particleEmitterType.direction2 = value;
  104806. }
  104807. },
  104808. enumerable: true,
  104809. configurable: true
  104810. });
  104811. Object.defineProperty(BaseParticleSystem.prototype, "minEmitBox", {
  104812. /**
  104813. * 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.
  104814. * This only works when particleEmitterTyps is a BoxParticleEmitter
  104815. */
  104816. get: function () {
  104817. if (this.particleEmitterType.minEmitBox) {
  104818. return this.particleEmitterType.minEmitBox;
  104819. }
  104820. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  104821. },
  104822. set: function (value) {
  104823. if (this.particleEmitterType.minEmitBox) {
  104824. this.particleEmitterType.minEmitBox = value;
  104825. }
  104826. },
  104827. enumerable: true,
  104828. configurable: true
  104829. });
  104830. Object.defineProperty(BaseParticleSystem.prototype, "maxEmitBox", {
  104831. /**
  104832. * 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.
  104833. * This only works when particleEmitterTyps is a BoxParticleEmitter
  104834. */
  104835. get: function () {
  104836. if (this.particleEmitterType.maxEmitBox) {
  104837. return this.particleEmitterType.maxEmitBox;
  104838. }
  104839. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  104840. },
  104841. set: function (value) {
  104842. if (this.particleEmitterType.maxEmitBox) {
  104843. this.particleEmitterType.maxEmitBox = value;
  104844. }
  104845. },
  104846. enumerable: true,
  104847. configurable: true
  104848. });
  104849. Object.defineProperty(BaseParticleSystem.prototype, "isBillboardBased", {
  104850. /**
  104851. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  104852. */
  104853. get: function () {
  104854. return this._isBillboardBased;
  104855. },
  104856. set: function (value) {
  104857. if (this._isBillboardBased === value) {
  104858. return;
  104859. }
  104860. this._isBillboardBased = value;
  104861. this._reset();
  104862. },
  104863. enumerable: true,
  104864. configurable: true
  104865. });
  104866. Object.defineProperty(BaseParticleSystem.prototype, "imageProcessingConfiguration", {
  104867. /**
  104868. * Gets the image processing configuration used either in this material.
  104869. */
  104870. get: function () {
  104871. return this._imageProcessingConfiguration;
  104872. },
  104873. /**
  104874. * Sets the Default image processing configuration used either in the this material.
  104875. *
  104876. * If sets to null, the scene one is in use.
  104877. */
  104878. set: function (value) {
  104879. this._attachImageProcessingConfiguration(value);
  104880. },
  104881. enumerable: true,
  104882. configurable: true
  104883. });
  104884. /**
  104885. * Attaches a new image processing configuration to the Standard Material.
  104886. * @param configuration
  104887. */
  104888. BaseParticleSystem.prototype._attachImageProcessingConfiguration = function (configuration) {
  104889. if (configuration === this._imageProcessingConfiguration) {
  104890. return;
  104891. }
  104892. // Pick the scene configuration if needed.
  104893. if (!configuration) {
  104894. this._imageProcessingConfiguration = this._scene.imageProcessingConfiguration;
  104895. }
  104896. else {
  104897. this._imageProcessingConfiguration = configuration;
  104898. }
  104899. };
  104900. /** @hidden */
  104901. BaseParticleSystem.prototype._reset = function () {
  104902. };
  104903. /** @hidden */
  104904. BaseParticleSystem.prototype._removeGradientAndTexture = function (gradient, gradients, texture) {
  104905. if (!gradients) {
  104906. return this;
  104907. }
  104908. var index = 0;
  104909. for (var _i = 0, gradients_1 = gradients; _i < gradients_1.length; _i++) {
  104910. var valueGradient = gradients_1[_i];
  104911. if (valueGradient.gradient === gradient) {
  104912. gradients.splice(index, 1);
  104913. break;
  104914. }
  104915. index++;
  104916. }
  104917. if (texture) {
  104918. texture.dispose();
  104919. }
  104920. return this;
  104921. };
  104922. /**
  104923. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  104924. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  104925. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  104926. * @returns the emitter
  104927. */
  104928. BaseParticleSystem.prototype.createPointEmitter = function (direction1, direction2) {
  104929. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["PointParticleEmitter"]();
  104930. particleEmitter.direction1 = direction1;
  104931. particleEmitter.direction2 = direction2;
  104932. this.particleEmitterType = particleEmitter;
  104933. return particleEmitter;
  104934. };
  104935. /**
  104936. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  104937. * @param radius The radius of the hemisphere to emit from
  104938. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  104939. * @returns the emitter
  104940. */
  104941. BaseParticleSystem.prototype.createHemisphericEmitter = function (radius, radiusRange) {
  104942. if (radius === void 0) { radius = 1; }
  104943. if (radiusRange === void 0) { radiusRange = 1; }
  104944. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["HemisphericParticleEmitter"](radius, radiusRange);
  104945. this.particleEmitterType = particleEmitter;
  104946. return particleEmitter;
  104947. };
  104948. /**
  104949. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  104950. * @param radius The radius of the sphere to emit from
  104951. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  104952. * @returns the emitter
  104953. */
  104954. BaseParticleSystem.prototype.createSphereEmitter = function (radius, radiusRange) {
  104955. if (radius === void 0) { radius = 1; }
  104956. if (radiusRange === void 0) { radiusRange = 1; }
  104957. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["SphereParticleEmitter"](radius, radiusRange);
  104958. this.particleEmitterType = particleEmitter;
  104959. return particleEmitter;
  104960. };
  104961. /**
  104962. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  104963. * @param radius The radius of the sphere to emit from
  104964. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  104965. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  104966. * @returns the emitter
  104967. */
  104968. BaseParticleSystem.prototype.createDirectedSphereEmitter = function (radius, direction1, direction2) {
  104969. if (radius === void 0) { radius = 1; }
  104970. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  104971. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  104972. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["SphereDirectedParticleEmitter"](radius, direction1, direction2);
  104973. this.particleEmitterType = particleEmitter;
  104974. return particleEmitter;
  104975. };
  104976. /**
  104977. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  104978. * @param radius The radius of the emission cylinder
  104979. * @param height The height of the emission cylinder
  104980. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  104981. * @param directionRandomizer How much to randomize the particle direction [0-1]
  104982. * @returns the emitter
  104983. */
  104984. BaseParticleSystem.prototype.createCylinderEmitter = function (radius, height, radiusRange, directionRandomizer) {
  104985. if (radius === void 0) { radius = 1; }
  104986. if (height === void 0) { height = 1; }
  104987. if (radiusRange === void 0) { radiusRange = 1; }
  104988. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  104989. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["CylinderParticleEmitter"](radius, height, radiusRange, directionRandomizer);
  104990. this.particleEmitterType = particleEmitter;
  104991. return particleEmitter;
  104992. };
  104993. /**
  104994. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  104995. * @param radius The radius of the cylinder to emit from
  104996. * @param height The height of the emission cylinder
  104997. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  104998. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  104999. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  105000. * @returns the emitter
  105001. */
  105002. BaseParticleSystem.prototype.createDirectedCylinderEmitter = function (radius, height, radiusRange, direction1, direction2) {
  105003. if (radius === void 0) { radius = 1; }
  105004. if (height === void 0) { height = 1; }
  105005. if (radiusRange === void 0) { radiusRange = 1; }
  105006. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  105007. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  105008. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["CylinderDirectedParticleEmitter"](radius, height, radiusRange, direction1, direction2);
  105009. this.particleEmitterType = particleEmitter;
  105010. return particleEmitter;
  105011. };
  105012. /**
  105013. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  105014. * @param radius The radius of the cone to emit from
  105015. * @param angle The base angle of the cone
  105016. * @returns the emitter
  105017. */
  105018. BaseParticleSystem.prototype.createConeEmitter = function (radius, angle) {
  105019. if (radius === void 0) { radius = 1; }
  105020. if (angle === void 0) { angle = Math.PI / 4; }
  105021. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["ConeParticleEmitter"](radius, angle);
  105022. this.particleEmitterType = particleEmitter;
  105023. return particleEmitter;
  105024. };
  105025. /**
  105026. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  105027. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  105028. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  105029. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  105030. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  105031. * @returns the emitter
  105032. */
  105033. BaseParticleSystem.prototype.createBoxEmitter = function (direction1, direction2, minEmitBox, maxEmitBox) {
  105034. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["BoxParticleEmitter"]();
  105035. this.particleEmitterType = particleEmitter;
  105036. this.direction1 = direction1;
  105037. this.direction2 = direction2;
  105038. this.minEmitBox = minEmitBox;
  105039. this.maxEmitBox = maxEmitBox;
  105040. return particleEmitter;
  105041. };
  105042. /**
  105043. * Source color is added to the destination color without alpha affecting the result
  105044. */
  105045. BaseParticleSystem.BLENDMODE_ONEONE = 0;
  105046. /**
  105047. * Blend current color and particle color using particle’s alpha
  105048. */
  105049. BaseParticleSystem.BLENDMODE_STANDARD = 1;
  105050. /**
  105051. * Add current color and particle color multiplied by particle’s alpha
  105052. */
  105053. BaseParticleSystem.BLENDMODE_ADD = 2;
  105054. /**
  105055. * Multiply current color with particle color
  105056. */
  105057. BaseParticleSystem.BLENDMODE_MULTIPLY = 3;
  105058. /**
  105059. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  105060. */
  105061. BaseParticleSystem.BLENDMODE_MULTIPLYADD = 4;
  105062. return BaseParticleSystem;
  105063. }());
  105064. /***/ }),
  105065. /***/ "./Particles/gpuParticleSystem.ts":
  105066. /*!****************************************!*\
  105067. !*** ./Particles/gpuParticleSystem.ts ***!
  105068. \****************************************/
  105069. /*! exports provided: GPUParticleSystem */
  105070. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105071. "use strict";
  105072. __webpack_require__.r(__webpack_exports__);
  105073. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return GPUParticleSystem; });
  105074. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  105075. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  105076. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  105077. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  105078. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  105079. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  105080. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  105081. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  105082. /* harmony import */ var _Particles_EmitterTypes_boxParticleEmitter__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Particles/EmitterTypes/boxParticleEmitter */ "./Particles/EmitterTypes/boxParticleEmitter.ts");
  105083. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  105084. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  105085. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  105086. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  105087. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  105088. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  105089. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  105090. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  105091. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  105092. /* harmony import */ var _Shaders_gpuUpdateParticles_fragment__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Shaders/gpuUpdateParticles.fragment */ "./Shaders/gpuUpdateParticles.fragment.ts");
  105093. /* harmony import */ var _Shaders_gpuUpdateParticles_vertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Shaders/gpuUpdateParticles.vertex */ "./Shaders/gpuUpdateParticles.vertex.ts");
  105094. /* harmony import */ var _Shaders_gpuRenderParticles_fragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Shaders/gpuRenderParticles.fragment */ "./Shaders/gpuRenderParticles.fragment.ts");
  105095. /* harmony import */ var _Shaders_gpuRenderParticles_vertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../Shaders/gpuRenderParticles.vertex */ "./Shaders/gpuRenderParticles.vertex.ts");
  105096. /**
  105097. * This represents a GPU particle system in Babylon
  105098. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  105099. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  105100. */
  105101. var GPUParticleSystem = /** @class */ (function (_super) {
  105102. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GPUParticleSystem, _super);
  105103. /**
  105104. * Instantiates a GPU particle system.
  105105. * 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.
  105106. * @param name The name of the particle system
  105107. * @param options The options used to create the system
  105108. * @param scene The scene the particle system belongs to
  105109. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  105110. */
  105111. function GPUParticleSystem(name, options, scene, isAnimationSheetEnabled) {
  105112. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  105113. var _this = _super.call(this, name) || this;
  105114. /**
  105115. * The layer mask we are rendering the particles through.
  105116. */
  105117. _this.layerMask = 0x0FFFFFFF;
  105118. _this._accumulatedCount = 0;
  105119. _this._targetIndex = 0;
  105120. _this._currentRenderId = -1;
  105121. _this._started = false;
  105122. _this._stopped = false;
  105123. _this._timeDelta = 0;
  105124. _this._actualFrame = 0;
  105125. _this._rawTextureWidth = 256;
  105126. /**
  105127. * An event triggered when the system is disposed.
  105128. */
  105129. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  105130. /**
  105131. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  105132. * to override the particles.
  105133. */
  105134. _this.forceDepthWrite = false;
  105135. _this._preWarmDone = false;
  105136. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene;
  105137. // Setup the default processing configuration to the scene.
  105138. _this._attachImageProcessingConfiguration(null);
  105139. _this._engine = _this._scene.getEngine();
  105140. if (!options.randomTextureSize) {
  105141. delete options.randomTextureSize;
  105142. }
  105143. var fullOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ capacity: 50000, randomTextureSize: _this._engine.getCaps().maxTextureSize }, options);
  105144. var optionsAsNumber = options;
  105145. if (isFinite(optionsAsNumber)) {
  105146. fullOptions.capacity = optionsAsNumber;
  105147. }
  105148. _this._capacity = fullOptions.capacity;
  105149. _this._activeCount = fullOptions.capacity;
  105150. _this._currentActiveCount = 0;
  105151. _this._isAnimationSheetEnabled = isAnimationSheetEnabled;
  105152. _this._scene.particleSystems.push(_this);
  105153. _this._updateEffectOptions = {
  105154. attributes: ["position", "age", "life", "seed", "size", "color", "direction", "initialDirection", "angle", "cellIndex", "cellStartOffset", "noiseCoordinates1", "noiseCoordinates2"],
  105155. uniformsNames: ["currentCount", "timeDelta", "emitterWM", "lifeTime", "color1", "color2", "sizeRange", "scaleRange", "gravity", "emitPower",
  105156. "direction1", "direction2", "minEmitBox", "maxEmitBox", "radius", "directionRandomizer", "height", "coneAngle", "stopFactor",
  105157. "angleRange", "radiusRange", "cellInfos", "noiseStrength", "limitVelocityDamping"],
  105158. uniformBuffersNames: [],
  105159. samplers: ["randomSampler", "randomSampler2", "sizeGradientSampler", "angularSpeedGradientSampler", "velocityGradientSampler", "limitVelocityGradientSampler", "noiseSampler", "dragGradientSampler"],
  105160. defines: "",
  105161. fallbacks: null,
  105162. onCompiled: null,
  105163. onError: null,
  105164. indexParameters: null,
  105165. maxSimultaneousLights: 0,
  105166. transformFeedbackVaryings: []
  105167. };
  105168. _this.particleEmitterType = new _Particles_EmitterTypes_boxParticleEmitter__WEBPACK_IMPORTED_MODULE_8__["BoxParticleEmitter"]();
  105169. // Random data
  105170. var maxTextureSize = Math.min(_this._engine.getCaps().maxTextureSize, fullOptions.randomTextureSize);
  105171. var d = [];
  105172. for (var i = 0; i < maxTextureSize; ++i) {
  105173. d.push(Math.random());
  105174. d.push(Math.random());
  105175. d.push(Math.random());
  105176. d.push(Math.random());
  105177. }
  105178. _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);
  105179. _this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  105180. _this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  105181. d = [];
  105182. for (var i = 0; i < maxTextureSize; ++i) {
  105183. d.push(Math.random());
  105184. d.push(Math.random());
  105185. d.push(Math.random());
  105186. d.push(Math.random());
  105187. }
  105188. _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);
  105189. _this._randomTexture2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  105190. _this._randomTexture2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  105191. _this._randomTextureSize = maxTextureSize;
  105192. return _this;
  105193. }
  105194. Object.defineProperty(GPUParticleSystem, "IsSupported", {
  105195. /**
  105196. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  105197. */
  105198. get: function () {
  105199. if (!_Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine) {
  105200. return false;
  105201. }
  105202. return _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine.webGLVersion > 1;
  105203. },
  105204. enumerable: true,
  105205. configurable: true
  105206. });
  105207. /**
  105208. * Gets the maximum number of particles active at the same time.
  105209. * @returns The max number of active particles.
  105210. */
  105211. GPUParticleSystem.prototype.getCapacity = function () {
  105212. return this._capacity;
  105213. };
  105214. Object.defineProperty(GPUParticleSystem.prototype, "activeParticleCount", {
  105215. /**
  105216. * Gets or set the number of active particles
  105217. */
  105218. get: function () {
  105219. return this._activeCount;
  105220. },
  105221. set: function (value) {
  105222. this._activeCount = Math.min(value, this._capacity);
  105223. },
  105224. enumerable: true,
  105225. configurable: true
  105226. });
  105227. /**
  105228. * Is this system ready to be used/rendered
  105229. * @return true if the system is ready
  105230. */
  105231. GPUParticleSystem.prototype.isReady = function () {
  105232. if (!this._updateEffect) {
  105233. this._recreateUpdateEffect();
  105234. this._recreateRenderEffect();
  105235. return false;
  105236. }
  105237. if (!this.emitter || !this._updateEffect.isReady() || !this._imageProcessingConfiguration.isReady() || !this._renderEffect.isReady() || !this.particleTexture || !this.particleTexture.isReady()) {
  105238. return false;
  105239. }
  105240. return true;
  105241. };
  105242. /**
  105243. * Gets if the system has been started. (Note: this will still be true after stop is called)
  105244. * @returns True if it has been started, otherwise false.
  105245. */
  105246. GPUParticleSystem.prototype.isStarted = function () {
  105247. return this._started;
  105248. };
  105249. /**
  105250. * Starts the particle system and begins to emit
  105251. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  105252. */
  105253. GPUParticleSystem.prototype.start = function (delay) {
  105254. var _this = this;
  105255. if (delay === void 0) { delay = this.startDelay; }
  105256. if (!this.targetStopDuration && this._hasTargetStopDurationDependantGradient()) {
  105257. throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
  105258. }
  105259. if (delay) {
  105260. setTimeout(function () {
  105261. _this.start(0);
  105262. }, delay);
  105263. return;
  105264. }
  105265. this._started = true;
  105266. this._stopped = false;
  105267. this._preWarmDone = false;
  105268. // Animations
  105269. if (this.beginAnimationOnStart && this.animations && this.animations.length > 0) {
  105270. this.getScene().beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop);
  105271. }
  105272. };
  105273. /**
  105274. * Stops the particle system.
  105275. */
  105276. GPUParticleSystem.prototype.stop = function () {
  105277. this._stopped = true;
  105278. };
  105279. /**
  105280. * Remove all active particles
  105281. */
  105282. GPUParticleSystem.prototype.reset = function () {
  105283. this._releaseBuffers();
  105284. this._releaseVAOs();
  105285. this._currentActiveCount = 0;
  105286. this._targetIndex = 0;
  105287. };
  105288. /**
  105289. * Returns the string "GPUParticleSystem"
  105290. * @returns a string containing the class name
  105291. */
  105292. GPUParticleSystem.prototype.getClassName = function () {
  105293. return "GPUParticleSystem";
  105294. };
  105295. GPUParticleSystem.prototype._removeGradientAndTexture = function (gradient, gradients, texture) {
  105296. _super.prototype._removeGradientAndTexture.call(this, gradient, gradients, texture);
  105297. this._releaseBuffers();
  105298. return this;
  105299. };
  105300. /**
  105301. * Adds a new color gradient
  105302. * @param gradient defines the gradient to use (between 0 and 1)
  105303. * @param color1 defines the color to affect to the specified gradient
  105304. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  105305. * @returns the current particle system
  105306. */
  105307. GPUParticleSystem.prototype.addColorGradient = function (gradient, color1, color2) {
  105308. if (!this._colorGradients) {
  105309. this._colorGradients = [];
  105310. }
  105311. var colorGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["ColorGradient"]();
  105312. colorGradient.gradient = gradient;
  105313. colorGradient.color1 = color1;
  105314. this._colorGradients.push(colorGradient);
  105315. this._colorGradients.sort(function (a, b) {
  105316. if (a.gradient < b.gradient) {
  105317. return -1;
  105318. }
  105319. else if (a.gradient > b.gradient) {
  105320. return 1;
  105321. }
  105322. return 0;
  105323. });
  105324. if (this._colorGradientsTexture) {
  105325. this._colorGradientsTexture.dispose();
  105326. this._colorGradientsTexture = null;
  105327. }
  105328. this._releaseBuffers();
  105329. return this;
  105330. };
  105331. /**
  105332. * Remove a specific color gradient
  105333. * @param gradient defines the gradient to remove
  105334. * @returns the current particle system
  105335. */
  105336. GPUParticleSystem.prototype.removeColorGradient = function (gradient) {
  105337. this._removeGradientAndTexture(gradient, this._colorGradients, this._colorGradientsTexture);
  105338. this._colorGradientsTexture = null;
  105339. return this;
  105340. };
  105341. GPUParticleSystem.prototype._addFactorGradient = function (factorGradients, gradient, factor) {
  105342. var valueGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["FactorGradient"]();
  105343. valueGradient.gradient = gradient;
  105344. valueGradient.factor1 = factor;
  105345. factorGradients.push(valueGradient);
  105346. factorGradients.sort(function (a, b) {
  105347. if (a.gradient < b.gradient) {
  105348. return -1;
  105349. }
  105350. else if (a.gradient > b.gradient) {
  105351. return 1;
  105352. }
  105353. return 0;
  105354. });
  105355. this._releaseBuffers();
  105356. };
  105357. /**
  105358. * Adds a new size gradient
  105359. * @param gradient defines the gradient to use (between 0 and 1)
  105360. * @param factor defines the size factor to affect to the specified gradient
  105361. * @returns the current particle system
  105362. */
  105363. GPUParticleSystem.prototype.addSizeGradient = function (gradient, factor) {
  105364. if (!this._sizeGradients) {
  105365. this._sizeGradients = [];
  105366. }
  105367. this._addFactorGradient(this._sizeGradients, gradient, factor);
  105368. if (this._sizeGradientsTexture) {
  105369. this._sizeGradientsTexture.dispose();
  105370. this._sizeGradientsTexture = null;
  105371. }
  105372. this._releaseBuffers();
  105373. return this;
  105374. };
  105375. /**
  105376. * Remove a specific size gradient
  105377. * @param gradient defines the gradient to remove
  105378. * @returns the current particle system
  105379. */
  105380. GPUParticleSystem.prototype.removeSizeGradient = function (gradient) {
  105381. this._removeGradientAndTexture(gradient, this._sizeGradients, this._sizeGradientsTexture);
  105382. this._sizeGradientsTexture = null;
  105383. return this;
  105384. };
  105385. /**
  105386. * Adds a new angular speed gradient
  105387. * @param gradient defines the gradient to use (between 0 and 1)
  105388. * @param factor defines the angular speed to affect to the specified gradient
  105389. * @returns the current particle system
  105390. */
  105391. GPUParticleSystem.prototype.addAngularSpeedGradient = function (gradient, factor) {
  105392. if (!this._angularSpeedGradients) {
  105393. this._angularSpeedGradients = [];
  105394. }
  105395. this._addFactorGradient(this._angularSpeedGradients, gradient, factor);
  105396. if (this._angularSpeedGradientsTexture) {
  105397. this._angularSpeedGradientsTexture.dispose();
  105398. this._angularSpeedGradientsTexture = null;
  105399. }
  105400. this._releaseBuffers();
  105401. return this;
  105402. };
  105403. /**
  105404. * Remove a specific angular speed gradient
  105405. * @param gradient defines the gradient to remove
  105406. * @returns the current particle system
  105407. */
  105408. GPUParticleSystem.prototype.removeAngularSpeedGradient = function (gradient) {
  105409. this._removeGradientAndTexture(gradient, this._angularSpeedGradients, this._angularSpeedGradientsTexture);
  105410. this._angularSpeedGradientsTexture = null;
  105411. return this;
  105412. };
  105413. /**
  105414. * Adds a new velocity gradient
  105415. * @param gradient defines the gradient to use (between 0 and 1)
  105416. * @param factor defines the velocity to affect to the specified gradient
  105417. * @returns the current particle system
  105418. */
  105419. GPUParticleSystem.prototype.addVelocityGradient = function (gradient, factor) {
  105420. if (!this._velocityGradients) {
  105421. this._velocityGradients = [];
  105422. }
  105423. this._addFactorGradient(this._velocityGradients, gradient, factor);
  105424. if (this._velocityGradientsTexture) {
  105425. this._velocityGradientsTexture.dispose();
  105426. this._velocityGradientsTexture = null;
  105427. }
  105428. this._releaseBuffers();
  105429. return this;
  105430. };
  105431. /**
  105432. * Remove a specific velocity gradient
  105433. * @param gradient defines the gradient to remove
  105434. * @returns the current particle system
  105435. */
  105436. GPUParticleSystem.prototype.removeVelocityGradient = function (gradient) {
  105437. this._removeGradientAndTexture(gradient, this._velocityGradients, this._velocityGradientsTexture);
  105438. this._velocityGradientsTexture = null;
  105439. return this;
  105440. };
  105441. /**
  105442. * Adds a new limit velocity gradient
  105443. * @param gradient defines the gradient to use (between 0 and 1)
  105444. * @param factor defines the limit velocity value to affect to the specified gradient
  105445. * @returns the current particle system
  105446. */
  105447. GPUParticleSystem.prototype.addLimitVelocityGradient = function (gradient, factor) {
  105448. if (!this._limitVelocityGradients) {
  105449. this._limitVelocityGradients = [];
  105450. }
  105451. this._addFactorGradient(this._limitVelocityGradients, gradient, factor);
  105452. if (this._limitVelocityGradientsTexture) {
  105453. this._limitVelocityGradientsTexture.dispose();
  105454. this._limitVelocityGradientsTexture = null;
  105455. }
  105456. this._releaseBuffers();
  105457. return this;
  105458. };
  105459. /**
  105460. * Remove a specific limit velocity gradient
  105461. * @param gradient defines the gradient to remove
  105462. * @returns the current particle system
  105463. */
  105464. GPUParticleSystem.prototype.removeLimitVelocityGradient = function (gradient) {
  105465. this._removeGradientAndTexture(gradient, this._limitVelocityGradients, this._limitVelocityGradientsTexture);
  105466. this._limitVelocityGradientsTexture = null;
  105467. return this;
  105468. };
  105469. /**
  105470. * Adds a new drag gradient
  105471. * @param gradient defines the gradient to use (between 0 and 1)
  105472. * @param factor defines the drag value to affect to the specified gradient
  105473. * @returns the current particle system
  105474. */
  105475. GPUParticleSystem.prototype.addDragGradient = function (gradient, factor) {
  105476. if (!this._dragGradients) {
  105477. this._dragGradients = [];
  105478. }
  105479. this._addFactorGradient(this._dragGradients, gradient, factor);
  105480. if (this._dragGradientsTexture) {
  105481. this._dragGradientsTexture.dispose();
  105482. this._dragGradientsTexture = null;
  105483. }
  105484. this._releaseBuffers();
  105485. return this;
  105486. };
  105487. /**
  105488. * Remove a specific drag gradient
  105489. * @param gradient defines the gradient to remove
  105490. * @returns the current particle system
  105491. */
  105492. GPUParticleSystem.prototype.removeDragGradient = function (gradient) {
  105493. this._removeGradientAndTexture(gradient, this._dragGradients, this._dragGradientsTexture);
  105494. this._dragGradientsTexture = null;
  105495. return this;
  105496. };
  105497. /**
  105498. * Not supported by GPUParticleSystem
  105499. * @param gradient defines the gradient to use (between 0 and 1)
  105500. * @param factor defines the emit rate value to affect to the specified gradient
  105501. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105502. * @returns the current particle system
  105503. */
  105504. GPUParticleSystem.prototype.addEmitRateGradient = function (gradient, factor, factor2) {
  105505. // Do nothing as emit rate is not supported by GPUParticleSystem
  105506. return this;
  105507. };
  105508. /**
  105509. * Not supported by GPUParticleSystem
  105510. * @param gradient defines the gradient to remove
  105511. * @returns the current particle system
  105512. */
  105513. GPUParticleSystem.prototype.removeEmitRateGradient = function (gradient) {
  105514. // Do nothing as emit rate is not supported by GPUParticleSystem
  105515. return this;
  105516. };
  105517. /**
  105518. * Not supported by GPUParticleSystem
  105519. * @param gradient defines the gradient to use (between 0 and 1)
  105520. * @param factor defines the start size value to affect to the specified gradient
  105521. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105522. * @returns the current particle system
  105523. */
  105524. GPUParticleSystem.prototype.addStartSizeGradient = function (gradient, factor, factor2) {
  105525. // Do nothing as start size is not supported by GPUParticleSystem
  105526. return this;
  105527. };
  105528. /**
  105529. * Not supported by GPUParticleSystem
  105530. * @param gradient defines the gradient to remove
  105531. * @returns the current particle system
  105532. */
  105533. GPUParticleSystem.prototype.removeStartSizeGradient = function (gradient) {
  105534. // Do nothing as start size is not supported by GPUParticleSystem
  105535. return this;
  105536. };
  105537. /**
  105538. * Not supported by GPUParticleSystem
  105539. * @param gradient defines the gradient to use (between 0 and 1)
  105540. * @param min defines the color remap minimal range
  105541. * @param max defines the color remap maximal range
  105542. * @returns the current particle system
  105543. */
  105544. GPUParticleSystem.prototype.addColorRemapGradient = function (gradient, min, max) {
  105545. // Do nothing as start size is not supported by GPUParticleSystem
  105546. return this;
  105547. };
  105548. /**
  105549. * Not supported by GPUParticleSystem
  105550. * @param gradient defines the gradient to remove
  105551. * @returns the current particle system
  105552. */
  105553. GPUParticleSystem.prototype.removeColorRemapGradient = function () {
  105554. // Do nothing as start size is not supported by GPUParticleSystem
  105555. return this;
  105556. };
  105557. /**
  105558. * Not supported by GPUParticleSystem
  105559. * @param gradient defines the gradient to use (between 0 and 1)
  105560. * @param min defines the alpha remap minimal range
  105561. * @param max defines the alpha remap maximal range
  105562. * @returns the current particle system
  105563. */
  105564. GPUParticleSystem.prototype.addAlphaRemapGradient = function (gradient, min, max) {
  105565. // Do nothing as start size is not supported by GPUParticleSystem
  105566. return this;
  105567. };
  105568. /**
  105569. * Not supported by GPUParticleSystem
  105570. * @param gradient defines the gradient to remove
  105571. * @returns the current particle system
  105572. */
  105573. GPUParticleSystem.prototype.removeAlphaRemapGradient = function () {
  105574. // Do nothing as start size is not supported by GPUParticleSystem
  105575. return this;
  105576. };
  105577. /**
  105578. * Not supported by GPUParticleSystem
  105579. * @param gradient defines the gradient to use (between 0 and 1)
  105580. * @param color defines the color to affect to the specified gradient
  105581. * @returns the current particle system
  105582. */
  105583. GPUParticleSystem.prototype.addRampGradient = function (gradient, color) {
  105584. //Not supported by GPUParticleSystem
  105585. return this;
  105586. };
  105587. /**
  105588. * Not supported by GPUParticleSystem
  105589. * @param gradient defines the gradient to remove
  105590. * @returns the current particle system
  105591. */
  105592. GPUParticleSystem.prototype.removeRampGradient = function () {
  105593. //Not supported by GPUParticleSystem
  105594. return this;
  105595. };
  105596. /**
  105597. * Not supported by GPUParticleSystem
  105598. * @returns the list of ramp gradients
  105599. */
  105600. GPUParticleSystem.prototype.getRampGradients = function () {
  105601. return null;
  105602. };
  105603. Object.defineProperty(GPUParticleSystem.prototype, "useRampGradients", {
  105604. /**
  105605. * Not supported by GPUParticleSystem
  105606. * Gets or sets a boolean indicating that ramp gradients must be used
  105607. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  105608. */
  105609. get: function () {
  105610. //Not supported by GPUParticleSystem
  105611. return false;
  105612. },
  105613. set: function (value) {
  105614. //Not supported by GPUParticleSystem
  105615. },
  105616. enumerable: true,
  105617. configurable: true
  105618. });
  105619. /**
  105620. * Not supported by GPUParticleSystem
  105621. * @param gradient defines the gradient to use (between 0 and 1)
  105622. * @param factor defines the life time factor to affect to the specified gradient
  105623. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105624. * @returns the current particle system
  105625. */
  105626. GPUParticleSystem.prototype.addLifeTimeGradient = function (gradient, factor, factor2) {
  105627. //Not supported by GPUParticleSystem
  105628. return this;
  105629. };
  105630. /**
  105631. * Not supported by GPUParticleSystem
  105632. * @param gradient defines the gradient to remove
  105633. * @returns the current particle system
  105634. */
  105635. GPUParticleSystem.prototype.removeLifeTimeGradient = function (gradient) {
  105636. //Not supported by GPUParticleSystem
  105637. return this;
  105638. };
  105639. GPUParticleSystem.prototype._reset = function () {
  105640. this._releaseBuffers();
  105641. };
  105642. GPUParticleSystem.prototype._createUpdateVAO = function (source) {
  105643. var updateVertexBuffers = {};
  105644. updateVertexBuffers["position"] = source.createVertexBuffer("position", 0, 3);
  105645. updateVertexBuffers["age"] = source.createVertexBuffer("age", 3, 1);
  105646. updateVertexBuffers["life"] = source.createVertexBuffer("life", 4, 1);
  105647. updateVertexBuffers["seed"] = source.createVertexBuffer("seed", 5, 4);
  105648. updateVertexBuffers["size"] = source.createVertexBuffer("size", 9, 3);
  105649. var offset = 12;
  105650. if (!this._colorGradientsTexture) {
  105651. updateVertexBuffers["color"] = source.createVertexBuffer("color", offset, 4);
  105652. offset += 4;
  105653. }
  105654. updateVertexBuffers["direction"] = source.createVertexBuffer("direction", offset, 3);
  105655. offset += 3;
  105656. if (!this._isBillboardBased) {
  105657. updateVertexBuffers["initialDirection"] = source.createVertexBuffer("initialDirection", offset, 3);
  105658. offset += 3;
  105659. }
  105660. if (this._angularSpeedGradientsTexture) {
  105661. updateVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 1);
  105662. offset += 1;
  105663. }
  105664. else {
  105665. updateVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 2);
  105666. offset += 2;
  105667. }
  105668. if (this._isAnimationSheetEnabled) {
  105669. updateVertexBuffers["cellIndex"] = source.createVertexBuffer("cellIndex", offset, 1);
  105670. offset += 1;
  105671. if (this.spriteRandomStartCell) {
  105672. updateVertexBuffers["cellStartOffset"] = source.createVertexBuffer("cellStartOffset", offset, 1);
  105673. offset += 1;
  105674. }
  105675. }
  105676. if (this.noiseTexture) {
  105677. updateVertexBuffers["noiseCoordinates1"] = source.createVertexBuffer("noiseCoordinates1", offset, 3);
  105678. offset += 3;
  105679. updateVertexBuffers["noiseCoordinates2"] = source.createVertexBuffer("noiseCoordinates2", offset, 3);
  105680. offset += 3;
  105681. }
  105682. var vao = this._engine.recordVertexArrayObject(updateVertexBuffers, null, this._updateEffect);
  105683. this._engine.bindArrayBuffer(null);
  105684. return vao;
  105685. };
  105686. GPUParticleSystem.prototype._createRenderVAO = function (source, spriteSource) {
  105687. var renderVertexBuffers = {};
  105688. renderVertexBuffers["position"] = source.createVertexBuffer("position", 0, 3, this._attributesStrideSize, true);
  105689. renderVertexBuffers["age"] = source.createVertexBuffer("age", 3, 1, this._attributesStrideSize, true);
  105690. renderVertexBuffers["life"] = source.createVertexBuffer("life", 4, 1, this._attributesStrideSize, true);
  105691. renderVertexBuffers["size"] = source.createVertexBuffer("size", 9, 3, this._attributesStrideSize, true);
  105692. var offset = 12;
  105693. if (!this._colorGradientsTexture) {
  105694. renderVertexBuffers["color"] = source.createVertexBuffer("color", offset, 4, this._attributesStrideSize, true);
  105695. offset += 4;
  105696. }
  105697. if (this.billboardMode === _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_STRETCHED) {
  105698. renderVertexBuffers["direction"] = source.createVertexBuffer("direction", offset, 3, this._attributesStrideSize, true);
  105699. }
  105700. offset += 3; // Direction
  105701. if (!this._isBillboardBased) {
  105702. renderVertexBuffers["initialDirection"] = source.createVertexBuffer("initialDirection", offset, 3, this._attributesStrideSize, true);
  105703. offset += 3;
  105704. }
  105705. renderVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 1, this._attributesStrideSize, true);
  105706. if (this._angularSpeedGradientsTexture) {
  105707. offset++;
  105708. }
  105709. else {
  105710. offset += 2;
  105711. }
  105712. if (this._isAnimationSheetEnabled) {
  105713. renderVertexBuffers["cellIndex"] = source.createVertexBuffer("cellIndex", offset, 1, this._attributesStrideSize, true);
  105714. offset += 1;
  105715. if (this.spriteRandomStartCell) {
  105716. renderVertexBuffers["cellStartOffset"] = source.createVertexBuffer("cellStartOffset", offset, 1, this._attributesStrideSize, true);
  105717. offset += 1;
  105718. }
  105719. }
  105720. if (this.noiseTexture) {
  105721. renderVertexBuffers["noiseCoordinates1"] = source.createVertexBuffer("noiseCoordinates1", offset, 3, this._attributesStrideSize, true);
  105722. offset += 3;
  105723. renderVertexBuffers["noiseCoordinates2"] = source.createVertexBuffer("noiseCoordinates2", offset, 3, this._attributesStrideSize, true);
  105724. offset += 3;
  105725. }
  105726. renderVertexBuffers["offset"] = spriteSource.createVertexBuffer("offset", 0, 2);
  105727. renderVertexBuffers["uv"] = spriteSource.createVertexBuffer("uv", 2, 2);
  105728. var vao = this._engine.recordVertexArrayObject(renderVertexBuffers, null, this._renderEffect);
  105729. this._engine.bindArrayBuffer(null);
  105730. return vao;
  105731. };
  105732. GPUParticleSystem.prototype._initialize = function (force) {
  105733. if (force === void 0) { force = false; }
  105734. if (this._buffer0 && !force) {
  105735. return;
  105736. }
  105737. var engine = this._scene.getEngine();
  105738. var data = new Array();
  105739. this._attributesStrideSize = 21;
  105740. this._targetIndex = 0;
  105741. if (!this.isBillboardBased) {
  105742. this._attributesStrideSize += 3;
  105743. }
  105744. if (this._colorGradientsTexture) {
  105745. this._attributesStrideSize -= 4;
  105746. }
  105747. if (this._angularSpeedGradientsTexture) {
  105748. this._attributesStrideSize -= 1;
  105749. }
  105750. if (this._isAnimationSheetEnabled) {
  105751. this._attributesStrideSize += 1;
  105752. if (this.spriteRandomStartCell) {
  105753. this._attributesStrideSize += 1;
  105754. }
  105755. }
  105756. if (this.noiseTexture) {
  105757. this._attributesStrideSize += 6;
  105758. }
  105759. for (var particleIndex = 0; particleIndex < this._capacity; particleIndex++) {
  105760. // position
  105761. data.push(0.0);
  105762. data.push(0.0);
  105763. data.push(0.0);
  105764. // Age and life
  105765. data.push(0.0); // create the particle as a dead one to create a new one at start
  105766. data.push(0.0);
  105767. // Seed
  105768. data.push(Math.random());
  105769. data.push(Math.random());
  105770. data.push(Math.random());
  105771. data.push(Math.random());
  105772. // Size
  105773. data.push(0.0);
  105774. data.push(0.0);
  105775. data.push(0.0);
  105776. if (!this._colorGradientsTexture) {
  105777. // color
  105778. data.push(0.0);
  105779. data.push(0.0);
  105780. data.push(0.0);
  105781. data.push(0.0);
  105782. }
  105783. // direction
  105784. data.push(0.0);
  105785. data.push(0.0);
  105786. data.push(0.0);
  105787. if (!this.isBillboardBased) {
  105788. // initialDirection
  105789. data.push(0.0);
  105790. data.push(0.0);
  105791. data.push(0.0);
  105792. }
  105793. // angle
  105794. data.push(0.0);
  105795. if (!this._angularSpeedGradientsTexture) {
  105796. data.push(0.0);
  105797. }
  105798. if (this._isAnimationSheetEnabled) {
  105799. data.push(0.0);
  105800. if (this.spriteRandomStartCell) {
  105801. data.push(0.0);
  105802. }
  105803. }
  105804. if (this.noiseTexture) { // Random coordinates for reading into noise texture
  105805. data.push(Math.random());
  105806. data.push(Math.random());
  105807. data.push(Math.random());
  105808. data.push(Math.random());
  105809. data.push(Math.random());
  105810. data.push(Math.random());
  105811. }
  105812. }
  105813. // Sprite data
  105814. var spriteData = new Float32Array([0.5, 0.5, 1, 1,
  105815. -0.5, 0.5, 0, 1,
  105816. -0.5, -0.5, 0, 0,
  105817. 0.5, -0.5, 1, 0]);
  105818. // Buffers
  105819. this._buffer0 = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, data, false, this._attributesStrideSize);
  105820. this._buffer1 = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, data, false, this._attributesStrideSize);
  105821. this._spriteBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, spriteData, false, 4);
  105822. // Update VAO
  105823. this._updateVAO = [];
  105824. this._updateVAO.push(this._createUpdateVAO(this._buffer0));
  105825. this._updateVAO.push(this._createUpdateVAO(this._buffer1));
  105826. // Render VAO
  105827. this._renderVAO = [];
  105828. this._renderVAO.push(this._createRenderVAO(this._buffer1, this._spriteBuffer));
  105829. this._renderVAO.push(this._createRenderVAO(this._buffer0, this._spriteBuffer));
  105830. // Links
  105831. this._sourceBuffer = this._buffer0;
  105832. this._targetBuffer = this._buffer1;
  105833. };
  105834. /** @hidden */
  105835. GPUParticleSystem.prototype._recreateUpdateEffect = function () {
  105836. var defines = this.particleEmitterType ? this.particleEmitterType.getEffectDefines() : "";
  105837. if (this._isBillboardBased) {
  105838. defines += "\n#define BILLBOARD";
  105839. }
  105840. if (this._colorGradientsTexture) {
  105841. defines += "\n#define COLORGRADIENTS";
  105842. }
  105843. if (this._sizeGradientsTexture) {
  105844. defines += "\n#define SIZEGRADIENTS";
  105845. }
  105846. if (this._angularSpeedGradientsTexture) {
  105847. defines += "\n#define ANGULARSPEEDGRADIENTS";
  105848. }
  105849. if (this._velocityGradientsTexture) {
  105850. defines += "\n#define VELOCITYGRADIENTS";
  105851. }
  105852. if (this._limitVelocityGradientsTexture) {
  105853. defines += "\n#define LIMITVELOCITYGRADIENTS";
  105854. }
  105855. if (this._dragGradientsTexture) {
  105856. defines += "\n#define DRAGGRADIENTS";
  105857. }
  105858. if (this.isAnimationSheetEnabled) {
  105859. defines += "\n#define ANIMATESHEET";
  105860. if (this.spriteRandomStartCell) {
  105861. defines += "\n#define ANIMATESHEETRANDOMSTART";
  105862. }
  105863. }
  105864. if (this.noiseTexture) {
  105865. defines += "\n#define NOISE";
  105866. }
  105867. if (this._updateEffect && this._updateEffectOptions.defines === defines) {
  105868. return;
  105869. }
  105870. this._updateEffectOptions.transformFeedbackVaryings = ["outPosition", "outAge", "outLife", "outSeed", "outSize"];
  105871. if (!this._colorGradientsTexture) {
  105872. this._updateEffectOptions.transformFeedbackVaryings.push("outColor");
  105873. }
  105874. this._updateEffectOptions.transformFeedbackVaryings.push("outDirection");
  105875. if (!this._isBillboardBased) {
  105876. this._updateEffectOptions.transformFeedbackVaryings.push("outInitialDirection");
  105877. }
  105878. this._updateEffectOptions.transformFeedbackVaryings.push("outAngle");
  105879. if (this.isAnimationSheetEnabled) {
  105880. this._updateEffectOptions.transformFeedbackVaryings.push("outCellIndex");
  105881. if (this.spriteRandomStartCell) {
  105882. this._updateEffectOptions.transformFeedbackVaryings.push("outCellStartOffset");
  105883. }
  105884. }
  105885. if (this.noiseTexture) {
  105886. this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates1");
  105887. this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates2");
  105888. }
  105889. this._updateEffectOptions.defines = defines;
  105890. this._updateEffect = new _Materials_effect__WEBPACK_IMPORTED_MODULE_9__["Effect"]("gpuUpdateParticles", this._updateEffectOptions, this._scene.getEngine());
  105891. };
  105892. /** @hidden */
  105893. GPUParticleSystem.prototype._recreateRenderEffect = function () {
  105894. var defines = "";
  105895. if (this._scene.clipPlane) {
  105896. defines = "\n#define CLIPPLANE";
  105897. }
  105898. if (this._scene.clipPlane2) {
  105899. defines = "\n#define CLIPPLANE2";
  105900. }
  105901. if (this._scene.clipPlane3) {
  105902. defines = "\n#define CLIPPLANE3";
  105903. }
  105904. if (this._scene.clipPlane4) {
  105905. defines = "\n#define CLIPPLANE4";
  105906. }
  105907. if (this.blendMode === _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_MULTIPLY) {
  105908. defines = "\n#define BLENDMULTIPLYMODE";
  105909. }
  105910. if (this._isBillboardBased) {
  105911. defines += "\n#define BILLBOARD";
  105912. switch (this.billboardMode) {
  105913. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_Y:
  105914. defines += "\n#define BILLBOARDY";
  105915. break;
  105916. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_STRETCHED:
  105917. defines += "\n#define BILLBOARDSTRETCHED";
  105918. break;
  105919. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_ALL:
  105920. default:
  105921. break;
  105922. }
  105923. }
  105924. if (this._colorGradientsTexture) {
  105925. defines += "\n#define COLORGRADIENTS";
  105926. }
  105927. if (this.isAnimationSheetEnabled) {
  105928. defines += "\n#define ANIMATESHEET";
  105929. }
  105930. if (this._imageProcessingConfiguration) {
  105931. this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines);
  105932. defines += "\n" + this._imageProcessingConfigurationDefines.toString();
  105933. }
  105934. if (this._renderEffect && this._renderEffect.defines === defines) {
  105935. return;
  105936. }
  105937. var uniforms = ["worldOffset", "view", "projection", "colorDead", "invView", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "sheetInfos", "translationPivot", "eyePosition"];
  105938. var samplers = ["textureSampler", "colorGradientSampler"];
  105939. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"]) {
  105940. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, this._imageProcessingConfigurationDefines);
  105941. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._imageProcessingConfigurationDefines);
  105942. }
  105943. 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);
  105944. };
  105945. /**
  105946. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  105947. * @param preWarm defines if we are in the pre-warmimg phase
  105948. */
  105949. GPUParticleSystem.prototype.animate = function (preWarm) {
  105950. if (preWarm === void 0) { preWarm = false; }
  105951. this._timeDelta = this.updateSpeed * (preWarm ? this.preWarmStepOffset : this._scene.getAnimationRatio());
  105952. this._actualFrame += this._timeDelta;
  105953. if (!this._stopped) {
  105954. if (this.targetStopDuration && this._actualFrame >= this.targetStopDuration) {
  105955. this.stop();
  105956. }
  105957. }
  105958. };
  105959. GPUParticleSystem.prototype._createFactorGradientTexture = function (factorGradients, textureName) {
  105960. var texture = this[textureName];
  105961. if (!factorGradients || !factorGradients.length || texture) {
  105962. return;
  105963. }
  105964. var data = new Float32Array(this._rawTextureWidth);
  105965. for (var x = 0; x < this._rawTextureWidth; x++) {
  105966. var ratio = x / this._rawTextureWidth;
  105967. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, factorGradients, function (currentGradient, nextGradient, scale) {
  105968. data[x] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  105969. });
  105970. }
  105971. 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);
  105972. };
  105973. GPUParticleSystem.prototype._createSizeGradientTexture = function () {
  105974. this._createFactorGradientTexture(this._sizeGradients, "_sizeGradientsTexture");
  105975. };
  105976. GPUParticleSystem.prototype._createAngularSpeedGradientTexture = function () {
  105977. this._createFactorGradientTexture(this._angularSpeedGradients, "_angularSpeedGradientsTexture");
  105978. };
  105979. GPUParticleSystem.prototype._createVelocityGradientTexture = function () {
  105980. this._createFactorGradientTexture(this._velocityGradients, "_velocityGradientsTexture");
  105981. };
  105982. GPUParticleSystem.prototype._createLimitVelocityGradientTexture = function () {
  105983. this._createFactorGradientTexture(this._limitVelocityGradients, "_limitVelocityGradientsTexture");
  105984. };
  105985. GPUParticleSystem.prototype._createDragGradientTexture = function () {
  105986. this._createFactorGradientTexture(this._dragGradients, "_dragGradientsTexture");
  105987. };
  105988. GPUParticleSystem.prototype._createColorGradientTexture = function () {
  105989. if (!this._colorGradients || !this._colorGradients.length || this._colorGradientsTexture) {
  105990. return;
  105991. }
  105992. var data = new Uint8Array(this._rawTextureWidth * 4);
  105993. var tmpColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Color4[0];
  105994. for (var x = 0; x < this._rawTextureWidth; x++) {
  105995. var ratio = x / this._rawTextureWidth;
  105996. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._colorGradients, function (currentGradient, nextGradient, scale) {
  105997. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(currentGradient.color1, nextGradient.color1, scale, tmpColor);
  105998. data[x * 4] = tmpColor.r * 255;
  105999. data[x * 4 + 1] = tmpColor.g * 255;
  106000. data[x * 4 + 2] = tmpColor.b * 255;
  106001. data[x * 4 + 3] = tmpColor.a * 255;
  106002. });
  106003. }
  106004. 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);
  106005. };
  106006. /**
  106007. * Renders the particle system in its current state
  106008. * @param preWarm defines if the system should only update the particles but not render them
  106009. * @returns the current number of particles
  106010. */
  106011. GPUParticleSystem.prototype.render = function (preWarm) {
  106012. if (preWarm === void 0) { preWarm = false; }
  106013. if (!this._started) {
  106014. return 0;
  106015. }
  106016. this._createColorGradientTexture();
  106017. this._createSizeGradientTexture();
  106018. this._createAngularSpeedGradientTexture();
  106019. this._createVelocityGradientTexture();
  106020. this._createLimitVelocityGradientTexture();
  106021. this._createDragGradientTexture();
  106022. this._recreateUpdateEffect();
  106023. this._recreateRenderEffect();
  106024. if (!this.isReady()) {
  106025. return 0;
  106026. }
  106027. if (!preWarm) {
  106028. if (!this._preWarmDone && this.preWarmCycles) {
  106029. for (var index = 0; index < this.preWarmCycles; index++) {
  106030. this.animate(true);
  106031. this.render(true);
  106032. }
  106033. this._preWarmDone = true;
  106034. }
  106035. if (this._currentRenderId === this._scene.getFrameId()) {
  106036. return 0;
  106037. }
  106038. this._currentRenderId = this._scene.getFrameId();
  106039. }
  106040. // Get everything ready to render
  106041. this._initialize();
  106042. this._accumulatedCount += this.emitRate * this._timeDelta;
  106043. if (this._accumulatedCount > 1) {
  106044. var intPart = this._accumulatedCount | 0;
  106045. this._accumulatedCount -= intPart;
  106046. this._currentActiveCount = Math.min(this._activeCount, this._currentActiveCount + intPart);
  106047. }
  106048. if (!this._currentActiveCount) {
  106049. return 0;
  106050. }
  106051. // Enable update effect
  106052. this._engine.enableEffect(this._updateEffect);
  106053. this._engine.setState(false);
  106054. this._updateEffect.setFloat("currentCount", this._currentActiveCount);
  106055. this._updateEffect.setFloat("timeDelta", this._timeDelta);
  106056. this._updateEffect.setFloat("stopFactor", this._stopped ? 0 : 1);
  106057. this._updateEffect.setTexture("randomSampler", this._randomTexture);
  106058. this._updateEffect.setTexture("randomSampler2", this._randomTexture2);
  106059. this._updateEffect.setFloat2("lifeTime", this.minLifeTime, this.maxLifeTime);
  106060. this._updateEffect.setFloat2("emitPower", this.minEmitPower, this.maxEmitPower);
  106061. if (!this._colorGradientsTexture) {
  106062. this._updateEffect.setDirectColor4("color1", this.color1);
  106063. this._updateEffect.setDirectColor4("color2", this.color2);
  106064. }
  106065. this._updateEffect.setFloat2("sizeRange", this.minSize, this.maxSize);
  106066. this._updateEffect.setFloat4("scaleRange", this.minScaleX, this.maxScaleX, this.minScaleY, this.maxScaleY);
  106067. this._updateEffect.setFloat4("angleRange", this.minAngularSpeed, this.maxAngularSpeed, this.minInitialRotation, this.maxInitialRotation);
  106068. this._updateEffect.setVector3("gravity", this.gravity);
  106069. if (this._sizeGradientsTexture) {
  106070. this._updateEffect.setTexture("sizeGradientSampler", this._sizeGradientsTexture);
  106071. }
  106072. if (this._angularSpeedGradientsTexture) {
  106073. this._updateEffect.setTexture("angularSpeedGradientSampler", this._angularSpeedGradientsTexture);
  106074. }
  106075. if (this._velocityGradientsTexture) {
  106076. this._updateEffect.setTexture("velocityGradientSampler", this._velocityGradientsTexture);
  106077. }
  106078. if (this._limitVelocityGradientsTexture) {
  106079. this._updateEffect.setTexture("limitVelocityGradientSampler", this._limitVelocityGradientsTexture);
  106080. this._updateEffect.setFloat("limitVelocityDamping", this.limitVelocityDamping);
  106081. }
  106082. if (this._dragGradientsTexture) {
  106083. this._updateEffect.setTexture("dragGradientSampler", this._dragGradientsTexture);
  106084. }
  106085. if (this.particleEmitterType) {
  106086. this.particleEmitterType.applyToShader(this._updateEffect);
  106087. }
  106088. if (this._isAnimationSheetEnabled) {
  106089. this._updateEffect.setFloat3("cellInfos", this.startSpriteCellID, this.endSpriteCellID, this.spriteCellChangeSpeed);
  106090. }
  106091. if (this.noiseTexture) {
  106092. this._updateEffect.setTexture("noiseSampler", this.noiseTexture);
  106093. this._updateEffect.setVector3("noiseStrength", this.noiseStrength);
  106094. }
  106095. var emitterWM;
  106096. if (this.emitter.position) {
  106097. var emitterMesh = this.emitter;
  106098. emitterWM = emitterMesh.getWorldMatrix();
  106099. }
  106100. else {
  106101. var emitterPosition = this.emitter;
  106102. emitterWM = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(emitterPosition.x, emitterPosition.y, emitterPosition.z);
  106103. }
  106104. this._updateEffect.setMatrix("emitterWM", emitterWM);
  106105. // Bind source VAO
  106106. this._engine.bindVertexArrayObject(this._updateVAO[this._targetIndex], null);
  106107. // Update
  106108. this._engine.bindTransformFeedbackBuffer(this._targetBuffer.getBuffer());
  106109. this._engine.setRasterizerState(false);
  106110. this._engine.beginTransformFeedback(true);
  106111. this._engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_10__["Material"].PointListDrawMode, 0, this._currentActiveCount);
  106112. this._engine.endTransformFeedback();
  106113. this._engine.setRasterizerState(true);
  106114. this._engine.bindTransformFeedbackBuffer(null);
  106115. if (!preWarm) {
  106116. // Enable render effect
  106117. this._engine.enableEffect(this._renderEffect);
  106118. var viewMatrix = this._scene.getViewMatrix();
  106119. this._renderEffect.setMatrix("view", viewMatrix);
  106120. this._renderEffect.setMatrix("projection", this._scene.getProjectionMatrix());
  106121. this._renderEffect.setTexture("textureSampler", this.particleTexture);
  106122. this._renderEffect.setVector2("translationPivot", this.translationPivot);
  106123. this._renderEffect.setVector3("worldOffset", this.worldOffset);
  106124. if (this._colorGradientsTexture) {
  106125. this._renderEffect.setTexture("colorGradientSampler", this._colorGradientsTexture);
  106126. }
  106127. else {
  106128. this._renderEffect.setDirectColor4("colorDead", this.colorDead);
  106129. }
  106130. if (this._isAnimationSheetEnabled && this.particleTexture) {
  106131. var baseSize = this.particleTexture.getBaseSize();
  106132. this._renderEffect.setFloat3("sheetInfos", this.spriteCellWidth / baseSize.width, this.spriteCellHeight / baseSize.height, baseSize.width / this.spriteCellWidth);
  106133. }
  106134. if (this._isBillboardBased) {
  106135. var camera = this._scene.activeCamera;
  106136. this._renderEffect.setVector3("eyePosition", camera.globalPosition);
  106137. }
  106138. if (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4) {
  106139. var invView = viewMatrix.clone();
  106140. invView.invert();
  106141. this._renderEffect.setMatrix("invView", invView);
  106142. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].BindClipPlane(this._renderEffect, this._scene);
  106143. }
  106144. // image processing
  106145. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  106146. this._imageProcessingConfiguration.bind(this._renderEffect);
  106147. }
  106148. // Draw order
  106149. switch (this.blendMode) {
  106150. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_ADD:
  106151. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_ADD);
  106152. break;
  106153. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_ONEONE:
  106154. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_ONEONE);
  106155. break;
  106156. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_STANDARD:
  106157. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_COMBINE);
  106158. break;
  106159. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_MULTIPLY:
  106160. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_MULTIPLY);
  106161. break;
  106162. }
  106163. if (this.forceDepthWrite) {
  106164. this._engine.setDepthWrite(true);
  106165. }
  106166. // Bind source VAO
  106167. this._engine.bindVertexArrayObject(this._renderVAO[this._targetIndex], null);
  106168. // Render
  106169. this._engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_10__["Material"].TriangleFanDrawMode, 0, 4, this._currentActiveCount);
  106170. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_DISABLE);
  106171. }
  106172. // Switch VAOs
  106173. this._targetIndex++;
  106174. if (this._targetIndex === 2) {
  106175. this._targetIndex = 0;
  106176. }
  106177. // Switch buffers
  106178. var tmpBuffer = this._sourceBuffer;
  106179. this._sourceBuffer = this._targetBuffer;
  106180. this._targetBuffer = tmpBuffer;
  106181. return this._currentActiveCount;
  106182. };
  106183. /**
  106184. * Rebuilds the particle system
  106185. */
  106186. GPUParticleSystem.prototype.rebuild = function () {
  106187. this._initialize(true);
  106188. };
  106189. GPUParticleSystem.prototype._releaseBuffers = function () {
  106190. if (this._buffer0) {
  106191. this._buffer0.dispose();
  106192. this._buffer0 = null;
  106193. }
  106194. if (this._buffer1) {
  106195. this._buffer1.dispose();
  106196. this._buffer1 = null;
  106197. }
  106198. if (this._spriteBuffer) {
  106199. this._spriteBuffer.dispose();
  106200. this._spriteBuffer = null;
  106201. }
  106202. };
  106203. GPUParticleSystem.prototype._releaseVAOs = function () {
  106204. if (!this._updateVAO) {
  106205. return;
  106206. }
  106207. for (var index = 0; index < this._updateVAO.length; index++) {
  106208. this._engine.releaseVertexArrayObject(this._updateVAO[index]);
  106209. }
  106210. this._updateVAO = [];
  106211. for (var index = 0; index < this._renderVAO.length; index++) {
  106212. this._engine.releaseVertexArrayObject(this._renderVAO[index]);
  106213. }
  106214. this._renderVAO = [];
  106215. };
  106216. /**
  106217. * Disposes the particle system and free the associated resources
  106218. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  106219. */
  106220. GPUParticleSystem.prototype.dispose = function (disposeTexture) {
  106221. if (disposeTexture === void 0) { disposeTexture = true; }
  106222. var index = this._scene.particleSystems.indexOf(this);
  106223. if (index > -1) {
  106224. this._scene.particleSystems.splice(index, 1);
  106225. }
  106226. this._releaseBuffers();
  106227. this._releaseVAOs();
  106228. if (this._colorGradientsTexture) {
  106229. this._colorGradientsTexture.dispose();
  106230. this._colorGradientsTexture = null;
  106231. }
  106232. if (this._sizeGradientsTexture) {
  106233. this._sizeGradientsTexture.dispose();
  106234. this._sizeGradientsTexture = null;
  106235. }
  106236. if (this._angularSpeedGradientsTexture) {
  106237. this._angularSpeedGradientsTexture.dispose();
  106238. this._angularSpeedGradientsTexture = null;
  106239. }
  106240. if (this._velocityGradientsTexture) {
  106241. this._velocityGradientsTexture.dispose();
  106242. this._velocityGradientsTexture = null;
  106243. }
  106244. if (this._limitVelocityGradientsTexture) {
  106245. this._limitVelocityGradientsTexture.dispose();
  106246. this._limitVelocityGradientsTexture = null;
  106247. }
  106248. if (this._dragGradientsTexture) {
  106249. this._dragGradientsTexture.dispose();
  106250. this._dragGradientsTexture = null;
  106251. }
  106252. if (this._randomTexture) {
  106253. this._randomTexture.dispose();
  106254. this._randomTexture = null;
  106255. }
  106256. if (this._randomTexture2) {
  106257. this._randomTexture2.dispose();
  106258. this._randomTexture2 = null;
  106259. }
  106260. if (disposeTexture && this.particleTexture) {
  106261. this.particleTexture.dispose();
  106262. this.particleTexture = null;
  106263. }
  106264. if (disposeTexture && this.noiseTexture) {
  106265. this.noiseTexture.dispose();
  106266. this.noiseTexture = null;
  106267. }
  106268. // Callback
  106269. this.onDisposeObservable.notifyObservers(this);
  106270. this.onDisposeObservable.clear();
  106271. };
  106272. /**
  106273. * Clones the particle system.
  106274. * @param name The name of the cloned object
  106275. * @param newEmitter The new emitter to use
  106276. * @returns the cloned particle system
  106277. */
  106278. GPUParticleSystem.prototype.clone = function (name, newEmitter) {
  106279. var result = new GPUParticleSystem(name, { capacity: this._capacity, randomTextureSize: this._randomTextureSize }, this._scene);
  106280. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_17__["DeepCopier"].DeepCopy(this, result);
  106281. if (newEmitter === undefined) {
  106282. newEmitter = this.emitter;
  106283. }
  106284. result.emitter = newEmitter;
  106285. if (this.particleTexture) {
  106286. result.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"](this.particleTexture.url, this._scene);
  106287. }
  106288. return result;
  106289. };
  106290. /**
  106291. * Serializes the particle system to a JSON object.
  106292. * @returns the JSON object
  106293. */
  106294. GPUParticleSystem.prototype.serialize = function () {
  106295. var serializationObject = {};
  106296. _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"]._Serialize(serializationObject, this);
  106297. serializationObject.activeParticleCount = this.activeParticleCount;
  106298. return serializationObject;
  106299. };
  106300. /**
  106301. * Parses a JSON object to create a GPU particle system.
  106302. * @param parsedParticleSystem The JSON object to parse
  106303. * @param scene The scene to create the particle system in
  106304. * @param rootUrl The root url to use to load external dependencies like texture
  106305. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  106306. * @returns the parsed GPU particle system
  106307. */
  106308. GPUParticleSystem.Parse = function (parsedParticleSystem, scene, rootUrl, doNotStart) {
  106309. if (doNotStart === void 0) { doNotStart = false; }
  106310. var name = parsedParticleSystem.name;
  106311. var particleSystem = new GPUParticleSystem(name, { capacity: parsedParticleSystem.capacity, randomTextureSize: parsedParticleSystem.randomTextureSize }, scene);
  106312. if (parsedParticleSystem.activeParticleCount) {
  106313. particleSystem.activeParticleCount = parsedParticleSystem.activeParticleCount;
  106314. }
  106315. _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"]._Parse(parsedParticleSystem, particleSystem, scene, rootUrl);
  106316. // Auto start
  106317. if (parsedParticleSystem.preventAutoStart) {
  106318. particleSystem.preventAutoStart = parsedParticleSystem.preventAutoStart;
  106319. }
  106320. if (!doNotStart && !particleSystem.preventAutoStart) {
  106321. particleSystem.start();
  106322. }
  106323. return particleSystem;
  106324. };
  106325. return GPUParticleSystem;
  106326. }(_baseParticleSystem__WEBPACK_IMPORTED_MODULE_6__["BaseParticleSystem"]));
  106327. /***/ }),
  106328. /***/ "./Particles/index.ts":
  106329. /*!****************************!*\
  106330. !*** ./Particles/index.ts ***!
  106331. \****************************/
  106332. /*! exports provided: BaseParticleSystem, GPUParticleSystem, Particle, ParticleHelper, ParticleSystem, _IDoNeedToBeInTheBuild, ParticleSystemSet, SolidParticle, ModelShape, DepthSortedParticle, SolidParticleSystem, SubEmitterType, SubEmitter, BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter */
  106333. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106334. "use strict";
  106335. __webpack_require__.r(__webpack_exports__);
  106336. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  106337. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _baseParticleSystem__WEBPACK_IMPORTED_MODULE_0__["BaseParticleSystem"]; });
  106338. /* harmony import */ var _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  106339. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["BoxParticleEmitter"]; });
  106340. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["ConeParticleEmitter"]; });
  106341. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["CylinderParticleEmitter"]; });
  106342. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["CylinderDirectedParticleEmitter"]; });
  106343. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["HemisphericParticleEmitter"]; });
  106344. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["PointParticleEmitter"]; });
  106345. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["SphereParticleEmitter"]; });
  106346. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["SphereDirectedParticleEmitter"]; });
  106347. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  106348. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__["GPUParticleSystem"]; });
  106349. /* harmony import */ var _particle__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./particle */ "./Particles/particle.ts");
  106350. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _particle__WEBPACK_IMPORTED_MODULE_3__["Particle"]; });
  106351. /* harmony import */ var _particleHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./particleHelper */ "./Particles/particleHelper.ts");
  106352. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _particleHelper__WEBPACK_IMPORTED_MODULE_4__["ParticleHelper"]; });
  106353. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  106354. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _particleSystem__WEBPACK_IMPORTED_MODULE_5__["ParticleSystem"]; });
  106355. /* harmony import */ var _particleSystemComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./particleSystemComponent */ "./Particles/particleSystemComponent.ts");
  106356. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _particleSystemComponent__WEBPACK_IMPORTED_MODULE_6__["_IDoNeedToBeInTheBuild"]; });
  106357. /* harmony import */ var _particleSystemSet__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./particleSystemSet */ "./Particles/particleSystemSet.ts");
  106358. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _particleSystemSet__WEBPACK_IMPORTED_MODULE_7__["ParticleSystemSet"]; });
  106359. /* harmony import */ var _solidParticle__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./solidParticle */ "./Particles/solidParticle.ts");
  106360. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["SolidParticle"]; });
  106361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["ModelShape"]; });
  106362. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["DepthSortedParticle"]; });
  106363. /* harmony import */ var _solidParticleSystem__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./solidParticleSystem */ "./Particles/solidParticleSystem.ts");
  106364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _solidParticleSystem__WEBPACK_IMPORTED_MODULE_9__["SolidParticleSystem"]; });
  106365. /* harmony import */ var _subEmitter__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./subEmitter */ "./Particles/subEmitter.ts");
  106366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _subEmitter__WEBPACK_IMPORTED_MODULE_10__["SubEmitterType"]; });
  106367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _subEmitter__WEBPACK_IMPORTED_MODULE_10__["SubEmitter"]; });
  106368. /***/ }),
  106369. /***/ "./Particles/particle.ts":
  106370. /*!*******************************!*\
  106371. !*** ./Particles/particle.ts ***!
  106372. \*******************************/
  106373. /*! exports provided: Particle */
  106374. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106375. "use strict";
  106376. __webpack_require__.r(__webpack_exports__);
  106377. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return Particle; });
  106378. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  106379. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  106380. /**
  106381. * A particle represents one of the element emitted by a particle system.
  106382. * This is mainly define by its coordinates, direction, velocity and age.
  106383. */
  106384. var Particle = /** @class */ (function () {
  106385. /**
  106386. * Creates a new instance Particle
  106387. * @param particleSystem the particle system the particle belongs to
  106388. */
  106389. function Particle(
  106390. /**
  106391. * The particle system the particle belongs to.
  106392. */
  106393. particleSystem) {
  106394. this.particleSystem = particleSystem;
  106395. /**
  106396. * The world position of the particle in the scene.
  106397. */
  106398. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  106399. /**
  106400. * The world direction of the particle in the scene.
  106401. */
  106402. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  106403. /**
  106404. * The color of the particle.
  106405. */
  106406. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  106407. /**
  106408. * The color change of the particle per step.
  106409. */
  106410. this.colorStep = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  106411. /**
  106412. * Defines how long will the life of the particle be.
  106413. */
  106414. this.lifeTime = 1.0;
  106415. /**
  106416. * The current age of the particle.
  106417. */
  106418. this.age = 0;
  106419. /**
  106420. * The current size of the particle.
  106421. */
  106422. this.size = 0;
  106423. /**
  106424. * The current scale of the particle.
  106425. */
  106426. this.scale = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](1, 1);
  106427. /**
  106428. * The current angle of the particle.
  106429. */
  106430. this.angle = 0;
  106431. /**
  106432. * Defines how fast is the angle changing.
  106433. */
  106434. this.angularSpeed = 0;
  106435. /**
  106436. * Defines the cell index used by the particle to be rendered from a sprite.
  106437. */
  106438. this.cellIndex = 0;
  106439. /** @hidden */
  106440. this._attachedSubEmitters = null;
  106441. /** @hidden */
  106442. this._currentColor1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  106443. /** @hidden */
  106444. this._currentColor2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  106445. /** @hidden */
  106446. this._currentSize1 = 0;
  106447. /** @hidden */
  106448. this._currentSize2 = 0;
  106449. /** @hidden */
  106450. this._currentAngularSpeed1 = 0;
  106451. /** @hidden */
  106452. this._currentAngularSpeed2 = 0;
  106453. /** @hidden */
  106454. this._currentVelocity1 = 0;
  106455. /** @hidden */
  106456. this._currentVelocity2 = 0;
  106457. /** @hidden */
  106458. this._currentLimitVelocity1 = 0;
  106459. /** @hidden */
  106460. this._currentLimitVelocity2 = 0;
  106461. /** @hidden */
  106462. this._currentDrag1 = 0;
  106463. /** @hidden */
  106464. this._currentDrag2 = 0;
  106465. this.id = Particle._Count++;
  106466. if (!this.particleSystem.isAnimationSheetEnabled) {
  106467. return;
  106468. }
  106469. this.updateCellInfoFromSystem();
  106470. }
  106471. Particle.prototype.updateCellInfoFromSystem = function () {
  106472. this.cellIndex = this.particleSystem.startSpriteCellID;
  106473. };
  106474. /**
  106475. * Defines how the sprite cell index is updated for the particle
  106476. */
  106477. Particle.prototype.updateCellIndex = function () {
  106478. var offsetAge = this.age;
  106479. var changeSpeed = this.particleSystem.spriteCellChangeSpeed;
  106480. if (this.particleSystem.spriteRandomStartCell) {
  106481. if (this._randomCellOffset === undefined) {
  106482. this._randomCellOffset = Math.random() * this.lifeTime;
  106483. }
  106484. if (changeSpeed === 0) { // Special case when speed = 0 meaning we want to stay on initial cell
  106485. changeSpeed = 1;
  106486. offsetAge = this._randomCellOffset;
  106487. }
  106488. else {
  106489. offsetAge += this._randomCellOffset;
  106490. }
  106491. }
  106492. var dist = (this._initialEndSpriteCellID - this._initialStartSpriteCellID);
  106493. var ratio = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(((offsetAge * changeSpeed) % this.lifeTime) / this.lifeTime);
  106494. this.cellIndex = this._initialStartSpriteCellID + (ratio * dist) | 0;
  106495. };
  106496. /** @hidden */
  106497. Particle.prototype._inheritParticleInfoToSubEmitter = function (subEmitter) {
  106498. if (subEmitter.particleSystem.emitter.position) {
  106499. var emitterMesh = subEmitter.particleSystem.emitter;
  106500. emitterMesh.position.copyFrom(this.position);
  106501. if (subEmitter.inheritDirection) {
  106502. emitterMesh.position.subtractToRef(this.direction, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  106503. // Look at using Y as forward
  106504. emitterMesh.lookAt(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0], 0, Math.PI / 2);
  106505. }
  106506. }
  106507. else {
  106508. var emitterPosition = subEmitter.particleSystem.emitter;
  106509. emitterPosition.copyFrom(this.position);
  106510. }
  106511. // Set inheritedVelocityOffset to be used when new particles are created
  106512. this.direction.scaleToRef(subEmitter.inheritedVelocityAmount / 2, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  106513. subEmitter.particleSystem._inheritedVelocityOffset.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  106514. };
  106515. /** @hidden */
  106516. Particle.prototype._inheritParticleInfoToSubEmitters = function () {
  106517. var _this = this;
  106518. if (this._attachedSubEmitters && this._attachedSubEmitters.length > 0) {
  106519. this._attachedSubEmitters.forEach(function (subEmitter) {
  106520. _this._inheritParticleInfoToSubEmitter(subEmitter);
  106521. });
  106522. }
  106523. };
  106524. /** @hidden */
  106525. Particle.prototype._reset = function () {
  106526. this.age = 0;
  106527. this._currentColorGradient = null;
  106528. this._currentSizeGradient = null;
  106529. this._currentAngularSpeedGradient = null;
  106530. this._currentVelocityGradient = null;
  106531. this._currentLimitVelocityGradient = null;
  106532. this._currentDragGradient = null;
  106533. this.cellIndex = this.particleSystem.startSpriteCellID;
  106534. this._randomCellOffset = undefined;
  106535. };
  106536. /**
  106537. * Copy the properties of particle to another one.
  106538. * @param other the particle to copy the information to.
  106539. */
  106540. Particle.prototype.copyTo = function (other) {
  106541. other.position.copyFrom(this.position);
  106542. if (this._initialDirection) {
  106543. if (other._initialDirection) {
  106544. other._initialDirection.copyFrom(this._initialDirection);
  106545. }
  106546. else {
  106547. other._initialDirection = this._initialDirection.clone();
  106548. }
  106549. }
  106550. else {
  106551. other._initialDirection = null;
  106552. }
  106553. other.direction.copyFrom(this.direction);
  106554. other.color.copyFrom(this.color);
  106555. other.colorStep.copyFrom(this.colorStep);
  106556. other.lifeTime = this.lifeTime;
  106557. other.age = this.age;
  106558. other._randomCellOffset = this._randomCellOffset;
  106559. other.size = this.size;
  106560. other.scale.copyFrom(this.scale);
  106561. other.angle = this.angle;
  106562. other.angularSpeed = this.angularSpeed;
  106563. other.particleSystem = this.particleSystem;
  106564. other.cellIndex = this.cellIndex;
  106565. other.id = this.id;
  106566. other._attachedSubEmitters = this._attachedSubEmitters;
  106567. if (this._currentColorGradient) {
  106568. other._currentColorGradient = this._currentColorGradient;
  106569. other._currentColor1.copyFrom(this._currentColor1);
  106570. other._currentColor2.copyFrom(this._currentColor2);
  106571. }
  106572. if (this._currentSizeGradient) {
  106573. other._currentSizeGradient = this._currentSizeGradient;
  106574. other._currentSize1 = this._currentSize1;
  106575. other._currentSize2 = this._currentSize2;
  106576. }
  106577. if (this._currentAngularSpeedGradient) {
  106578. other._currentAngularSpeedGradient = this._currentAngularSpeedGradient;
  106579. other._currentAngularSpeed1 = this._currentAngularSpeed1;
  106580. other._currentAngularSpeed2 = this._currentAngularSpeed2;
  106581. }
  106582. if (this._currentVelocityGradient) {
  106583. other._currentVelocityGradient = this._currentVelocityGradient;
  106584. other._currentVelocity1 = this._currentVelocity1;
  106585. other._currentVelocity2 = this._currentVelocity2;
  106586. }
  106587. if (this._currentLimitVelocityGradient) {
  106588. other._currentLimitVelocityGradient = this._currentLimitVelocityGradient;
  106589. other._currentLimitVelocity1 = this._currentLimitVelocity1;
  106590. other._currentLimitVelocity2 = this._currentLimitVelocity2;
  106591. }
  106592. if (this._currentDragGradient) {
  106593. other._currentDragGradient = this._currentDragGradient;
  106594. other._currentDrag1 = this._currentDrag1;
  106595. other._currentDrag2 = this._currentDrag2;
  106596. }
  106597. if (this.particleSystem.isAnimationSheetEnabled) {
  106598. other._initialStartSpriteCellID = this._initialStartSpriteCellID;
  106599. other._initialEndSpriteCellID = this._initialEndSpriteCellID;
  106600. }
  106601. if (this.particleSystem.useRampGradients) {
  106602. other.remapData.copyFrom(this.remapData);
  106603. }
  106604. if (this._randomNoiseCoordinates1) {
  106605. if (other._randomNoiseCoordinates1) {
  106606. other._randomNoiseCoordinates1.copyFrom(this._randomNoiseCoordinates1);
  106607. other._randomNoiseCoordinates2.copyFrom(this._randomNoiseCoordinates2);
  106608. }
  106609. else {
  106610. other._randomNoiseCoordinates1 = this._randomNoiseCoordinates1.clone();
  106611. other._randomNoiseCoordinates2 = this._randomNoiseCoordinates2.clone();
  106612. }
  106613. }
  106614. };
  106615. Particle._Count = 0;
  106616. return Particle;
  106617. }());
  106618. /***/ }),
  106619. /***/ "./Particles/particleHelper.ts":
  106620. /*!*************************************!*\
  106621. !*** ./Particles/particleHelper.ts ***!
  106622. \*************************************/
  106623. /*! exports provided: ParticleHelper */
  106624. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106625. "use strict";
  106626. __webpack_require__.r(__webpack_exports__);
  106627. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return ParticleHelper; });
  106628. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  106629. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  106630. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  106631. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  106632. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  106633. /* harmony import */ var _particleSystemSet__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./particleSystemSet */ "./Particles/particleSystemSet.ts");
  106634. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  106635. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  106636. /**
  106637. * This class is made for on one-liner static method to help creating particle system set.
  106638. */
  106639. var ParticleHelper = /** @class */ (function () {
  106640. function ParticleHelper() {
  106641. }
  106642. /**
  106643. * Create a default particle system that you can tweak
  106644. * @param emitter defines the emitter to use
  106645. * @param capacity defines the system capacity (default is 500 particles)
  106646. * @param scene defines the hosting scene
  106647. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  106648. * @returns the new Particle system
  106649. */
  106650. ParticleHelper.CreateDefault = function (emitter, capacity, scene, useGPU) {
  106651. if (capacity === void 0) { capacity = 500; }
  106652. if (useGPU === void 0) { useGPU = false; }
  106653. var system;
  106654. if (useGPU) {
  106655. system = new _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__["GPUParticleSystem"]("default system", { capacity: capacity }, scene);
  106656. }
  106657. else {
  106658. system = new _particleSystem__WEBPACK_IMPORTED_MODULE_6__["ParticleSystem"]("default system", capacity, scene);
  106659. }
  106660. system.emitter = emitter;
  106661. system.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]("https://www.babylonjs.com/assets/Flare.png", system.getScene());
  106662. system.createConeEmitter(0.1, Math.PI / 4);
  106663. // Particle color
  106664. system.color1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  106665. system.color2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  106666. system.colorDead = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 0.0);
  106667. // Particle Size
  106668. system.minSize = 0.1;
  106669. system.maxSize = 0.1;
  106670. // Emission speed
  106671. system.minEmitPower = 2;
  106672. system.maxEmitPower = 2;
  106673. // Update speed
  106674. system.updateSpeed = 1 / 60;
  106675. system.emitRate = 30;
  106676. return system;
  106677. };
  106678. /**
  106679. * This is the main static method (one-liner) of this helper to create different particle systems
  106680. * @param type This string represents the type to the particle system to create
  106681. * @param scene The scene where the particle system should live
  106682. * @param gpu If the system will use gpu
  106683. * @returns the ParticleSystemSet created
  106684. */
  106685. ParticleHelper.CreateAsync = function (type, scene, gpu) {
  106686. if (gpu === void 0) { gpu = false; }
  106687. if (!scene) {
  106688. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  106689. }
  106690. var token = {};
  106691. scene._addPendingData(token);
  106692. return new Promise(function (resolve, reject) {
  106693. if (gpu && !_gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__["GPUParticleSystem"].IsSupported) {
  106694. scene._removePendingData(token);
  106695. return reject("Particle system with GPU is not supported.");
  106696. }
  106697. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(ParticleHelper.BaseAssetsUrl + "/systems/" + type + ".json", function (data) {
  106698. scene._removePendingData(token);
  106699. var newData = JSON.parse(data.toString());
  106700. return resolve(_particleSystemSet__WEBPACK_IMPORTED_MODULE_5__["ParticleSystemSet"].Parse(newData, scene, gpu));
  106701. }, undefined, undefined, undefined, function () {
  106702. scene._removePendingData(token);
  106703. return reject("An error occured while the creation of your particle system. Check if your type '" + type + "' exists.");
  106704. });
  106705. });
  106706. };
  106707. /**
  106708. * Static function used to export a particle system to a ParticleSystemSet variable.
  106709. * Please note that the emitter shape is not exported
  106710. * @param systems defines the particle systems to export
  106711. * @returns the created particle system set
  106712. */
  106713. ParticleHelper.ExportSet = function (systems) {
  106714. var set = new _particleSystemSet__WEBPACK_IMPORTED_MODULE_5__["ParticleSystemSet"]();
  106715. for (var _i = 0, systems_1 = systems; _i < systems_1.length; _i++) {
  106716. var system = systems_1[_i];
  106717. set.systems.push(system);
  106718. }
  106719. return set;
  106720. };
  106721. /**
  106722. * Gets or sets base Assets URL
  106723. */
  106724. ParticleHelper.BaseAssetsUrl = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].PARTICLES_BaseAssetsUrl;
  106725. return ParticleHelper;
  106726. }());
  106727. /***/ }),
  106728. /***/ "./Particles/particleSystem.ts":
  106729. /*!*************************************!*\
  106730. !*** ./Particles/particleSystem.ts ***!
  106731. \*************************************/
  106732. /*! exports provided: ParticleSystem */
  106733. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106734. "use strict";
  106735. __webpack_require__.r(__webpack_exports__);
  106736. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return ParticleSystem; });
  106737. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  106738. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  106739. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  106740. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  106741. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  106742. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  106743. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  106744. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  106745. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  106746. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  106747. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  106748. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  106749. /* harmony import */ var _Materials_Textures_Procedurals_proceduralTexture__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/Textures/Procedurals/proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  106750. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  106751. /* harmony import */ var _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Particles/EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  106752. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  106753. /* harmony import */ var _particle__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./particle */ "./Particles/particle.ts");
  106754. /* harmony import */ var _subEmitter__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./subEmitter */ "./Particles/subEmitter.ts");
  106755. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  106756. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  106757. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  106758. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  106759. /* harmony import */ var _Shaders_particles_fragment__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Shaders/particles.fragment */ "./Shaders/particles.fragment.ts");
  106760. /* harmony import */ var _Shaders_particles_vertex__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../Shaders/particles.vertex */ "./Shaders/particles.vertex.ts");
  106761. /**
  106762. * This represents a particle system in Babylon.
  106763. * 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.
  106764. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  106765. * @example https://doc.babylonjs.com/babylon101/particles
  106766. */
  106767. var ParticleSystem = /** @class */ (function (_super) {
  106768. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ParticleSystem, _super);
  106769. /**
  106770. * Instantiates a particle system.
  106771. * 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.
  106772. * @param name The name of the particle system
  106773. * @param capacity The max number of particles alive at the same time
  106774. * @param scene The scene the particle system belongs to
  106775. * @param customEffect a custom effect used to change the way particles are rendered by default
  106776. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  106777. * @param epsilon Offset used to render the particles
  106778. */
  106779. function ParticleSystem(name, capacity, scene, customEffect, isAnimationSheetEnabled, epsilon) {
  106780. if (customEffect === void 0) { customEffect = null; }
  106781. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  106782. if (epsilon === void 0) { epsilon = 0.01; }
  106783. var _this = _super.call(this, name) || this;
  106784. /**
  106785. * @hidden
  106786. */
  106787. _this._inheritedVelocityOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  106788. /**
  106789. * An event triggered when the system is disposed
  106790. */
  106791. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  106792. _this._particles = new Array();
  106793. _this._stockParticles = new Array();
  106794. _this._newPartsExcess = 0;
  106795. _this._vertexBuffers = {};
  106796. _this._scaledColorStep = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 0);
  106797. _this._colorDiff = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 0);
  106798. _this._scaledDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  106799. _this._scaledGravity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  106800. _this._currentRenderId = -1;
  106801. _this._useInstancing = false;
  106802. _this._started = false;
  106803. _this._stopped = false;
  106804. _this._actualFrame = 0;
  106805. /** @hidden */
  106806. _this._currentEmitRate1 = 0;
  106807. /** @hidden */
  106808. _this._currentEmitRate2 = 0;
  106809. /** @hidden */
  106810. _this._currentStartSize1 = 0;
  106811. /** @hidden */
  106812. _this._currentStartSize2 = 0;
  106813. _this._rawTextureWidth = 256;
  106814. _this._useRampGradients = false;
  106815. /**
  106816. * @hidden
  106817. * If the particle systems emitter should be disposed when the particle system is disposed
  106818. */
  106819. _this._disposeEmitterOnDispose = false;
  106820. // start of sub system methods
  106821. /**
  106822. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  106823. * Its lifetime will start back at 0.
  106824. */
  106825. _this.recycleParticle = function (particle) {
  106826. // move particle from activeParticle list to stock particles
  106827. var lastParticle = _this._particles.pop();
  106828. if (lastParticle !== particle) {
  106829. lastParticle.copyTo(particle);
  106830. }
  106831. _this._stockParticles.push(lastParticle);
  106832. };
  106833. _this._createParticle = function () {
  106834. var particle;
  106835. if (_this._stockParticles.length !== 0) {
  106836. particle = _this._stockParticles.pop();
  106837. particle._reset();
  106838. }
  106839. else {
  106840. particle = new _particle__WEBPACK_IMPORTED_MODULE_16__["Particle"](_this);
  106841. }
  106842. // Attach emitters
  106843. if (_this._subEmitters && _this._subEmitters.length > 0) {
  106844. var subEmitters = _this._subEmitters[Math.floor(Math.random() * _this._subEmitters.length)];
  106845. particle._attachedSubEmitters = [];
  106846. subEmitters.forEach(function (subEmitter) {
  106847. if (subEmitter.type === _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitterType"].ATTACHED) {
  106848. var newEmitter = subEmitter.clone();
  106849. particle._attachedSubEmitters.push(newEmitter);
  106850. newEmitter.particleSystem.start();
  106851. }
  106852. });
  106853. }
  106854. return particle;
  106855. };
  106856. _this._emitFromParticle = function (particle) {
  106857. if (!_this._subEmitters || _this._subEmitters.length === 0) {
  106858. return;
  106859. }
  106860. var templateIndex = Math.floor(Math.random() * _this._subEmitters.length);
  106861. _this._subEmitters[templateIndex].forEach(function (subEmitter) {
  106862. if (subEmitter.type === _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitterType"].END) {
  106863. var subSystem = subEmitter.clone();
  106864. particle._inheritParticleInfoToSubEmitter(subSystem);
  106865. subSystem.particleSystem._rootParticleSystem = _this;
  106866. _this.activeSubSystems.push(subSystem.particleSystem);
  106867. subSystem.particleSystem.start();
  106868. }
  106869. });
  106870. };
  106871. _this._capacity = capacity;
  106872. _this._epsilon = epsilon;
  106873. _this._isAnimationSheetEnabled = isAnimationSheetEnabled;
  106874. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_13__["EngineStore"].LastCreatedScene;
  106875. // Setup the default processing configuration to the scene.
  106876. _this._attachImageProcessingConfiguration(null);
  106877. _this._customEffect = customEffect;
  106878. _this._scene.particleSystems.push(_this);
  106879. _this._useInstancing = _this._scene.getEngine().getCaps().instancedArrays;
  106880. _this._createIndexBuffer();
  106881. _this._createVertexBuffers();
  106882. // Default emitter type
  106883. _this.particleEmitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  106884. // Update
  106885. _this.updateFunction = function (particles) {
  106886. var noiseTextureSize = null;
  106887. var noiseTextureData = null;
  106888. if (_this.noiseTexture) { // We need to get texture data back to CPU
  106889. noiseTextureSize = _this.noiseTexture.getSize();
  106890. noiseTextureData = (_this.noiseTexture.getContent());
  106891. }
  106892. var _loop_1 = function () {
  106893. particle = particles[index];
  106894. var scaledUpdateSpeed = _this._scaledUpdateSpeed;
  106895. var previousAge = particle.age;
  106896. particle.age += scaledUpdateSpeed;
  106897. // Evaluate step to death
  106898. if (particle.age > particle.lifeTime) {
  106899. var diff = particle.age - previousAge;
  106900. var oldDiff = particle.lifeTime - previousAge;
  106901. scaledUpdateSpeed = (oldDiff * scaledUpdateSpeed) / diff;
  106902. particle.age = particle.lifeTime;
  106903. }
  106904. var ratio = particle.age / particle.lifeTime;
  106905. // Color
  106906. if (_this._colorGradients && _this._colorGradients.length > 0) {
  106907. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._colorGradients, function (currentGradient, nextGradient, scale) {
  106908. if (currentGradient !== particle._currentColorGradient) {
  106909. particle._currentColor1.copyFrom(particle._currentColor2);
  106910. nextGradient.getColorToRef(particle._currentColor2);
  106911. particle._currentColorGradient = currentGradient;
  106912. }
  106913. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(particle._currentColor1, particle._currentColor2, scale, particle.color);
  106914. });
  106915. }
  106916. else {
  106917. particle.colorStep.scaleToRef(scaledUpdateSpeed, _this._scaledColorStep);
  106918. particle.color.addInPlace(_this._scaledColorStep);
  106919. if (particle.color.a < 0) {
  106920. particle.color.a = 0;
  106921. }
  106922. }
  106923. // Angular speed
  106924. if (_this._angularSpeedGradients && _this._angularSpeedGradients.length > 0) {
  106925. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._angularSpeedGradients, function (currentGradient, nextGradient, scale) {
  106926. if (currentGradient !== particle._currentAngularSpeedGradient) {
  106927. particle._currentAngularSpeed1 = particle._currentAngularSpeed2;
  106928. particle._currentAngularSpeed2 = nextGradient.getFactor();
  106929. particle._currentAngularSpeedGradient = currentGradient;
  106930. }
  106931. particle.angularSpeed = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentAngularSpeed1, particle._currentAngularSpeed2, scale);
  106932. });
  106933. }
  106934. particle.angle += particle.angularSpeed * scaledUpdateSpeed;
  106935. // Direction
  106936. var directionScale = scaledUpdateSpeed;
  106937. /// Velocity
  106938. if (_this._velocityGradients && _this._velocityGradients.length > 0) {
  106939. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._velocityGradients, function (currentGradient, nextGradient, scale) {
  106940. if (currentGradient !== particle._currentVelocityGradient) {
  106941. particle._currentVelocity1 = particle._currentVelocity2;
  106942. particle._currentVelocity2 = nextGradient.getFactor();
  106943. particle._currentVelocityGradient = currentGradient;
  106944. }
  106945. directionScale *= _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentVelocity1, particle._currentVelocity2, scale);
  106946. });
  106947. }
  106948. particle.direction.scaleToRef(directionScale, _this._scaledDirection);
  106949. /// Limit velocity
  106950. if (_this._limitVelocityGradients && _this._limitVelocityGradients.length > 0) {
  106951. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._limitVelocityGradients, function (currentGradient, nextGradient, scale) {
  106952. if (currentGradient !== particle._currentLimitVelocityGradient) {
  106953. particle._currentLimitVelocity1 = particle._currentLimitVelocity2;
  106954. particle._currentLimitVelocity2 = nextGradient.getFactor();
  106955. particle._currentLimitVelocityGradient = currentGradient;
  106956. }
  106957. var limitVelocity = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentLimitVelocity1, particle._currentLimitVelocity2, scale);
  106958. var currentVelocity = particle.direction.length();
  106959. if (currentVelocity > limitVelocity) {
  106960. particle.direction.scaleInPlace(_this.limitVelocityDamping);
  106961. }
  106962. });
  106963. }
  106964. /// Drag
  106965. if (_this._dragGradients && _this._dragGradients.length > 0) {
  106966. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._dragGradients, function (currentGradient, nextGradient, scale) {
  106967. if (currentGradient !== particle._currentDragGradient) {
  106968. particle._currentDrag1 = particle._currentDrag2;
  106969. particle._currentDrag2 = nextGradient.getFactor();
  106970. particle._currentDragGradient = currentGradient;
  106971. }
  106972. var drag = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentDrag1, particle._currentDrag2, scale);
  106973. _this._scaledDirection.scaleInPlace(1.0 - drag);
  106974. });
  106975. }
  106976. particle.position.addInPlace(_this._scaledDirection);
  106977. // Noise
  106978. if (noiseTextureData && noiseTextureSize && particle._randomNoiseCoordinates1) {
  106979. var fetchedColorR = _this._fetchR(particle._randomNoiseCoordinates1.x, particle._randomNoiseCoordinates1.y, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  106980. var fetchedColorG = _this._fetchR(particle._randomNoiseCoordinates1.z, particle._randomNoiseCoordinates2.x, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  106981. var fetchedColorB = _this._fetchR(particle._randomNoiseCoordinates2.y, particle._randomNoiseCoordinates2.z, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  106982. var force = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  106983. var scaledForce = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  106984. force.copyFromFloats((2 * fetchedColorR - 1) * _this.noiseStrength.x, (2 * fetchedColorG - 1) * _this.noiseStrength.y, (2 * fetchedColorB - 1) * _this.noiseStrength.z);
  106985. force.scaleToRef(scaledUpdateSpeed, scaledForce);
  106986. particle.direction.addInPlace(scaledForce);
  106987. }
  106988. // Gravity
  106989. _this.gravity.scaleToRef(scaledUpdateSpeed, _this._scaledGravity);
  106990. particle.direction.addInPlace(_this._scaledGravity);
  106991. // Size
  106992. if (_this._sizeGradients && _this._sizeGradients.length > 0) {
  106993. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._sizeGradients, function (currentGradient, nextGradient, scale) {
  106994. if (currentGradient !== particle._currentSizeGradient) {
  106995. particle._currentSize1 = particle._currentSize2;
  106996. particle._currentSize2 = nextGradient.getFactor();
  106997. particle._currentSizeGradient = currentGradient;
  106998. }
  106999. particle.size = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentSize1, particle._currentSize2, scale);
  107000. });
  107001. }
  107002. // Remap data
  107003. if (_this._useRampGradients) {
  107004. if (_this._colorRemapGradients && _this._colorRemapGradients.length > 0) {
  107005. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._colorRemapGradients, function (currentGradient, nextGradient, scale) {
  107006. var min = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  107007. var max = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor2, nextGradient.factor2, scale);
  107008. particle.remapData.x = min;
  107009. particle.remapData.y = max - min;
  107010. });
  107011. }
  107012. if (_this._alphaRemapGradients && _this._alphaRemapGradients.length > 0) {
  107013. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._alphaRemapGradients, function (currentGradient, nextGradient, scale) {
  107014. var min = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  107015. var max = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor2, nextGradient.factor2, scale);
  107016. particle.remapData.z = min;
  107017. particle.remapData.w = max - min;
  107018. });
  107019. }
  107020. }
  107021. if (_this._isAnimationSheetEnabled) {
  107022. particle.updateCellIndex();
  107023. }
  107024. // Update the position of the attached sub-emitters to match their attached particle
  107025. particle._inheritParticleInfoToSubEmitters();
  107026. if (particle.age >= particle.lifeTime) { // Recycle by swapping with last particle
  107027. _this._emitFromParticle(particle);
  107028. if (particle._attachedSubEmitters) {
  107029. particle._attachedSubEmitters.forEach(function (subEmitter) {
  107030. subEmitter.particleSystem.disposeOnStop = true;
  107031. subEmitter.particleSystem.stop();
  107032. });
  107033. particle._attachedSubEmitters = null;
  107034. }
  107035. _this.recycleParticle(particle);
  107036. index--;
  107037. return "continue";
  107038. }
  107039. };
  107040. var particle;
  107041. for (var index = 0; index < particles.length; index++) {
  107042. _loop_1();
  107043. }
  107044. };
  107045. return _this;
  107046. }
  107047. Object.defineProperty(ParticleSystem.prototype, "onDispose", {
  107048. /**
  107049. * Sets a callback that will be triggered when the system is disposed
  107050. */
  107051. set: function (callback) {
  107052. if (this._onDisposeObserver) {
  107053. this.onDisposeObservable.remove(this._onDisposeObserver);
  107054. }
  107055. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  107056. },
  107057. enumerable: true,
  107058. configurable: true
  107059. });
  107060. Object.defineProperty(ParticleSystem.prototype, "useRampGradients", {
  107061. /** Gets or sets a boolean indicating that ramp gradients must be used
  107062. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  107063. */
  107064. get: function () {
  107065. return this._useRampGradients;
  107066. },
  107067. set: function (value) {
  107068. if (this._useRampGradients === value) {
  107069. return;
  107070. }
  107071. this._useRampGradients = value;
  107072. this._resetEffect();
  107073. },
  107074. enumerable: true,
  107075. configurable: true
  107076. });
  107077. Object.defineProperty(ParticleSystem.prototype, "particles", {
  107078. //end of Sub-emitter
  107079. /**
  107080. * Gets the current list of active particles
  107081. */
  107082. get: function () {
  107083. return this._particles;
  107084. },
  107085. enumerable: true,
  107086. configurable: true
  107087. });
  107088. /**
  107089. * Returns the string "ParticleSystem"
  107090. * @returns a string containing the class name
  107091. */
  107092. ParticleSystem.prototype.getClassName = function () {
  107093. return "ParticleSystem";
  107094. };
  107095. ParticleSystem.prototype._addFactorGradient = function (factorGradients, gradient, factor, factor2) {
  107096. var newGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["FactorGradient"]();
  107097. newGradient.gradient = gradient;
  107098. newGradient.factor1 = factor;
  107099. newGradient.factor2 = factor2;
  107100. factorGradients.push(newGradient);
  107101. factorGradients.sort(function (a, b) {
  107102. if (a.gradient < b.gradient) {
  107103. return -1;
  107104. }
  107105. else if (a.gradient > b.gradient) {
  107106. return 1;
  107107. }
  107108. return 0;
  107109. });
  107110. };
  107111. ParticleSystem.prototype._removeFactorGradient = function (factorGradients, gradient) {
  107112. if (!factorGradients) {
  107113. return;
  107114. }
  107115. var index = 0;
  107116. for (var _i = 0, factorGradients_1 = factorGradients; _i < factorGradients_1.length; _i++) {
  107117. var factorGradient = factorGradients_1[_i];
  107118. if (factorGradient.gradient === gradient) {
  107119. factorGradients.splice(index, 1);
  107120. break;
  107121. }
  107122. index++;
  107123. }
  107124. };
  107125. /**
  107126. * Adds a new life time gradient
  107127. * @param gradient defines the gradient to use (between 0 and 1)
  107128. * @param factor defines the life time factor to affect to the specified gradient
  107129. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107130. * @returns the current particle system
  107131. */
  107132. ParticleSystem.prototype.addLifeTimeGradient = function (gradient, factor, factor2) {
  107133. if (!this._lifeTimeGradients) {
  107134. this._lifeTimeGradients = [];
  107135. }
  107136. this._addFactorGradient(this._lifeTimeGradients, gradient, factor, factor2);
  107137. return this;
  107138. };
  107139. /**
  107140. * Remove a specific life time gradient
  107141. * @param gradient defines the gradient to remove
  107142. * @returns the current particle system
  107143. */
  107144. ParticleSystem.prototype.removeLifeTimeGradient = function (gradient) {
  107145. this._removeFactorGradient(this._lifeTimeGradients, gradient);
  107146. return this;
  107147. };
  107148. /**
  107149. * Adds a new size gradient
  107150. * @param gradient defines the gradient to use (between 0 and 1)
  107151. * @param factor defines the size factor to affect to the specified gradient
  107152. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107153. * @returns the current particle system
  107154. */
  107155. ParticleSystem.prototype.addSizeGradient = function (gradient, factor, factor2) {
  107156. if (!this._sizeGradients) {
  107157. this._sizeGradients = [];
  107158. }
  107159. this._addFactorGradient(this._sizeGradients, gradient, factor, factor2);
  107160. return this;
  107161. };
  107162. /**
  107163. * Remove a specific size gradient
  107164. * @param gradient defines the gradient to remove
  107165. * @returns the current particle system
  107166. */
  107167. ParticleSystem.prototype.removeSizeGradient = function (gradient) {
  107168. this._removeFactorGradient(this._sizeGradients, gradient);
  107169. return this;
  107170. };
  107171. /**
  107172. * Adds a new color remap gradient
  107173. * @param gradient defines the gradient to use (between 0 and 1)
  107174. * @param min defines the color remap minimal range
  107175. * @param max defines the color remap maximal range
  107176. * @returns the current particle system
  107177. */
  107178. ParticleSystem.prototype.addColorRemapGradient = function (gradient, min, max) {
  107179. if (!this._colorRemapGradients) {
  107180. this._colorRemapGradients = [];
  107181. }
  107182. this._addFactorGradient(this._colorRemapGradients, gradient, min, max);
  107183. return this;
  107184. };
  107185. /**
  107186. * Remove a specific color remap gradient
  107187. * @param gradient defines the gradient to remove
  107188. * @returns the current particle system
  107189. */
  107190. ParticleSystem.prototype.removeColorRemapGradient = function (gradient) {
  107191. this._removeFactorGradient(this._colorRemapGradients, gradient);
  107192. return this;
  107193. };
  107194. /**
  107195. * Adds a new alpha remap gradient
  107196. * @param gradient defines the gradient to use (between 0 and 1)
  107197. * @param min defines the alpha remap minimal range
  107198. * @param max defines the alpha remap maximal range
  107199. * @returns the current particle system
  107200. */
  107201. ParticleSystem.prototype.addAlphaRemapGradient = function (gradient, min, max) {
  107202. if (!this._alphaRemapGradients) {
  107203. this._alphaRemapGradients = [];
  107204. }
  107205. this._addFactorGradient(this._alphaRemapGradients, gradient, min, max);
  107206. return this;
  107207. };
  107208. /**
  107209. * Remove a specific alpha remap gradient
  107210. * @param gradient defines the gradient to remove
  107211. * @returns the current particle system
  107212. */
  107213. ParticleSystem.prototype.removeAlphaRemapGradient = function (gradient) {
  107214. this._removeFactorGradient(this._alphaRemapGradients, gradient);
  107215. return this;
  107216. };
  107217. /**
  107218. * Adds a new angular speed gradient
  107219. * @param gradient defines the gradient to use (between 0 and 1)
  107220. * @param factor defines the angular speed to affect to the specified gradient
  107221. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107222. * @returns the current particle system
  107223. */
  107224. ParticleSystem.prototype.addAngularSpeedGradient = function (gradient, factor, factor2) {
  107225. if (!this._angularSpeedGradients) {
  107226. this._angularSpeedGradients = [];
  107227. }
  107228. this._addFactorGradient(this._angularSpeedGradients, gradient, factor, factor2);
  107229. return this;
  107230. };
  107231. /**
  107232. * Remove a specific angular speed gradient
  107233. * @param gradient defines the gradient to remove
  107234. * @returns the current particle system
  107235. */
  107236. ParticleSystem.prototype.removeAngularSpeedGradient = function (gradient) {
  107237. this._removeFactorGradient(this._angularSpeedGradients, gradient);
  107238. return this;
  107239. };
  107240. /**
  107241. * Adds a new velocity gradient
  107242. * @param gradient defines the gradient to use (between 0 and 1)
  107243. * @param factor defines the velocity to affect to the specified gradient
  107244. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107245. * @returns the current particle system
  107246. */
  107247. ParticleSystem.prototype.addVelocityGradient = function (gradient, factor, factor2) {
  107248. if (!this._velocityGradients) {
  107249. this._velocityGradients = [];
  107250. }
  107251. this._addFactorGradient(this._velocityGradients, gradient, factor, factor2);
  107252. return this;
  107253. };
  107254. /**
  107255. * Remove a specific velocity gradient
  107256. * @param gradient defines the gradient to remove
  107257. * @returns the current particle system
  107258. */
  107259. ParticleSystem.prototype.removeVelocityGradient = function (gradient) {
  107260. this._removeFactorGradient(this._velocityGradients, gradient);
  107261. return this;
  107262. };
  107263. /**
  107264. * Adds a new limit velocity gradient
  107265. * @param gradient defines the gradient to use (between 0 and 1)
  107266. * @param factor defines the limit velocity value to affect to the specified gradient
  107267. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107268. * @returns the current particle system
  107269. */
  107270. ParticleSystem.prototype.addLimitVelocityGradient = function (gradient, factor, factor2) {
  107271. if (!this._limitVelocityGradients) {
  107272. this._limitVelocityGradients = [];
  107273. }
  107274. this._addFactorGradient(this._limitVelocityGradients, gradient, factor, factor2);
  107275. return this;
  107276. };
  107277. /**
  107278. * Remove a specific limit velocity gradient
  107279. * @param gradient defines the gradient to remove
  107280. * @returns the current particle system
  107281. */
  107282. ParticleSystem.prototype.removeLimitVelocityGradient = function (gradient) {
  107283. this._removeFactorGradient(this._limitVelocityGradients, gradient);
  107284. return this;
  107285. };
  107286. /**
  107287. * Adds a new drag gradient
  107288. * @param gradient defines the gradient to use (between 0 and 1)
  107289. * @param factor defines the drag value to affect to the specified gradient
  107290. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107291. * @returns the current particle system
  107292. */
  107293. ParticleSystem.prototype.addDragGradient = function (gradient, factor, factor2) {
  107294. if (!this._dragGradients) {
  107295. this._dragGradients = [];
  107296. }
  107297. this._addFactorGradient(this._dragGradients, gradient, factor, factor2);
  107298. return this;
  107299. };
  107300. /**
  107301. * Remove a specific drag gradient
  107302. * @param gradient defines the gradient to remove
  107303. * @returns the current particle system
  107304. */
  107305. ParticleSystem.prototype.removeDragGradient = function (gradient) {
  107306. this._removeFactorGradient(this._dragGradients, gradient);
  107307. return this;
  107308. };
  107309. /**
  107310. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  107311. * @param gradient defines the gradient to use (between 0 and 1)
  107312. * @param factor defines the emit rate value to affect to the specified gradient
  107313. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107314. * @returns the current particle system
  107315. */
  107316. ParticleSystem.prototype.addEmitRateGradient = function (gradient, factor, factor2) {
  107317. if (!this._emitRateGradients) {
  107318. this._emitRateGradients = [];
  107319. }
  107320. this._addFactorGradient(this._emitRateGradients, gradient, factor, factor2);
  107321. return this;
  107322. };
  107323. /**
  107324. * Remove a specific emit rate gradient
  107325. * @param gradient defines the gradient to remove
  107326. * @returns the current particle system
  107327. */
  107328. ParticleSystem.prototype.removeEmitRateGradient = function (gradient) {
  107329. this._removeFactorGradient(this._emitRateGradients, gradient);
  107330. return this;
  107331. };
  107332. /**
  107333. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  107334. * @param gradient defines the gradient to use (between 0 and 1)
  107335. * @param factor defines the start size value to affect to the specified gradient
  107336. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107337. * @returns the current particle system
  107338. */
  107339. ParticleSystem.prototype.addStartSizeGradient = function (gradient, factor, factor2) {
  107340. if (!this._startSizeGradients) {
  107341. this._startSizeGradients = [];
  107342. }
  107343. this._addFactorGradient(this._startSizeGradients, gradient, factor, factor2);
  107344. return this;
  107345. };
  107346. /**
  107347. * Remove a specific start size gradient
  107348. * @param gradient defines the gradient to remove
  107349. * @returns the current particle system
  107350. */
  107351. ParticleSystem.prototype.removeStartSizeGradient = function (gradient) {
  107352. this._removeFactorGradient(this._emitRateGradients, gradient);
  107353. return this;
  107354. };
  107355. ParticleSystem.prototype._createRampGradientTexture = function () {
  107356. if (!this._rampGradients || !this._rampGradients.length || this._rampGradientsTexture) {
  107357. return;
  107358. }
  107359. var data = new Uint8Array(this._rawTextureWidth * 4);
  107360. var tmpColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Color3[0];
  107361. for (var x = 0; x < this._rawTextureWidth; x++) {
  107362. var ratio = x / this._rawTextureWidth;
  107363. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._rampGradients, function (currentGradient, nextGradient, scale) {
  107364. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].LerpToRef(currentGradient.color, nextGradient.color, scale, tmpColor);
  107365. data[x * 4] = tmpColor.r * 255;
  107366. data[x * 4 + 1] = tmpColor.g * 255;
  107367. data[x * 4 + 2] = tmpColor.b * 255;
  107368. data[x * 4 + 3] = 255;
  107369. });
  107370. }
  107371. 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);
  107372. };
  107373. /**
  107374. * Gets the current list of ramp gradients.
  107375. * You must use addRampGradient and removeRampGradient to udpate this list
  107376. * @returns the list of ramp gradients
  107377. */
  107378. ParticleSystem.prototype.getRampGradients = function () {
  107379. return this._rampGradients;
  107380. };
  107381. /**
  107382. * Adds a new ramp gradient used to remap particle colors
  107383. * @param gradient defines the gradient to use (between 0 and 1)
  107384. * @param color defines the color to affect to the specified gradient
  107385. * @returns the current particle system
  107386. */
  107387. ParticleSystem.prototype.addRampGradient = function (gradient, color) {
  107388. if (!this._rampGradients) {
  107389. this._rampGradients = [];
  107390. }
  107391. var rampGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Color3Gradient"]();
  107392. rampGradient.gradient = gradient;
  107393. rampGradient.color = color;
  107394. this._rampGradients.push(rampGradient);
  107395. this._rampGradients.sort(function (a, b) {
  107396. if (a.gradient < b.gradient) {
  107397. return -1;
  107398. }
  107399. else if (a.gradient > b.gradient) {
  107400. return 1;
  107401. }
  107402. return 0;
  107403. });
  107404. if (this._rampGradientsTexture) {
  107405. this._rampGradientsTexture.dispose();
  107406. this._rampGradientsTexture = null;
  107407. }
  107408. this._createRampGradientTexture();
  107409. return this;
  107410. };
  107411. /**
  107412. * Remove a specific ramp gradient
  107413. * @param gradient defines the gradient to remove
  107414. * @returns the current particle system
  107415. */
  107416. ParticleSystem.prototype.removeRampGradient = function (gradient) {
  107417. this._removeGradientAndTexture(gradient, this._rampGradients, this._rampGradientsTexture);
  107418. this._rampGradientsTexture = null;
  107419. if (this._rampGradients && this._rampGradients.length > 0) {
  107420. this._createRampGradientTexture();
  107421. }
  107422. return this;
  107423. };
  107424. /**
  107425. * Adds a new color gradient
  107426. * @param gradient defines the gradient to use (between 0 and 1)
  107427. * @param color1 defines the color to affect to the specified gradient
  107428. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  107429. * @returns this particle system
  107430. */
  107431. ParticleSystem.prototype.addColorGradient = function (gradient, color1, color2) {
  107432. if (!this._colorGradients) {
  107433. this._colorGradients = [];
  107434. }
  107435. var colorGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["ColorGradient"]();
  107436. colorGradient.gradient = gradient;
  107437. colorGradient.color1 = color1;
  107438. colorGradient.color2 = color2;
  107439. this._colorGradients.push(colorGradient);
  107440. this._colorGradients.sort(function (a, b) {
  107441. if (a.gradient < b.gradient) {
  107442. return -1;
  107443. }
  107444. else if (a.gradient > b.gradient) {
  107445. return 1;
  107446. }
  107447. return 0;
  107448. });
  107449. return this;
  107450. };
  107451. /**
  107452. * Remove a specific color gradient
  107453. * @param gradient defines the gradient to remove
  107454. * @returns this particle system
  107455. */
  107456. ParticleSystem.prototype.removeColorGradient = function (gradient) {
  107457. if (!this._colorGradients) {
  107458. return this;
  107459. }
  107460. var index = 0;
  107461. for (var _i = 0, _a = this._colorGradients; _i < _a.length; _i++) {
  107462. var colorGradient = _a[_i];
  107463. if (colorGradient.gradient === gradient) {
  107464. this._colorGradients.splice(index, 1);
  107465. break;
  107466. }
  107467. index++;
  107468. }
  107469. return this;
  107470. };
  107471. ParticleSystem.prototype._fetchR = function (u, v, width, height, pixels) {
  107472. u = Math.abs(u) * 0.5 + 0.5;
  107473. v = Math.abs(v) * 0.5 + 0.5;
  107474. var wrappedU = ((u * width) % width) | 0;
  107475. var wrappedV = ((v * height) % height) | 0;
  107476. var position = (wrappedU + wrappedV * width) * 4;
  107477. return pixels[position] / 255;
  107478. };
  107479. ParticleSystem.prototype._reset = function () {
  107480. this._resetEffect();
  107481. };
  107482. ParticleSystem.prototype._resetEffect = function () {
  107483. if (this._vertexBuffer) {
  107484. this._vertexBuffer.dispose();
  107485. this._vertexBuffer = null;
  107486. }
  107487. if (this._spriteBuffer) {
  107488. this._spriteBuffer.dispose();
  107489. this._spriteBuffer = null;
  107490. }
  107491. this._createVertexBuffers();
  107492. };
  107493. ParticleSystem.prototype._createVertexBuffers = function () {
  107494. this._vertexBufferSize = this._useInstancing ? 10 : 12;
  107495. if (this._isAnimationSheetEnabled) {
  107496. this._vertexBufferSize += 1;
  107497. }
  107498. if (!this._isBillboardBased || this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  107499. this._vertexBufferSize += 3;
  107500. }
  107501. if (this._useRampGradients) {
  107502. this._vertexBufferSize += 4;
  107503. }
  107504. var engine = this._scene.getEngine();
  107505. this._vertexData = new Float32Array(this._capacity * this._vertexBufferSize * (this._useInstancing ? 1 : 4));
  107506. this._vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, this._vertexData, true, this._vertexBufferSize);
  107507. var dataOffset = 0;
  107508. var positions = this._vertexBuffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind, dataOffset, 3, this._vertexBufferSize, this._useInstancing);
  107509. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind] = positions;
  107510. dataOffset += 3;
  107511. var colors = this._vertexBuffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind, dataOffset, 4, this._vertexBufferSize, this._useInstancing);
  107512. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind] = colors;
  107513. dataOffset += 4;
  107514. var options = this._vertexBuffer.createVertexBuffer("angle", dataOffset, 1, this._vertexBufferSize, this._useInstancing);
  107515. this._vertexBuffers["angle"] = options;
  107516. dataOffset += 1;
  107517. var size = this._vertexBuffer.createVertexBuffer("size", dataOffset, 2, this._vertexBufferSize, this._useInstancing);
  107518. this._vertexBuffers["size"] = size;
  107519. dataOffset += 2;
  107520. if (this._isAnimationSheetEnabled) {
  107521. var cellIndexBuffer = this._vertexBuffer.createVertexBuffer("cellIndex", dataOffset, 1, this._vertexBufferSize, this._useInstancing);
  107522. this._vertexBuffers["cellIndex"] = cellIndexBuffer;
  107523. dataOffset += 1;
  107524. }
  107525. if (!this._isBillboardBased || this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  107526. var directionBuffer = this._vertexBuffer.createVertexBuffer("direction", dataOffset, 3, this._vertexBufferSize, this._useInstancing);
  107527. this._vertexBuffers["direction"] = directionBuffer;
  107528. dataOffset += 3;
  107529. }
  107530. if (this._useRampGradients) {
  107531. var rampDataBuffer = this._vertexBuffer.createVertexBuffer("remapData", dataOffset, 4, this._vertexBufferSize, this._useInstancing);
  107532. this._vertexBuffers["remapData"] = rampDataBuffer;
  107533. dataOffset += 4;
  107534. }
  107535. var offsets;
  107536. if (this._useInstancing) {
  107537. var spriteData = new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]);
  107538. this._spriteBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, spriteData, false, 2);
  107539. offsets = this._spriteBuffer.createVertexBuffer("offset", 0, 2);
  107540. }
  107541. else {
  107542. offsets = this._vertexBuffer.createVertexBuffer("offset", dataOffset, 2, this._vertexBufferSize, this._useInstancing);
  107543. dataOffset += 2;
  107544. }
  107545. this._vertexBuffers["offset"] = offsets;
  107546. };
  107547. ParticleSystem.prototype._createIndexBuffer = function () {
  107548. if (this._useInstancing) {
  107549. return;
  107550. }
  107551. var indices = [];
  107552. var index = 0;
  107553. for (var count = 0; count < this._capacity; count++) {
  107554. indices.push(index);
  107555. indices.push(index + 1);
  107556. indices.push(index + 2);
  107557. indices.push(index);
  107558. indices.push(index + 2);
  107559. indices.push(index + 3);
  107560. index += 4;
  107561. }
  107562. this._indexBuffer = this._scene.getEngine().createIndexBuffer(indices);
  107563. };
  107564. /**
  107565. * Gets the maximum number of particles active at the same time.
  107566. * @returns The max number of active particles.
  107567. */
  107568. ParticleSystem.prototype.getCapacity = function () {
  107569. return this._capacity;
  107570. };
  107571. /**
  107572. * Gets whether there are still active particles in the system.
  107573. * @returns True if it is alive, otherwise false.
  107574. */
  107575. ParticleSystem.prototype.isAlive = function () {
  107576. return this._alive;
  107577. };
  107578. /**
  107579. * Gets if the system has been started. (Note: this will still be true after stop is called)
  107580. * @returns True if it has been started, otherwise false.
  107581. */
  107582. ParticleSystem.prototype.isStarted = function () {
  107583. return this._started;
  107584. };
  107585. ParticleSystem.prototype._prepareSubEmitterInternalArray = function () {
  107586. var _this = this;
  107587. this._subEmitters = new Array();
  107588. if (this.subEmitters) {
  107589. this.subEmitters.forEach(function (subEmitter) {
  107590. if (subEmitter instanceof ParticleSystem) {
  107591. _this._subEmitters.push([new _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"](subEmitter)]);
  107592. }
  107593. else if (subEmitter instanceof _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"]) {
  107594. _this._subEmitters.push([subEmitter]);
  107595. }
  107596. else if (subEmitter instanceof Array) {
  107597. _this._subEmitters.push(subEmitter);
  107598. }
  107599. });
  107600. }
  107601. };
  107602. /**
  107603. * Starts the particle system and begins to emit
  107604. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  107605. */
  107606. ParticleSystem.prototype.start = function (delay) {
  107607. var _this = this;
  107608. if (delay === void 0) { delay = this.startDelay; }
  107609. if (!this.targetStopDuration && this._hasTargetStopDurationDependantGradient()) {
  107610. throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
  107611. }
  107612. if (delay) {
  107613. setTimeout(function () {
  107614. _this.start(0);
  107615. }, delay);
  107616. return;
  107617. }
  107618. // Convert the subEmitters field to the constant type field _subEmitters
  107619. this._prepareSubEmitterInternalArray();
  107620. this._started = true;
  107621. this._stopped = false;
  107622. this._actualFrame = 0;
  107623. if (this._subEmitters && this._subEmitters.length != 0) {
  107624. this.activeSubSystems = new Array();
  107625. }
  107626. // Reset emit gradient so it acts the same on every start
  107627. if (this._emitRateGradients) {
  107628. if (this._emitRateGradients.length > 0) {
  107629. this._currentEmitRateGradient = this._emitRateGradients[0];
  107630. this._currentEmitRate1 = this._currentEmitRateGradient.getFactor();
  107631. this._currentEmitRate2 = this._currentEmitRate1;
  107632. }
  107633. if (this._emitRateGradients.length > 1) {
  107634. this._currentEmitRate2 = this._emitRateGradients[1].getFactor();
  107635. }
  107636. }
  107637. // Reset start size gradient so it acts the same on every start
  107638. if (this._startSizeGradients) {
  107639. if (this._startSizeGradients.length > 0) {
  107640. this._currentStartSizeGradient = this._startSizeGradients[0];
  107641. this._currentStartSize1 = this._currentStartSizeGradient.getFactor();
  107642. this._currentStartSize2 = this._currentStartSize1;
  107643. }
  107644. if (this._startSizeGradients.length > 1) {
  107645. this._currentStartSize2 = this._startSizeGradients[1].getFactor();
  107646. }
  107647. }
  107648. if (this.preWarmCycles) {
  107649. if (this.emitter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_6__["AbstractMesh"]) {
  107650. this.emitter.computeWorldMatrix(true);
  107651. }
  107652. var noiseTextureAsProcedural_1 = this.noiseTexture;
  107653. if (noiseTextureAsProcedural_1 && noiseTextureAsProcedural_1.onGeneratedObservable) {
  107654. noiseTextureAsProcedural_1.onGeneratedObservable.addOnce(function () {
  107655. setTimeout(function () {
  107656. for (var index = 0; index < _this.preWarmCycles; index++) {
  107657. _this.animate(true);
  107658. noiseTextureAsProcedural_1.render();
  107659. }
  107660. });
  107661. });
  107662. }
  107663. else {
  107664. for (var index = 0; index < this.preWarmCycles; index++) {
  107665. this.animate(true);
  107666. }
  107667. }
  107668. }
  107669. // Animations
  107670. if (this.beginAnimationOnStart && this.animations && this.animations.length > 0) {
  107671. this.getScene().beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop);
  107672. }
  107673. };
  107674. /**
  107675. * Stops the particle system.
  107676. * @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.
  107677. */
  107678. ParticleSystem.prototype.stop = function (stopSubEmitters) {
  107679. if (stopSubEmitters === void 0) { stopSubEmitters = true; }
  107680. this._stopped = true;
  107681. if (stopSubEmitters) {
  107682. this._stopSubEmitters();
  107683. }
  107684. };
  107685. // animation sheet
  107686. /**
  107687. * Remove all active particles
  107688. */
  107689. ParticleSystem.prototype.reset = function () {
  107690. this._stockParticles = [];
  107691. this._particles = [];
  107692. };
  107693. /**
  107694. * @hidden (for internal use only)
  107695. */
  107696. ParticleSystem.prototype._appendParticleVertex = function (index, particle, offsetX, offsetY) {
  107697. var offset = index * this._vertexBufferSize;
  107698. this._vertexData[offset++] = particle.position.x + this.worldOffset.x;
  107699. this._vertexData[offset++] = particle.position.y + this.worldOffset.y;
  107700. this._vertexData[offset++] = particle.position.z + this.worldOffset.z;
  107701. this._vertexData[offset++] = particle.color.r;
  107702. this._vertexData[offset++] = particle.color.g;
  107703. this._vertexData[offset++] = particle.color.b;
  107704. this._vertexData[offset++] = particle.color.a;
  107705. this._vertexData[offset++] = particle.angle;
  107706. this._vertexData[offset++] = particle.scale.x * particle.size;
  107707. this._vertexData[offset++] = particle.scale.y * particle.size;
  107708. if (this._isAnimationSheetEnabled) {
  107709. this._vertexData[offset++] = particle.cellIndex;
  107710. }
  107711. if (!this._isBillboardBased) {
  107712. if (particle._initialDirection) {
  107713. this._vertexData[offset++] = particle._initialDirection.x;
  107714. this._vertexData[offset++] = particle._initialDirection.y;
  107715. this._vertexData[offset++] = particle._initialDirection.z;
  107716. }
  107717. else {
  107718. this._vertexData[offset++] = particle.direction.x;
  107719. this._vertexData[offset++] = particle.direction.y;
  107720. this._vertexData[offset++] = particle.direction.z;
  107721. }
  107722. }
  107723. else if (this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  107724. this._vertexData[offset++] = particle.direction.x;
  107725. this._vertexData[offset++] = particle.direction.y;
  107726. this._vertexData[offset++] = particle.direction.z;
  107727. }
  107728. if (this._useRampGradients) {
  107729. this._vertexData[offset++] = particle.remapData.x;
  107730. this._vertexData[offset++] = particle.remapData.y;
  107731. this._vertexData[offset++] = particle.remapData.z;
  107732. this._vertexData[offset++] = particle.remapData.w;
  107733. }
  107734. if (!this._useInstancing) {
  107735. if (this._isAnimationSheetEnabled) {
  107736. if (offsetX === 0) {
  107737. offsetX = this._epsilon;
  107738. }
  107739. else if (offsetX === 1) {
  107740. offsetX = 1 - this._epsilon;
  107741. }
  107742. if (offsetY === 0) {
  107743. offsetY = this._epsilon;
  107744. }
  107745. else if (offsetY === 1) {
  107746. offsetY = 1 - this._epsilon;
  107747. }
  107748. }
  107749. this._vertexData[offset++] = offsetX;
  107750. this._vertexData[offset++] = offsetY;
  107751. }
  107752. };
  107753. ParticleSystem.prototype._stopSubEmitters = function () {
  107754. if (!this.activeSubSystems) {
  107755. return;
  107756. }
  107757. this.activeSubSystems.forEach(function (subSystem) {
  107758. subSystem.stop(true);
  107759. });
  107760. this.activeSubSystems = new Array();
  107761. };
  107762. ParticleSystem.prototype._removeFromRoot = function () {
  107763. if (!this._rootParticleSystem) {
  107764. return;
  107765. }
  107766. var index = this._rootParticleSystem.activeSubSystems.indexOf(this);
  107767. if (index !== -1) {
  107768. this._rootParticleSystem.activeSubSystems.splice(index, 1);
  107769. }
  107770. this._rootParticleSystem = null;
  107771. };
  107772. // End of sub system methods
  107773. ParticleSystem.prototype._update = function (newParticles) {
  107774. var _this = this;
  107775. // Update current
  107776. this._alive = this._particles.length > 0;
  107777. if (this.emitter.position) {
  107778. var emitterMesh = this.emitter;
  107779. this._emitterWorldMatrix = emitterMesh.getWorldMatrix();
  107780. }
  107781. else {
  107782. var emitterPosition = this.emitter;
  107783. this._emitterWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(emitterPosition.x, emitterPosition.y, emitterPosition.z);
  107784. }
  107785. this.updateFunction(this._particles);
  107786. // Add new ones
  107787. var particle;
  107788. var _loop_2 = function () {
  107789. if (this_1._particles.length === this_1._capacity) {
  107790. return "break";
  107791. }
  107792. particle = this_1._createParticle();
  107793. this_1._particles.push(particle);
  107794. // Emitter
  107795. var emitPower = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minEmitPower, this_1.maxEmitPower);
  107796. if (this_1.startPositionFunction) {
  107797. this_1.startPositionFunction(this_1._emitterWorldMatrix, particle.position, particle);
  107798. }
  107799. else {
  107800. this_1.particleEmitterType.startPositionFunction(this_1._emitterWorldMatrix, particle.position, particle);
  107801. }
  107802. if (this_1.startDirectionFunction) {
  107803. this_1.startDirectionFunction(this_1._emitterWorldMatrix, particle.direction, particle);
  107804. }
  107805. else {
  107806. this_1.particleEmitterType.startDirectionFunction(this_1._emitterWorldMatrix, particle.direction, particle);
  107807. }
  107808. if (emitPower === 0) {
  107809. if (!particle._initialDirection) {
  107810. particle._initialDirection = particle.direction.clone();
  107811. }
  107812. else {
  107813. particle._initialDirection.copyFrom(particle.direction);
  107814. }
  107815. }
  107816. else {
  107817. particle._initialDirection = null;
  107818. }
  107819. particle.direction.scaleInPlace(emitPower);
  107820. // Life time
  107821. if (this_1.targetStopDuration && this_1._lifeTimeGradients && this_1._lifeTimeGradients.length > 0) {
  107822. var ratio_1 = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Clamp(this_1._actualFrame / this_1.targetStopDuration);
  107823. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio_1, this_1._lifeTimeGradients, function (currentGradient, nextGradient) {
  107824. var factorGradient1 = currentGradient;
  107825. var factorGradient2 = nextGradient;
  107826. var lifeTime1 = factorGradient1.getFactor();
  107827. var lifeTime2 = factorGradient2.getFactor();
  107828. var gradient = (ratio_1 - factorGradient1.gradient) / (factorGradient2.gradient - factorGradient1.gradient);
  107829. particle.lifeTime = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(lifeTime1, lifeTime2, gradient);
  107830. });
  107831. }
  107832. else {
  107833. particle.lifeTime = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minLifeTime, this_1.maxLifeTime);
  107834. }
  107835. // Size
  107836. if (!this_1._sizeGradients || this_1._sizeGradients.length === 0) {
  107837. particle.size = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minSize, this_1.maxSize);
  107838. }
  107839. else {
  107840. particle._currentSizeGradient = this_1._sizeGradients[0];
  107841. particle._currentSize1 = particle._currentSizeGradient.getFactor();
  107842. particle.size = particle._currentSize1;
  107843. if (this_1._sizeGradients.length > 1) {
  107844. particle._currentSize2 = this_1._sizeGradients[1].getFactor();
  107845. }
  107846. else {
  107847. particle._currentSize2 = particle._currentSize1;
  107848. }
  107849. }
  107850. // Size and scale
  107851. 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));
  107852. // Adjust scale by start size
  107853. if (this_1._startSizeGradients && this_1._startSizeGradients[0] && this_1.targetStopDuration) {
  107854. var ratio = this_1._actualFrame / this_1.targetStopDuration;
  107855. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this_1._startSizeGradients, function (currentGradient, nextGradient, scale) {
  107856. if (currentGradient !== _this._currentStartSizeGradient) {
  107857. _this._currentStartSize1 = _this._currentStartSize2;
  107858. _this._currentStartSize2 = nextGradient.getFactor();
  107859. _this._currentStartSizeGradient = currentGradient;
  107860. }
  107861. var value = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(_this._currentStartSize1, _this._currentStartSize2, scale);
  107862. particle.scale.scaleInPlace(value);
  107863. });
  107864. }
  107865. // Angle
  107866. if (!this_1._angularSpeedGradients || this_1._angularSpeedGradients.length === 0) {
  107867. particle.angularSpeed = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minAngularSpeed, this_1.maxAngularSpeed);
  107868. }
  107869. else {
  107870. particle._currentAngularSpeedGradient = this_1._angularSpeedGradients[0];
  107871. particle.angularSpeed = particle._currentAngularSpeedGradient.getFactor();
  107872. particle._currentAngularSpeed1 = particle.angularSpeed;
  107873. if (this_1._angularSpeedGradients.length > 1) {
  107874. particle._currentAngularSpeed2 = this_1._angularSpeedGradients[1].getFactor();
  107875. }
  107876. else {
  107877. particle._currentAngularSpeed2 = particle._currentAngularSpeed1;
  107878. }
  107879. }
  107880. particle.angle = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minInitialRotation, this_1.maxInitialRotation);
  107881. // Velocity
  107882. if (this_1._velocityGradients && this_1._velocityGradients.length > 0) {
  107883. particle._currentVelocityGradient = this_1._velocityGradients[0];
  107884. particle._currentVelocity1 = particle._currentVelocityGradient.getFactor();
  107885. if (this_1._velocityGradients.length > 1) {
  107886. particle._currentVelocity2 = this_1._velocityGradients[1].getFactor();
  107887. }
  107888. else {
  107889. particle._currentVelocity2 = particle._currentVelocity1;
  107890. }
  107891. }
  107892. // Limit velocity
  107893. if (this_1._limitVelocityGradients && this_1._limitVelocityGradients.length > 0) {
  107894. particle._currentLimitVelocityGradient = this_1._limitVelocityGradients[0];
  107895. particle._currentLimitVelocity1 = particle._currentLimitVelocityGradient.getFactor();
  107896. if (this_1._limitVelocityGradients.length > 1) {
  107897. particle._currentLimitVelocity2 = this_1._limitVelocityGradients[1].getFactor();
  107898. }
  107899. else {
  107900. particle._currentLimitVelocity2 = particle._currentLimitVelocity1;
  107901. }
  107902. }
  107903. // Drag
  107904. if (this_1._dragGradients && this_1._dragGradients.length > 0) {
  107905. particle._currentDragGradient = this_1._dragGradients[0];
  107906. particle._currentDrag1 = particle._currentDragGradient.getFactor();
  107907. if (this_1._dragGradients.length > 1) {
  107908. particle._currentDrag2 = this_1._dragGradients[1].getFactor();
  107909. }
  107910. else {
  107911. particle._currentDrag2 = particle._currentDrag1;
  107912. }
  107913. }
  107914. // Color
  107915. if (!this_1._colorGradients || this_1._colorGradients.length === 0) {
  107916. step = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(0, 1.0);
  107917. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(this_1.color1, this_1.color2, step, particle.color);
  107918. this_1.colorDead.subtractToRef(particle.color, this_1._colorDiff);
  107919. this_1._colorDiff.scaleToRef(1.0 / particle.lifeTime, particle.colorStep);
  107920. }
  107921. else {
  107922. particle._currentColorGradient = this_1._colorGradients[0];
  107923. particle._currentColorGradient.getColorToRef(particle.color);
  107924. particle._currentColor1.copyFrom(particle.color);
  107925. if (this_1._colorGradients.length > 1) {
  107926. this_1._colorGradients[1].getColorToRef(particle._currentColor2);
  107927. }
  107928. else {
  107929. particle._currentColor2.copyFrom(particle.color);
  107930. }
  107931. }
  107932. // Sheet
  107933. if (this_1._isAnimationSheetEnabled) {
  107934. particle._initialStartSpriteCellID = this_1.startSpriteCellID;
  107935. particle._initialEndSpriteCellID = this_1.endSpriteCellID;
  107936. }
  107937. // Inherited Velocity
  107938. particle.direction.addInPlace(this_1._inheritedVelocityOffset);
  107939. // Ramp
  107940. if (this_1._useRampGradients) {
  107941. particle.remapData = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector4"](0, 1, 0, 1);
  107942. }
  107943. // Noise texture coordinates
  107944. if (this_1.noiseTexture) {
  107945. if (particle._randomNoiseCoordinates1) {
  107946. particle._randomNoiseCoordinates1.copyFromFloats(Math.random(), Math.random(), Math.random());
  107947. particle._randomNoiseCoordinates2.copyFromFloats(Math.random(), Math.random(), Math.random());
  107948. }
  107949. else {
  107950. particle._randomNoiseCoordinates1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.random(), Math.random(), Math.random());
  107951. particle._randomNoiseCoordinates2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.random(), Math.random(), Math.random());
  107952. }
  107953. }
  107954. // Update the position of the attached sub-emitters to match their attached particle
  107955. particle._inheritParticleInfoToSubEmitters();
  107956. };
  107957. var this_1 = this, step;
  107958. for (var index = 0; index < newParticles; index++) {
  107959. var state_1 = _loop_2();
  107960. if (state_1 === "break")
  107961. break;
  107962. }
  107963. };
  107964. /** @hidden */
  107965. ParticleSystem._GetAttributeNamesOrOptions = function (isAnimationSheetEnabled, isBillboardBased, useRampGradients) {
  107966. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  107967. if (isBillboardBased === void 0) { isBillboardBased = false; }
  107968. if (useRampGradients === void 0) { useRampGradients = false; }
  107969. var attributeNamesOrOptions = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind, "angle", "offset", "size"];
  107970. if (isAnimationSheetEnabled) {
  107971. attributeNamesOrOptions.push("cellIndex");
  107972. }
  107973. if (!isBillboardBased) {
  107974. attributeNamesOrOptions.push("direction");
  107975. }
  107976. if (useRampGradients) {
  107977. attributeNamesOrOptions.push("remapData");
  107978. }
  107979. return attributeNamesOrOptions;
  107980. };
  107981. /** @hidden */
  107982. ParticleSystem._GetEffectCreationOptions = function (isAnimationSheetEnabled) {
  107983. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  107984. var effectCreationOption = ["invView", "view", "projection", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "textureMask", "translationPivot", "eyePosition"];
  107985. if (isAnimationSheetEnabled) {
  107986. effectCreationOption.push("particlesInfos");
  107987. }
  107988. return effectCreationOption;
  107989. };
  107990. /** @hidden */
  107991. ParticleSystem.prototype._getEffect = function (blendMode) {
  107992. if (this._customEffect) {
  107993. return this._customEffect;
  107994. }
  107995. var defines = [];
  107996. if (this._scene.clipPlane) {
  107997. defines.push("#define CLIPPLANE");
  107998. }
  107999. if (this._scene.clipPlane2) {
  108000. defines.push("#define CLIPPLANE2");
  108001. }
  108002. if (this._scene.clipPlane3) {
  108003. defines.push("#define CLIPPLANE3");
  108004. }
  108005. if (this._scene.clipPlane4) {
  108006. defines.push("#define CLIPPLANE4");
  108007. }
  108008. if (this._isAnimationSheetEnabled) {
  108009. defines.push("#define ANIMATESHEET");
  108010. }
  108011. if (blendMode === ParticleSystem.BLENDMODE_MULTIPLY) {
  108012. defines.push("#define BLENDMULTIPLYMODE");
  108013. }
  108014. if (this._useRampGradients) {
  108015. defines.push("#define RAMPGRADIENT");
  108016. }
  108017. if (this._isBillboardBased) {
  108018. defines.push("#define BILLBOARD");
  108019. switch (this.billboardMode) {
  108020. case ParticleSystem.BILLBOARDMODE_Y:
  108021. defines.push("#define BILLBOARDY");
  108022. break;
  108023. case ParticleSystem.BILLBOARDMODE_STRETCHED:
  108024. defines.push("#define BILLBOARDSTRETCHED");
  108025. break;
  108026. case ParticleSystem.BILLBOARDMODE_ALL:
  108027. default:
  108028. break;
  108029. }
  108030. }
  108031. if (this._imageProcessingConfiguration) {
  108032. this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines);
  108033. defines.push(this._imageProcessingConfigurationDefines.toString());
  108034. }
  108035. // Effect
  108036. var join = defines.join("\n");
  108037. if (this._cachedDefines !== join) {
  108038. this._cachedDefines = join;
  108039. var attributesNamesOrOptions = ParticleSystem._GetAttributeNamesOrOptions(this._isAnimationSheetEnabled, this._isBillboardBased && this.billboardMode !== ParticleSystem.BILLBOARDMODE_STRETCHED, this._useRampGradients);
  108040. var effectCreationOption = ParticleSystem._GetEffectCreationOptions(this._isAnimationSheetEnabled);
  108041. var samplers = ["diffuseSampler", "rampSampler"];
  108042. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"]) {
  108043. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"].PrepareUniforms(effectCreationOption, this._imageProcessingConfigurationDefines);
  108044. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._imageProcessingConfigurationDefines);
  108045. }
  108046. this._effect = this._scene.getEngine().createEffect("particles", attributesNamesOrOptions, effectCreationOption, samplers, join);
  108047. }
  108048. return this._effect;
  108049. };
  108050. /**
  108051. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  108052. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  108053. */
  108054. ParticleSystem.prototype.animate = function (preWarmOnly) {
  108055. var _this = this;
  108056. if (preWarmOnly === void 0) { preWarmOnly = false; }
  108057. if (!this._started) {
  108058. return;
  108059. }
  108060. if (!preWarmOnly) {
  108061. // Check
  108062. if (!this.isReady()) {
  108063. return;
  108064. }
  108065. if (this._currentRenderId === this._scene.getFrameId()) {
  108066. return;
  108067. }
  108068. this._currentRenderId = this._scene.getFrameId();
  108069. }
  108070. this._scaledUpdateSpeed = this.updateSpeed * (preWarmOnly ? this.preWarmStepOffset : this._scene.getAnimationRatio());
  108071. // Determine the number of particles we need to create
  108072. var newParticles;
  108073. if (this.manualEmitCount > -1) {
  108074. newParticles = this.manualEmitCount;
  108075. this._newPartsExcess = 0;
  108076. this.manualEmitCount = 0;
  108077. }
  108078. else {
  108079. var rate_1 = this.emitRate;
  108080. if (this._emitRateGradients && this._emitRateGradients.length > 0 && this.targetStopDuration) {
  108081. var ratio = this._actualFrame / this.targetStopDuration;
  108082. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._emitRateGradients, function (currentGradient, nextGradient, scale) {
  108083. if (currentGradient !== _this._currentEmitRateGradient) {
  108084. _this._currentEmitRate1 = _this._currentEmitRate2;
  108085. _this._currentEmitRate2 = nextGradient.getFactor();
  108086. _this._currentEmitRateGradient = currentGradient;
  108087. }
  108088. rate_1 = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(_this._currentEmitRate1, _this._currentEmitRate2, scale);
  108089. });
  108090. }
  108091. newParticles = ((rate_1 * this._scaledUpdateSpeed) >> 0);
  108092. this._newPartsExcess += rate_1 * this._scaledUpdateSpeed - newParticles;
  108093. }
  108094. if (this._newPartsExcess > 1.0) {
  108095. newParticles += this._newPartsExcess >> 0;
  108096. this._newPartsExcess -= this._newPartsExcess >> 0;
  108097. }
  108098. this._alive = false;
  108099. if (!this._stopped) {
  108100. this._actualFrame += this._scaledUpdateSpeed;
  108101. if (this.targetStopDuration && this._actualFrame >= this.targetStopDuration) {
  108102. this.stop();
  108103. }
  108104. }
  108105. else {
  108106. newParticles = 0;
  108107. }
  108108. this._update(newParticles);
  108109. // Stopped?
  108110. if (this._stopped) {
  108111. if (!this._alive) {
  108112. this._started = false;
  108113. if (this.onAnimationEnd) {
  108114. this.onAnimationEnd();
  108115. }
  108116. if (this.disposeOnStop) {
  108117. this._scene._toBeDisposed.push(this);
  108118. }
  108119. }
  108120. }
  108121. if (!preWarmOnly) {
  108122. // Update VBO
  108123. var offset = 0;
  108124. for (var index = 0; index < this._particles.length; index++) {
  108125. var particle = this._particles[index];
  108126. this._appendParticleVertices(offset, particle);
  108127. offset += this._useInstancing ? 1 : 4;
  108128. }
  108129. if (this._vertexBuffer) {
  108130. this._vertexBuffer.update(this._vertexData);
  108131. }
  108132. }
  108133. if (this.manualEmitCount === 0 && this.disposeOnStop) {
  108134. this.stop();
  108135. }
  108136. };
  108137. ParticleSystem.prototype._appendParticleVertices = function (offset, particle) {
  108138. this._appendParticleVertex(offset++, particle, 0, 0);
  108139. if (!this._useInstancing) {
  108140. this._appendParticleVertex(offset++, particle, 1, 0);
  108141. this._appendParticleVertex(offset++, particle, 1, 1);
  108142. this._appendParticleVertex(offset++, particle, 0, 1);
  108143. }
  108144. };
  108145. /**
  108146. * Rebuilds the particle system.
  108147. */
  108148. ParticleSystem.prototype.rebuild = function () {
  108149. this._createIndexBuffer();
  108150. if (this._vertexBuffer) {
  108151. this._vertexBuffer._rebuild();
  108152. }
  108153. };
  108154. /**
  108155. * Is this system ready to be used/rendered
  108156. * @return true if the system is ready
  108157. */
  108158. ParticleSystem.prototype.isReady = function () {
  108159. if (!this.emitter || !this._imageProcessingConfiguration.isReady() || !this.particleTexture || !this.particleTexture.isReady()) {
  108160. return false;
  108161. }
  108162. if (this.blendMode !== ParticleSystem.BLENDMODE_MULTIPLYADD) {
  108163. if (!this._getEffect(this.blendMode).isReady()) {
  108164. return false;
  108165. }
  108166. }
  108167. else {
  108168. if (!this._getEffect(ParticleSystem.BLENDMODE_MULTIPLY).isReady()) {
  108169. return false;
  108170. }
  108171. if (!this._getEffect(ParticleSystem.BLENDMODE_ADD).isReady()) {
  108172. return false;
  108173. }
  108174. }
  108175. return true;
  108176. };
  108177. ParticleSystem.prototype._render = function (blendMode) {
  108178. var effect = this._getEffect(blendMode);
  108179. var engine = this._scene.getEngine();
  108180. // Render
  108181. engine.enableEffect(effect);
  108182. var viewMatrix = this._scene.getViewMatrix();
  108183. effect.setTexture("diffuseSampler", this.particleTexture);
  108184. effect.setMatrix("view", viewMatrix);
  108185. effect.setMatrix("projection", this._scene.getProjectionMatrix());
  108186. if (this._isAnimationSheetEnabled && this.particleTexture) {
  108187. var baseSize = this.particleTexture.getBaseSize();
  108188. effect.setFloat3("particlesInfos", this.spriteCellWidth / baseSize.width, this.spriteCellHeight / baseSize.height, baseSize.width / this.spriteCellWidth);
  108189. }
  108190. effect.setVector2("translationPivot", this.translationPivot);
  108191. effect.setFloat4("textureMask", this.textureMask.r, this.textureMask.g, this.textureMask.b, this.textureMask.a);
  108192. if (this._isBillboardBased) {
  108193. var camera = this._scene.activeCamera;
  108194. effect.setVector3("eyePosition", camera.globalPosition);
  108195. }
  108196. if (this._rampGradientsTexture) {
  108197. effect.setTexture("rampSampler", this._rampGradientsTexture);
  108198. }
  108199. if (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4) {
  108200. var invView = viewMatrix.clone();
  108201. invView.invert();
  108202. effect.setMatrix("invView", invView);
  108203. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_8__["MaterialHelper"].BindClipPlane(effect, this._scene);
  108204. }
  108205. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  108206. // image processing
  108207. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  108208. this._imageProcessingConfiguration.bind(effect);
  108209. }
  108210. // Draw order
  108211. switch (blendMode) {
  108212. case ParticleSystem.BLENDMODE_ADD:
  108213. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_ADD);
  108214. break;
  108215. case ParticleSystem.BLENDMODE_ONEONE:
  108216. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_ONEONE);
  108217. break;
  108218. case ParticleSystem.BLENDMODE_STANDARD:
  108219. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_COMBINE);
  108220. break;
  108221. case ParticleSystem.BLENDMODE_MULTIPLY:
  108222. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_MULTIPLY);
  108223. break;
  108224. }
  108225. if (this._useInstancing) {
  108226. engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFanDrawMode, 0, 4, this._particles.length);
  108227. }
  108228. else {
  108229. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, this._particles.length * 6);
  108230. }
  108231. return this._particles.length;
  108232. };
  108233. /**
  108234. * Renders the particle system in its current state.
  108235. * @returns the current number of particles
  108236. */
  108237. ParticleSystem.prototype.render = function () {
  108238. // Check
  108239. if (!this.isReady() || !this._particles.length) {
  108240. return 0;
  108241. }
  108242. var engine = this._scene.getEngine();
  108243. engine.setState(false);
  108244. if (this.forceDepthWrite) {
  108245. engine.setDepthWrite(true);
  108246. }
  108247. var outparticles = 0;
  108248. if (this.blendMode === ParticleSystem.BLENDMODE_MULTIPLYADD) {
  108249. outparticles = this._render(ParticleSystem.BLENDMODE_MULTIPLY) + this._render(ParticleSystem.BLENDMODE_ADD);
  108250. }
  108251. outparticles = this._render(this.blendMode);
  108252. engine.unbindInstanceAttributes();
  108253. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_DISABLE);
  108254. return outparticles;
  108255. };
  108256. /**
  108257. * Disposes the particle system and free the associated resources
  108258. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  108259. */
  108260. ParticleSystem.prototype.dispose = function (disposeTexture) {
  108261. if (disposeTexture === void 0) { disposeTexture = true; }
  108262. if (this._vertexBuffer) {
  108263. this._vertexBuffer.dispose();
  108264. this._vertexBuffer = null;
  108265. }
  108266. if (this._spriteBuffer) {
  108267. this._spriteBuffer.dispose();
  108268. this._spriteBuffer = null;
  108269. }
  108270. if (this._indexBuffer) {
  108271. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  108272. this._indexBuffer = null;
  108273. }
  108274. if (disposeTexture && this.particleTexture) {
  108275. this.particleTexture.dispose();
  108276. this.particleTexture = null;
  108277. }
  108278. if (disposeTexture && this.noiseTexture) {
  108279. this.noiseTexture.dispose();
  108280. this.noiseTexture = null;
  108281. }
  108282. if (this._rampGradientsTexture) {
  108283. this._rampGradientsTexture.dispose();
  108284. this._rampGradientsTexture = null;
  108285. }
  108286. this._removeFromRoot();
  108287. if (this._subEmitters && this._subEmitters.length) {
  108288. for (var index = 0; index < this._subEmitters.length; index++) {
  108289. for (var _i = 0, _a = this._subEmitters[index]; _i < _a.length; _i++) {
  108290. var subEmitter = _a[_i];
  108291. subEmitter.dispose();
  108292. }
  108293. }
  108294. this._subEmitters = [];
  108295. this.subEmitters = [];
  108296. }
  108297. if (this._disposeEmitterOnDispose && this.emitter && this.emitter.dispose) {
  108298. this.emitter.dispose(true);
  108299. }
  108300. // Remove from scene
  108301. var index = this._scene.particleSystems.indexOf(this);
  108302. if (index > -1) {
  108303. this._scene.particleSystems.splice(index, 1);
  108304. }
  108305. this._scene._activeParticleSystems.dispose();
  108306. // Callback
  108307. this.onDisposeObservable.notifyObservers(this);
  108308. this.onDisposeObservable.clear();
  108309. this.reset();
  108310. };
  108311. // Clone
  108312. /**
  108313. * Clones the particle system.
  108314. * @param name The name of the cloned object
  108315. * @param newEmitter The new emitter to use
  108316. * @returns the cloned particle system
  108317. */
  108318. ParticleSystem.prototype.clone = function (name, newEmitter) {
  108319. var custom = null;
  108320. var program = null;
  108321. if (this.customShader != null) {
  108322. program = this.customShader;
  108323. var defines = (program.shaderOptions.defines.length > 0) ? program.shaderOptions.defines.join("\n") : "";
  108324. custom = this._scene.getEngine().createEffectForParticles(program.shaderPath.fragmentElement, program.shaderOptions.uniforms, program.shaderOptions.samplers, defines);
  108325. }
  108326. else if (this._customEffect) {
  108327. custom = this._customEffect;
  108328. }
  108329. var result = new ParticleSystem(name, this._capacity, this._scene, custom);
  108330. result.customShader = program;
  108331. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_20__["DeepCopier"].DeepCopy(this, result, ["particles", "customShader", "noiseTexture"]);
  108332. if (newEmitter === undefined) {
  108333. newEmitter = this.emitter;
  108334. }
  108335. result.noiseTexture = this.noiseTexture;
  108336. result.emitter = newEmitter;
  108337. if (this.particleTexture) {
  108338. result.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__["Texture"](this.particleTexture.url, this._scene);
  108339. }
  108340. // Clone gradients
  108341. if (this._colorGradients) {
  108342. this._colorGradients.forEach(function (v) {
  108343. result.addColorGradient(v.gradient, v.color1, v.color2);
  108344. });
  108345. }
  108346. if (this._dragGradients) {
  108347. this._dragGradients.forEach(function (v) {
  108348. result.addDragGradient(v.gradient, v.factor1, v.factor2);
  108349. });
  108350. }
  108351. if (this._angularSpeedGradients) {
  108352. this._angularSpeedGradients.forEach(function (v) {
  108353. result.addAngularSpeedGradient(v.gradient, v.factor1, v.factor2);
  108354. });
  108355. }
  108356. if (this._emitRateGradients) {
  108357. this._emitRateGradients.forEach(function (v) {
  108358. result.addEmitRateGradient(v.gradient, v.factor1, v.factor2);
  108359. });
  108360. }
  108361. if (this._lifeTimeGradients) {
  108362. this._lifeTimeGradients.forEach(function (v) {
  108363. result.addLifeTimeGradient(v.gradient, v.factor1, v.factor2);
  108364. });
  108365. }
  108366. if (this._limitVelocityGradients) {
  108367. this._limitVelocityGradients.forEach(function (v) {
  108368. result.addLimitVelocityGradient(v.gradient, v.factor1, v.factor2);
  108369. });
  108370. }
  108371. if (this._sizeGradients) {
  108372. this._sizeGradients.forEach(function (v) {
  108373. result.addSizeGradient(v.gradient, v.factor1, v.factor2);
  108374. });
  108375. }
  108376. if (this._startSizeGradients) {
  108377. this._startSizeGradients.forEach(function (v) {
  108378. result.addStartSizeGradient(v.gradient, v.factor1, v.factor2);
  108379. });
  108380. }
  108381. if (this._velocityGradients) {
  108382. this._velocityGradients.forEach(function (v) {
  108383. result.addVelocityGradient(v.gradient, v.factor1, v.factor2);
  108384. });
  108385. }
  108386. if (this._rampGradients) {
  108387. this._rampGradients.forEach(function (v) {
  108388. result.addRampGradient(v.gradient, v.color);
  108389. });
  108390. }
  108391. if (this._colorRemapGradients) {
  108392. this._colorRemapGradients.forEach(function (v) {
  108393. result.addColorRemapGradient(v.gradient, v.factor1, v.factor2);
  108394. });
  108395. }
  108396. if (this._alphaRemapGradients) {
  108397. this._alphaRemapGradients.forEach(function (v) {
  108398. result.addAlphaRemapGradient(v.gradient, v.factor1, v.factor2);
  108399. });
  108400. }
  108401. if (!this.preventAutoStart) {
  108402. result.start();
  108403. }
  108404. return result;
  108405. };
  108406. /**
  108407. * Serializes the particle system to a JSON object.
  108408. * @returns the JSON object
  108409. */
  108410. ParticleSystem.prototype.serialize = function () {
  108411. var serializationObject = {};
  108412. ParticleSystem._Serialize(serializationObject, this);
  108413. serializationObject.textureMask = this.textureMask.asArray();
  108414. serializationObject.customShader = this.customShader;
  108415. serializationObject.preventAutoStart = this.preventAutoStart;
  108416. // SubEmitters
  108417. if (this.subEmitters) {
  108418. serializationObject.subEmitters = [];
  108419. if (!this._subEmitters) {
  108420. this._prepareSubEmitterInternalArray();
  108421. }
  108422. for (var _i = 0, _a = this._subEmitters; _i < _a.length; _i++) {
  108423. var subs = _a[_i];
  108424. var cell = [];
  108425. for (var _b = 0, subs_1 = subs; _b < subs_1.length; _b++) {
  108426. var sub = subs_1[_b];
  108427. cell.push(sub.serialize());
  108428. }
  108429. serializationObject.subEmitters.push(cell);
  108430. }
  108431. }
  108432. return serializationObject;
  108433. };
  108434. /** @hidden */
  108435. ParticleSystem._Serialize = function (serializationObject, particleSystem) {
  108436. serializationObject.name = particleSystem.name;
  108437. serializationObject.id = particleSystem.id;
  108438. serializationObject.capacity = particleSystem.getCapacity();
  108439. // Emitter
  108440. if (particleSystem.emitter.position) {
  108441. var emitterMesh = particleSystem.emitter;
  108442. serializationObject.emitterId = emitterMesh.id;
  108443. }
  108444. else {
  108445. var emitterPosition = particleSystem.emitter;
  108446. serializationObject.emitter = emitterPosition.asArray();
  108447. }
  108448. // Emitter
  108449. if (particleSystem.particleEmitterType) {
  108450. serializationObject.particleEmitterType = particleSystem.particleEmitterType.serialize();
  108451. }
  108452. if (particleSystem.particleTexture) {
  108453. serializationObject.textureName = particleSystem.particleTexture.name;
  108454. serializationObject.invertY = particleSystem.particleTexture._invertY;
  108455. }
  108456. // Animations
  108457. _Misc_decorators__WEBPACK_IMPORTED_MODULE_19__["SerializationHelper"].AppendSerializedAnimations(particleSystem, serializationObject);
  108458. serializationObject.beginAnimationOnStart = particleSystem.beginAnimationOnStart;
  108459. serializationObject.beginAnimationFrom = particleSystem.beginAnimationFrom;
  108460. serializationObject.beginAnimationTo = particleSystem.beginAnimationTo;
  108461. serializationObject.beginAnimationLoop = particleSystem.beginAnimationLoop;
  108462. // Particle system
  108463. serializationObject.startDelay = particleSystem.startDelay;
  108464. serializationObject.renderingGroupId = particleSystem.renderingGroupId;
  108465. serializationObject.isBillboardBased = particleSystem.isBillboardBased;
  108466. serializationObject.billboardMode = particleSystem.billboardMode;
  108467. serializationObject.minAngularSpeed = particleSystem.minAngularSpeed;
  108468. serializationObject.maxAngularSpeed = particleSystem.maxAngularSpeed;
  108469. serializationObject.minSize = particleSystem.minSize;
  108470. serializationObject.maxSize = particleSystem.maxSize;
  108471. serializationObject.minScaleX = particleSystem.minScaleX;
  108472. serializationObject.maxScaleX = particleSystem.maxScaleX;
  108473. serializationObject.minScaleY = particleSystem.minScaleY;
  108474. serializationObject.maxScaleY = particleSystem.maxScaleY;
  108475. serializationObject.minEmitPower = particleSystem.minEmitPower;
  108476. serializationObject.maxEmitPower = particleSystem.maxEmitPower;
  108477. serializationObject.minLifeTime = particleSystem.minLifeTime;
  108478. serializationObject.maxLifeTime = particleSystem.maxLifeTime;
  108479. serializationObject.emitRate = particleSystem.emitRate;
  108480. serializationObject.gravity = particleSystem.gravity.asArray();
  108481. serializationObject.noiseStrength = particleSystem.noiseStrength.asArray();
  108482. serializationObject.color1 = particleSystem.color1.asArray();
  108483. serializationObject.color2 = particleSystem.color2.asArray();
  108484. serializationObject.colorDead = particleSystem.colorDead.asArray();
  108485. serializationObject.updateSpeed = particleSystem.updateSpeed;
  108486. serializationObject.targetStopDuration = particleSystem.targetStopDuration;
  108487. serializationObject.blendMode = particleSystem.blendMode;
  108488. serializationObject.preWarmCycles = particleSystem.preWarmCycles;
  108489. serializationObject.preWarmStepOffset = particleSystem.preWarmStepOffset;
  108490. serializationObject.minInitialRotation = particleSystem.minInitialRotation;
  108491. serializationObject.maxInitialRotation = particleSystem.maxInitialRotation;
  108492. serializationObject.startSpriteCellID = particleSystem.startSpriteCellID;
  108493. serializationObject.endSpriteCellID = particleSystem.endSpriteCellID;
  108494. serializationObject.spriteCellChangeSpeed = particleSystem.spriteCellChangeSpeed;
  108495. serializationObject.spriteCellWidth = particleSystem.spriteCellWidth;
  108496. serializationObject.spriteCellHeight = particleSystem.spriteCellHeight;
  108497. serializationObject.spriteRandomStartCell = particleSystem.spriteRandomStartCell;
  108498. serializationObject.isAnimationSheetEnabled = particleSystem.isAnimationSheetEnabled;
  108499. var colorGradients = particleSystem.getColorGradients();
  108500. if (colorGradients) {
  108501. serializationObject.colorGradients = [];
  108502. for (var _i = 0, colorGradients_1 = colorGradients; _i < colorGradients_1.length; _i++) {
  108503. var colorGradient = colorGradients_1[_i];
  108504. var serializedGradient = {
  108505. gradient: colorGradient.gradient,
  108506. color1: colorGradient.color1.asArray()
  108507. };
  108508. if (colorGradient.color2) {
  108509. serializedGradient.color2 = colorGradient.color2.asArray();
  108510. }
  108511. serializationObject.colorGradients.push(serializedGradient);
  108512. }
  108513. }
  108514. var rampGradients = particleSystem.getRampGradients();
  108515. if (rampGradients) {
  108516. serializationObject.rampGradients = [];
  108517. for (var _a = 0, rampGradients_1 = rampGradients; _a < rampGradients_1.length; _a++) {
  108518. var rampGradient = rampGradients_1[_a];
  108519. var serializedGradient = {
  108520. gradient: rampGradient.gradient,
  108521. color: rampGradient.color.asArray()
  108522. };
  108523. serializationObject.rampGradients.push(serializedGradient);
  108524. }
  108525. serializationObject.useRampGradients = particleSystem.useRampGradients;
  108526. }
  108527. var colorRemapGradients = particleSystem.getColorRemapGradients();
  108528. if (colorRemapGradients) {
  108529. serializationObject.colorRemapGradients = [];
  108530. for (var _b = 0, colorRemapGradients_1 = colorRemapGradients; _b < colorRemapGradients_1.length; _b++) {
  108531. var colorRemapGradient = colorRemapGradients_1[_b];
  108532. var serializedGradient = {
  108533. gradient: colorRemapGradient.gradient,
  108534. factor1: colorRemapGradient.factor1
  108535. };
  108536. if (colorRemapGradient.factor2 !== undefined) {
  108537. serializedGradient.factor2 = colorRemapGradient.factor2;
  108538. }
  108539. serializationObject.colorRemapGradients.push(serializedGradient);
  108540. }
  108541. }
  108542. var alphaRemapGradients = particleSystem.getAlphaRemapGradients();
  108543. if (alphaRemapGradients) {
  108544. serializationObject.alphaRemapGradients = [];
  108545. for (var _c = 0, alphaRemapGradients_1 = alphaRemapGradients; _c < alphaRemapGradients_1.length; _c++) {
  108546. var alphaRemapGradient = alphaRemapGradients_1[_c];
  108547. var serializedGradient = {
  108548. gradient: alphaRemapGradient.gradient,
  108549. factor1: alphaRemapGradient.factor1
  108550. };
  108551. if (alphaRemapGradient.factor2 !== undefined) {
  108552. serializedGradient.factor2 = alphaRemapGradient.factor2;
  108553. }
  108554. serializationObject.alphaRemapGradients.push(serializedGradient);
  108555. }
  108556. }
  108557. var sizeGradients = particleSystem.getSizeGradients();
  108558. if (sizeGradients) {
  108559. serializationObject.sizeGradients = [];
  108560. for (var _d = 0, sizeGradients_1 = sizeGradients; _d < sizeGradients_1.length; _d++) {
  108561. var sizeGradient = sizeGradients_1[_d];
  108562. var serializedGradient = {
  108563. gradient: sizeGradient.gradient,
  108564. factor1: sizeGradient.factor1
  108565. };
  108566. if (sizeGradient.factor2 !== undefined) {
  108567. serializedGradient.factor2 = sizeGradient.factor2;
  108568. }
  108569. serializationObject.sizeGradients.push(serializedGradient);
  108570. }
  108571. }
  108572. var angularSpeedGradients = particleSystem.getAngularSpeedGradients();
  108573. if (angularSpeedGradients) {
  108574. serializationObject.angularSpeedGradients = [];
  108575. for (var _e = 0, angularSpeedGradients_1 = angularSpeedGradients; _e < angularSpeedGradients_1.length; _e++) {
  108576. var angularSpeedGradient = angularSpeedGradients_1[_e];
  108577. var serializedGradient = {
  108578. gradient: angularSpeedGradient.gradient,
  108579. factor1: angularSpeedGradient.factor1
  108580. };
  108581. if (angularSpeedGradient.factor2 !== undefined) {
  108582. serializedGradient.factor2 = angularSpeedGradient.factor2;
  108583. }
  108584. serializationObject.angularSpeedGradients.push(serializedGradient);
  108585. }
  108586. }
  108587. var velocityGradients = particleSystem.getVelocityGradients();
  108588. if (velocityGradients) {
  108589. serializationObject.velocityGradients = [];
  108590. for (var _f = 0, velocityGradients_1 = velocityGradients; _f < velocityGradients_1.length; _f++) {
  108591. var velocityGradient = velocityGradients_1[_f];
  108592. var serializedGradient = {
  108593. gradient: velocityGradient.gradient,
  108594. factor1: velocityGradient.factor1
  108595. };
  108596. if (velocityGradient.factor2 !== undefined) {
  108597. serializedGradient.factor2 = velocityGradient.factor2;
  108598. }
  108599. serializationObject.velocityGradients.push(serializedGradient);
  108600. }
  108601. }
  108602. var dragGradients = particleSystem.getDragGradients();
  108603. if (dragGradients) {
  108604. serializationObject.dragyGradients = [];
  108605. for (var _g = 0, dragGradients_1 = dragGradients; _g < dragGradients_1.length; _g++) {
  108606. var dragGradient = dragGradients_1[_g];
  108607. var serializedGradient = {
  108608. gradient: dragGradient.gradient,
  108609. factor1: dragGradient.factor1
  108610. };
  108611. if (dragGradient.factor2 !== undefined) {
  108612. serializedGradient.factor2 = dragGradient.factor2;
  108613. }
  108614. serializationObject.dragGradients.push(serializedGradient);
  108615. }
  108616. }
  108617. var emitRateGradients = particleSystem.getEmitRateGradients();
  108618. if (emitRateGradients) {
  108619. serializationObject.emitRateGradients = [];
  108620. for (var _h = 0, emitRateGradients_1 = emitRateGradients; _h < emitRateGradients_1.length; _h++) {
  108621. var emitRateGradient = emitRateGradients_1[_h];
  108622. var serializedGradient = {
  108623. gradient: emitRateGradient.gradient,
  108624. factor1: emitRateGradient.factor1
  108625. };
  108626. if (emitRateGradient.factor2 !== undefined) {
  108627. serializedGradient.factor2 = emitRateGradient.factor2;
  108628. }
  108629. serializationObject.emitRateGradients.push(serializedGradient);
  108630. }
  108631. }
  108632. var startSizeGradients = particleSystem.getStartSizeGradients();
  108633. if (startSizeGradients) {
  108634. serializationObject.startSizeGradients = [];
  108635. for (var _j = 0, startSizeGradients_1 = startSizeGradients; _j < startSizeGradients_1.length; _j++) {
  108636. var startSizeGradient = startSizeGradients_1[_j];
  108637. var serializedGradient = {
  108638. gradient: startSizeGradient.gradient,
  108639. factor1: startSizeGradient.factor1
  108640. };
  108641. if (startSizeGradient.factor2 !== undefined) {
  108642. serializedGradient.factor2 = startSizeGradient.factor2;
  108643. }
  108644. serializationObject.startSizeGradients.push(serializedGradient);
  108645. }
  108646. }
  108647. var lifeTimeGradients = particleSystem.getLifeTimeGradients();
  108648. if (lifeTimeGradients) {
  108649. serializationObject.lifeTimeGradients = [];
  108650. for (var _k = 0, lifeTimeGradients_1 = lifeTimeGradients; _k < lifeTimeGradients_1.length; _k++) {
  108651. var lifeTimeGradient = lifeTimeGradients_1[_k];
  108652. var serializedGradient = {
  108653. gradient: lifeTimeGradient.gradient,
  108654. factor1: lifeTimeGradient.factor1
  108655. };
  108656. if (lifeTimeGradient.factor2 !== undefined) {
  108657. serializedGradient.factor2 = lifeTimeGradient.factor2;
  108658. }
  108659. serializationObject.lifeTimeGradients.push(serializedGradient);
  108660. }
  108661. }
  108662. var limitVelocityGradients = particleSystem.getLimitVelocityGradients();
  108663. if (limitVelocityGradients) {
  108664. serializationObject.limitVelocityGradients = [];
  108665. for (var _l = 0, limitVelocityGradients_1 = limitVelocityGradients; _l < limitVelocityGradients_1.length; _l++) {
  108666. var limitVelocityGradient = limitVelocityGradients_1[_l];
  108667. var serializedGradient = {
  108668. gradient: limitVelocityGradient.gradient,
  108669. factor1: limitVelocityGradient.factor1
  108670. };
  108671. if (limitVelocityGradient.factor2 !== undefined) {
  108672. serializedGradient.factor2 = limitVelocityGradient.factor2;
  108673. }
  108674. serializationObject.limitVelocityGradients.push(serializedGradient);
  108675. }
  108676. serializationObject.limitVelocityDamping = particleSystem.limitVelocityDamping;
  108677. }
  108678. if (particleSystem.noiseTexture) {
  108679. serializationObject.noiseTexture = particleSystem.noiseTexture.serialize();
  108680. }
  108681. };
  108682. /** @hidden */
  108683. ParticleSystem._Parse = function (parsedParticleSystem, particleSystem, scene, rootUrl) {
  108684. // Texture
  108685. if (parsedParticleSystem.textureName) {
  108686. particleSystem.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__["Texture"](rootUrl + parsedParticleSystem.textureName, scene, false, parsedParticleSystem.invertY !== undefined ? parsedParticleSystem.invertY : true);
  108687. particleSystem.particleTexture.name = parsedParticleSystem.textureName;
  108688. }
  108689. // Emitter
  108690. if (!parsedParticleSystem.emitterId && parsedParticleSystem.emitterId !== 0 && parsedParticleSystem.emitter === undefined) {
  108691. particleSystem.emitter = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  108692. }
  108693. else if (parsedParticleSystem.emitterId) {
  108694. particleSystem.emitter = scene.getLastMeshByID(parsedParticleSystem.emitterId);
  108695. }
  108696. else {
  108697. particleSystem.emitter = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.emitter);
  108698. }
  108699. // Misc.
  108700. if (parsedParticleSystem.renderingGroupId !== undefined) {
  108701. particleSystem.renderingGroupId = parsedParticleSystem.renderingGroupId;
  108702. }
  108703. if (parsedParticleSystem.isBillboardBased !== undefined) {
  108704. particleSystem.isBillboardBased = parsedParticleSystem.isBillboardBased;
  108705. }
  108706. if (parsedParticleSystem.billboardMode !== undefined) {
  108707. particleSystem.billboardMode = parsedParticleSystem.billboardMode;
  108708. }
  108709. // Animations
  108710. if (parsedParticleSystem.animations) {
  108711. for (var animationIndex = 0; animationIndex < parsedParticleSystem.animations.length; animationIndex++) {
  108712. var parsedAnimation = parsedParticleSystem.animations[animationIndex];
  108713. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_21__["_TypeStore"].GetClass("BABYLON.Animation");
  108714. if (internalClass) {
  108715. particleSystem.animations.push(internalClass.Parse(parsedAnimation));
  108716. }
  108717. }
  108718. particleSystem.beginAnimationOnStart = parsedParticleSystem.beginAnimationOnStart;
  108719. particleSystem.beginAnimationFrom = parsedParticleSystem.beginAnimationFrom;
  108720. particleSystem.beginAnimationTo = parsedParticleSystem.beginAnimationTo;
  108721. particleSystem.beginAnimationLoop = parsedParticleSystem.beginAnimationLoop;
  108722. }
  108723. if (parsedParticleSystem.autoAnimate) {
  108724. scene.beginAnimation(particleSystem, parsedParticleSystem.autoAnimateFrom, parsedParticleSystem.autoAnimateTo, parsedParticleSystem.autoAnimateLoop, parsedParticleSystem.autoAnimateSpeed || 1.0);
  108725. }
  108726. // Particle system
  108727. particleSystem.startDelay = parsedParticleSystem.startDelay | 0;
  108728. particleSystem.minAngularSpeed = parsedParticleSystem.minAngularSpeed;
  108729. particleSystem.maxAngularSpeed = parsedParticleSystem.maxAngularSpeed;
  108730. particleSystem.minSize = parsedParticleSystem.minSize;
  108731. particleSystem.maxSize = parsedParticleSystem.maxSize;
  108732. if (parsedParticleSystem.minScaleX) {
  108733. particleSystem.minScaleX = parsedParticleSystem.minScaleX;
  108734. particleSystem.maxScaleX = parsedParticleSystem.maxScaleX;
  108735. particleSystem.minScaleY = parsedParticleSystem.minScaleY;
  108736. particleSystem.maxScaleY = parsedParticleSystem.maxScaleY;
  108737. }
  108738. if (parsedParticleSystem.preWarmCycles !== undefined) {
  108739. particleSystem.preWarmCycles = parsedParticleSystem.preWarmCycles;
  108740. particleSystem.preWarmStepOffset = parsedParticleSystem.preWarmStepOffset;
  108741. }
  108742. if (parsedParticleSystem.minInitialRotation !== undefined) {
  108743. particleSystem.minInitialRotation = parsedParticleSystem.minInitialRotation;
  108744. particleSystem.maxInitialRotation = parsedParticleSystem.maxInitialRotation;
  108745. }
  108746. particleSystem.minLifeTime = parsedParticleSystem.minLifeTime;
  108747. particleSystem.maxLifeTime = parsedParticleSystem.maxLifeTime;
  108748. particleSystem.minEmitPower = parsedParticleSystem.minEmitPower;
  108749. particleSystem.maxEmitPower = parsedParticleSystem.maxEmitPower;
  108750. particleSystem.emitRate = parsedParticleSystem.emitRate;
  108751. particleSystem.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.gravity);
  108752. if (parsedParticleSystem.noiseStrength) {
  108753. particleSystem.noiseStrength = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.noiseStrength);
  108754. }
  108755. particleSystem.color1 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.color1);
  108756. particleSystem.color2 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.color2);
  108757. particleSystem.colorDead = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.colorDead);
  108758. particleSystem.updateSpeed = parsedParticleSystem.updateSpeed;
  108759. particleSystem.targetStopDuration = parsedParticleSystem.targetStopDuration;
  108760. particleSystem.blendMode = parsedParticleSystem.blendMode;
  108761. if (parsedParticleSystem.colorGradients) {
  108762. for (var _i = 0, _a = parsedParticleSystem.colorGradients; _i < _a.length; _i++) {
  108763. var colorGradient = _a[_i];
  108764. 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);
  108765. }
  108766. }
  108767. if (parsedParticleSystem.rampGradients) {
  108768. for (var _b = 0, _c = parsedParticleSystem.rampGradients; _b < _c.length; _b++) {
  108769. var rampGradient = _c[_b];
  108770. particleSystem.addRampGradient(rampGradient.gradient, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].FromArray(rampGradient.color));
  108771. }
  108772. particleSystem.useRampGradients = parsedParticleSystem.useRampGradients;
  108773. }
  108774. if (parsedParticleSystem.colorRemapGradients) {
  108775. for (var _d = 0, _e = parsedParticleSystem.colorRemapGradients; _d < _e.length; _d++) {
  108776. var colorRemapGradient = _e[_d];
  108777. particleSystem.addColorRemapGradient(colorRemapGradient.gradient, colorRemapGradient.factor1 !== undefined ? colorRemapGradient.factor1 : colorRemapGradient.factor, colorRemapGradient.factor2);
  108778. }
  108779. }
  108780. if (parsedParticleSystem.alphaRemapGradients) {
  108781. for (var _f = 0, _g = parsedParticleSystem.alphaRemapGradients; _f < _g.length; _f++) {
  108782. var alphaRemapGradient = _g[_f];
  108783. particleSystem.addAlphaRemapGradient(alphaRemapGradient.gradient, alphaRemapGradient.factor1 !== undefined ? alphaRemapGradient.factor1 : alphaRemapGradient.factor, alphaRemapGradient.factor2);
  108784. }
  108785. }
  108786. if (parsedParticleSystem.sizeGradients) {
  108787. for (var _h = 0, _j = parsedParticleSystem.sizeGradients; _h < _j.length; _h++) {
  108788. var sizeGradient = _j[_h];
  108789. particleSystem.addSizeGradient(sizeGradient.gradient, sizeGradient.factor1 !== undefined ? sizeGradient.factor1 : sizeGradient.factor, sizeGradient.factor2);
  108790. }
  108791. }
  108792. if (parsedParticleSystem.sizeGradients) {
  108793. for (var _k = 0, _l = parsedParticleSystem.sizeGradients; _k < _l.length; _k++) {
  108794. var sizeGradient = _l[_k];
  108795. particleSystem.addSizeGradient(sizeGradient.gradient, sizeGradient.factor1 !== undefined ? sizeGradient.factor1 : sizeGradient.factor, sizeGradient.factor2);
  108796. }
  108797. }
  108798. if (parsedParticleSystem.angularSpeedGradients) {
  108799. for (var _m = 0, _o = parsedParticleSystem.angularSpeedGradients; _m < _o.length; _m++) {
  108800. var angularSpeedGradient = _o[_m];
  108801. particleSystem.addAngularSpeedGradient(angularSpeedGradient.gradient, angularSpeedGradient.factor1 !== undefined ? angularSpeedGradient.factor1 : angularSpeedGradient.factor, angularSpeedGradient.factor2);
  108802. }
  108803. }
  108804. if (parsedParticleSystem.velocityGradients) {
  108805. for (var _p = 0, _q = parsedParticleSystem.velocityGradients; _p < _q.length; _p++) {
  108806. var velocityGradient = _q[_p];
  108807. particleSystem.addVelocityGradient(velocityGradient.gradient, velocityGradient.factor1 !== undefined ? velocityGradient.factor1 : velocityGradient.factor, velocityGradient.factor2);
  108808. }
  108809. }
  108810. if (parsedParticleSystem.dragGradients) {
  108811. for (var _r = 0, _s = parsedParticleSystem.dragGradients; _r < _s.length; _r++) {
  108812. var dragGradient = _s[_r];
  108813. particleSystem.addDragGradient(dragGradient.gradient, dragGradient.factor1 !== undefined ? dragGradient.factor1 : dragGradient.factor, dragGradient.factor2);
  108814. }
  108815. }
  108816. if (parsedParticleSystem.emitRateGradients) {
  108817. for (var _t = 0, _u = parsedParticleSystem.emitRateGradients; _t < _u.length; _t++) {
  108818. var emitRateGradient = _u[_t];
  108819. particleSystem.addEmitRateGradient(emitRateGradient.gradient, emitRateGradient.factor1 !== undefined ? emitRateGradient.factor1 : emitRateGradient.factor, emitRateGradient.factor2);
  108820. }
  108821. }
  108822. if (parsedParticleSystem.startSizeGradients) {
  108823. for (var _v = 0, _w = parsedParticleSystem.startSizeGradients; _v < _w.length; _v++) {
  108824. var startSizeGradient = _w[_v];
  108825. particleSystem.addStartSizeGradient(startSizeGradient.gradient, startSizeGradient.factor1 !== undefined ? startSizeGradient.factor1 : startSizeGradient.factor, startSizeGradient.factor2);
  108826. }
  108827. }
  108828. if (parsedParticleSystem.lifeTimeGradients) {
  108829. for (var _x = 0, _y = parsedParticleSystem.lifeTimeGradients; _x < _y.length; _x++) {
  108830. var lifeTimeGradient = _y[_x];
  108831. particleSystem.addLifeTimeGradient(lifeTimeGradient.gradient, lifeTimeGradient.factor1 !== undefined ? lifeTimeGradient.factor1 : lifeTimeGradient.factor, lifeTimeGradient.factor2);
  108832. }
  108833. }
  108834. if (parsedParticleSystem.limitVelocityGradients) {
  108835. for (var _z = 0, _0 = parsedParticleSystem.limitVelocityGradients; _z < _0.length; _z++) {
  108836. var limitVelocityGradient = _0[_z];
  108837. particleSystem.addLimitVelocityGradient(limitVelocityGradient.gradient, limitVelocityGradient.factor1 !== undefined ? limitVelocityGradient.factor1 : limitVelocityGradient.factor, limitVelocityGradient.factor2);
  108838. }
  108839. particleSystem.limitVelocityDamping = parsedParticleSystem.limitVelocityDamping;
  108840. }
  108841. if (parsedParticleSystem.noiseTexture) {
  108842. particleSystem.noiseTexture = _Materials_Textures_Procedurals_proceduralTexture__WEBPACK_IMPORTED_MODULE_12__["ProceduralTexture"].Parse(parsedParticleSystem.noiseTexture, scene, rootUrl);
  108843. }
  108844. // Emitter
  108845. var emitterType;
  108846. if (parsedParticleSystem.particleEmitterType) {
  108847. switch (parsedParticleSystem.particleEmitterType.type) {
  108848. case "SphereParticleEmitter":
  108849. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["SphereParticleEmitter"]();
  108850. break;
  108851. case "SphereDirectedParticleEmitter":
  108852. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["SphereDirectedParticleEmitter"]();
  108853. break;
  108854. case "ConeEmitter":
  108855. case "ConeParticleEmitter":
  108856. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["ConeParticleEmitter"]();
  108857. break;
  108858. case "CylinderParticleEmitter":
  108859. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["CylinderParticleEmitter"]();
  108860. break;
  108861. case "HemisphericParticleEmitter":
  108862. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["HemisphericParticleEmitter"]();
  108863. break;
  108864. case "BoxEmitter":
  108865. case "BoxParticleEmitter":
  108866. default:
  108867. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  108868. break;
  108869. }
  108870. emitterType.parse(parsedParticleSystem.particleEmitterType);
  108871. }
  108872. else {
  108873. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  108874. emitterType.parse(parsedParticleSystem);
  108875. }
  108876. particleSystem.particleEmitterType = emitterType;
  108877. // Animation sheet
  108878. particleSystem.startSpriteCellID = parsedParticleSystem.startSpriteCellID;
  108879. particleSystem.endSpriteCellID = parsedParticleSystem.endSpriteCellID;
  108880. particleSystem.spriteCellWidth = parsedParticleSystem.spriteCellWidth;
  108881. particleSystem.spriteCellHeight = parsedParticleSystem.spriteCellHeight;
  108882. particleSystem.spriteCellChangeSpeed = parsedParticleSystem.spriteCellChangeSpeed;
  108883. particleSystem.spriteRandomStartCell = parsedParticleSystem.spriteRandomStartCell;
  108884. };
  108885. /**
  108886. * Parses a JSON object to create a particle system.
  108887. * @param parsedParticleSystem The JSON object to parse
  108888. * @param scene The scene to create the particle system in
  108889. * @param rootUrl The root url to use to load external dependencies like texture
  108890. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  108891. * @returns the Parsed particle system
  108892. */
  108893. ParticleSystem.Parse = function (parsedParticleSystem, scene, rootUrl, doNotStart) {
  108894. if (doNotStart === void 0) { doNotStart = false; }
  108895. var name = parsedParticleSystem.name;
  108896. var custom = null;
  108897. var program = null;
  108898. if (parsedParticleSystem.customShader) {
  108899. program = parsedParticleSystem.customShader;
  108900. var defines = (program.shaderOptions.defines.length > 0) ? program.shaderOptions.defines.join("\n") : "";
  108901. custom = scene.getEngine().createEffectForParticles(program.shaderPath.fragmentElement, program.shaderOptions.uniforms, program.shaderOptions.samplers, defines);
  108902. }
  108903. var particleSystem = new ParticleSystem(name, parsedParticleSystem.capacity, scene, custom, parsedParticleSystem.isAnimationSheetEnabled);
  108904. particleSystem.customShader = program;
  108905. if (parsedParticleSystem.id) {
  108906. particleSystem.id = parsedParticleSystem.id;
  108907. }
  108908. // SubEmitters
  108909. if (parsedParticleSystem.subEmitters) {
  108910. particleSystem.subEmitters = [];
  108911. for (var _i = 0, _a = parsedParticleSystem.subEmitters; _i < _a.length; _i++) {
  108912. var cell = _a[_i];
  108913. var cellArray = [];
  108914. for (var _b = 0, cell_1 = cell; _b < cell_1.length; _b++) {
  108915. var sub = cell_1[_b];
  108916. cellArray.push(_subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"].Parse(sub, scene, rootUrl));
  108917. }
  108918. particleSystem.subEmitters.push(cellArray);
  108919. }
  108920. }
  108921. ParticleSystem._Parse(parsedParticleSystem, particleSystem, scene, rootUrl);
  108922. particleSystem.textureMask = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.textureMask);
  108923. // Auto start
  108924. if (parsedParticleSystem.preventAutoStart) {
  108925. particleSystem.preventAutoStart = parsedParticleSystem.preventAutoStart;
  108926. }
  108927. if (!doNotStart && !particleSystem.preventAutoStart) {
  108928. particleSystem.start();
  108929. }
  108930. return particleSystem;
  108931. };
  108932. /**
  108933. * Billboard mode will only apply to Y axis
  108934. */
  108935. ParticleSystem.BILLBOARDMODE_Y = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_Y;
  108936. /**
  108937. * Billboard mode will apply to all axes
  108938. */
  108939. ParticleSystem.BILLBOARDMODE_ALL = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_ALL;
  108940. /**
  108941. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  108942. */
  108943. ParticleSystem.BILLBOARDMODE_STRETCHED = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_STRETCHED;
  108944. return ParticleSystem;
  108945. }(_baseParticleSystem__WEBPACK_IMPORTED_MODULE_15__["BaseParticleSystem"]));
  108946. _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"]._ParseParticleSystem = ParticleSystem.Parse;
  108947. /***/ }),
  108948. /***/ "./Particles/particleSystemComponent.ts":
  108949. /*!**********************************************!*\
  108950. !*** ./Particles/particleSystemComponent.ts ***!
  108951. \**********************************************/
  108952. /*! exports provided: _IDoNeedToBeInTheBuild */
  108953. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  108954. "use strict";
  108955. __webpack_require__.r(__webpack_exports__);
  108956. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _IDoNeedToBeInTheBuild; });
  108957. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  108958. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  108959. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  108960. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  108961. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  108962. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  108963. /* harmony import */ var _Shaders_particles_vertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/particles.vertex */ "./Shaders/particles.vertex.ts");
  108964. // Adds the parsers to the scene parsers.
  108965. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM, function (parsedData, scene, container, rootUrl) {
  108966. var individualParser = _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].GetIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM);
  108967. if (!individualParser) {
  108968. return;
  108969. }
  108970. // Particles Systems
  108971. if (parsedData.particleSystems !== undefined && parsedData.particleSystems !== null) {
  108972. for (var index = 0, cache = parsedData.particleSystems.length; index < cache; index++) {
  108973. var parsedParticleSystem = parsedData.particleSystems[index];
  108974. container.particleSystems.push(individualParser(parsedParticleSystem, scene, rootUrl));
  108975. }
  108976. }
  108977. });
  108978. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM, function (parsedParticleSystem, scene, rootUrl) {
  108979. if (parsedParticleSystem.activeParticleCount) {
  108980. var ps = _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_1__["GPUParticleSystem"].Parse(parsedParticleSystem, scene, rootUrl);
  108981. return ps;
  108982. }
  108983. else {
  108984. var ps = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"].Parse(parsedParticleSystem, scene, rootUrl);
  108985. return ps;
  108986. }
  108987. });
  108988. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].prototype.createEffectForParticles = function (fragmentName, uniformsNames, samplers, defines, fallbacks, onCompiled, onError) {
  108989. if (uniformsNames === void 0) { uniformsNames = []; }
  108990. if (samplers === void 0) { samplers = []; }
  108991. if (defines === void 0) { defines = ""; }
  108992. var attributesNamesOrOptions = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"]._GetAttributeNamesOrOptions();
  108993. var effectCreationOption = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"]._GetEffectCreationOptions();
  108994. if (defines.indexOf(" BILLBOARD") === -1) {
  108995. defines += "\n#define BILLBOARD\n";
  108996. }
  108997. if (samplers.indexOf("diffuseSampler") === -1) {
  108998. samplers.push("diffuseSampler");
  108999. }
  109000. return this.createEffect({
  109001. vertex: "particles",
  109002. fragmentElement: fragmentName
  109003. }, attributesNamesOrOptions, effectCreationOption.concat(uniformsNames), samplers, defines, fallbacks, onCompiled, onError);
  109004. };
  109005. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].prototype.getEmittedParticleSystems = function () {
  109006. var results = new Array();
  109007. for (var index = 0; index < this.getScene().particleSystems.length; index++) {
  109008. var particleSystem = this.getScene().particleSystems[index];
  109009. if (particleSystem.emitter === this) {
  109010. results.push(particleSystem);
  109011. }
  109012. }
  109013. return results;
  109014. };
  109015. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].prototype.getHierarchyEmittedParticleSystems = function () {
  109016. var results = new Array();
  109017. var descendants = this.getDescendants();
  109018. descendants.push(this);
  109019. for (var index = 0; index < this.getScene().particleSystems.length; index++) {
  109020. var particleSystem = this.getScene().particleSystems[index];
  109021. var emitter = particleSystem.emitter;
  109022. if (emitter.position && descendants.indexOf(emitter) !== -1) {
  109023. results.push(particleSystem);
  109024. }
  109025. }
  109026. return results;
  109027. };
  109028. /**
  109029. * @hidden
  109030. */
  109031. var _IDoNeedToBeInTheBuild = 42;
  109032. /***/ }),
  109033. /***/ "./Particles/particleSystemSet.ts":
  109034. /*!****************************************!*\
  109035. !*** ./Particles/particleSystemSet.ts ***!
  109036. \****************************************/
  109037. /*! exports provided: ParticleSystemSet */
  109038. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109039. "use strict";
  109040. __webpack_require__.r(__webpack_exports__);
  109041. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return ParticleSystemSet; });
  109042. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  109043. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  109044. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  109045. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  109046. /* harmony import */ var _Particles_particleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Particles/particleSystem */ "./Particles/particleSystem.ts");
  109047. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  109048. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  109049. /** Internal class used to store shapes for emitters */
  109050. var ParticleSystemSetEmitterCreationOptions = /** @class */ (function () {
  109051. function ParticleSystemSetEmitterCreationOptions() {
  109052. }
  109053. return ParticleSystemSetEmitterCreationOptions;
  109054. }());
  109055. /**
  109056. * Represents a set of particle systems working together to create a specific effect
  109057. */
  109058. var ParticleSystemSet = /** @class */ (function () {
  109059. function ParticleSystemSet() {
  109060. /**
  109061. * Gets the particle system list
  109062. */
  109063. this.systems = new Array();
  109064. }
  109065. Object.defineProperty(ParticleSystemSet.prototype, "emitterNode", {
  109066. /**
  109067. * Gets the emitter node used with this set
  109068. */
  109069. get: function () {
  109070. return this._emitterNode;
  109071. },
  109072. enumerable: true,
  109073. configurable: true
  109074. });
  109075. /**
  109076. * Creates a new emitter mesh as a sphere
  109077. * @param options defines the options used to create the sphere
  109078. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  109079. * @param scene defines the hosting scene
  109080. */
  109081. ParticleSystemSet.prototype.setEmitterAsSphere = function (options, renderingGroupId, scene) {
  109082. if (this._emitterNode) {
  109083. this._emitterNode.dispose();
  109084. }
  109085. this._emitterCreationOptions = {
  109086. kind: "Sphere",
  109087. options: options,
  109088. renderingGroupId: renderingGroupId
  109089. };
  109090. var emitterMesh = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__["SphereBuilder"].CreateSphere("emitterSphere", { diameter: options.diameter, segments: options.segments }, scene);
  109091. emitterMesh.renderingGroupId = renderingGroupId;
  109092. var material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("emitterSphereMaterial", scene);
  109093. material.emissiveColor = options.color;
  109094. emitterMesh.material = material;
  109095. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  109096. var system = _a[_i];
  109097. system.emitter = emitterMesh;
  109098. }
  109099. this._emitterNode = emitterMesh;
  109100. };
  109101. /**
  109102. * Starts all particle systems of the set
  109103. * @param emitter defines an optional mesh to use as emitter for the particle systems
  109104. */
  109105. ParticleSystemSet.prototype.start = function (emitter) {
  109106. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  109107. var system = _a[_i];
  109108. if (emitter) {
  109109. system.emitter = emitter;
  109110. }
  109111. system.start();
  109112. }
  109113. };
  109114. /**
  109115. * Release all associated resources
  109116. */
  109117. ParticleSystemSet.prototype.dispose = function () {
  109118. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  109119. var system = _a[_i];
  109120. system.dispose();
  109121. }
  109122. this.systems = [];
  109123. if (this._emitterNode) {
  109124. this._emitterNode.dispose();
  109125. this._emitterNode = null;
  109126. }
  109127. };
  109128. /**
  109129. * Serialize the set into a JSON compatible object
  109130. * @returns a JSON compatible representation of the set
  109131. */
  109132. ParticleSystemSet.prototype.serialize = function () {
  109133. var result = {};
  109134. result.systems = [];
  109135. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  109136. var system = _a[_i];
  109137. result.systems.push(system.serialize());
  109138. }
  109139. if (this._emitterNode) {
  109140. result.emitter = this._emitterCreationOptions;
  109141. }
  109142. return result;
  109143. };
  109144. /**
  109145. * Parse a new ParticleSystemSet from a serialized source
  109146. * @param data defines a JSON compatible representation of the set
  109147. * @param scene defines the hosting scene
  109148. * @param gpu defines if we want GPU particles or CPU particles
  109149. * @returns a new ParticleSystemSet
  109150. */
  109151. ParticleSystemSet.Parse = function (data, scene, gpu) {
  109152. if (gpu === void 0) { gpu = false; }
  109153. var result = new ParticleSystemSet();
  109154. var rootUrl = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].PARTICLES_BaseAssetsUrl + "/textures/";
  109155. scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  109156. for (var _i = 0, _a = data.systems; _i < _a.length; _i++) {
  109157. var system = _a[_i];
  109158. 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));
  109159. }
  109160. if (data.emitter) {
  109161. var options = data.emitter.options;
  109162. switch (data.emitter.kind) {
  109163. case "Sphere":
  109164. result.setEmitterAsSphere({
  109165. diameter: options.diameter,
  109166. segments: options.segments,
  109167. color: _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].FromArray(options.color)
  109168. }, data.emitter.renderingGroupId, scene);
  109169. break;
  109170. }
  109171. }
  109172. return result;
  109173. };
  109174. return ParticleSystemSet;
  109175. }());
  109176. /***/ }),
  109177. /***/ "./Particles/solidParticle.ts":
  109178. /*!************************************!*\
  109179. !*** ./Particles/solidParticle.ts ***!
  109180. \************************************/
  109181. /*! exports provided: SolidParticle, ModelShape, DepthSortedParticle */
  109182. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109183. "use strict";
  109184. __webpack_require__.r(__webpack_exports__);
  109185. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return SolidParticle; });
  109186. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return ModelShape; });
  109187. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return DepthSortedParticle; });
  109188. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  109189. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  109190. /* harmony import */ var _Culling_boundingSphere__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Culling/boundingSphere */ "./Culling/boundingSphere.ts");
  109191. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  109192. /**
  109193. * Represents one particle of a solid particle system.
  109194. */
  109195. var SolidParticle = /** @class */ (function () {
  109196. /**
  109197. * Creates a Solid Particle object.
  109198. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  109199. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  109200. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  109201. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  109202. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  109203. * @param shapeId (integer) is the model shape identifier in the SPS.
  109204. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  109205. * @param sps defines the sps it is associated to
  109206. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  109207. */
  109208. function SolidParticle(particleIndex, positionIndex, indiceIndex, model, shapeId, idxInShape, sps, modelBoundingInfo) {
  109209. if (modelBoundingInfo === void 0) { modelBoundingInfo = null; }
  109210. /**
  109211. * particle global index
  109212. */
  109213. this.idx = 0;
  109214. /**
  109215. * The color of the particle
  109216. */
  109217. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  109218. /**
  109219. * The world space position of the particle.
  109220. */
  109221. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  109222. /**
  109223. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  109224. */
  109225. this.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  109226. /**
  109227. * The scaling of the particle.
  109228. */
  109229. this.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  109230. /**
  109231. * The uvs of the particle.
  109232. */
  109233. this.uvs = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  109234. /**
  109235. * The current speed of the particle.
  109236. */
  109237. this.velocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  109238. /**
  109239. * The pivot point in the particle local space.
  109240. */
  109241. this.pivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  109242. /**
  109243. * Must the particle be translated from its pivot point in its local space ?
  109244. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  109245. * Default : false
  109246. */
  109247. this.translateFromPivot = false;
  109248. /**
  109249. * Is the particle active or not ?
  109250. */
  109251. this.alive = true;
  109252. /**
  109253. * Is the particle visible or not ?
  109254. */
  109255. this.isVisible = true;
  109256. /**
  109257. * Index of this particle in the global "positions" array (Internal use)
  109258. * @hidden
  109259. */
  109260. this._pos = 0;
  109261. /**
  109262. * @hidden Index of this particle in the global "indices" array (Internal use)
  109263. */
  109264. this._ind = 0;
  109265. /**
  109266. * ModelShape id of this particle
  109267. */
  109268. this.shapeId = 0;
  109269. /**
  109270. * Index of the particle in its shape id (Internal use)
  109271. */
  109272. this.idxInShape = 0;
  109273. /**
  109274. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  109275. */
  109276. this._stillInvisible = false;
  109277. /**
  109278. * @hidden Last computed particle rotation matrix
  109279. */
  109280. this._rotationMatrix = [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0];
  109281. /**
  109282. * Parent particle Id, if any.
  109283. * Default null.
  109284. */
  109285. this.parentId = null;
  109286. /**
  109287. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  109288. * The possible values are :
  109289. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  109290. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  109291. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  109292. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  109293. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  109294. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  109295. * */
  109296. this.cullingStrategy = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"].CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY;
  109297. /**
  109298. * @hidden Internal global position in the SPS.
  109299. */
  109300. this._globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  109301. this.idx = particleIndex;
  109302. this._pos = positionIndex;
  109303. this._ind = indiceIndex;
  109304. this._model = model;
  109305. this.shapeId = shapeId;
  109306. this.idxInShape = idxInShape;
  109307. this._sps = sps;
  109308. if (modelBoundingInfo) {
  109309. this._modelBoundingInfo = modelBoundingInfo;
  109310. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_1__["BoundingInfo"](modelBoundingInfo.minimum, modelBoundingInfo.maximum);
  109311. }
  109312. }
  109313. Object.defineProperty(SolidParticle.prototype, "scale", {
  109314. /**
  109315. * Legacy support, changed scale to scaling
  109316. */
  109317. get: function () {
  109318. return this.scaling;
  109319. },
  109320. /**
  109321. * Legacy support, changed scale to scaling
  109322. */
  109323. set: function (scale) {
  109324. this.scaling = scale;
  109325. },
  109326. enumerable: true,
  109327. configurable: true
  109328. });
  109329. Object.defineProperty(SolidParticle.prototype, "quaternion", {
  109330. /**
  109331. * Legacy support, changed quaternion to rotationQuaternion
  109332. */
  109333. get: function () {
  109334. return this.rotationQuaternion;
  109335. },
  109336. /**
  109337. * Legacy support, changed quaternion to rotationQuaternion
  109338. */
  109339. set: function (q) {
  109340. this.rotationQuaternion = q;
  109341. },
  109342. enumerable: true,
  109343. configurable: true
  109344. });
  109345. /**
  109346. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  109347. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  109348. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  109349. * @returns true if it intersects
  109350. */
  109351. SolidParticle.prototype.intersectsMesh = function (target) {
  109352. if (!this._boundingInfo || !target._boundingInfo) {
  109353. return false;
  109354. }
  109355. if (this._sps._bSphereOnly) {
  109356. return _Culling_boundingSphere__WEBPACK_IMPORTED_MODULE_2__["BoundingSphere"].Intersects(this._boundingInfo.boundingSphere, target._boundingInfo.boundingSphere);
  109357. }
  109358. return this._boundingInfo.intersects(target._boundingInfo, false);
  109359. };
  109360. /**
  109361. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  109362. * A particle is in the frustum if its bounding box intersects the frustum
  109363. * @param frustumPlanes defines the frustum to test
  109364. * @returns true if the particle is in the frustum planes
  109365. */
  109366. SolidParticle.prototype.isInFrustum = function (frustumPlanes) {
  109367. return this._boundingInfo !== null && this._boundingInfo.isInFrustum(frustumPlanes, this.cullingStrategy);
  109368. };
  109369. /**
  109370. * get the rotation matrix of the particle
  109371. * @hidden
  109372. */
  109373. SolidParticle.prototype.getRotationMatrix = function (m) {
  109374. var quaternion;
  109375. if (this.rotationQuaternion) {
  109376. quaternion = this.rotationQuaternion;
  109377. }
  109378. else {
  109379. quaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Quaternion[0];
  109380. var rotation = this.rotation;
  109381. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, quaternion);
  109382. }
  109383. quaternion.toRotationMatrix(m);
  109384. };
  109385. return SolidParticle;
  109386. }());
  109387. /**
  109388. * Represents the shape of the model used by one particle of a solid particle system.
  109389. * SPS internal tool, don't use it manually.
  109390. */
  109391. var ModelShape = /** @class */ (function () {
  109392. /**
  109393. * 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.
  109394. * SPS internal tool, don't use it manually.
  109395. * @hidden
  109396. */
  109397. function ModelShape(id, shape, indicesLength, shapeUV, posFunction, vtxFunction) {
  109398. /**
  109399. * length of the shape in the model indices array (internal use)
  109400. * @hidden
  109401. */
  109402. this._indicesLength = 0;
  109403. this.shapeID = id;
  109404. this._shape = shape;
  109405. this._indicesLength = indicesLength;
  109406. this._shapeUV = shapeUV;
  109407. this._positionFunction = posFunction;
  109408. this._vertexFunction = vtxFunction;
  109409. }
  109410. return ModelShape;
  109411. }());
  109412. /**
  109413. * Represents a Depth Sorted Particle in the solid particle system.
  109414. */
  109415. var DepthSortedParticle = /** @class */ (function () {
  109416. function DepthSortedParticle() {
  109417. /**
  109418. * Index of the particle in the "indices" array
  109419. */
  109420. this.ind = 0;
  109421. /**
  109422. * Length of the particle shape in the "indices" array
  109423. */
  109424. this.indicesLength = 0;
  109425. /**
  109426. * Squared distance from the particle to the camera
  109427. */
  109428. this.sqDistance = 0.0;
  109429. }
  109430. return DepthSortedParticle;
  109431. }());
  109432. /***/ }),
  109433. /***/ "./Particles/solidParticleSystem.ts":
  109434. /*!******************************************!*\
  109435. !*** ./Particles/solidParticleSystem.ts ***!
  109436. \******************************************/
  109437. /*! exports provided: SolidParticleSystem */
  109438. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109439. "use strict";
  109440. __webpack_require__.r(__webpack_exports__);
  109441. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return SolidParticleSystem; });
  109442. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  109443. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  109444. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  109445. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  109446. /* harmony import */ var _Meshes_Builders_discBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/discBuilder */ "./Meshes/Builders/discBuilder.ts");
  109447. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  109448. /* harmony import */ var _solidParticle__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./solidParticle */ "./Particles/solidParticle.ts");
  109449. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  109450. var depthSortFunction = function (p1, p2) { return p2.sqDistance - p1.sqDistance; };
  109451. /**
  109452. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  109453. *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.
  109454. * The SPS is also a particle system. It provides some methods to manage the particles.
  109455. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  109456. *
  109457. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  109458. */
  109459. var SolidParticleSystem = /** @class */ (function () {
  109460. /**
  109461. * Creates a SPS (Solid Particle System) object.
  109462. * @param name (String) is the SPS name, this will be the underlying mesh name.
  109463. * @param scene (Scene) is the scene in which the SPS is added.
  109464. * @param options defines the options of the sps e.g.
  109465. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  109466. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  109467. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  109468. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  109469. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  109470. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  109471. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  109472. */
  109473. function SolidParticleSystem(name, scene, options) {
  109474. /**
  109475. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  109476. * Example : var p = SPS.particles[i];
  109477. */
  109478. this.particles = new Array();
  109479. /**
  109480. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  109481. */
  109482. this.nbParticles = 0;
  109483. /**
  109484. * If the particles must ever face the camera (default false). Useful for planar particles.
  109485. */
  109486. this.billboard = false;
  109487. /**
  109488. * Recompute normals when adding a shape
  109489. */
  109490. this.recomputeNormals = true;
  109491. /**
  109492. * This a counter ofr your own usage. It's not set by any SPS functions.
  109493. */
  109494. this.counter = 0;
  109495. /**
  109496. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  109497. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  109498. */
  109499. this.vars = {};
  109500. /**
  109501. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  109502. * @hidden
  109503. */
  109504. this._bSphereOnly = false;
  109505. /**
  109506. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  109507. * @hidden
  109508. */
  109509. this._bSphereRadiusFactor = 1.0;
  109510. this._positions = new Array();
  109511. this._indices = new Array();
  109512. this._normals = new Array();
  109513. this._colors = new Array();
  109514. this._uvs = new Array();
  109515. this._index = 0; // indices index
  109516. this._updatable = true;
  109517. this._pickable = false;
  109518. this._isVisibilityBoxLocked = false;
  109519. this._alwaysVisible = false;
  109520. this._depthSort = false;
  109521. this._shapeCounter = 0;
  109522. this._copy = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["SolidParticle"](0, 0, 0, null, 0, 0, this);
  109523. this._color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  109524. this._computeParticleColor = true;
  109525. this._computeParticleTexture = true;
  109526. this._computeParticleRotation = true;
  109527. this._computeParticleVertex = false;
  109528. this._computeBoundingBox = false;
  109529. this._depthSortParticles = true;
  109530. this._mustUnrotateFixedNormals = false;
  109531. this._particlesIntersect = false;
  109532. this._needs32Bits = false;
  109533. this.name = name;
  109534. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  109535. this._camera = scene.activeCamera;
  109536. this._pickable = options ? options.isPickable : false;
  109537. this._depthSort = options ? options.enableDepthSort : false;
  109538. this._particlesIntersect = options ? options.particleIntersection : false;
  109539. this._bSphereOnly = options ? options.boundingSphereOnly : false;
  109540. this._bSphereRadiusFactor = (options && options.bSphereRadiusFactor) ? options.bSphereRadiusFactor : 1.0;
  109541. if (options && options.updatable !== undefined) {
  109542. this._updatable = options.updatable;
  109543. }
  109544. else {
  109545. this._updatable = true;
  109546. }
  109547. if (this._pickable) {
  109548. this.pickedParticles = [];
  109549. }
  109550. if (this._depthSort) {
  109551. this.depthSortedParticles = [];
  109552. }
  109553. }
  109554. /**
  109555. * Builds the SPS underlying mesh. Returns a standard Mesh.
  109556. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  109557. * @returns the created mesh
  109558. */
  109559. SolidParticleSystem.prototype.buildMesh = function () {
  109560. if (this.nbParticles === 0) {
  109561. var triangle = _Meshes_Builders_discBuilder__WEBPACK_IMPORTED_MODULE_4__["DiscBuilder"].CreateDisc("", { radius: 1, tessellation: 3 }, this._scene);
  109562. this.addShape(triangle, 1);
  109563. triangle.dispose();
  109564. }
  109565. this._indices32 = (this._needs32Bits) ? new Uint32Array(this._indices) : new Uint16Array(this._indices);
  109566. this._positions32 = new Float32Array(this._positions);
  109567. this._uvs32 = new Float32Array(this._uvs);
  109568. this._colors32 = new Float32Array(this._colors);
  109569. if (this.recomputeNormals) {
  109570. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(this._positions32, this._indices32, this._normals);
  109571. }
  109572. this._normals32 = new Float32Array(this._normals);
  109573. this._fixedNormal32 = new Float32Array(this._normals);
  109574. if (this._mustUnrotateFixedNormals) { // the particles could be created already rotated in the mesh with a positionFunction
  109575. this._unrotateFixedNormals();
  109576. }
  109577. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  109578. vertexData.indices = (this._depthSort) ? this._indices : this._indices32;
  109579. vertexData.set(this._positions32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  109580. vertexData.set(this._normals32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  109581. if (this._uvs32.length > 0) {
  109582. vertexData.set(this._uvs32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  109583. }
  109584. if (this._colors32.length > 0) {
  109585. vertexData.set(this._colors32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  109586. }
  109587. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](this.name, this._scene);
  109588. vertexData.applyToMesh(mesh, this._updatable);
  109589. this.mesh = mesh;
  109590. this.mesh.isPickable = this._pickable;
  109591. // free memory
  109592. if (!this._depthSort) {
  109593. this._indices = null;
  109594. }
  109595. this._positions = null;
  109596. this._normals = null;
  109597. this._uvs = null;
  109598. this._colors = null;
  109599. if (!this._updatable) {
  109600. this.particles.length = 0;
  109601. }
  109602. return mesh;
  109603. };
  109604. /**
  109605. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  109606. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  109607. * Thus the particles generated from `digest()` have their property `position` set yet.
  109608. * @param mesh ( Mesh ) is the mesh to be digested
  109609. * @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
  109610. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  109611. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  109612. * @returns the current SPS
  109613. */
  109614. SolidParticleSystem.prototype.digest = function (mesh, options) {
  109615. var size = (options && options.facetNb) || 1;
  109616. var number = (options && options.number) || 0;
  109617. var delta = (options && options.delta) || 0;
  109618. var meshPos = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  109619. var meshInd = mesh.getIndices();
  109620. var meshUV = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  109621. var meshCol = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  109622. var meshNor = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  109623. var f = 0; // facet counter
  109624. var totalFacets = meshInd.length / 3; // a facet is a triangle, so 3 indices
  109625. // compute size from number
  109626. if (number) {
  109627. number = (number > totalFacets) ? totalFacets : number;
  109628. size = Math.round(totalFacets / number);
  109629. delta = 0;
  109630. }
  109631. else {
  109632. size = (size > totalFacets) ? totalFacets : size;
  109633. }
  109634. var facetPos = []; // submesh positions
  109635. var facetInd = []; // submesh indices
  109636. var facetUV = []; // submesh UV
  109637. var facetCol = []; // submesh colors
  109638. var barycenter = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  109639. var sizeO = size;
  109640. while (f < totalFacets) {
  109641. size = sizeO + Math.floor((1 + delta) * Math.random());
  109642. if (f > totalFacets - size) {
  109643. size = totalFacets - f;
  109644. }
  109645. // reset temp arrays
  109646. facetPos.length = 0;
  109647. facetInd.length = 0;
  109648. facetUV.length = 0;
  109649. facetCol.length = 0;
  109650. // iterate over "size" facets
  109651. var fi = 0;
  109652. for (var j = f * 3; j < (f + size) * 3; j++) {
  109653. facetInd.push(fi);
  109654. var i = meshInd[j];
  109655. facetPos.push(meshPos[i * 3], meshPos[i * 3 + 1], meshPos[i * 3 + 2]);
  109656. if (meshUV) {
  109657. facetUV.push(meshUV[i * 2], meshUV[i * 2 + 1]);
  109658. }
  109659. if (meshCol) {
  109660. facetCol.push(meshCol[i * 4], meshCol[i * 4 + 1], meshCol[i * 4 + 2], meshCol[i * 4 + 3]);
  109661. }
  109662. fi++;
  109663. }
  109664. // create a model shape for each single particle
  109665. var idx = this.nbParticles;
  109666. var shape = this._posToShape(facetPos);
  109667. var shapeUV = this._uvsToShapeUV(facetUV);
  109668. // compute the barycenter of the shape
  109669. var v;
  109670. for (v = 0; v < shape.length; v++) {
  109671. barycenter.addInPlace(shape[v]);
  109672. }
  109673. barycenter.scaleInPlace(1 / shape.length);
  109674. // shift the shape from its barycenter to the origin
  109675. for (v = 0; v < shape.length; v++) {
  109676. shape[v].subtractInPlace(barycenter);
  109677. }
  109678. var bInfo;
  109679. if (this._particlesIntersect) {
  109680. bInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__["BoundingInfo"](barycenter, barycenter);
  109681. }
  109682. var modelShape = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["ModelShape"](this._shapeCounter, shape, size * 3, shapeUV, null, null);
  109683. // add the particle in the SPS
  109684. var currentPos = this._positions.length;
  109685. var currentInd = this._indices.length;
  109686. this._meshBuilder(this._index, shape, this._positions, facetInd, this._indices, facetUV, this._uvs, facetCol, this._colors, meshNor, this._normals, idx, 0, null);
  109687. this._addParticle(idx, currentPos, currentInd, modelShape, this._shapeCounter, 0, bInfo);
  109688. // initialize the particle position
  109689. this.particles[this.nbParticles].position.addInPlace(barycenter);
  109690. this._index += shape.length;
  109691. idx++;
  109692. this.nbParticles++;
  109693. this._shapeCounter++;
  109694. f += size;
  109695. }
  109696. return this;
  109697. };
  109698. // unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  109699. SolidParticleSystem.prototype._unrotateFixedNormals = function () {
  109700. var index = 0;
  109701. var idx = 0;
  109702. var tmpNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  109703. var quaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Quaternion[0];
  109704. var invertedRotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  109705. for (var p = 0; p < this.particles.length; p++) {
  109706. var particle = this.particles[p];
  109707. var shape = particle._model._shape;
  109708. // computing the inverse of the rotation matrix from the quaternion
  109709. // is equivalent to computing the matrix of the inverse quaternion, i.e of the conjugate quaternion
  109710. if (particle.rotationQuaternion) {
  109711. particle.rotationQuaternion.conjugateToRef(quaternion);
  109712. }
  109713. else {
  109714. var rotation = particle.rotation;
  109715. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, quaternion);
  109716. quaternion.conjugateInPlace();
  109717. }
  109718. quaternion.toRotationMatrix(invertedRotMatrix);
  109719. for (var pt = 0; pt < shape.length; pt++) {
  109720. idx = index + pt * 3;
  109721. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalFromFloatsToRef(this._normals32[idx], this._normals32[idx + 1], this._normals32[idx + 2], invertedRotMatrix, tmpNormal);
  109722. tmpNormal.toArray(this._fixedNormal32, idx);
  109723. }
  109724. index = idx + 3;
  109725. }
  109726. };
  109727. //reset copy
  109728. SolidParticleSystem.prototype._resetCopy = function () {
  109729. var copy = this._copy;
  109730. copy.position.setAll(0);
  109731. copy.rotation.setAll(0);
  109732. copy.rotationQuaternion = null;
  109733. copy.scaling.setAll(1);
  109734. copy.uvs.copyFromFloats(0.0, 0.0, 1.0, 1.0);
  109735. copy.color = null;
  109736. copy.translateFromPivot = false;
  109737. };
  109738. // _meshBuilder : inserts the shape model in the global SPS mesh
  109739. SolidParticleSystem.prototype._meshBuilder = function (p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options) {
  109740. var i;
  109741. var u = 0;
  109742. var c = 0;
  109743. var n = 0;
  109744. this._resetCopy();
  109745. var copy = this._copy;
  109746. if (options && options.positionFunction) { // call to custom positionFunction
  109747. options.positionFunction(copy, idx, idxInShape);
  109748. this._mustUnrotateFixedNormals = true;
  109749. }
  109750. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  109751. var tmpVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  109752. var tmpRotated = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1];
  109753. var pivotBackTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[2];
  109754. var scaledPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[3];
  109755. copy.getRotationMatrix(rotMatrix);
  109756. copy.pivot.multiplyToRef(copy.scaling, scaledPivot);
  109757. if (copy.translateFromPivot) {
  109758. pivotBackTranslation.setAll(0.0);
  109759. }
  109760. else {
  109761. pivotBackTranslation.copyFrom(scaledPivot);
  109762. }
  109763. for (i = 0; i < shape.length; i++) {
  109764. tmpVertex.copyFrom(shape[i]);
  109765. if (options && options.vertexFunction) {
  109766. options.vertexFunction(copy, tmpVertex, i);
  109767. }
  109768. tmpVertex.multiplyInPlace(copy.scaling).subtractInPlace(scaledPivot);
  109769. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(tmpVertex, rotMatrix, tmpRotated);
  109770. tmpRotated.addInPlace(pivotBackTranslation).addInPlace(copy.position);
  109771. positions.push(tmpRotated.x, tmpRotated.y, tmpRotated.z);
  109772. if (meshUV) {
  109773. var copyUvs = copy.uvs;
  109774. uvs.push((copyUvs.z - copyUvs.x) * meshUV[u] + copyUvs.x, (copyUvs.w - copyUvs.y) * meshUV[u + 1] + copyUvs.y);
  109775. u += 2;
  109776. }
  109777. if (copy.color) {
  109778. this._color = copy.color;
  109779. }
  109780. else {
  109781. var color = this._color;
  109782. if (meshCol && meshCol[c] !== undefined) {
  109783. color.r = meshCol[c];
  109784. color.g = meshCol[c + 1];
  109785. color.b = meshCol[c + 2];
  109786. color.a = meshCol[c + 3];
  109787. }
  109788. else {
  109789. color.r = 1.0;
  109790. color.g = 1.0;
  109791. color.b = 1.0;
  109792. color.a = 1.0;
  109793. }
  109794. }
  109795. colors.push(this._color.r, this._color.g, this._color.b, this._color.a);
  109796. c += 4;
  109797. if (!this.recomputeNormals && meshNor) {
  109798. tmpVertex.x = meshNor[n];
  109799. tmpVertex.y = meshNor[n + 1];
  109800. tmpVertex.z = meshNor[n + 2];
  109801. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(tmpVertex, rotMatrix, tmpVertex);
  109802. normals.push(tmpVertex.x, tmpVertex.y, tmpVertex.z);
  109803. n += 3;
  109804. }
  109805. }
  109806. for (i = 0; i < meshInd.length; i++) {
  109807. var current_ind = p + meshInd[i];
  109808. indices.push(current_ind);
  109809. if (current_ind > 65535) {
  109810. this._needs32Bits = true;
  109811. }
  109812. }
  109813. if (this._pickable) {
  109814. var nbfaces = meshInd.length / 3;
  109815. for (i = 0; i < nbfaces; i++) {
  109816. this.pickedParticles.push({ idx: idx, faceId: i });
  109817. }
  109818. }
  109819. if (this._depthSort) {
  109820. this.depthSortedParticles.push(new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["DepthSortedParticle"]());
  109821. }
  109822. return copy;
  109823. };
  109824. // returns a shape array from positions array
  109825. SolidParticleSystem.prototype._posToShape = function (positions) {
  109826. var shape = [];
  109827. for (var i = 0; i < positions.length; i += 3) {
  109828. shape.push(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, i));
  109829. }
  109830. return shape;
  109831. };
  109832. // returns a shapeUV array from a Vector4 uvs
  109833. SolidParticleSystem.prototype._uvsToShapeUV = function (uvs) {
  109834. var shapeUV = [];
  109835. if (uvs) {
  109836. for (var i = 0; i < uvs.length; i++) {
  109837. shapeUV.push(uvs[i]);
  109838. }
  109839. }
  109840. return shapeUV;
  109841. };
  109842. // adds a new particle object in the particles array
  109843. SolidParticleSystem.prototype._addParticle = function (idx, idxpos, idxind, model, shapeId, idxInShape, bInfo) {
  109844. if (bInfo === void 0) { bInfo = null; }
  109845. var sp = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["SolidParticle"](idx, idxpos, idxind, model, shapeId, idxInShape, this, bInfo);
  109846. this.particles.push(sp);
  109847. return sp;
  109848. };
  109849. /**
  109850. * Adds some particles to the SPS from the model shape. Returns the shape id.
  109851. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  109852. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  109853. * @param nb (positive integer) the number of particles to be created from this model
  109854. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  109855. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  109856. * @returns the number of shapes in the system
  109857. */
  109858. SolidParticleSystem.prototype.addShape = function (mesh, nb, options) {
  109859. var meshPos = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  109860. var meshInd = mesh.getIndices();
  109861. var meshUV = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  109862. var meshCol = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  109863. var meshNor = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  109864. var bbInfo;
  109865. if (this._particlesIntersect) {
  109866. bbInfo = mesh.getBoundingInfo();
  109867. }
  109868. var shape = this._posToShape(meshPos);
  109869. var shapeUV = this._uvsToShapeUV(meshUV);
  109870. var posfunc = options ? options.positionFunction : null;
  109871. var vtxfunc = options ? options.vertexFunction : null;
  109872. var modelShape = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["ModelShape"](this._shapeCounter, shape, meshInd.length, shapeUV, posfunc, vtxfunc);
  109873. // particles
  109874. var sp;
  109875. var currentCopy;
  109876. var idx = this.nbParticles;
  109877. for (var i = 0; i < nb; i++) {
  109878. var currentPos = this._positions.length;
  109879. var currentInd = this._indices.length;
  109880. currentCopy = this._meshBuilder(this._index, shape, this._positions, meshInd, this._indices, meshUV, this._uvs, meshCol, this._colors, meshNor, this._normals, idx, i, options);
  109881. if (this._updatable) {
  109882. sp = this._addParticle(idx, currentPos, currentInd, modelShape, this._shapeCounter, i, bbInfo);
  109883. sp.position.copyFrom(currentCopy.position);
  109884. sp.rotation.copyFrom(currentCopy.rotation);
  109885. if (currentCopy.rotationQuaternion && sp.rotationQuaternion) {
  109886. sp.rotationQuaternion.copyFrom(currentCopy.rotationQuaternion);
  109887. }
  109888. if (currentCopy.color && sp.color) {
  109889. sp.color.copyFrom(currentCopy.color);
  109890. }
  109891. sp.scaling.copyFrom(currentCopy.scaling);
  109892. sp.uvs.copyFrom(currentCopy.uvs);
  109893. }
  109894. this._index += shape.length;
  109895. idx++;
  109896. }
  109897. this.nbParticles += nb;
  109898. this._shapeCounter++;
  109899. return this._shapeCounter - 1;
  109900. };
  109901. // rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  109902. SolidParticleSystem.prototype._rebuildParticle = function (particle) {
  109903. this._resetCopy();
  109904. var copy = this._copy;
  109905. if (particle._model._positionFunction) { // recall to stored custom positionFunction
  109906. particle._model._positionFunction(copy, particle.idx, particle.idxInShape);
  109907. }
  109908. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  109909. var tmpVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  109910. var tmpRotated = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1];
  109911. var pivotBackTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[2];
  109912. var scaledPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[3];
  109913. copy.getRotationMatrix(rotMatrix);
  109914. particle.pivot.multiplyToRef(particle.scaling, scaledPivot);
  109915. if (copy.translateFromPivot) {
  109916. pivotBackTranslation.copyFromFloats(0.0, 0.0, 0.0);
  109917. }
  109918. else {
  109919. pivotBackTranslation.copyFrom(scaledPivot);
  109920. }
  109921. var shape = particle._model._shape;
  109922. for (var pt = 0; pt < shape.length; pt++) {
  109923. tmpVertex.copyFrom(shape[pt]);
  109924. if (particle._model._vertexFunction) {
  109925. particle._model._vertexFunction(copy, tmpVertex, pt); // recall to stored vertexFunction
  109926. }
  109927. tmpVertex.multiplyInPlace(copy.scaling).subtractInPlace(scaledPivot);
  109928. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(tmpVertex, rotMatrix, tmpRotated);
  109929. tmpRotated.addInPlace(pivotBackTranslation).addInPlace(copy.position).toArray(this._positions32, particle._pos + pt * 3);
  109930. }
  109931. particle.position.setAll(0.0);
  109932. particle.rotation.setAll(0.0);
  109933. particle.rotationQuaternion = null;
  109934. particle.scaling.setAll(1.0);
  109935. particle.uvs.setAll(0.0);
  109936. particle.pivot.setAll(0.0);
  109937. particle.translateFromPivot = false;
  109938. particle.parentId = null;
  109939. };
  109940. /**
  109941. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  109942. * @returns the SPS.
  109943. */
  109944. SolidParticleSystem.prototype.rebuildMesh = function () {
  109945. for (var p = 0; p < this.particles.length; p++) {
  109946. this._rebuildParticle(this.particles[p]);
  109947. }
  109948. this.mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this._positions32, false, false);
  109949. return this;
  109950. };
  109951. /**
  109952. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  109953. * This method calls `updateParticle()` for each particle of the SPS.
  109954. * For an animated SPS, it is usually called within the render loop.
  109955. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  109956. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  109957. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  109958. * @returns the SPS.
  109959. */
  109960. SolidParticleSystem.prototype.setParticles = function (start, end, update) {
  109961. if (start === void 0) { start = 0; }
  109962. if (end === void 0) { end = this.nbParticles - 1; }
  109963. if (update === void 0) { update = true; }
  109964. if (!this._updatable) {
  109965. return this;
  109966. }
  109967. // custom beforeUpdate
  109968. this.beforeUpdateParticles(start, end, update);
  109969. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  109970. var invertedMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  109971. var mesh = this.mesh;
  109972. var colors32 = this._colors32;
  109973. var positions32 = this._positions32;
  109974. var normals32 = this._normals32;
  109975. var uvs32 = this._uvs32;
  109976. var indices32 = this._indices32;
  109977. var indices = this._indices;
  109978. var fixedNormal32 = this._fixedNormal32;
  109979. var tempVectors = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3;
  109980. var camAxisX = tempVectors[5].copyFromFloats(1.0, 0.0, 0.0);
  109981. var camAxisY = tempVectors[6].copyFromFloats(0.0, 1.0, 0.0);
  109982. var camAxisZ = tempVectors[7].copyFromFloats(0.0, 0.0, 1.0);
  109983. var minimum = tempVectors[8].setAll(Number.MAX_VALUE);
  109984. var maximum = tempVectors[9].setAll(-Number.MAX_VALUE);
  109985. var camInvertedPosition = tempVectors[10].setAll(0);
  109986. // cases when the World Matrix is to be computed first
  109987. if (this.billboard || this._depthSort) {
  109988. this.mesh.computeWorldMatrix(true);
  109989. this.mesh._worldMatrix.invertToRef(invertedMatrix);
  109990. }
  109991. // if the particles will always face the camera
  109992. if (this.billboard) {
  109993. // compute the camera position and un-rotate it by the current mesh rotation
  109994. var tmpVertex = tempVectors[0];
  109995. this._camera.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Axis"].Z, tmpVertex);
  109996. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(tmpVertex, invertedMatrix, camAxisZ);
  109997. camAxisZ.normalize();
  109998. // same for camera up vector extracted from the cam view matrix
  109999. var view = this._camera.getViewMatrix(true);
  110000. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalFromFloatsToRef(view.m[1], view.m[5], view.m[9], invertedMatrix, camAxisY);
  110001. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(camAxisY, camAxisZ, camAxisX);
  110002. camAxisY.normalize();
  110003. camAxisX.normalize();
  110004. }
  110005. // if depthSort, compute the camera global position in the mesh local system
  110006. if (this._depthSort) {
  110007. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this._camera.globalPosition, invertedMatrix, camInvertedPosition); // then un-rotate the camera
  110008. }
  110009. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityToRef(rotMatrix);
  110010. var idx = 0; // current position index in the global array positions32
  110011. var index = 0; // position start index in the global array positions32 of the current particle
  110012. var colidx = 0; // current color index in the global array colors32
  110013. var colorIndex = 0; // color start index in the global array colors32 of the current particle
  110014. var uvidx = 0; // current uv index in the global array uvs32
  110015. var uvIndex = 0; // uv start index in the global array uvs32 of the current particle
  110016. var pt = 0; // current index in the particle model shape
  110017. if (this.mesh.isFacetDataEnabled) {
  110018. this._computeBoundingBox = true;
  110019. }
  110020. end = (end >= this.nbParticles) ? this.nbParticles - 1 : end;
  110021. if (this._computeBoundingBox) {
  110022. if (start != 0 || end != this.nbParticles - 1) { // only some particles are updated, then use the current existing BBox basis. Note : it can only increase.
  110023. var boundingInfo = this.mesh._boundingInfo;
  110024. if (boundingInfo) {
  110025. minimum.copyFrom(boundingInfo.minimum);
  110026. maximum.copyFrom(boundingInfo.maximum);
  110027. }
  110028. }
  110029. }
  110030. // particle loop
  110031. index = this.particles[start]._pos;
  110032. var vpos = (index / 3) | 0;
  110033. colorIndex = vpos * 4;
  110034. uvIndex = vpos * 2;
  110035. for (var p = start; p <= end; p++) {
  110036. var particle = this.particles[p];
  110037. // call to custom user function to update the particle properties
  110038. this.updateParticle(particle);
  110039. var shape = particle._model._shape;
  110040. var shapeUV = particle._model._shapeUV;
  110041. var particleRotationMatrix = particle._rotationMatrix;
  110042. var particlePosition = particle.position;
  110043. var particleRotation = particle.rotation;
  110044. var particleScaling = particle.scaling;
  110045. var particleGlobalPosition = particle._globalPosition;
  110046. // camera-particle distance for depth sorting
  110047. if (this._depthSort && this._depthSortParticles) {
  110048. var dsp = this.depthSortedParticles[p];
  110049. dsp.ind = particle._ind;
  110050. dsp.indicesLength = particle._model._indicesLength;
  110051. dsp.sqDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].DistanceSquared(particle.position, camInvertedPosition);
  110052. }
  110053. // skip the computations for inactive or already invisible particles
  110054. if (!particle.alive || (particle._stillInvisible && !particle.isVisible)) {
  110055. // increment indexes for the next particle
  110056. pt = shape.length;
  110057. index += pt * 3;
  110058. colorIndex += pt * 4;
  110059. uvIndex += pt * 2;
  110060. continue;
  110061. }
  110062. if (particle.isVisible) {
  110063. particle._stillInvisible = false; // un-mark permanent invisibility
  110064. var scaledPivot = tempVectors[12];
  110065. particle.pivot.multiplyToRef(particleScaling, scaledPivot);
  110066. // particle rotation matrix
  110067. if (this.billboard) {
  110068. particleRotation.x = 0.0;
  110069. particleRotation.y = 0.0;
  110070. }
  110071. if (this._computeParticleRotation || this.billboard) {
  110072. particle.getRotationMatrix(rotMatrix);
  110073. }
  110074. var particleHasParent = (particle.parentId !== null);
  110075. if (particleHasParent) {
  110076. var parent_1 = this.particles[particle.parentId];
  110077. var parentRotationMatrix = parent_1._rotationMatrix;
  110078. var parentGlobalPosition = parent_1._globalPosition;
  110079. var rotatedY = particlePosition.x * parentRotationMatrix[1] + particlePosition.y * parentRotationMatrix[4] + particlePosition.z * parentRotationMatrix[7];
  110080. var rotatedX = particlePosition.x * parentRotationMatrix[0] + particlePosition.y * parentRotationMatrix[3] + particlePosition.z * parentRotationMatrix[6];
  110081. var rotatedZ = particlePosition.x * parentRotationMatrix[2] + particlePosition.y * parentRotationMatrix[5] + particlePosition.z * parentRotationMatrix[8];
  110082. particleGlobalPosition.x = parentGlobalPosition.x + rotatedX;
  110083. particleGlobalPosition.y = parentGlobalPosition.y + rotatedY;
  110084. particleGlobalPosition.z = parentGlobalPosition.z + rotatedZ;
  110085. if (this._computeParticleRotation || this.billboard) {
  110086. var rotMatrixValues = rotMatrix.m;
  110087. particleRotationMatrix[0] = rotMatrixValues[0] * parentRotationMatrix[0] + rotMatrixValues[1] * parentRotationMatrix[3] + rotMatrixValues[2] * parentRotationMatrix[6];
  110088. particleRotationMatrix[1] = rotMatrixValues[0] * parentRotationMatrix[1] + rotMatrixValues[1] * parentRotationMatrix[4] + rotMatrixValues[2] * parentRotationMatrix[7];
  110089. particleRotationMatrix[2] = rotMatrixValues[0] * parentRotationMatrix[2] + rotMatrixValues[1] * parentRotationMatrix[5] + rotMatrixValues[2] * parentRotationMatrix[8];
  110090. particleRotationMatrix[3] = rotMatrixValues[4] * parentRotationMatrix[0] + rotMatrixValues[5] * parentRotationMatrix[3] + rotMatrixValues[6] * parentRotationMatrix[6];
  110091. particleRotationMatrix[4] = rotMatrixValues[4] * parentRotationMatrix[1] + rotMatrixValues[5] * parentRotationMatrix[4] + rotMatrixValues[6] * parentRotationMatrix[7];
  110092. particleRotationMatrix[5] = rotMatrixValues[4] * parentRotationMatrix[2] + rotMatrixValues[5] * parentRotationMatrix[5] + rotMatrixValues[6] * parentRotationMatrix[8];
  110093. particleRotationMatrix[6] = rotMatrixValues[8] * parentRotationMatrix[0] + rotMatrixValues[9] * parentRotationMatrix[3] + rotMatrixValues[10] * parentRotationMatrix[6];
  110094. particleRotationMatrix[7] = rotMatrixValues[8] * parentRotationMatrix[1] + rotMatrixValues[9] * parentRotationMatrix[4] + rotMatrixValues[10] * parentRotationMatrix[7];
  110095. particleRotationMatrix[8] = rotMatrixValues[8] * parentRotationMatrix[2] + rotMatrixValues[9] * parentRotationMatrix[5] + rotMatrixValues[10] * parentRotationMatrix[8];
  110096. }
  110097. }
  110098. else {
  110099. particleGlobalPosition.x = particlePosition.x;
  110100. particleGlobalPosition.y = particlePosition.y;
  110101. particleGlobalPosition.z = particlePosition.z;
  110102. if (this._computeParticleRotation || this.billboard) {
  110103. var rotMatrixValues = rotMatrix.m;
  110104. particleRotationMatrix[0] = rotMatrixValues[0];
  110105. particleRotationMatrix[1] = rotMatrixValues[1];
  110106. particleRotationMatrix[2] = rotMatrixValues[2];
  110107. particleRotationMatrix[3] = rotMatrixValues[4];
  110108. particleRotationMatrix[4] = rotMatrixValues[5];
  110109. particleRotationMatrix[5] = rotMatrixValues[6];
  110110. particleRotationMatrix[6] = rotMatrixValues[8];
  110111. particleRotationMatrix[7] = rotMatrixValues[9];
  110112. particleRotationMatrix[8] = rotMatrixValues[10];
  110113. }
  110114. }
  110115. var pivotBackTranslation = tempVectors[11];
  110116. if (particle.translateFromPivot) {
  110117. pivotBackTranslation.setAll(0.0);
  110118. }
  110119. else {
  110120. pivotBackTranslation.copyFrom(scaledPivot);
  110121. }
  110122. // particle vertex loop
  110123. for (pt = 0; pt < shape.length; pt++) {
  110124. idx = index + pt * 3;
  110125. colidx = colorIndex + pt * 4;
  110126. uvidx = uvIndex + pt * 2;
  110127. var tmpVertex = tempVectors[0];
  110128. tmpVertex.copyFrom(shape[pt]);
  110129. if (this._computeParticleVertex) {
  110130. this.updateParticleVertex(particle, tmpVertex, pt);
  110131. }
  110132. // positions
  110133. var vertexX = tmpVertex.x * particleScaling.x - scaledPivot.x;
  110134. var vertexY = tmpVertex.y * particleScaling.y - scaledPivot.y;
  110135. var vertexZ = tmpVertex.z * particleScaling.z - scaledPivot.z;
  110136. var rotatedX = vertexX * particleRotationMatrix[0] + vertexY * particleRotationMatrix[3] + vertexZ * particleRotationMatrix[6];
  110137. var rotatedY = vertexX * particleRotationMatrix[1] + vertexY * particleRotationMatrix[4] + vertexZ * particleRotationMatrix[7];
  110138. var rotatedZ = vertexX * particleRotationMatrix[2] + vertexY * particleRotationMatrix[5] + vertexZ * particleRotationMatrix[8];
  110139. rotatedX += pivotBackTranslation.x;
  110140. rotatedY += pivotBackTranslation.y;
  110141. rotatedZ += pivotBackTranslation.z;
  110142. var px = positions32[idx] = particleGlobalPosition.x + camAxisX.x * rotatedX + camAxisY.x * rotatedY + camAxisZ.x * rotatedZ;
  110143. var py = positions32[idx + 1] = particleGlobalPosition.y + camAxisX.y * rotatedX + camAxisY.y * rotatedY + camAxisZ.y * rotatedZ;
  110144. var pz = positions32[idx + 2] = particleGlobalPosition.z + camAxisX.z * rotatedX + camAxisY.z * rotatedY + camAxisZ.z * rotatedZ;
  110145. if (this._computeBoundingBox) {
  110146. minimum.minimizeInPlaceFromFloats(px, py, pz);
  110147. maximum.maximizeInPlaceFromFloats(px, py, pz);
  110148. }
  110149. // normals : if the particles can't be morphed then just rotate the normals, what is much more faster than ComputeNormals()
  110150. if (!this._computeParticleVertex) {
  110151. var normalx = fixedNormal32[idx];
  110152. var normaly = fixedNormal32[idx + 1];
  110153. var normalz = fixedNormal32[idx + 2];
  110154. var rotatedx = normalx * particleRotationMatrix[0] + normaly * particleRotationMatrix[3] + normalz * particleRotationMatrix[6];
  110155. var rotatedy = normalx * particleRotationMatrix[1] + normaly * particleRotationMatrix[4] + normalz * particleRotationMatrix[7];
  110156. var rotatedz = normalx * particleRotationMatrix[2] + normaly * particleRotationMatrix[5] + normalz * particleRotationMatrix[8];
  110157. normals32[idx] = camAxisX.x * rotatedx + camAxisY.x * rotatedy + camAxisZ.x * rotatedz;
  110158. normals32[idx + 1] = camAxisX.y * rotatedx + camAxisY.y * rotatedy + camAxisZ.y * rotatedz;
  110159. normals32[idx + 2] = camAxisX.z * rotatedx + camAxisY.z * rotatedy + camAxisZ.z * rotatedz;
  110160. }
  110161. if (this._computeParticleColor && particle.color) {
  110162. var color = particle.color;
  110163. var colors32_1 = this._colors32;
  110164. colors32_1[colidx] = color.r;
  110165. colors32_1[colidx + 1] = color.g;
  110166. colors32_1[colidx + 2] = color.b;
  110167. colors32_1[colidx + 3] = color.a;
  110168. }
  110169. if (this._computeParticleTexture) {
  110170. var uvs = particle.uvs;
  110171. uvs32[uvidx] = shapeUV[pt * 2] * (uvs.z - uvs.x) + uvs.x;
  110172. uvs32[uvidx + 1] = shapeUV[pt * 2 + 1] * (uvs.w - uvs.y) + uvs.y;
  110173. }
  110174. }
  110175. }
  110176. // particle just set invisible : scaled to zero and positioned at the origin
  110177. else {
  110178. particle._stillInvisible = true; // mark the particle as invisible
  110179. for (pt = 0; pt < shape.length; pt++) {
  110180. idx = index + pt * 3;
  110181. colidx = colorIndex + pt * 4;
  110182. uvidx = uvIndex + pt * 2;
  110183. positions32[idx] = positions32[idx + 1] = positions32[idx + 2] = 0;
  110184. normals32[idx] = normals32[idx + 1] = normals32[idx + 2] = 0;
  110185. if (this._computeParticleColor && particle.color) {
  110186. var color = particle.color;
  110187. colors32[colidx] = color.r;
  110188. colors32[colidx + 1] = color.g;
  110189. colors32[colidx + 2] = color.b;
  110190. colors32[colidx + 3] = color.a;
  110191. }
  110192. if (this._computeParticleTexture) {
  110193. var uvs = particle.uvs;
  110194. uvs32[uvidx] = shapeUV[pt * 2] * (uvs.z - uvs.x) + uvs.x;
  110195. uvs32[uvidx + 1] = shapeUV[pt * 2 + 1] * (uvs.w - uvs.y) + uvs.y;
  110196. }
  110197. }
  110198. }
  110199. // if the particle intersections must be computed : update the bbInfo
  110200. if (this._particlesIntersect) {
  110201. var bInfo = particle._boundingInfo;
  110202. var bBox = bInfo.boundingBox;
  110203. var bSphere = bInfo.boundingSphere;
  110204. var modelBoundingInfo = particle._modelBoundingInfo;
  110205. if (!this._bSphereOnly) {
  110206. // place, scale and rotate the particle bbox within the SPS local system, then update it
  110207. var modelBoundingInfoVectors = modelBoundingInfo.boundingBox.vectors;
  110208. var tempMin = tempVectors[1];
  110209. var tempMax = tempVectors[2];
  110210. tempMin.setAll(Number.MAX_VALUE);
  110211. tempMax.setAll(-Number.MAX_VALUE);
  110212. for (var b = 0; b < 8; b++) {
  110213. var scaledX = modelBoundingInfoVectors[b].x * particleScaling.x;
  110214. var scaledY = modelBoundingInfoVectors[b].y * particleScaling.y;
  110215. var scaledZ = modelBoundingInfoVectors[b].z * particleScaling.z;
  110216. var rotatedX = scaledX * particleRotationMatrix[0] + scaledY * particleRotationMatrix[3] + scaledZ * particleRotationMatrix[6];
  110217. var rotatedY = scaledX * particleRotationMatrix[1] + scaledY * particleRotationMatrix[4] + scaledZ * particleRotationMatrix[7];
  110218. var rotatedZ = scaledX * particleRotationMatrix[2] + scaledY * particleRotationMatrix[5] + scaledZ * particleRotationMatrix[8];
  110219. var x = particlePosition.x + camAxisX.x * rotatedX + camAxisY.x * rotatedY + camAxisZ.x * rotatedZ;
  110220. var y = particlePosition.y + camAxisX.y * rotatedX + camAxisY.y * rotatedY + camAxisZ.y * rotatedZ;
  110221. var z = particlePosition.z + camAxisX.z * rotatedX + camAxisY.z * rotatedY + camAxisZ.z * rotatedZ;
  110222. tempMin.minimizeInPlaceFromFloats(x, y, z);
  110223. tempMax.maximizeInPlaceFromFloats(x, y, z);
  110224. }
  110225. bBox.reConstruct(tempMin, tempMax, mesh._worldMatrix);
  110226. }
  110227. // place and scale the particle bouding sphere in the SPS local system, then update it
  110228. var minBbox = modelBoundingInfo.minimum.multiplyToRef(particleScaling, tempVectors[1]);
  110229. var maxBbox = modelBoundingInfo.maximum.multiplyToRef(particleScaling, tempVectors[2]);
  110230. var bSphereCenter = maxBbox.addToRef(minBbox, tempVectors[3]).scaleInPlace(0.5).addInPlace(particleGlobalPosition);
  110231. var halfDiag = maxBbox.subtractToRef(minBbox, tempVectors[4]).scaleInPlace(0.5 * this._bSphereRadiusFactor);
  110232. var bSphereMinBbox = bSphereCenter.subtractToRef(halfDiag, tempVectors[1]);
  110233. var bSphereMaxBbox = bSphereCenter.addToRef(halfDiag, tempVectors[2]);
  110234. bSphere.reConstruct(bSphereMinBbox, bSphereMaxBbox, mesh._worldMatrix);
  110235. }
  110236. // increment indexes for the next particle
  110237. index = idx + 3;
  110238. colorIndex = colidx + 4;
  110239. uvIndex = uvidx + 2;
  110240. }
  110241. // if the VBO must be updated
  110242. if (update) {
  110243. if (this._computeParticleColor) {
  110244. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, colors32, false, false);
  110245. }
  110246. if (this._computeParticleTexture) {
  110247. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, uvs32, false, false);
  110248. }
  110249. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, positions32, false, false);
  110250. if (!mesh.areNormalsFrozen || mesh.isFacetDataEnabled) {
  110251. if (this._computeParticleVertex || mesh.isFacetDataEnabled) {
  110252. // recompute the normals only if the particles can be morphed, update then also the normal reference array _fixedNormal32[]
  110253. var params = mesh.isFacetDataEnabled ? mesh.getFacetDataParameters() : null;
  110254. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions32, indices32, normals32, params);
  110255. for (var i = 0; i < normals32.length; i++) {
  110256. fixedNormal32[i] = normals32[i];
  110257. }
  110258. }
  110259. if (!mesh.areNormalsFrozen) {
  110260. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, normals32, false, false);
  110261. }
  110262. }
  110263. if (this._depthSort && this._depthSortParticles) {
  110264. var depthSortedParticles = this.depthSortedParticles;
  110265. depthSortedParticles.sort(depthSortFunction);
  110266. var dspl = depthSortedParticles.length;
  110267. var sid = 0;
  110268. for (var sorted = 0; sorted < dspl; sorted++) {
  110269. var lind = depthSortedParticles[sorted].indicesLength;
  110270. var sind = depthSortedParticles[sorted].ind;
  110271. for (var i = 0; i < lind; i++) {
  110272. indices32[sid] = indices[sind + i];
  110273. sid++;
  110274. }
  110275. }
  110276. mesh.updateIndices(indices32);
  110277. }
  110278. }
  110279. if (this._computeBoundingBox) {
  110280. if (mesh._boundingInfo) {
  110281. mesh._boundingInfo.reConstruct(minimum, maximum, mesh._worldMatrix);
  110282. }
  110283. else {
  110284. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__["BoundingInfo"](minimum, maximum, mesh._worldMatrix);
  110285. }
  110286. }
  110287. this.afterUpdateParticles(start, end, update);
  110288. return this;
  110289. };
  110290. /**
  110291. * Disposes the SPS.
  110292. */
  110293. SolidParticleSystem.prototype.dispose = function () {
  110294. this.mesh.dispose();
  110295. this.vars = null;
  110296. // drop references to internal big arrays for the GC
  110297. this._positions = null;
  110298. this._indices = null;
  110299. this._normals = null;
  110300. this._uvs = null;
  110301. this._colors = null;
  110302. this._indices32 = null;
  110303. this._positions32 = null;
  110304. this._normals32 = null;
  110305. this._fixedNormal32 = null;
  110306. this._uvs32 = null;
  110307. this._colors32 = null;
  110308. this.pickedParticles = null;
  110309. };
  110310. /**
  110311. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  110312. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  110313. * @returns the SPS.
  110314. */
  110315. SolidParticleSystem.prototype.refreshVisibleSize = function () {
  110316. if (!this._isVisibilityBoxLocked) {
  110317. this.mesh.refreshBoundingInfo();
  110318. }
  110319. return this;
  110320. };
  110321. /**
  110322. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  110323. * @param size the size (float) of the visibility box
  110324. * note : this doesn't lock the SPS mesh bounding box.
  110325. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  110326. */
  110327. SolidParticleSystem.prototype.setVisibilityBox = function (size) {
  110328. var vis = size / 2;
  110329. 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));
  110330. };
  110331. Object.defineProperty(SolidParticleSystem.prototype, "isAlwaysVisible", {
  110332. /**
  110333. * Gets whether the SPS as always visible or not
  110334. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  110335. */
  110336. get: function () {
  110337. return this._alwaysVisible;
  110338. },
  110339. /**
  110340. * Sets the SPS as always visible or not
  110341. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  110342. */
  110343. set: function (val) {
  110344. this._alwaysVisible = val;
  110345. this.mesh.alwaysSelectAsActiveMesh = val;
  110346. },
  110347. enumerable: true,
  110348. configurable: true
  110349. });
  110350. Object.defineProperty(SolidParticleSystem.prototype, "isVisibilityBoxLocked", {
  110351. /**
  110352. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  110353. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  110354. */
  110355. get: function () {
  110356. return this._isVisibilityBoxLocked;
  110357. },
  110358. /**
  110359. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  110360. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  110361. */
  110362. set: function (val) {
  110363. this._isVisibilityBoxLocked = val;
  110364. var boundingInfo = this.mesh.getBoundingInfo();
  110365. boundingInfo.isLocked = val;
  110366. },
  110367. enumerable: true,
  110368. configurable: true
  110369. });
  110370. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleRotation", {
  110371. /**
  110372. * Gets if `setParticles()` computes the particle rotations or not.
  110373. * Default value : true. The SPS is faster when it's set to false.
  110374. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  110375. */
  110376. get: function () {
  110377. return this._computeParticleRotation;
  110378. },
  110379. /**
  110380. * Tells to `setParticles()` to compute the particle rotations or not.
  110381. * Default value : true. The SPS is faster when it's set to false.
  110382. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  110383. */
  110384. set: function (val) {
  110385. this._computeParticleRotation = val;
  110386. },
  110387. enumerable: true,
  110388. configurable: true
  110389. });
  110390. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleColor", {
  110391. /**
  110392. * Gets if `setParticles()` computes the particle colors or not.
  110393. * Default value : true. The SPS is faster when it's set to false.
  110394. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  110395. */
  110396. get: function () {
  110397. return this._computeParticleColor;
  110398. },
  110399. /**
  110400. * Tells to `setParticles()` to compute the particle colors or not.
  110401. * Default value : true. The SPS is faster when it's set to false.
  110402. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  110403. */
  110404. set: function (val) {
  110405. this._computeParticleColor = val;
  110406. },
  110407. enumerable: true,
  110408. configurable: true
  110409. });
  110410. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleTexture", {
  110411. /**
  110412. * Gets if `setParticles()` computes the particle textures or not.
  110413. * Default value : true. The SPS is faster when it's set to false.
  110414. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  110415. */
  110416. get: function () {
  110417. return this._computeParticleTexture;
  110418. },
  110419. set: function (val) {
  110420. this._computeParticleTexture = val;
  110421. },
  110422. enumerable: true,
  110423. configurable: true
  110424. });
  110425. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleVertex", {
  110426. /**
  110427. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  110428. * Default value : false. The SPS is faster when it's set to false.
  110429. * Note : the particle custom vertex positions aren't stored values.
  110430. */
  110431. get: function () {
  110432. return this._computeParticleVertex;
  110433. },
  110434. /**
  110435. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  110436. * Default value : false. The SPS is faster when it's set to false.
  110437. * Note : the particle custom vertex positions aren't stored values.
  110438. */
  110439. set: function (val) {
  110440. this._computeParticleVertex = val;
  110441. },
  110442. enumerable: true,
  110443. configurable: true
  110444. });
  110445. Object.defineProperty(SolidParticleSystem.prototype, "computeBoundingBox", {
  110446. /**
  110447. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  110448. */
  110449. get: function () {
  110450. return this._computeBoundingBox;
  110451. },
  110452. /**
  110453. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  110454. */
  110455. set: function (val) {
  110456. this._computeBoundingBox = val;
  110457. },
  110458. enumerable: true,
  110459. configurable: true
  110460. });
  110461. Object.defineProperty(SolidParticleSystem.prototype, "depthSortParticles", {
  110462. /**
  110463. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  110464. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  110465. * Default : `true`
  110466. */
  110467. get: function () {
  110468. return this._depthSortParticles;
  110469. },
  110470. /**
  110471. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  110472. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  110473. * Default : `true`
  110474. */
  110475. set: function (val) {
  110476. this._depthSortParticles = val;
  110477. },
  110478. enumerable: true,
  110479. configurable: true
  110480. });
  110481. // =======================================================================
  110482. // Particle behavior logic
  110483. // these following methods may be overwritten by the user to fit his needs
  110484. /**
  110485. * This function does nothing. It may be overwritten to set all the particle first values.
  110486. * The SPS doesn't call this function, you may have to call it by your own.
  110487. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  110488. */
  110489. SolidParticleSystem.prototype.initParticles = function () {
  110490. };
  110491. /**
  110492. * This function does nothing. It may be overwritten to recycle a particle.
  110493. * The SPS doesn't call this function, you may have to call it by your own.
  110494. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  110495. * @param particle The particle to recycle
  110496. * @returns the recycled particle
  110497. */
  110498. SolidParticleSystem.prototype.recycleParticle = function (particle) {
  110499. return particle;
  110500. };
  110501. /**
  110502. * Updates a particle : this function should be overwritten by the user.
  110503. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  110504. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  110505. * @example : just set a particle position or velocity and recycle conditions
  110506. * @param particle The particle to update
  110507. * @returns the updated particle
  110508. */
  110509. SolidParticleSystem.prototype.updateParticle = function (particle) {
  110510. return particle;
  110511. };
  110512. /**
  110513. * Updates a vertex of a particle : it can be overwritten by the user.
  110514. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  110515. * @param particle the current particle
  110516. * @param vertex the current index of the current particle
  110517. * @param pt the index of the current vertex in the particle shape
  110518. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  110519. * @example : just set a vertex particle position
  110520. * @returns the updated vertex
  110521. */
  110522. SolidParticleSystem.prototype.updateParticleVertex = function (particle, vertex, pt) {
  110523. return vertex;
  110524. };
  110525. /**
  110526. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  110527. * This does nothing and may be overwritten by the user.
  110528. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  110529. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  110530. * @param update the boolean update value actually passed to setParticles()
  110531. */
  110532. SolidParticleSystem.prototype.beforeUpdateParticles = function (start, stop, update) {
  110533. };
  110534. /**
  110535. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  110536. * This will be passed three parameters.
  110537. * This does nothing and may be overwritten by the user.
  110538. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  110539. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  110540. * @param update the boolean update value actually passed to setParticles()
  110541. */
  110542. SolidParticleSystem.prototype.afterUpdateParticles = function (start, stop, update) {
  110543. };
  110544. return SolidParticleSystem;
  110545. }());
  110546. /***/ }),
  110547. /***/ "./Particles/subEmitter.ts":
  110548. /*!*********************************!*\
  110549. !*** ./Particles/subEmitter.ts ***!
  110550. \*********************************/
  110551. /*! exports provided: SubEmitterType, SubEmitter */
  110552. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  110553. "use strict";
  110554. __webpack_require__.r(__webpack_exports__);
  110555. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return SubEmitterType; });
  110556. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return SubEmitter; });
  110557. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  110558. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  110559. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  110560. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  110561. /**
  110562. * Type of sub emitter
  110563. */
  110564. var SubEmitterType;
  110565. (function (SubEmitterType) {
  110566. /**
  110567. * Attached to the particle over it's lifetime
  110568. */
  110569. SubEmitterType[SubEmitterType["ATTACHED"] = 0] = "ATTACHED";
  110570. /**
  110571. * Created when the particle dies
  110572. */
  110573. SubEmitterType[SubEmitterType["END"] = 1] = "END";
  110574. })(SubEmitterType || (SubEmitterType = {}));
  110575. /**
  110576. * Sub emitter class used to emit particles from an existing particle
  110577. */
  110578. var SubEmitter = /** @class */ (function () {
  110579. /**
  110580. * Creates a sub emitter
  110581. * @param particleSystem the particle system to be used by the sub emitter
  110582. */
  110583. function SubEmitter(
  110584. /**
  110585. * the particle system to be used by the sub emitter
  110586. */
  110587. particleSystem) {
  110588. this.particleSystem = particleSystem;
  110589. /**
  110590. * Type of the submitter (Default: END)
  110591. */
  110592. this.type = SubEmitterType.END;
  110593. /**
  110594. * 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)
  110595. * Note: This only is supported when using an emitter of type Mesh
  110596. */
  110597. this.inheritDirection = false;
  110598. /**
  110599. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  110600. */
  110601. this.inheritedVelocityAmount = 0;
  110602. // Create mesh as emitter to support rotation
  110603. if (!particleSystem.emitter || !particleSystem.emitter.dispose) {
  110604. particleSystem.emitter = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("SubemitterSystemEmitter", particleSystem.getScene());
  110605. }
  110606. // Automatically dispose of subemitter when system is disposed
  110607. particleSystem.onDisposeObservable.add(function () {
  110608. if (particleSystem.emitter && particleSystem.emitter.dispose) {
  110609. particleSystem.emitter.dispose();
  110610. }
  110611. });
  110612. }
  110613. /**
  110614. * Clones the sub emitter
  110615. * @returns the cloned sub emitter
  110616. */
  110617. SubEmitter.prototype.clone = function () {
  110618. // Clone particle system
  110619. var emitter = this.particleSystem.emitter;
  110620. if (!emitter) {
  110621. emitter = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  110622. }
  110623. else if (emitter instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]) {
  110624. emitter = emitter.clone();
  110625. }
  110626. else if (emitter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  110627. emitter = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("", emitter.getScene());
  110628. emitter.isVisible = false;
  110629. }
  110630. var clone = new SubEmitter(this.particleSystem.clone("", emitter));
  110631. // Clone properties
  110632. clone.type = this.type;
  110633. clone.inheritDirection = this.inheritDirection;
  110634. clone.inheritedVelocityAmount = this.inheritedVelocityAmount;
  110635. clone.particleSystem._disposeEmitterOnDispose = true;
  110636. clone.particleSystem.disposeOnStop = true;
  110637. return clone;
  110638. };
  110639. /**
  110640. * Serialize current object to a JSON object
  110641. * @returns the serialized object
  110642. */
  110643. SubEmitter.prototype.serialize = function () {
  110644. var serializationObject = {};
  110645. serializationObject.type = this.type;
  110646. serializationObject.inheritDirection = this.inheritDirection;
  110647. serializationObject.inheritedVelocityAmount = this.inheritedVelocityAmount;
  110648. serializationObject.particleSystem = this.particleSystem.serialize();
  110649. return serializationObject;
  110650. };
  110651. /** @hidden */
  110652. SubEmitter._ParseParticleSystem = function (system, scene, rootUrl) {
  110653. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__["_DevTools"].WarnImport("ParseParticle");
  110654. };
  110655. /**
  110656. * Creates a new SubEmitter from a serialized JSON version
  110657. * @param serializationObject defines the JSON object to read from
  110658. * @param scene defines the hosting scene
  110659. * @param rootUrl defines the rootUrl for data loading
  110660. * @returns a new SubEmitter
  110661. */
  110662. SubEmitter.Parse = function (serializationObject, scene, rootUrl) {
  110663. var system = serializationObject.particleSystem;
  110664. var subEmitter = new SubEmitter(SubEmitter._ParseParticleSystem(system, scene, rootUrl));
  110665. subEmitter.type = serializationObject.type;
  110666. subEmitter.inheritDirection = serializationObject.inheritDirection;
  110667. subEmitter.inheritedVelocityAmount = serializationObject.inheritedVelocityAmount;
  110668. subEmitter.particleSystem._isSubEmitter = true;
  110669. return subEmitter;
  110670. };
  110671. /** Release associated resources */
  110672. SubEmitter.prototype.dispose = function () {
  110673. this.particleSystem.dispose();
  110674. };
  110675. return SubEmitter;
  110676. }());
  110677. /***/ }),
  110678. /***/ "./Physics/Plugins/ammoJSPlugin.ts":
  110679. /*!*****************************************!*\
  110680. !*** ./Physics/Plugins/ammoJSPlugin.ts ***!
  110681. \*****************************************/
  110682. /*! exports provided: AmmoJSPlugin */
  110683. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  110684. "use strict";
  110685. __webpack_require__.r(__webpack_exports__);
  110686. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return AmmoJSPlugin; });
  110687. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  110688. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  110689. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  110690. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  110691. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  110692. /**
  110693. * AmmoJS Physics plugin
  110694. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  110695. * @see https://github.com/kripken/ammo.js/
  110696. */
  110697. var AmmoJSPlugin = /** @class */ (function () {
  110698. /**
  110699. * Initializes the ammoJS plugin
  110700. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  110701. * @param ammoInjection can be used to inject your own ammo reference
  110702. */
  110703. function AmmoJSPlugin(_useDeltaForWorldStep, ammoInjection) {
  110704. if (_useDeltaForWorldStep === void 0) { _useDeltaForWorldStep = true; }
  110705. if (ammoInjection === void 0) { ammoInjection = Ammo; }
  110706. var _this = this;
  110707. this._useDeltaForWorldStep = _useDeltaForWorldStep;
  110708. /**
  110709. * Reference to the Ammo library
  110710. */
  110711. this.bjsAMMO = {};
  110712. /**
  110713. * Name of the plugin
  110714. */
  110715. this.name = "AmmoJSPlugin";
  110716. this._timeStep = 1 / 60;
  110717. this._fixedTimeStep = 1 / 60;
  110718. this._maxSteps = 5;
  110719. this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  110720. this._tmpContactCallbackResult = false;
  110721. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  110722. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  110723. if (typeof ammoInjection === "function") {
  110724. ammoInjection(this.bjsAMMO);
  110725. }
  110726. else {
  110727. this.bjsAMMO = ammoInjection;
  110728. }
  110729. if (!this.isSupported()) {
  110730. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("AmmoJS is not available. Please make sure you included the js file.");
  110731. return;
  110732. }
  110733. // Initialize the physics world
  110734. this._collisionConfiguration = new this.bjsAMMO.btDefaultCollisionConfiguration();
  110735. this._dispatcher = new this.bjsAMMO.btCollisionDispatcher(this._collisionConfiguration);
  110736. this._overlappingPairCache = new this.bjsAMMO.btDbvtBroadphase();
  110737. this._solver = new this.bjsAMMO.btSequentialImpulseConstraintSolver();
  110738. this.world = new this.bjsAMMO.btDiscreteDynamicsWorld(this._dispatcher, this._overlappingPairCache, this._solver, this._collisionConfiguration);
  110739. this._tmpAmmoConcreteContactResultCallback = new this.bjsAMMO.ConcreteContactResultCallback();
  110740. this._tmpAmmoConcreteContactResultCallback.addSingleResult = function () { _this._tmpContactCallbackResult = true; };
  110741. // Create temp ammo variables
  110742. this._tmpAmmoTransform = new this.bjsAMMO.btTransform();
  110743. this._tmpAmmoTransform.setIdentity();
  110744. this._tmpAmmoQuaternion = new this.bjsAMMO.btQuaternion(0, 0, 0, 1);
  110745. this._tmpAmmoVectorA = new this.bjsAMMO.btVector3(0, 0, 0);
  110746. this._tmpAmmoVectorB = new this.bjsAMMO.btVector3(0, 0, 0);
  110747. this._tmpAmmoVectorC = new this.bjsAMMO.btVector3(0, 0, 0);
  110748. }
  110749. /**
  110750. * Sets the gravity of the physics world (m/(s^2))
  110751. * @param gravity Gravity to set
  110752. */
  110753. AmmoJSPlugin.prototype.setGravity = function (gravity) {
  110754. this._tmpAmmoVectorA.setValue(gravity.x, gravity.y, gravity.z);
  110755. this.world.setGravity(this._tmpAmmoVectorA);
  110756. };
  110757. /**
  110758. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  110759. * @param timeStep timestep to use in seconds
  110760. */
  110761. AmmoJSPlugin.prototype.setTimeStep = function (timeStep) {
  110762. this._timeStep = timeStep;
  110763. };
  110764. /**
  110765. * 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)
  110766. * @param fixedTimeStep fixedTimeStep to use in seconds
  110767. */
  110768. AmmoJSPlugin.prototype.setFixedTimeStep = function (fixedTimeStep) {
  110769. this._fixedTimeStep = fixedTimeStep;
  110770. };
  110771. /**
  110772. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  110773. * @param maxSteps the maximum number of steps by the physics engine per frame
  110774. */
  110775. AmmoJSPlugin.prototype.setMaxSteps = function (maxSteps) {
  110776. this._maxSteps = maxSteps;
  110777. };
  110778. /**
  110779. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  110780. * @returns the current timestep in seconds
  110781. */
  110782. AmmoJSPlugin.prototype.getTimeStep = function () {
  110783. return this._timeStep;
  110784. };
  110785. // Ammo's contactTest and contactPairTest take a callback that runs synchronously, wrap them so that they are easier to consume
  110786. AmmoJSPlugin.prototype._isImpostorInContact = function (impostor) {
  110787. this._tmpContactCallbackResult = false;
  110788. this.world.contactTest(impostor.physicsBody, this._tmpAmmoConcreteContactResultCallback);
  110789. return this._tmpContactCallbackResult;
  110790. };
  110791. // Ammo's collision events have some weird quirks
  110792. // contactPairTest fires too many events as it fires events even when objects are close together but contactTest does not
  110793. // so only fire event if both contactTest and contactPairTest have a hit
  110794. AmmoJSPlugin.prototype._isImpostorPairInContact = function (impostorA, impostorB) {
  110795. this._tmpContactCallbackResult = false;
  110796. this.world.contactPairTest(impostorA.physicsBody, impostorB.physicsBody, this._tmpAmmoConcreteContactResultCallback);
  110797. return this._tmpContactCallbackResult;
  110798. };
  110799. // Ammo's behavior when maxSteps > 0 does not behave as described in docs
  110800. // @see http://www.bulletphysics.org/mediawiki-1.5.8/index.php/Stepping_The_World
  110801. //
  110802. // When maxSteps is 0 do the entire simulation in one step
  110803. // 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)
  110804. // Note: To get deterministic physics, timeStep would always need to be divisible by fixedTimeStep
  110805. AmmoJSPlugin.prototype._stepSimulation = function (timeStep, maxSteps, fixedTimeStep) {
  110806. if (timeStep === void 0) { timeStep = 1 / 60; }
  110807. if (maxSteps === void 0) { maxSteps = 10; }
  110808. if (fixedTimeStep === void 0) { fixedTimeStep = 1 / 60; }
  110809. if (maxSteps == 0) {
  110810. this.world.stepSimulation(timeStep, 0);
  110811. }
  110812. else {
  110813. while (maxSteps > 0 && timeStep > 0) {
  110814. if (timeStep - fixedTimeStep < fixedTimeStep) {
  110815. this.world.stepSimulation(timeStep, 0);
  110816. timeStep = 0;
  110817. }
  110818. else {
  110819. timeStep -= fixedTimeStep;
  110820. this.world.stepSimulation(fixedTimeStep, 0);
  110821. }
  110822. maxSteps--;
  110823. }
  110824. }
  110825. };
  110826. /**
  110827. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  110828. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  110829. * After the step the babylon meshes are set to the position of the physics imposters
  110830. * @param delta amount of time to step forward
  110831. * @param impostors array of imposters to update before/after the step
  110832. */
  110833. AmmoJSPlugin.prototype.executeStep = function (delta, impostors) {
  110834. for (var _i = 0, impostors_1 = impostors; _i < impostors_1.length; _i++) {
  110835. var impostor = impostors_1[_i];
  110836. // Update physics world objects to match babylon world
  110837. impostor.beforeStep();
  110838. }
  110839. this._stepSimulation(this._useDeltaForWorldStep ? delta : this._timeStep, this._maxSteps, this._fixedTimeStep);
  110840. for (var _a = 0, impostors_2 = impostors; _a < impostors_2.length; _a++) {
  110841. var mainImpostor = impostors_2[_a];
  110842. // After physics update make babylon world objects match physics world objects
  110843. mainImpostor.afterStep();
  110844. // Handle collision event
  110845. if (mainImpostor._onPhysicsCollideCallbacks.length > 0) {
  110846. if (this._isImpostorInContact(mainImpostor)) {
  110847. for (var _b = 0, _c = mainImpostor._onPhysicsCollideCallbacks; _b < _c.length; _b++) {
  110848. var collideCallback = _c[_b];
  110849. for (var _d = 0, _e = collideCallback.otherImpostors; _d < _e.length; _d++) {
  110850. var otherImpostor = _e[_d];
  110851. if (mainImpostor.physicsBody.isActive() || otherImpostor.physicsBody.isActive()) {
  110852. if (this._isImpostorPairInContact(mainImpostor, otherImpostor)) {
  110853. mainImpostor.onCollide({ body: otherImpostor.physicsBody });
  110854. otherImpostor.onCollide({ body: mainImpostor.physicsBody });
  110855. }
  110856. }
  110857. }
  110858. }
  110859. }
  110860. }
  110861. }
  110862. };
  110863. /**
  110864. * Applies an implulse on the imposter
  110865. * @param impostor imposter to apply impulse
  110866. * @param force amount of force to be applied to the imposter
  110867. * @param contactPoint the location to apply the impulse on the imposter
  110868. */
  110869. AmmoJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  110870. impostor.physicsBody.activate();
  110871. var worldPoint = this._tmpAmmoVectorA;
  110872. var impulse = this._tmpAmmoVectorB;
  110873. // Convert contactPoint into world space
  110874. if (impostor.object && impostor.object.getWorldMatrix) {
  110875. impostor.object.getWorldMatrix().invertToRef(this._tmpMatrix);
  110876. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(contactPoint, this._tmpMatrix, this._tmpVector);
  110877. contactPoint = this._tmpVector;
  110878. }
  110879. worldPoint.setValue(contactPoint.x, contactPoint.y, contactPoint.z);
  110880. impulse.setValue(force.x, force.y, force.z);
  110881. impostor.physicsBody.applyImpulse(impulse, worldPoint);
  110882. };
  110883. /**
  110884. * Applies a force on the imposter
  110885. * @param impostor imposter to apply force
  110886. * @param force amount of force to be applied to the imposter
  110887. * @param contactPoint the location to apply the force on the imposter
  110888. */
  110889. AmmoJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  110890. impostor.physicsBody.activate();
  110891. var worldPoint = this._tmpAmmoVectorA;
  110892. var impulse = this._tmpAmmoVectorB;
  110893. // Convert contactPoint into world space
  110894. if (impostor.object && impostor.object.getWorldMatrix) {
  110895. impostor.object.getWorldMatrix().invertToRef(this._tmpMatrix);
  110896. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(contactPoint, this._tmpMatrix, this._tmpVector);
  110897. contactPoint = this._tmpVector;
  110898. }
  110899. worldPoint.setValue(contactPoint.x, contactPoint.y, contactPoint.z);
  110900. impulse.setValue(force.x, force.y, force.z);
  110901. impostor.physicsBody.applyForce(impulse, worldPoint);
  110902. };
  110903. /**
  110904. * Creates a physics body using the plugin
  110905. * @param impostor the imposter to create the physics body on
  110906. */
  110907. AmmoJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  110908. impostor._pluginData = { toDispose: [] };
  110909. //parent-child relationship
  110910. if (impostor.parent) {
  110911. if (impostor.physicsBody) {
  110912. this.removePhysicsBody(impostor);
  110913. impostor.forceUpdate();
  110914. }
  110915. return;
  110916. }
  110917. if (impostor.isBodyInitRequired()) {
  110918. var colShape = this._createShape(impostor);
  110919. var mass = impostor.getParam("mass");
  110920. impostor._pluginData.mass = mass;
  110921. var localInertia = new Ammo.btVector3(0, 0, 0);
  110922. var startTransform = new Ammo.btTransform();
  110923. startTransform.setIdentity();
  110924. if (mass !== 0) {
  110925. colShape.calculateLocalInertia(mass, localInertia);
  110926. }
  110927. this._tmpAmmoVectorA.setValue(impostor.object.position.x, impostor.object.position.y, impostor.object.position.z);
  110928. this._tmpAmmoQuaternion.setValue(impostor.object.rotationQuaternion.x, impostor.object.rotationQuaternion.y, impostor.object.rotationQuaternion.z, impostor.object.rotationQuaternion.w);
  110929. startTransform.setOrigin(this._tmpAmmoVectorA);
  110930. startTransform.setRotation(this._tmpAmmoQuaternion);
  110931. var myMotionState = new Ammo.btDefaultMotionState(startTransform);
  110932. var rbInfo = new Ammo.btRigidBodyConstructionInfo(mass, myMotionState, colShape, localInertia);
  110933. var body = new Ammo.btRigidBody(rbInfo);
  110934. // Make objects kinematic if it's mass is 0
  110935. if (mass === 0) {
  110936. body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.KINEMATIC_FLAG);
  110937. body.setActivationState(AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG);
  110938. }
  110939. // Disable collision if NoImpostor, but keep collision if shape is btCompoundShape
  110940. if (impostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor && !colShape.getChildShape) {
  110941. body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.DISABLE_COLLISION_FLAG);
  110942. }
  110943. this.world.addRigidBody(body);
  110944. impostor.physicsBody = body;
  110945. this.setBodyRestitution(impostor, impostor.getParam("restitution"));
  110946. this.setBodyFriction(impostor, impostor.getParam("friction"));
  110947. impostor._pluginData.toDispose.concat([body, rbInfo, myMotionState, startTransform, localInertia, colShape]);
  110948. }
  110949. };
  110950. /**
  110951. * Removes the physics body from the imposter and disposes of the body's memory
  110952. * @param impostor imposter to remove the physics body from
  110953. */
  110954. AmmoJSPlugin.prototype.removePhysicsBody = function (impostor) {
  110955. var _this = this;
  110956. if (this.world) {
  110957. this.world.removeRigidBody(impostor.physicsBody);
  110958. impostor._pluginData.toDispose.forEach(function (d) {
  110959. _this.bjsAMMO.destroy(d);
  110960. });
  110961. }
  110962. };
  110963. /**
  110964. * Generates a joint
  110965. * @param impostorJoint the imposter joint to create the joint with
  110966. */
  110967. AmmoJSPlugin.prototype.generateJoint = function (impostorJoint) {
  110968. var mainBody = impostorJoint.mainImpostor.physicsBody;
  110969. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  110970. if (!mainBody || !connectedBody) {
  110971. return;
  110972. }
  110973. var jointData = impostorJoint.joint.jointData;
  110974. if (!jointData.mainPivot) {
  110975. jointData.mainPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  110976. }
  110977. if (!jointData.connectedPivot) {
  110978. jointData.connectedPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  110979. }
  110980. var joint;
  110981. switch (impostorJoint.joint.type) {
  110982. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].DistanceJoint:
  110983. var distance = jointData.maxDistance;
  110984. if (distance) {
  110985. jointData.mainPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -distance / 2, 0);
  110986. jointData.connectedPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, distance / 2, 0);
  110987. }
  110988. 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));
  110989. break;
  110990. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].HingeJoint:
  110991. if (!jointData.mainAxis) {
  110992. jointData.mainAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  110993. }
  110994. if (!jointData.connectedAxis) {
  110995. jointData.connectedAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  110996. }
  110997. var mainAxis = new Ammo.btVector3(jointData.mainAxis.x, jointData.mainAxis.y, jointData.mainAxis.z);
  110998. var connectedAxis = new Ammo.btVector3(jointData.connectedAxis.x, jointData.connectedAxis.y, jointData.connectedAxis.z);
  110999. 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);
  111000. break;
  111001. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].BallAndSocketJoint:
  111002. 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));
  111003. break;
  111004. default:
  111005. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("JointType not currently supported by the Ammo plugin, falling back to PhysicsJoint.BallAndSocketJoint");
  111006. 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));
  111007. break;
  111008. }
  111009. this.world.addConstraint(joint, !impostorJoint.joint.jointData.collision);
  111010. impostorJoint.joint.physicsJoint = joint;
  111011. };
  111012. /**
  111013. * Removes a joint
  111014. * @param impostorJoint the imposter joint to remove the joint from
  111015. */
  111016. AmmoJSPlugin.prototype.removeJoint = function (impostorJoint) {
  111017. if (this.world) {
  111018. this.world.removeConstraint(impostorJoint.joint.physicsJoint);
  111019. }
  111020. };
  111021. // adds all verticies (including child verticies) to the triangle mesh
  111022. AmmoJSPlugin.prototype._addMeshVerts = function (btTriangleMesh, topLevelObject, object) {
  111023. var _this = this;
  111024. var triangleCount = 0;
  111025. if (object && object.getIndices && object.getWorldMatrix && object.getChildMeshes) {
  111026. var indices = object.getIndices();
  111027. if (!indices) {
  111028. indices = [];
  111029. }
  111030. var vertexPositions = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  111031. if (!vertexPositions) {
  111032. vertexPositions = [];
  111033. }
  111034. object.computeWorldMatrix(false);
  111035. var faceCount = indices.length / 3;
  111036. for (var i = 0; i < faceCount; i++) {
  111037. var triPoints = [];
  111038. for (var point = 0; point < 3; point++) {
  111039. 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]);
  111040. v = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(v, object.getWorldMatrix());
  111041. v.subtractInPlace(topLevelObject.position);
  111042. var vec;
  111043. if (point == 0) {
  111044. vec = this._tmpAmmoVectorA;
  111045. }
  111046. else if (point == 1) {
  111047. vec = this._tmpAmmoVectorB;
  111048. }
  111049. else {
  111050. vec = this._tmpAmmoVectorC;
  111051. }
  111052. vec.setValue(v.x, v.y, v.z);
  111053. triPoints.push(vec);
  111054. }
  111055. btTriangleMesh.addTriangle(triPoints[0], triPoints[1], triPoints[2]);
  111056. triangleCount++;
  111057. }
  111058. object.getChildMeshes().forEach(function (m) {
  111059. triangleCount += _this._addMeshVerts(btTriangleMesh, topLevelObject, m);
  111060. });
  111061. }
  111062. return triangleCount;
  111063. };
  111064. AmmoJSPlugin.prototype._createShape = function (impostor, ignoreChildren) {
  111065. var _this = this;
  111066. if (ignoreChildren === void 0) { ignoreChildren = false; }
  111067. var object = impostor.object;
  111068. var returnValue;
  111069. var extendSize = impostor.getObjectExtendSize();
  111070. if (!ignoreChildren) {
  111071. var meshChildren = impostor.object.getChildMeshes ? impostor.object.getChildMeshes(true) : [];
  111072. returnValue = new Ammo.btCompoundShape();
  111073. // Add shape of all children to the compound shape
  111074. var childrenAdded = 0;
  111075. meshChildren.forEach(function (childMesh) {
  111076. var childImpostor = childMesh.getPhysicsImpostor();
  111077. if (childImpostor) {
  111078. var shape = _this._createShape(childImpostor);
  111079. // Position needs to be scaled based on parent's scaling
  111080. var parentMat = childMesh.parent.getWorldMatrix().clone();
  111081. var s = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  111082. parentMat.decompose(s);
  111083. _this._tmpAmmoTransform.getOrigin().setValue(childMesh.position.x * s.x, childMesh.position.y * s.y, childMesh.position.z * s.z);
  111084. _this._tmpAmmoQuaternion.setValue(childMesh.rotationQuaternion.x, childMesh.rotationQuaternion.y, childMesh.rotationQuaternion.z, childMesh.rotationQuaternion.w);
  111085. _this._tmpAmmoTransform.setRotation(_this._tmpAmmoQuaternion);
  111086. returnValue.addChildShape(_this._tmpAmmoTransform, shape);
  111087. childImpostor.dispose();
  111088. childrenAdded++;
  111089. }
  111090. });
  111091. if (childrenAdded > 0) {
  111092. // Add parents shape as a child if present
  111093. if (impostor.type != _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor) {
  111094. var shape = this._createShape(impostor, true);
  111095. if (shape) {
  111096. this._tmpAmmoTransform.getOrigin().setValue(0, 0, 0);
  111097. this._tmpAmmoQuaternion.setValue(0, 0, 0, 1);
  111098. this._tmpAmmoTransform.setRotation(this._tmpAmmoQuaternion);
  111099. returnValue.addChildShape(this._tmpAmmoTransform, shape);
  111100. }
  111101. }
  111102. return returnValue;
  111103. }
  111104. else {
  111105. // If no children with impostors create the actual shape below instead
  111106. Ammo.destroy(returnValue);
  111107. returnValue = null;
  111108. }
  111109. }
  111110. switch (impostor.type) {
  111111. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].SphereImpostor:
  111112. returnValue = new Ammo.btSphereShape(extendSize.x / 2);
  111113. break;
  111114. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].CylinderImpostor:
  111115. this._tmpAmmoVectorA.setValue(extendSize.x / 2, extendSize.y / 2, extendSize.z / 2);
  111116. returnValue = new Ammo.btCylinderShape(this._tmpAmmoVectorA);
  111117. break;
  111118. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].PlaneImpostor:
  111119. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].BoxImpostor:
  111120. this._tmpAmmoVectorA.setValue(extendSize.x / 2, extendSize.y / 2, extendSize.z / 2);
  111121. returnValue = new Ammo.btBoxShape(this._tmpAmmoVectorA);
  111122. break;
  111123. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].MeshImpostor:
  111124. var tetraMesh = new Ammo.btTriangleMesh();
  111125. impostor._pluginData.toDispose.concat([tetraMesh]);
  111126. var triangeCount = this._addMeshVerts(tetraMesh, object, object);
  111127. if (triangeCount == 0) {
  111128. returnValue = new Ammo.btCompoundShape();
  111129. }
  111130. else {
  111131. returnValue = new Ammo.btBvhTriangleMeshShape(tetraMesh);
  111132. }
  111133. break;
  111134. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor:
  111135. // Fill with sphere but collision is disabled on the rigid body in generatePhysicsBody, using an empty shape caused unexpected movement with joints
  111136. returnValue = new Ammo.btSphereShape(extendSize.x / 2);
  111137. break;
  111138. default:
  111139. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("The impostor type is not currently supported by the ammo plugin.");
  111140. break;
  111141. }
  111142. return returnValue;
  111143. };
  111144. /**
  111145. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  111146. * @param impostor imposter containing the physics body and babylon object
  111147. */
  111148. AmmoJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  111149. impostor.physicsBody.getMotionState().getWorldTransform(this._tmpAmmoTransform);
  111150. impostor.object.position.set(this._tmpAmmoTransform.getOrigin().x(), this._tmpAmmoTransform.getOrigin().y(), this._tmpAmmoTransform.getOrigin().z());
  111151. if (!impostor.object.rotationQuaternion) {
  111152. if (impostor.object.rotation) {
  111153. this._tmpQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w());
  111154. this._tmpQuaternion.toEulerAnglesToRef(impostor.object.rotation);
  111155. }
  111156. }
  111157. else {
  111158. impostor.object.rotationQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w());
  111159. }
  111160. };
  111161. /**
  111162. * Sets the babylon object's position/rotation from the physics body's position/rotation
  111163. * @param impostor imposter containing the physics body and babylon object
  111164. * @param newPosition new position
  111165. * @param newRotation new rotation
  111166. */
  111167. AmmoJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  111168. var trans = impostor.physicsBody.getWorldTransform();
  111169. // If rotation/position has changed update and activate riged body
  111170. if (trans.getOrigin().x() != newPosition.x ||
  111171. trans.getOrigin().y() != newPosition.y ||
  111172. trans.getOrigin().z() != newPosition.z ||
  111173. trans.getRotation().x() != newRotation.x ||
  111174. trans.getRotation().y() != newRotation.y ||
  111175. trans.getRotation().z() != newRotation.z ||
  111176. trans.getRotation().w() != newRotation.w) {
  111177. this._tmpAmmoVectorA.setValue(newPosition.x, newPosition.y, newPosition.z);
  111178. trans.setOrigin(this._tmpAmmoVectorA);
  111179. this._tmpAmmoQuaternion.setValue(newRotation.x, newRotation.y, newRotation.z, newRotation.w);
  111180. trans.setRotation(this._tmpAmmoQuaternion);
  111181. impostor.physicsBody.setWorldTransform(trans);
  111182. if (impostor.mass == 0) {
  111183. // Kinematic objects must be updated using motion state
  111184. var motionState = impostor.physicsBody.getMotionState();
  111185. if (motionState) {
  111186. motionState.setWorldTransform(trans);
  111187. }
  111188. }
  111189. else {
  111190. impostor.physicsBody.activate();
  111191. }
  111192. }
  111193. };
  111194. /**
  111195. * If this plugin is supported
  111196. * @returns true if its supported
  111197. */
  111198. AmmoJSPlugin.prototype.isSupported = function () {
  111199. return this.bjsAMMO !== undefined;
  111200. };
  111201. /**
  111202. * Sets the linear velocity of the physics body
  111203. * @param impostor imposter to set the velocity on
  111204. * @param velocity velocity to set
  111205. */
  111206. AmmoJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  111207. this._tmpAmmoVectorA.setValue(velocity.x, velocity.y, velocity.z);
  111208. impostor.physicsBody.setLinearVelocity(this._tmpAmmoVectorA);
  111209. };
  111210. /**
  111211. * Sets the angular velocity of the physics body
  111212. * @param impostor imposter to set the velocity on
  111213. * @param velocity velocity to set
  111214. */
  111215. AmmoJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  111216. this._tmpAmmoVectorA.setValue(velocity.x, velocity.y, velocity.z);
  111217. impostor.physicsBody.setAngularVelocity(this._tmpAmmoVectorA);
  111218. };
  111219. /**
  111220. * gets the linear velocity
  111221. * @param impostor imposter to get linear velocity from
  111222. * @returns linear velocity
  111223. */
  111224. AmmoJSPlugin.prototype.getLinearVelocity = function (impostor) {
  111225. var v = impostor.physicsBody.getLinearVelocity();
  111226. if (!v) {
  111227. return null;
  111228. }
  111229. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](v.x(), v.y(), v.z());
  111230. };
  111231. /**
  111232. * gets the angular velocity
  111233. * @param impostor imposter to get angular velocity from
  111234. * @returns angular velocity
  111235. */
  111236. AmmoJSPlugin.prototype.getAngularVelocity = function (impostor) {
  111237. var v = impostor.physicsBody.getAngularVelocity();
  111238. if (!v) {
  111239. return null;
  111240. }
  111241. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](v.x(), v.y(), v.z());
  111242. };
  111243. /**
  111244. * Sets the mass of physics body
  111245. * @param impostor imposter to set the mass on
  111246. * @param mass mass to set
  111247. */
  111248. AmmoJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  111249. impostor.physicsBody.setMassProps(mass);
  111250. impostor._pluginData.mass = mass;
  111251. };
  111252. /**
  111253. * Gets the mass of the physics body
  111254. * @param impostor imposter to get the mass from
  111255. * @returns mass
  111256. */
  111257. AmmoJSPlugin.prototype.getBodyMass = function (impostor) {
  111258. return impostor._pluginData.mass;
  111259. };
  111260. /**
  111261. * Gets friction of the impostor
  111262. * @param impostor impostor to get friction from
  111263. * @returns friction value
  111264. */
  111265. AmmoJSPlugin.prototype.getBodyFriction = function (impostor) {
  111266. return impostor._pluginData.friction;
  111267. };
  111268. /**
  111269. * Sets friction of the impostor
  111270. * @param impostor impostor to set friction on
  111271. * @param friction friction value
  111272. */
  111273. AmmoJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  111274. impostor.physicsBody.setFriction(friction);
  111275. impostor._pluginData.friction = friction;
  111276. };
  111277. /**
  111278. * Gets restitution of the impostor
  111279. * @param impostor impostor to get restitution from
  111280. * @returns restitution value
  111281. */
  111282. AmmoJSPlugin.prototype.getBodyRestitution = function (impostor) {
  111283. return impostor._pluginData.restitution;
  111284. };
  111285. /**
  111286. * Sets resitution of the impostor
  111287. * @param impostor impostor to set resitution on
  111288. * @param restitution resitution value
  111289. */
  111290. AmmoJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  111291. impostor.physicsBody.setRestitution(restitution);
  111292. impostor._pluginData.restitution = restitution;
  111293. };
  111294. /**
  111295. * Sleeps the physics body and stops it from being active
  111296. * @param impostor impostor to sleep
  111297. */
  111298. AmmoJSPlugin.prototype.sleepBody = function (impostor) {
  111299. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("sleepBody is not currently supported by the Ammo physics plugin");
  111300. };
  111301. /**
  111302. * Activates the physics body
  111303. * @param impostor impostor to activate
  111304. */
  111305. AmmoJSPlugin.prototype.wakeUpBody = function (impostor) {
  111306. impostor.physicsBody.activate();
  111307. };
  111308. /**
  111309. * Updates the distance parameters of the joint
  111310. * @param joint joint to update
  111311. * @param maxDistance maximum distance of the joint
  111312. * @param minDistance minimum distance of the joint
  111313. */
  111314. AmmoJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance, minDistance) {
  111315. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("updateDistanceJoint is not currently supported by the Ammo physics plugin");
  111316. };
  111317. /**
  111318. * Sets a motor on the joint
  111319. * @param joint joint to set motor on
  111320. * @param speed speed of the motor
  111321. * @param maxForce maximum force of the motor
  111322. * @param motorIndex index of the motor
  111323. */
  111324. AmmoJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
  111325. joint.physicsJoint.enableAngularMotor(true, speed, maxForce);
  111326. };
  111327. /**
  111328. * Sets the motors limit
  111329. * @param joint joint to set limit on
  111330. * @param upperLimit upper limit
  111331. * @param lowerLimit lower limit
  111332. */
  111333. AmmoJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit) {
  111334. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("setLimit is not currently supported by the Ammo physics plugin");
  111335. };
  111336. /**
  111337. * Syncs the position and rotation of a mesh with the impostor
  111338. * @param mesh mesh to sync
  111339. * @param impostor impostor to update the mesh with
  111340. */
  111341. AmmoJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  111342. var body = impostor.physicsBody;
  111343. body.getMotionState().getWorldTransform(this._tmpAmmoTransform);
  111344. mesh.position.x = this._tmpAmmoTransform.getOrigin().x();
  111345. mesh.position.y = this._tmpAmmoTransform.getOrigin().y();
  111346. mesh.position.z = this._tmpAmmoTransform.getOrigin().z();
  111347. if (mesh.rotationQuaternion) {
  111348. mesh.rotationQuaternion.x = this._tmpAmmoTransform.getRotation().x();
  111349. mesh.rotationQuaternion.y = this._tmpAmmoTransform.getRotation().y();
  111350. mesh.rotationQuaternion.z = this._tmpAmmoTransform.getRotation().z();
  111351. mesh.rotationQuaternion.w = this._tmpAmmoTransform.getRotation().w();
  111352. }
  111353. };
  111354. /**
  111355. * Gets the radius of the impostor
  111356. * @param impostor impostor to get radius from
  111357. * @returns the radius
  111358. */
  111359. AmmoJSPlugin.prototype.getRadius = function (impostor) {
  111360. var exntend = impostor.getObjectExtendSize();
  111361. return exntend.x / 2;
  111362. };
  111363. /**
  111364. * Gets the box size of the impostor
  111365. * @param impostor impostor to get box size from
  111366. * @param result the resulting box size
  111367. */
  111368. AmmoJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  111369. var exntend = impostor.getObjectExtendSize();
  111370. result.x = exntend.x;
  111371. result.y = exntend.y;
  111372. result.z = exntend.z;
  111373. };
  111374. /**
  111375. * Disposes of the impostor
  111376. */
  111377. AmmoJSPlugin.prototype.dispose = function () {
  111378. // Dispose of world
  111379. Ammo.destroy(this.world);
  111380. Ammo.destroy(this._solver);
  111381. Ammo.destroy(this._overlappingPairCache);
  111382. Ammo.destroy(this._dispatcher);
  111383. Ammo.destroy(this._collisionConfiguration);
  111384. // Dispose of tmp variables
  111385. Ammo.destroy(this._tmpAmmoVectorA);
  111386. Ammo.destroy(this._tmpAmmoVectorB);
  111387. Ammo.destroy(this._tmpAmmoVectorC);
  111388. Ammo.destroy(this._tmpAmmoTransform);
  111389. Ammo.destroy(this._tmpAmmoQuaternion);
  111390. Ammo.destroy(this._tmpAmmoConcreteContactResultCallback);
  111391. this.world = null;
  111392. };
  111393. AmmoJSPlugin.DISABLE_COLLISION_FLAG = 4;
  111394. AmmoJSPlugin.KINEMATIC_FLAG = 2;
  111395. AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG = 4;
  111396. return AmmoJSPlugin;
  111397. }());
  111398. /***/ }),
  111399. /***/ "./Physics/Plugins/cannonJSPlugin.ts":
  111400. /*!*******************************************!*\
  111401. !*** ./Physics/Plugins/cannonJSPlugin.ts ***!
  111402. \*******************************************/
  111403. /*! exports provided: CannonJSPlugin */
  111404. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111405. "use strict";
  111406. __webpack_require__.r(__webpack_exports__);
  111407. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return CannonJSPlugin; });
  111408. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  111409. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  111410. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  111411. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  111412. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  111413. /* harmony import */ var _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Physics/physicsEngine */ "./Physics/physicsEngine.ts");
  111414. /** @hidden */
  111415. var CannonJSPlugin = /** @class */ (function () {
  111416. function CannonJSPlugin(_useDeltaForWorldStep, iterations, cannonInjection) {
  111417. if (_useDeltaForWorldStep === void 0) { _useDeltaForWorldStep = true; }
  111418. if (iterations === void 0) { iterations = 10; }
  111419. if (cannonInjection === void 0) { cannonInjection = CANNON; }
  111420. this._useDeltaForWorldStep = _useDeltaForWorldStep;
  111421. this.name = "CannonJSPlugin";
  111422. this._physicsMaterials = new Array();
  111423. this._fixedTimeStep = 1 / 60;
  111424. this._minus90X = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](-0.7071067811865475, 0, 0, 0.7071067811865475);
  111425. this._plus90X = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](0.7071067811865475, 0, 0, 0.7071067811865475);
  111426. this._tmpPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  111427. this._tmpDeltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  111428. this._tmpUnityRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  111429. this.BJSCANNON = cannonInjection;
  111430. if (!this.isSupported()) {
  111431. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("CannonJS is not available. Please make sure you included the js file.");
  111432. return;
  111433. }
  111434. this._extendNamespace();
  111435. this.world = new this.BJSCANNON.World();
  111436. this.world.broadphase = new this.BJSCANNON.NaiveBroadphase();
  111437. this.world.solver.iterations = iterations;
  111438. }
  111439. CannonJSPlugin.prototype.setGravity = function (gravity) {
  111440. this.world.gravity.copy(gravity);
  111441. };
  111442. CannonJSPlugin.prototype.setTimeStep = function (timeStep) {
  111443. this._fixedTimeStep = timeStep;
  111444. };
  111445. CannonJSPlugin.prototype.getTimeStep = function () {
  111446. return this._fixedTimeStep;
  111447. };
  111448. CannonJSPlugin.prototype.executeStep = function (delta) {
  111449. this.world.step(this._fixedTimeStep, this._useDeltaForWorldStep ? delta : 0, 3);
  111450. };
  111451. CannonJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  111452. var worldPoint = new this.BJSCANNON.Vec3(contactPoint.x, contactPoint.y, contactPoint.z);
  111453. var impulse = new this.BJSCANNON.Vec3(force.x, force.y, force.z);
  111454. impostor.physicsBody.applyImpulse(impulse, worldPoint);
  111455. };
  111456. CannonJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  111457. var worldPoint = new this.BJSCANNON.Vec3(contactPoint.x, contactPoint.y, contactPoint.z);
  111458. var impulse = new this.BJSCANNON.Vec3(force.x, force.y, force.z);
  111459. impostor.physicsBody.applyForce(impulse, worldPoint);
  111460. };
  111461. CannonJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  111462. //parent-child relationship. Does this impostor has a parent impostor?
  111463. if (impostor.parent) {
  111464. if (impostor.physicsBody) {
  111465. this.removePhysicsBody(impostor);
  111466. //TODO is that needed?
  111467. impostor.forceUpdate();
  111468. }
  111469. return;
  111470. }
  111471. //should a new body be created for this impostor?
  111472. if (impostor.isBodyInitRequired()) {
  111473. var shape = this._createShape(impostor);
  111474. //unregister events, if body is being changed
  111475. var oldBody = impostor.physicsBody;
  111476. if (oldBody) {
  111477. this.removePhysicsBody(impostor);
  111478. }
  111479. //create the body and material
  111480. var material = this._addMaterial("mat-" + impostor.uniqueId, impostor.getParam("friction"), impostor.getParam("restitution"));
  111481. var bodyCreationObject = {
  111482. mass: impostor.getParam("mass"),
  111483. material: material
  111484. };
  111485. // A simple extend, in case native options were used.
  111486. var nativeOptions = impostor.getParam("nativeOptions");
  111487. for (var key in nativeOptions) {
  111488. if (nativeOptions.hasOwnProperty(key)) {
  111489. bodyCreationObject[key] = nativeOptions[key];
  111490. }
  111491. }
  111492. impostor.physicsBody = new this.BJSCANNON.Body(bodyCreationObject);
  111493. impostor.physicsBody.addEventListener("collide", impostor.onCollide);
  111494. this.world.addEventListener("preStep", impostor.beforeStep);
  111495. this.world.addEventListener("postStep", impostor.afterStep);
  111496. impostor.physicsBody.addShape(shape);
  111497. this.world.add(impostor.physicsBody);
  111498. //try to keep the body moving in the right direction by taking old properties.
  111499. //Should be tested!
  111500. if (oldBody) {
  111501. ['force', 'torque', 'velocity', 'angularVelocity'].forEach(function (param) {
  111502. impostor.physicsBody[param].copy(oldBody[param]);
  111503. });
  111504. }
  111505. this._processChildMeshes(impostor);
  111506. }
  111507. //now update the body's transformation
  111508. this._updatePhysicsBodyTransformation(impostor);
  111509. };
  111510. CannonJSPlugin.prototype._processChildMeshes = function (mainImpostor) {
  111511. var _this = this;
  111512. var meshChildren = mainImpostor.object.getChildMeshes ? mainImpostor.object.getChildMeshes(true) : [];
  111513. var currentRotation = mainImpostor.object.rotationQuaternion;
  111514. if (meshChildren.length) {
  111515. var processMesh = function (localPosition, mesh) {
  111516. if (!currentRotation || !mesh.rotationQuaternion) {
  111517. return;
  111518. }
  111519. var childImpostor = mesh.getPhysicsImpostor();
  111520. if (childImpostor) {
  111521. var parent = childImpostor.parent;
  111522. if (parent !== mainImpostor) {
  111523. var pPosition = mesh.getAbsolutePosition().subtract(mainImpostor.object.getAbsolutePosition());
  111524. var localRotation = mesh.rotationQuaternion.multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Inverse(currentRotation));
  111525. if (childImpostor.physicsBody) {
  111526. _this.removePhysicsBody(childImpostor);
  111527. childImpostor.physicsBody = null;
  111528. }
  111529. childImpostor.parent = mainImpostor;
  111530. childImpostor.resetUpdateFlags();
  111531. 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));
  111532. //Add the mass of the children.
  111533. mainImpostor.physicsBody.mass += childImpostor.getParam("mass");
  111534. }
  111535. }
  111536. currentRotation.multiplyInPlace(mesh.rotationQuaternion);
  111537. mesh.getChildMeshes(true).filter(function (m) { return !!m.physicsImpostor; }).forEach(processMesh.bind(_this, mesh.getAbsolutePosition()));
  111538. };
  111539. meshChildren.filter(function (m) { return !!m.physicsImpostor; }).forEach(processMesh.bind(this, mainImpostor.object.getAbsolutePosition()));
  111540. }
  111541. };
  111542. CannonJSPlugin.prototype.removePhysicsBody = function (impostor) {
  111543. impostor.physicsBody.removeEventListener("collide", impostor.onCollide);
  111544. this.world.removeEventListener("preStep", impostor.beforeStep);
  111545. this.world.removeEventListener("postStep", impostor.afterStep);
  111546. this.world.remove(impostor.physicsBody);
  111547. };
  111548. CannonJSPlugin.prototype.generateJoint = function (impostorJoint) {
  111549. var mainBody = impostorJoint.mainImpostor.physicsBody;
  111550. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  111551. if (!mainBody || !connectedBody) {
  111552. return;
  111553. }
  111554. var constraint;
  111555. var jointData = impostorJoint.joint.jointData;
  111556. //TODO - https://github.com/schteppe/this.BJSCANNON.js/blob/gh-pages/demos/collisionFilter.html
  111557. var constraintData = {
  111558. pivotA: jointData.mainPivot ? new this.BJSCANNON.Vec3().copy(jointData.mainPivot) : null,
  111559. pivotB: jointData.connectedPivot ? new this.BJSCANNON.Vec3().copy(jointData.connectedPivot) : null,
  111560. axisA: jointData.mainAxis ? new this.BJSCANNON.Vec3().copy(jointData.mainAxis) : null,
  111561. axisB: jointData.connectedAxis ? new this.BJSCANNON.Vec3().copy(jointData.connectedAxis) : null,
  111562. maxForce: jointData.nativeParams.maxForce,
  111563. collideConnected: !!jointData.collision
  111564. };
  111565. switch (impostorJoint.joint.type) {
  111566. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].HingeJoint:
  111567. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].Hinge2Joint:
  111568. constraint = new this.BJSCANNON.HingeConstraint(mainBody, connectedBody, constraintData);
  111569. break;
  111570. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].DistanceJoint:
  111571. constraint = new this.BJSCANNON.DistanceConstraint(mainBody, connectedBody, jointData.maxDistance || 2);
  111572. break;
  111573. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint:
  111574. var springData = jointData;
  111575. constraint = new this.BJSCANNON.Spring(mainBody, connectedBody, {
  111576. restLength: springData.length,
  111577. stiffness: springData.stiffness,
  111578. damping: springData.damping,
  111579. localAnchorA: constraintData.pivotA,
  111580. localAnchorB: constraintData.pivotB
  111581. });
  111582. break;
  111583. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].LockJoint:
  111584. constraint = new this.BJSCANNON.LockConstraint(mainBody, connectedBody, constraintData);
  111585. break;
  111586. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].PointToPointJoint:
  111587. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].BallAndSocketJoint:
  111588. default:
  111589. constraint = new this.BJSCANNON.PointToPointConstraint(mainBody, constraintData.pivotA, connectedBody, constraintData.pivotB, constraintData.maxForce);
  111590. break;
  111591. }
  111592. //set the collideConnected flag after the creation, since DistanceJoint ignores it.
  111593. constraint.collideConnected = !!jointData.collision;
  111594. impostorJoint.joint.physicsJoint = constraint;
  111595. //don't add spring as constraint, as it is not one.
  111596. if (impostorJoint.joint.type !== _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint) {
  111597. this.world.addConstraint(constraint);
  111598. }
  111599. else {
  111600. impostorJoint.joint.jointData.forceApplicationCallback = impostorJoint.joint.jointData.forceApplicationCallback || function () {
  111601. constraint.applyForce();
  111602. };
  111603. impostorJoint.mainImpostor.registerAfterPhysicsStep(impostorJoint.joint.jointData.forceApplicationCallback);
  111604. }
  111605. };
  111606. CannonJSPlugin.prototype.removeJoint = function (impostorJoint) {
  111607. if (impostorJoint.joint.type !== _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint) {
  111608. this.world.removeConstraint(impostorJoint.joint.physicsJoint);
  111609. }
  111610. else {
  111611. impostorJoint.mainImpostor.unregisterAfterPhysicsStep(impostorJoint.joint.jointData.forceApplicationCallback);
  111612. }
  111613. };
  111614. CannonJSPlugin.prototype._addMaterial = function (name, friction, restitution) {
  111615. var index;
  111616. var mat;
  111617. for (index = 0; index < this._physicsMaterials.length; index++) {
  111618. mat = this._physicsMaterials[index];
  111619. if (mat.friction === friction && mat.restitution === restitution) {
  111620. return mat;
  111621. }
  111622. }
  111623. var currentMat = new this.BJSCANNON.Material(name);
  111624. currentMat.friction = friction;
  111625. currentMat.restitution = restitution;
  111626. this._physicsMaterials.push(currentMat);
  111627. return currentMat;
  111628. };
  111629. CannonJSPlugin.prototype._checkWithEpsilon = function (value) {
  111630. return value < _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].Epsilon ? _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].Epsilon : value;
  111631. };
  111632. CannonJSPlugin.prototype._createShape = function (impostor) {
  111633. var object = impostor.object;
  111634. var returnValue;
  111635. var extendSize = impostor.getObjectExtendSize();
  111636. switch (impostor.type) {
  111637. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].SphereImpostor:
  111638. var radiusX = extendSize.x;
  111639. var radiusY = extendSize.y;
  111640. var radiusZ = extendSize.z;
  111641. returnValue = new this.BJSCANNON.Sphere(Math.max(this._checkWithEpsilon(radiusX), this._checkWithEpsilon(radiusY), this._checkWithEpsilon(radiusZ)) / 2);
  111642. break;
  111643. //TMP also for cylinder - TODO Cannon supports cylinder natively.
  111644. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].CylinderImpostor:
  111645. var nativeParams = impostor.getParam("nativeOptions");
  111646. if (!nativeParams) {
  111647. nativeParams = {};
  111648. }
  111649. var radiusTop = nativeParams.radiusTop !== undefined ? nativeParams.radiusTop : this._checkWithEpsilon(extendSize.x) / 2;
  111650. var radiusBottom = nativeParams.radiusBottom !== undefined ? nativeParams.radiusBottom : this._checkWithEpsilon(extendSize.x) / 2;
  111651. var height = nativeParams.height !== undefined ? nativeParams.height : this._checkWithEpsilon(extendSize.y);
  111652. var numSegments = nativeParams.numSegments !== undefined ? nativeParams.numSegments : 16;
  111653. returnValue = new this.BJSCANNON.Cylinder(radiusTop, radiusBottom, height, numSegments);
  111654. // Rotate 90 degrees as this shape is horizontal in cannon
  111655. var quat = new this.BJSCANNON.Quaternion();
  111656. quat.setFromAxisAngle(new this.BJSCANNON.Vec3(1, 0, 0), -Math.PI / 2);
  111657. var translation = new this.BJSCANNON.Vec3(0, 0, 0);
  111658. returnValue.transformAllPoints(translation, quat);
  111659. break;
  111660. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].BoxImpostor:
  111661. var box = extendSize.scale(0.5);
  111662. returnValue = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(this._checkWithEpsilon(box.x), this._checkWithEpsilon(box.y), this._checkWithEpsilon(box.z)));
  111663. break;
  111664. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].PlaneImpostor:
  111665. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Attention, PlaneImposter might not behave as you expect. Consider using BoxImposter instead");
  111666. returnValue = new this.BJSCANNON.Plane();
  111667. break;
  111668. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].MeshImpostor:
  111669. // should transform the vertex data to world coordinates!!
  111670. var rawVerts = object.getVerticesData ? object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) : [];
  111671. var rawFaces = object.getIndices ? object.getIndices() : [];
  111672. if (!rawVerts) {
  111673. return;
  111674. }
  111675. // get only scale! so the object could transform correctly.
  111676. var oldPosition = object.position.clone();
  111677. var oldRotation = object.rotation && object.rotation.clone();
  111678. var oldQuaternion = object.rotationQuaternion && object.rotationQuaternion.clone();
  111679. object.position.copyFromFloats(0, 0, 0);
  111680. object.rotation && object.rotation.copyFromFloats(0, 0, 0);
  111681. object.rotationQuaternion && object.rotationQuaternion.copyFrom(impostor.getParentsRotation());
  111682. object.rotationQuaternion && object.parent && object.rotationQuaternion.conjugateInPlace();
  111683. var transform = object.computeWorldMatrix(true);
  111684. // convert rawVerts to object space
  111685. var temp = new Array();
  111686. var index;
  111687. for (index = 0; index < rawVerts.length; index += 3) {
  111688. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(rawVerts, index), transform).toArray(temp, index);
  111689. }
  111690. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("MeshImpostor only collides against spheres.");
  111691. returnValue = new this.BJSCANNON.Trimesh(temp, rawFaces);
  111692. //now set back the transformation!
  111693. object.position.copyFrom(oldPosition);
  111694. oldRotation && object.rotation && object.rotation.copyFrom(oldRotation);
  111695. oldQuaternion && object.rotationQuaternion && object.rotationQuaternion.copyFrom(oldQuaternion);
  111696. break;
  111697. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor:
  111698. var oldPosition2 = object.position.clone();
  111699. var oldRotation2 = object.rotation && object.rotation.clone();
  111700. var oldQuaternion2 = object.rotationQuaternion && object.rotationQuaternion.clone();
  111701. object.position.copyFromFloats(0, 0, 0);
  111702. object.rotation && object.rotation.copyFromFloats(0, 0, 0);
  111703. object.rotationQuaternion && object.rotationQuaternion.copyFrom(impostor.getParentsRotation());
  111704. object.rotationQuaternion && object.parent && object.rotationQuaternion.conjugateInPlace();
  111705. object.rotationQuaternion && object.rotationQuaternion.multiplyInPlace(this._minus90X);
  111706. returnValue = this._createHeightmap(object);
  111707. object.position.copyFrom(oldPosition2);
  111708. oldRotation2 && object.rotation && object.rotation.copyFrom(oldRotation2);
  111709. oldQuaternion2 && object.rotationQuaternion && object.rotationQuaternion.copyFrom(oldQuaternion2);
  111710. object.computeWorldMatrix(true);
  111711. break;
  111712. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].ParticleImpostor:
  111713. returnValue = new this.BJSCANNON.Particle();
  111714. break;
  111715. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].NoImpostor:
  111716. returnValue = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(0, 0, 0));
  111717. break;
  111718. }
  111719. return returnValue;
  111720. };
  111721. CannonJSPlugin.prototype._createHeightmap = function (object, pointDepth) {
  111722. var pos = (object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind));
  111723. var transform = object.computeWorldMatrix(true);
  111724. // convert rawVerts to object space
  111725. var temp = new Array();
  111726. var index;
  111727. for (index = 0; index < pos.length; index += 3) {
  111728. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(pos, index), transform).toArray(temp, index);
  111729. }
  111730. pos = temp;
  111731. var matrix = new Array();
  111732. //For now pointDepth will not be used and will be automatically calculated.
  111733. //Future reference - try and find the best place to add a reference to the pointDepth variable.
  111734. var arraySize = pointDepth || ~~(Math.sqrt(pos.length / 3) - 1);
  111735. var boundingInfo = object.getBoundingInfo();
  111736. var dim = Math.min(boundingInfo.boundingBox.extendSizeWorld.x, boundingInfo.boundingBox.extendSizeWorld.y);
  111737. var minY = boundingInfo.boundingBox.extendSizeWorld.z;
  111738. var elementSize = dim * 2 / arraySize;
  111739. for (var i = 0; i < pos.length; i = i + 3) {
  111740. var x = Math.round((pos[i + 0]) / elementSize + arraySize / 2);
  111741. var z = Math.round(((pos[i + 1]) / elementSize - arraySize / 2) * -1);
  111742. var y = -pos[i + 2] + minY;
  111743. if (!matrix[x]) {
  111744. matrix[x] = [];
  111745. }
  111746. if (!matrix[x][z]) {
  111747. matrix[x][z] = y;
  111748. }
  111749. matrix[x][z] = Math.max(y, matrix[x][z]);
  111750. }
  111751. for (var x = 0; x <= arraySize; ++x) {
  111752. if (!matrix[x]) {
  111753. var loc = 1;
  111754. while (!matrix[(x + loc) % arraySize]) {
  111755. loc++;
  111756. }
  111757. matrix[x] = matrix[(x + loc) % arraySize].slice();
  111758. //console.log("missing x", x);
  111759. }
  111760. for (var z = 0; z <= arraySize; ++z) {
  111761. if (!matrix[x][z]) {
  111762. var loc = 1;
  111763. var newValue;
  111764. while (newValue === undefined) {
  111765. newValue = matrix[x][(z + loc++) % arraySize];
  111766. }
  111767. matrix[x][z] = newValue;
  111768. }
  111769. }
  111770. }
  111771. var shape = new this.BJSCANNON.Heightfield(matrix, {
  111772. elementSize: elementSize
  111773. });
  111774. //For future reference, needed for body transformation
  111775. shape.minY = minY;
  111776. return shape;
  111777. };
  111778. CannonJSPlugin.prototype._updatePhysicsBodyTransformation = function (impostor) {
  111779. var object = impostor.object;
  111780. //make sure it is updated...
  111781. object.computeWorldMatrix && object.computeWorldMatrix(true);
  111782. // The delta between the mesh position and the mesh bounding box center
  111783. var bInfo = object.getBoundingInfo();
  111784. if (!bInfo) {
  111785. return;
  111786. }
  111787. var center = impostor.getObjectCenter();
  111788. //m.getAbsolutePosition().subtract(m.getBoundingInfo().boundingBox.centerWorld)
  111789. this._tmpDeltaPosition.copyFrom(object.getAbsolutePivotPoint().subtract(center));
  111790. this._tmpDeltaPosition.divideInPlace(impostor.object.scaling);
  111791. this._tmpPosition.copyFrom(center);
  111792. var quaternion = object.rotationQuaternion;
  111793. if (!quaternion) {
  111794. return;
  111795. }
  111796. //is shape is a plane or a heightmap, it must be rotated 90 degs in the X axis.
  111797. //ideally these would be rotated at time of creation like cylinder but they dont extend ConvexPolyhedron
  111798. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].PlaneImpostor || impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor) {
  111799. //-90 DEG in X, precalculated
  111800. quaternion = quaternion.multiply(this._minus90X);
  111801. //Invert! (Precalculated, 90 deg in X)
  111802. //No need to clone. this will never change.
  111803. impostor.setDeltaRotation(this._plus90X);
  111804. }
  111805. //If it is a heightfield, if should be centered.
  111806. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor) {
  111807. var mesh = object;
  111808. var boundingInfo = mesh.getBoundingInfo();
  111809. //calculate the correct body position:
  111810. var rotationQuaternion = mesh.rotationQuaternion;
  111811. mesh.rotationQuaternion = this._tmpUnityRotation;
  111812. mesh.computeWorldMatrix(true);
  111813. //get original center with no rotation
  111814. var c = center.clone();
  111815. var oldPivot = mesh.getPivotMatrix();
  111816. if (oldPivot) {
  111817. // create a copy the pivot Matrix as it is modified in place
  111818. oldPivot = oldPivot.clone();
  111819. }
  111820. else {
  111821. oldPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  111822. }
  111823. //calculate the new center using a pivot (since this.BJSCANNON.js doesn't center height maps)
  111824. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Translation(boundingInfo.boundingBox.extendSizeWorld.x, 0, -boundingInfo.boundingBox.extendSizeWorld.z);
  111825. mesh.setPreTransformMatrix(p);
  111826. mesh.computeWorldMatrix(true);
  111827. //calculate the translation
  111828. var translation = boundingInfo.boundingBox.centerWorld.subtract(center).subtract(mesh.position).negate();
  111829. this._tmpPosition.copyFromFloats(translation.x, translation.y - boundingInfo.boundingBox.extendSizeWorld.y, translation.z);
  111830. //add it inverted to the delta
  111831. this._tmpDeltaPosition.copyFrom(boundingInfo.boundingBox.centerWorld.subtract(c));
  111832. this._tmpDeltaPosition.y += boundingInfo.boundingBox.extendSizeWorld.y;
  111833. //rotation is back
  111834. mesh.rotationQuaternion = rotationQuaternion;
  111835. mesh.setPreTransformMatrix(oldPivot);
  111836. mesh.computeWorldMatrix(true);
  111837. }
  111838. else if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].MeshImpostor) {
  111839. this._tmpDeltaPosition.copyFromFloats(0, 0, 0);
  111840. //this._tmpPosition.copyFrom(object.position);
  111841. }
  111842. impostor.setDeltaPosition(this._tmpDeltaPosition);
  111843. //Now update the impostor object
  111844. impostor.physicsBody.position.copy(this._tmpPosition);
  111845. impostor.physicsBody.quaternion.copy(quaternion);
  111846. };
  111847. CannonJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  111848. impostor.object.position.copyFrom(impostor.physicsBody.position);
  111849. if (impostor.object.rotationQuaternion) {
  111850. impostor.object.rotationQuaternion.copyFrom(impostor.physicsBody.quaternion);
  111851. }
  111852. };
  111853. CannonJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  111854. impostor.physicsBody.position.copy(newPosition);
  111855. impostor.physicsBody.quaternion.copy(newRotation);
  111856. };
  111857. CannonJSPlugin.prototype.isSupported = function () {
  111858. return this.BJSCANNON !== undefined;
  111859. };
  111860. CannonJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  111861. impostor.physicsBody.velocity.copy(velocity);
  111862. };
  111863. CannonJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  111864. impostor.physicsBody.angularVelocity.copy(velocity);
  111865. };
  111866. CannonJSPlugin.prototype.getLinearVelocity = function (impostor) {
  111867. var v = impostor.physicsBody.velocity;
  111868. if (!v) {
  111869. return null;
  111870. }
  111871. return new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](v.x, v.y, v.z);
  111872. };
  111873. CannonJSPlugin.prototype.getAngularVelocity = function (impostor) {
  111874. var v = impostor.physicsBody.angularVelocity;
  111875. if (!v) {
  111876. return null;
  111877. }
  111878. return new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](v.x, v.y, v.z);
  111879. };
  111880. CannonJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  111881. impostor.physicsBody.mass = mass;
  111882. impostor.physicsBody.updateMassProperties();
  111883. };
  111884. CannonJSPlugin.prototype.getBodyMass = function (impostor) {
  111885. return impostor.physicsBody.mass;
  111886. };
  111887. CannonJSPlugin.prototype.getBodyFriction = function (impostor) {
  111888. return impostor.physicsBody.material.friction;
  111889. };
  111890. CannonJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  111891. impostor.physicsBody.material.friction = friction;
  111892. };
  111893. CannonJSPlugin.prototype.getBodyRestitution = function (impostor) {
  111894. return impostor.physicsBody.material.restitution;
  111895. };
  111896. CannonJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  111897. impostor.physicsBody.material.restitution = restitution;
  111898. };
  111899. CannonJSPlugin.prototype.sleepBody = function (impostor) {
  111900. impostor.physicsBody.sleep();
  111901. };
  111902. CannonJSPlugin.prototype.wakeUpBody = function (impostor) {
  111903. impostor.physicsBody.wakeUp();
  111904. };
  111905. CannonJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance) {
  111906. joint.physicsJoint.distance = maxDistance;
  111907. };
  111908. // private enableMotor(joint: IMotorEnabledJoint, motorIndex?: number) {
  111909. // if (!motorIndex) {
  111910. // joint.physicsJoint.enableMotor();
  111911. // }
  111912. // }
  111913. // private disableMotor(joint: IMotorEnabledJoint, motorIndex?: number) {
  111914. // if (!motorIndex) {
  111915. // joint.physicsJoint.disableMotor();
  111916. // }
  111917. // }
  111918. CannonJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
  111919. if (!motorIndex) {
  111920. joint.physicsJoint.enableMotor();
  111921. joint.physicsJoint.setMotorSpeed(speed);
  111922. if (maxForce) {
  111923. this.setLimit(joint, maxForce);
  111924. }
  111925. }
  111926. };
  111927. CannonJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit) {
  111928. joint.physicsJoint.motorEquation.maxForce = upperLimit;
  111929. joint.physicsJoint.motorEquation.minForce = lowerLimit === void 0 ? -upperLimit : lowerLimit;
  111930. };
  111931. CannonJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  111932. var body = impostor.physicsBody;
  111933. mesh.position.x = body.position.x;
  111934. mesh.position.y = body.position.y;
  111935. mesh.position.z = body.position.z;
  111936. if (mesh.rotationQuaternion) {
  111937. mesh.rotationQuaternion.x = body.quaternion.x;
  111938. mesh.rotationQuaternion.y = body.quaternion.y;
  111939. mesh.rotationQuaternion.z = body.quaternion.z;
  111940. mesh.rotationQuaternion.w = body.quaternion.w;
  111941. }
  111942. };
  111943. CannonJSPlugin.prototype.getRadius = function (impostor) {
  111944. var shape = impostor.physicsBody.shapes[0];
  111945. return shape.boundingSphereRadius;
  111946. };
  111947. CannonJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  111948. var shape = impostor.physicsBody.shapes[0];
  111949. result.x = shape.halfExtents.x * 2;
  111950. result.y = shape.halfExtents.y * 2;
  111951. result.z = shape.halfExtents.z * 2;
  111952. };
  111953. CannonJSPlugin.prototype.dispose = function () {
  111954. };
  111955. CannonJSPlugin.prototype._extendNamespace = function () {
  111956. //this will force cannon to execute at least one step when using interpolation
  111957. var step_tmp1 = new this.BJSCANNON.Vec3();
  111958. var Engine = this.BJSCANNON;
  111959. this.BJSCANNON.World.prototype.step = function (dt, timeSinceLastCalled, maxSubSteps) {
  111960. maxSubSteps = maxSubSteps || 10;
  111961. timeSinceLastCalled = timeSinceLastCalled || 0;
  111962. if (timeSinceLastCalled === 0) {
  111963. this.internalStep(dt);
  111964. this.time += dt;
  111965. }
  111966. else {
  111967. var internalSteps = Math.floor((this.time + timeSinceLastCalled) / dt) - Math.floor(this.time / dt);
  111968. internalSteps = Math.min(internalSteps, maxSubSteps) || 1;
  111969. var t0 = performance.now();
  111970. for (var i = 0; i !== internalSteps; i++) {
  111971. this.internalStep(dt);
  111972. if (performance.now() - t0 > dt * 1000) {
  111973. break;
  111974. }
  111975. }
  111976. this.time += timeSinceLastCalled;
  111977. var h = this.time % dt;
  111978. var h_div_dt = h / dt;
  111979. var interpvelo = step_tmp1;
  111980. var bodies = this.bodies;
  111981. for (var j = 0; j !== bodies.length; j++) {
  111982. var b = bodies[j];
  111983. if (b.type !== Engine.Body.STATIC && b.sleepState !== Engine.Body.SLEEPING) {
  111984. b.position.vsub(b.previousPosition, interpvelo);
  111985. interpvelo.scale(h_div_dt, interpvelo);
  111986. b.position.vadd(interpvelo, b.interpolatedPosition);
  111987. }
  111988. else {
  111989. b.interpolatedPosition.copy(b.position);
  111990. b.interpolatedQuaternion.copy(b.quaternion);
  111991. }
  111992. }
  111993. }
  111994. };
  111995. };
  111996. return CannonJSPlugin;
  111997. }());
  111998. _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].DefaultPluginFactory = function () { return new CannonJSPlugin(); };
  111999. /***/ }),
  112000. /***/ "./Physics/Plugins/index.ts":
  112001. /*!**********************************!*\
  112002. !*** ./Physics/Plugins/index.ts ***!
  112003. \**********************************/
  112004. /*! exports provided: CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin */
  112005. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112006. "use strict";
  112007. __webpack_require__.r(__webpack_exports__);
  112008. /* harmony import */ var _cannonJSPlugin__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cannonJSPlugin */ "./Physics/Plugins/cannonJSPlugin.ts");
  112009. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _cannonJSPlugin__WEBPACK_IMPORTED_MODULE_0__["CannonJSPlugin"]; });
  112010. /* harmony import */ var _ammoJSPlugin__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ammoJSPlugin */ "./Physics/Plugins/ammoJSPlugin.ts");
  112011. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _ammoJSPlugin__WEBPACK_IMPORTED_MODULE_1__["AmmoJSPlugin"]; });
  112012. /* harmony import */ var _oimoJSPlugin__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./oimoJSPlugin */ "./Physics/Plugins/oimoJSPlugin.ts");
  112013. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _oimoJSPlugin__WEBPACK_IMPORTED_MODULE_2__["OimoJSPlugin"]; });
  112014. /***/ }),
  112015. /***/ "./Physics/Plugins/oimoJSPlugin.ts":
  112016. /*!*****************************************!*\
  112017. !*** ./Physics/Plugins/oimoJSPlugin.ts ***!
  112018. \*****************************************/
  112019. /*! exports provided: OimoJSPlugin */
  112020. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112021. "use strict";
  112022. __webpack_require__.r(__webpack_exports__);
  112023. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return OimoJSPlugin; });
  112024. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  112025. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  112026. /* harmony import */ var _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Physics/physicsEngine */ "./Physics/physicsEngine.ts");
  112027. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  112028. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  112029. /** @hidden */
  112030. var OimoJSPlugin = /** @class */ (function () {
  112031. function OimoJSPlugin(iterations, oimoInjection) {
  112032. if (oimoInjection === void 0) { oimoInjection = OIMO; }
  112033. this.name = "OimoJSPlugin";
  112034. this._tmpImpostorsArray = [];
  112035. this._tmpPositionVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  112036. this.BJSOIMO = oimoInjection;
  112037. this.world = new this.BJSOIMO.World({
  112038. iterations: iterations
  112039. });
  112040. this.world.clear();
  112041. }
  112042. OimoJSPlugin.prototype.setGravity = function (gravity) {
  112043. this.world.gravity.copy(gravity);
  112044. };
  112045. OimoJSPlugin.prototype.setTimeStep = function (timeStep) {
  112046. this.world.timeStep = timeStep;
  112047. };
  112048. OimoJSPlugin.prototype.getTimeStep = function () {
  112049. return this.world.timeStep;
  112050. };
  112051. OimoJSPlugin.prototype.executeStep = function (delta, impostors) {
  112052. var _this = this;
  112053. impostors.forEach(function (impostor) {
  112054. impostor.beforeStep();
  112055. });
  112056. this.world.step();
  112057. impostors.forEach(function (impostor) {
  112058. impostor.afterStep();
  112059. //update the ordered impostors array
  112060. _this._tmpImpostorsArray[impostor.uniqueId] = impostor;
  112061. });
  112062. //check for collisions
  112063. var contact = this.world.contacts;
  112064. while (contact !== null) {
  112065. if (contact.touching && !contact.body1.sleeping && !contact.body2.sleeping) {
  112066. contact = contact.next;
  112067. continue;
  112068. }
  112069. //is this body colliding with any other? get the impostor
  112070. var mainImpostor = this._tmpImpostorsArray[+contact.body1.name];
  112071. var collidingImpostor = this._tmpImpostorsArray[+contact.body2.name];
  112072. if (!mainImpostor || !collidingImpostor) {
  112073. contact = contact.next;
  112074. continue;
  112075. }
  112076. mainImpostor.onCollide({ body: collidingImpostor.physicsBody });
  112077. collidingImpostor.onCollide({ body: mainImpostor.physicsBody });
  112078. contact = contact.next;
  112079. }
  112080. };
  112081. OimoJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  112082. var mass = impostor.physicsBody.mass;
  112083. impostor.physicsBody.applyImpulse(contactPoint.scale(this.world.invScale), force.scale(this.world.invScale * mass));
  112084. };
  112085. OimoJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  112086. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("Oimo doesn't support applying force. Using impule instead.");
  112087. this.applyImpulse(impostor, force, contactPoint);
  112088. };
  112089. OimoJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  112090. var _this = this;
  112091. //parent-child relationship. Does this impostor has a parent impostor?
  112092. if (impostor.parent) {
  112093. if (impostor.physicsBody) {
  112094. this.removePhysicsBody(impostor);
  112095. //TODO is that needed?
  112096. impostor.forceUpdate();
  112097. }
  112098. return;
  112099. }
  112100. if (impostor.isBodyInitRequired()) {
  112101. var bodyConfig = {
  112102. name: impostor.uniqueId,
  112103. //Oimo must have mass, also for static objects.
  112104. config: [impostor.getParam("mass") || 1, impostor.getParam("friction"), impostor.getParam("restitution")],
  112105. size: [],
  112106. type: [],
  112107. pos: [],
  112108. posShape: [],
  112109. rot: [],
  112110. rotShape: [],
  112111. move: impostor.getParam("mass") !== 0,
  112112. density: impostor.getParam("mass"),
  112113. friction: impostor.getParam("friction"),
  112114. restitution: impostor.getParam("restitution"),
  112115. //Supporting older versions of Oimo
  112116. world: this.world
  112117. };
  112118. var impostors = [impostor];
  112119. var addToArray = function (parent) {
  112120. if (!parent.getChildMeshes) {
  112121. return;
  112122. }
  112123. parent.getChildMeshes().forEach(function (m) {
  112124. if (m.physicsImpostor) {
  112125. impostors.push(m.physicsImpostor);
  112126. //m.physicsImpostor._init();
  112127. }
  112128. });
  112129. };
  112130. addToArray(impostor.object);
  112131. var checkWithEpsilon_1 = function (value) {
  112132. return Math.max(value, _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_2__["PhysicsEngine"].Epsilon);
  112133. };
  112134. var globalQuaternion_1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  112135. impostors.forEach(function (i) {
  112136. if (!i.object.rotationQuaternion) {
  112137. return;
  112138. }
  112139. //get the correct bounding box
  112140. var oldQuaternion = i.object.rotationQuaternion;
  112141. globalQuaternion_1 = oldQuaternion.clone();
  112142. var rot = oldQuaternion.toEulerAngles();
  112143. var extendSize = i.getObjectExtendSize();
  112144. var radToDeg = 57.295779513082320876;
  112145. if (i === impostor) {
  112146. var center = impostor.getObjectCenter();
  112147. impostor.object.getAbsolutePivotPoint().subtractToRef(center, _this._tmpPositionVector);
  112148. _this._tmpPositionVector.divideInPlace(impostor.object.scaling);
  112149. //Can also use Array.prototype.push.apply
  112150. bodyConfig.pos.push(center.x);
  112151. bodyConfig.pos.push(center.y);
  112152. bodyConfig.pos.push(center.z);
  112153. bodyConfig.posShape.push(0, 0, 0);
  112154. bodyConfig.rotShape.push(0, 0, 0);
  112155. }
  112156. else {
  112157. var localPosition = i.object.getAbsolutePosition().subtract(impostor.object.getAbsolutePosition());
  112158. bodyConfig.posShape.push(localPosition.x);
  112159. bodyConfig.posShape.push(localPosition.y);
  112160. bodyConfig.posShape.push(localPosition.z);
  112161. bodyConfig.pos.push(0, 0, 0);
  112162. bodyConfig.rotShape.push(rot.x * radToDeg);
  112163. bodyConfig.rotShape.push(rot.y * radToDeg);
  112164. bodyConfig.rotShape.push(rot.z * radToDeg);
  112165. }
  112166. // register mesh
  112167. switch (i.type) {
  112168. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].ParticleImpostor:
  112169. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("No Particle support in OIMO.js. using SphereImpostor instead");
  112170. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].SphereImpostor:
  112171. var radiusX = extendSize.x;
  112172. var radiusY = extendSize.y;
  112173. var radiusZ = extendSize.z;
  112174. var size = Math.max(checkWithEpsilon_1(radiusX), checkWithEpsilon_1(radiusY), checkWithEpsilon_1(radiusZ)) / 2;
  112175. bodyConfig.type.push('sphere');
  112176. //due to the way oimo works with compounds, add 3 times
  112177. bodyConfig.size.push(size);
  112178. bodyConfig.size.push(size);
  112179. bodyConfig.size.push(size);
  112180. break;
  112181. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].CylinderImpostor:
  112182. var sizeX = checkWithEpsilon_1(extendSize.x) / 2;
  112183. var sizeY = checkWithEpsilon_1(extendSize.y);
  112184. bodyConfig.type.push('cylinder');
  112185. bodyConfig.size.push(sizeX);
  112186. bodyConfig.size.push(sizeY);
  112187. //due to the way oimo works with compounds, add one more value.
  112188. bodyConfig.size.push(sizeY);
  112189. break;
  112190. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].PlaneImpostor:
  112191. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].BoxImpostor:
  112192. default:
  112193. var sizeX = checkWithEpsilon_1(extendSize.x);
  112194. var sizeY = checkWithEpsilon_1(extendSize.y);
  112195. var sizeZ = checkWithEpsilon_1(extendSize.z);
  112196. bodyConfig.type.push('box');
  112197. //if (i === impostor) {
  112198. bodyConfig.size.push(sizeX);
  112199. bodyConfig.size.push(sizeY);
  112200. bodyConfig.size.push(sizeZ);
  112201. //} else {
  112202. // bodyConfig.size.push(0,0,0);
  112203. //}
  112204. break;
  112205. }
  112206. //actually not needed, but hey...
  112207. i.object.rotationQuaternion = oldQuaternion;
  112208. });
  112209. impostor.physicsBody = this.world.add(bodyConfig);
  112210. // set the quaternion, ignoring the previously defined (euler) rotation
  112211. impostor.physicsBody.resetQuaternion(globalQuaternion_1);
  112212. // update with delta 0, so the body will reveive the new rotation.
  112213. impostor.physicsBody.updatePosition(0);
  112214. }
  112215. else {
  112216. this._tmpPositionVector.copyFromFloats(0, 0, 0);
  112217. }
  112218. impostor.setDeltaPosition(this._tmpPositionVector);
  112219. //this._tmpPositionVector.addInPlace(impostor.mesh.getBoundingInfo().boundingBox.center);
  112220. //this.setPhysicsBodyTransformation(impostor, this._tmpPositionVector, impostor.mesh.rotationQuaternion);
  112221. };
  112222. OimoJSPlugin.prototype.removePhysicsBody = function (impostor) {
  112223. //impostor.physicsBody.dispose();
  112224. //Same as : (older oimo versions)
  112225. this.world.removeRigidBody(impostor.physicsBody);
  112226. };
  112227. OimoJSPlugin.prototype.generateJoint = function (impostorJoint) {
  112228. var mainBody = impostorJoint.mainImpostor.physicsBody;
  112229. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  112230. if (!mainBody || !connectedBody) {
  112231. return;
  112232. }
  112233. var jointData = impostorJoint.joint.jointData;
  112234. var options = jointData.nativeParams || {};
  112235. var type;
  112236. var nativeJointData = {
  112237. body1: mainBody,
  112238. body2: connectedBody,
  112239. axe1: options.axe1 || (jointData.mainAxis ? jointData.mainAxis.asArray() : null),
  112240. axe2: options.axe2 || (jointData.connectedAxis ? jointData.connectedAxis.asArray() : null),
  112241. pos1: options.pos1 || (jointData.mainPivot ? jointData.mainPivot.asArray() : null),
  112242. pos2: options.pos2 || (jointData.connectedPivot ? jointData.connectedPivot.asArray() : null),
  112243. min: options.min,
  112244. max: options.max,
  112245. collision: options.collision || jointData.collision,
  112246. spring: options.spring,
  112247. //supporting older version of Oimo
  112248. world: this.world
  112249. };
  112250. switch (impostorJoint.joint.type) {
  112251. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].BallAndSocketJoint:
  112252. type = "jointBall";
  112253. break;
  112254. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].SpringJoint:
  112255. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("OIMO.js doesn't support Spring Constraint. Simulating using DistanceJoint instead");
  112256. var springData = jointData;
  112257. nativeJointData.min = springData.length || nativeJointData.min;
  112258. //Max should also be set, just make sure it is at least min
  112259. nativeJointData.max = Math.max(nativeJointData.min, nativeJointData.max);
  112260. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].DistanceJoint:
  112261. type = "jointDistance";
  112262. nativeJointData.max = jointData.maxDistance;
  112263. break;
  112264. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].PrismaticJoint:
  112265. type = "jointPrisme";
  112266. break;
  112267. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].SliderJoint:
  112268. type = "jointSlide";
  112269. break;
  112270. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].WheelJoint:
  112271. type = "jointWheel";
  112272. break;
  112273. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].HingeJoint:
  112274. default:
  112275. type = "jointHinge";
  112276. break;
  112277. }
  112278. nativeJointData.type = type;
  112279. impostorJoint.joint.physicsJoint = this.world.add(nativeJointData);
  112280. };
  112281. OimoJSPlugin.prototype.removeJoint = function (impostorJoint) {
  112282. //Bug in Oimo prevents us from disposing a joint in the playground
  112283. //joint.joint.physicsJoint.dispose();
  112284. //So we will bruteforce it!
  112285. try {
  112286. this.world.removeJoint(impostorJoint.joint.physicsJoint);
  112287. }
  112288. catch (e) {
  112289. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn(e);
  112290. }
  112291. };
  112292. OimoJSPlugin.prototype.isSupported = function () {
  112293. return this.BJSOIMO !== undefined;
  112294. };
  112295. OimoJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  112296. if (!impostor.physicsBody.sleeping) {
  112297. //TODO check that
  112298. /*if (impostor.physicsBody.shapes.next) {
  112299. var parentShape = this._getLastShape(impostor.physicsBody);
  112300. impostor.object.position.copyFrom(parentShape.position);
  112301. console.log(parentShape.position);
  112302. } else {*/
  112303. impostor.object.position.copyFrom(impostor.physicsBody.getPosition());
  112304. //}
  112305. if (impostor.object.rotationQuaternion) {
  112306. impostor.object.rotationQuaternion.copyFrom(impostor.physicsBody.getQuaternion());
  112307. }
  112308. }
  112309. };
  112310. OimoJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  112311. var body = impostor.physicsBody;
  112312. body.position.copy(newPosition);
  112313. body.orientation.copy(newRotation);
  112314. body.syncShapes();
  112315. body.awake();
  112316. };
  112317. /*private _getLastShape(body: any): any {
  112318. var lastShape = body.shapes;
  112319. while (lastShape.next) {
  112320. lastShape = lastShape.next;
  112321. }
  112322. return lastShape;
  112323. }*/
  112324. OimoJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  112325. impostor.physicsBody.linearVelocity.copy(velocity);
  112326. };
  112327. OimoJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  112328. impostor.physicsBody.angularVelocity.copy(velocity);
  112329. };
  112330. OimoJSPlugin.prototype.getLinearVelocity = function (impostor) {
  112331. var v = impostor.physicsBody.linearVelocity;
  112332. if (!v) {
  112333. return null;
  112334. }
  112335. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](v.x, v.y, v.z);
  112336. };
  112337. OimoJSPlugin.prototype.getAngularVelocity = function (impostor) {
  112338. var v = impostor.physicsBody.angularVelocity;
  112339. if (!v) {
  112340. return null;
  112341. }
  112342. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](v.x, v.y, v.z);
  112343. };
  112344. OimoJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  112345. var staticBody = mass === 0;
  112346. //this will actually set the body's density and not its mass.
  112347. //But this is how oimo treats the mass variable.
  112348. impostor.physicsBody.shapes.density = staticBody ? 1 : mass;
  112349. impostor.physicsBody.setupMass(staticBody ? 0x2 : 0x1);
  112350. };
  112351. OimoJSPlugin.prototype.getBodyMass = function (impostor) {
  112352. return impostor.physicsBody.shapes.density;
  112353. };
  112354. OimoJSPlugin.prototype.getBodyFriction = function (impostor) {
  112355. return impostor.physicsBody.shapes.friction;
  112356. };
  112357. OimoJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  112358. impostor.physicsBody.shapes.friction = friction;
  112359. };
  112360. OimoJSPlugin.prototype.getBodyRestitution = function (impostor) {
  112361. return impostor.physicsBody.shapes.restitution;
  112362. };
  112363. OimoJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  112364. impostor.physicsBody.shapes.restitution = restitution;
  112365. };
  112366. OimoJSPlugin.prototype.sleepBody = function (impostor) {
  112367. impostor.physicsBody.sleep();
  112368. };
  112369. OimoJSPlugin.prototype.wakeUpBody = function (impostor) {
  112370. impostor.physicsBody.awake();
  112371. };
  112372. OimoJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance, minDistance) {
  112373. joint.physicsJoint.limitMotor.upperLimit = maxDistance;
  112374. if (minDistance !== void 0) {
  112375. joint.physicsJoint.limitMotor.lowerLimit = minDistance;
  112376. }
  112377. };
  112378. OimoJSPlugin.prototype.setMotor = function (joint, speed, force, motorIndex) {
  112379. if (force !== undefined) {
  112380. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("OimoJS plugin currently has unexpected behavior when using setMotor with force parameter");
  112381. }
  112382. else {
  112383. force = 1e6;
  112384. }
  112385. speed *= -1;
  112386. //TODO separate rotational and transational motors.
  112387. var motor = motorIndex ? joint.physicsJoint.rotationalLimitMotor2 : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.rotationalLimitMotor || joint.physicsJoint.limitMotor;
  112388. if (motor) {
  112389. motor.setMotor(speed, force);
  112390. }
  112391. };
  112392. OimoJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit, motorIndex) {
  112393. //TODO separate rotational and transational motors.
  112394. var motor = motorIndex ? joint.physicsJoint.rotationalLimitMotor2 : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.rotationalLimitMotor || joint.physicsJoint.limitMotor;
  112395. if (motor) {
  112396. motor.setLimit(upperLimit, lowerLimit === void 0 ? -upperLimit : lowerLimit);
  112397. }
  112398. };
  112399. OimoJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  112400. var body = impostor.physicsBody;
  112401. mesh.position.x = body.position.x;
  112402. mesh.position.y = body.position.y;
  112403. mesh.position.z = body.position.z;
  112404. if (mesh.rotationQuaternion) {
  112405. mesh.rotationQuaternion.x = body.orientation.x;
  112406. mesh.rotationQuaternion.y = body.orientation.y;
  112407. mesh.rotationQuaternion.z = body.orientation.z;
  112408. mesh.rotationQuaternion.w = body.orientation.s;
  112409. }
  112410. };
  112411. OimoJSPlugin.prototype.getRadius = function (impostor) {
  112412. return impostor.physicsBody.shapes.radius;
  112413. };
  112414. OimoJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  112415. var shape = impostor.physicsBody.shapes;
  112416. result.x = shape.halfWidth * 2;
  112417. result.y = shape.halfHeight * 2;
  112418. result.z = shape.halfDepth * 2;
  112419. };
  112420. OimoJSPlugin.prototype.dispose = function () {
  112421. this.world.clear();
  112422. };
  112423. return OimoJSPlugin;
  112424. }());
  112425. /***/ }),
  112426. /***/ "./Physics/index.ts":
  112427. /*!**************************!*\
  112428. !*** ./Physics/index.ts ***!
  112429. \**************************/
  112430. /*! exports provided: PhysicsEngine, PhysicsEngineSceneComponent, PhysicsHelper, PhysicsRadialExplosionEvent, PhysicsGravitationalFieldEvent, PhysicsUpdraftEvent, PhysicsVortexEvent, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode, PhysicsImpostor, PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint, CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin */
  112431. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112432. "use strict";
  112433. __webpack_require__.r(__webpack_exports__);
  112434. /* harmony import */ var _physicsEngine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./physicsEngine */ "./Physics/physicsEngine.ts");
  112435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _physicsEngine__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngine"]; });
  112436. /* harmony import */ var _physicsEngineComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./physicsEngineComponent */ "./Physics/physicsEngineComponent.ts");
  112437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _physicsEngineComponent__WEBPACK_IMPORTED_MODULE_1__["PhysicsEngineSceneComponent"]; });
  112438. /* harmony import */ var _physicsHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./physicsHelper */ "./Physics/physicsHelper.ts");
  112439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsHelper"]; });
  112440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEvent", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsRadialExplosionEvent"]; });
  112441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsGravitationalFieldEvent", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsGravitationalFieldEvent"]; });
  112442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEvent", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsUpdraftEvent"]; });
  112443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEvent", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsVortexEvent"]; });
  112444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsRadialImpulseFalloff"]; });
  112445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsUpdraftMode"]; });
  112446. /* harmony import */ var _physicsImpostor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./physicsImpostor */ "./Physics/physicsImpostor.ts");
  112447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"]; });
  112448. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  112449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"]; });
  112450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["DistanceJoint"]; });
  112451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["MotorEnabledJoint"]; });
  112452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["HingeJoint"]; });
  112453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["Hinge2Joint"]; });
  112454. /* harmony import */ var _Plugins_index__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Plugins/index */ "./Physics/Plugins/index.ts");
  112455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["CannonJSPlugin"]; });
  112456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["AmmoJSPlugin"]; });
  112457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["OimoJSPlugin"]; });
  112458. /***/ }),
  112459. /***/ "./Physics/physicsEngine.ts":
  112460. /*!**********************************!*\
  112461. !*** ./Physics/physicsEngine.ts ***!
  112462. \**********************************/
  112463. /*! exports provided: PhysicsEngine */
  112464. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112465. "use strict";
  112466. __webpack_require__.r(__webpack_exports__);
  112467. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return PhysicsEngine; });
  112468. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  112469. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  112470. /**
  112471. * Class used to control physics engine
  112472. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  112473. */
  112474. var PhysicsEngine = /** @class */ (function () {
  112475. /**
  112476. * Creates a new Physics Engine
  112477. * @param gravity defines the gravity vector used by the simulation
  112478. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  112479. */
  112480. function PhysicsEngine(gravity, _physicsPlugin) {
  112481. if (_physicsPlugin === void 0) { _physicsPlugin = PhysicsEngine.DefaultPluginFactory(); }
  112482. this._physicsPlugin = _physicsPlugin;
  112483. this._impostors = [];
  112484. this._joints = [];
  112485. if (!this._physicsPlugin.isSupported()) {
  112486. throw new Error("Physics Engine " + this._physicsPlugin.name + " cannot be found. "
  112487. + "Please make sure it is included.");
  112488. }
  112489. gravity = gravity || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -9.807, 0);
  112490. this.setGravity(gravity);
  112491. this.setTimeStep();
  112492. }
  112493. /**
  112494. * Factory used to create the default physics plugin.
  112495. * @returns The default physics plugin
  112496. */
  112497. PhysicsEngine.DefaultPluginFactory = function () {
  112498. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_1__["_DevTools"].WarnImport("CannonJSPlugin");
  112499. };
  112500. /**
  112501. * Sets the gravity vector used by the simulation
  112502. * @param gravity defines the gravity vector to use
  112503. */
  112504. PhysicsEngine.prototype.setGravity = function (gravity) {
  112505. this.gravity = gravity;
  112506. this._physicsPlugin.setGravity(this.gravity);
  112507. };
  112508. /**
  112509. * Set the time step of the physics engine.
  112510. * Default is 1/60.
  112511. * To slow it down, enter 1/600 for example.
  112512. * To speed it up, 1/30
  112513. * @param newTimeStep defines the new timestep to apply to this world.
  112514. */
  112515. PhysicsEngine.prototype.setTimeStep = function (newTimeStep) {
  112516. if (newTimeStep === void 0) { newTimeStep = 1 / 60; }
  112517. this._physicsPlugin.setTimeStep(newTimeStep);
  112518. };
  112519. /**
  112520. * Get the time step of the physics engine.
  112521. * @returns the current time step
  112522. */
  112523. PhysicsEngine.prototype.getTimeStep = function () {
  112524. return this._physicsPlugin.getTimeStep();
  112525. };
  112526. /**
  112527. * Release all resources
  112528. */
  112529. PhysicsEngine.prototype.dispose = function () {
  112530. this._impostors.forEach(function (impostor) {
  112531. impostor.dispose();
  112532. });
  112533. this._physicsPlugin.dispose();
  112534. };
  112535. /**
  112536. * Gets the name of the current physics plugin
  112537. * @returns the name of the plugin
  112538. */
  112539. PhysicsEngine.prototype.getPhysicsPluginName = function () {
  112540. return this._physicsPlugin.name;
  112541. };
  112542. /**
  112543. * Adding a new impostor for the impostor tracking.
  112544. * This will be done by the impostor itself.
  112545. * @param impostor the impostor to add
  112546. */
  112547. PhysicsEngine.prototype.addImpostor = function (impostor) {
  112548. impostor.uniqueId = this._impostors.push(impostor);
  112549. //if no parent, generate the body
  112550. if (!impostor.parent) {
  112551. this._physicsPlugin.generatePhysicsBody(impostor);
  112552. }
  112553. };
  112554. /**
  112555. * Remove an impostor from the engine.
  112556. * This impostor and its mesh will not longer be updated by the physics engine.
  112557. * @param impostor the impostor to remove
  112558. */
  112559. PhysicsEngine.prototype.removeImpostor = function (impostor) {
  112560. var index = this._impostors.indexOf(impostor);
  112561. if (index > -1) {
  112562. var removed = this._impostors.splice(index, 1);
  112563. //Is it needed?
  112564. if (removed.length) {
  112565. //this will also remove it from the world.
  112566. removed[0].physicsBody = null;
  112567. }
  112568. }
  112569. };
  112570. /**
  112571. * Add a joint to the physics engine
  112572. * @param mainImpostor defines the main impostor to which the joint is added.
  112573. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  112574. * @param joint defines the joint that will connect both impostors.
  112575. */
  112576. PhysicsEngine.prototype.addJoint = function (mainImpostor, connectedImpostor, joint) {
  112577. var impostorJoint = {
  112578. mainImpostor: mainImpostor,
  112579. connectedImpostor: connectedImpostor,
  112580. joint: joint
  112581. };
  112582. joint.physicsPlugin = this._physicsPlugin;
  112583. this._joints.push(impostorJoint);
  112584. this._physicsPlugin.generateJoint(impostorJoint);
  112585. };
  112586. /**
  112587. * Removes a joint from the simulation
  112588. * @param mainImpostor defines the impostor used with the joint
  112589. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  112590. * @param joint defines the joint to remove
  112591. */
  112592. PhysicsEngine.prototype.removeJoint = function (mainImpostor, connectedImpostor, joint) {
  112593. var matchingJoints = this._joints.filter(function (impostorJoint) {
  112594. return (impostorJoint.connectedImpostor === connectedImpostor
  112595. && impostorJoint.joint === joint
  112596. && impostorJoint.mainImpostor === mainImpostor);
  112597. });
  112598. if (matchingJoints.length) {
  112599. this._physicsPlugin.removeJoint(matchingJoints[0]);
  112600. //TODO remove it from the list as well
  112601. }
  112602. };
  112603. /**
  112604. * Called by the scene. No need to call it.
  112605. * @param delta defines the timespam between frames
  112606. */
  112607. PhysicsEngine.prototype._step = function (delta) {
  112608. var _this = this;
  112609. //check if any mesh has no body / requires an update
  112610. this._impostors.forEach(function (impostor) {
  112611. if (impostor.isBodyInitRequired()) {
  112612. _this._physicsPlugin.generatePhysicsBody(impostor);
  112613. }
  112614. });
  112615. if (delta > 0.1) {
  112616. delta = 0.1;
  112617. }
  112618. else if (delta <= 0) {
  112619. delta = 1.0 / 60.0;
  112620. }
  112621. this._physicsPlugin.executeStep(delta, this._impostors);
  112622. };
  112623. /**
  112624. * Gets the current plugin used to run the simulation
  112625. * @returns current plugin
  112626. */
  112627. PhysicsEngine.prototype.getPhysicsPlugin = function () {
  112628. return this._physicsPlugin;
  112629. };
  112630. /**
  112631. * Gets the list of physic impostors
  112632. * @returns an array of PhysicsImpostor
  112633. */
  112634. PhysicsEngine.prototype.getImpostors = function () {
  112635. return this._impostors;
  112636. };
  112637. /**
  112638. * Gets the impostor for a physics enabled object
  112639. * @param object defines the object impersonated by the impostor
  112640. * @returns the PhysicsImpostor or null if not found
  112641. */
  112642. PhysicsEngine.prototype.getImpostorForPhysicsObject = function (object) {
  112643. for (var i = 0; i < this._impostors.length; ++i) {
  112644. if (this._impostors[i].object === object) {
  112645. return this._impostors[i];
  112646. }
  112647. }
  112648. return null;
  112649. };
  112650. /**
  112651. * Gets the impostor for a physics body object
  112652. * @param body defines physics body used by the impostor
  112653. * @returns the PhysicsImpostor or null if not found
  112654. */
  112655. PhysicsEngine.prototype.getImpostorWithPhysicsBody = function (body) {
  112656. for (var i = 0; i < this._impostors.length; ++i) {
  112657. if (this._impostors[i].physicsBody === body) {
  112658. return this._impostors[i];
  112659. }
  112660. }
  112661. return null;
  112662. };
  112663. /**
  112664. * Global value used to control the smallest number supported by the simulation
  112665. */
  112666. PhysicsEngine.Epsilon = 0.001;
  112667. return PhysicsEngine;
  112668. }());
  112669. /***/ }),
  112670. /***/ "./Physics/physicsEngineComponent.ts":
  112671. /*!*******************************************!*\
  112672. !*** ./Physics/physicsEngineComponent.ts ***!
  112673. \*******************************************/
  112674. /*! exports provided: PhysicsEngineSceneComponent */
  112675. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112676. "use strict";
  112677. __webpack_require__.r(__webpack_exports__);
  112678. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return PhysicsEngineSceneComponent; });
  112679. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  112680. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  112681. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  112682. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  112683. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  112684. /* harmony import */ var _physicsEngine__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./physicsEngine */ "./Physics/physicsEngine.ts");
  112685. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  112686. /**
  112687. * Gets the current physics engine
  112688. * @returns a IPhysicsEngine or null if none attached
  112689. */
  112690. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.getPhysicsEngine = function () {
  112691. return this._physicsEngine;
  112692. };
  112693. /**
  112694. * Enables physics to the current scene
  112695. * @param gravity defines the scene's gravity for the physics engine
  112696. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  112697. * @return a boolean indicating if the physics engine was initialized
  112698. */
  112699. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.enablePhysics = function (gravity, plugin) {
  112700. if (gravity === void 0) { gravity = null; }
  112701. if (this._physicsEngine) {
  112702. return true;
  112703. }
  112704. // Register the component to the scene
  112705. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_PHYSICSENGINE);
  112706. if (!component) {
  112707. component = new PhysicsEngineSceneComponent(this);
  112708. this._addComponent(component);
  112709. }
  112710. try {
  112711. this._physicsEngine = new _physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"](gravity, plugin);
  112712. return true;
  112713. }
  112714. catch (e) {
  112715. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error(e.message);
  112716. return false;
  112717. }
  112718. };
  112719. /**
  112720. * Disables and disposes the physics engine associated with the scene
  112721. */
  112722. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.disablePhysicsEngine = function () {
  112723. if (!this._physicsEngine) {
  112724. return;
  112725. }
  112726. this._physicsEngine.dispose();
  112727. this._physicsEngine = null;
  112728. };
  112729. /**
  112730. * Gets a boolean indicating if there is an active physics engine
  112731. * @returns a boolean indicating if there is an active physics engine
  112732. */
  112733. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.isPhysicsEnabled = function () {
  112734. return this._physicsEngine !== undefined;
  112735. };
  112736. /**
  112737. * Deletes a physics compound impostor
  112738. * @param compound defines the compound to delete
  112739. */
  112740. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.deleteCompoundImpostor = function (compound) {
  112741. var mesh = compound.parts[0].mesh;
  112742. if (mesh.physicsImpostor) {
  112743. mesh.physicsImpostor.dispose( /*true*/);
  112744. mesh.physicsImpostor = null;
  112745. }
  112746. };
  112747. /** @hidden */
  112748. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._advancePhysicsEngineStep = function (step) {
  112749. if (this._physicsEngine) {
  112750. this.onBeforePhysicsObservable.notifyObservers(this);
  112751. this._physicsEngine._step(step / 1000);
  112752. this.onAfterPhysicsObservable.notifyObservers(this);
  112753. }
  112754. };
  112755. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "physicsImpostor", {
  112756. get: function () {
  112757. return this._physicsImpostor;
  112758. },
  112759. set: function (value) {
  112760. var _this = this;
  112761. if (this._physicsImpostor === value) {
  112762. return;
  112763. }
  112764. if (this._disposePhysicsObserver) {
  112765. this.onDisposeObservable.remove(this._disposePhysicsObserver);
  112766. }
  112767. this._physicsImpostor = value;
  112768. if (value) {
  112769. this._disposePhysicsObserver = this.onDisposeObservable.add(function () {
  112770. // Physics
  112771. if (_this.physicsImpostor) {
  112772. _this.physicsImpostor.dispose( /*!doNotRecurse*/);
  112773. _this.physicsImpostor = null;
  112774. }
  112775. });
  112776. }
  112777. },
  112778. enumerable: true,
  112779. configurable: true
  112780. });
  112781. /**
  112782. * Gets the current physics impostor
  112783. * @see http://doc.babylonjs.com/features/physics_engine
  112784. * @returns a physics impostor or null
  112785. */
  112786. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.getPhysicsImpostor = function () {
  112787. return this.physicsImpostor;
  112788. };
  112789. /**
  112790. * Apply a physic impulse to the mesh
  112791. * @param force defines the force to apply
  112792. * @param contactPoint defines where to apply the force
  112793. * @returns the current mesh
  112794. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  112795. */
  112796. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.applyImpulse = function (force, contactPoint) {
  112797. if (!this.physicsImpostor) {
  112798. return this;
  112799. }
  112800. this.physicsImpostor.applyImpulse(force, contactPoint);
  112801. return this;
  112802. };
  112803. /**
  112804. * Creates a physic joint between two meshes
  112805. * @param otherMesh defines the other mesh to use
  112806. * @param pivot1 defines the pivot to use on this mesh
  112807. * @param pivot2 defines the pivot to use on the other mesh
  112808. * @param options defines additional options (can be plugin dependent)
  112809. * @returns the current mesh
  112810. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  112811. */
  112812. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.setPhysicsLinkWith = function (otherMesh, pivot1, pivot2, options) {
  112813. if (!this.physicsImpostor || !otherMesh.physicsImpostor) {
  112814. return this;
  112815. }
  112816. this.physicsImpostor.createJoint(otherMesh.physicsImpostor, _physicsJoint__WEBPACK_IMPORTED_MODULE_6__["PhysicsJoint"].HingeJoint, {
  112817. mainPivot: pivot1,
  112818. connectedPivot: pivot2,
  112819. nativeParams: options
  112820. });
  112821. return this;
  112822. };
  112823. /**
  112824. * Defines the physics engine scene component responsible to manage a physics engine
  112825. */
  112826. var PhysicsEngineSceneComponent = /** @class */ (function () {
  112827. /**
  112828. * Creates a new instance of the component for the given scene
  112829. * @param scene Defines the scene to register the component in
  112830. */
  112831. function PhysicsEngineSceneComponent(scene) {
  112832. var _this = this;
  112833. /**
  112834. * The component name helpful to identify the component in the list of scene components.
  112835. */
  112836. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_PHYSICSENGINE;
  112837. this.scene = scene;
  112838. this.scene.onBeforePhysicsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  112839. this.scene.onAfterPhysicsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  112840. // Replace the function used to get the deterministic frame time
  112841. this.scene.getDeterministicFrameTime = function () {
  112842. if (_this.scene._physicsEngine) {
  112843. return _this.scene._physicsEngine.getTimeStep() * 1000;
  112844. }
  112845. return 1000.0 / 60.0;
  112846. };
  112847. }
  112848. /**
  112849. * Registers the component in a given scene
  112850. */
  112851. PhysicsEngineSceneComponent.prototype.register = function () {
  112852. };
  112853. /**
  112854. * Rebuilds the elements related to this component in case of
  112855. * context lost for instance.
  112856. */
  112857. PhysicsEngineSceneComponent.prototype.rebuild = function () {
  112858. // Nothing to do for this component
  112859. };
  112860. /**
  112861. * Disposes the component and the associated ressources
  112862. */
  112863. PhysicsEngineSceneComponent.prototype.dispose = function () {
  112864. this.scene.onBeforePhysicsObservable.clear();
  112865. this.scene.onAfterPhysicsObservable.clear();
  112866. if (this.scene._physicsEngine) {
  112867. this.scene.disablePhysicsEngine();
  112868. }
  112869. };
  112870. return PhysicsEngineSceneComponent;
  112871. }());
  112872. /***/ }),
  112873. /***/ "./Physics/physicsHelper.ts":
  112874. /*!**********************************!*\
  112875. !*** ./Physics/physicsHelper.ts ***!
  112876. \**********************************/
  112877. /*! exports provided: PhysicsHelper, PhysicsRadialExplosionEvent, PhysicsGravitationalFieldEvent, PhysicsUpdraftEvent, PhysicsVortexEvent, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode */
  112878. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112879. "use strict";
  112880. __webpack_require__.r(__webpack_exports__);
  112881. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return PhysicsHelper; });
  112882. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEvent", function() { return PhysicsRadialExplosionEvent; });
  112883. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsGravitationalFieldEvent", function() { return PhysicsGravitationalFieldEvent; });
  112884. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEvent", function() { return PhysicsUpdraftEvent; });
  112885. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEvent", function() { return PhysicsVortexEvent; });
  112886. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return PhysicsRadialImpulseFalloff; });
  112887. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return PhysicsUpdraftMode; });
  112888. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  112889. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  112890. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  112891. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  112892. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  112893. /**
  112894. * A helper for physics simulations
  112895. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112896. */
  112897. var PhysicsHelper = /** @class */ (function () {
  112898. /**
  112899. * Initializes the Physics helper
  112900. * @param scene Babylon.js scene
  112901. */
  112902. function PhysicsHelper(scene) {
  112903. this._scene = scene;
  112904. this._physicsEngine = this._scene.getPhysicsEngine();
  112905. if (!this._physicsEngine) {
  112906. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you can use the methods.');
  112907. }
  112908. }
  112909. /**
  112910. * Applies a radial explosion impulse
  112911. * @param origin the origin of the explosion
  112912. * @param radius the explosion radius
  112913. * @param strength the explosion strength
  112914. * @param falloff possible options: Constant & Linear. Defaults to Constant
  112915. * @returns A physics radial explosion event, or null
  112916. */
  112917. PhysicsHelper.prototype.applyRadialExplosionImpulse = function (origin, radius, strength, falloff) {
  112918. if (falloff === void 0) { falloff = PhysicsRadialImpulseFalloff.Constant; }
  112919. if (!this._physicsEngine) {
  112920. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call this method.');
  112921. return null;
  112922. }
  112923. var impostors = this._physicsEngine.getImpostors();
  112924. if (impostors.length === 0) {
  112925. return null;
  112926. }
  112927. var event = new PhysicsRadialExplosionEvent(this._scene);
  112928. impostors.forEach(function (impostor) {
  112929. var impostorForceAndContactPoint = event.getImpostorForceAndContactPoint(impostor, origin, radius, strength, falloff);
  112930. if (!impostorForceAndContactPoint) {
  112931. return;
  112932. }
  112933. impostor.applyImpulse(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  112934. });
  112935. event.dispose(false);
  112936. return event;
  112937. };
  112938. /**
  112939. * Applies a radial explosion force
  112940. * @param origin the origin of the explosion
  112941. * @param radius the explosion radius
  112942. * @param strength the explosion strength
  112943. * @param falloff possible options: Constant & Linear. Defaults to Constant
  112944. * @returns A physics radial explosion event, or null
  112945. */
  112946. PhysicsHelper.prototype.applyRadialExplosionForce = function (origin, radius, strength, falloff) {
  112947. if (falloff === void 0) { falloff = PhysicsRadialImpulseFalloff.Constant; }
  112948. if (!this._physicsEngine) {
  112949. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  112950. return null;
  112951. }
  112952. var impostors = this._physicsEngine.getImpostors();
  112953. if (impostors.length === 0) {
  112954. return null;
  112955. }
  112956. var event = new PhysicsRadialExplosionEvent(this._scene);
  112957. impostors.forEach(function (impostor) {
  112958. var impostorForceAndContactPoint = event.getImpostorForceAndContactPoint(impostor, origin, radius, strength, falloff);
  112959. if (!impostorForceAndContactPoint) {
  112960. return;
  112961. }
  112962. impostor.applyForce(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  112963. });
  112964. event.dispose(false);
  112965. return event;
  112966. };
  112967. /**
  112968. * Creates a gravitational field
  112969. * @param origin the origin of the explosion
  112970. * @param radius the explosion radius
  112971. * @param strength the explosion strength
  112972. * @param falloff possible options: Constant & Linear. Defaults to Constant
  112973. * @returns A physics gravitational field event, or null
  112974. */
  112975. PhysicsHelper.prototype.gravitationalField = function (origin, radius, strength, falloff) {
  112976. if (falloff === void 0) { falloff = PhysicsRadialImpulseFalloff.Constant; }
  112977. if (!this._physicsEngine) {
  112978. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  112979. return null;
  112980. }
  112981. var impostors = this._physicsEngine.getImpostors();
  112982. if (impostors.length === 0) {
  112983. return null;
  112984. }
  112985. var event = new PhysicsGravitationalFieldEvent(this, this._scene, origin, radius, strength, falloff);
  112986. event.dispose(false);
  112987. return event;
  112988. };
  112989. /**
  112990. * Creates a physics updraft event
  112991. * @param origin the origin of the updraft
  112992. * @param radius the radius of the updraft
  112993. * @param strength the strength of the updraft
  112994. * @param height the height of the updraft
  112995. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  112996. * @returns A physics updraft event, or null
  112997. */
  112998. PhysicsHelper.prototype.updraft = function (origin, radius, strength, height, updraftMode) {
  112999. if (updraftMode === void 0) { updraftMode = PhysicsUpdraftMode.Center; }
  113000. if (!this._physicsEngine) {
  113001. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  113002. return null;
  113003. }
  113004. if (this._physicsEngine.getImpostors().length === 0) {
  113005. return null;
  113006. }
  113007. var event = new PhysicsUpdraftEvent(this._scene, origin, radius, strength, height, updraftMode);
  113008. event.dispose(false);
  113009. return event;
  113010. };
  113011. /**
  113012. * Creates a physics vortex event
  113013. * @param origin the of the vortex
  113014. * @param radius the radius of the vortex
  113015. * @param strength the strength of the vortex
  113016. * @param height the height of the vortex
  113017. * @returns a Physics vortex event, or null
  113018. * A physics vortex event or null
  113019. */
  113020. PhysicsHelper.prototype.vortex = function (origin, radius, strength, height) {
  113021. if (!this._physicsEngine) {
  113022. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  113023. return null;
  113024. }
  113025. if (this._physicsEngine.getImpostors().length === 0) {
  113026. return null;
  113027. }
  113028. var event = new PhysicsVortexEvent(this._scene, origin, radius, strength, height);
  113029. event.dispose(false);
  113030. return event;
  113031. };
  113032. return PhysicsHelper;
  113033. }());
  113034. /**
  113035. * Represents a physics radial explosion event
  113036. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113037. */
  113038. var PhysicsRadialExplosionEvent = /** @class */ (function () {
  113039. /**
  113040. * Initializes a radial explosioin event
  113041. * @param scene BabylonJS scene
  113042. */
  113043. function PhysicsRadialExplosionEvent(scene) {
  113044. this._sphereOptions = { segments: 32, diameter: 1 }; // TODO: make configurable
  113045. this._rays = [];
  113046. this._dataFetched = false; // check if the data has been fetched. If not, do cleanup
  113047. this._scene = scene;
  113048. }
  113049. /**
  113050. * Returns the data related to the radial explosion event (sphere & rays).
  113051. * @returns The radial explosion event data
  113052. */
  113053. PhysicsRadialExplosionEvent.prototype.getData = function () {
  113054. this._dataFetched = true;
  113055. return {
  113056. sphere: this._sphere,
  113057. rays: this._rays,
  113058. };
  113059. };
  113060. /**
  113061. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  113062. * @param impostor A physics imposter
  113063. * @param origin the origin of the explosion
  113064. * @param radius the explosion radius
  113065. * @param strength the explosion strength
  113066. * @param falloff possible options: Constant & Linear
  113067. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  113068. */
  113069. PhysicsRadialExplosionEvent.prototype.getImpostorForceAndContactPoint = function (impostor, origin, radius, strength, falloff) {
  113070. if (impostor.mass === 0) {
  113071. return null;
  113072. }
  113073. if (!this._intersectsWithSphere(impostor, origin, radius)) {
  113074. return null;
  113075. }
  113076. if (impostor.object.getClassName() !== 'Mesh' && impostor.object.getClassName() !== 'InstancedMesh') {
  113077. return null;
  113078. }
  113079. var impostorObjectCenter = impostor.getObjectCenter();
  113080. var direction = impostorObjectCenter.subtract(origin);
  113081. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_4__["Ray"](origin, direction, radius);
  113082. this._rays.push(ray);
  113083. var hit = ray.intersectsMesh(impostor.object);
  113084. var contactPoint = hit.pickedPoint;
  113085. if (!contactPoint) {
  113086. return null;
  113087. }
  113088. var distanceFromOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Distance(origin, contactPoint);
  113089. if (distanceFromOrigin > radius) {
  113090. return null;
  113091. }
  113092. var multiplier = falloff === PhysicsRadialImpulseFalloff.Constant
  113093. ? strength
  113094. : strength * (1 - (distanceFromOrigin / radius));
  113095. var force = direction.multiplyByFloats(multiplier, multiplier, multiplier);
  113096. return { force: force, contactPoint: contactPoint };
  113097. };
  113098. /**
  113099. * Disposes the sphere.
  113100. * @param force Specifies if the sphere should be disposed by force
  113101. */
  113102. PhysicsRadialExplosionEvent.prototype.dispose = function (force) {
  113103. var _this = this;
  113104. if (force === void 0) { force = true; }
  113105. if (force) {
  113106. this._sphere.dispose();
  113107. }
  113108. else {
  113109. setTimeout(function () {
  113110. if (!_this._dataFetched) {
  113111. _this._sphere.dispose();
  113112. }
  113113. }, 0);
  113114. }
  113115. };
  113116. /*** Helpers ***/
  113117. PhysicsRadialExplosionEvent.prototype._prepareSphere = function () {
  113118. if (!this._sphere) {
  113119. this._sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_2__["SphereBuilder"].CreateSphere("radialExplosionEventSphere", this._sphereOptions, this._scene);
  113120. this._sphere.isVisible = false;
  113121. }
  113122. };
  113123. PhysicsRadialExplosionEvent.prototype._intersectsWithSphere = function (impostor, origin, radius) {
  113124. var impostorObject = impostor.object;
  113125. this._prepareSphere();
  113126. this._sphere.position = origin;
  113127. this._sphere.scaling = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](radius * 2, radius * 2, radius * 2);
  113128. this._sphere._updateBoundingInfo();
  113129. this._sphere.computeWorldMatrix(true);
  113130. return this._sphere.intersectsMesh(impostorObject, true);
  113131. };
  113132. return PhysicsRadialExplosionEvent;
  113133. }());
  113134. /**
  113135. * Represents a gravitational field event
  113136. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113137. */
  113138. var PhysicsGravitationalFieldEvent = /** @class */ (function () {
  113139. /**
  113140. * Initializes the physics gravitational field event
  113141. * @param physicsHelper A physics helper
  113142. * @param scene BabylonJS scene
  113143. * @param origin The origin position of the gravitational field event
  113144. * @param radius The radius of the gravitational field event
  113145. * @param strength The strength of the gravitational field event
  113146. * @param falloff The falloff for the gravitational field event
  113147. */
  113148. function PhysicsGravitationalFieldEvent(physicsHelper, scene, origin, radius, strength, falloff) {
  113149. if (falloff === void 0) { falloff = PhysicsRadialImpulseFalloff.Constant; }
  113150. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  113151. this._physicsHelper = physicsHelper;
  113152. this._scene = scene;
  113153. this._origin = origin;
  113154. this._radius = radius;
  113155. this._strength = strength;
  113156. this._falloff = falloff;
  113157. this._tickCallback = this._tick.bind(this);
  113158. }
  113159. /**
  113160. * Returns the data related to the gravitational field event (sphere).
  113161. * @returns A gravitational field event
  113162. */
  113163. PhysicsGravitationalFieldEvent.prototype.getData = function () {
  113164. this._dataFetched = true;
  113165. return {
  113166. sphere: this._sphere,
  113167. };
  113168. };
  113169. /**
  113170. * Enables the gravitational field.
  113171. */
  113172. PhysicsGravitationalFieldEvent.prototype.enable = function () {
  113173. this._tickCallback.call(this);
  113174. this._scene.registerBeforeRender(this._tickCallback);
  113175. };
  113176. /**
  113177. * Disables the gravitational field.
  113178. */
  113179. PhysicsGravitationalFieldEvent.prototype.disable = function () {
  113180. this._scene.unregisterBeforeRender(this._tickCallback);
  113181. };
  113182. /**
  113183. * Disposes the sphere.
  113184. * @param force The force to dispose from the gravitational field event
  113185. */
  113186. PhysicsGravitationalFieldEvent.prototype.dispose = function (force) {
  113187. var _this = this;
  113188. if (force === void 0) { force = true; }
  113189. if (force) {
  113190. this._sphere.dispose();
  113191. }
  113192. else {
  113193. setTimeout(function () {
  113194. if (!_this._dataFetched) {
  113195. _this._sphere.dispose();
  113196. }
  113197. }, 0);
  113198. }
  113199. };
  113200. PhysicsGravitationalFieldEvent.prototype._tick = function () {
  113201. // Since the params won't change, we fetch the event only once
  113202. if (this._sphere) {
  113203. this._physicsHelper.applyRadialExplosionForce(this._origin, this._radius, this._strength * -1, this._falloff);
  113204. }
  113205. else {
  113206. var radialExplosionEvent = this._physicsHelper.applyRadialExplosionForce(this._origin, this._radius, this._strength * -1, this._falloff);
  113207. if (radialExplosionEvent) {
  113208. this._sphere = radialExplosionEvent.getData().sphere.clone('radialExplosionEventSphereClone');
  113209. }
  113210. }
  113211. };
  113212. return PhysicsGravitationalFieldEvent;
  113213. }());
  113214. /**
  113215. * Represents a physics updraft event
  113216. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113217. */
  113218. var PhysicsUpdraftEvent = /** @class */ (function () {
  113219. /**
  113220. * Initializes the physics updraft event
  113221. * @param _scene BabylonJS scene
  113222. * @param _origin The origin position of the updraft
  113223. * @param _radius The radius of the updraft
  113224. * @param _strength The strength of the updraft
  113225. * @param _height The height of the updraft
  113226. * @param _updraftMode The mode of the updraft
  113227. */
  113228. function PhysicsUpdraftEvent(_scene, _origin, _radius, _strength, _height, _updraftMode) {
  113229. this._scene = _scene;
  113230. this._origin = _origin;
  113231. this._radius = _radius;
  113232. this._strength = _strength;
  113233. this._height = _height;
  113234. this._updraftMode = _updraftMode;
  113235. this._originTop = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(); // the most upper part of the cylinder
  113236. this._originDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(); // used if the updraftMode is perpendicular
  113237. 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
  113238. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  113239. this._physicsEngine = this._scene.getPhysicsEngine();
  113240. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, this._height / 2, 0), this._cylinderPosition);
  113241. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, this._height, 0), this._originTop);
  113242. if (this._updraftMode === PhysicsUpdraftMode.Perpendicular) {
  113243. this._originDirection = this._origin.subtract(this._originTop).normalize();
  113244. }
  113245. this._tickCallback = this._tick.bind(this);
  113246. this._prepareCylinder();
  113247. }
  113248. /**
  113249. * Returns the data related to the updraft event (cylinder).
  113250. * @returns A physics updraft event
  113251. */
  113252. PhysicsUpdraftEvent.prototype.getData = function () {
  113253. this._dataFetched = true;
  113254. return {
  113255. cylinder: this._cylinder,
  113256. };
  113257. };
  113258. /**
  113259. * Enables the updraft.
  113260. */
  113261. PhysicsUpdraftEvent.prototype.enable = function () {
  113262. this._tickCallback.call(this);
  113263. this._scene.registerBeforeRender(this._tickCallback);
  113264. };
  113265. /**
  113266. * Disables the cortex.
  113267. */
  113268. PhysicsUpdraftEvent.prototype.disable = function () {
  113269. this._scene.unregisterBeforeRender(this._tickCallback);
  113270. };
  113271. /**
  113272. * Disposes the sphere.
  113273. * @param force Specifies if the updraft should be disposed by force
  113274. */
  113275. PhysicsUpdraftEvent.prototype.dispose = function (force) {
  113276. var _this = this;
  113277. if (force === void 0) { force = true; }
  113278. if (!this._cylinder) {
  113279. return;
  113280. }
  113281. if (force) {
  113282. this._cylinder.dispose();
  113283. }
  113284. else {
  113285. setTimeout(function () {
  113286. if (!_this._dataFetched) {
  113287. _this._cylinder.dispose();
  113288. }
  113289. }, 0);
  113290. }
  113291. };
  113292. PhysicsUpdraftEvent.prototype.getImpostorForceAndContactPoint = function (impostor) {
  113293. if (impostor.mass === 0) {
  113294. return null;
  113295. }
  113296. if (!this._intersectsWithCylinder(impostor)) {
  113297. return null;
  113298. }
  113299. var impostorObjectCenter = impostor.getObjectCenter();
  113300. if (this._updraftMode === PhysicsUpdraftMode.Perpendicular) {
  113301. var direction = this._originDirection;
  113302. }
  113303. else {
  113304. var direction = impostorObjectCenter.subtract(this._originTop);
  113305. }
  113306. var multiplier = this._strength * -1;
  113307. var force = direction.multiplyByFloats(multiplier, multiplier, multiplier);
  113308. return { force: force, contactPoint: impostorObjectCenter };
  113309. };
  113310. PhysicsUpdraftEvent.prototype._tick = function () {
  113311. var _this = this;
  113312. this._physicsEngine.getImpostors().forEach(function (impostor) {
  113313. var impostorForceAndContactPoint = _this.getImpostorForceAndContactPoint(impostor);
  113314. if (!impostorForceAndContactPoint) {
  113315. return;
  113316. }
  113317. impostor.applyForce(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  113318. });
  113319. };
  113320. /*** Helpers ***/
  113321. PhysicsUpdraftEvent.prototype._prepareCylinder = function () {
  113322. if (!this._cylinder) {
  113323. this._cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_3__["CylinderBuilder"].CreateCylinder("updraftEventCylinder", {
  113324. height: this._height,
  113325. diameter: this._radius * 2,
  113326. }, this._scene);
  113327. this._cylinder.isVisible = false;
  113328. }
  113329. };
  113330. PhysicsUpdraftEvent.prototype._intersectsWithCylinder = function (impostor) {
  113331. var impostorObject = impostor.object;
  113332. this._cylinder.position = this._cylinderPosition;
  113333. return this._cylinder.intersectsMesh(impostorObject, true);
  113334. };
  113335. return PhysicsUpdraftEvent;
  113336. }());
  113337. /**
  113338. * Represents a physics vortex event
  113339. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113340. */
  113341. var PhysicsVortexEvent = /** @class */ (function () {
  113342. /**
  113343. * Initializes the physics vortex event
  113344. * @param _scene The BabylonJS scene
  113345. * @param _origin The origin position of the vortex
  113346. * @param _radius The radius of the vortex
  113347. * @param _strength The strength of the vortex
  113348. * @param _height The height of the vortex
  113349. */
  113350. function PhysicsVortexEvent(_scene, _origin, _radius, _strength, _height) {
  113351. this._scene = _scene;
  113352. this._origin = _origin;
  113353. this._radius = _radius;
  113354. this._strength = _strength;
  113355. this._height = _height;
  113356. this._originTop = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(); // the most upper part of the cylinder
  113357. this._centripetalForceThreshold = 0.7; // at which distance, relative to the radius the centripetal forces should kick in
  113358. this._updraftMultiplier = 0.02;
  113359. 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
  113360. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  113361. this._physicsEngine = this._scene.getPhysicsEngine();
  113362. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, this._height / 2, 0), this._cylinderPosition);
  113363. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, this._height, 0), this._originTop);
  113364. this._tickCallback = this._tick.bind(this);
  113365. this._prepareCylinder();
  113366. }
  113367. /**
  113368. * Returns the data related to the vortex event (cylinder).
  113369. * @returns The physics vortex event data
  113370. */
  113371. PhysicsVortexEvent.prototype.getData = function () {
  113372. this._dataFetched = true;
  113373. return {
  113374. cylinder: this._cylinder,
  113375. };
  113376. };
  113377. /**
  113378. * Enables the vortex.
  113379. */
  113380. PhysicsVortexEvent.prototype.enable = function () {
  113381. this._tickCallback.call(this);
  113382. this._scene.registerBeforeRender(this._tickCallback);
  113383. };
  113384. /**
  113385. * Disables the cortex.
  113386. */
  113387. PhysicsVortexEvent.prototype.disable = function () {
  113388. this._scene.unregisterBeforeRender(this._tickCallback);
  113389. };
  113390. /**
  113391. * Disposes the sphere.
  113392. * @param force
  113393. */
  113394. PhysicsVortexEvent.prototype.dispose = function (force) {
  113395. var _this = this;
  113396. if (force === void 0) { force = true; }
  113397. if (force) {
  113398. this._cylinder.dispose();
  113399. }
  113400. else {
  113401. setTimeout(function () {
  113402. if (!_this._dataFetched) {
  113403. _this._cylinder.dispose();
  113404. }
  113405. }, 0);
  113406. }
  113407. };
  113408. PhysicsVortexEvent.prototype.getImpostorForceAndContactPoint = function (impostor) {
  113409. if (impostor.mass === 0) {
  113410. return null;
  113411. }
  113412. if (!this._intersectsWithCylinder(impostor)) {
  113413. return null;
  113414. }
  113415. if (impostor.object.getClassName() !== 'Mesh' && impostor.object.getClassName() !== 'InstancedMesh') {
  113416. return null;
  113417. }
  113418. var impostorObjectCenter = impostor.getObjectCenter();
  113419. 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)
  113420. var originToImpostorDirection = impostorObjectCenter.subtract(originOnPlane);
  113421. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_4__["Ray"](originOnPlane, originToImpostorDirection, this._radius);
  113422. var hit = ray.intersectsMesh(impostor.object);
  113423. var contactPoint = hit.pickedPoint;
  113424. if (!contactPoint) {
  113425. return null;
  113426. }
  113427. var absoluteDistanceFromOrigin = hit.distance / this._radius;
  113428. var perpendicularDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(originOnPlane, impostorObjectCenter).normalize();
  113429. var directionToOrigin = contactPoint.normalize();
  113430. if (absoluteDistanceFromOrigin > this._centripetalForceThreshold) {
  113431. directionToOrigin = directionToOrigin.negate();
  113432. }
  113433. // TODO: find a more physically based solution
  113434. if (absoluteDistanceFromOrigin > this._centripetalForceThreshold) {
  113435. var forceX = directionToOrigin.x * this._strength / 8;
  113436. var forceY = directionToOrigin.y * this._updraftMultiplier;
  113437. var forceZ = directionToOrigin.z * this._strength / 8;
  113438. }
  113439. else {
  113440. var forceX = (perpendicularDirection.x + directionToOrigin.x) / 2;
  113441. var forceY = this._originTop.y * this._updraftMultiplier;
  113442. var forceZ = (perpendicularDirection.z + directionToOrigin.z) / 2;
  113443. }
  113444. var force = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](forceX, forceY, forceZ);
  113445. force = force.multiplyByFloats(this._strength, this._strength, this._strength);
  113446. return { force: force, contactPoint: impostorObjectCenter };
  113447. };
  113448. PhysicsVortexEvent.prototype._tick = function () {
  113449. var _this = this;
  113450. this._physicsEngine.getImpostors().forEach(function (impostor) {
  113451. var impostorForceAndContactPoint = _this.getImpostorForceAndContactPoint(impostor);
  113452. if (!impostorForceAndContactPoint) {
  113453. return;
  113454. }
  113455. impostor.applyForce(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  113456. });
  113457. };
  113458. /*** Helpers ***/
  113459. PhysicsVortexEvent.prototype._prepareCylinder = function () {
  113460. if (!this._cylinder) {
  113461. this._cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_3__["CylinderBuilder"].CreateCylinder("vortexEventCylinder", {
  113462. height: this._height,
  113463. diameter: this._radius * 2,
  113464. }, this._scene);
  113465. this._cylinder.isVisible = false;
  113466. }
  113467. };
  113468. PhysicsVortexEvent.prototype._intersectsWithCylinder = function (impostor) {
  113469. var impostorObject = impostor.object;
  113470. this._cylinder.position = this._cylinderPosition;
  113471. return this._cylinder.intersectsMesh(impostorObject, true);
  113472. };
  113473. return PhysicsVortexEvent;
  113474. }());
  113475. /**
  113476. * The strenght of the force in correspondence to the distance of the affected object
  113477. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113478. */
  113479. var PhysicsRadialImpulseFalloff;
  113480. (function (PhysicsRadialImpulseFalloff) {
  113481. /** Defines that impulse is constant in strength across it's whole radius */
  113482. PhysicsRadialImpulseFalloff[PhysicsRadialImpulseFalloff["Constant"] = 0] = "Constant";
  113483. /** DEfines that impulse gets weaker if it's further from the origin */
  113484. PhysicsRadialImpulseFalloff[PhysicsRadialImpulseFalloff["Linear"] = 1] = "Linear";
  113485. })(PhysicsRadialImpulseFalloff || (PhysicsRadialImpulseFalloff = {}));
  113486. /**
  113487. * The strength of the force in correspondence to the distance of the affected object
  113488. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113489. */
  113490. var PhysicsUpdraftMode;
  113491. (function (PhysicsUpdraftMode) {
  113492. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  113493. PhysicsUpdraftMode[PhysicsUpdraftMode["Center"] = 0] = "Center";
  113494. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  113495. PhysicsUpdraftMode[PhysicsUpdraftMode["Perpendicular"] = 1] = "Perpendicular";
  113496. })(PhysicsUpdraftMode || (PhysicsUpdraftMode = {}));
  113497. /***/ }),
  113498. /***/ "./Physics/physicsImpostor.ts":
  113499. /*!************************************!*\
  113500. !*** ./Physics/physicsImpostor.ts ***!
  113501. \************************************/
  113502. /*! exports provided: PhysicsImpostor */
  113503. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  113504. "use strict";
  113505. __webpack_require__.r(__webpack_exports__);
  113506. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return PhysicsImpostor; });
  113507. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  113508. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  113509. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  113510. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  113511. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  113512. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  113513. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"]._PhysicsImpostorParser = function (scene, physicObject, jsonObject) {
  113514. return new PhysicsImpostor(physicObject, jsonObject.physicsImpostor, {
  113515. mass: jsonObject.physicsMass,
  113516. friction: jsonObject.physicsFriction,
  113517. restitution: jsonObject.physicsRestitution
  113518. }, scene);
  113519. };
  113520. /**
  113521. * Represents a physics imposter
  113522. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113523. */
  113524. var PhysicsImpostor = /** @class */ (function () {
  113525. /**
  113526. * Initializes the physics imposter
  113527. * @param object The physics-enabled object used as the physics imposter
  113528. * @param type The type of the physics imposter
  113529. * @param _options The options for the physics imposter
  113530. * @param _scene The Babylon scene
  113531. */
  113532. function PhysicsImpostor(
  113533. /**
  113534. * The physics-enabled object used as the physics imposter
  113535. */
  113536. object,
  113537. /**
  113538. * The type of the physics imposter
  113539. */
  113540. type, _options, _scene) {
  113541. if (_options === void 0) { _options = { mass: 0 }; }
  113542. var _this = this;
  113543. this.object = object;
  113544. this.type = type;
  113545. this._options = _options;
  113546. this._scene = _scene;
  113547. this._bodyUpdateRequired = false;
  113548. this._onBeforePhysicsStepCallbacks = new Array();
  113549. this._onAfterPhysicsStepCallbacks = new Array();
  113550. /** @hidden */
  113551. this._onPhysicsCollideCallbacks = [];
  113552. this._deltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  113553. this._isDisposed = false;
  113554. //temp variables for parent rotation calculations
  113555. //private _mats: Array<Matrix> = [new Matrix(), new Matrix()];
  113556. this._tmpQuat = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  113557. this._tmpQuat2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  113558. /**
  113559. * this function is executed by the physics engine.
  113560. */
  113561. this.beforeStep = function () {
  113562. if (!_this._physicsEngine) {
  113563. return;
  113564. }
  113565. _this.object.translate(_this._deltaPosition, -1);
  113566. _this._deltaRotationConjugated && _this.object.rotationQuaternion && _this.object.rotationQuaternion.multiplyToRef(_this._deltaRotationConjugated, _this.object.rotationQuaternion);
  113567. _this.object.computeWorldMatrix(false);
  113568. if (_this.object.parent && _this.object.rotationQuaternion) {
  113569. _this.getParentsRotation();
  113570. _this._tmpQuat.multiplyToRef(_this.object.rotationQuaternion, _this._tmpQuat);
  113571. }
  113572. else {
  113573. _this._tmpQuat.copyFrom(_this.object.rotationQuaternion || new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]());
  113574. }
  113575. if (!_this._options.disableBidirectionalTransformation) {
  113576. _this.object.rotationQuaternion && _this._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(_this, /*bInfo.boundingBox.centerWorld*/ _this.object.getAbsolutePosition(), _this._tmpQuat);
  113577. }
  113578. _this._onBeforePhysicsStepCallbacks.forEach(function (func) {
  113579. func(_this);
  113580. });
  113581. };
  113582. /**
  113583. * this function is executed by the physics engine
  113584. */
  113585. this.afterStep = function () {
  113586. if (!_this._physicsEngine) {
  113587. return;
  113588. }
  113589. _this._onAfterPhysicsStepCallbacks.forEach(function (func) {
  113590. func(_this);
  113591. });
  113592. _this._physicsEngine.getPhysicsPlugin().setTransformationFromPhysicsBody(_this);
  113593. // object has now its world rotation. needs to be converted to local.
  113594. if (_this.object.parent && _this.object.rotationQuaternion) {
  113595. _this.getParentsRotation();
  113596. _this._tmpQuat.conjugateInPlace();
  113597. _this._tmpQuat.multiplyToRef(_this.object.rotationQuaternion, _this.object.rotationQuaternion);
  113598. }
  113599. // take the position set and make it the absolute position of this object.
  113600. _this.object.setAbsolutePosition(_this.object.position);
  113601. _this._deltaRotation && _this.object.rotationQuaternion && _this.object.rotationQuaternion.multiplyToRef(_this._deltaRotation, _this.object.rotationQuaternion);
  113602. _this.object.translate(_this._deltaPosition, 1);
  113603. };
  113604. /**
  113605. * Legacy collision detection event support
  113606. */
  113607. this.onCollideEvent = null;
  113608. /**
  113609. * event and body object due to cannon's event-based architecture.
  113610. */
  113611. this.onCollide = function (e) {
  113612. if (!_this._onPhysicsCollideCallbacks.length && !_this.onCollideEvent) {
  113613. return;
  113614. }
  113615. if (!_this._physicsEngine) {
  113616. return;
  113617. }
  113618. var otherImpostor = _this._physicsEngine.getImpostorWithPhysicsBody(e.body);
  113619. if (otherImpostor) {
  113620. // Legacy collision detection event support
  113621. if (_this.onCollideEvent) {
  113622. _this.onCollideEvent(_this, otherImpostor);
  113623. }
  113624. _this._onPhysicsCollideCallbacks.filter(function (obj) {
  113625. return obj.otherImpostors.indexOf(otherImpostor) !== -1;
  113626. }).forEach(function (obj) {
  113627. obj.callback(_this, otherImpostor);
  113628. });
  113629. }
  113630. };
  113631. //sanity check!
  113632. if (!this.object) {
  113633. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("No object was provided. A physics object is obligatory");
  113634. return;
  113635. }
  113636. // Legacy support for old syntax.
  113637. if (!this._scene && object.getScene) {
  113638. this._scene = object.getScene();
  113639. }
  113640. if (!this._scene) {
  113641. return;
  113642. }
  113643. this._physicsEngine = this._scene.getPhysicsEngine();
  113644. if (!this._physicsEngine) {
  113645. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Physics not enabled. Please use scene.enablePhysics(...) before creating impostors.");
  113646. }
  113647. else {
  113648. //set the object's quaternion, if not set
  113649. if (!this.object.rotationQuaternion) {
  113650. if (this.object.rotation) {
  113651. this.object.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRoll(this.object.rotation.y, this.object.rotation.x, this.object.rotation.z);
  113652. }
  113653. else {
  113654. this.object.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  113655. }
  113656. }
  113657. //default options params
  113658. this._options.mass = (_options.mass === void 0) ? 0 : _options.mass;
  113659. this._options.friction = (_options.friction === void 0) ? 0.2 : _options.friction;
  113660. this._options.restitution = (_options.restitution === void 0) ? 0.2 : _options.restitution;
  113661. this._joints = [];
  113662. //If the mesh has a parent, don't initialize the physicsBody. Instead wait for the parent to do that.
  113663. if (!this.object.parent || this._options.ignoreParent) {
  113664. this._init();
  113665. }
  113666. else if (this.object.parent.physicsImpostor) {
  113667. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("You must affect impostors to children before affecting impostor to parent.");
  113668. }
  113669. }
  113670. }
  113671. Object.defineProperty(PhysicsImpostor.prototype, "isDisposed", {
  113672. /**
  113673. * Specifies if the physics imposter is disposed
  113674. */
  113675. get: function () {
  113676. return this._isDisposed;
  113677. },
  113678. enumerable: true,
  113679. configurable: true
  113680. });
  113681. Object.defineProperty(PhysicsImpostor.prototype, "mass", {
  113682. /**
  113683. * Gets the mass of the physics imposter
  113684. */
  113685. get: function () {
  113686. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyMass(this) : 0;
  113687. },
  113688. set: function (value) {
  113689. this.setMass(value);
  113690. },
  113691. enumerable: true,
  113692. configurable: true
  113693. });
  113694. Object.defineProperty(PhysicsImpostor.prototype, "friction", {
  113695. /**
  113696. * Gets the coefficient of friction
  113697. */
  113698. get: function () {
  113699. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyFriction(this) : 0;
  113700. },
  113701. /**
  113702. * Sets the coefficient of friction
  113703. */
  113704. set: function (value) {
  113705. if (!this._physicsEngine) {
  113706. return;
  113707. }
  113708. this._physicsEngine.getPhysicsPlugin().setBodyFriction(this, value);
  113709. },
  113710. enumerable: true,
  113711. configurable: true
  113712. });
  113713. Object.defineProperty(PhysicsImpostor.prototype, "restitution", {
  113714. /**
  113715. * Gets the coefficient of restitution
  113716. */
  113717. get: function () {
  113718. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyRestitution(this) : 0;
  113719. },
  113720. /**
  113721. * Sets the coefficient of restitution
  113722. */
  113723. set: function (value) {
  113724. if (!this._physicsEngine) {
  113725. return;
  113726. }
  113727. this._physicsEngine.getPhysicsPlugin().setBodyRestitution(this, value);
  113728. },
  113729. enumerable: true,
  113730. configurable: true
  113731. });
  113732. /**
  113733. * This function will completly initialize this impostor.
  113734. * It will create a new body - but only if this mesh has no parent.
  113735. * If it has, this impostor will not be used other than to define the impostor
  113736. * of the child mesh.
  113737. * @hidden
  113738. */
  113739. PhysicsImpostor.prototype._init = function () {
  113740. if (!this._physicsEngine) {
  113741. return;
  113742. }
  113743. this._physicsEngine.removeImpostor(this);
  113744. this.physicsBody = null;
  113745. this._parent = this._parent || this._getPhysicsParent();
  113746. if (!this._isDisposed && (!this.parent || this._options.ignoreParent)) {
  113747. this._physicsEngine.addImpostor(this);
  113748. }
  113749. };
  113750. PhysicsImpostor.prototype._getPhysicsParent = function () {
  113751. if (this.object.parent instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]) {
  113752. var parentMesh = this.object.parent;
  113753. return parentMesh.physicsImpostor;
  113754. }
  113755. return null;
  113756. };
  113757. /**
  113758. * Should a new body be generated.
  113759. * @returns boolean specifying if body initialization is required
  113760. */
  113761. PhysicsImpostor.prototype.isBodyInitRequired = function () {
  113762. return this._bodyUpdateRequired || (!this._physicsBody && !this._parent);
  113763. };
  113764. /**
  113765. * Sets the updated scaling
  113766. * @param updated Specifies if the scaling is updated
  113767. */
  113768. PhysicsImpostor.prototype.setScalingUpdated = function () {
  113769. this.forceUpdate();
  113770. };
  113771. /**
  113772. * Force a regeneration of this or the parent's impostor's body.
  113773. * Use under cautious - This will remove all joints already implemented.
  113774. */
  113775. PhysicsImpostor.prototype.forceUpdate = function () {
  113776. this._init();
  113777. if (this.parent && !this._options.ignoreParent) {
  113778. this.parent.forceUpdate();
  113779. }
  113780. };
  113781. Object.defineProperty(PhysicsImpostor.prototype, "physicsBody", {
  113782. /*public get mesh(): AbstractMesh {
  113783. return this._mesh;
  113784. }*/
  113785. /**
  113786. * Gets the body that holds this impostor. Either its own, or its parent.
  113787. */
  113788. get: function () {
  113789. return (this._parent && !this._options.ignoreParent) ? this._parent.physicsBody : this._physicsBody;
  113790. },
  113791. /**
  113792. * Set the physics body. Used mainly by the physics engine/plugin
  113793. */
  113794. set: function (physicsBody) {
  113795. if (this._physicsBody && this._physicsEngine) {
  113796. this._physicsEngine.getPhysicsPlugin().removePhysicsBody(this);
  113797. }
  113798. this._physicsBody = physicsBody;
  113799. this.resetUpdateFlags();
  113800. },
  113801. enumerable: true,
  113802. configurable: true
  113803. });
  113804. Object.defineProperty(PhysicsImpostor.prototype, "parent", {
  113805. /**
  113806. * Get the parent of the physics imposter
  113807. * @returns Physics imposter or null
  113808. */
  113809. get: function () {
  113810. return !this._options.ignoreParent && this._parent ? this._parent : null;
  113811. },
  113812. /**
  113813. * Sets the parent of the physics imposter
  113814. */
  113815. set: function (value) {
  113816. this._parent = value;
  113817. },
  113818. enumerable: true,
  113819. configurable: true
  113820. });
  113821. /**
  113822. * Resets the update flags
  113823. */
  113824. PhysicsImpostor.prototype.resetUpdateFlags = function () {
  113825. this._bodyUpdateRequired = false;
  113826. };
  113827. /**
  113828. * Gets the object extend size
  113829. * @returns the object extend size
  113830. */
  113831. PhysicsImpostor.prototype.getObjectExtendSize = function () {
  113832. if (this.object.getBoundingInfo) {
  113833. var q = this.object.rotationQuaternion;
  113834. //reset rotation
  113835. this.object.rotationQuaternion = PhysicsImpostor.IDENTITY_QUATERNION;
  113836. //calculate the world matrix with no rotation
  113837. this.object.computeWorldMatrix && this.object.computeWorldMatrix(true);
  113838. var boundingInfo = this.object.getBoundingInfo();
  113839. var size = boundingInfo.boundingBox.extendSizeWorld.scale(2);
  113840. //bring back the rotation
  113841. this.object.rotationQuaternion = q;
  113842. //calculate the world matrix with the new rotation
  113843. this.object.computeWorldMatrix && this.object.computeWorldMatrix(true);
  113844. return size;
  113845. }
  113846. else {
  113847. return PhysicsImpostor.DEFAULT_OBJECT_SIZE;
  113848. }
  113849. };
  113850. /**
  113851. * Gets the object center
  113852. * @returns The object center
  113853. */
  113854. PhysicsImpostor.prototype.getObjectCenter = function () {
  113855. if (this.object.getBoundingInfo) {
  113856. var boundingInfo = this.object.getBoundingInfo();
  113857. return boundingInfo.boundingBox.centerWorld;
  113858. }
  113859. else {
  113860. return this.object.position;
  113861. }
  113862. };
  113863. /**
  113864. * Get a specific parametes from the options parameter
  113865. * @param paramName The object parameter name
  113866. * @returns The object parameter
  113867. */
  113868. PhysicsImpostor.prototype.getParam = function (paramName) {
  113869. return this._options[paramName];
  113870. };
  113871. /**
  113872. * Sets a specific parameter in the options given to the physics plugin
  113873. * @param paramName The parameter name
  113874. * @param value The value of the parameter
  113875. */
  113876. PhysicsImpostor.prototype.setParam = function (paramName, value) {
  113877. this._options[paramName] = value;
  113878. this._bodyUpdateRequired = true;
  113879. };
  113880. /**
  113881. * Specifically change the body's mass option. Won't recreate the physics body object
  113882. * @param mass The mass of the physics imposter
  113883. */
  113884. PhysicsImpostor.prototype.setMass = function (mass) {
  113885. if (this.getParam("mass") !== mass) {
  113886. this.setParam("mass", mass);
  113887. }
  113888. if (this._physicsEngine) {
  113889. this._physicsEngine.getPhysicsPlugin().setBodyMass(this, mass);
  113890. }
  113891. };
  113892. /**
  113893. * Gets the linear velocity
  113894. * @returns linear velocity or null
  113895. */
  113896. PhysicsImpostor.prototype.getLinearVelocity = function () {
  113897. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getLinearVelocity(this) : _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  113898. };
  113899. /**
  113900. * Sets the linear velocity
  113901. * @param velocity linear velocity or null
  113902. */
  113903. PhysicsImpostor.prototype.setLinearVelocity = function (velocity) {
  113904. if (this._physicsEngine) {
  113905. this._physicsEngine.getPhysicsPlugin().setLinearVelocity(this, velocity);
  113906. }
  113907. };
  113908. /**
  113909. * Gets the angular velocity
  113910. * @returns angular velocity or null
  113911. */
  113912. PhysicsImpostor.prototype.getAngularVelocity = function () {
  113913. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getAngularVelocity(this) : _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  113914. };
  113915. /**
  113916. * Sets the angular velocity
  113917. * @param velocity The velocity or null
  113918. */
  113919. PhysicsImpostor.prototype.setAngularVelocity = function (velocity) {
  113920. if (this._physicsEngine) {
  113921. this._physicsEngine.getPhysicsPlugin().setAngularVelocity(this, velocity);
  113922. }
  113923. };
  113924. /**
  113925. * Execute a function with the physics plugin native code
  113926. * Provide a function the will have two variables - the world object and the physics body object
  113927. * @param func The function to execute with the physics plugin native code
  113928. */
  113929. PhysicsImpostor.prototype.executeNativeFunction = function (func) {
  113930. if (this._physicsEngine) {
  113931. func(this._physicsEngine.getPhysicsPlugin().world, this.physicsBody);
  113932. }
  113933. };
  113934. /**
  113935. * Register a function that will be executed before the physics world is stepping forward
  113936. * @param func The function to execute before the physics world is stepped forward
  113937. */
  113938. PhysicsImpostor.prototype.registerBeforePhysicsStep = function (func) {
  113939. this._onBeforePhysicsStepCallbacks.push(func);
  113940. };
  113941. /**
  113942. * Unregister a function that will be executed before the physics world is stepping forward
  113943. * @param func The function to execute before the physics world is stepped forward
  113944. */
  113945. PhysicsImpostor.prototype.unregisterBeforePhysicsStep = function (func) {
  113946. var index = this._onBeforePhysicsStepCallbacks.indexOf(func);
  113947. if (index > -1) {
  113948. this._onBeforePhysicsStepCallbacks.splice(index, 1);
  113949. }
  113950. else {
  113951. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  113952. }
  113953. };
  113954. /**
  113955. * Register a function that will be executed after the physics step
  113956. * @param func The function to execute after physics step
  113957. */
  113958. PhysicsImpostor.prototype.registerAfterPhysicsStep = function (func) {
  113959. this._onAfterPhysicsStepCallbacks.push(func);
  113960. };
  113961. /**
  113962. * Unregisters a function that will be executed after the physics step
  113963. * @param func The function to execute after physics step
  113964. */
  113965. PhysicsImpostor.prototype.unregisterAfterPhysicsStep = function (func) {
  113966. var index = this._onAfterPhysicsStepCallbacks.indexOf(func);
  113967. if (index > -1) {
  113968. this._onAfterPhysicsStepCallbacks.splice(index, 1);
  113969. }
  113970. else {
  113971. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  113972. }
  113973. };
  113974. /**
  113975. * register a function that will be executed when this impostor collides against a different body
  113976. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  113977. * @param func Callback that is executed on collision
  113978. */
  113979. PhysicsImpostor.prototype.registerOnPhysicsCollide = function (collideAgainst, func) {
  113980. var collidedAgainstList = collideAgainst instanceof Array ? collideAgainst : [collideAgainst];
  113981. this._onPhysicsCollideCallbacks.push({ callback: func, otherImpostors: collidedAgainstList });
  113982. };
  113983. /**
  113984. * Unregisters the physics imposter on contact
  113985. * @param collideAgainst The physics object to collide against
  113986. * @param func Callback to execute on collision
  113987. */
  113988. PhysicsImpostor.prototype.unregisterOnPhysicsCollide = function (collideAgainst, func) {
  113989. var collidedAgainstList = collideAgainst instanceof Array ? collideAgainst : [collideAgainst];
  113990. var index = -1;
  113991. var found = this._onPhysicsCollideCallbacks.some(function (cbDef, idx) {
  113992. if (cbDef.callback === func && cbDef.otherImpostors.length === collidedAgainstList.length) {
  113993. // chcek the arrays match
  113994. var sameList = cbDef.otherImpostors.every(function (impostor) {
  113995. return collidedAgainstList.indexOf(impostor) > -1;
  113996. });
  113997. if (sameList) {
  113998. index = idx;
  113999. }
  114000. return sameList;
  114001. }
  114002. return false;
  114003. });
  114004. if (found) {
  114005. this._onPhysicsCollideCallbacks.splice(index, 1);
  114006. }
  114007. else {
  114008. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  114009. }
  114010. };
  114011. /**
  114012. * Get the parent rotation
  114013. * @returns The parent rotation
  114014. */
  114015. PhysicsImpostor.prototype.getParentsRotation = function () {
  114016. var parent = this.object.parent;
  114017. this._tmpQuat.copyFromFloats(0, 0, 0, 1);
  114018. while (parent) {
  114019. if (parent.rotationQuaternion) {
  114020. this._tmpQuat2.copyFrom(parent.rotationQuaternion);
  114021. }
  114022. else {
  114023. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(parent.rotation.y, parent.rotation.x, parent.rotation.z, this._tmpQuat2);
  114024. }
  114025. this._tmpQuat.multiplyToRef(this._tmpQuat2, this._tmpQuat);
  114026. parent = parent.parent;
  114027. }
  114028. return this._tmpQuat;
  114029. };
  114030. /**
  114031. * Apply a force
  114032. * @param force The force to apply
  114033. * @param contactPoint The contact point for the force
  114034. * @returns The physics imposter
  114035. */
  114036. PhysicsImpostor.prototype.applyForce = function (force, contactPoint) {
  114037. if (this._physicsEngine) {
  114038. this._physicsEngine.getPhysicsPlugin().applyForce(this, force, contactPoint);
  114039. }
  114040. return this;
  114041. };
  114042. /**
  114043. * Apply an impulse
  114044. * @param force The impulse force
  114045. * @param contactPoint The contact point for the impulse force
  114046. * @returns The physics imposter
  114047. */
  114048. PhysicsImpostor.prototype.applyImpulse = function (force, contactPoint) {
  114049. if (this._physicsEngine) {
  114050. this._physicsEngine.getPhysicsPlugin().applyImpulse(this, force, contactPoint);
  114051. }
  114052. return this;
  114053. };
  114054. /**
  114055. * A help function to create a joint
  114056. * @param otherImpostor A physics imposter used to create a joint
  114057. * @param jointType The type of joint
  114058. * @param jointData The data for the joint
  114059. * @returns The physics imposter
  114060. */
  114061. PhysicsImpostor.prototype.createJoint = function (otherImpostor, jointType, jointData) {
  114062. var joint = new _physicsJoint__WEBPACK_IMPORTED_MODULE_5__["PhysicsJoint"](jointType, jointData);
  114063. this.addJoint(otherImpostor, joint);
  114064. return this;
  114065. };
  114066. /**
  114067. * Add a joint to this impostor with a different impostor
  114068. * @param otherImpostor A physics imposter used to add a joint
  114069. * @param joint The joint to add
  114070. * @returns The physics imposter
  114071. */
  114072. PhysicsImpostor.prototype.addJoint = function (otherImpostor, joint) {
  114073. this._joints.push({
  114074. otherImpostor: otherImpostor,
  114075. joint: joint
  114076. });
  114077. if (this._physicsEngine) {
  114078. this._physicsEngine.addJoint(this, otherImpostor, joint);
  114079. }
  114080. return this;
  114081. };
  114082. /**
  114083. * Will keep this body still, in a sleep mode.
  114084. * @returns the physics imposter
  114085. */
  114086. PhysicsImpostor.prototype.sleep = function () {
  114087. if (this._physicsEngine) {
  114088. this._physicsEngine.getPhysicsPlugin().sleepBody(this);
  114089. }
  114090. return this;
  114091. };
  114092. /**
  114093. * Wake the body up.
  114094. * @returns The physics imposter
  114095. */
  114096. PhysicsImpostor.prototype.wakeUp = function () {
  114097. if (this._physicsEngine) {
  114098. this._physicsEngine.getPhysicsPlugin().wakeUpBody(this);
  114099. }
  114100. return this;
  114101. };
  114102. /**
  114103. * Clones the physics imposter
  114104. * @param newObject The physics imposter clones to this physics-enabled object
  114105. * @returns A nullable physics imposter
  114106. */
  114107. PhysicsImpostor.prototype.clone = function (newObject) {
  114108. if (!newObject) {
  114109. return null;
  114110. }
  114111. return new PhysicsImpostor(newObject, this.type, this._options, this._scene);
  114112. };
  114113. /**
  114114. * Disposes the physics imposter
  114115. */
  114116. PhysicsImpostor.prototype.dispose = function ( /*disposeChildren: boolean = true*/) {
  114117. var _this = this;
  114118. //no dispose if no physics engine is available.
  114119. if (!this._physicsEngine) {
  114120. return;
  114121. }
  114122. this._joints.forEach(function (j) {
  114123. if (_this._physicsEngine) {
  114124. _this._physicsEngine.removeJoint(_this, j.otherImpostor, j.joint);
  114125. }
  114126. });
  114127. //dispose the physics body
  114128. this._physicsEngine.removeImpostor(this);
  114129. if (this.parent) {
  114130. this.parent.forceUpdate();
  114131. }
  114132. else {
  114133. /*this._object.getChildMeshes().forEach(function(mesh) {
  114134. if (mesh.physicsImpostor) {
  114135. if (disposeChildren) {
  114136. mesh.physicsImpostor.dispose();
  114137. mesh.physicsImpostor = null;
  114138. }
  114139. }
  114140. })*/
  114141. }
  114142. this._isDisposed = true;
  114143. };
  114144. /**
  114145. * Sets the delta position
  114146. * @param position The delta position amount
  114147. */
  114148. PhysicsImpostor.prototype.setDeltaPosition = function (position) {
  114149. this._deltaPosition.copyFrom(position);
  114150. };
  114151. /**
  114152. * Sets the delta rotation
  114153. * @param rotation The delta rotation amount
  114154. */
  114155. PhysicsImpostor.prototype.setDeltaRotation = function (rotation) {
  114156. if (!this._deltaRotation) {
  114157. this._deltaRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  114158. }
  114159. this._deltaRotation.copyFrom(rotation);
  114160. this._deltaRotationConjugated = this._deltaRotation.conjugate();
  114161. };
  114162. /**
  114163. * Gets the box size of the physics imposter and stores the result in the input parameter
  114164. * @param result Stores the box size
  114165. * @returns The physics imposter
  114166. */
  114167. PhysicsImpostor.prototype.getBoxSizeToRef = function (result) {
  114168. if (this._physicsEngine) {
  114169. this._physicsEngine.getPhysicsPlugin().getBoxSizeToRef(this, result);
  114170. }
  114171. return this;
  114172. };
  114173. /**
  114174. * Gets the radius of the physics imposter
  114175. * @returns Radius of the physics imposter
  114176. */
  114177. PhysicsImpostor.prototype.getRadius = function () {
  114178. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getRadius(this) : 0;
  114179. };
  114180. /**
  114181. * Sync a bone with this impostor
  114182. * @param bone The bone to sync to the impostor.
  114183. * @param boneMesh The mesh that the bone is influencing.
  114184. * @param jointPivot The pivot of the joint / bone in local space.
  114185. * @param distToJoint Optional distance from the impostor to the joint.
  114186. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  114187. */
  114188. PhysicsImpostor.prototype.syncBoneWithImpostor = function (bone, boneMesh, jointPivot, distToJoint, adjustRotation) {
  114189. var tempVec = PhysicsImpostor._tmpVecs[0];
  114190. var mesh = this.object;
  114191. if (mesh.rotationQuaternion) {
  114192. if (adjustRotation) {
  114193. var tempQuat = PhysicsImpostor._tmpQuat;
  114194. mesh.rotationQuaternion.multiplyToRef(adjustRotation, tempQuat);
  114195. bone.setRotationQuaternion(tempQuat, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh);
  114196. }
  114197. else {
  114198. bone.setRotationQuaternion(mesh.rotationQuaternion, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh);
  114199. }
  114200. }
  114201. tempVec.x = 0;
  114202. tempVec.y = 0;
  114203. tempVec.z = 0;
  114204. if (jointPivot) {
  114205. tempVec.x = jointPivot.x;
  114206. tempVec.y = jointPivot.y;
  114207. tempVec.z = jointPivot.z;
  114208. bone.getDirectionToRef(tempVec, boneMesh, tempVec);
  114209. if (distToJoint === undefined || distToJoint === null) {
  114210. distToJoint = jointPivot.length();
  114211. }
  114212. tempVec.x *= distToJoint;
  114213. tempVec.y *= distToJoint;
  114214. tempVec.z *= distToJoint;
  114215. }
  114216. if (bone.getParent()) {
  114217. tempVec.addInPlace(mesh.getAbsolutePosition());
  114218. bone.setAbsolutePosition(tempVec, boneMesh);
  114219. }
  114220. else {
  114221. boneMesh.setAbsolutePosition(mesh.getAbsolutePosition());
  114222. boneMesh.position.x -= tempVec.x;
  114223. boneMesh.position.y -= tempVec.y;
  114224. boneMesh.position.z -= tempVec.z;
  114225. }
  114226. };
  114227. /**
  114228. * Sync impostor to a bone
  114229. * @param bone The bone that the impostor will be synced to.
  114230. * @param boneMesh The mesh that the bone is influencing.
  114231. * @param jointPivot The pivot of the joint / bone in local space.
  114232. * @param distToJoint Optional distance from the impostor to the joint.
  114233. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  114234. * @param boneAxis Optional vector3 axis the bone is aligned with
  114235. */
  114236. PhysicsImpostor.prototype.syncImpostorWithBone = function (bone, boneMesh, jointPivot, distToJoint, adjustRotation, boneAxis) {
  114237. var mesh = this.object;
  114238. if (mesh.rotationQuaternion) {
  114239. if (adjustRotation) {
  114240. var tempQuat = PhysicsImpostor._tmpQuat;
  114241. bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh, tempQuat);
  114242. tempQuat.multiplyToRef(adjustRotation, mesh.rotationQuaternion);
  114243. }
  114244. else {
  114245. bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh, mesh.rotationQuaternion);
  114246. }
  114247. }
  114248. var pos = PhysicsImpostor._tmpVecs[0];
  114249. var boneDir = PhysicsImpostor._tmpVecs[1];
  114250. if (!boneAxis) {
  114251. boneAxis = PhysicsImpostor._tmpVecs[2];
  114252. boneAxis.x = 0;
  114253. boneAxis.y = 1;
  114254. boneAxis.z = 0;
  114255. }
  114256. bone.getDirectionToRef(boneAxis, boneMesh, boneDir);
  114257. bone.getAbsolutePositionToRef(boneMesh, pos);
  114258. if ((distToJoint === undefined || distToJoint === null) && jointPivot) {
  114259. distToJoint = jointPivot.length();
  114260. }
  114261. if (distToJoint !== undefined && distToJoint !== null) {
  114262. pos.x += boneDir.x * distToJoint;
  114263. pos.y += boneDir.y * distToJoint;
  114264. pos.z += boneDir.z * distToJoint;
  114265. }
  114266. mesh.setAbsolutePosition(pos);
  114267. };
  114268. /**
  114269. * The default object size of the imposter
  114270. */
  114271. PhysicsImpostor.DEFAULT_OBJECT_SIZE = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 1, 1);
  114272. /**
  114273. * The identity quaternion of the imposter
  114274. */
  114275. PhysicsImpostor.IDENTITY_QUATERNION = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  114276. PhysicsImpostor._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_1__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero);
  114277. PhysicsImpostor._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  114278. //Impostor types
  114279. /**
  114280. * No-Imposter type
  114281. */
  114282. PhysicsImpostor.NoImpostor = 0;
  114283. /**
  114284. * Sphere-Imposter type
  114285. */
  114286. PhysicsImpostor.SphereImpostor = 1;
  114287. /**
  114288. * Box-Imposter type
  114289. */
  114290. PhysicsImpostor.BoxImpostor = 2;
  114291. /**
  114292. * Plane-Imposter type
  114293. */
  114294. PhysicsImpostor.PlaneImpostor = 3;
  114295. /**
  114296. * Mesh-imposter type
  114297. */
  114298. PhysicsImpostor.MeshImpostor = 4;
  114299. /**
  114300. * Cylinder-Imposter type
  114301. */
  114302. PhysicsImpostor.CylinderImpostor = 7;
  114303. /**
  114304. * Particle-Imposter type
  114305. */
  114306. PhysicsImpostor.ParticleImpostor = 8;
  114307. /**
  114308. * Heightmap-Imposter type
  114309. */
  114310. PhysicsImpostor.HeightmapImpostor = 9;
  114311. return PhysicsImpostor;
  114312. }());
  114313. /***/ }),
  114314. /***/ "./Physics/physicsJoint.ts":
  114315. /*!*********************************!*\
  114316. !*** ./Physics/physicsJoint.ts ***!
  114317. \*********************************/
  114318. /*! exports provided: PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint */
  114319. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114320. "use strict";
  114321. __webpack_require__.r(__webpack_exports__);
  114322. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return PhysicsJoint; });
  114323. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return DistanceJoint; });
  114324. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return MotorEnabledJoint; });
  114325. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return HingeJoint; });
  114326. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return Hinge2Joint; });
  114327. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  114328. /**
  114329. * This is a holder class for the physics joint created by the physics plugin
  114330. * It holds a set of functions to control the underlying joint
  114331. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  114332. */
  114333. var PhysicsJoint = /** @class */ (function () {
  114334. /**
  114335. * Initializes the physics joint
  114336. * @param type The type of the physics joint
  114337. * @param jointData The data for the physics joint
  114338. */
  114339. function PhysicsJoint(
  114340. /**
  114341. * The type of the physics joint
  114342. */
  114343. type,
  114344. /**
  114345. * The data for the physics joint
  114346. */
  114347. jointData) {
  114348. this.type = type;
  114349. this.jointData = jointData;
  114350. jointData.nativeParams = jointData.nativeParams || {};
  114351. }
  114352. Object.defineProperty(PhysicsJoint.prototype, "physicsJoint", {
  114353. /**
  114354. * Gets the physics joint
  114355. */
  114356. get: function () {
  114357. return this._physicsJoint;
  114358. },
  114359. /**
  114360. * Sets the physics joint
  114361. */
  114362. set: function (newJoint) {
  114363. if (this._physicsJoint) {
  114364. //remove from the wolrd
  114365. }
  114366. this._physicsJoint = newJoint;
  114367. },
  114368. enumerable: true,
  114369. configurable: true
  114370. });
  114371. Object.defineProperty(PhysicsJoint.prototype, "physicsPlugin", {
  114372. /**
  114373. * Sets the physics plugin
  114374. */
  114375. set: function (physicsPlugin) {
  114376. this._physicsPlugin = physicsPlugin;
  114377. },
  114378. enumerable: true,
  114379. configurable: true
  114380. });
  114381. /**
  114382. * Execute a function that is physics-plugin specific.
  114383. * @param {Function} func the function that will be executed.
  114384. * It accepts two parameters: the physics world and the physics joint
  114385. */
  114386. PhysicsJoint.prototype.executeNativeFunction = function (func) {
  114387. func(this._physicsPlugin.world, this._physicsJoint);
  114388. };
  114389. //TODO check if the native joints are the same
  114390. //Joint Types
  114391. /**
  114392. * Distance-Joint type
  114393. */
  114394. PhysicsJoint.DistanceJoint = 0;
  114395. /**
  114396. * Hinge-Joint type
  114397. */
  114398. PhysicsJoint.HingeJoint = 1;
  114399. /**
  114400. * Ball-and-Socket joint type
  114401. */
  114402. PhysicsJoint.BallAndSocketJoint = 2;
  114403. /**
  114404. * Wheel-Joint type
  114405. */
  114406. PhysicsJoint.WheelJoint = 3;
  114407. /**
  114408. * Slider-Joint type
  114409. */
  114410. PhysicsJoint.SliderJoint = 4;
  114411. //OIMO
  114412. /**
  114413. * Prismatic-Joint type
  114414. */
  114415. PhysicsJoint.PrismaticJoint = 5;
  114416. //
  114417. /**
  114418. * Universal-Joint type
  114419. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  114420. */
  114421. PhysicsJoint.UniversalJoint = 6;
  114422. /**
  114423. * Hinge-Joint 2 type
  114424. */
  114425. PhysicsJoint.Hinge2Joint = PhysicsJoint.WheelJoint;
  114426. //Cannon
  114427. /**
  114428. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  114429. */
  114430. PhysicsJoint.PointToPointJoint = 8;
  114431. //Cannon only at the moment
  114432. /**
  114433. * Spring-Joint type
  114434. */
  114435. PhysicsJoint.SpringJoint = 9;
  114436. /**
  114437. * Lock-Joint type
  114438. */
  114439. PhysicsJoint.LockJoint = 10;
  114440. return PhysicsJoint;
  114441. }());
  114442. /**
  114443. * A class representing a physics distance joint
  114444. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  114445. */
  114446. var DistanceJoint = /** @class */ (function (_super) {
  114447. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DistanceJoint, _super);
  114448. /**
  114449. *
  114450. * @param jointData The data for the Distance-Joint
  114451. */
  114452. function DistanceJoint(jointData) {
  114453. return _super.call(this, PhysicsJoint.DistanceJoint, jointData) || this;
  114454. }
  114455. /**
  114456. * Update the predefined distance.
  114457. * @param maxDistance The maximum preferred distance
  114458. * @param minDistance The minimum preferred distance
  114459. */
  114460. DistanceJoint.prototype.updateDistance = function (maxDistance, minDistance) {
  114461. this._physicsPlugin.updateDistanceJoint(this, maxDistance, minDistance);
  114462. };
  114463. return DistanceJoint;
  114464. }(PhysicsJoint));
  114465. /**
  114466. * Represents a Motor-Enabled Joint
  114467. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  114468. */
  114469. var MotorEnabledJoint = /** @class */ (function (_super) {
  114470. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MotorEnabledJoint, _super);
  114471. /**
  114472. * Initializes the Motor-Enabled Joint
  114473. * @param type The type of the joint
  114474. * @param jointData The physica joint data for the joint
  114475. */
  114476. function MotorEnabledJoint(type, jointData) {
  114477. return _super.call(this, type, jointData) || this;
  114478. }
  114479. /**
  114480. * Set the motor values.
  114481. * Attention, this function is plugin specific. Engines won't react 100% the same.
  114482. * @param force the force to apply
  114483. * @param maxForce max force for this motor.
  114484. */
  114485. MotorEnabledJoint.prototype.setMotor = function (force, maxForce) {
  114486. this._physicsPlugin.setMotor(this, force || 0, maxForce);
  114487. };
  114488. /**
  114489. * Set the motor's limits.
  114490. * Attention, this function is plugin specific. Engines won't react 100% the same.
  114491. * @param upperLimit The upper limit of the motor
  114492. * @param lowerLimit The lower limit of the motor
  114493. */
  114494. MotorEnabledJoint.prototype.setLimit = function (upperLimit, lowerLimit) {
  114495. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit);
  114496. };
  114497. return MotorEnabledJoint;
  114498. }(PhysicsJoint));
  114499. /**
  114500. * This class represents a single physics Hinge-Joint
  114501. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  114502. */
  114503. var HingeJoint = /** @class */ (function (_super) {
  114504. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HingeJoint, _super);
  114505. /**
  114506. * Initializes the Hinge-Joint
  114507. * @param jointData The joint data for the Hinge-Joint
  114508. */
  114509. function HingeJoint(jointData) {
  114510. return _super.call(this, PhysicsJoint.HingeJoint, jointData) || this;
  114511. }
  114512. /**
  114513. * Set the motor values.
  114514. * Attention, this function is plugin specific. Engines won't react 100% the same.
  114515. * @param {number} force the force to apply
  114516. * @param {number} maxForce max force for this motor.
  114517. */
  114518. HingeJoint.prototype.setMotor = function (force, maxForce) {
  114519. this._physicsPlugin.setMotor(this, force || 0, maxForce);
  114520. };
  114521. /**
  114522. * Set the motor's limits.
  114523. * Attention, this function is plugin specific. Engines won't react 100% the same.
  114524. * @param upperLimit The upper limit of the motor
  114525. * @param lowerLimit The lower limit of the motor
  114526. */
  114527. HingeJoint.prototype.setLimit = function (upperLimit, lowerLimit) {
  114528. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit);
  114529. };
  114530. return HingeJoint;
  114531. }(MotorEnabledJoint));
  114532. /**
  114533. * This class represents a dual hinge physics joint (same as wheel joint)
  114534. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  114535. */
  114536. var Hinge2Joint = /** @class */ (function (_super) {
  114537. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Hinge2Joint, _super);
  114538. /**
  114539. * Initializes the Hinge2-Joint
  114540. * @param jointData The joint data for the Hinge2-Joint
  114541. */
  114542. function Hinge2Joint(jointData) {
  114543. return _super.call(this, PhysicsJoint.Hinge2Joint, jointData) || this;
  114544. }
  114545. /**
  114546. * Set the motor values.
  114547. * Attention, this function is plugin specific. Engines won't react 100% the same.
  114548. * @param {number} targetSpeed the speed the motor is to reach
  114549. * @param {number} maxForce max force for this motor.
  114550. * @param {motorIndex} the motor's index, 0 or 1.
  114551. */
  114552. Hinge2Joint.prototype.setMotor = function (targetSpeed, maxForce, motorIndex) {
  114553. if (motorIndex === void 0) { motorIndex = 0; }
  114554. this._physicsPlugin.setMotor(this, targetSpeed || 0, maxForce, motorIndex);
  114555. };
  114556. /**
  114557. * Set the motor limits.
  114558. * Attention, this function is plugin specific. Engines won't react 100% the same.
  114559. * @param {number} upperLimit the upper limit
  114560. * @param {number} lowerLimit lower limit
  114561. * @param {motorIndex} the motor's index, 0 or 1.
  114562. */
  114563. Hinge2Joint.prototype.setLimit = function (upperLimit, lowerLimit, motorIndex) {
  114564. if (motorIndex === void 0) { motorIndex = 0; }
  114565. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit, motorIndex);
  114566. };
  114567. return Hinge2Joint;
  114568. }(MotorEnabledJoint));
  114569. /***/ }),
  114570. /***/ "./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts":
  114571. /*!****************************************************************************!*\
  114572. !*** ./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts ***!
  114573. \****************************************************************************/
  114574. /*! exports provided: DefaultRenderingPipeline */
  114575. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114576. "use strict";
  114577. __webpack_require__.r(__webpack_exports__);
  114578. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return DefaultRenderingPipeline; });
  114579. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  114580. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  114581. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  114582. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  114583. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  114584. /* harmony import */ var _Layers_glowLayer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Layers/glowLayer */ "./Layers/glowLayer.ts");
  114585. /* harmony import */ var _PostProcesses_sharpenPostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/sharpenPostProcess */ "./PostProcesses/sharpenPostProcess.ts");
  114586. /* harmony import */ var _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  114587. /* harmony import */ var _PostProcesses_chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/chromaticAberrationPostProcess */ "./PostProcesses/chromaticAberrationPostProcess.ts");
  114588. /* harmony import */ var _PostProcesses_grainPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/grainPostProcess */ "./PostProcesses/grainPostProcess.ts");
  114589. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  114590. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  114591. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  114592. /* harmony import */ var _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../PostProcesses/depthOfFieldEffect */ "./PostProcesses/depthOfFieldEffect.ts");
  114593. /* harmony import */ var _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../../PostProcesses/bloomEffect */ "./PostProcesses/bloomEffect.ts");
  114594. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  114595. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  114596. /**
  114597. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  114598. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  114599. */
  114600. var DefaultRenderingPipeline = /** @class */ (function (_super) {
  114601. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DefaultRenderingPipeline, _super);
  114602. /**
  114603. * @constructor
  114604. * @param name - The rendering pipeline name (default: "")
  114605. * @param hdr - If high dynamic range textures should be used (default: true)
  114606. * @param scene - The scene linked to this pipeline (default: the last created scene)
  114607. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  114608. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  114609. */
  114610. function DefaultRenderingPipeline(name, hdr, scene, cameras, automaticBuild) {
  114611. if (name === void 0) { name = ""; }
  114612. if (hdr === void 0) { hdr = true; }
  114613. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene; }
  114614. if (automaticBuild === void 0) { automaticBuild = true; }
  114615. var _this = _super.call(this, scene.getEngine(), name) || this;
  114616. _this._camerasToBeAttached = [];
  114617. /**
  114618. * ID of the sharpen post process,
  114619. */
  114620. _this.SharpenPostProcessId = "SharpenPostProcessEffect";
  114621. /**
  114622. * @ignore
  114623. * ID of the image processing post process;
  114624. */
  114625. _this.ImageProcessingPostProcessId = "ImageProcessingPostProcessEffect";
  114626. /**
  114627. * @ignore
  114628. * ID of the Fast Approximate Anti-Aliasing post process;
  114629. */
  114630. _this.FxaaPostProcessId = "FxaaPostProcessEffect";
  114631. /**
  114632. * ID of the chromatic aberration post process,
  114633. */
  114634. _this.ChromaticAberrationPostProcessId = "ChromaticAberrationPostProcessEffect";
  114635. /**
  114636. * ID of the grain post process
  114637. */
  114638. _this.GrainPostProcessId = "GrainPostProcessEffect";
  114639. /**
  114640. * Glow post process which adds a glow to emissive areas of the image
  114641. */
  114642. _this._glowLayer = null;
  114643. /**
  114644. * Animations which can be used to tweak settings over a period of time
  114645. */
  114646. _this.animations = [];
  114647. _this._imageProcessingConfigurationObserver = null;
  114648. // Values
  114649. _this._sharpenEnabled = false;
  114650. _this._bloomEnabled = false;
  114651. _this._depthOfFieldEnabled = false;
  114652. _this._depthOfFieldBlurLevel = _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffectBlurLevel"].Low;
  114653. _this._fxaaEnabled = false;
  114654. _this._imageProcessingEnabled = true;
  114655. _this._bloomScale = 0.5;
  114656. _this._chromaticAberrationEnabled = false;
  114657. _this._grainEnabled = false;
  114658. _this._buildAllowed = true;
  114659. _this._resizeObserver = null;
  114660. _this._hardwareScaleLevel = 1.0;
  114661. _this._bloomKernel = 64;
  114662. /**
  114663. * Specifies the weight of the bloom in the final rendering
  114664. */
  114665. _this._bloomWeight = 0.15;
  114666. /**
  114667. * Specifies the luma threshold for the area that will be blurred by the bloom
  114668. */
  114669. _this._bloomThreshold = 0.9;
  114670. _this._samples = 1;
  114671. _this._hasCleared = false;
  114672. _this._prevPostProcess = null;
  114673. _this._prevPrevPostProcess = null;
  114674. _this._depthOfFieldSceneObserver = null;
  114675. _this._cameras = cameras || scene.cameras;
  114676. _this._cameras = _this._cameras.slice();
  114677. _this._camerasToBeAttached = _this._cameras.slice();
  114678. _this._buildAllowed = automaticBuild;
  114679. // Initialize
  114680. _this._scene = scene;
  114681. var caps = _this._scene.getEngine().getCaps();
  114682. _this._hdr = hdr && (caps.textureHalfFloatRender || caps.textureFloatRender);
  114683. // Misc
  114684. if (_this._hdr) {
  114685. if (caps.textureHalfFloatRender) {
  114686. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_HALF_FLOAT;
  114687. }
  114688. else if (caps.textureFloatRender) {
  114689. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_FLOAT;
  114690. }
  114691. }
  114692. else {
  114693. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  114694. }
  114695. // Attach
  114696. scene.postProcessRenderPipelineManager.addPipeline(_this);
  114697. var engine = _this._scene.getEngine();
  114698. // Create post processes before hand so they can be modified before enabled.
  114699. // Block compilation flag is set to true to avoid compilation prior to use, these will be updated on first use in build pipeline.
  114700. _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);
  114701. _this._sharpenEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.SharpenPostProcessId, function () { return _this.sharpen; }, true);
  114702. _this.depthOfField = new _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffect"](_this._scene, null, _this._depthOfFieldBlurLevel, _this._defaultPipelineTextureType, true);
  114703. _this.bloom = new _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__["BloomEffect"](_this._scene, _this._bloomScale, _this._bloomWeight, _this.bloomKernel, _this._defaultPipelineTextureType, true);
  114704. _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);
  114705. _this._chromaticAberrationEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.ChromaticAberrationPostProcessId, function () { return _this.chromaticAberration; }, true);
  114706. _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);
  114707. _this._grainEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.GrainPostProcessId, function () { return _this.grain; }, true);
  114708. _this._resizeObserver = engine.onResizeObservable.add(function () {
  114709. _this._hardwareScaleLevel = engine.getHardwareScalingLevel();
  114710. _this.bloomKernel = _this.bloomKernel;
  114711. });
  114712. _this._imageProcessingConfigurationObserver = _this._scene.imageProcessingConfiguration.onUpdateParameters.add(function () {
  114713. _this.bloom._downscale._exposure = _this._scene.imageProcessingConfiguration.exposure;
  114714. });
  114715. _this._buildPipeline();
  114716. return _this;
  114717. }
  114718. Object.defineProperty(DefaultRenderingPipeline.prototype, "scene", {
  114719. /**
  114720. * Gets active scene
  114721. */
  114722. get: function () {
  114723. return this._scene;
  114724. },
  114725. enumerable: true,
  114726. configurable: true
  114727. });
  114728. Object.defineProperty(DefaultRenderingPipeline.prototype, "sharpenEnabled", {
  114729. get: function () {
  114730. return this._sharpenEnabled;
  114731. },
  114732. /**
  114733. * Enable or disable the sharpen process from the pipeline
  114734. */
  114735. set: function (enabled) {
  114736. if (this._sharpenEnabled === enabled) {
  114737. return;
  114738. }
  114739. this._sharpenEnabled = enabled;
  114740. this._buildPipeline();
  114741. },
  114742. enumerable: true,
  114743. configurable: true
  114744. });
  114745. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomKernel", {
  114746. /**
  114747. * Specifies the size of the bloom blur kernel, relative to the final output size
  114748. */
  114749. get: function () {
  114750. return this._bloomKernel;
  114751. },
  114752. set: function (value) {
  114753. this._bloomKernel = value;
  114754. this.bloom.kernel = value / this._hardwareScaleLevel;
  114755. },
  114756. enumerable: true,
  114757. configurable: true
  114758. });
  114759. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomWeight", {
  114760. get: function () {
  114761. return this._bloomWeight;
  114762. },
  114763. /**
  114764. * The strength of the bloom.
  114765. */
  114766. set: function (value) {
  114767. if (this._bloomWeight === value) {
  114768. return;
  114769. }
  114770. this.bloom.weight = value;
  114771. this._bloomWeight = value;
  114772. },
  114773. enumerable: true,
  114774. configurable: true
  114775. });
  114776. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomThreshold", {
  114777. get: function () {
  114778. return this._bloomThreshold;
  114779. },
  114780. /**
  114781. * The strength of the bloom.
  114782. */
  114783. set: function (value) {
  114784. if (this._bloomThreshold === value) {
  114785. return;
  114786. }
  114787. this.bloom.threshold = value;
  114788. this._bloomThreshold = value;
  114789. },
  114790. enumerable: true,
  114791. configurable: true
  114792. });
  114793. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomScale", {
  114794. get: function () {
  114795. return this._bloomScale;
  114796. },
  114797. /**
  114798. * The scale of the bloom, lower value will provide better performance.
  114799. */
  114800. set: function (value) {
  114801. if (this._bloomScale === value) {
  114802. return;
  114803. }
  114804. this._bloomScale = value;
  114805. // recreate bloom and dispose old as this setting is not dynamic
  114806. this._rebuildBloom();
  114807. this._buildPipeline();
  114808. },
  114809. enumerable: true,
  114810. configurable: true
  114811. });
  114812. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomEnabled", {
  114813. get: function () {
  114814. return this._bloomEnabled;
  114815. },
  114816. /**
  114817. * Enable or disable the bloom from the pipeline
  114818. */
  114819. set: function (enabled) {
  114820. if (this._bloomEnabled === enabled) {
  114821. return;
  114822. }
  114823. this._bloomEnabled = enabled;
  114824. this._buildPipeline();
  114825. },
  114826. enumerable: true,
  114827. configurable: true
  114828. });
  114829. DefaultRenderingPipeline.prototype._rebuildBloom = function () {
  114830. // recreate bloom and dispose old as this setting is not dynamic
  114831. var oldBloom = this.bloom;
  114832. this.bloom = new _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__["BloomEffect"](this._scene, this.bloomScale, this._bloomWeight, this.bloomKernel, this._defaultPipelineTextureType, false);
  114833. this.bloom.threshold = oldBloom.threshold;
  114834. for (var i = 0; i < this._cameras.length; i++) {
  114835. oldBloom.disposeEffects(this._cameras[i]);
  114836. }
  114837. };
  114838. Object.defineProperty(DefaultRenderingPipeline.prototype, "depthOfFieldEnabled", {
  114839. /**
  114840. * If the depth of field is enabled.
  114841. */
  114842. get: function () {
  114843. return this._depthOfFieldEnabled;
  114844. },
  114845. set: function (enabled) {
  114846. if (this._depthOfFieldEnabled === enabled) {
  114847. return;
  114848. }
  114849. this._depthOfFieldEnabled = enabled;
  114850. this._buildPipeline();
  114851. },
  114852. enumerable: true,
  114853. configurable: true
  114854. });
  114855. Object.defineProperty(DefaultRenderingPipeline.prototype, "depthOfFieldBlurLevel", {
  114856. /**
  114857. * Blur level of the depth of field effect. (Higher blur will effect performance)
  114858. */
  114859. get: function () {
  114860. return this._depthOfFieldBlurLevel;
  114861. },
  114862. set: function (value) {
  114863. if (this._depthOfFieldBlurLevel === value) {
  114864. return;
  114865. }
  114866. this._depthOfFieldBlurLevel = value;
  114867. // recreate dof and dispose old as this setting is not dynamic
  114868. var oldDof = this.depthOfField;
  114869. this.depthOfField = new _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffect"](this._scene, null, this._depthOfFieldBlurLevel, this._defaultPipelineTextureType, false);
  114870. this.depthOfField.focalLength = oldDof.focalLength;
  114871. this.depthOfField.focusDistance = oldDof.focusDistance;
  114872. this.depthOfField.fStop = oldDof.fStop;
  114873. this.depthOfField.lensSize = oldDof.lensSize;
  114874. for (var i = 0; i < this._cameras.length; i++) {
  114875. oldDof.disposeEffects(this._cameras[i]);
  114876. }
  114877. this._buildPipeline();
  114878. },
  114879. enumerable: true,
  114880. configurable: true
  114881. });
  114882. Object.defineProperty(DefaultRenderingPipeline.prototype, "fxaaEnabled", {
  114883. get: function () {
  114884. return this._fxaaEnabled;
  114885. },
  114886. /**
  114887. * If the anti aliasing is enabled.
  114888. */
  114889. set: function (enabled) {
  114890. if (this._fxaaEnabled === enabled) {
  114891. return;
  114892. }
  114893. this._fxaaEnabled = enabled;
  114894. this._buildPipeline();
  114895. },
  114896. enumerable: true,
  114897. configurable: true
  114898. });
  114899. Object.defineProperty(DefaultRenderingPipeline.prototype, "samples", {
  114900. get: function () {
  114901. return this._samples;
  114902. },
  114903. /**
  114904. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  114905. */
  114906. set: function (sampleCount) {
  114907. if (this._samples === sampleCount) {
  114908. return;
  114909. }
  114910. this._samples = sampleCount;
  114911. this._buildPipeline();
  114912. },
  114913. enumerable: true,
  114914. configurable: true
  114915. });
  114916. Object.defineProperty(DefaultRenderingPipeline.prototype, "imageProcessingEnabled", {
  114917. get: function () {
  114918. return this._imageProcessingEnabled;
  114919. },
  114920. /**
  114921. * If image processing is enabled.
  114922. */
  114923. set: function (enabled) {
  114924. if (this._imageProcessingEnabled === enabled) {
  114925. return;
  114926. }
  114927. this._imageProcessingEnabled = enabled;
  114928. this._buildPipeline();
  114929. },
  114930. enumerable: true,
  114931. configurable: true
  114932. });
  114933. Object.defineProperty(DefaultRenderingPipeline.prototype, "glowLayerEnabled", {
  114934. get: function () {
  114935. return this._glowLayer != null;
  114936. },
  114937. /**
  114938. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  114939. */
  114940. set: function (enabled) {
  114941. if (enabled && !this._glowLayer) {
  114942. this._glowLayer = new _Layers_glowLayer__WEBPACK_IMPORTED_MODULE_5__["GlowLayer"]("", this._scene);
  114943. }
  114944. else if (!enabled && this._glowLayer) {
  114945. this._glowLayer.dispose();
  114946. this._glowLayer = null;
  114947. }
  114948. },
  114949. enumerable: true,
  114950. configurable: true
  114951. });
  114952. Object.defineProperty(DefaultRenderingPipeline.prototype, "chromaticAberrationEnabled", {
  114953. get: function () {
  114954. return this._chromaticAberrationEnabled;
  114955. },
  114956. /**
  114957. * Enable or disable the chromaticAberration process from the pipeline
  114958. */
  114959. set: function (enabled) {
  114960. if (this._chromaticAberrationEnabled === enabled) {
  114961. return;
  114962. }
  114963. this._chromaticAberrationEnabled = enabled;
  114964. this._buildPipeline();
  114965. },
  114966. enumerable: true,
  114967. configurable: true
  114968. });
  114969. Object.defineProperty(DefaultRenderingPipeline.prototype, "grainEnabled", {
  114970. get: function () {
  114971. return this._grainEnabled;
  114972. },
  114973. /**
  114974. * Enable or disable the grain process from the pipeline
  114975. */
  114976. set: function (enabled) {
  114977. if (this._grainEnabled === enabled) {
  114978. return;
  114979. }
  114980. this._grainEnabled = enabled;
  114981. this._buildPipeline();
  114982. },
  114983. enumerable: true,
  114984. configurable: true
  114985. });
  114986. /**
  114987. * Get the class name
  114988. * @returns "DefaultRenderingPipeline"
  114989. */
  114990. DefaultRenderingPipeline.prototype.getClassName = function () {
  114991. return "DefaultRenderingPipeline";
  114992. };
  114993. /**
  114994. * Force the compilation of the entire pipeline.
  114995. */
  114996. DefaultRenderingPipeline.prototype.prepare = function () {
  114997. var previousState = this._buildAllowed;
  114998. this._buildAllowed = true;
  114999. this._buildPipeline();
  115000. this._buildAllowed = previousState;
  115001. };
  115002. DefaultRenderingPipeline.prototype._setAutoClearAndTextureSharing = function (postProcess, skipTextureSharing) {
  115003. if (skipTextureSharing === void 0) { skipTextureSharing = false; }
  115004. if (this._hasCleared) {
  115005. postProcess.autoClear = false;
  115006. }
  115007. else {
  115008. postProcess.autoClear = true;
  115009. this._scene.autoClear = false;
  115010. this._hasCleared = true;
  115011. }
  115012. if (!skipTextureSharing) {
  115013. if (this._prevPrevPostProcess) {
  115014. postProcess.shareOutputWith(this._prevPrevPostProcess);
  115015. }
  115016. else {
  115017. postProcess.useOwnOutput();
  115018. }
  115019. if (this._prevPostProcess) {
  115020. this._prevPrevPostProcess = this._prevPostProcess;
  115021. }
  115022. this._prevPostProcess = postProcess;
  115023. }
  115024. };
  115025. DefaultRenderingPipeline.prototype._buildPipeline = function () {
  115026. var _this = this;
  115027. if (!this._buildAllowed) {
  115028. return;
  115029. }
  115030. this._scene.autoClear = true;
  115031. var engine = this._scene.getEngine();
  115032. this._disposePostProcesses();
  115033. if (this._cameras !== null) {
  115034. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  115035. // get back cameras to be used to reattach pipeline
  115036. this._cameras = this._camerasToBeAttached.slice();
  115037. }
  115038. this._reset();
  115039. this._prevPostProcess = null;
  115040. this._prevPrevPostProcess = null;
  115041. this._hasCleared = false;
  115042. if (this.depthOfFieldEnabled) {
  115043. // Multi camera suport
  115044. if (this._cameras.length > 1) {
  115045. for (var _i = 0, _a = this._cameras; _i < _a.length; _i++) {
  115046. var camera = _a[_i];
  115047. var depthRenderer = this._scene.enableDepthRenderer(camera);
  115048. depthRenderer.useOnlyInActiveCamera = true;
  115049. }
  115050. this._depthOfFieldSceneObserver = this._scene.onAfterRenderTargetsRenderObservable.add(function (scene) {
  115051. if (_this._cameras.indexOf(scene.activeCamera) > -1) {
  115052. _this.depthOfField.depthTexture = scene.enableDepthRenderer(scene.activeCamera).getDepthMap();
  115053. }
  115054. });
  115055. }
  115056. else {
  115057. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  115058. var depthRenderer = this._scene.enableDepthRenderer(this._cameras[0]);
  115059. this.depthOfField.depthTexture = depthRenderer.getDepthMap();
  115060. }
  115061. if (!this.depthOfField._isReady()) {
  115062. this.depthOfField._updateEffects();
  115063. }
  115064. this.addEffect(this.depthOfField);
  115065. this._setAutoClearAndTextureSharing(this.depthOfField._effects[0], true);
  115066. }
  115067. else {
  115068. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  115069. }
  115070. if (this.bloomEnabled) {
  115071. if (!this.bloom._isReady()) {
  115072. this.bloom._updateEffects();
  115073. }
  115074. this.addEffect(this.bloom);
  115075. this._setAutoClearAndTextureSharing(this.bloom._effects[0], true);
  115076. }
  115077. if (this._imageProcessingEnabled) {
  115078. 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);
  115079. if (this._hdr) {
  115080. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, this.ImageProcessingPostProcessId, function () { return _this.imageProcessing; }, true));
  115081. this._setAutoClearAndTextureSharing(this.imageProcessing);
  115082. }
  115083. else {
  115084. this._scene.imageProcessingConfiguration.applyByPostProcess = false;
  115085. }
  115086. }
  115087. if (this.sharpenEnabled) {
  115088. if (!this.sharpen.isReady()) {
  115089. this.sharpen.updateEffect();
  115090. }
  115091. this.addEffect(this._sharpenEffect);
  115092. this._setAutoClearAndTextureSharing(this.sharpen);
  115093. }
  115094. if (this.grainEnabled) {
  115095. if (!this.grain.isReady()) {
  115096. this.grain.updateEffect();
  115097. }
  115098. this.addEffect(this._grainEffect);
  115099. this._setAutoClearAndTextureSharing(this.grain);
  115100. }
  115101. if (this.chromaticAberrationEnabled) {
  115102. if (!this.chromaticAberration.isReady()) {
  115103. this.chromaticAberration.updateEffect();
  115104. }
  115105. this.addEffect(this._chromaticAberrationEffect);
  115106. this._setAutoClearAndTextureSharing(this.chromaticAberration);
  115107. }
  115108. if (this.fxaaEnabled) {
  115109. 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);
  115110. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, this.FxaaPostProcessId, function () { return _this.fxaa; }, true));
  115111. this._setAutoClearAndTextureSharing(this.fxaa, true);
  115112. }
  115113. if (this._cameras !== null) {
  115114. this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);
  115115. }
  115116. if (!this._enableMSAAOnFirstPostProcess(this.samples) && this.samples > 1) {
  115117. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
  115118. }
  115119. };
  115120. DefaultRenderingPipeline.prototype._disposePostProcesses = function (disposeNonRecreated) {
  115121. if (disposeNonRecreated === void 0) { disposeNonRecreated = false; }
  115122. for (var i = 0; i < this._cameras.length; i++) {
  115123. var camera = this._cameras[i];
  115124. if (this.imageProcessing) {
  115125. this.imageProcessing.dispose(camera);
  115126. }
  115127. if (this.fxaa) {
  115128. this.fxaa.dispose(camera);
  115129. }
  115130. // These are created in the constructor and should not be disposed on every pipeline change
  115131. if (disposeNonRecreated) {
  115132. if (this.sharpen) {
  115133. this.sharpen.dispose(camera);
  115134. }
  115135. if (this.depthOfField) {
  115136. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  115137. this.depthOfField.disposeEffects(camera);
  115138. }
  115139. if (this.bloom) {
  115140. this.bloom.disposeEffects(camera);
  115141. }
  115142. if (this.chromaticAberration) {
  115143. this.chromaticAberration.dispose(camera);
  115144. }
  115145. if (this.grain) {
  115146. this.grain.dispose(camera);
  115147. }
  115148. if (this._glowLayer) {
  115149. this._glowLayer.dispose();
  115150. }
  115151. }
  115152. }
  115153. this.imageProcessing = null;
  115154. this.fxaa = null;
  115155. if (disposeNonRecreated) {
  115156. this.sharpen = null;
  115157. this._sharpenEffect = null;
  115158. this.depthOfField = null;
  115159. this.bloom = null;
  115160. this.chromaticAberration = null;
  115161. this._chromaticAberrationEffect = null;
  115162. this.grain = null;
  115163. this._grainEffect = null;
  115164. this._glowLayer = null;
  115165. }
  115166. };
  115167. /**
  115168. * Adds a camera to the pipeline
  115169. * @param camera the camera to be added
  115170. */
  115171. DefaultRenderingPipeline.prototype.addCamera = function (camera) {
  115172. this._camerasToBeAttached.push(camera);
  115173. this._buildPipeline();
  115174. };
  115175. /**
  115176. * Removes a camera from the pipeline
  115177. * @param camera the camera to remove
  115178. */
  115179. DefaultRenderingPipeline.prototype.removeCamera = function (camera) {
  115180. var index = this._camerasToBeAttached.indexOf(camera);
  115181. this._camerasToBeAttached.splice(index, 1);
  115182. this._buildPipeline();
  115183. };
  115184. /**
  115185. * Dispose of the pipeline and stop all post processes
  115186. */
  115187. DefaultRenderingPipeline.prototype.dispose = function () {
  115188. this._disposePostProcesses(true);
  115189. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  115190. this._scene.autoClear = true;
  115191. if (this._resizeObserver) {
  115192. this._scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  115193. this._resizeObserver = null;
  115194. }
  115195. this._scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigurationObserver);
  115196. _super.prototype.dispose.call(this);
  115197. };
  115198. /**
  115199. * Serialize the rendering pipeline (Used when exporting)
  115200. * @returns the serialized object
  115201. */
  115202. DefaultRenderingPipeline.prototype.serialize = function () {
  115203. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  115204. serializationObject.customType = "DefaultRenderingPipeline";
  115205. return serializationObject;
  115206. };
  115207. /**
  115208. * Parse the serialized pipeline
  115209. * @param source Source pipeline.
  115210. * @param scene The scene to load the pipeline to.
  115211. * @param rootUrl The URL of the serialized pipeline.
  115212. * @returns An instantiated pipeline from the serialized object.
  115213. */
  115214. DefaultRenderingPipeline.Parse = function (source, scene, rootUrl) {
  115215. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new DefaultRenderingPipeline(source._name, source._name._hdr, scene); }, source, scene, rootUrl);
  115216. };
  115217. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115218. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115219. ], DefaultRenderingPipeline.prototype, "sharpenEnabled", null);
  115220. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115221. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115222. ], DefaultRenderingPipeline.prototype, "bloomKernel", null);
  115223. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115224. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115225. ], DefaultRenderingPipeline.prototype, "_bloomWeight", void 0);
  115226. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115227. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115228. ], DefaultRenderingPipeline.prototype, "_bloomThreshold", void 0);
  115229. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115230. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115231. ], DefaultRenderingPipeline.prototype, "_hdr", void 0);
  115232. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115233. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115234. ], DefaultRenderingPipeline.prototype, "bloomWeight", null);
  115235. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115236. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115237. ], DefaultRenderingPipeline.prototype, "bloomThreshold", null);
  115238. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115239. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115240. ], DefaultRenderingPipeline.prototype, "bloomScale", null);
  115241. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115242. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115243. ], DefaultRenderingPipeline.prototype, "bloomEnabled", null);
  115244. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115245. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115246. ], DefaultRenderingPipeline.prototype, "depthOfFieldEnabled", null);
  115247. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115248. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115249. ], DefaultRenderingPipeline.prototype, "depthOfFieldBlurLevel", null);
  115250. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115251. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115252. ], DefaultRenderingPipeline.prototype, "fxaaEnabled", null);
  115253. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115254. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115255. ], DefaultRenderingPipeline.prototype, "samples", null);
  115256. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115257. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115258. ], DefaultRenderingPipeline.prototype, "imageProcessingEnabled", null);
  115259. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115260. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115261. ], DefaultRenderingPipeline.prototype, "glowLayerEnabled", null);
  115262. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115263. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115264. ], DefaultRenderingPipeline.prototype, "chromaticAberrationEnabled", null);
  115265. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115266. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115267. ], DefaultRenderingPipeline.prototype, "grainEnabled", null);
  115268. return DefaultRenderingPipeline;
  115269. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_11__["PostProcessRenderPipeline"]));
  115270. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_15__["_TypeStore"].RegisteredTypes["BABYLON.DefaultRenderingPipeline"] = DefaultRenderingPipeline;
  115271. /***/ }),
  115272. /***/ "./PostProcesses/RenderPipeline/Pipelines/index.ts":
  115273. /*!*********************************************************!*\
  115274. !*** ./PostProcesses/RenderPipeline/Pipelines/index.ts ***!
  115275. \*********************************************************/
  115276. /*! exports provided: DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  115277. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115278. "use strict";
  115279. __webpack_require__.r(__webpack_exports__);
  115280. /* harmony import */ var _defaultRenderingPipeline__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defaultRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts");
  115281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _defaultRenderingPipeline__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  115282. /* harmony import */ var _lensRenderingPipeline__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lensRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts");
  115283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _lensRenderingPipeline__WEBPACK_IMPORTED_MODULE_1__["LensRenderingPipeline"]; });
  115284. /* harmony import */ var _ssao2RenderingPipeline__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ssao2RenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts");
  115285. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _ssao2RenderingPipeline__WEBPACK_IMPORTED_MODULE_2__["SSAO2RenderingPipeline"]; });
  115286. /* harmony import */ var _ssaoRenderingPipeline__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ssaoRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts");
  115287. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _ssaoRenderingPipeline__WEBPACK_IMPORTED_MODULE_3__["SSAORenderingPipeline"]; });
  115288. /* harmony import */ var _standardRenderingPipeline__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./standardRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts");
  115289. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _standardRenderingPipeline__WEBPACK_IMPORTED_MODULE_4__["StandardRenderingPipeline"]; });
  115290. /***/ }),
  115291. /***/ "./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts":
  115292. /*!*************************************************************************!*\
  115293. !*** ./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts ***!
  115294. \*************************************************************************/
  115295. /*! exports provided: LensRenderingPipeline */
  115296. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115297. "use strict";
  115298. __webpack_require__.r(__webpack_exports__);
  115299. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return LensRenderingPipeline; });
  115300. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115301. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  115302. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  115303. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  115304. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  115305. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  115306. /* harmony import */ var _Shaders_chromaticAberration_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../Shaders/chromaticAberration.fragment */ "./Shaders/chromaticAberration.fragment.ts");
  115307. /* harmony import */ var _Shaders_lensHighlights_fragment__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../Shaders/lensHighlights.fragment */ "./Shaders/lensHighlights.fragment.ts");
  115308. /* harmony import */ var _Shaders_depthOfField_fragment__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../Shaders/depthOfField.fragment */ "./Shaders/depthOfField.fragment.ts");
  115309. /**
  115310. * BABYLON.JS Chromatic Aberration GLSL Shader
  115311. * Author: Olivier Guyot
  115312. * Separates very slightly R, G and B colors on the edges of the screen
  115313. * Inspired by Francois Tarlier & Martins Upitis
  115314. */
  115315. var LensRenderingPipeline = /** @class */ (function (_super) {
  115316. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LensRenderingPipeline, _super);
  115317. /**
  115318. * @constructor
  115319. *
  115320. * Effect parameters are as follow:
  115321. * {
  115322. * chromatic_aberration: number; // from 0 to x (1 for realism)
  115323. * edge_blur: number; // from 0 to x (1 for realism)
  115324. * distortion: number; // from 0 to x (1 for realism)
  115325. * grain_amount: number; // from 0 to 1
  115326. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  115327. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  115328. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  115329. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  115330. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  115331. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  115332. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  115333. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  115334. * }
  115335. * Note: if an effect parameter is unset, effect is disabled
  115336. *
  115337. * @param name The rendering pipeline name
  115338. * @param parameters - An object containing all parameters (see above)
  115339. * @param scene The scene linked to this pipeline
  115340. * @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)
  115341. * @param cameras The array of cameras that the rendering pipeline will be attached to
  115342. */
  115343. function LensRenderingPipeline(name, parameters, scene, ratio, cameras) {
  115344. if (ratio === void 0) { ratio = 1.0; }
  115345. var _this = _super.call(this, scene.getEngine(), name) || this;
  115346. // Lens effects can be of the following:
  115347. // - chromatic aberration (slight shift of RGB colors)
  115348. // - blur on the edge of the lens
  115349. // - lens distortion
  115350. // - depth-of-field blur & highlights enhancing
  115351. // - depth-of-field 'bokeh' effect (shapes appearing in blurred areas)
  115352. // - grain effect (noise or custom texture)
  115353. // Two additional texture samplers are needed:
  115354. // - depth map (for depth-of-field)
  115355. // - grain texture
  115356. /**
  115357. * @ignore
  115358. * The chromatic aberration PostProcess id in the pipeline
  115359. */
  115360. _this.LensChromaticAberrationEffect = "LensChromaticAberrationEffect";
  115361. /**
  115362. * @ignore
  115363. * The highlights enhancing PostProcess id in the pipeline
  115364. */
  115365. _this.HighlightsEnhancingEffect = "HighlightsEnhancingEffect";
  115366. /**
  115367. * @ignore
  115368. * The depth-of-field PostProcess id in the pipeline
  115369. */
  115370. _this.LensDepthOfFieldEffect = "LensDepthOfFieldEffect";
  115371. _this._scene = scene;
  115372. // Fetch texture samplers
  115373. _this._depthTexture = scene.enableDepthRenderer().getDepthMap(); // Force depth renderer "on"
  115374. if (parameters.grain_texture) {
  115375. _this._grainTexture = parameters.grain_texture;
  115376. }
  115377. else {
  115378. _this._createGrainTexture();
  115379. }
  115380. // save parameters
  115381. _this._edgeBlur = parameters.edge_blur ? parameters.edge_blur : 0;
  115382. _this._grainAmount = parameters.grain_amount ? parameters.grain_amount : 0;
  115383. _this._chromaticAberration = parameters.chromatic_aberration ? parameters.chromatic_aberration : 0;
  115384. _this._distortion = parameters.distortion ? parameters.distortion : 0;
  115385. _this._highlightsGain = parameters.dof_gain !== undefined ? parameters.dof_gain : -1;
  115386. _this._highlightsThreshold = parameters.dof_threshold ? parameters.dof_threshold : 1;
  115387. _this._dofDistance = parameters.dof_focus_distance !== undefined ? parameters.dof_focus_distance : -1;
  115388. _this._dofAperture = parameters.dof_aperture ? parameters.dof_aperture : 1;
  115389. _this._dofDarken = parameters.dof_darken ? parameters.dof_darken : 0;
  115390. _this._dofPentagon = parameters.dof_pentagon !== undefined ? parameters.dof_pentagon : true;
  115391. _this._blurNoise = parameters.blur_noise !== undefined ? parameters.blur_noise : true;
  115392. // Create effects
  115393. _this._createChromaticAberrationPostProcess(ratio);
  115394. _this._createHighlightsPostProcess(ratio);
  115395. _this._createDepthOfFieldPostProcess(ratio / 4);
  115396. // Set up pipeline
  115397. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.LensChromaticAberrationEffect, function () { return _this._chromaticAberrationPostProcess; }, true));
  115398. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.HighlightsEnhancingEffect, function () { return _this._highlightsPostProcess; }, true));
  115399. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.LensDepthOfFieldEffect, function () { return _this._depthOfFieldPostProcess; }, true));
  115400. if (_this._highlightsGain === -1) {
  115401. _this._disableEffect(_this.HighlightsEnhancingEffect, null);
  115402. }
  115403. // Finish
  115404. scene.postProcessRenderPipelineManager.addPipeline(_this);
  115405. if (cameras) {
  115406. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  115407. }
  115408. return _this;
  115409. }
  115410. // public methods (self explanatory)
  115411. /**
  115412. * Sets the amount of blur at the edges
  115413. * @param amount blur amount
  115414. */
  115415. LensRenderingPipeline.prototype.setEdgeBlur = function (amount) { this._edgeBlur = amount; };
  115416. /**
  115417. * Sets edge blur to 0
  115418. */
  115419. LensRenderingPipeline.prototype.disableEdgeBlur = function () { this._edgeBlur = 0; };
  115420. /**
  115421. * Sets the amout of grain
  115422. * @param amount Amount of grain
  115423. */
  115424. LensRenderingPipeline.prototype.setGrainAmount = function (amount) { this._grainAmount = amount; };
  115425. /**
  115426. * Set grain amount to 0
  115427. */
  115428. LensRenderingPipeline.prototype.disableGrain = function () { this._grainAmount = 0; };
  115429. /**
  115430. * Sets the chromatic aberration amount
  115431. * @param amount amount of chromatic aberration
  115432. */
  115433. LensRenderingPipeline.prototype.setChromaticAberration = function (amount) { this._chromaticAberration = amount; };
  115434. /**
  115435. * Sets chromatic aberration amount to 0
  115436. */
  115437. LensRenderingPipeline.prototype.disableChromaticAberration = function () { this._chromaticAberration = 0; };
  115438. /**
  115439. * Sets the EdgeDistortion amount
  115440. * @param amount amount of EdgeDistortion
  115441. */
  115442. LensRenderingPipeline.prototype.setEdgeDistortion = function (amount) { this._distortion = amount; };
  115443. /**
  115444. * Sets edge distortion to 0
  115445. */
  115446. LensRenderingPipeline.prototype.disableEdgeDistortion = function () { this._distortion = 0; };
  115447. /**
  115448. * Sets the FocusDistance amount
  115449. * @param amount amount of FocusDistance
  115450. */
  115451. LensRenderingPipeline.prototype.setFocusDistance = function (amount) { this._dofDistance = amount; };
  115452. /**
  115453. * Disables depth of field
  115454. */
  115455. LensRenderingPipeline.prototype.disableDepthOfField = function () { this._dofDistance = -1; };
  115456. /**
  115457. * Sets the Aperture amount
  115458. * @param amount amount of Aperture
  115459. */
  115460. LensRenderingPipeline.prototype.setAperture = function (amount) { this._dofAperture = amount; };
  115461. /**
  115462. * Sets the DarkenOutOfFocus amount
  115463. * @param amount amount of DarkenOutOfFocus
  115464. */
  115465. LensRenderingPipeline.prototype.setDarkenOutOfFocus = function (amount) { this._dofDarken = amount; };
  115466. /**
  115467. * Creates a pentagon bokeh effect
  115468. */
  115469. LensRenderingPipeline.prototype.enablePentagonBokeh = function () {
  115470. this._highlightsPostProcess.updateEffect("#define PENTAGON\n");
  115471. };
  115472. /**
  115473. * Disables the pentagon bokeh effect
  115474. */
  115475. LensRenderingPipeline.prototype.disablePentagonBokeh = function () {
  115476. this._highlightsPostProcess.updateEffect();
  115477. };
  115478. /**
  115479. * Enables noise blur
  115480. */
  115481. LensRenderingPipeline.prototype.enableNoiseBlur = function () { this._blurNoise = true; };
  115482. /**
  115483. * Disables noise blur
  115484. */
  115485. LensRenderingPipeline.prototype.disableNoiseBlur = function () { this._blurNoise = false; };
  115486. /**
  115487. * Sets the HighlightsGain amount
  115488. * @param amount amount of HighlightsGain
  115489. */
  115490. LensRenderingPipeline.prototype.setHighlightsGain = function (amount) {
  115491. this._highlightsGain = amount;
  115492. };
  115493. /**
  115494. * Sets the HighlightsThreshold amount
  115495. * @param amount amount of HighlightsThreshold
  115496. */
  115497. LensRenderingPipeline.prototype.setHighlightsThreshold = function (amount) {
  115498. if (this._highlightsGain === -1) {
  115499. this._highlightsGain = 1.0;
  115500. }
  115501. this._highlightsThreshold = amount;
  115502. };
  115503. /**
  115504. * Disables highlights
  115505. */
  115506. LensRenderingPipeline.prototype.disableHighlights = function () {
  115507. this._highlightsGain = -1;
  115508. };
  115509. /**
  115510. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  115511. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  115512. */
  115513. LensRenderingPipeline.prototype.dispose = function (disableDepthRender) {
  115514. if (disableDepthRender === void 0) { disableDepthRender = false; }
  115515. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  115516. this._chromaticAberrationPostProcess = null;
  115517. this._highlightsPostProcess = null;
  115518. this._depthOfFieldPostProcess = null;
  115519. this._grainTexture.dispose();
  115520. if (disableDepthRender) {
  115521. this._scene.disableDepthRenderer();
  115522. }
  115523. };
  115524. // colors shifting and distortion
  115525. LensRenderingPipeline.prototype._createChromaticAberrationPostProcess = function (ratio) {
  115526. var _this = this;
  115527. this._chromaticAberrationPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensChromaticAberration", "chromaticAberration", ["chromatic_aberration", "screen_width", "screen_height", "direction", "radialIntensity", "centerPosition"], // uniforms
  115528. [], // samplers
  115529. ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);
  115530. this._chromaticAberrationPostProcess.onApply = function (effect) {
  115531. effect.setFloat('chromatic_aberration', _this._chromaticAberration);
  115532. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  115533. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  115534. effect.setFloat('radialIntensity', 1);
  115535. effect.setFloat2('direction', 17, 17);
  115536. effect.setFloat2('centerPosition', 0.5, 0.5);
  115537. };
  115538. };
  115539. // highlights enhancing
  115540. LensRenderingPipeline.prototype._createHighlightsPostProcess = function (ratio) {
  115541. var _this = this;
  115542. this._highlightsPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensHighlights", "lensHighlights", ["gain", "threshold", "screen_width", "screen_height"], // uniforms
  115543. [], // samplers
  115544. ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, this._dofPentagon ? "#define PENTAGON\n" : "");
  115545. this._highlightsPostProcess.onApply = function (effect) {
  115546. effect.setFloat('gain', _this._highlightsGain);
  115547. effect.setFloat('threshold', _this._highlightsThreshold);
  115548. effect.setTextureFromPostProcess("textureSampler", _this._chromaticAberrationPostProcess);
  115549. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  115550. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  115551. };
  115552. };
  115553. // colors shifting and distortion
  115554. LensRenderingPipeline.prototype._createDepthOfFieldPostProcess = function (ratio) {
  115555. var _this = this;
  115556. this._depthOfFieldPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensDepthOfField", "depthOfField", [
  115557. "grain_amount", "blur_noise", "screen_width", "screen_height", "distortion", "dof_enabled",
  115558. "screen_distance", "aperture", "darken", "edge_blur", "highlights", "near", "far"
  115559. ], ["depthSampler", "grainSampler", "highlightsSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);
  115560. this._depthOfFieldPostProcess.onApply = function (effect) {
  115561. effect.setTexture("depthSampler", _this._depthTexture);
  115562. effect.setTexture("grainSampler", _this._grainTexture);
  115563. effect.setTextureFromPostProcess("textureSampler", _this._highlightsPostProcess);
  115564. effect.setTextureFromPostProcess("highlightsSampler", _this._depthOfFieldPostProcess);
  115565. effect.setFloat('grain_amount', _this._grainAmount);
  115566. effect.setBool('blur_noise', _this._blurNoise);
  115567. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  115568. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  115569. effect.setFloat('distortion', _this._distortion);
  115570. effect.setBool('dof_enabled', (_this._dofDistance !== -1));
  115571. effect.setFloat('screen_distance', 1.0 / (0.1 - 1.0 / _this._dofDistance));
  115572. effect.setFloat('aperture', _this._dofAperture);
  115573. effect.setFloat('darken', _this._dofDarken);
  115574. effect.setFloat('edge_blur', _this._edgeBlur);
  115575. effect.setBool('highlights', (_this._highlightsGain !== -1));
  115576. if (_this._scene.activeCamera) {
  115577. effect.setFloat('near', _this._scene.activeCamera.minZ);
  115578. effect.setFloat('far', _this._scene.activeCamera.maxZ);
  115579. }
  115580. };
  115581. };
  115582. // creates a black and white random noise texture, 512x512
  115583. LensRenderingPipeline.prototype._createGrainTexture = function () {
  115584. var size = 512;
  115585. 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);
  115586. this._grainTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].WRAP_ADDRESSMODE;
  115587. this._grainTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].WRAP_ADDRESSMODE;
  115588. var context = this._grainTexture.getContext();
  115589. var rand = function (min, max) {
  115590. return Math.random() * (max - min) + min;
  115591. };
  115592. var value;
  115593. for (var x = 0; x < size; x++) {
  115594. for (var y = 0; y < size; y++) {
  115595. value = Math.floor(rand(0.42, 0.58) * 255);
  115596. context.fillStyle = 'rgb(' + value + ', ' + value + ', ' + value + ')';
  115597. context.fillRect(x, y, 1, 1);
  115598. }
  115599. }
  115600. this._grainTexture.update(false);
  115601. };
  115602. return LensRenderingPipeline;
  115603. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_4__["PostProcessRenderPipeline"]));
  115604. /***/ }),
  115605. /***/ "./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts":
  115606. /*!**************************************************************************!*\
  115607. !*** ./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts ***!
  115608. \**************************************************************************/
  115609. /*! exports provided: SSAO2RenderingPipeline */
  115610. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115611. "use strict";
  115612. __webpack_require__.r(__webpack_exports__);
  115613. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return SSAO2RenderingPipeline; });
  115614. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115615. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  115616. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  115617. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  115618. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  115619. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  115620. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  115621. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  115622. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  115623. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  115624. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  115625. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  115626. /* harmony import */ var _Shaders_ssao2_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Shaders/ssao2.fragment */ "./Shaders/ssao2.fragment.ts");
  115627. /* harmony import */ var _Shaders_ssaoCombine_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../Shaders/ssaoCombine.fragment */ "./Shaders/ssaoCombine.fragment.ts");
  115628. /**
  115629. * Render pipeline to produce ssao effect
  115630. */
  115631. var SSAO2RenderingPipeline = /** @class */ (function (_super) {
  115632. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SSAO2RenderingPipeline, _super);
  115633. /**
  115634. * @constructor
  115635. * @param name The rendering pipeline name
  115636. * @param scene The scene linked to this pipeline
  115637. * @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 }
  115638. * @param cameras The array of cameras that the rendering pipeline will be attached to
  115639. */
  115640. function SSAO2RenderingPipeline(name, scene, ratio, cameras) {
  115641. var _this = _super.call(this, scene.getEngine(), name) || this;
  115642. // Members
  115643. /**
  115644. * @ignore
  115645. * The PassPostProcess id in the pipeline that contains the original scene color
  115646. */
  115647. _this.SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect";
  115648. /**
  115649. * @ignore
  115650. * The SSAO PostProcess id in the pipeline
  115651. */
  115652. _this.SSAORenderEffect = "SSAORenderEffect";
  115653. /**
  115654. * @ignore
  115655. * The horizontal blur PostProcess id in the pipeline
  115656. */
  115657. _this.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect";
  115658. /**
  115659. * @ignore
  115660. * The vertical blur PostProcess id in the pipeline
  115661. */
  115662. _this.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect";
  115663. /**
  115664. * @ignore
  115665. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  115666. */
  115667. _this.SSAOCombineRenderEffect = "SSAOCombineRenderEffect";
  115668. /**
  115669. * The output strength of the SSAO post-process. Default value is 1.0.
  115670. */
  115671. _this.totalStrength = 1.0;
  115672. /**
  115673. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  115674. */
  115675. _this.maxZ = 100.0;
  115676. /**
  115677. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  115678. */
  115679. _this.minZAspect = 0.2;
  115680. _this._samples = 8;
  115681. _this._textureSamples = 1;
  115682. _this._expensiveBlur = true;
  115683. /**
  115684. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  115685. */
  115686. _this.radius = 2.0;
  115687. /**
  115688. * The base color of the SSAO post-process
  115689. * The final result is "base + ssao" between [0, 1]
  115690. */
  115691. _this.base = 0;
  115692. _this._firstUpdate = true;
  115693. _this._bits = new Uint32Array(1);
  115694. _this._scene = scene;
  115695. _this._ratio = ratio;
  115696. if (!_this.isSupported) {
  115697. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("SSAO 2 needs WebGL 2 support.");
  115698. return _this;
  115699. }
  115700. var ssaoRatio = _this._ratio.ssaoRatio || ratio;
  115701. var blurRatio = _this._ratio.blurRatio || ratio;
  115702. // Set up assets
  115703. var geometryBufferRenderer = scene.enableGeometryBufferRenderer();
  115704. _this._createRandomTexture();
  115705. _this._depthTexture = geometryBufferRenderer.getGBuffer().textures[0];
  115706. _this._normalTexture = geometryBufferRenderer.getGBuffer().textures[1];
  115707. _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);
  115708. _this._originalColorPostProcess.samples = _this.textureSamples;
  115709. _this._createSSAOPostProcess(1.0);
  115710. _this._createBlurPostProcess(ssaoRatio, blurRatio);
  115711. _this._createSSAOCombinePostProcess(blurRatio);
  115712. // Set up pipeline
  115713. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOOriginalSceneColorEffect, function () { return _this._originalColorPostProcess; }, true));
  115714. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAORenderEffect, function () { return _this._ssaoPostProcess; }, true));
  115715. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurHRenderEffect, function () { return _this._blurHPostProcess; }, true));
  115716. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurVRenderEffect, function () { return _this._blurVPostProcess; }, true));
  115717. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOCombineRenderEffect, function () { return _this._ssaoCombinePostProcess; }, true));
  115718. // Finish
  115719. scene.postProcessRenderPipelineManager.addPipeline(_this);
  115720. if (cameras) {
  115721. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  115722. }
  115723. return _this;
  115724. }
  115725. Object.defineProperty(SSAO2RenderingPipeline.prototype, "samples", {
  115726. get: function () {
  115727. return this._samples;
  115728. },
  115729. /**
  115730. * Number of samples used for the SSAO calculations. Default value is 8
  115731. */
  115732. set: function (n) {
  115733. this._ssaoPostProcess.updateEffect("#define SAMPLES " + n + "\n#define SSAO");
  115734. this._samples = n;
  115735. this._sampleSphere = this._generateHemisphere();
  115736. this._firstUpdate = true;
  115737. },
  115738. enumerable: true,
  115739. configurable: true
  115740. });
  115741. Object.defineProperty(SSAO2RenderingPipeline.prototype, "textureSamples", {
  115742. get: function () {
  115743. return this._textureSamples;
  115744. },
  115745. /**
  115746. * Number of samples to use for antialiasing
  115747. */
  115748. set: function (n) {
  115749. this._textureSamples = n;
  115750. this._originalColorPostProcess.samples = n;
  115751. this._blurHPostProcess.samples = n;
  115752. this._blurVPostProcess.samples = n;
  115753. this._ssaoPostProcess.samples = n;
  115754. this._ssaoCombinePostProcess.samples = n;
  115755. },
  115756. enumerable: true,
  115757. configurable: true
  115758. });
  115759. Object.defineProperty(SSAO2RenderingPipeline.prototype, "expensiveBlur", {
  115760. get: function () {
  115761. return this._expensiveBlur;
  115762. },
  115763. /**
  115764. * If bilateral blur should be used
  115765. */
  115766. set: function (b) {
  115767. 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"]);
  115768. this._blurVPostProcess.updateEffect("#define BILATERAL_BLUR\n#define SAMPLES 16\n#define EXPENSIVE " + (b ? "1" : "0") + "\n", null, ["textureSampler", "depthSampler"]);
  115769. this._expensiveBlur = b;
  115770. this._firstUpdate = true;
  115771. },
  115772. enumerable: true,
  115773. configurable: true
  115774. });
  115775. Object.defineProperty(SSAO2RenderingPipeline, "IsSupported", {
  115776. /**
  115777. * Support test.
  115778. */
  115779. get: function () {
  115780. var engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_11__["EngineStore"].LastCreatedEngine;
  115781. if (!engine) {
  115782. return false;
  115783. }
  115784. return engine.getCaps().drawBuffersExtension;
  115785. },
  115786. enumerable: true,
  115787. configurable: true
  115788. });
  115789. Object.defineProperty(SSAO2RenderingPipeline.prototype, "scene", {
  115790. /**
  115791. * Gets active scene
  115792. */
  115793. get: function () {
  115794. return this._scene;
  115795. },
  115796. enumerable: true,
  115797. configurable: true
  115798. });
  115799. // Public Methods
  115800. /**
  115801. * Get the class name
  115802. * @returns "SSAO2RenderingPipeline"
  115803. */
  115804. SSAO2RenderingPipeline.prototype.getClassName = function () {
  115805. return "SSAO2RenderingPipeline";
  115806. };
  115807. /**
  115808. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  115809. */
  115810. SSAO2RenderingPipeline.prototype.dispose = function (disableGeometryBufferRenderer) {
  115811. if (disableGeometryBufferRenderer === void 0) { disableGeometryBufferRenderer = false; }
  115812. for (var i = 0; i < this._scene.cameras.length; i++) {
  115813. var camera = this._scene.cameras[i];
  115814. this._originalColorPostProcess.dispose(camera);
  115815. this._ssaoPostProcess.dispose(camera);
  115816. this._blurHPostProcess.dispose(camera);
  115817. this._blurVPostProcess.dispose(camera);
  115818. this._ssaoCombinePostProcess.dispose(camera);
  115819. }
  115820. this._randomTexture.dispose();
  115821. if (disableGeometryBufferRenderer) {
  115822. this._scene.disableGeometryBufferRenderer();
  115823. }
  115824. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  115825. _super.prototype.dispose.call(this);
  115826. };
  115827. // Private Methods
  115828. SSAO2RenderingPipeline.prototype._createBlurPostProcess = function (ssaoRatio, blurRatio) {
  115829. var _this = this;
  115830. this._samplerOffsets = [];
  115831. var expensive = this.expensiveBlur;
  115832. for (var i = -8; i < 8; i++) {
  115833. this._samplerOffsets.push(i * 2 + 0.5);
  115834. }
  115835. 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");
  115836. this._blurHPostProcess.onApply = function (effect) {
  115837. if (!_this._scene.activeCamera) {
  115838. return;
  115839. }
  115840. effect.setFloat("outSize", _this._ssaoCombinePostProcess.width > 0 ? _this._ssaoCombinePostProcess.width : _this._originalColorPostProcess.width);
  115841. effect.setFloat("near", _this._scene.activeCamera.minZ);
  115842. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  115843. effect.setFloat("radius", _this.radius);
  115844. effect.setTexture("depthSampler", _this._depthTexture);
  115845. if (_this._firstUpdate) {
  115846. effect.setArray("samplerOffsets", _this._samplerOffsets);
  115847. }
  115848. };
  115849. 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");
  115850. this._blurVPostProcess.onApply = function (effect) {
  115851. if (!_this._scene.activeCamera) {
  115852. return;
  115853. }
  115854. effect.setFloat("outSize", _this._ssaoCombinePostProcess.height > 0 ? _this._ssaoCombinePostProcess.height : _this._originalColorPostProcess.height);
  115855. effect.setFloat("near", _this._scene.activeCamera.minZ);
  115856. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  115857. effect.setFloat("radius", _this.radius);
  115858. effect.setTexture("depthSampler", _this._depthTexture);
  115859. if (_this._firstUpdate) {
  115860. effect.setArray("samplerOffsets", _this._samplerOffsets);
  115861. _this._firstUpdate = false;
  115862. }
  115863. };
  115864. this._blurHPostProcess.samples = this.textureSamples;
  115865. this._blurVPostProcess.samples = this.textureSamples;
  115866. };
  115867. /** @hidden */
  115868. SSAO2RenderingPipeline.prototype._rebuild = function () {
  115869. this._firstUpdate = true;
  115870. _super.prototype._rebuild.call(this);
  115871. };
  115872. //Van der Corput radical inverse
  115873. SSAO2RenderingPipeline.prototype._radicalInverse_VdC = function (i) {
  115874. this._bits[0] = i;
  115875. this._bits[0] = ((this._bits[0] << 16) | (this._bits[0] >> 16)) >>> 0;
  115876. this._bits[0] = ((this._bits[0] & 0x55555555) << 1) | ((this._bits[0] & 0xAAAAAAAA) >>> 1) >>> 0;
  115877. this._bits[0] = ((this._bits[0] & 0x33333333) << 2) | ((this._bits[0] & 0xCCCCCCCC) >>> 2) >>> 0;
  115878. this._bits[0] = ((this._bits[0] & 0x0F0F0F0F) << 4) | ((this._bits[0] & 0xF0F0F0F0) >>> 4) >>> 0;
  115879. this._bits[0] = ((this._bits[0] & 0x00FF00FF) << 8) | ((this._bits[0] & 0xFF00FF00) >>> 8) >>> 0;
  115880. return this._bits[0] * 2.3283064365386963e-10; // / 0x100000000 or / 4294967296
  115881. };
  115882. SSAO2RenderingPipeline.prototype._hammersley = function (i, n) {
  115883. return [i / n, this._radicalInverse_VdC(i)];
  115884. };
  115885. SSAO2RenderingPipeline.prototype._hemisphereSample_uniform = function (u, v) {
  115886. var phi = v * 2.0 * Math.PI;
  115887. // rejecting samples that are close to tangent plane to avoid z-fighting artifacts
  115888. var cosTheta = 1.0 - (u * 0.85 + 0.15);
  115889. var sinTheta = Math.sqrt(1.0 - cosTheta * cosTheta);
  115890. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.cos(phi) * sinTheta, Math.sin(phi) * sinTheta, cosTheta);
  115891. };
  115892. SSAO2RenderingPipeline.prototype._generateHemisphere = function () {
  115893. var numSamples = this.samples;
  115894. var result = [];
  115895. var vector;
  115896. var i = 0;
  115897. while (i < numSamples) {
  115898. if (numSamples < 16) {
  115899. vector = this._hemisphereSample_uniform(Math.random(), Math.random());
  115900. }
  115901. else {
  115902. var rand = this._hammersley(i, numSamples);
  115903. vector = this._hemisphereSample_uniform(rand[0], rand[1]);
  115904. }
  115905. result.push(vector.x, vector.y, vector.z);
  115906. i++;
  115907. }
  115908. return result;
  115909. };
  115910. SSAO2RenderingPipeline.prototype._createSSAOPostProcess = function (ratio) {
  115911. var _this = this;
  115912. var numSamples = this.samples;
  115913. this._sampleSphere = this._generateHemisphere();
  115914. this._ssaoPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__["PostProcess"]("ssao2", "ssao2", [
  115915. "sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius",
  115916. "base", "range", "projection", "near", "far", "texelSize",
  115917. "xViewport", "yViewport", "maxZ", "minZAspect"
  115918. ], ["randomSampler", "normalSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, "#define SAMPLES " + numSamples + "\n#define SSAO");
  115919. this._ssaoPostProcess.onApply = function (effect) {
  115920. if (_this._firstUpdate) {
  115921. effect.setArray3("sampleSphere", _this._sampleSphere);
  115922. effect.setFloat("randTextureTiles", 32.0);
  115923. }
  115924. if (!_this._scene.activeCamera) {
  115925. return;
  115926. }
  115927. effect.setFloat("samplesFactor", 1 / _this.samples);
  115928. effect.setFloat("totalStrength", _this.totalStrength);
  115929. effect.setFloat2("texelSize", 1 / _this._ssaoPostProcess.width, 1 / _this._ssaoPostProcess.height);
  115930. effect.setFloat("radius", _this.radius);
  115931. effect.setFloat("maxZ", _this.maxZ);
  115932. effect.setFloat("minZAspect", _this.minZAspect);
  115933. effect.setFloat("base", _this.base);
  115934. effect.setFloat("near", _this._scene.activeCamera.minZ);
  115935. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  115936. effect.setFloat("xViewport", Math.tan(_this._scene.activeCamera.fov / 2) * _this._scene.getEngine().getAspectRatio(_this._scene.activeCamera, true));
  115937. effect.setFloat("yViewport", Math.tan(_this._scene.activeCamera.fov / 2));
  115938. effect.setMatrix("projection", _this._scene.getProjectionMatrix());
  115939. effect.setTexture("textureSampler", _this._depthTexture);
  115940. effect.setTexture("normalSampler", _this._normalTexture);
  115941. effect.setTexture("randomSampler", _this._randomTexture);
  115942. };
  115943. this._ssaoPostProcess.samples = this.textureSamples;
  115944. };
  115945. SSAO2RenderingPipeline.prototype._createSSAOCombinePostProcess = function (ratio) {
  115946. var _this = this;
  115947. 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);
  115948. this._ssaoCombinePostProcess.onApply = function (effect) {
  115949. var viewport = _this._scene.activeCamera.viewport;
  115950. effect.setVector4("viewport", _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector4[0].copyFromFloats(viewport.x, viewport.y, viewport.width, viewport.height));
  115951. effect.setTextureFromPostProcess("originalColor", _this._originalColorPostProcess);
  115952. };
  115953. this._ssaoCombinePostProcess.samples = this.textureSamples;
  115954. };
  115955. SSAO2RenderingPipeline.prototype._createRandomTexture = function () {
  115956. var size = 128;
  115957. 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);
  115958. this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  115959. this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  115960. var context = this._randomTexture.getContext();
  115961. var rand = function (min, max) {
  115962. return Math.random() * (max - min) + min;
  115963. };
  115964. var randVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  115965. for (var x = 0; x < size; x++) {
  115966. for (var y = 0; y < size; y++) {
  115967. randVector.x = rand(0.0, 1.0);
  115968. randVector.y = rand(0.0, 1.0);
  115969. randVector.z = 0.0;
  115970. randVector.normalize();
  115971. randVector.scaleInPlace(255);
  115972. randVector.x = Math.floor(randVector.x);
  115973. randVector.y = Math.floor(randVector.y);
  115974. context.fillStyle = 'rgb(' + randVector.x + ', ' + randVector.y + ', ' + randVector.z + ')';
  115975. context.fillRect(x, y, 1, 1);
  115976. }
  115977. }
  115978. this._randomTexture.update(false);
  115979. };
  115980. /**
  115981. * Serialize the rendering pipeline (Used when exporting)
  115982. * @returns the serialized object
  115983. */
  115984. SSAO2RenderingPipeline.prototype.serialize = function () {
  115985. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].Serialize(this);
  115986. serializationObject.customType = "SSAO2RenderingPipeline";
  115987. return serializationObject;
  115988. };
  115989. /**
  115990. * Parse the serialized pipeline
  115991. * @param source Source pipeline.
  115992. * @param scene The scene to load the pipeline to.
  115993. * @param rootUrl The URL of the serialized pipeline.
  115994. * @returns An instantiated pipeline from the serialized object.
  115995. */
  115996. SSAO2RenderingPipeline.Parse = function (source, scene, rootUrl) {
  115997. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].Parse(function () { return new SSAO2RenderingPipeline(source._name, scene, source._ratio); }, source, scene, rootUrl);
  115998. };
  115999. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116000. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  116001. ], SSAO2RenderingPipeline.prototype, "totalStrength", void 0);
  116002. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116003. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  116004. ], SSAO2RenderingPipeline.prototype, "maxZ", void 0);
  116005. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116006. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  116007. ], SSAO2RenderingPipeline.prototype, "minZAspect", void 0);
  116008. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116009. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("samples")
  116010. ], SSAO2RenderingPipeline.prototype, "_samples", void 0);
  116011. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116012. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("textureSamples")
  116013. ], SSAO2RenderingPipeline.prototype, "_textureSamples", void 0);
  116014. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116015. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  116016. ], SSAO2RenderingPipeline.prototype, "_ratio", void 0);
  116017. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116018. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("expensiveBlur")
  116019. ], SSAO2RenderingPipeline.prototype, "_expensiveBlur", void 0);
  116020. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116021. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  116022. ], SSAO2RenderingPipeline.prototype, "radius", void 0);
  116023. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116024. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  116025. ], SSAO2RenderingPipeline.prototype, "base", void 0);
  116026. return SSAO2RenderingPipeline;
  116027. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__["PostProcessRenderPipeline"]));
  116028. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_10__["_TypeStore"].RegisteredTypes["BABYLON.SSAO2RenderingPipeline"] = SSAO2RenderingPipeline;
  116029. /***/ }),
  116030. /***/ "./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts":
  116031. /*!*************************************************************************!*\
  116032. !*** ./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts ***!
  116033. \*************************************************************************/
  116034. /*! exports provided: SSAORenderingPipeline */
  116035. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116036. "use strict";
  116037. __webpack_require__.r(__webpack_exports__);
  116038. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return SSAORenderingPipeline; });
  116039. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116040. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  116041. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  116042. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  116043. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  116044. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  116045. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  116046. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  116047. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  116048. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  116049. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  116050. /* harmony import */ var _Shaders_ssao_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Shaders/ssao.fragment */ "./Shaders/ssao.fragment.ts");
  116051. /* harmony import */ var _Shaders_ssaoCombine_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Shaders/ssaoCombine.fragment */ "./Shaders/ssaoCombine.fragment.ts");
  116052. /**
  116053. * Render pipeline to produce ssao effect
  116054. */
  116055. var SSAORenderingPipeline = /** @class */ (function (_super) {
  116056. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SSAORenderingPipeline, _super);
  116057. /**
  116058. * @constructor
  116059. * @param name - The rendering pipeline name
  116060. * @param scene - The scene linked to this pipeline
  116061. * @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 }
  116062. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  116063. */
  116064. function SSAORenderingPipeline(name, scene, ratio, cameras) {
  116065. var _this = _super.call(this, scene.getEngine(), name) || this;
  116066. // Members
  116067. /**
  116068. * @ignore
  116069. * The PassPostProcess id in the pipeline that contains the original scene color
  116070. */
  116071. _this.SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect";
  116072. /**
  116073. * @ignore
  116074. * The SSAO PostProcess id in the pipeline
  116075. */
  116076. _this.SSAORenderEffect = "SSAORenderEffect";
  116077. /**
  116078. * @ignore
  116079. * The horizontal blur PostProcess id in the pipeline
  116080. */
  116081. _this.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect";
  116082. /**
  116083. * @ignore
  116084. * The vertical blur PostProcess id in the pipeline
  116085. */
  116086. _this.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect";
  116087. /**
  116088. * @ignore
  116089. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  116090. */
  116091. _this.SSAOCombineRenderEffect = "SSAOCombineRenderEffect";
  116092. /**
  116093. * The output strength of the SSAO post-process. Default value is 1.0.
  116094. */
  116095. _this.totalStrength = 1.0;
  116096. /**
  116097. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  116098. */
  116099. _this.radius = 0.0001;
  116100. /**
  116101. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  116102. * Must not be equal to fallOff and superior to fallOff.
  116103. * Default value is 0.0075
  116104. */
  116105. _this.area = 0.0075;
  116106. /**
  116107. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  116108. * Must not be equal to area and inferior to area.
  116109. * Default value is 0.000001
  116110. */
  116111. _this.fallOff = 0.000001;
  116112. /**
  116113. * The base color of the SSAO post-process
  116114. * The final result is "base + ssao" between [0, 1]
  116115. */
  116116. _this.base = 0.5;
  116117. _this._firstUpdate = true;
  116118. _this._scene = scene;
  116119. // Set up assets
  116120. _this._createRandomTexture();
  116121. _this._depthTexture = scene.enableDepthRenderer().getDepthMap(); // Force depth renderer "on"
  116122. var ssaoRatio = ratio.ssaoRatio || ratio;
  116123. var combineRatio = ratio.combineRatio || ratio;
  116124. _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);
  116125. _this._createSSAOPostProcess(ssaoRatio);
  116126. _this._createBlurPostProcess(ssaoRatio);
  116127. _this._createSSAOCombinePostProcess(combineRatio);
  116128. // Set up pipeline
  116129. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOOriginalSceneColorEffect, function () { return _this._originalColorPostProcess; }, true));
  116130. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAORenderEffect, function () { return _this._ssaoPostProcess; }, true));
  116131. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurHRenderEffect, function () { return _this._blurHPostProcess; }, true));
  116132. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurVRenderEffect, function () { return _this._blurVPostProcess; }, true));
  116133. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOCombineRenderEffect, function () { return _this._ssaoCombinePostProcess; }, true));
  116134. // Finish
  116135. scene.postProcessRenderPipelineManager.addPipeline(_this);
  116136. if (cameras) {
  116137. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  116138. }
  116139. return _this;
  116140. }
  116141. Object.defineProperty(SSAORenderingPipeline.prototype, "scene", {
  116142. /**
  116143. * Gets active scene
  116144. */
  116145. get: function () {
  116146. return this._scene;
  116147. },
  116148. enumerable: true,
  116149. configurable: true
  116150. });
  116151. // Public Methods
  116152. /**
  116153. * Get the class name
  116154. * @returns "SSAORenderingPipeline"
  116155. */
  116156. SSAORenderingPipeline.prototype.getClassName = function () {
  116157. return "SSAORenderingPipeline";
  116158. };
  116159. /**
  116160. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  116161. */
  116162. SSAORenderingPipeline.prototype.dispose = function (disableDepthRender) {
  116163. if (disableDepthRender === void 0) { disableDepthRender = false; }
  116164. for (var i = 0; i < this._scene.cameras.length; i++) {
  116165. var camera = this._scene.cameras[i];
  116166. this._originalColorPostProcess.dispose(camera);
  116167. this._ssaoPostProcess.dispose(camera);
  116168. this._blurHPostProcess.dispose(camera);
  116169. this._blurVPostProcess.dispose(camera);
  116170. this._ssaoCombinePostProcess.dispose(camera);
  116171. }
  116172. this._randomTexture.dispose();
  116173. if (disableDepthRender) {
  116174. this._scene.disableDepthRenderer();
  116175. }
  116176. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  116177. _super.prototype.dispose.call(this);
  116178. };
  116179. // Private Methods
  116180. SSAORenderingPipeline.prototype._createBlurPostProcess = function (ratio) {
  116181. var _this = this;
  116182. var size = 16;
  116183. 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);
  116184. 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);
  116185. this._blurHPostProcess.onActivateObservable.add(function () {
  116186. var dw = _this._blurHPostProcess.width / _this._scene.getEngine().getRenderWidth();
  116187. _this._blurHPostProcess.kernel = size * dw;
  116188. });
  116189. this._blurVPostProcess.onActivateObservable.add(function () {
  116190. var dw = _this._blurVPostProcess.height / _this._scene.getEngine().getRenderHeight();
  116191. _this._blurVPostProcess.kernel = size * dw;
  116192. });
  116193. };
  116194. /** @hidden */
  116195. SSAORenderingPipeline.prototype._rebuild = function () {
  116196. this._firstUpdate = true;
  116197. _super.prototype._rebuild.call(this);
  116198. };
  116199. SSAORenderingPipeline.prototype._createSSAOPostProcess = function (ratio) {
  116200. var _this = this;
  116201. var numSamples = 16;
  116202. var sampleSphere = [
  116203. 0.5381, 0.1856, -0.4319,
  116204. 0.1379, 0.2486, 0.4430,
  116205. 0.3371, 0.5679, -0.0057,
  116206. -0.6999, -0.0451, -0.0019,
  116207. 0.0689, -0.1598, -0.8547,
  116208. 0.0560, 0.0069, -0.1843,
  116209. -0.0146, 0.1402, 0.0762,
  116210. 0.0100, -0.1924, -0.0344,
  116211. -0.3577, -0.5301, -0.4358,
  116212. -0.3169, 0.1063, 0.0158,
  116213. 0.0103, -0.5869, 0.0046,
  116214. -0.0897, -0.4940, 0.3287,
  116215. 0.7119, -0.0154, -0.0918,
  116216. -0.0533, 0.0596, -0.5411,
  116217. 0.0352, -0.0631, 0.5460,
  116218. -0.4776, 0.2847, -0.0271
  116219. ];
  116220. var samplesFactor = 1.0 / numSamples;
  116221. this._ssaoPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_4__["PostProcess"]("ssao", "ssao", [
  116222. "sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius",
  116223. "area", "fallOff", "base", "range", "viewport"
  116224. ], ["randomSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, "#define SAMPLES " + numSamples + "\n#define SSAO");
  116225. this._ssaoPostProcess.onApply = function (effect) {
  116226. if (_this._firstUpdate) {
  116227. effect.setArray3("sampleSphere", sampleSphere);
  116228. effect.setFloat("samplesFactor", samplesFactor);
  116229. effect.setFloat("randTextureTiles", 4.0);
  116230. }
  116231. effect.setFloat("totalStrength", _this.totalStrength);
  116232. effect.setFloat("radius", _this.radius);
  116233. effect.setFloat("area", _this.area);
  116234. effect.setFloat("fallOff", _this.fallOff);
  116235. effect.setFloat("base", _this.base);
  116236. effect.setTexture("textureSampler", _this._depthTexture);
  116237. effect.setTexture("randomSampler", _this._randomTexture);
  116238. };
  116239. };
  116240. SSAORenderingPipeline.prototype._createSSAOCombinePostProcess = function (ratio) {
  116241. var _this = this;
  116242. 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);
  116243. this._ssaoCombinePostProcess.onApply = function (effect) {
  116244. effect.setVector4("viewport", _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector4[0].copyFromFloats(0, 0, 1.0, 1.0));
  116245. effect.setTextureFromPostProcess("originalColor", _this._originalColorPostProcess);
  116246. };
  116247. };
  116248. SSAORenderingPipeline.prototype._createRandomTexture = function () {
  116249. var size = 512;
  116250. 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);
  116251. this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].WRAP_ADDRESSMODE;
  116252. this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].WRAP_ADDRESSMODE;
  116253. var context = this._randomTexture.getContext();
  116254. var rand = function (min, max) {
  116255. return Math.random() * (max - min) + min;
  116256. };
  116257. var randVector = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  116258. for (var x = 0; x < size; x++) {
  116259. for (var y = 0; y < size; y++) {
  116260. randVector.x = Math.floor(rand(-1.0, 1.0) * 255);
  116261. randVector.y = Math.floor(rand(-1.0, 1.0) * 255);
  116262. randVector.z = Math.floor(rand(-1.0, 1.0) * 255);
  116263. context.fillStyle = 'rgb(' + randVector.x + ', ' + randVector.y + ', ' + randVector.z + ')';
  116264. context.fillRect(x, y, 1, 1);
  116265. }
  116266. }
  116267. this._randomTexture.update(false);
  116268. };
  116269. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116270. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  116271. ], SSAORenderingPipeline.prototype, "totalStrength", void 0);
  116272. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116273. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  116274. ], SSAORenderingPipeline.prototype, "radius", void 0);
  116275. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116276. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  116277. ], SSAORenderingPipeline.prototype, "area", void 0);
  116278. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116279. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  116280. ], SSAORenderingPipeline.prototype, "fallOff", void 0);
  116281. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116282. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  116283. ], SSAORenderingPipeline.prototype, "base", void 0);
  116284. return SSAORenderingPipeline;
  116285. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderPipeline"]));
  116286. /***/ }),
  116287. /***/ "./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts":
  116288. /*!*****************************************************************************!*\
  116289. !*** ./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts ***!
  116290. \*****************************************************************************/
  116291. /*! exports provided: StandardRenderingPipeline */
  116292. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116293. "use strict";
  116294. __webpack_require__.r(__webpack_exports__);
  116295. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return StandardRenderingPipeline; });
  116296. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116297. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  116298. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  116299. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  116300. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  116301. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  116302. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  116303. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  116304. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  116305. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  116306. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  116307. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  116308. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  116309. /* harmony import */ var _Shaders_standard_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../Shaders/standard.fragment */ "./Shaders/standard.fragment.ts");
  116310. /**
  116311. * Standard rendering pipeline
  116312. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  116313. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  116314. */
  116315. var StandardRenderingPipeline = /** @class */ (function (_super) {
  116316. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardRenderingPipeline, _super);
  116317. /**
  116318. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  116319. * @constructor
  116320. * @param name The rendering pipeline name
  116321. * @param scene The scene linked to this pipeline
  116322. * @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)
  116323. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  116324. * @param cameras The array of cameras that the rendering pipeline will be attached to
  116325. */
  116326. function StandardRenderingPipeline(name, scene, ratio, originalPostProcess, cameras) {
  116327. if (originalPostProcess === void 0) { originalPostProcess = null; }
  116328. var _this = _super.call(this, scene.getEngine(), name) || this;
  116329. /**
  116330. * Post-process used to down scale an image x4
  116331. */
  116332. _this.downSampleX4PostProcess = null;
  116333. /**
  116334. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  116335. */
  116336. _this.brightPassPostProcess = null;
  116337. /**
  116338. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  116339. */
  116340. _this.blurHPostProcesses = [];
  116341. /**
  116342. * Post-process array storing all the vertical blur post-processes used by the pipeline
  116343. */
  116344. _this.blurVPostProcesses = [];
  116345. /**
  116346. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  116347. */
  116348. _this.textureAdderPostProcess = null;
  116349. /**
  116350. * Post-process used to create volumetric lighting effect
  116351. */
  116352. _this.volumetricLightPostProcess = null;
  116353. /**
  116354. * Post-process used to smooth the previous volumetric light post-process on the X axis
  116355. */
  116356. _this.volumetricLightSmoothXPostProcess = null;
  116357. /**
  116358. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  116359. */
  116360. _this.volumetricLightSmoothYPostProcess = null;
  116361. /**
  116362. * Post-process used to merge the volumetric light effect and the real scene color
  116363. */
  116364. _this.volumetricLightMergePostProces = null;
  116365. /**
  116366. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  116367. */
  116368. _this.volumetricLightFinalPostProcess = null;
  116369. /**
  116370. * Base post-process used to calculate the average luminance of the final image for HDR
  116371. */
  116372. _this.luminancePostProcess = null;
  116373. /**
  116374. * Post-processes used to create down sample post-processes in order to get
  116375. * the average luminance of the final image for HDR
  116376. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  116377. */
  116378. _this.luminanceDownSamplePostProcesses = [];
  116379. /**
  116380. * Post-process used to create a HDR effect (light adaptation)
  116381. */
  116382. _this.hdrPostProcess = null;
  116383. /**
  116384. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  116385. */
  116386. _this.textureAdderFinalPostProcess = null;
  116387. /**
  116388. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  116389. */
  116390. _this.lensFlareFinalPostProcess = null;
  116391. /**
  116392. * Post-process used to merge the final HDR post-process and the real scene color
  116393. */
  116394. _this.hdrFinalPostProcess = null;
  116395. /**
  116396. * Post-process used to create a lens flare effect
  116397. */
  116398. _this.lensFlarePostProcess = null;
  116399. /**
  116400. * Post-process that merges the result of the lens flare post-process and the real scene color
  116401. */
  116402. _this.lensFlareComposePostProcess = null;
  116403. /**
  116404. * Post-process used to create a motion blur effect
  116405. */
  116406. _this.motionBlurPostProcess = null;
  116407. /**
  116408. * Post-process used to create a depth of field effect
  116409. */
  116410. _this.depthOfFieldPostProcess = null;
  116411. /**
  116412. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  116413. */
  116414. _this.fxaaPostProcess = null;
  116415. // Values
  116416. /**
  116417. * Represents the brightness threshold in order to configure the illuminated surfaces
  116418. */
  116419. _this.brightThreshold = 1.0;
  116420. /**
  116421. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  116422. */
  116423. _this.blurWidth = 512.0;
  116424. /**
  116425. * Sets if the blur for highlighted surfaces must be only horizontal
  116426. */
  116427. _this.horizontalBlur = false;
  116428. /**
  116429. * Sets the overall exposure used by the pipeline
  116430. */
  116431. _this.exposure = 1.0;
  116432. /**
  116433. * Texture used typically to simulate "dirty" on camera lens
  116434. */
  116435. _this.lensTexture = null;
  116436. /**
  116437. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  116438. */
  116439. _this.volumetricLightCoefficient = 0.2;
  116440. /**
  116441. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  116442. */
  116443. _this.volumetricLightPower = 4.0;
  116444. /**
  116445. * Used the set the blur intensity to smooth the volumetric lights
  116446. */
  116447. _this.volumetricLightBlurScale = 64.0;
  116448. /**
  116449. * Light (spot or directional) used to generate the volumetric lights rays
  116450. * The source light must have a shadow generate so the pipeline can get its
  116451. * depth map
  116452. */
  116453. _this.sourceLight = null;
  116454. /**
  116455. * For eye adaptation, represents the minimum luminance the eye can see
  116456. */
  116457. _this.hdrMinimumLuminance = 1.0;
  116458. /**
  116459. * For eye adaptation, represents the decrease luminance speed
  116460. */
  116461. _this.hdrDecreaseRate = 0.5;
  116462. /**
  116463. * For eye adaptation, represents the increase luminance speed
  116464. */
  116465. _this.hdrIncreaseRate = 0.5;
  116466. /**
  116467. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  116468. */
  116469. _this.lensColorTexture = null;
  116470. /**
  116471. * The overall strengh for the lens flare effect
  116472. */
  116473. _this.lensFlareStrength = 20.0;
  116474. /**
  116475. * Dispersion coefficient for lens flare ghosts
  116476. */
  116477. _this.lensFlareGhostDispersal = 1.4;
  116478. /**
  116479. * Main lens flare halo width
  116480. */
  116481. _this.lensFlareHaloWidth = 0.7;
  116482. /**
  116483. * Based on the lens distortion effect, defines how much the lens flare result
  116484. * is distorted
  116485. */
  116486. _this.lensFlareDistortionStrength = 16.0;
  116487. /**
  116488. * Lens star texture must be used to simulate rays on the flares and is available
  116489. * in the documentation
  116490. */
  116491. _this.lensStarTexture = null;
  116492. /**
  116493. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  116494. * flare effect by taking account of the dirt texture
  116495. */
  116496. _this.lensFlareDirtTexture = null;
  116497. /**
  116498. * Represents the focal length for the depth of field effect
  116499. */
  116500. _this.depthOfFieldDistance = 10.0;
  116501. /**
  116502. * Represents the blur intensity for the blurred part of the depth of field effect
  116503. */
  116504. _this.depthOfFieldBlurWidth = 64.0;
  116505. /**
  116506. * For motion blur, defines how much the image is blurred by the movement
  116507. */
  116508. _this.motionStrength = 1.0;
  116509. /**
  116510. * List of animations for the pipeline (IAnimatable implementation)
  116511. */
  116512. _this.animations = [];
  116513. _this._currentDepthOfFieldSource = null;
  116514. _this._hdrCurrentLuminance = 1.0;
  116515. // Getters and setters
  116516. _this._bloomEnabled = false;
  116517. _this._depthOfFieldEnabled = false;
  116518. _this._vlsEnabled = false;
  116519. _this._lensFlareEnabled = false;
  116520. _this._hdrEnabled = false;
  116521. _this._motionBlurEnabled = false;
  116522. _this._fxaaEnabled = false;
  116523. _this._motionBlurSamples = 64.0;
  116524. _this._volumetricLightStepsCount = 50.0;
  116525. _this._samples = 1;
  116526. _this._cameras = cameras || [];
  116527. // Initialize
  116528. _this._scene = scene;
  116529. _this._basePostProcess = originalPostProcess;
  116530. _this._ratio = ratio;
  116531. // Misc
  116532. _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;
  116533. // Finish
  116534. scene.postProcessRenderPipelineManager.addPipeline(_this);
  116535. _this._buildPipeline();
  116536. return _this;
  116537. }
  116538. Object.defineProperty(StandardRenderingPipeline.prototype, "BloomEnabled", {
  116539. /**
  116540. * @ignore
  116541. * Specifies if the bloom pipeline is enabled
  116542. */
  116543. get: function () {
  116544. return this._bloomEnabled;
  116545. },
  116546. set: function (enabled) {
  116547. if (this._bloomEnabled === enabled) {
  116548. return;
  116549. }
  116550. this._bloomEnabled = enabled;
  116551. this._buildPipeline();
  116552. },
  116553. enumerable: true,
  116554. configurable: true
  116555. });
  116556. Object.defineProperty(StandardRenderingPipeline.prototype, "DepthOfFieldEnabled", {
  116557. /**
  116558. * @ignore
  116559. * Specifies if the depth of field pipeline is enabed
  116560. */
  116561. get: function () {
  116562. return this._depthOfFieldEnabled;
  116563. },
  116564. set: function (enabled) {
  116565. if (this._depthOfFieldEnabled === enabled) {
  116566. return;
  116567. }
  116568. this._depthOfFieldEnabled = enabled;
  116569. this._buildPipeline();
  116570. },
  116571. enumerable: true,
  116572. configurable: true
  116573. });
  116574. Object.defineProperty(StandardRenderingPipeline.prototype, "LensFlareEnabled", {
  116575. /**
  116576. * @ignore
  116577. * Specifies if the lens flare pipeline is enabed
  116578. */
  116579. get: function () {
  116580. return this._lensFlareEnabled;
  116581. },
  116582. set: function (enabled) {
  116583. if (this._lensFlareEnabled === enabled) {
  116584. return;
  116585. }
  116586. this._lensFlareEnabled = enabled;
  116587. this._buildPipeline();
  116588. },
  116589. enumerable: true,
  116590. configurable: true
  116591. });
  116592. Object.defineProperty(StandardRenderingPipeline.prototype, "HDREnabled", {
  116593. /**
  116594. * @ignore
  116595. * Specifies if the HDR pipeline is enabled
  116596. */
  116597. get: function () {
  116598. return this._hdrEnabled;
  116599. },
  116600. set: function (enabled) {
  116601. if (this._hdrEnabled === enabled) {
  116602. return;
  116603. }
  116604. this._hdrEnabled = enabled;
  116605. this._buildPipeline();
  116606. },
  116607. enumerable: true,
  116608. configurable: true
  116609. });
  116610. Object.defineProperty(StandardRenderingPipeline.prototype, "VLSEnabled", {
  116611. /**
  116612. * @ignore
  116613. * Specifies if the volumetric lights scattering effect is enabled
  116614. */
  116615. get: function () {
  116616. return this._vlsEnabled;
  116617. },
  116618. set: function (enabled) {
  116619. if (this._vlsEnabled === enabled) {
  116620. return;
  116621. }
  116622. if (enabled) {
  116623. var geometry = this._scene.enableGeometryBufferRenderer();
  116624. if (!geometry) {
  116625. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("Geometry renderer is not supported, cannot create volumetric lights in Standard Rendering Pipeline");
  116626. return;
  116627. }
  116628. }
  116629. this._vlsEnabled = enabled;
  116630. this._buildPipeline();
  116631. },
  116632. enumerable: true,
  116633. configurable: true
  116634. });
  116635. Object.defineProperty(StandardRenderingPipeline.prototype, "MotionBlurEnabled", {
  116636. /**
  116637. * @ignore
  116638. * Specifies if the motion blur effect is enabled
  116639. */
  116640. get: function () {
  116641. return this._motionBlurEnabled;
  116642. },
  116643. set: function (enabled) {
  116644. if (this._motionBlurEnabled === enabled) {
  116645. return;
  116646. }
  116647. this._motionBlurEnabled = enabled;
  116648. this._buildPipeline();
  116649. },
  116650. enumerable: true,
  116651. configurable: true
  116652. });
  116653. Object.defineProperty(StandardRenderingPipeline.prototype, "fxaaEnabled", {
  116654. /**
  116655. * Specifies if anti-aliasing is enabled
  116656. */
  116657. get: function () {
  116658. return this._fxaaEnabled;
  116659. },
  116660. set: function (enabled) {
  116661. if (this._fxaaEnabled === enabled) {
  116662. return;
  116663. }
  116664. this._fxaaEnabled = enabled;
  116665. this._buildPipeline();
  116666. },
  116667. enumerable: true,
  116668. configurable: true
  116669. });
  116670. Object.defineProperty(StandardRenderingPipeline.prototype, "volumetricLightStepsCount", {
  116671. /**
  116672. * Specifies the number of steps used to calculate the volumetric lights
  116673. * Typically in interval [50, 200]
  116674. */
  116675. get: function () {
  116676. return this._volumetricLightStepsCount;
  116677. },
  116678. set: function (count) {
  116679. if (this.volumetricLightPostProcess) {
  116680. this.volumetricLightPostProcess.updateEffect("#define VLS\n#define NB_STEPS " + count.toFixed(1));
  116681. }
  116682. this._volumetricLightStepsCount = count;
  116683. },
  116684. enumerable: true,
  116685. configurable: true
  116686. });
  116687. Object.defineProperty(StandardRenderingPipeline.prototype, "motionBlurSamples", {
  116688. /**
  116689. * Specifies the number of samples used for the motion blur effect
  116690. * Typically in interval [16, 64]
  116691. */
  116692. get: function () {
  116693. return this._motionBlurSamples;
  116694. },
  116695. set: function (samples) {
  116696. if (this.motionBlurPostProcess) {
  116697. this.motionBlurPostProcess.updateEffect("#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES " + samples.toFixed(1));
  116698. }
  116699. this._motionBlurSamples = samples;
  116700. },
  116701. enumerable: true,
  116702. configurable: true
  116703. });
  116704. Object.defineProperty(StandardRenderingPipeline.prototype, "samples", {
  116705. /**
  116706. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  116707. */
  116708. get: function () {
  116709. return this._samples;
  116710. },
  116711. set: function (sampleCount) {
  116712. if (this._samples === sampleCount) {
  116713. return;
  116714. }
  116715. this._samples = sampleCount;
  116716. this._buildPipeline();
  116717. },
  116718. enumerable: true,
  116719. configurable: true
  116720. });
  116721. StandardRenderingPipeline.prototype._buildPipeline = function () {
  116722. var _this = this;
  116723. var ratio = this._ratio;
  116724. var scene = this._scene;
  116725. this._disposePostProcesses();
  116726. this._reset();
  116727. // Create pass post-process
  116728. if (!this._basePostProcess) {
  116729. 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);
  116730. this.originalPostProcess.onApply = function () {
  116731. _this._currentDepthOfFieldSource = _this.originalPostProcess;
  116732. };
  116733. }
  116734. else {
  116735. this.originalPostProcess = this._basePostProcess;
  116736. }
  116737. if (this._bloomEnabled || this._vlsEnabled || this._lensFlareEnabled || this._depthOfFieldEnabled || this._motionBlurEnabled) {
  116738. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPassPostProcess", function () { return _this.originalPostProcess; }, true));
  116739. }
  116740. this._currentDepthOfFieldSource = this.originalPostProcess;
  116741. if (this._bloomEnabled) {
  116742. // Create down sample X4 post-process
  116743. this._createDownSampleX4PostProcess(scene, ratio / 2);
  116744. // Create bright pass post-process
  116745. this._createBrightPassPostProcess(scene, ratio / 2);
  116746. // Create gaussian blur post-processes (down sampling blurs)
  116747. this._createBlurPostProcesses(scene, ratio / 4, 1);
  116748. // Create texture adder post-process
  116749. this._createTextureAdderPostProcess(scene, ratio);
  116750. // Create depth-of-field source post-process
  116751. 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);
  116752. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBaseDepthOfFieldSource", function () { return _this.textureAdderFinalPostProcess; }, true));
  116753. }
  116754. if (this._vlsEnabled) {
  116755. // Create volumetric light
  116756. this._createVolumetricLightPostProcess(scene, ratio);
  116757. // Create volumetric light final post-process
  116758. 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);
  116759. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLSFinal", function () { return _this.volumetricLightFinalPostProcess; }, true));
  116760. }
  116761. if (this._lensFlareEnabled) {
  116762. // Create lens flare post-process
  116763. this._createLensFlarePostProcess(scene, ratio);
  116764. // Create depth-of-field source post-process post lens-flare and disable it now
  116765. 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);
  116766. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPostLensFlareDepthOfFieldSource", function () { return _this.lensFlareFinalPostProcess; }, true));
  116767. }
  116768. if (this._hdrEnabled) {
  116769. // Create luminance
  116770. this._createLuminancePostProcesses(scene, this._floatTextureType);
  116771. // Create HDR
  116772. this._createHdrPostProcess(scene, ratio);
  116773. // Create depth-of-field source post-process post hdr and disable it now
  116774. 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);
  116775. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPostHDReDepthOfFieldSource", function () { return _this.hdrFinalPostProcess; }, true));
  116776. }
  116777. if (this._depthOfFieldEnabled) {
  116778. // Create gaussian blur used by depth-of-field
  116779. this._createBlurPostProcesses(scene, ratio / 2, 3, "depthOfFieldBlurWidth");
  116780. // Create depth-of-field post-process
  116781. this._createDepthOfFieldPostProcess(scene, ratio);
  116782. }
  116783. if (this._motionBlurEnabled) {
  116784. // Create motion blur post-process
  116785. this._createMotionBlurPostProcess(scene, ratio);
  116786. }
  116787. if (this._fxaaEnabled) {
  116788. // Create fxaa post-process
  116789. 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);
  116790. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRFxaa", function () { return _this.fxaaPostProcess; }, true));
  116791. }
  116792. if (this._cameras !== null) {
  116793. this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);
  116794. }
  116795. if (!this._enableMSAAOnFirstPostProcess(this._samples) && this._samples > 1) {
  116796. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
  116797. }
  116798. };
  116799. // Down Sample X4 Post-Processs
  116800. StandardRenderingPipeline.prototype._createDownSampleX4PostProcess = function (scene, ratio) {
  116801. var _this = this;
  116802. var downSampleX4Offsets = new Array(32);
  116803. 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);
  116804. this.downSampleX4PostProcess.onApply = function (effect) {
  116805. var id = 0;
  116806. var width = _this.downSampleX4PostProcess.width;
  116807. var height = _this.downSampleX4PostProcess.height;
  116808. for (var i = -2; i < 2; i++) {
  116809. for (var j = -2; j < 2; j++) {
  116810. downSampleX4Offsets[id] = (i + 0.5) * (1.0 / width);
  116811. downSampleX4Offsets[id + 1] = (j + 0.5) * (1.0 / height);
  116812. id += 2;
  116813. }
  116814. }
  116815. effect.setArray2("dsOffsets", downSampleX4Offsets);
  116816. };
  116817. // Add to pipeline
  116818. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRDownSampleX4", function () { return _this.downSampleX4PostProcess; }, true));
  116819. };
  116820. // Brightpass Post-Process
  116821. StandardRenderingPipeline.prototype._createBrightPassPostProcess = function (scene, ratio) {
  116822. var _this = this;
  116823. var brightOffsets = new Array(8);
  116824. 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);
  116825. this.brightPassPostProcess.onApply = function (effect) {
  116826. var sU = (1.0 / _this.brightPassPostProcess.width);
  116827. var sV = (1.0 / _this.brightPassPostProcess.height);
  116828. brightOffsets[0] = -0.5 * sU;
  116829. brightOffsets[1] = 0.5 * sV;
  116830. brightOffsets[2] = 0.5 * sU;
  116831. brightOffsets[3] = 0.5 * sV;
  116832. brightOffsets[4] = -0.5 * sU;
  116833. brightOffsets[5] = -0.5 * sV;
  116834. brightOffsets[6] = 0.5 * sU;
  116835. brightOffsets[7] = -0.5 * sV;
  116836. effect.setArray2("dsOffsets", brightOffsets);
  116837. effect.setFloat("brightThreshold", _this.brightThreshold);
  116838. };
  116839. // Add to pipeline
  116840. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBrightPass", function () { return _this.brightPassPostProcess; }, true));
  116841. };
  116842. // Create blur H&V post-processes
  116843. StandardRenderingPipeline.prototype._createBlurPostProcesses = function (scene, ratio, indice, blurWidthKey) {
  116844. var _this = this;
  116845. if (blurWidthKey === void 0) { blurWidthKey = "blurWidth"; }
  116846. var engine = scene.getEngine();
  116847. 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);
  116848. 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);
  116849. blurX.onActivateObservable.add(function () {
  116850. var dw = blurX.width / engine.getRenderWidth();
  116851. blurX.kernel = _this[blurWidthKey] * dw;
  116852. });
  116853. blurY.onActivateObservable.add(function () {
  116854. var dw = blurY.height / engine.getRenderHeight();
  116855. blurY.kernel = _this.horizontalBlur ? 64 * dw : _this[blurWidthKey] * dw;
  116856. });
  116857. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBlurH" + indice, function () { return blurX; }, true));
  116858. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBlurV" + indice, function () { return blurY; }, true));
  116859. this.blurHPostProcesses.push(blurX);
  116860. this.blurVPostProcesses.push(blurY);
  116861. };
  116862. // Create texture adder post-process
  116863. StandardRenderingPipeline.prototype._createTextureAdderPostProcess = function (scene, ratio) {
  116864. var _this = this;
  116865. 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);
  116866. this.textureAdderPostProcess.onApply = function (effect) {
  116867. effect.setTextureFromPostProcess("otherSampler", _this._vlsEnabled ? _this._currentDepthOfFieldSource : _this.originalPostProcess);
  116868. effect.setTexture("lensSampler", _this.lensTexture);
  116869. effect.setFloat("exposure", _this.exposure);
  116870. _this._currentDepthOfFieldSource = _this.textureAdderFinalPostProcess;
  116871. };
  116872. // Add to pipeline
  116873. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRTextureAdder", function () { return _this.textureAdderPostProcess; }, true));
  116874. };
  116875. StandardRenderingPipeline.prototype._createVolumetricLightPostProcess = function (scene, ratio) {
  116876. var _this = this;
  116877. var geometryRenderer = scene.enableGeometryBufferRenderer();
  116878. geometryRenderer.enablePosition = true;
  116879. var geometry = geometryRenderer.getGBuffer();
  116880. // Base post-process
  116881. 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));
  116882. var depthValues = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  116883. this.volumetricLightPostProcess.onApply = function (effect) {
  116884. if (_this.sourceLight && _this.sourceLight.getShadowGenerator() && _this._scene.activeCamera) {
  116885. var generator = _this.sourceLight.getShadowGenerator();
  116886. effect.setTexture("shadowMapSampler", generator.getShadowMap());
  116887. effect.setTexture("positionSampler", geometry.textures[2]);
  116888. effect.setColor3("sunColor", _this.sourceLight.diffuse);
  116889. effect.setVector3("sunDirection", _this.sourceLight.getShadowDirection());
  116890. effect.setVector3("cameraPosition", _this._scene.activeCamera.globalPosition);
  116891. effect.setMatrix("shadowViewProjection", generator.getTransformMatrix());
  116892. effect.setFloat("scatteringCoefficient", _this.volumetricLightCoefficient);
  116893. effect.setFloat("scatteringPower", _this.volumetricLightPower);
  116894. depthValues.x = _this.sourceLight.getDepthMinZ(_this._scene.activeCamera);
  116895. depthValues.y = _this.sourceLight.getDepthMaxZ(_this._scene.activeCamera);
  116896. effect.setVector2("depthValues", depthValues);
  116897. }
  116898. };
  116899. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLS", function () { return _this.volumetricLightPostProcess; }, true));
  116900. // Smooth
  116901. this._createBlurPostProcesses(scene, ratio / 4, 0, "volumetricLightBlurScale");
  116902. // Merge
  116903. 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");
  116904. this.volumetricLightMergePostProces.onApply = function (effect) {
  116905. effect.setTextureFromPostProcess("originalSampler", _this._bloomEnabled ? _this.textureAdderFinalPostProcess : _this.originalPostProcess);
  116906. _this._currentDepthOfFieldSource = _this.volumetricLightFinalPostProcess;
  116907. };
  116908. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLSMerge", function () { return _this.volumetricLightMergePostProces; }, true));
  116909. };
  116910. // Create luminance
  116911. StandardRenderingPipeline.prototype._createLuminancePostProcesses = function (scene, textureType) {
  116912. var _this = this;
  116913. // Create luminance
  116914. var size = Math.pow(3, StandardRenderingPipeline.LuminanceSteps);
  116915. 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);
  116916. var offsets = [];
  116917. this.luminancePostProcess.onApply = function (effect) {
  116918. var sU = (1.0 / _this.luminancePostProcess.width);
  116919. var sV = (1.0 / _this.luminancePostProcess.height);
  116920. offsets[0] = -0.5 * sU;
  116921. offsets[1] = 0.5 * sV;
  116922. offsets[2] = 0.5 * sU;
  116923. offsets[3] = 0.5 * sV;
  116924. offsets[4] = -0.5 * sU;
  116925. offsets[5] = -0.5 * sV;
  116926. offsets[6] = 0.5 * sU;
  116927. offsets[7] = -0.5 * sV;
  116928. effect.setArray2("lumOffsets", offsets);
  116929. };
  116930. // Add to pipeline
  116931. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLuminance", function () { return _this.luminancePostProcess; }, true));
  116932. // Create down sample luminance
  116933. for (var i = StandardRenderingPipeline.LuminanceSteps - 1; i >= 0; i--) {
  116934. var size = Math.pow(3, i);
  116935. var defines = "#define LUMINANCE_DOWN_SAMPLE\n";
  116936. if (i === 0) {
  116937. defines += "#define FINAL_DOWN_SAMPLER";
  116938. }
  116939. 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);
  116940. this.luminanceDownSamplePostProcesses.push(postProcess);
  116941. }
  116942. // Create callbacks and add effects
  116943. var lastLuminance = this.luminancePostProcess;
  116944. this.luminanceDownSamplePostProcesses.forEach(function (pp, index) {
  116945. var downSampleOffsets = new Array(18);
  116946. pp.onApply = function (effect) {
  116947. if (!lastLuminance) {
  116948. return;
  116949. }
  116950. var id = 0;
  116951. for (var x = -1; x < 2; x++) {
  116952. for (var y = -1; y < 2; y++) {
  116953. downSampleOffsets[id] = x / lastLuminance.width;
  116954. downSampleOffsets[id + 1] = y / lastLuminance.height;
  116955. id += 2;
  116956. }
  116957. }
  116958. effect.setArray2("dsOffsets", downSampleOffsets);
  116959. effect.setFloat("halfDestPixelSize", 0.5 / lastLuminance.width);
  116960. if (index === _this.luminanceDownSamplePostProcesses.length - 1) {
  116961. lastLuminance = _this.luminancePostProcess;
  116962. }
  116963. else {
  116964. lastLuminance = pp;
  116965. }
  116966. };
  116967. if (index === _this.luminanceDownSamplePostProcesses.length - 1) {
  116968. pp.onAfterRender = function () {
  116969. var pixel = scene.getEngine().readPixels(0, 0, 1, 1);
  116970. 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);
  116971. _this._hdrCurrentLuminance = (pixel[0] * bit_shift.x + pixel[1] * bit_shift.y + pixel[2] * bit_shift.z + pixel[3] * bit_shift.w) / 100.0;
  116972. };
  116973. }
  116974. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLuminanceDownSample" + index, function () { return pp; }, true));
  116975. });
  116976. };
  116977. // Create HDR post-process
  116978. StandardRenderingPipeline.prototype._createHdrPostProcess = function (scene, ratio) {
  116979. var _this = this;
  116980. 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);
  116981. var outputLiminance = 1;
  116982. var time = 0;
  116983. var lastTime = 0;
  116984. this.hdrPostProcess.onApply = function (effect) {
  116985. effect.setTextureFromPostProcess("textureAdderSampler", _this._currentDepthOfFieldSource);
  116986. time += scene.getEngine().getDeltaTime();
  116987. if (outputLiminance < 0) {
  116988. outputLiminance = _this._hdrCurrentLuminance;
  116989. }
  116990. else {
  116991. var dt = (lastTime - time) / 1000.0;
  116992. if (_this._hdrCurrentLuminance < outputLiminance + _this.hdrDecreaseRate * dt) {
  116993. outputLiminance += _this.hdrDecreaseRate * dt;
  116994. }
  116995. else if (_this._hdrCurrentLuminance > outputLiminance - _this.hdrIncreaseRate * dt) {
  116996. outputLiminance -= _this.hdrIncreaseRate * dt;
  116997. }
  116998. else {
  116999. outputLiminance = _this._hdrCurrentLuminance;
  117000. }
  117001. }
  117002. outputLiminance = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Clamp(outputLiminance, _this.hdrMinimumLuminance, 1e20);
  117003. effect.setFloat("averageLuminance", outputLiminance);
  117004. lastTime = time;
  117005. _this._currentDepthOfFieldSource = _this.hdrFinalPostProcess;
  117006. };
  117007. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDR", function () { return _this.hdrPostProcess; }, true));
  117008. };
  117009. // Create lens flare post-process
  117010. StandardRenderingPipeline.prototype._createLensFlarePostProcess = function (scene, ratio) {
  117011. var _this = this;
  117012. 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);
  117013. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLensFlare", function () { return _this.lensFlarePostProcess; }, true));
  117014. this._createBlurPostProcesses(scene, ratio / 4, 2);
  117015. 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);
  117016. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLensFlareCompose", function () { return _this.lensFlareComposePostProcess; }, true));
  117017. var resolution = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 0);
  117018. // Lens flare
  117019. this.lensFlarePostProcess.onApply = function (effect) {
  117020. effect.setTextureFromPostProcess("textureSampler", _this._bloomEnabled ? _this.blurHPostProcesses[0] : _this.originalPostProcess);
  117021. effect.setTexture("lensColorSampler", _this.lensColorTexture);
  117022. effect.setFloat("strength", _this.lensFlareStrength);
  117023. effect.setFloat("ghostDispersal", _this.lensFlareGhostDispersal);
  117024. effect.setFloat("haloWidth", _this.lensFlareHaloWidth);
  117025. // Shift
  117026. resolution.x = _this.lensFlarePostProcess.width;
  117027. resolution.y = _this.lensFlarePostProcess.height;
  117028. effect.setVector2("resolution", resolution);
  117029. effect.setFloat("distortionStrength", _this.lensFlareDistortionStrength);
  117030. };
  117031. // Compose
  117032. 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);
  117033. 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);
  117034. this.lensFlareComposePostProcess.onApply = function (effect) {
  117035. if (!_this._scene.activeCamera) {
  117036. return;
  117037. }
  117038. effect.setTextureFromPostProcess("otherSampler", _this._currentDepthOfFieldSource);
  117039. effect.setTexture("lensDirtSampler", _this.lensFlareDirtTexture);
  117040. effect.setTexture("lensStarSampler", _this.lensStarTexture);
  117041. // Lens start rotation matrix
  117042. var camerax = _this._scene.activeCamera.getViewMatrix().getRow(0);
  117043. var cameraz = _this._scene.activeCamera.getViewMatrix().getRow(2);
  117044. 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));
  117045. camRot *= 4.0;
  117046. 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);
  117047. var lensStarMatrix = scaleBias2.multiply(starRotation).multiply(scaleBias1);
  117048. effect.setMatrix("lensStarMatrix", lensStarMatrix);
  117049. _this._currentDepthOfFieldSource = _this.lensFlareFinalPostProcess;
  117050. };
  117051. };
  117052. // Create depth-of-field post-process
  117053. StandardRenderingPipeline.prototype._createDepthOfFieldPostProcess = function (scene, ratio) {
  117054. var _this = this;
  117055. 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);
  117056. this.depthOfFieldPostProcess.onApply = function (effect) {
  117057. effect.setTextureFromPostProcess("otherSampler", _this._currentDepthOfFieldSource);
  117058. effect.setTexture("depthSampler", _this._getDepthTexture());
  117059. effect.setFloat("distance", _this.depthOfFieldDistance);
  117060. };
  117061. // Add to pipeline
  117062. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRDepthOfField", function () { return _this.depthOfFieldPostProcess; }, true));
  117063. };
  117064. // Create motion blur post-process
  117065. StandardRenderingPipeline.prototype._createMotionBlurPostProcess = function (scene, ratio) {
  117066. var _this = this;
  117067. 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);
  117068. var motionScale = 0;
  117069. var prevViewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  117070. var invViewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  117071. var viewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  117072. var screenSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  117073. this.motionBlurPostProcess.onApply = function (effect) {
  117074. viewProjection = scene.getProjectionMatrix().multiply(scene.getViewMatrix());
  117075. viewProjection.invertToRef(invViewProjection);
  117076. effect.setMatrix("inverseViewProjection", invViewProjection);
  117077. effect.setMatrix("prevViewProjection", prevViewProjection);
  117078. prevViewProjection = viewProjection;
  117079. screenSize.x = _this.motionBlurPostProcess.width;
  117080. screenSize.y = _this.motionBlurPostProcess.height;
  117081. effect.setVector2("screenSize", screenSize);
  117082. motionScale = scene.getEngine().getFps() / 60.0;
  117083. effect.setFloat("motionScale", motionScale);
  117084. effect.setFloat("motionStrength", _this.motionStrength);
  117085. effect.setTexture("depthSampler", _this._getDepthTexture());
  117086. };
  117087. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRMotionBlur", function () { return _this.motionBlurPostProcess; }, true));
  117088. };
  117089. StandardRenderingPipeline.prototype._getDepthTexture = function () {
  117090. if (this._scene.getEngine().getCaps().drawBuffersExtension) {
  117091. var renderer = this._scene.enableGeometryBufferRenderer();
  117092. return renderer.getGBuffer().textures[0];
  117093. }
  117094. return this._scene.enableDepthRenderer().getDepthMap();
  117095. };
  117096. StandardRenderingPipeline.prototype._disposePostProcesses = function () {
  117097. for (var i = 0; i < this._cameras.length; i++) {
  117098. var camera = this._cameras[i];
  117099. if (this.originalPostProcess) {
  117100. this.originalPostProcess.dispose(camera);
  117101. }
  117102. if (this.downSampleX4PostProcess) {
  117103. this.downSampleX4PostProcess.dispose(camera);
  117104. }
  117105. if (this.brightPassPostProcess) {
  117106. this.brightPassPostProcess.dispose(camera);
  117107. }
  117108. if (this.textureAdderPostProcess) {
  117109. this.textureAdderPostProcess.dispose(camera);
  117110. }
  117111. if (this.textureAdderFinalPostProcess) {
  117112. this.textureAdderFinalPostProcess.dispose(camera);
  117113. }
  117114. if (this.volumetricLightPostProcess) {
  117115. this.volumetricLightPostProcess.dispose(camera);
  117116. }
  117117. if (this.volumetricLightSmoothXPostProcess) {
  117118. this.volumetricLightSmoothXPostProcess.dispose(camera);
  117119. }
  117120. if (this.volumetricLightSmoothYPostProcess) {
  117121. this.volumetricLightSmoothYPostProcess.dispose(camera);
  117122. }
  117123. if (this.volumetricLightMergePostProces) {
  117124. this.volumetricLightMergePostProces.dispose(camera);
  117125. }
  117126. if (this.volumetricLightFinalPostProcess) {
  117127. this.volumetricLightFinalPostProcess.dispose(camera);
  117128. }
  117129. if (this.lensFlarePostProcess) {
  117130. this.lensFlarePostProcess.dispose(camera);
  117131. }
  117132. if (this.lensFlareComposePostProcess) {
  117133. this.lensFlareComposePostProcess.dispose(camera);
  117134. }
  117135. for (var j = 0; j < this.luminanceDownSamplePostProcesses.length; j++) {
  117136. this.luminanceDownSamplePostProcesses[j].dispose(camera);
  117137. }
  117138. if (this.luminancePostProcess) {
  117139. this.luminancePostProcess.dispose(camera);
  117140. }
  117141. if (this.hdrPostProcess) {
  117142. this.hdrPostProcess.dispose(camera);
  117143. }
  117144. if (this.hdrFinalPostProcess) {
  117145. this.hdrFinalPostProcess.dispose(camera);
  117146. }
  117147. if (this.depthOfFieldPostProcess) {
  117148. this.depthOfFieldPostProcess.dispose(camera);
  117149. }
  117150. if (this.motionBlurPostProcess) {
  117151. this.motionBlurPostProcess.dispose(camera);
  117152. }
  117153. if (this.fxaaPostProcess) {
  117154. this.fxaaPostProcess.dispose(camera);
  117155. }
  117156. for (var j = 0; j < this.blurHPostProcesses.length; j++) {
  117157. this.blurHPostProcesses[j].dispose(camera);
  117158. }
  117159. for (var j = 0; j < this.blurVPostProcesses.length; j++) {
  117160. this.blurVPostProcesses[j].dispose(camera);
  117161. }
  117162. }
  117163. this.originalPostProcess = null;
  117164. this.downSampleX4PostProcess = null;
  117165. this.brightPassPostProcess = null;
  117166. this.textureAdderPostProcess = null;
  117167. this.textureAdderFinalPostProcess = null;
  117168. this.volumetricLightPostProcess = null;
  117169. this.volumetricLightSmoothXPostProcess = null;
  117170. this.volumetricLightSmoothYPostProcess = null;
  117171. this.volumetricLightMergePostProces = null;
  117172. this.volumetricLightFinalPostProcess = null;
  117173. this.lensFlarePostProcess = null;
  117174. this.lensFlareComposePostProcess = null;
  117175. this.luminancePostProcess = null;
  117176. this.hdrPostProcess = null;
  117177. this.hdrFinalPostProcess = null;
  117178. this.depthOfFieldPostProcess = null;
  117179. this.motionBlurPostProcess = null;
  117180. this.fxaaPostProcess = null;
  117181. this.luminanceDownSamplePostProcesses = [];
  117182. this.blurHPostProcesses = [];
  117183. this.blurVPostProcesses = [];
  117184. };
  117185. /**
  117186. * Dispose of the pipeline and stop all post processes
  117187. */
  117188. StandardRenderingPipeline.prototype.dispose = function () {
  117189. this._disposePostProcesses();
  117190. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  117191. _super.prototype.dispose.call(this);
  117192. };
  117193. /**
  117194. * Serialize the rendering pipeline (Used when exporting)
  117195. * @returns the serialized object
  117196. */
  117197. StandardRenderingPipeline.prototype.serialize = function () {
  117198. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  117199. if (this.sourceLight) {
  117200. serializationObject.sourceLightId = this.sourceLight.id;
  117201. }
  117202. serializationObject.customType = "StandardRenderingPipeline";
  117203. return serializationObject;
  117204. };
  117205. /**
  117206. * Parse the serialized pipeline
  117207. * @param source Source pipeline.
  117208. * @param scene The scene to load the pipeline to.
  117209. * @param rootUrl The URL of the serialized pipeline.
  117210. * @returns An instantiated pipeline from the serialized object.
  117211. */
  117212. StandardRenderingPipeline.Parse = function (source, scene, rootUrl) {
  117213. var p = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new StandardRenderingPipeline(source._name, scene, source._ratio); }, source, scene, rootUrl);
  117214. if (source.sourceLightId) {
  117215. p.sourceLight = scene.getLightByID(source.sourceLightId);
  117216. }
  117217. return p;
  117218. };
  117219. /**
  117220. * Luminance steps
  117221. */
  117222. StandardRenderingPipeline.LuminanceSteps = 6;
  117223. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117224. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117225. ], StandardRenderingPipeline.prototype, "brightThreshold", void 0);
  117226. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117227. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117228. ], StandardRenderingPipeline.prototype, "blurWidth", void 0);
  117229. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117230. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117231. ], StandardRenderingPipeline.prototype, "horizontalBlur", void 0);
  117232. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117233. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117234. ], StandardRenderingPipeline.prototype, "exposure", void 0);
  117235. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117236. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensTexture")
  117237. ], StandardRenderingPipeline.prototype, "lensTexture", void 0);
  117238. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117239. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117240. ], StandardRenderingPipeline.prototype, "volumetricLightCoefficient", void 0);
  117241. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117242. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117243. ], StandardRenderingPipeline.prototype, "volumetricLightPower", void 0);
  117244. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117245. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117246. ], StandardRenderingPipeline.prototype, "volumetricLightBlurScale", void 0);
  117247. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117248. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117249. ], StandardRenderingPipeline.prototype, "hdrMinimumLuminance", void 0);
  117250. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117251. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117252. ], StandardRenderingPipeline.prototype, "hdrDecreaseRate", void 0);
  117253. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117254. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117255. ], StandardRenderingPipeline.prototype, "hdrIncreaseRate", void 0);
  117256. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117257. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensColorTexture")
  117258. ], StandardRenderingPipeline.prototype, "lensColorTexture", void 0);
  117259. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117260. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117261. ], StandardRenderingPipeline.prototype, "lensFlareStrength", void 0);
  117262. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117263. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117264. ], StandardRenderingPipeline.prototype, "lensFlareGhostDispersal", void 0);
  117265. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117266. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117267. ], StandardRenderingPipeline.prototype, "lensFlareHaloWidth", void 0);
  117268. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117269. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117270. ], StandardRenderingPipeline.prototype, "lensFlareDistortionStrength", void 0);
  117271. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117272. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensStarTexture")
  117273. ], StandardRenderingPipeline.prototype, "lensStarTexture", void 0);
  117274. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117275. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensFlareDirtTexture")
  117276. ], StandardRenderingPipeline.prototype, "lensFlareDirtTexture", void 0);
  117277. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117278. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117279. ], StandardRenderingPipeline.prototype, "depthOfFieldDistance", void 0);
  117280. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117281. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117282. ], StandardRenderingPipeline.prototype, "depthOfFieldBlurWidth", void 0);
  117283. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117284. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117285. ], StandardRenderingPipeline.prototype, "motionStrength", void 0);
  117286. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117287. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117288. ], StandardRenderingPipeline.prototype, "_ratio", void 0);
  117289. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117290. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117291. ], StandardRenderingPipeline.prototype, "BloomEnabled", null);
  117292. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117293. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117294. ], StandardRenderingPipeline.prototype, "DepthOfFieldEnabled", null);
  117295. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117296. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117297. ], StandardRenderingPipeline.prototype, "LensFlareEnabled", null);
  117298. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117299. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117300. ], StandardRenderingPipeline.prototype, "HDREnabled", null);
  117301. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117302. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117303. ], StandardRenderingPipeline.prototype, "VLSEnabled", null);
  117304. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117305. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117306. ], StandardRenderingPipeline.prototype, "MotionBlurEnabled", null);
  117307. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117308. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117309. ], StandardRenderingPipeline.prototype, "fxaaEnabled", null);
  117310. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117311. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117312. ], StandardRenderingPipeline.prototype, "volumetricLightStepsCount", null);
  117313. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117314. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117315. ], StandardRenderingPipeline.prototype, "motionBlurSamples", null);
  117316. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117317. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117318. ], StandardRenderingPipeline.prototype, "samples", null);
  117319. return StandardRenderingPipeline;
  117320. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__["PostProcessRenderPipeline"]));
  117321. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.StandardRenderingPipeline"] = StandardRenderingPipeline;
  117322. /***/ }),
  117323. /***/ "./PostProcesses/RenderPipeline/index.ts":
  117324. /*!***********************************************!*\
  117325. !*** ./PostProcesses/RenderPipeline/index.ts ***!
  117326. \***********************************************/
  117327. /*! exports provided: PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  117328. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117329. "use strict";
  117330. __webpack_require__.r(__webpack_exports__);
  117331. /* harmony import */ var _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Pipelines/index */ "./PostProcesses/RenderPipeline/Pipelines/index.ts");
  117332. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  117333. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["LensRenderingPipeline"]; });
  117334. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["SSAO2RenderingPipeline"]; });
  117335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["SSAORenderingPipeline"]; });
  117336. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["StandardRenderingPipeline"]; });
  117337. /* harmony import */ var _postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  117338. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderEffect"]; });
  117339. /* harmony import */ var _postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  117340. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_2__["PostProcessRenderPipeline"]; });
  117341. /* harmony import */ var _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcessRenderPipelineManager */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts");
  117342. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_3__["PostProcessRenderPipelineManager"]; });
  117343. /* harmony import */ var _postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./postProcessRenderPipelineManagerSceneComponent */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts");
  117344. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_4__["PostProcessRenderPipelineManagerSceneComponent"]; });
  117345. /***/ }),
  117346. /***/ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts":
  117347. /*!*****************************************************************!*\
  117348. !*** ./PostProcesses/RenderPipeline/postProcessRenderEffect.ts ***!
  117349. \*****************************************************************/
  117350. /*! exports provided: PostProcessRenderEffect */
  117351. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117352. "use strict";
  117353. __webpack_require__.r(__webpack_exports__);
  117354. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return PostProcessRenderEffect; });
  117355. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  117356. /**
  117357. * This represents a set of one or more post processes in Babylon.
  117358. * A post process can be used to apply a shader to a texture after it is rendered.
  117359. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  117360. */
  117361. var PostProcessRenderEffect = /** @class */ (function () {
  117362. /**
  117363. * Instantiates a post process render effect.
  117364. * A post process can be used to apply a shader to a texture after it is rendered.
  117365. * @param engine The engine the effect is tied to
  117366. * @param name The name of the effect
  117367. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  117368. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  117369. */
  117370. function PostProcessRenderEffect(engine, name, getPostProcesses, singleInstance) {
  117371. this._name = name;
  117372. this._singleInstance = singleInstance || true;
  117373. this._getPostProcesses = getPostProcesses;
  117374. this._cameras = {};
  117375. this._indicesForCamera = {};
  117376. this._postProcesses = {};
  117377. }
  117378. Object.defineProperty(PostProcessRenderEffect.prototype, "isSupported", {
  117379. /**
  117380. * Checks if all the post processes in the effect are supported.
  117381. */
  117382. get: function () {
  117383. for (var index in this._postProcesses) {
  117384. if (this._postProcesses.hasOwnProperty(index)) {
  117385. var pps = this._postProcesses[index];
  117386. for (var ppIndex = 0; ppIndex < pps.length; ppIndex++) {
  117387. if (!pps[ppIndex].isSupported) {
  117388. return false;
  117389. }
  117390. }
  117391. }
  117392. }
  117393. return true;
  117394. },
  117395. enumerable: true,
  117396. configurable: true
  117397. });
  117398. /**
  117399. * Updates the current state of the effect
  117400. * @hidden
  117401. */
  117402. PostProcessRenderEffect.prototype._update = function () {
  117403. };
  117404. /**
  117405. * Attaches the effect on cameras
  117406. * @param cameras The camera to attach to.
  117407. * @hidden
  117408. */
  117409. PostProcessRenderEffect.prototype._attachCameras = function (cameras) {
  117410. var _this = this;
  117411. var cameraKey;
  117412. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  117413. if (!cams) {
  117414. return;
  117415. }
  117416. for (var i = 0; i < cams.length; i++) {
  117417. var camera = cams[i];
  117418. var cameraName = camera.name;
  117419. if (this._singleInstance) {
  117420. cameraKey = 0;
  117421. }
  117422. else {
  117423. cameraKey = cameraName;
  117424. }
  117425. if (!this._postProcesses[cameraKey]) {
  117426. var postProcess = this._getPostProcesses();
  117427. if (postProcess) {
  117428. this._postProcesses[cameraKey] = Array.isArray(postProcess) ? postProcess : [postProcess];
  117429. }
  117430. }
  117431. if (!this._indicesForCamera[cameraName]) {
  117432. this._indicesForCamera[cameraName] = [];
  117433. }
  117434. this._postProcesses[cameraKey].forEach(function (postProcess) {
  117435. var index = camera.attachPostProcess(postProcess);
  117436. _this._indicesForCamera[cameraName].push(index);
  117437. });
  117438. if (!this._cameras[cameraName]) {
  117439. this._cameras[cameraName] = camera;
  117440. }
  117441. }
  117442. };
  117443. /**
  117444. * Detatches the effect on cameras
  117445. * @param cameras The camera to detatch from.
  117446. * @hidden
  117447. */
  117448. PostProcessRenderEffect.prototype._detachCameras = function (cameras) {
  117449. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  117450. if (!cams) {
  117451. return;
  117452. }
  117453. for (var i = 0; i < cams.length; i++) {
  117454. var camera = cams[i];
  117455. var cameraName = camera.name;
  117456. var postProcesses = this._postProcesses[this._singleInstance ? 0 : cameraName];
  117457. if (postProcesses) {
  117458. postProcesses.forEach(function (postProcess) {
  117459. camera.detachPostProcess(postProcess);
  117460. });
  117461. }
  117462. if (this._cameras[cameraName]) {
  117463. this._cameras[cameraName] = null;
  117464. }
  117465. }
  117466. };
  117467. /**
  117468. * Enables the effect on given cameras
  117469. * @param cameras The camera to enable.
  117470. * @hidden
  117471. */
  117472. PostProcessRenderEffect.prototype._enable = function (cameras) {
  117473. var _this = this;
  117474. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  117475. if (!cams) {
  117476. return;
  117477. }
  117478. for (var i = 0; i < cams.length; i++) {
  117479. var camera = cams[i];
  117480. var cameraName = camera.name;
  117481. for (var j = 0; j < this._indicesForCamera[cameraName].length; j++) {
  117482. if (camera._postProcesses[this._indicesForCamera[cameraName][j]] === undefined || camera._postProcesses[this._indicesForCamera[cameraName][j]] === null) {
  117483. this._postProcesses[this._singleInstance ? 0 : cameraName].forEach(function (postProcess) {
  117484. cams[i].attachPostProcess(postProcess, _this._indicesForCamera[cameraName][j]);
  117485. });
  117486. }
  117487. }
  117488. }
  117489. };
  117490. /**
  117491. * Disables the effect on the given cameras
  117492. * @param cameras The camera to disable.
  117493. * @hidden
  117494. */
  117495. PostProcessRenderEffect.prototype._disable = function (cameras) {
  117496. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  117497. if (!cams) {
  117498. return;
  117499. }
  117500. for (var i = 0; i < cams.length; i++) {
  117501. var camera = cams[i];
  117502. var cameraName = camera.name;
  117503. this._postProcesses[this._singleInstance ? 0 : cameraName].forEach(function (postProcess) {
  117504. camera.detachPostProcess(postProcess);
  117505. });
  117506. }
  117507. };
  117508. /**
  117509. * Gets a list of the post processes contained in the effect.
  117510. * @param camera The camera to get the post processes on.
  117511. * @returns The list of the post processes in the effect.
  117512. */
  117513. PostProcessRenderEffect.prototype.getPostProcesses = function (camera) {
  117514. if (this._singleInstance) {
  117515. return this._postProcesses[0];
  117516. }
  117517. else {
  117518. if (!camera) {
  117519. return null;
  117520. }
  117521. return this._postProcesses[camera.name];
  117522. }
  117523. };
  117524. return PostProcessRenderEffect;
  117525. }());
  117526. /***/ }),
  117527. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts":
  117528. /*!*******************************************************************!*\
  117529. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts ***!
  117530. \*******************************************************************/
  117531. /*! exports provided: PostProcessRenderPipeline */
  117532. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117533. "use strict";
  117534. __webpack_require__.r(__webpack_exports__);
  117535. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return PostProcessRenderPipeline; });
  117536. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117537. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  117538. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  117539. /**
  117540. * PostProcessRenderPipeline
  117541. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  117542. */
  117543. var PostProcessRenderPipeline = /** @class */ (function () {
  117544. /**
  117545. * Initializes a PostProcessRenderPipeline
  117546. * @param engine engine to add the pipeline to
  117547. * @param name name of the pipeline
  117548. */
  117549. function PostProcessRenderPipeline(engine, name) {
  117550. this.engine = engine;
  117551. this._name = name;
  117552. this._renderEffects = {};
  117553. this._renderEffectsForIsolatedPass = new Array();
  117554. this._cameras = [];
  117555. }
  117556. Object.defineProperty(PostProcessRenderPipeline.prototype, "name", {
  117557. /**
  117558. * Gets pipeline name
  117559. */
  117560. get: function () {
  117561. return this._name;
  117562. },
  117563. enumerable: true,
  117564. configurable: true
  117565. });
  117566. /**
  117567. * Gets the class name
  117568. * @returns "PostProcessRenderPipeline"
  117569. */
  117570. PostProcessRenderPipeline.prototype.getClassName = function () {
  117571. return "PostProcessRenderPipeline";
  117572. };
  117573. Object.defineProperty(PostProcessRenderPipeline.prototype, "isSupported", {
  117574. /**
  117575. * If all the render effects in the pipeline are supported
  117576. */
  117577. get: function () {
  117578. for (var renderEffectName in this._renderEffects) {
  117579. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  117580. if (!this._renderEffects[renderEffectName].isSupported) {
  117581. return false;
  117582. }
  117583. }
  117584. }
  117585. return true;
  117586. },
  117587. enumerable: true,
  117588. configurable: true
  117589. });
  117590. /**
  117591. * Adds an effect to the pipeline
  117592. * @param renderEffect the effect to add
  117593. */
  117594. PostProcessRenderPipeline.prototype.addEffect = function (renderEffect) {
  117595. this._renderEffects[renderEffect._name] = renderEffect;
  117596. };
  117597. // private
  117598. /** @hidden */
  117599. PostProcessRenderPipeline.prototype._rebuild = function () {
  117600. };
  117601. /** @hidden */
  117602. PostProcessRenderPipeline.prototype._enableEffect = function (renderEffectName, cameras) {
  117603. var renderEffects = this._renderEffects[renderEffectName];
  117604. if (!renderEffects) {
  117605. return;
  117606. }
  117607. renderEffects._enable(_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras));
  117608. };
  117609. /** @hidden */
  117610. PostProcessRenderPipeline.prototype._disableEffect = function (renderEffectName, cameras) {
  117611. var renderEffects = this._renderEffects[renderEffectName];
  117612. if (!renderEffects) {
  117613. return;
  117614. }
  117615. renderEffects._disable(_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras));
  117616. };
  117617. /** @hidden */
  117618. PostProcessRenderPipeline.prototype._attachCameras = function (cameras, unique) {
  117619. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras);
  117620. if (!cams) {
  117621. return;
  117622. }
  117623. var indicesToDelete = [];
  117624. var i;
  117625. for (i = 0; i < cams.length; i++) {
  117626. var camera = cams[i];
  117627. var cameraName = camera.name;
  117628. if (this._cameras.indexOf(camera) === -1) {
  117629. this._cameras[cameraName] = camera;
  117630. }
  117631. else if (unique) {
  117632. indicesToDelete.push(i);
  117633. }
  117634. }
  117635. for (i = 0; i < indicesToDelete.length; i++) {
  117636. cameras.splice(indicesToDelete[i], 1);
  117637. }
  117638. for (var renderEffectName in this._renderEffects) {
  117639. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  117640. this._renderEffects[renderEffectName]._attachCameras(cams);
  117641. }
  117642. }
  117643. };
  117644. /** @hidden */
  117645. PostProcessRenderPipeline.prototype._detachCameras = function (cameras) {
  117646. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras);
  117647. if (!cams) {
  117648. return;
  117649. }
  117650. for (var renderEffectName in this._renderEffects) {
  117651. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  117652. this._renderEffects[renderEffectName]._detachCameras(cams);
  117653. }
  117654. }
  117655. for (var i = 0; i < cams.length; i++) {
  117656. this._cameras.splice(this._cameras.indexOf(cams[i]), 1);
  117657. }
  117658. };
  117659. /** @hidden */
  117660. PostProcessRenderPipeline.prototype._update = function () {
  117661. for (var renderEffectName in this._renderEffects) {
  117662. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  117663. this._renderEffects[renderEffectName]._update();
  117664. }
  117665. }
  117666. for (var i = 0; i < this._cameras.length; i++) {
  117667. var cameraName = this._cameras[i].name;
  117668. if (this._renderEffectsForIsolatedPass[cameraName]) {
  117669. this._renderEffectsForIsolatedPass[cameraName]._update();
  117670. }
  117671. }
  117672. };
  117673. /** @hidden */
  117674. PostProcessRenderPipeline.prototype._reset = function () {
  117675. this._renderEffects = {};
  117676. this._renderEffectsForIsolatedPass = new Array();
  117677. };
  117678. PostProcessRenderPipeline.prototype._enableMSAAOnFirstPostProcess = function (sampleCount) {
  117679. // 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)
  117680. var effectKeys = Object.keys(this._renderEffects);
  117681. if (this.engine.webGLVersion >= 2 && effectKeys.length > 0) {
  117682. var postProcesses = this._renderEffects[effectKeys[0]].getPostProcesses();
  117683. if (postProcesses) {
  117684. postProcesses[0].samples = sampleCount;
  117685. return true;
  117686. }
  117687. }
  117688. return false;
  117689. };
  117690. /**
  117691. * Disposes of the pipeline
  117692. */
  117693. PostProcessRenderPipeline.prototype.dispose = function () {
  117694. // Must be implemented by children
  117695. };
  117696. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117697. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  117698. ], PostProcessRenderPipeline.prototype, "_name", void 0);
  117699. return PostProcessRenderPipeline;
  117700. }());
  117701. /***/ }),
  117702. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts":
  117703. /*!**************************************************************************!*\
  117704. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts ***!
  117705. \**************************************************************************/
  117706. /*! exports provided: PostProcessRenderPipelineManager */
  117707. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117708. "use strict";
  117709. __webpack_require__.r(__webpack_exports__);
  117710. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return PostProcessRenderPipelineManager; });
  117711. /**
  117712. * PostProcessRenderPipelineManager class
  117713. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  117714. */
  117715. var PostProcessRenderPipelineManager = /** @class */ (function () {
  117716. /**
  117717. * Initializes a PostProcessRenderPipelineManager
  117718. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  117719. */
  117720. function PostProcessRenderPipelineManager() {
  117721. this._renderPipelines = {};
  117722. }
  117723. Object.defineProperty(PostProcessRenderPipelineManager.prototype, "supportedPipelines", {
  117724. /**
  117725. * Gets the list of supported render pipelines
  117726. */
  117727. get: function () {
  117728. var result = [];
  117729. for (var renderPipelineName in this._renderPipelines) {
  117730. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  117731. var pipeline = this._renderPipelines[renderPipelineName];
  117732. if (pipeline.isSupported) {
  117733. result.push(pipeline);
  117734. }
  117735. }
  117736. }
  117737. return result;
  117738. },
  117739. enumerable: true,
  117740. configurable: true
  117741. });
  117742. /**
  117743. * Adds a pipeline to the manager
  117744. * @param renderPipeline The pipeline to add
  117745. */
  117746. PostProcessRenderPipelineManager.prototype.addPipeline = function (renderPipeline) {
  117747. this._renderPipelines[renderPipeline._name] = renderPipeline;
  117748. };
  117749. /**
  117750. * Attaches a camera to the pipeline
  117751. * @param renderPipelineName The name of the pipeline to attach to
  117752. * @param cameras the camera to attach
  117753. * @param unique if the camera can be attached multiple times to the pipeline
  117754. */
  117755. PostProcessRenderPipelineManager.prototype.attachCamerasToRenderPipeline = function (renderPipelineName, cameras, unique) {
  117756. if (unique === void 0) { unique = false; }
  117757. var renderPipeline = this._renderPipelines[renderPipelineName];
  117758. if (!renderPipeline) {
  117759. return;
  117760. }
  117761. renderPipeline._attachCameras(cameras, unique);
  117762. };
  117763. /**
  117764. * Detaches a camera from the pipeline
  117765. * @param renderPipelineName The name of the pipeline to detach from
  117766. * @param cameras the camera to detach
  117767. */
  117768. PostProcessRenderPipelineManager.prototype.detachCamerasFromRenderPipeline = function (renderPipelineName, cameras) {
  117769. var renderPipeline = this._renderPipelines[renderPipelineName];
  117770. if (!renderPipeline) {
  117771. return;
  117772. }
  117773. renderPipeline._detachCameras(cameras);
  117774. };
  117775. /**
  117776. * Enables an effect by name on a pipeline
  117777. * @param renderPipelineName the name of the pipeline to enable the effect in
  117778. * @param renderEffectName the name of the effect to enable
  117779. * @param cameras the cameras that the effect should be enabled on
  117780. */
  117781. PostProcessRenderPipelineManager.prototype.enableEffectInPipeline = function (renderPipelineName, renderEffectName, cameras) {
  117782. var renderPipeline = this._renderPipelines[renderPipelineName];
  117783. if (!renderPipeline) {
  117784. return;
  117785. }
  117786. renderPipeline._enableEffect(renderEffectName, cameras);
  117787. };
  117788. /**
  117789. * Disables an effect by name on a pipeline
  117790. * @param renderPipelineName the name of the pipeline to disable the effect in
  117791. * @param renderEffectName the name of the effect to disable
  117792. * @param cameras the cameras that the effect should be disabled on
  117793. */
  117794. PostProcessRenderPipelineManager.prototype.disableEffectInPipeline = function (renderPipelineName, renderEffectName, cameras) {
  117795. var renderPipeline = this._renderPipelines[renderPipelineName];
  117796. if (!renderPipeline) {
  117797. return;
  117798. }
  117799. renderPipeline._disableEffect(renderEffectName, cameras);
  117800. };
  117801. /**
  117802. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  117803. */
  117804. PostProcessRenderPipelineManager.prototype.update = function () {
  117805. for (var renderPipelineName in this._renderPipelines) {
  117806. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  117807. var pipeline = this._renderPipelines[renderPipelineName];
  117808. if (!pipeline.isSupported) {
  117809. pipeline.dispose();
  117810. delete this._renderPipelines[renderPipelineName];
  117811. }
  117812. else {
  117813. pipeline._update();
  117814. }
  117815. }
  117816. }
  117817. };
  117818. /** @hidden */
  117819. PostProcessRenderPipelineManager.prototype._rebuild = function () {
  117820. for (var renderPipelineName in this._renderPipelines) {
  117821. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  117822. var pipeline = this._renderPipelines[renderPipelineName];
  117823. pipeline._rebuild();
  117824. }
  117825. }
  117826. };
  117827. /**
  117828. * Disposes of the manager and pipelines
  117829. */
  117830. PostProcessRenderPipelineManager.prototype.dispose = function () {
  117831. for (var renderPipelineName in this._renderPipelines) {
  117832. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  117833. var pipeline = this._renderPipelines[renderPipelineName];
  117834. pipeline.dispose();
  117835. }
  117836. }
  117837. };
  117838. return PostProcessRenderPipelineManager;
  117839. }());
  117840. /***/ }),
  117841. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts":
  117842. /*!****************************************************************************************!*\
  117843. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts ***!
  117844. \****************************************************************************************/
  117845. /*! exports provided: PostProcessRenderPipelineManagerSceneComponent */
  117846. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117847. "use strict";
  117848. __webpack_require__.r(__webpack_exports__);
  117849. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return PostProcessRenderPipelineManagerSceneComponent; });
  117850. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  117851. /* harmony import */ var _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcessRenderPipelineManager */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts");
  117852. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  117853. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype, "postProcessRenderPipelineManager", {
  117854. get: function () {
  117855. if (!this._postProcessRenderPipelineManager) {
  117856. // Register the G Buffer component to the scene.
  117857. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_POSTPROCESSRENDERPIPELINEMANAGER);
  117858. if (!component) {
  117859. component = new PostProcessRenderPipelineManagerSceneComponent(this);
  117860. this._addComponent(component);
  117861. }
  117862. this._postProcessRenderPipelineManager = new _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderPipelineManager"]();
  117863. }
  117864. return this._postProcessRenderPipelineManager;
  117865. },
  117866. enumerable: true,
  117867. configurable: true
  117868. });
  117869. /**
  117870. * Defines the Render Pipeline scene component responsible to rendering pipelines
  117871. */
  117872. var PostProcessRenderPipelineManagerSceneComponent = /** @class */ (function () {
  117873. /**
  117874. * Creates a new instance of the component for the given scene
  117875. * @param scene Defines the scene to register the component in
  117876. */
  117877. function PostProcessRenderPipelineManagerSceneComponent(scene) {
  117878. /**
  117879. * The component name helpfull to identify the component in the list of scene components.
  117880. */
  117881. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_POSTPROCESSRENDERPIPELINEMANAGER;
  117882. this.scene = scene;
  117883. }
  117884. /**
  117885. * Registers the component in a given scene
  117886. */
  117887. PostProcessRenderPipelineManagerSceneComponent.prototype.register = function () {
  117888. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER, this, this._gatherRenderTargets);
  117889. };
  117890. /**
  117891. * Rebuilds the elements related to this component in case of
  117892. * context lost for instance.
  117893. */
  117894. PostProcessRenderPipelineManagerSceneComponent.prototype.rebuild = function () {
  117895. if (this.scene._postProcessRenderPipelineManager) {
  117896. this.scene._postProcessRenderPipelineManager._rebuild();
  117897. }
  117898. };
  117899. /**
  117900. * Disposes the component and the associated ressources
  117901. */
  117902. PostProcessRenderPipelineManagerSceneComponent.prototype.dispose = function () {
  117903. if (this.scene._postProcessRenderPipelineManager) {
  117904. this.scene._postProcessRenderPipelineManager.dispose();
  117905. }
  117906. };
  117907. PostProcessRenderPipelineManagerSceneComponent.prototype._gatherRenderTargets = function () {
  117908. if (this.scene._postProcessRenderPipelineManager) {
  117909. this.scene._postProcessRenderPipelineManager.update();
  117910. }
  117911. };
  117912. return PostProcessRenderPipelineManagerSceneComponent;
  117913. }());
  117914. /***/ }),
  117915. /***/ "./PostProcesses/anaglyphPostProcess.ts":
  117916. /*!**********************************************!*\
  117917. !*** ./PostProcesses/anaglyphPostProcess.ts ***!
  117918. \**********************************************/
  117919. /*! exports provided: AnaglyphPostProcess */
  117920. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117921. "use strict";
  117922. __webpack_require__.r(__webpack_exports__);
  117923. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return AnaglyphPostProcess; });
  117924. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117925. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117926. /* harmony import */ var _Shaders_anaglyph_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/anaglyph.fragment */ "./Shaders/anaglyph.fragment.ts");
  117927. /**
  117928. * Postprocess used to generate anaglyphic rendering
  117929. */
  117930. var AnaglyphPostProcess = /** @class */ (function (_super) {
  117931. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphPostProcess, _super);
  117932. /**
  117933. * Creates a new AnaglyphPostProcess
  117934. * @param name defines postprocess name
  117935. * @param options defines creation options or target ratio scale
  117936. * @param rigCameras defines cameras using this postprocess
  117937. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  117938. * @param engine defines hosting engine
  117939. * @param reusable defines if the postprocess will be reused multiple times per frame
  117940. */
  117941. function AnaglyphPostProcess(name, options, rigCameras, samplingMode, engine, reusable) {
  117942. var _this = _super.call(this, name, "anaglyph", null, ["leftSampler"], options, rigCameras[1], samplingMode, engine, reusable) || this;
  117943. _this._passedProcess = rigCameras[0]._rigPostProcess;
  117944. _this.onApplyObservable.add(function (effect) {
  117945. effect.setTextureFromPostProcess("leftSampler", _this._passedProcess);
  117946. });
  117947. return _this;
  117948. }
  117949. return AnaglyphPostProcess;
  117950. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  117951. /***/ }),
  117952. /***/ "./PostProcesses/blackAndWhitePostProcess.ts":
  117953. /*!***************************************************!*\
  117954. !*** ./PostProcesses/blackAndWhitePostProcess.ts ***!
  117955. \***************************************************/
  117956. /*! exports provided: BlackAndWhitePostProcess */
  117957. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117958. "use strict";
  117959. __webpack_require__.r(__webpack_exports__);
  117960. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return BlackAndWhitePostProcess; });
  117961. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117962. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117963. /* harmony import */ var _Shaders_blackAndWhite_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/blackAndWhite.fragment */ "./Shaders/blackAndWhite.fragment.ts");
  117964. /**
  117965. * Post process used to render in black and white
  117966. */
  117967. var BlackAndWhitePostProcess = /** @class */ (function (_super) {
  117968. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BlackAndWhitePostProcess, _super);
  117969. /**
  117970. * Creates a black and white post process
  117971. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  117972. * @param name The name of the effect.
  117973. * @param options The required width/height ratio to downsize to before computing the render pass.
  117974. * @param camera The camera to apply the render pass to.
  117975. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117976. * @param engine The engine which the post process will be applied. (default: current engine)
  117977. * @param reusable If the post process can be reused on the same frame. (default: false)
  117978. */
  117979. function BlackAndWhitePostProcess(name, options, camera, samplingMode, engine, reusable) {
  117980. var _this = _super.call(this, name, "blackAndWhite", ["degree"], null, options, camera, samplingMode, engine, reusable) || this;
  117981. /**
  117982. * Linear about to convert he result to black and white (default: 1)
  117983. */
  117984. _this.degree = 1;
  117985. _this.onApplyObservable.add(function (effect) {
  117986. effect.setFloat("degree", _this.degree);
  117987. });
  117988. return _this;
  117989. }
  117990. return BlackAndWhitePostProcess;
  117991. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  117992. /***/ }),
  117993. /***/ "./PostProcesses/bloomEffect.ts":
  117994. /*!**************************************!*\
  117995. !*** ./PostProcesses/bloomEffect.ts ***!
  117996. \**************************************/
  117997. /*! exports provided: BloomEffect */
  117998. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117999. "use strict";
  118000. __webpack_require__.r(__webpack_exports__);
  118001. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return BloomEffect; });
  118002. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118003. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  118004. /* harmony import */ var _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./extractHighlightsPostProcess */ "./PostProcesses/extractHighlightsPostProcess.ts");
  118005. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  118006. /* harmony import */ var _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bloomMergePostProcess */ "./PostProcesses/bloomMergePostProcess.ts");
  118007. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  118008. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  118009. /**
  118010. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  118011. */
  118012. var BloomEffect = /** @class */ (function (_super) {
  118013. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BloomEffect, _super);
  118014. /**
  118015. * Creates a new instance of @see BloomEffect
  118016. * @param scene The scene the effect belongs to.
  118017. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  118018. * @param bloomKernel The size of the kernel to be used when applying the blur.
  118019. * @param bloomWeight The the strength of bloom.
  118020. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  118021. * @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)
  118022. */
  118023. function BloomEffect(scene, bloomScale, bloomWeight, bloomKernel, pipelineTextureType, blockCompilation) {
  118024. if (pipelineTextureType === void 0) { pipelineTextureType = 0; }
  118025. if (blockCompilation === void 0) { blockCompilation = false; }
  118026. var _this = _super.call(this, scene.getEngine(), "bloom", function () {
  118027. return _this._effects;
  118028. }, true) || this;
  118029. _this.bloomScale = bloomScale;
  118030. /**
  118031. * @hidden Internal
  118032. */
  118033. _this._effects = [];
  118034. _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);
  118035. _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);
  118036. _this._blurX.alwaysForcePOT = true;
  118037. _this._blurX.autoClear = false;
  118038. _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);
  118039. _this._blurY.alwaysForcePOT = true;
  118040. _this._blurY.autoClear = false;
  118041. _this.kernel = bloomKernel;
  118042. _this._effects = [_this._downscale, _this._blurX, _this._blurY];
  118043. _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);
  118044. _this._merge.autoClear = false;
  118045. _this._effects.push(_this._merge);
  118046. return _this;
  118047. }
  118048. Object.defineProperty(BloomEffect.prototype, "threshold", {
  118049. /**
  118050. * The luminance threshold to find bright areas of the image to bloom.
  118051. */
  118052. get: function () {
  118053. return this._downscale.threshold;
  118054. },
  118055. set: function (value) {
  118056. this._downscale.threshold = value;
  118057. },
  118058. enumerable: true,
  118059. configurable: true
  118060. });
  118061. Object.defineProperty(BloomEffect.prototype, "weight", {
  118062. /**
  118063. * The strength of the bloom.
  118064. */
  118065. get: function () {
  118066. return this._merge.weight;
  118067. },
  118068. set: function (value) {
  118069. this._merge.weight = value;
  118070. },
  118071. enumerable: true,
  118072. configurable: true
  118073. });
  118074. Object.defineProperty(BloomEffect.prototype, "kernel", {
  118075. /**
  118076. * Specifies the size of the bloom blur kernel, relative to the final output size
  118077. */
  118078. get: function () {
  118079. return this._blurX.kernel / this.bloomScale;
  118080. },
  118081. set: function (value) {
  118082. this._blurX.kernel = value * this.bloomScale;
  118083. this._blurY.kernel = value * this.bloomScale;
  118084. },
  118085. enumerable: true,
  118086. configurable: true
  118087. });
  118088. /**
  118089. * Disposes each of the internal effects for a given camera.
  118090. * @param camera The camera to dispose the effect on.
  118091. */
  118092. BloomEffect.prototype.disposeEffects = function (camera) {
  118093. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  118094. this._effects[effectIndex].dispose(camera);
  118095. }
  118096. };
  118097. /**
  118098. * @hidden Internal
  118099. */
  118100. BloomEffect.prototype._updateEffects = function () {
  118101. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  118102. this._effects[effectIndex].updateEffect();
  118103. }
  118104. };
  118105. /**
  118106. * Internal
  118107. * @returns if all the contained post processes are ready.
  118108. * @hidden
  118109. */
  118110. BloomEffect.prototype._isReady = function () {
  118111. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  118112. if (!this._effects[effectIndex].isReady()) {
  118113. return false;
  118114. }
  118115. }
  118116. return true;
  118117. };
  118118. return BloomEffect;
  118119. }(_PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderEffect"]));
  118120. /***/ }),
  118121. /***/ "./PostProcesses/bloomMergePostProcess.ts":
  118122. /*!************************************************!*\
  118123. !*** ./PostProcesses/bloomMergePostProcess.ts ***!
  118124. \************************************************/
  118125. /*! exports provided: BloomMergePostProcess */
  118126. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118127. "use strict";
  118128. __webpack_require__.r(__webpack_exports__);
  118129. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return BloomMergePostProcess; });
  118130. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118131. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118132. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118133. /* harmony import */ var _Shaders_bloomMerge_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/bloomMerge.fragment */ "./Shaders/bloomMerge.fragment.ts");
  118134. /**
  118135. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  118136. */
  118137. var BloomMergePostProcess = /** @class */ (function (_super) {
  118138. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BloomMergePostProcess, _super);
  118139. /**
  118140. * Creates a new instance of @see BloomMergePostProcess
  118141. * @param name The name of the effect.
  118142. * @param originalFromInput Post process which's input will be used for the merge.
  118143. * @param blurred Blurred highlights post process which's output will be used.
  118144. * @param weight Weight of the bloom to be added to the original input.
  118145. * @param options The required width/height ratio to downsize to before computing the render pass.
  118146. * @param camera The camera to apply the render pass to.
  118147. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118148. * @param engine The engine which the post process will be applied. (default: current engine)
  118149. * @param reusable If the post process can be reused on the same frame. (default: false)
  118150. * @param textureType Type of textures used when performing the post process. (default: 0)
  118151. * @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)
  118152. */
  118153. function BloomMergePostProcess(name, originalFromInput, blurred,
  118154. /** Weight of the bloom to be added to the original input. */
  118155. weight, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  118156. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  118157. if (blockCompilation === void 0) { blockCompilation = false; }
  118158. var _this = _super.call(this, name, "bloomMerge", ["bloomWeight"], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2", "bloomBlur"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, true) || this;
  118159. _this.weight = weight;
  118160. _this.onApplyObservable.add(function (effect) {
  118161. effect.setTextureFromPostProcess("textureSampler", originalFromInput);
  118162. effect.setTextureFromPostProcessOutput("bloomBlur", blurred);
  118163. effect.setFloat("bloomWeight", _this.weight);
  118164. });
  118165. if (!blockCompilation) {
  118166. _this.updateEffect();
  118167. }
  118168. return _this;
  118169. }
  118170. return BloomMergePostProcess;
  118171. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  118172. /***/ }),
  118173. /***/ "./PostProcesses/blurPostProcess.ts":
  118174. /*!******************************************!*\
  118175. !*** ./PostProcesses/blurPostProcess.ts ***!
  118176. \******************************************/
  118177. /*! exports provided: BlurPostProcess */
  118178. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118179. "use strict";
  118180. __webpack_require__.r(__webpack_exports__);
  118181. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return BlurPostProcess; });
  118182. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118183. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118184. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  118185. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118186. /* harmony import */ var _Shaders_kernelBlur_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/kernelBlur.fragment */ "./Shaders/kernelBlur.fragment.ts");
  118187. /* harmony import */ var _Shaders_kernelBlur_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/kernelBlur.vertex */ "./Shaders/kernelBlur.vertex.ts");
  118188. /**
  118189. * The Blur Post Process which blurs an image based on a kernel and direction.
  118190. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  118191. */
  118192. var BlurPostProcess = /** @class */ (function (_super) {
  118193. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BlurPostProcess, _super);
  118194. /**
  118195. * Creates a new instance BlurPostProcess
  118196. * @param name The name of the effect.
  118197. * @param direction The direction in which to blur the image.
  118198. * @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.
  118199. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  118200. * @param camera The camera to apply the render pass to.
  118201. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118202. * @param engine The engine which the post process will be applied. (default: current engine)
  118203. * @param reusable If the post process can be reused on the same frame. (default: false)
  118204. * @param textureType Type of textures used when performing the post process. (default: 0)
  118205. * @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)
  118206. */
  118207. function BlurPostProcess(name,
  118208. /** The direction in which to blur the image. */
  118209. direction, kernel, options, camera, samplingMode, engine, reusable, textureType, defines, blockCompilation) {
  118210. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE; }
  118211. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  118212. if (defines === void 0) { defines = ""; }
  118213. if (blockCompilation === void 0) { blockCompilation = false; }
  118214. 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;
  118215. _this.direction = direction;
  118216. _this.blockCompilation = blockCompilation;
  118217. _this._packedFloat = false;
  118218. _this._staticDefines = "";
  118219. _this._staticDefines = defines;
  118220. _this.onApplyObservable.add(function (effect) {
  118221. if (_this._outputTexture) {
  118222. effect.setFloat2('delta', (1 / _this._outputTexture.width) * _this.direction.x, (1 / _this._outputTexture.height) * _this.direction.y);
  118223. }
  118224. else {
  118225. effect.setFloat2('delta', (1 / _this.width) * _this.direction.x, (1 / _this.height) * _this.direction.y);
  118226. }
  118227. });
  118228. _this.kernel = kernel;
  118229. return _this;
  118230. }
  118231. Object.defineProperty(BlurPostProcess.prototype, "kernel", {
  118232. /**
  118233. * Gets the length in pixels of the blur sample region
  118234. */
  118235. get: function () {
  118236. return this._idealKernel;
  118237. },
  118238. /**
  118239. * Sets the length in pixels of the blur sample region
  118240. */
  118241. set: function (v) {
  118242. if (this._idealKernel === v) {
  118243. return;
  118244. }
  118245. v = Math.max(v, 1);
  118246. this._idealKernel = v;
  118247. this._kernel = this._nearestBestKernel(v);
  118248. if (!this.blockCompilation) {
  118249. this._updateParameters();
  118250. }
  118251. },
  118252. enumerable: true,
  118253. configurable: true
  118254. });
  118255. Object.defineProperty(BlurPostProcess.prototype, "packedFloat", {
  118256. /**
  118257. * Gets wether or not the blur is unpacking/repacking floats
  118258. */
  118259. get: function () {
  118260. return this._packedFloat;
  118261. },
  118262. /**
  118263. * Sets wether or not the blur needs to unpack/repack floats
  118264. */
  118265. set: function (v) {
  118266. if (this._packedFloat === v) {
  118267. return;
  118268. }
  118269. this._packedFloat = v;
  118270. if (!this.blockCompilation) {
  118271. this._updateParameters();
  118272. }
  118273. },
  118274. enumerable: true,
  118275. configurable: true
  118276. });
  118277. /**
  118278. * Updates the effect with the current post process compile time values and recompiles the shader.
  118279. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  118280. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  118281. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  118282. * @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
  118283. * @param onCompiled Called when the shader has been compiled.
  118284. * @param onError Called if there is an error when compiling a shader.
  118285. */
  118286. BlurPostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  118287. if (defines === void 0) { defines = null; }
  118288. if (uniforms === void 0) { uniforms = null; }
  118289. if (samplers === void 0) { samplers = null; }
  118290. this._updateParameters(onCompiled, onError);
  118291. };
  118292. BlurPostProcess.prototype._updateParameters = function (onCompiled, onError) {
  118293. // Generate sampling offsets and weights
  118294. var N = this._kernel;
  118295. var centerIndex = (N - 1) / 2;
  118296. // Generate Gaussian sampling weights over kernel
  118297. var offsets = [];
  118298. var weights = [];
  118299. var totalWeight = 0;
  118300. for (var i = 0; i < N; i++) {
  118301. var u = i / (N - 1);
  118302. var w = this._gaussianWeight(u * 2.0 - 1);
  118303. offsets[i] = (i - centerIndex);
  118304. weights[i] = w;
  118305. totalWeight += w;
  118306. }
  118307. // Normalize weights
  118308. for (var i = 0; i < weights.length; i++) {
  118309. weights[i] /= totalWeight;
  118310. }
  118311. // Optimize: combine samples to take advantage of hardware linear sampling
  118312. // Walk from left to center, combining pairs (symmetrically)
  118313. var linearSamplingWeights = [];
  118314. var linearSamplingOffsets = [];
  118315. var linearSamplingMap = [];
  118316. for (var i = 0; i <= centerIndex; i += 2) {
  118317. var j = Math.min(i + 1, Math.floor(centerIndex));
  118318. var singleCenterSample = i === j;
  118319. if (singleCenterSample) {
  118320. linearSamplingMap.push({ o: offsets[i], w: weights[i] });
  118321. }
  118322. else {
  118323. var sharedCell = j === centerIndex;
  118324. var weightLinear = (weights[i] + weights[j] * (sharedCell ? .5 : 1.));
  118325. var offsetLinear = offsets[i] + 1 / (1 + weights[i] / weights[j]);
  118326. if (offsetLinear === 0) {
  118327. linearSamplingMap.push({ o: offsets[i], w: weights[i] });
  118328. linearSamplingMap.push({ o: offsets[i + 1], w: weights[i + 1] });
  118329. }
  118330. else {
  118331. linearSamplingMap.push({ o: offsetLinear, w: weightLinear });
  118332. linearSamplingMap.push({ o: -offsetLinear, w: weightLinear });
  118333. }
  118334. }
  118335. }
  118336. for (var i = 0; i < linearSamplingMap.length; i++) {
  118337. linearSamplingOffsets[i] = linearSamplingMap[i].o;
  118338. linearSamplingWeights[i] = linearSamplingMap[i].w;
  118339. }
  118340. // Replace with optimized
  118341. offsets = linearSamplingOffsets;
  118342. weights = linearSamplingWeights;
  118343. // Generate shaders
  118344. var maxVaryingRows = this.getEngine().getCaps().maxVaryingVectors;
  118345. var freeVaryingVec2 = Math.max(maxVaryingRows, 0.) - 1; // Because of sampleCenter
  118346. var varyingCount = Math.min(offsets.length, freeVaryingVec2);
  118347. var defines = "";
  118348. defines += this._staticDefines;
  118349. // The DOF fragment should ignore the center pixel when looping as it is handled manualy in the fragment shader.
  118350. if (this._staticDefines.indexOf("DOF") != -1) {
  118351. defines += "#define CENTER_WEIGHT " + this._glslFloat(weights[varyingCount - 1]) + "\r\n";
  118352. varyingCount--;
  118353. }
  118354. for (var i = 0; i < varyingCount; i++) {
  118355. defines += "#define KERNEL_OFFSET" + i + " " + this._glslFloat(offsets[i]) + "\r\n";
  118356. defines += "#define KERNEL_WEIGHT" + i + " " + this._glslFloat(weights[i]) + "\r\n";
  118357. }
  118358. var depCount = 0;
  118359. for (var i = freeVaryingVec2; i < offsets.length; i++) {
  118360. defines += "#define KERNEL_DEP_OFFSET" + depCount + " " + this._glslFloat(offsets[i]) + "\r\n";
  118361. defines += "#define KERNEL_DEP_WEIGHT" + depCount + " " + this._glslFloat(weights[i]) + "\r\n";
  118362. depCount++;
  118363. }
  118364. if (this.packedFloat) {
  118365. defines += "#define PACKEDFLOAT 1";
  118366. }
  118367. this.blockCompilation = false;
  118368. _super.prototype.updateEffect.call(this, defines, null, null, {
  118369. varyingCount: varyingCount,
  118370. depCount: depCount
  118371. }, onCompiled, onError);
  118372. };
  118373. /**
  118374. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  118375. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  118376. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  118377. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  118378. * The gaps between physical kernels are compensated for in the weighting of the samples
  118379. * @param idealKernel Ideal blur kernel.
  118380. * @return Nearest best kernel.
  118381. */
  118382. BlurPostProcess.prototype._nearestBestKernel = function (idealKernel) {
  118383. var v = Math.round(idealKernel);
  118384. for (var _i = 0, _a = [v, v - 1, v + 1, v - 2, v + 2]; _i < _a.length; _i++) {
  118385. var k = _a[_i];
  118386. if (((k % 2) !== 0) && ((Math.floor(k / 2) % 2) === 0) && k > 0) {
  118387. return Math.max(k, 3);
  118388. }
  118389. }
  118390. return Math.max(v, 3);
  118391. };
  118392. /**
  118393. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  118394. * @param x The point on the Gaussian distribution to sample.
  118395. * @return the value of the Gaussian function at x.
  118396. */
  118397. BlurPostProcess.prototype._gaussianWeight = function (x) {
  118398. //reference: Engines/ImageProcessingBlur.cpp #dcc760
  118399. // We are evaluating the Gaussian (normal) distribution over a kernel parameter space of [-1,1],
  118400. // so we truncate at three standard deviations by setting stddev (sigma) to 1/3.
  118401. // The choice of 3-sigma truncation is common but arbitrary, and means that the signal is
  118402. // truncated at around 1.3% of peak strength.
  118403. //the distribution is scaled to account for the difference between the actual kernel size and the requested kernel size
  118404. var sigma = (1 / 3);
  118405. var denominator = Math.sqrt(2.0 * Math.PI) * sigma;
  118406. var exponent = -((x * x) / (2.0 * sigma * sigma));
  118407. var weight = (1.0 / denominator) * Math.exp(exponent);
  118408. return weight;
  118409. };
  118410. /**
  118411. * Generates a string that can be used as a floating point number in GLSL.
  118412. * @param x Value to print.
  118413. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  118414. * @return GLSL float string.
  118415. */
  118416. BlurPostProcess.prototype._glslFloat = function (x, decimalFigures) {
  118417. if (decimalFigures === void 0) { decimalFigures = 8; }
  118418. return x.toFixed(decimalFigures).replace(/0+$/, '');
  118419. };
  118420. return BlurPostProcess;
  118421. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  118422. /***/ }),
  118423. /***/ "./PostProcesses/chromaticAberrationPostProcess.ts":
  118424. /*!*********************************************************!*\
  118425. !*** ./PostProcesses/chromaticAberrationPostProcess.ts ***!
  118426. \*********************************************************/
  118427. /*! exports provided: ChromaticAberrationPostProcess */
  118428. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118429. "use strict";
  118430. __webpack_require__.r(__webpack_exports__);
  118431. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return ChromaticAberrationPostProcess; });
  118432. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118433. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  118434. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118435. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118436. /* harmony import */ var _Shaders_chromaticAberration_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/chromaticAberration.fragment */ "./Shaders/chromaticAberration.fragment.ts");
  118437. /**
  118438. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  118439. */
  118440. var ChromaticAberrationPostProcess = /** @class */ (function (_super) {
  118441. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ChromaticAberrationPostProcess, _super);
  118442. /**
  118443. * Creates a new instance ChromaticAberrationPostProcess
  118444. * @param name The name of the effect.
  118445. * @param screenWidth The width of the screen to apply the effect on.
  118446. * @param screenHeight The height of the screen to apply the effect on.
  118447. * @param options The required width/height ratio to downsize to before computing the render pass.
  118448. * @param camera The camera to apply the render pass to.
  118449. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118450. * @param engine The engine which the post process will be applied. (default: current engine)
  118451. * @param reusable If the post process can be reused on the same frame. (default: false)
  118452. * @param textureType Type of textures used when performing the post process. (default: 0)
  118453. * @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)
  118454. */
  118455. function ChromaticAberrationPostProcess(name, screenWidth, screenHeight, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  118456. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  118457. if (blockCompilation === void 0) { blockCompilation = false; }
  118458. 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;
  118459. /**
  118460. * The amount of seperation of rgb channels (default: 30)
  118461. */
  118462. _this.aberrationAmount = 30;
  118463. /**
  118464. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  118465. */
  118466. _this.radialIntensity = 0;
  118467. /**
  118468. * 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))
  118469. */
  118470. _this.direction = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0.707, 0.707);
  118471. /**
  118472. * 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))
  118473. */
  118474. _this.centerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0.5, 0.5);
  118475. _this.onApplyObservable.add(function (effect) {
  118476. effect.setFloat('chromatic_aberration', _this.aberrationAmount);
  118477. effect.setFloat('screen_width', screenWidth);
  118478. effect.setFloat('screen_height', screenHeight);
  118479. effect.setFloat('radialIntensity', _this.radialIntensity);
  118480. effect.setFloat2('direction', _this.direction.x, _this.direction.y);
  118481. effect.setFloat2('centerPosition', _this.centerPosition.x, _this.centerPosition.y);
  118482. });
  118483. return _this;
  118484. }
  118485. return ChromaticAberrationPostProcess;
  118486. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  118487. /***/ }),
  118488. /***/ "./PostProcesses/circleOfConfusionPostProcess.ts":
  118489. /*!*******************************************************!*\
  118490. !*** ./PostProcesses/circleOfConfusionPostProcess.ts ***!
  118491. \*******************************************************/
  118492. /*! exports provided: CircleOfConfusionPostProcess */
  118493. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118494. "use strict";
  118495. __webpack_require__.r(__webpack_exports__);
  118496. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return CircleOfConfusionPostProcess; });
  118497. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118498. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118499. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  118500. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118501. /* harmony import */ var _Shaders_circleOfConfusion_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/circleOfConfusion.fragment */ "./Shaders/circleOfConfusion.fragment.ts");
  118502. /**
  118503. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  118504. */
  118505. var CircleOfConfusionPostProcess = /** @class */ (function (_super) {
  118506. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CircleOfConfusionPostProcess, _super);
  118507. /**
  118508. * Creates a new instance CircleOfConfusionPostProcess
  118509. * @param name The name of the effect.
  118510. * @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.
  118511. * @param options The required width/height ratio to downsize to before computing the render pass.
  118512. * @param camera The camera to apply the render pass to.
  118513. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118514. * @param engine The engine which the post process will be applied. (default: current engine)
  118515. * @param reusable If the post process can be reused on the same frame. (default: false)
  118516. * @param textureType Type of textures used when performing the post process. (default: 0)
  118517. * @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)
  118518. */
  118519. function CircleOfConfusionPostProcess(name, depthTexture, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  118520. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  118521. if (blockCompilation === void 0) { blockCompilation = false; }
  118522. var _this = _super.call(this, name, "circleOfConfusion", ["cameraMinMaxZ", "focusDistance", "cocPrecalculation"], ["depthSampler"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  118523. /**
  118524. * 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.
  118525. */
  118526. _this.lensSize = 50;
  118527. /**
  118528. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  118529. */
  118530. _this.fStop = 1.4;
  118531. /**
  118532. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  118533. */
  118534. _this.focusDistance = 2000;
  118535. /**
  118536. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  118537. */
  118538. _this.focalLength = 50;
  118539. _this._depthTexture = null;
  118540. _this._depthTexture = depthTexture;
  118541. _this.onApplyObservable.add(function (effect) {
  118542. if (!_this._depthTexture) {
  118543. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("No depth texture set on CircleOfConfusionPostProcess");
  118544. return;
  118545. }
  118546. effect.setTexture("depthSampler", _this._depthTexture);
  118547. // Circle of confusion calculation, See https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch23.html
  118548. var aperture = _this.lensSize / _this.fStop;
  118549. var cocPrecalculation = ((aperture * _this.focalLength) / ((_this.focusDistance - _this.focalLength))); // * ((this.focusDistance - pixelDistance)/pixelDistance) [This part is done in shader]
  118550. effect.setFloat('focusDistance', _this.focusDistance);
  118551. effect.setFloat('cocPrecalculation', cocPrecalculation);
  118552. effect.setFloat2('cameraMinMaxZ', _this._depthTexture.activeCamera.minZ, _this._depthTexture.activeCamera.maxZ);
  118553. });
  118554. return _this;
  118555. }
  118556. Object.defineProperty(CircleOfConfusionPostProcess.prototype, "depthTexture", {
  118557. /**
  118558. * 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.
  118559. */
  118560. set: function (value) {
  118561. this._depthTexture = value;
  118562. },
  118563. enumerable: true,
  118564. configurable: true
  118565. });
  118566. return CircleOfConfusionPostProcess;
  118567. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  118568. /***/ }),
  118569. /***/ "./PostProcesses/colorCorrectionPostProcess.ts":
  118570. /*!*****************************************************!*\
  118571. !*** ./PostProcesses/colorCorrectionPostProcess.ts ***!
  118572. \*****************************************************/
  118573. /*! exports provided: ColorCorrectionPostProcess */
  118574. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118575. "use strict";
  118576. __webpack_require__.r(__webpack_exports__);
  118577. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return ColorCorrectionPostProcess; });
  118578. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118579. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118580. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  118581. /* harmony import */ var _Shaders_colorCorrection_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/colorCorrection.fragment */ "./Shaders/colorCorrection.fragment.ts");
  118582. /**
  118583. *
  118584. * This post-process allows the modification of rendered colors by using
  118585. * a 'look-up table' (LUT). This effect is also called Color Grading.
  118586. *
  118587. * The object needs to be provided an url to a texture containing the color
  118588. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  118589. * Use an image editing software to tweak the LUT to match your needs.
  118590. *
  118591. * For an example of a color LUT, see here:
  118592. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  118593. * For explanations on color grading, see here:
  118594. * @see http://udn.epicgames.com/Three/ColorGrading.html
  118595. *
  118596. */
  118597. var ColorCorrectionPostProcess = /** @class */ (function (_super) {
  118598. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorCorrectionPostProcess, _super);
  118599. function ColorCorrectionPostProcess(name, colorTableUrl, options, camera, samplingMode, engine, reusable) {
  118600. var _this = _super.call(this, name, 'colorCorrection', null, ['colorTable'], options, camera, samplingMode, engine, reusable) || this;
  118601. _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);
  118602. _this._colorTableTexture.anisotropicFilteringLevel = 1;
  118603. _this._colorTableTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  118604. _this._colorTableTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  118605. _this.onApply = function (effect) {
  118606. effect.setTexture("colorTable", _this._colorTableTexture);
  118607. };
  118608. return _this;
  118609. }
  118610. return ColorCorrectionPostProcess;
  118611. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  118612. /***/ }),
  118613. /***/ "./PostProcesses/convolutionPostProcess.ts":
  118614. /*!*************************************************!*\
  118615. !*** ./PostProcesses/convolutionPostProcess.ts ***!
  118616. \*************************************************/
  118617. /*! exports provided: ConvolutionPostProcess */
  118618. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118619. "use strict";
  118620. __webpack_require__.r(__webpack_exports__);
  118621. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return ConvolutionPostProcess; });
  118622. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118623. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118624. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118625. /* harmony import */ var _Shaders_convolution_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/convolution.fragment */ "./Shaders/convolution.fragment.ts");
  118626. /**
  118627. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  118628. * input texture to perform effects such as edge detection or sharpening
  118629. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  118630. */
  118631. var ConvolutionPostProcess = /** @class */ (function (_super) {
  118632. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ConvolutionPostProcess, _super);
  118633. /**
  118634. * Creates a new instance ConvolutionPostProcess
  118635. * @param name The name of the effect.
  118636. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  118637. * @param options The required width/height ratio to downsize to before computing the render pass.
  118638. * @param camera The camera to apply the render pass to.
  118639. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118640. * @param engine The engine which the post process will be applied. (default: current engine)
  118641. * @param reusable If the post process can be reused on the same frame. (default: false)
  118642. * @param textureType Type of textures used when performing the post process. (default: 0)
  118643. */
  118644. function ConvolutionPostProcess(name,
  118645. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  118646. kernel, options, camera, samplingMode, engine, reusable, textureType) {
  118647. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  118648. var _this = _super.call(this, name, "convolution", ["kernel", "screenSize"], null, options, camera, samplingMode, engine, reusable, null, textureType) || this;
  118649. _this.kernel = kernel;
  118650. _this.onApply = function (effect) {
  118651. effect.setFloat2("screenSize", _this.width, _this.height);
  118652. effect.setArray("kernel", _this.kernel);
  118653. };
  118654. return _this;
  118655. }
  118656. // Statics
  118657. /**
  118658. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118659. */
  118660. ConvolutionPostProcess.EdgeDetect0Kernel = [1, 0, -1, 0, 0, 0, -1, 0, 1];
  118661. /**
  118662. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118663. */
  118664. ConvolutionPostProcess.EdgeDetect1Kernel = [0, 1, 0, 1, -4, 1, 0, 1, 0];
  118665. /**
  118666. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118667. */
  118668. ConvolutionPostProcess.EdgeDetect2Kernel = [-1, -1, -1, -1, 8, -1, -1, -1, -1];
  118669. /**
  118670. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118671. */
  118672. ConvolutionPostProcess.SharpenKernel = [0, -1, 0, -1, 5, -1, 0, -1, 0];
  118673. /**
  118674. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118675. */
  118676. ConvolutionPostProcess.EmbossKernel = [-2, -1, 0, -1, 1, 1, 0, 1, 2];
  118677. /**
  118678. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118679. */
  118680. ConvolutionPostProcess.GaussianKernel = [0, 1, 0, 1, 1, 1, 0, 1, 0];
  118681. return ConvolutionPostProcess;
  118682. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  118683. /***/ }),
  118684. /***/ "./PostProcesses/depthOfFieldBlurPostProcess.ts":
  118685. /*!******************************************************!*\
  118686. !*** ./PostProcesses/depthOfFieldBlurPostProcess.ts ***!
  118687. \******************************************************/
  118688. /*! exports provided: DepthOfFieldBlurPostProcess */
  118689. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118690. "use strict";
  118691. __webpack_require__.r(__webpack_exports__);
  118692. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return DepthOfFieldBlurPostProcess; });
  118693. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118694. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  118695. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  118696. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118697. /**
  118698. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  118699. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  118700. * based on samples that have a large difference in distance than the center pixel.
  118701. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  118702. */
  118703. var DepthOfFieldBlurPostProcess = /** @class */ (function (_super) {
  118704. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldBlurPostProcess, _super);
  118705. /**
  118706. * Creates a new instance CircleOfConfusionPostProcess
  118707. * @param name The name of the effect.
  118708. * @param scene The scene the effect belongs to.
  118709. * @param direction The direction the blur should be applied.
  118710. * @param kernel The size of the kernel used to blur.
  118711. * @param options The required width/height ratio to downsize to before computing the render pass.
  118712. * @param camera The camera to apply the render pass to.
  118713. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  118714. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  118715. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118716. * @param engine The engine which the post process will be applied. (default: current engine)
  118717. * @param reusable If the post process can be reused on the same frame. (default: false)
  118718. * @param textureType Type of textures used when performing the post process. (default: 0)
  118719. * @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)
  118720. */
  118721. function DepthOfFieldBlurPostProcess(name, scene, direction, kernel, options, camera, circleOfConfusion, imageToBlur, samplingMode, engine, reusable, textureType, blockCompilation) {
  118722. if (imageToBlur === void 0) { imageToBlur = null; }
  118723. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  118724. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  118725. if (blockCompilation === void 0) { blockCompilation = false; }
  118726. 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;
  118727. _this.direction = direction;
  118728. _this.onApplyObservable.add(function (effect) {
  118729. if (imageToBlur != null) {
  118730. effect.setTextureFromPostProcess("textureSampler", imageToBlur);
  118731. }
  118732. effect.setTextureFromPostProcessOutput("circleOfConfusionSampler", circleOfConfusion);
  118733. if (scene.activeCamera) {
  118734. effect.setFloat2('cameraMinMaxZ', scene.activeCamera.minZ, scene.activeCamera.maxZ);
  118735. }
  118736. });
  118737. return _this;
  118738. }
  118739. return DepthOfFieldBlurPostProcess;
  118740. }(_blurPostProcess__WEBPACK_IMPORTED_MODULE_2__["BlurPostProcess"]));
  118741. /***/ }),
  118742. /***/ "./PostProcesses/depthOfFieldEffect.ts":
  118743. /*!*********************************************!*\
  118744. !*** ./PostProcesses/depthOfFieldEffect.ts ***!
  118745. \*********************************************/
  118746. /*! exports provided: DepthOfFieldEffectBlurLevel, DepthOfFieldEffect */
  118747. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118748. "use strict";
  118749. __webpack_require__.r(__webpack_exports__);
  118750. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return DepthOfFieldEffectBlurLevel; });
  118751. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return DepthOfFieldEffect; });
  118752. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118753. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  118754. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  118755. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  118756. /* harmony import */ var _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./circleOfConfusionPostProcess */ "./PostProcesses/circleOfConfusionPostProcess.ts");
  118757. /* harmony import */ var _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./depthOfFieldBlurPostProcess */ "./PostProcesses/depthOfFieldBlurPostProcess.ts");
  118758. /* harmony import */ var _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./depthOfFieldMergePostProcess */ "./PostProcesses/depthOfFieldMergePostProcess.ts");
  118759. /**
  118760. * Specifies the level of max blur that should be applied when using the depth of field effect
  118761. */
  118762. var DepthOfFieldEffectBlurLevel;
  118763. (function (DepthOfFieldEffectBlurLevel) {
  118764. /**
  118765. * Subtle blur
  118766. */
  118767. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["Low"] = 0] = "Low";
  118768. /**
  118769. * Medium blur
  118770. */
  118771. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["Medium"] = 1] = "Medium";
  118772. /**
  118773. * Large blur
  118774. */
  118775. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["High"] = 2] = "High";
  118776. })(DepthOfFieldEffectBlurLevel || (DepthOfFieldEffectBlurLevel = {}));
  118777. /**
  118778. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  118779. */
  118780. var DepthOfFieldEffect = /** @class */ (function (_super) {
  118781. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldEffect, _super);
  118782. /**
  118783. * Creates a new instance DepthOfFieldEffect
  118784. * @param scene The scene the effect belongs to.
  118785. * @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.
  118786. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  118787. * @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)
  118788. */
  118789. function DepthOfFieldEffect(scene, depthTexture, blurLevel, pipelineTextureType, blockCompilation) {
  118790. if (blurLevel === void 0) { blurLevel = DepthOfFieldEffectBlurLevel.Low; }
  118791. if (pipelineTextureType === void 0) { pipelineTextureType = 0; }
  118792. if (blockCompilation === void 0) { blockCompilation = false; }
  118793. var _this = _super.call(this, scene.getEngine(), "depth of field", function () {
  118794. return _this._effects;
  118795. }, true) || this;
  118796. /**
  118797. * @hidden Internal post processes in depth of field effect
  118798. */
  118799. _this._effects = [];
  118800. // Circle of confusion value for each pixel is used to determine how much to blur that pixel
  118801. _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);
  118802. // 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)
  118803. // Blur the image but do not blur on sharp far to near distance changes to avoid bleeding artifacts
  118804. // See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  118805. _this._depthOfFieldBlurY = [];
  118806. _this._depthOfFieldBlurX = [];
  118807. var blurCount = 1;
  118808. var kernelSize = 15;
  118809. switch (blurLevel) {
  118810. case DepthOfFieldEffectBlurLevel.High: {
  118811. blurCount = 3;
  118812. kernelSize = 51;
  118813. break;
  118814. }
  118815. case DepthOfFieldEffectBlurLevel.Medium: {
  118816. blurCount = 2;
  118817. kernelSize = 31;
  118818. break;
  118819. }
  118820. default: {
  118821. kernelSize = 15;
  118822. blurCount = 1;
  118823. break;
  118824. }
  118825. }
  118826. var adjustedKernelSize = kernelSize / Math.pow(2, blurCount - 1);
  118827. var ratio = 1.0;
  118828. for (var i = 0; i < blurCount; i++) {
  118829. 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);
  118830. blurY.autoClear = false;
  118831. ratio = 0.75 / Math.pow(2, i);
  118832. 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);
  118833. blurX.autoClear = false;
  118834. _this._depthOfFieldBlurY.push(blurY);
  118835. _this._depthOfFieldBlurX.push(blurX);
  118836. }
  118837. // Set all post processes on the effect.
  118838. _this._effects = [_this._circleOfConfusion];
  118839. for (var i = 0; i < _this._depthOfFieldBlurX.length; i++) {
  118840. _this._effects.push(_this._depthOfFieldBlurY[i]);
  118841. _this._effects.push(_this._depthOfFieldBlurX[i]);
  118842. }
  118843. // Merge blurred images with original image based on circleOfConfusion
  118844. _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);
  118845. _this._dofMerge.autoClear = false;
  118846. _this._effects.push(_this._dofMerge);
  118847. return _this;
  118848. }
  118849. Object.defineProperty(DepthOfFieldEffect.prototype, "focalLength", {
  118850. get: function () {
  118851. return this._circleOfConfusion.focalLength;
  118852. },
  118853. /**
  118854. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  118855. */
  118856. set: function (value) {
  118857. this._circleOfConfusion.focalLength = value;
  118858. },
  118859. enumerable: true,
  118860. configurable: true
  118861. });
  118862. Object.defineProperty(DepthOfFieldEffect.prototype, "fStop", {
  118863. get: function () {
  118864. return this._circleOfConfusion.fStop;
  118865. },
  118866. /**
  118867. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  118868. */
  118869. set: function (value) {
  118870. this._circleOfConfusion.fStop = value;
  118871. },
  118872. enumerable: true,
  118873. configurable: true
  118874. });
  118875. Object.defineProperty(DepthOfFieldEffect.prototype, "focusDistance", {
  118876. get: function () {
  118877. return this._circleOfConfusion.focusDistance;
  118878. },
  118879. /**
  118880. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  118881. */
  118882. set: function (value) {
  118883. this._circleOfConfusion.focusDistance = value;
  118884. },
  118885. enumerable: true,
  118886. configurable: true
  118887. });
  118888. Object.defineProperty(DepthOfFieldEffect.prototype, "lensSize", {
  118889. get: function () {
  118890. return this._circleOfConfusion.lensSize;
  118891. },
  118892. /**
  118893. * 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.
  118894. */
  118895. set: function (value) {
  118896. this._circleOfConfusion.lensSize = value;
  118897. },
  118898. enumerable: true,
  118899. configurable: true
  118900. });
  118901. Object.defineProperty(DepthOfFieldEffect.prototype, "depthTexture", {
  118902. /**
  118903. * 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.
  118904. */
  118905. set: function (value) {
  118906. this._circleOfConfusion.depthTexture = value;
  118907. },
  118908. enumerable: true,
  118909. configurable: true
  118910. });
  118911. /**
  118912. * Disposes each of the internal effects for a given camera.
  118913. * @param camera The camera to dispose the effect on.
  118914. */
  118915. DepthOfFieldEffect.prototype.disposeEffects = function (camera) {
  118916. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  118917. this._effects[effectIndex].dispose(camera);
  118918. }
  118919. };
  118920. /**
  118921. * @hidden Internal
  118922. */
  118923. DepthOfFieldEffect.prototype._updateEffects = function () {
  118924. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  118925. this._effects[effectIndex].updateEffect();
  118926. }
  118927. };
  118928. /**
  118929. * Internal
  118930. * @returns if all the contained post processes are ready.
  118931. * @hidden
  118932. */
  118933. DepthOfFieldEffect.prototype._isReady = function () {
  118934. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  118935. if (!this._effects[effectIndex].isReady()) {
  118936. return false;
  118937. }
  118938. }
  118939. return true;
  118940. };
  118941. return DepthOfFieldEffect;
  118942. }(_PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_3__["PostProcessRenderEffect"]));
  118943. /***/ }),
  118944. /***/ "./PostProcesses/depthOfFieldMergePostProcess.ts":
  118945. /*!*******************************************************!*\
  118946. !*** ./PostProcesses/depthOfFieldMergePostProcess.ts ***!
  118947. \*******************************************************/
  118948. /*! exports provided: DepthOfFieldMergePostProcessOptions, DepthOfFieldMergePostProcess */
  118949. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118950. "use strict";
  118951. __webpack_require__.r(__webpack_exports__);
  118952. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return DepthOfFieldMergePostProcessOptions; });
  118953. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return DepthOfFieldMergePostProcess; });
  118954. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118955. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118956. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118957. /* harmony import */ var _Shaders_depthOfFieldMerge_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/depthOfFieldMerge.fragment */ "./Shaders/depthOfFieldMerge.fragment.ts");
  118958. /**
  118959. * Options to be set when merging outputs from the default pipeline.
  118960. */
  118961. var DepthOfFieldMergePostProcessOptions = /** @class */ (function () {
  118962. function DepthOfFieldMergePostProcessOptions() {
  118963. }
  118964. return DepthOfFieldMergePostProcessOptions;
  118965. }());
  118966. /**
  118967. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  118968. */
  118969. var DepthOfFieldMergePostProcess = /** @class */ (function (_super) {
  118970. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldMergePostProcess, _super);
  118971. /**
  118972. * Creates a new instance of DepthOfFieldMergePostProcess
  118973. * @param name The name of the effect.
  118974. * @param originalFromInput Post process which's input will be used for the merge.
  118975. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  118976. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  118977. * @param options The required width/height ratio to downsize to before computing the render pass.
  118978. * @param camera The camera to apply the render pass to.
  118979. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118980. * @param engine The engine which the post process will be applied. (default: current engine)
  118981. * @param reusable If the post process can be reused on the same frame. (default: false)
  118982. * @param textureType Type of textures used when performing the post process. (default: 0)
  118983. * @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)
  118984. */
  118985. function DepthOfFieldMergePostProcess(name, originalFromInput, circleOfConfusion, blurSteps, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  118986. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  118987. if (blockCompilation === void 0) { blockCompilation = false; }
  118988. var _this = _super.call(this, name, "depthOfFieldMerge", [], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, true) || this;
  118989. _this.blurSteps = blurSteps;
  118990. _this.onApplyObservable.add(function (effect) {
  118991. effect.setTextureFromPostProcess("textureSampler", originalFromInput);
  118992. effect.setTextureFromPostProcessOutput("circleOfConfusionSampler", circleOfConfusion);
  118993. blurSteps.forEach(function (step, index) {
  118994. effect.setTextureFromPostProcessOutput("blurStep" + (blurSteps.length - index - 1), step);
  118995. });
  118996. });
  118997. if (!blockCompilation) {
  118998. _this.updateEffect();
  118999. }
  119000. return _this;
  119001. }
  119002. /**
  119003. * Updates the effect with the current post process compile time values and recompiles the shader.
  119004. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  119005. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  119006. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  119007. * @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
  119008. * @param onCompiled Called when the shader has been compiled.
  119009. * @param onError Called if there is an error when compiling a shader.
  119010. */
  119011. DepthOfFieldMergePostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  119012. if (defines === void 0) { defines = null; }
  119013. if (uniforms === void 0) { uniforms = null; }
  119014. if (samplers === void 0) { samplers = null; }
  119015. if (!defines) {
  119016. defines = "";
  119017. defines += "#define BLUR_LEVEL " + (this.blurSteps.length - 1) + "\n";
  119018. }
  119019. _super.prototype.updateEffect.call(this, defines, uniforms, samplers, indexParameters, onCompiled, onError);
  119020. };
  119021. return DepthOfFieldMergePostProcess;
  119022. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  119023. /***/ }),
  119024. /***/ "./PostProcesses/displayPassPostProcess.ts":
  119025. /*!*************************************************!*\
  119026. !*** ./PostProcesses/displayPassPostProcess.ts ***!
  119027. \*************************************************/
  119028. /*! exports provided: DisplayPassPostProcess */
  119029. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119030. "use strict";
  119031. __webpack_require__.r(__webpack_exports__);
  119032. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return DisplayPassPostProcess; });
  119033. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119034. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119035. /* harmony import */ var _Shaders_displayPass_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/displayPass.fragment */ "./Shaders/displayPass.fragment.ts");
  119036. /**
  119037. * DisplayPassPostProcess which produces an output the same as it's input
  119038. */
  119039. var DisplayPassPostProcess = /** @class */ (function (_super) {
  119040. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DisplayPassPostProcess, _super);
  119041. /**
  119042. * Creates the DisplayPassPostProcess
  119043. * @param name The name of the effect.
  119044. * @param options The required width/height ratio to downsize to before computing the render pass.
  119045. * @param camera The camera to apply the render pass to.
  119046. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119047. * @param engine The engine which the post process will be applied. (default: current engine)
  119048. * @param reusable If the post process can be reused on the same frame. (default: false)
  119049. */
  119050. function DisplayPassPostProcess(name, options, camera, samplingMode, engine, reusable) {
  119051. return _super.call(this, name, "displayPass", ["passSampler"], ["passSampler"], options, camera, samplingMode, engine, reusable) || this;
  119052. }
  119053. return DisplayPassPostProcess;
  119054. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  119055. /***/ }),
  119056. /***/ "./PostProcesses/extractHighlightsPostProcess.ts":
  119057. /*!*******************************************************!*\
  119058. !*** ./PostProcesses/extractHighlightsPostProcess.ts ***!
  119059. \*******************************************************/
  119060. /*! exports provided: ExtractHighlightsPostProcess */
  119061. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119062. "use strict";
  119063. __webpack_require__.r(__webpack_exports__);
  119064. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return ExtractHighlightsPostProcess; });
  119065. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119066. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119067. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  119068. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119069. /* harmony import */ var _Shaders_extractHighlights_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/extractHighlights.fragment */ "./Shaders/extractHighlights.fragment.ts");
  119070. /**
  119071. * 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.
  119072. */
  119073. var ExtractHighlightsPostProcess = /** @class */ (function (_super) {
  119074. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExtractHighlightsPostProcess, _super);
  119075. function ExtractHighlightsPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  119076. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  119077. if (blockCompilation === void 0) { blockCompilation = false; }
  119078. var _this = _super.call(this, name, "extractHighlights", ["threshold", "exposure"], null, options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  119079. /**
  119080. * The luminance threshold, pixels below this value will be set to black.
  119081. */
  119082. _this.threshold = 0.9;
  119083. /** @hidden */
  119084. _this._exposure = 1;
  119085. /**
  119086. * Post process which has the input texture to be used when performing highlight extraction
  119087. * @hidden
  119088. */
  119089. _this._inputPostProcess = null;
  119090. _this.onApplyObservable.add(function (effect) {
  119091. if (_this._inputPostProcess) {
  119092. effect.setTextureFromPostProcess("textureSampler", _this._inputPostProcess);
  119093. }
  119094. effect.setFloat('threshold', Math.pow(_this.threshold, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["ToGammaSpace"]));
  119095. effect.setFloat('exposure', _this._exposure);
  119096. });
  119097. return _this;
  119098. }
  119099. return ExtractHighlightsPostProcess;
  119100. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  119101. /***/ }),
  119102. /***/ "./PostProcesses/filterPostProcess.ts":
  119103. /*!********************************************!*\
  119104. !*** ./PostProcesses/filterPostProcess.ts ***!
  119105. \********************************************/
  119106. /*! exports provided: FilterPostProcess */
  119107. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119108. "use strict";
  119109. __webpack_require__.r(__webpack_exports__);
  119110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return FilterPostProcess; });
  119111. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119112. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119113. /* harmony import */ var _Shaders_filter_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/filter.fragment */ "./Shaders/filter.fragment.ts");
  119114. /**
  119115. * Applies a kernel filter to the image
  119116. */
  119117. var FilterPostProcess = /** @class */ (function (_super) {
  119118. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FilterPostProcess, _super);
  119119. /**
  119120. *
  119121. * @param name The name of the effect.
  119122. * @param kernelMatrix The matrix to be applied to the image
  119123. * @param options The required width/height ratio to downsize to before computing the render pass.
  119124. * @param camera The camera to apply the render pass to.
  119125. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119126. * @param engine The engine which the post process will be applied. (default: current engine)
  119127. * @param reusable If the post process can be reused on the same frame. (default: false)
  119128. */
  119129. function FilterPostProcess(name,
  119130. /** The matrix to be applied to the image */
  119131. kernelMatrix, options, camera, samplingMode, engine, reusable) {
  119132. var _this = _super.call(this, name, "filter", ["kernelMatrix"], null, options, camera, samplingMode, engine, reusable) || this;
  119133. _this.kernelMatrix = kernelMatrix;
  119134. _this.onApply = function (effect) {
  119135. effect.setMatrix("kernelMatrix", _this.kernelMatrix);
  119136. };
  119137. return _this;
  119138. }
  119139. return FilterPostProcess;
  119140. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  119141. /***/ }),
  119142. /***/ "./PostProcesses/fxaaPostProcess.ts":
  119143. /*!******************************************!*\
  119144. !*** ./PostProcesses/fxaaPostProcess.ts ***!
  119145. \******************************************/
  119146. /*! exports provided: FxaaPostProcess */
  119147. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119148. "use strict";
  119149. __webpack_require__.r(__webpack_exports__);
  119150. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return FxaaPostProcess; });
  119151. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119152. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  119153. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119154. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119155. /* harmony import */ var _Shaders_fxaa_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/fxaa.fragment */ "./Shaders/fxaa.fragment.ts");
  119156. /* harmony import */ var _Shaders_fxaa_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/fxaa.vertex */ "./Shaders/fxaa.vertex.ts");
  119157. /**
  119158. * Fxaa post process
  119159. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  119160. */
  119161. var FxaaPostProcess = /** @class */ (function (_super) {
  119162. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FxaaPostProcess, _super);
  119163. function FxaaPostProcess(name, options, camera, samplingMode, engine, reusable, textureType) {
  119164. if (camera === void 0) { camera = null; }
  119165. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  119166. 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;
  119167. var defines = _this._getDefines();
  119168. _this.updateEffect(defines);
  119169. _this.onApplyObservable.add(function (effect) {
  119170. var texelSize = _this.texelSize;
  119171. effect.setFloat2("texelSize", texelSize.x, texelSize.y);
  119172. });
  119173. return _this;
  119174. }
  119175. FxaaPostProcess.prototype._getDefines = function () {
  119176. var engine = this.getEngine();
  119177. if (!engine) {
  119178. return null;
  119179. }
  119180. var glInfo = engine.getGlInfo();
  119181. if (glInfo && glInfo.renderer && glInfo.renderer.toLowerCase().indexOf("mali") > -1) {
  119182. return "#define MALI 1\n";
  119183. }
  119184. return null;
  119185. };
  119186. return FxaaPostProcess;
  119187. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  119188. /***/ }),
  119189. /***/ "./PostProcesses/grainPostProcess.ts":
  119190. /*!*******************************************!*\
  119191. !*** ./PostProcesses/grainPostProcess.ts ***!
  119192. \*******************************************/
  119193. /*! exports provided: GrainPostProcess */
  119194. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119195. "use strict";
  119196. __webpack_require__.r(__webpack_exports__);
  119197. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return GrainPostProcess; });
  119198. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119199. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119200. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119201. /* harmony import */ var _Shaders_grain_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/grain.fragment */ "./Shaders/grain.fragment.ts");
  119202. /**
  119203. * The GrainPostProcess adds noise to the image at mid luminance levels
  119204. */
  119205. var GrainPostProcess = /** @class */ (function (_super) {
  119206. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GrainPostProcess, _super);
  119207. /**
  119208. * Creates a new instance of @see GrainPostProcess
  119209. * @param name The name of the effect.
  119210. * @param options The required width/height ratio to downsize to before computing the render pass.
  119211. * @param camera The camera to apply the render pass to.
  119212. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119213. * @param engine The engine which the post process will be applied. (default: current engine)
  119214. * @param reusable If the post process can be reused on the same frame. (default: false)
  119215. * @param textureType Type of textures used when performing the post process. (default: 0)
  119216. * @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)
  119217. */
  119218. function GrainPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  119219. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  119220. if (blockCompilation === void 0) { blockCompilation = false; }
  119221. var _this = _super.call(this, name, "grain", ["intensity", "animatedSeed"], [], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  119222. /**
  119223. * The intensity of the grain added (default: 30)
  119224. */
  119225. _this.intensity = 30;
  119226. /**
  119227. * If the grain should be randomized on every frame
  119228. */
  119229. _this.animated = false;
  119230. _this.onApplyObservable.add(function (effect) {
  119231. effect.setFloat('intensity', _this.intensity);
  119232. effect.setFloat('animatedSeed', _this.animated ? Math.random() + 1 : 1);
  119233. });
  119234. return _this;
  119235. }
  119236. return GrainPostProcess;
  119237. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  119238. /***/ }),
  119239. /***/ "./PostProcesses/highlightsPostProcess.ts":
  119240. /*!************************************************!*\
  119241. !*** ./PostProcesses/highlightsPostProcess.ts ***!
  119242. \************************************************/
  119243. /*! exports provided: HighlightsPostProcess */
  119244. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119245. "use strict";
  119246. __webpack_require__.r(__webpack_exports__);
  119247. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return HighlightsPostProcess; });
  119248. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119249. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119250. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119251. /* harmony import */ var _Shaders_highlights_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/highlights.fragment */ "./Shaders/highlights.fragment.ts");
  119252. /**
  119253. * Extracts highlights from the image
  119254. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  119255. */
  119256. var HighlightsPostProcess = /** @class */ (function (_super) {
  119257. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HighlightsPostProcess, _super);
  119258. /**
  119259. * Extracts highlights from the image
  119260. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  119261. * @param name The name of the effect.
  119262. * @param options The required width/height ratio to downsize to before computing the render pass.
  119263. * @param camera The camera to apply the render pass to.
  119264. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119265. * @param engine The engine which the post process will be applied. (default: current engine)
  119266. * @param reusable If the post process can be reused on the same frame. (default: false)
  119267. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  119268. */
  119269. function HighlightsPostProcess(name, options, camera, samplingMode, engine, reusable, textureType) {
  119270. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  119271. return _super.call(this, name, "highlights", null, null, options, camera, samplingMode, engine, reusable, null, textureType) || this;
  119272. }
  119273. return HighlightsPostProcess;
  119274. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  119275. /***/ }),
  119276. /***/ "./PostProcesses/imageProcessingPostProcess.ts":
  119277. /*!*****************************************************!*\
  119278. !*** ./PostProcesses/imageProcessingPostProcess.ts ***!
  119279. \*****************************************************/
  119280. /*! exports provided: ImageProcessingPostProcess */
  119281. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119282. "use strict";
  119283. __webpack_require__.r(__webpack_exports__);
  119284. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return ImageProcessingPostProcess; });
  119285. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119286. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  119287. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  119288. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119289. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  119290. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119291. /* harmony import */ var _Shaders_imageProcessing_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/imageProcessing.fragment */ "./Shaders/imageProcessing.fragment.ts");
  119292. /* harmony import */ var _Shaders_postprocess_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/postprocess.vertex */ "./Shaders/postprocess.vertex.ts");
  119293. /**
  119294. * ImageProcessingPostProcess
  119295. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  119296. */
  119297. var ImageProcessingPostProcess = /** @class */ (function (_super) {
  119298. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageProcessingPostProcess, _super);
  119299. function ImageProcessingPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, imageProcessingConfiguration) {
  119300. if (camera === void 0) { camera = null; }
  119301. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  119302. var _this = _super.call(this, name, "imageProcessing", [], [], options, camera, samplingMode, engine, reusable, null, textureType, "postprocess", null, true) || this;
  119303. _this._fromLinearSpace = true;
  119304. /**
  119305. * Defines cache preventing GC.
  119306. */
  119307. _this._defines = {
  119308. IMAGEPROCESSING: false,
  119309. VIGNETTE: false,
  119310. VIGNETTEBLENDMODEMULTIPLY: false,
  119311. VIGNETTEBLENDMODEOPAQUE: false,
  119312. TONEMAPPING: false,
  119313. TONEMAPPING_ACES: false,
  119314. CONTRAST: false,
  119315. COLORCURVES: false,
  119316. COLORGRADING: false,
  119317. COLORGRADING3D: false,
  119318. FROMLINEARSPACE: false,
  119319. SAMPLER3DGREENDEPTH: false,
  119320. SAMPLER3DBGRMAP: false,
  119321. IMAGEPROCESSINGPOSTPROCESS: false,
  119322. EXPOSURE: false,
  119323. };
  119324. // Setup the configuration as forced by the constructor. This would then not force the
  119325. // scene materials output in linear space and let untouched the default forward pass.
  119326. if (imageProcessingConfiguration) {
  119327. imageProcessingConfiguration.applyByPostProcess = true;
  119328. _this._attachImageProcessingConfiguration(imageProcessingConfiguration, true);
  119329. // This will cause the shader to be compiled
  119330. _this.fromLinearSpace = false;
  119331. }
  119332. // Setup the default processing configuration to the scene.
  119333. else {
  119334. _this._attachImageProcessingConfiguration(null, true);
  119335. _this.imageProcessingConfiguration.applyByPostProcess = true;
  119336. }
  119337. _this.onApply = function (effect) {
  119338. _this.imageProcessingConfiguration.bind(effect, _this.aspectRatio);
  119339. };
  119340. return _this;
  119341. }
  119342. Object.defineProperty(ImageProcessingPostProcess.prototype, "imageProcessingConfiguration", {
  119343. /**
  119344. * Gets the image processing configuration used either in this material.
  119345. */
  119346. get: function () {
  119347. return this._imageProcessingConfiguration;
  119348. },
  119349. /**
  119350. * Sets the Default image processing configuration used either in the this material.
  119351. *
  119352. * If sets to null, the scene one is in use.
  119353. */
  119354. set: function (value) {
  119355. this._attachImageProcessingConfiguration(value);
  119356. },
  119357. enumerable: true,
  119358. configurable: true
  119359. });
  119360. /**
  119361. * Attaches a new image processing configuration to the PBR Material.
  119362. * @param configuration
  119363. */
  119364. ImageProcessingPostProcess.prototype._attachImageProcessingConfiguration = function (configuration, doNotBuild) {
  119365. var _this = this;
  119366. if (doNotBuild === void 0) { doNotBuild = false; }
  119367. if (configuration === this._imageProcessingConfiguration) {
  119368. return;
  119369. }
  119370. // Detaches observer.
  119371. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  119372. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  119373. }
  119374. // Pick the scene configuration if needed.
  119375. if (!configuration) {
  119376. var scene = null;
  119377. var engine = this.getEngine();
  119378. var camera = this.getCamera();
  119379. if (camera) {
  119380. scene = camera.getScene();
  119381. }
  119382. else if (engine && engine.scenes) {
  119383. var scenes = engine.scenes;
  119384. scene = scenes[scenes.length - 1];
  119385. }
  119386. else {
  119387. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene;
  119388. }
  119389. this._imageProcessingConfiguration = scene.imageProcessingConfiguration;
  119390. }
  119391. else {
  119392. this._imageProcessingConfiguration = configuration;
  119393. }
  119394. // Attaches observer.
  119395. if (this._imageProcessingConfiguration) {
  119396. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  119397. _this._updateParameters();
  119398. });
  119399. }
  119400. // Ensure the effect will be rebuilt.
  119401. if (!doNotBuild) {
  119402. this._updateParameters();
  119403. }
  119404. };
  119405. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorCurves", {
  119406. /**
  119407. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  119408. */
  119409. get: function () {
  119410. return this.imageProcessingConfiguration.colorCurves;
  119411. },
  119412. /**
  119413. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  119414. */
  119415. set: function (value) {
  119416. this.imageProcessingConfiguration.colorCurves = value;
  119417. },
  119418. enumerable: true,
  119419. configurable: true
  119420. });
  119421. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorCurvesEnabled", {
  119422. /**
  119423. * Gets wether the color curves effect is enabled.
  119424. */
  119425. get: function () {
  119426. return this.imageProcessingConfiguration.colorCurvesEnabled;
  119427. },
  119428. /**
  119429. * Sets wether the color curves effect is enabled.
  119430. */
  119431. set: function (value) {
  119432. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  119433. },
  119434. enumerable: true,
  119435. configurable: true
  119436. });
  119437. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorGradingTexture", {
  119438. /**
  119439. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  119440. */
  119441. get: function () {
  119442. return this.imageProcessingConfiguration.colorGradingTexture;
  119443. },
  119444. /**
  119445. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  119446. */
  119447. set: function (value) {
  119448. this.imageProcessingConfiguration.colorGradingTexture = value;
  119449. },
  119450. enumerable: true,
  119451. configurable: true
  119452. });
  119453. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorGradingEnabled", {
  119454. /**
  119455. * Gets wether the color grading effect is enabled.
  119456. */
  119457. get: function () {
  119458. return this.imageProcessingConfiguration.colorGradingEnabled;
  119459. },
  119460. /**
  119461. * Gets wether the color grading effect is enabled.
  119462. */
  119463. set: function (value) {
  119464. this.imageProcessingConfiguration.colorGradingEnabled = value;
  119465. },
  119466. enumerable: true,
  119467. configurable: true
  119468. });
  119469. Object.defineProperty(ImageProcessingPostProcess.prototype, "exposure", {
  119470. /**
  119471. * Gets exposure used in the effect.
  119472. */
  119473. get: function () {
  119474. return this.imageProcessingConfiguration.exposure;
  119475. },
  119476. /**
  119477. * Sets exposure used in the effect.
  119478. */
  119479. set: function (value) {
  119480. this.imageProcessingConfiguration.exposure = value;
  119481. },
  119482. enumerable: true,
  119483. configurable: true
  119484. });
  119485. Object.defineProperty(ImageProcessingPostProcess.prototype, "toneMappingEnabled", {
  119486. /**
  119487. * Gets wether tonemapping is enabled or not.
  119488. */
  119489. get: function () {
  119490. return this._imageProcessingConfiguration.toneMappingEnabled;
  119491. },
  119492. /**
  119493. * Sets wether tonemapping is enabled or not
  119494. */
  119495. set: function (value) {
  119496. this._imageProcessingConfiguration.toneMappingEnabled = value;
  119497. },
  119498. enumerable: true,
  119499. configurable: true
  119500. });
  119501. Object.defineProperty(ImageProcessingPostProcess.prototype, "toneMappingType", {
  119502. /**
  119503. * Gets the type of tone mapping effect.
  119504. */
  119505. get: function () {
  119506. return this._imageProcessingConfiguration.toneMappingType;
  119507. },
  119508. /**
  119509. * Sets the type of tone mapping effect.
  119510. */
  119511. set: function (value) {
  119512. this._imageProcessingConfiguration.toneMappingType = value;
  119513. },
  119514. enumerable: true,
  119515. configurable: true
  119516. });
  119517. Object.defineProperty(ImageProcessingPostProcess.prototype, "contrast", {
  119518. /**
  119519. * Gets contrast used in the effect.
  119520. */
  119521. get: function () {
  119522. return this.imageProcessingConfiguration.contrast;
  119523. },
  119524. /**
  119525. * Sets contrast used in the effect.
  119526. */
  119527. set: function (value) {
  119528. this.imageProcessingConfiguration.contrast = value;
  119529. },
  119530. enumerable: true,
  119531. configurable: true
  119532. });
  119533. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteStretch", {
  119534. /**
  119535. * Gets Vignette stretch size.
  119536. */
  119537. get: function () {
  119538. return this.imageProcessingConfiguration.vignetteStretch;
  119539. },
  119540. /**
  119541. * Sets Vignette stretch size.
  119542. */
  119543. set: function (value) {
  119544. this.imageProcessingConfiguration.vignetteStretch = value;
  119545. },
  119546. enumerable: true,
  119547. configurable: true
  119548. });
  119549. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCentreX", {
  119550. /**
  119551. * Gets Vignette centre X Offset.
  119552. */
  119553. get: function () {
  119554. return this.imageProcessingConfiguration.vignetteCentreX;
  119555. },
  119556. /**
  119557. * Sets Vignette centre X Offset.
  119558. */
  119559. set: function (value) {
  119560. this.imageProcessingConfiguration.vignetteCentreX = value;
  119561. },
  119562. enumerable: true,
  119563. configurable: true
  119564. });
  119565. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCentreY", {
  119566. /**
  119567. * Gets Vignette centre Y Offset.
  119568. */
  119569. get: function () {
  119570. return this.imageProcessingConfiguration.vignetteCentreY;
  119571. },
  119572. /**
  119573. * Sets Vignette centre Y Offset.
  119574. */
  119575. set: function (value) {
  119576. this.imageProcessingConfiguration.vignetteCentreY = value;
  119577. },
  119578. enumerable: true,
  119579. configurable: true
  119580. });
  119581. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteWeight", {
  119582. /**
  119583. * Gets Vignette weight or intensity of the vignette effect.
  119584. */
  119585. get: function () {
  119586. return this.imageProcessingConfiguration.vignetteWeight;
  119587. },
  119588. /**
  119589. * Sets Vignette weight or intensity of the vignette effect.
  119590. */
  119591. set: function (value) {
  119592. this.imageProcessingConfiguration.vignetteWeight = value;
  119593. },
  119594. enumerable: true,
  119595. configurable: true
  119596. });
  119597. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteColor", {
  119598. /**
  119599. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  119600. * if vignetteEnabled is set to true.
  119601. */
  119602. get: function () {
  119603. return this.imageProcessingConfiguration.vignetteColor;
  119604. },
  119605. /**
  119606. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  119607. * if vignetteEnabled is set to true.
  119608. */
  119609. set: function (value) {
  119610. this.imageProcessingConfiguration.vignetteColor = value;
  119611. },
  119612. enumerable: true,
  119613. configurable: true
  119614. });
  119615. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCameraFov", {
  119616. /**
  119617. * Gets Camera field of view used by the Vignette effect.
  119618. */
  119619. get: function () {
  119620. return this.imageProcessingConfiguration.vignetteCameraFov;
  119621. },
  119622. /**
  119623. * Sets Camera field of view used by the Vignette effect.
  119624. */
  119625. set: function (value) {
  119626. this.imageProcessingConfiguration.vignetteCameraFov = value;
  119627. },
  119628. enumerable: true,
  119629. configurable: true
  119630. });
  119631. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteBlendMode", {
  119632. /**
  119633. * Gets the vignette blend mode allowing different kind of effect.
  119634. */
  119635. get: function () {
  119636. return this.imageProcessingConfiguration.vignetteBlendMode;
  119637. },
  119638. /**
  119639. * Sets the vignette blend mode allowing different kind of effect.
  119640. */
  119641. set: function (value) {
  119642. this.imageProcessingConfiguration.vignetteBlendMode = value;
  119643. },
  119644. enumerable: true,
  119645. configurable: true
  119646. });
  119647. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteEnabled", {
  119648. /**
  119649. * Gets wether the vignette effect is enabled.
  119650. */
  119651. get: function () {
  119652. return this.imageProcessingConfiguration.vignetteEnabled;
  119653. },
  119654. /**
  119655. * Sets wether the vignette effect is enabled.
  119656. */
  119657. set: function (value) {
  119658. this.imageProcessingConfiguration.vignetteEnabled = value;
  119659. },
  119660. enumerable: true,
  119661. configurable: true
  119662. });
  119663. Object.defineProperty(ImageProcessingPostProcess.prototype, "fromLinearSpace", {
  119664. /**
  119665. * Gets wether the input of the processing is in Gamma or Linear Space.
  119666. */
  119667. get: function () {
  119668. return this._fromLinearSpace;
  119669. },
  119670. /**
  119671. * Sets wether the input of the processing is in Gamma or Linear Space.
  119672. */
  119673. set: function (value) {
  119674. if (this._fromLinearSpace === value) {
  119675. return;
  119676. }
  119677. this._fromLinearSpace = value;
  119678. this._updateParameters();
  119679. },
  119680. enumerable: true,
  119681. configurable: true
  119682. });
  119683. /**
  119684. * "ImageProcessingPostProcess"
  119685. * @returns "ImageProcessingPostProcess"
  119686. */
  119687. ImageProcessingPostProcess.prototype.getClassName = function () {
  119688. return "ImageProcessingPostProcess";
  119689. };
  119690. ImageProcessingPostProcess.prototype._updateParameters = function () {
  119691. this._defines.FROMLINEARSPACE = this._fromLinearSpace;
  119692. this.imageProcessingConfiguration.prepareDefines(this._defines, true);
  119693. var defines = "";
  119694. for (var define in this._defines) {
  119695. if (this._defines[define]) {
  119696. defines += "#define " + define + ";\r\n";
  119697. }
  119698. }
  119699. var samplers = ["textureSampler"];
  119700. var uniforms = ["scale"];
  119701. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"]) {
  119702. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._defines);
  119703. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, this._defines);
  119704. }
  119705. this.updateEffect(defines, uniforms, samplers);
  119706. };
  119707. ImageProcessingPostProcess.prototype.dispose = function (camera) {
  119708. _super.prototype.dispose.call(this, camera);
  119709. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  119710. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  119711. }
  119712. if (this._imageProcessingConfiguration) {
  119713. this.imageProcessingConfiguration.applyByPostProcess = false;
  119714. }
  119715. };
  119716. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119717. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119718. ], ImageProcessingPostProcess.prototype, "_fromLinearSpace", void 0);
  119719. return ImageProcessingPostProcess;
  119720. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  119721. /***/ }),
  119722. /***/ "./PostProcesses/index.ts":
  119723. /*!********************************!*\
  119724. !*** ./PostProcesses/index.ts ***!
  119725. \********************************/
  119726. /*! 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 */
  119727. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119728. "use strict";
  119729. __webpack_require__.r(__webpack_exports__);
  119730. /* harmony import */ var _anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./anaglyphPostProcess */ "./PostProcesses/anaglyphPostProcess.ts");
  119731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_0__["AnaglyphPostProcess"]; });
  119732. /* harmony import */ var _blackAndWhitePostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./blackAndWhitePostProcess */ "./PostProcesses/blackAndWhitePostProcess.ts");
  119733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _blackAndWhitePostProcess__WEBPACK_IMPORTED_MODULE_1__["BlackAndWhitePostProcess"]; });
  119734. /* harmony import */ var _bloomEffect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bloomEffect */ "./PostProcesses/bloomEffect.ts");
  119735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _bloomEffect__WEBPACK_IMPORTED_MODULE_2__["BloomEffect"]; });
  119736. /* harmony import */ var _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./bloomMergePostProcess */ "./PostProcesses/bloomMergePostProcess.ts");
  119737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_3__["BloomMergePostProcess"]; });
  119738. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  119739. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _blurPostProcess__WEBPACK_IMPORTED_MODULE_4__["BlurPostProcess"]; });
  119740. /* harmony import */ var _chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./chromaticAberrationPostProcess */ "./PostProcesses/chromaticAberrationPostProcess.ts");
  119741. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_5__["ChromaticAberrationPostProcess"]; });
  119742. /* harmony import */ var _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./circleOfConfusionPostProcess */ "./PostProcesses/circleOfConfusionPostProcess.ts");
  119743. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_6__["CircleOfConfusionPostProcess"]; });
  119744. /* harmony import */ var _colorCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./colorCorrectionPostProcess */ "./PostProcesses/colorCorrectionPostProcess.ts");
  119745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _colorCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_7__["ColorCorrectionPostProcess"]; });
  119746. /* harmony import */ var _convolutionPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./convolutionPostProcess */ "./PostProcesses/convolutionPostProcess.ts");
  119747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _convolutionPostProcess__WEBPACK_IMPORTED_MODULE_8__["ConvolutionPostProcess"]; });
  119748. /* harmony import */ var _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./depthOfFieldBlurPostProcess */ "./PostProcesses/depthOfFieldBlurPostProcess.ts");
  119749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_9__["DepthOfFieldBlurPostProcess"]; });
  119750. /* harmony import */ var _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./depthOfFieldEffect */ "./PostProcesses/depthOfFieldEffect.ts");
  119751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__["DepthOfFieldEffectBlurLevel"]; });
  119752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__["DepthOfFieldEffect"]; });
  119753. /* harmony import */ var _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./depthOfFieldMergePostProcess */ "./PostProcesses/depthOfFieldMergePostProcess.ts");
  119754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__["DepthOfFieldMergePostProcessOptions"]; });
  119755. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__["DepthOfFieldMergePostProcess"]; });
  119756. /* harmony import */ var _displayPassPostProcess__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./displayPassPostProcess */ "./PostProcesses/displayPassPostProcess.ts");
  119757. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _displayPassPostProcess__WEBPACK_IMPORTED_MODULE_12__["DisplayPassPostProcess"]; });
  119758. /* harmony import */ var _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./extractHighlightsPostProcess */ "./PostProcesses/extractHighlightsPostProcess.ts");
  119759. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_13__["ExtractHighlightsPostProcess"]; });
  119760. /* harmony import */ var _filterPostProcess__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./filterPostProcess */ "./PostProcesses/filterPostProcess.ts");
  119761. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _filterPostProcess__WEBPACK_IMPORTED_MODULE_14__["FilterPostProcess"]; });
  119762. /* harmony import */ var _fxaaPostProcess__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  119763. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _fxaaPostProcess__WEBPACK_IMPORTED_MODULE_15__["FxaaPostProcess"]; });
  119764. /* harmony import */ var _grainPostProcess__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./grainPostProcess */ "./PostProcesses/grainPostProcess.ts");
  119765. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _grainPostProcess__WEBPACK_IMPORTED_MODULE_16__["GrainPostProcess"]; });
  119766. /* harmony import */ var _highlightsPostProcess__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./highlightsPostProcess */ "./PostProcesses/highlightsPostProcess.ts");
  119767. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _highlightsPostProcess__WEBPACK_IMPORTED_MODULE_17__["HighlightsPostProcess"]; });
  119768. /* harmony import */ var _imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  119769. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_18__["ImageProcessingPostProcess"]; });
  119770. /* harmony import */ var _motionBlurPostProcess__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./motionBlurPostProcess */ "./PostProcesses/motionBlurPostProcess.ts");
  119771. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _motionBlurPostProcess__WEBPACK_IMPORTED_MODULE_19__["MotionBlurPostProcess"]; });
  119772. /* harmony import */ var _passPostProcess__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./passPostProcess */ "./PostProcesses/passPostProcess.ts");
  119773. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _passPostProcess__WEBPACK_IMPORTED_MODULE_20__["PassPostProcess"]; });
  119774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _passPostProcess__WEBPACK_IMPORTED_MODULE_20__["PassCubePostProcess"]; });
  119775. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119776. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _postProcess__WEBPACK_IMPORTED_MODULE_21__["PostProcess"]; });
  119777. /* harmony import */ var _postProcessManager__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./postProcessManager */ "./PostProcesses/postProcessManager.ts");
  119778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _postProcessManager__WEBPACK_IMPORTED_MODULE_22__["PostProcessManager"]; });
  119779. /* harmony import */ var _refractionPostProcess__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./refractionPostProcess */ "./PostProcesses/refractionPostProcess.ts");
  119780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _refractionPostProcess__WEBPACK_IMPORTED_MODULE_23__["RefractionPostProcess"]; });
  119781. /* harmony import */ var _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./RenderPipeline/index */ "./PostProcesses/RenderPipeline/index.ts");
  119782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderEffect"]; });
  119783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipeline"]; });
  119784. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipelineManager"]; });
  119785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipelineManagerSceneComponent"]; });
  119786. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["DefaultRenderingPipeline"]; });
  119787. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["LensRenderingPipeline"]; });
  119788. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["SSAO2RenderingPipeline"]; });
  119789. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["SSAORenderingPipeline"]; });
  119790. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["StandardRenderingPipeline"]; });
  119791. /* harmony import */ var _sharpenPostProcess__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./sharpenPostProcess */ "./PostProcesses/sharpenPostProcess.ts");
  119792. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _sharpenPostProcess__WEBPACK_IMPORTED_MODULE_25__["SharpenPostProcess"]; });
  119793. /* harmony import */ var _stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./stereoscopicInterlacePostProcess */ "./PostProcesses/stereoscopicInterlacePostProcess.ts");
  119794. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_26__["StereoscopicInterlacePostProcess"]; });
  119795. /* harmony import */ var _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./tonemapPostProcess */ "./PostProcesses/tonemapPostProcess.ts");
  119796. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__["TonemappingOperator"]; });
  119797. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__["TonemapPostProcess"]; });
  119798. /* harmony import */ var _volumetricLightScatteringPostProcess__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./volumetricLightScatteringPostProcess */ "./PostProcesses/volumetricLightScatteringPostProcess.ts");
  119799. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _volumetricLightScatteringPostProcess__WEBPACK_IMPORTED_MODULE_28__["VolumetricLightScatteringPostProcess"]; });
  119800. /* harmony import */ var _vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./vrDistortionCorrectionPostProcess */ "./PostProcesses/vrDistortionCorrectionPostProcess.ts");
  119801. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_29__["VRDistortionCorrectionPostProcess"]; });
  119802. /***/ }),
  119803. /***/ "./PostProcesses/motionBlurPostProcess.ts":
  119804. /*!************************************************!*\
  119805. !*** ./PostProcesses/motionBlurPostProcess.ts ***!
  119806. \************************************************/
  119807. /*! exports provided: MotionBlurPostProcess */
  119808. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119809. "use strict";
  119810. __webpack_require__.r(__webpack_exports__);
  119811. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return MotionBlurPostProcess; });
  119812. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119813. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  119814. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  119815. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119816. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119817. /* harmony import */ var _Rendering_geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Rendering/geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  119818. /* harmony import */ var _Shaders_motionBlur_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/motionBlur.fragment */ "./Shaders/motionBlur.fragment.ts");
  119819. /**
  119820. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  119821. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  119822. * As an example, all you have to do is to create the post-process:
  119823. * var mb = new BABYLON.MotionBlurPostProcess(
  119824. * 'mb', // The name of the effect.
  119825. * scene, // The scene containing the objects to blur according to their velocity.
  119826. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  119827. * camera // The camera to apply the render pass to.
  119828. * );
  119829. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  119830. */
  119831. var MotionBlurPostProcess = /** @class */ (function (_super) {
  119832. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MotionBlurPostProcess, _super);
  119833. /**
  119834. * Creates a new instance MotionBlurPostProcess
  119835. * @param name The name of the effect.
  119836. * @param scene The scene containing the objects to blur according to their velocity.
  119837. * @param options The required width/height ratio to downsize to before computing the render pass.
  119838. * @param camera The camera to apply the render pass to.
  119839. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119840. * @param engine The engine which the post process will be applied. (default: current engine)
  119841. * @param reusable If the post process can be reused on the same frame. (default: false)
  119842. * @param textureType Type of textures used when performing the post process. (default: 0)
  119843. * @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)
  119844. */
  119845. function MotionBlurPostProcess(name, scene, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  119846. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  119847. if (blockCompilation === void 0) { blockCompilation = false; }
  119848. 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;
  119849. /**
  119850. * Defines how much the image is blurred by the movement. Default value is equal to 1
  119851. */
  119852. _this.motionStrength = 1;
  119853. _this._motionBlurSamples = 32;
  119854. _this._geometryBufferRenderer = scene.enableGeometryBufferRenderer();
  119855. if (!_this._geometryBufferRenderer) {
  119856. // Geometry buffer renderer is not supported. So, work as a passthrough.
  119857. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Multiple Render Target support needed to compute object based motion blur");
  119858. _this.updateEffect();
  119859. }
  119860. else {
  119861. // Geometry buffer renderer is supported.
  119862. _this._geometryBufferRenderer.enableVelocity = true;
  119863. _this.onApply = function (effect) {
  119864. effect.setVector2("screenSize", new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](_this.width, _this.height));
  119865. effect.setFloat("motionScale", scene.getAnimationRatio());
  119866. effect.setFloat("motionStrength", _this.motionStrength);
  119867. if (_this._geometryBufferRenderer) {
  119868. var velocityIndex = _this._geometryBufferRenderer.getTextureIndex(_Rendering_geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_5__["GeometryBufferRenderer"].VELOCITY_TEXTURE_TYPE);
  119869. effect.setTexture("velocitySampler", _this._geometryBufferRenderer.getGBuffer().textures[velocityIndex]);
  119870. }
  119871. };
  119872. }
  119873. return _this;
  119874. }
  119875. Object.defineProperty(MotionBlurPostProcess.prototype, "motionBlurSamples", {
  119876. /**
  119877. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  119878. */
  119879. get: function () {
  119880. return this._motionBlurSamples;
  119881. },
  119882. /**
  119883. * Sets the number of iterations to be used for motion blur quality
  119884. */
  119885. set: function (samples) {
  119886. this._motionBlurSamples = samples;
  119887. if (this._geometryBufferRenderer) {
  119888. this.updateEffect("#define GEOMETRY_SUPPORTED\n#define SAMPLES " + samples.toFixed(1));
  119889. }
  119890. },
  119891. enumerable: true,
  119892. configurable: true
  119893. });
  119894. /**
  119895. * Disposes the post process.
  119896. * @param camera The camera to dispose the post process on.
  119897. */
  119898. MotionBlurPostProcess.prototype.dispose = function (camera) {
  119899. if (this._geometryBufferRenderer) {
  119900. // Clear previous transformation matrices dictionary used to compute objects velocities
  119901. this._geometryBufferRenderer._previousTransformationMatrices = {};
  119902. }
  119903. _super.prototype.dispose.call(this, camera);
  119904. };
  119905. return MotionBlurPostProcess;
  119906. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  119907. /***/ }),
  119908. /***/ "./PostProcesses/passPostProcess.ts":
  119909. /*!******************************************!*\
  119910. !*** ./PostProcesses/passPostProcess.ts ***!
  119911. \******************************************/
  119912. /*! exports provided: PassPostProcess, PassCubePostProcess */
  119913. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119914. "use strict";
  119915. __webpack_require__.r(__webpack_exports__);
  119916. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return PassPostProcess; });
  119917. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return PassCubePostProcess; });
  119918. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119919. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119920. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119921. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  119922. /* harmony import */ var _Shaders_pass_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/pass.fragment */ "./Shaders/pass.fragment.ts");
  119923. /* harmony import */ var _Shaders_passCube_fragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/passCube.fragment */ "./Shaders/passCube.fragment.ts");
  119924. /**
  119925. * PassPostProcess which produces an output the same as it's input
  119926. */
  119927. var PassPostProcess = /** @class */ (function (_super) {
  119928. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PassPostProcess, _super);
  119929. /**
  119930. * Creates the PassPostProcess
  119931. * @param name The name of the effect.
  119932. * @param options The required width/height ratio to downsize to before computing the render pass.
  119933. * @param camera The camera to apply the render pass to.
  119934. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119935. * @param engine The engine which the post process will be applied. (default: current engine)
  119936. * @param reusable If the post process can be reused on the same frame. (default: false)
  119937. * @param textureType The type of texture to be used when performing the post processing.
  119938. * @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)
  119939. */
  119940. function PassPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  119941. if (camera === void 0) { camera = null; }
  119942. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  119943. if (blockCompilation === void 0) { blockCompilation = false; }
  119944. return _super.call(this, name, "pass", null, null, options, camera, samplingMode, engine, reusable, undefined, textureType, undefined, null, blockCompilation) || this;
  119945. }
  119946. return PassPostProcess;
  119947. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  119948. /**
  119949. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  119950. */
  119951. var PassCubePostProcess = /** @class */ (function (_super) {
  119952. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PassCubePostProcess, _super);
  119953. /**
  119954. * Creates the PassCubePostProcess
  119955. * @param name The name of the effect.
  119956. * @param options The required width/height ratio to downsize to before computing the render pass.
  119957. * @param camera The camera to apply the render pass to.
  119958. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119959. * @param engine The engine which the post process will be applied. (default: current engine)
  119960. * @param reusable If the post process can be reused on the same frame. (default: false)
  119961. * @param textureType The type of texture to be used when performing the post processing.
  119962. * @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)
  119963. */
  119964. function PassCubePostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  119965. if (camera === void 0) { camera = null; }
  119966. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  119967. if (blockCompilation === void 0) { blockCompilation = false; }
  119968. var _this = _super.call(this, name, "passCube", null, null, options, camera, samplingMode, engine, reusable, "#define POSITIVEX", textureType, undefined, null, blockCompilation) || this;
  119969. _this._face = 0;
  119970. return _this;
  119971. }
  119972. Object.defineProperty(PassCubePostProcess.prototype, "face", {
  119973. /**
  119974. * Gets or sets the cube face to display.
  119975. * * 0 is +X
  119976. * * 1 is -X
  119977. * * 2 is +Y
  119978. * * 3 is -Y
  119979. * * 4 is +Z
  119980. * * 5 is -Z
  119981. */
  119982. get: function () {
  119983. return this._face;
  119984. },
  119985. set: function (value) {
  119986. if (value < 0 || value > 5) {
  119987. return;
  119988. }
  119989. this._face = value;
  119990. switch (this._face) {
  119991. case 0:
  119992. this.updateEffect("#define POSITIVEX");
  119993. break;
  119994. case 1:
  119995. this.updateEffect("#define NEGATIVEX");
  119996. break;
  119997. case 2:
  119998. this.updateEffect("#define POSITIVEY");
  119999. break;
  120000. case 3:
  120001. this.updateEffect("#define NEGATIVEY");
  120002. break;
  120003. case 4:
  120004. this.updateEffect("#define POSITIVEZ");
  120005. break;
  120006. case 5:
  120007. this.updateEffect("#define NEGATIVEZ");
  120008. break;
  120009. }
  120010. },
  120011. enumerable: true,
  120012. configurable: true
  120013. });
  120014. return PassCubePostProcess;
  120015. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  120016. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"]._RescalePostProcessFactory = function (engine) {
  120017. 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);
  120018. };
  120019. /***/ }),
  120020. /***/ "./PostProcesses/postProcess.ts":
  120021. /*!**************************************!*\
  120022. !*** ./PostProcesses/postProcess.ts ***!
  120023. \**************************************/
  120024. /*! exports provided: PostProcess */
  120025. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120026. "use strict";
  120027. __webpack_require__.r(__webpack_exports__);
  120028. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return PostProcess; });
  120029. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  120030. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  120031. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  120032. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  120033. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  120034. /* harmony import */ var _Shaders_postprocess_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/postprocess.vertex */ "./Shaders/postprocess.vertex.ts");
  120035. /**
  120036. * PostProcess can be used to apply a shader to a texture after it has been rendered
  120037. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  120038. */
  120039. var PostProcess = /** @class */ (function () {
  120040. /**
  120041. * Creates a new instance PostProcess
  120042. * @param name The name of the PostProcess.
  120043. * @param fragmentUrl The url of the fragment shader to be used.
  120044. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  120045. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  120046. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  120047. * @param camera The camera to apply the render pass to.
  120048. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120049. * @param engine The engine which the post process will be applied. (default: current engine)
  120050. * @param reusable If the post process can be reused on the same frame. (default: false)
  120051. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  120052. * @param textureType Type of textures used when performing the post process. (default: 0)
  120053. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  120054. * @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
  120055. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  120056. */
  120057. function PostProcess(
  120058. /** Name of the PostProcess. */
  120059. name, fragmentUrl, parameters, samplers, options, camera, samplingMode, engine, reusable, defines, textureType, vertexUrl, indexParameters, blockCompilation) {
  120060. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE; }
  120061. if (defines === void 0) { defines = null; }
  120062. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  120063. if (vertexUrl === void 0) { vertexUrl = "postprocess"; }
  120064. if (blockCompilation === void 0) { blockCompilation = false; }
  120065. this.name = name;
  120066. /**
  120067. * Width of the texture to apply the post process on
  120068. */
  120069. this.width = -1;
  120070. /**
  120071. * Height of the texture to apply the post process on
  120072. */
  120073. this.height = -1;
  120074. /**
  120075. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  120076. * @hidden
  120077. */
  120078. this._outputTexture = null;
  120079. /**
  120080. * If the buffer needs to be cleared before applying the post process. (default: true)
  120081. * Should be set to false if shader will overwrite all previous pixels.
  120082. */
  120083. this.autoClear = true;
  120084. /**
  120085. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  120086. */
  120087. this.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ALPHA_DISABLE;
  120088. /**
  120089. * Animations to be used for the post processing
  120090. */
  120091. this.animations = new Array();
  120092. /**
  120093. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  120094. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  120095. */
  120096. this.enablePixelPerfectMode = false;
  120097. /**
  120098. * Force the postprocess to be applied without taking in account viewport
  120099. */
  120100. this.forceFullscreenViewport = true;
  120101. /**
  120102. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  120103. *
  120104. * | Value | Type | Description |
  120105. * | ----- | ----------------------------------- | ----------- |
  120106. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  120107. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  120108. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  120109. *
  120110. */
  120111. this.scaleMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].SCALEMODE_FLOOR;
  120112. /**
  120113. * Force textures to be a power of two (default: false)
  120114. */
  120115. this.alwaysForcePOT = false;
  120116. this._samples = 1;
  120117. /**
  120118. * Modify the scale of the post process to be the same as the viewport (default: false)
  120119. */
  120120. this.adaptScaleToCurrentViewport = false;
  120121. this._reusable = false;
  120122. /**
  120123. * Smart array of input and output textures for the post process.
  120124. * @hidden
  120125. */
  120126. this._textures = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__["SmartArray"](2);
  120127. /**
  120128. * The index in _textures that corresponds to the output texture.
  120129. * @hidden
  120130. */
  120131. this._currentRenderTextureInd = 0;
  120132. this._scaleRatio = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](1, 1);
  120133. this._texelSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  120134. // Events
  120135. /**
  120136. * An event triggered when the postprocess is activated.
  120137. */
  120138. this.onActivateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  120139. /**
  120140. * An event triggered when the postprocess changes its size.
  120141. */
  120142. this.onSizeChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  120143. /**
  120144. * An event triggered when the postprocess applies its effect.
  120145. */
  120146. this.onApplyObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  120147. /**
  120148. * An event triggered before rendering the postprocess
  120149. */
  120150. this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  120151. /**
  120152. * An event triggered after rendering the postprocess
  120153. */
  120154. this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  120155. if (camera != null) {
  120156. this._camera = camera;
  120157. this._scene = camera.getScene();
  120158. camera.attachPostProcess(this);
  120159. this._engine = this._scene.getEngine();
  120160. this._scene.postProcesses.push(this);
  120161. this.uniqueId = this._scene.getUniqueId();
  120162. }
  120163. else if (engine) {
  120164. this._engine = engine;
  120165. this._engine.postProcesses.push(this);
  120166. }
  120167. this._options = options;
  120168. this.renderTargetSamplingMode = samplingMode ? samplingMode : _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  120169. this._reusable = reusable || false;
  120170. this._textureType = textureType;
  120171. this._samplers = samplers || [];
  120172. this._samplers.push("textureSampler");
  120173. this._fragmentUrl = fragmentUrl;
  120174. this._vertexUrl = vertexUrl;
  120175. this._parameters = parameters || [];
  120176. this._parameters.push("scale");
  120177. this._indexParameters = indexParameters;
  120178. if (!blockCompilation) {
  120179. this.updateEffect(defines);
  120180. }
  120181. }
  120182. Object.defineProperty(PostProcess.prototype, "samples", {
  120183. /**
  120184. * Number of sample textures (default: 1)
  120185. */
  120186. get: function () {
  120187. return this._samples;
  120188. },
  120189. set: function (n) {
  120190. var _this = this;
  120191. this._samples = n;
  120192. this._textures.forEach(function (texture) {
  120193. if (texture.samples !== _this._samples) {
  120194. _this._engine.updateRenderTargetTextureSampleCount(texture, _this._samples);
  120195. }
  120196. });
  120197. },
  120198. enumerable: true,
  120199. configurable: true
  120200. });
  120201. /**
  120202. * Returns the fragment url or shader name used in the post process.
  120203. * @returns the fragment url or name in the shader store.
  120204. */
  120205. PostProcess.prototype.getEffectName = function () {
  120206. return this._fragmentUrl;
  120207. };
  120208. Object.defineProperty(PostProcess.prototype, "onActivate", {
  120209. /**
  120210. * A function that is added to the onActivateObservable
  120211. */
  120212. set: function (callback) {
  120213. if (this._onActivateObserver) {
  120214. this.onActivateObservable.remove(this._onActivateObserver);
  120215. }
  120216. if (callback) {
  120217. this._onActivateObserver = this.onActivateObservable.add(callback);
  120218. }
  120219. },
  120220. enumerable: true,
  120221. configurable: true
  120222. });
  120223. Object.defineProperty(PostProcess.prototype, "onSizeChanged", {
  120224. /**
  120225. * A function that is added to the onSizeChangedObservable
  120226. */
  120227. set: function (callback) {
  120228. if (this._onSizeChangedObserver) {
  120229. this.onSizeChangedObservable.remove(this._onSizeChangedObserver);
  120230. }
  120231. this._onSizeChangedObserver = this.onSizeChangedObservable.add(callback);
  120232. },
  120233. enumerable: true,
  120234. configurable: true
  120235. });
  120236. Object.defineProperty(PostProcess.prototype, "onApply", {
  120237. /**
  120238. * A function that is added to the onApplyObservable
  120239. */
  120240. set: function (callback) {
  120241. if (this._onApplyObserver) {
  120242. this.onApplyObservable.remove(this._onApplyObserver);
  120243. }
  120244. this._onApplyObserver = this.onApplyObservable.add(callback);
  120245. },
  120246. enumerable: true,
  120247. configurable: true
  120248. });
  120249. Object.defineProperty(PostProcess.prototype, "onBeforeRender", {
  120250. /**
  120251. * A function that is added to the onBeforeRenderObservable
  120252. */
  120253. set: function (callback) {
  120254. if (this._onBeforeRenderObserver) {
  120255. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  120256. }
  120257. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  120258. },
  120259. enumerable: true,
  120260. configurable: true
  120261. });
  120262. Object.defineProperty(PostProcess.prototype, "onAfterRender", {
  120263. /**
  120264. * A function that is added to the onAfterRenderObservable
  120265. */
  120266. set: function (callback) {
  120267. if (this._onAfterRenderObserver) {
  120268. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  120269. }
  120270. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  120271. },
  120272. enumerable: true,
  120273. configurable: true
  120274. });
  120275. Object.defineProperty(PostProcess.prototype, "inputTexture", {
  120276. /**
  120277. * 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
  120278. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  120279. */
  120280. get: function () {
  120281. return this._textures.data[this._currentRenderTextureInd];
  120282. },
  120283. set: function (value) {
  120284. this._forcedOutputTexture = value;
  120285. },
  120286. enumerable: true,
  120287. configurable: true
  120288. });
  120289. /**
  120290. * Gets the camera which post process is applied to.
  120291. * @returns The camera the post process is applied to.
  120292. */
  120293. PostProcess.prototype.getCamera = function () {
  120294. return this._camera;
  120295. };
  120296. Object.defineProperty(PostProcess.prototype, "texelSize", {
  120297. /**
  120298. * Gets the texel size of the postprocess.
  120299. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  120300. */
  120301. get: function () {
  120302. if (this._shareOutputWithPostProcess) {
  120303. return this._shareOutputWithPostProcess.texelSize;
  120304. }
  120305. if (this._forcedOutputTexture) {
  120306. this._texelSize.copyFromFloats(1.0 / this._forcedOutputTexture.width, 1.0 / this._forcedOutputTexture.height);
  120307. }
  120308. return this._texelSize;
  120309. },
  120310. enumerable: true,
  120311. configurable: true
  120312. });
  120313. /**
  120314. * Gets a string idenfifying the name of the class
  120315. * @returns "PostProcess" string
  120316. */
  120317. PostProcess.prototype.getClassName = function () {
  120318. return "PostProcess";
  120319. };
  120320. /**
  120321. * Gets the engine which this post process belongs to.
  120322. * @returns The engine the post process was enabled with.
  120323. */
  120324. PostProcess.prototype.getEngine = function () {
  120325. return this._engine;
  120326. };
  120327. /**
  120328. * The effect that is created when initializing the post process.
  120329. * @returns The created effect corrisponding the the postprocess.
  120330. */
  120331. PostProcess.prototype.getEffect = function () {
  120332. return this._effect;
  120333. };
  120334. /**
  120335. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  120336. * @param postProcess The post process to share the output with.
  120337. * @returns This post process.
  120338. */
  120339. PostProcess.prototype.shareOutputWith = function (postProcess) {
  120340. this._disposeTextures();
  120341. this._shareOutputWithPostProcess = postProcess;
  120342. return this;
  120343. };
  120344. /**
  120345. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  120346. * This should be called if the post process that shares output with this post process is disabled/disposed.
  120347. */
  120348. PostProcess.prototype.useOwnOutput = function () {
  120349. if (this._textures.length == 0) {
  120350. this._textures = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__["SmartArray"](2);
  120351. }
  120352. this._shareOutputWithPostProcess = null;
  120353. };
  120354. /**
  120355. * Updates the effect with the current post process compile time values and recompiles the shader.
  120356. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  120357. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  120358. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  120359. * @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
  120360. * @param onCompiled Called when the shader has been compiled.
  120361. * @param onError Called if there is an error when compiling a shader.
  120362. */
  120363. PostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  120364. if (defines === void 0) { defines = null; }
  120365. if (uniforms === void 0) { uniforms = null; }
  120366. if (samplers === void 0) { samplers = null; }
  120367. 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);
  120368. };
  120369. /**
  120370. * The post process is reusable if it can be used multiple times within one frame.
  120371. * @returns If the post process is reusable
  120372. */
  120373. PostProcess.prototype.isReusable = function () {
  120374. return this._reusable;
  120375. };
  120376. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  120377. PostProcess.prototype.markTextureDirty = function () {
  120378. this.width = -1;
  120379. };
  120380. /**
  120381. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  120382. * 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.
  120383. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  120384. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  120385. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  120386. * @returns The target texture that was bound to be written to.
  120387. */
  120388. PostProcess.prototype.activate = function (camera, sourceTexture, forceDepthStencil) {
  120389. var _this = this;
  120390. if (sourceTexture === void 0) { sourceTexture = null; }
  120391. camera = camera || this._camera;
  120392. var scene = camera.getScene();
  120393. var engine = scene.getEngine();
  120394. var maxSize = engine.getCaps().maxTextureSize;
  120395. var requiredWidth = ((sourceTexture ? sourceTexture.width : this._engine.getRenderWidth(true)) * this._options) | 0;
  120396. var requiredHeight = ((sourceTexture ? sourceTexture.height : this._engine.getRenderHeight(true)) * this._options) | 0;
  120397. // 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
  120398. var webVRCamera = camera.parent;
  120399. if (webVRCamera && (webVRCamera.leftCamera == camera || webVRCamera.rightCamera == camera)) {
  120400. requiredWidth /= 2;
  120401. }
  120402. var desiredWidth = (this._options.width || requiredWidth);
  120403. var desiredHeight = this._options.height || requiredHeight;
  120404. if (!this._shareOutputWithPostProcess && !this._forcedOutputTexture) {
  120405. if (this.adaptScaleToCurrentViewport) {
  120406. var currentViewport = engine.currentViewport;
  120407. if (currentViewport) {
  120408. desiredWidth *= currentViewport.width;
  120409. desiredHeight *= currentViewport.height;
  120410. }
  120411. }
  120412. if (this.renderTargetSamplingMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE || this.alwaysForcePOT) {
  120413. if (!this._options.width) {
  120414. desiredWidth = engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetExponentOfTwo(desiredWidth, maxSize, this.scaleMode) : desiredWidth;
  120415. }
  120416. if (!this._options.height) {
  120417. desiredHeight = engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetExponentOfTwo(desiredHeight, maxSize, this.scaleMode) : desiredHeight;
  120418. }
  120419. }
  120420. if (this.width !== desiredWidth || this.height !== desiredHeight) {
  120421. if (this._textures.length > 0) {
  120422. for (var i = 0; i < this._textures.length; i++) {
  120423. this._engine._releaseTexture(this._textures.data[i]);
  120424. }
  120425. this._textures.reset();
  120426. }
  120427. this.width = desiredWidth;
  120428. this.height = desiredHeight;
  120429. var textureSize = { width: this.width, height: this.height };
  120430. var textureOptions = {
  120431. generateMipMaps: false,
  120432. generateDepthBuffer: forceDepthStencil || camera._postProcesses.indexOf(this) === 0,
  120433. generateStencilBuffer: (forceDepthStencil || camera._postProcesses.indexOf(this) === 0) && this._engine.isStencilEnable,
  120434. samplingMode: this.renderTargetSamplingMode,
  120435. type: this._textureType
  120436. };
  120437. this._textures.push(this._engine.createRenderTargetTexture(textureSize, textureOptions));
  120438. if (this._reusable) {
  120439. this._textures.push(this._engine.createRenderTargetTexture(textureSize, textureOptions));
  120440. }
  120441. this._texelSize.copyFromFloats(1.0 / this.width, 1.0 / this.height);
  120442. this.onSizeChangedObservable.notifyObservers(this);
  120443. }
  120444. this._textures.forEach(function (texture) {
  120445. if (texture.samples !== _this.samples) {
  120446. _this._engine.updateRenderTargetTextureSampleCount(texture, _this.samples);
  120447. }
  120448. });
  120449. }
  120450. var target;
  120451. if (this._shareOutputWithPostProcess) {
  120452. target = this._shareOutputWithPostProcess.inputTexture;
  120453. }
  120454. else if (this._forcedOutputTexture) {
  120455. target = this._forcedOutputTexture;
  120456. this.width = this._forcedOutputTexture.width;
  120457. this.height = this._forcedOutputTexture.height;
  120458. }
  120459. else {
  120460. target = this.inputTexture;
  120461. }
  120462. // Bind the input of this post process to be used as the output of the previous post process.
  120463. if (this.enablePixelPerfectMode) {
  120464. this._scaleRatio.copyFromFloats(requiredWidth / desiredWidth, requiredHeight / desiredHeight);
  120465. this._engine.bindFramebuffer(target, 0, requiredWidth, requiredHeight, this.forceFullscreenViewport);
  120466. }
  120467. else {
  120468. this._scaleRatio.copyFromFloats(1, 1);
  120469. this._engine.bindFramebuffer(target, 0, undefined, undefined, this.forceFullscreenViewport);
  120470. }
  120471. this.onActivateObservable.notifyObservers(camera);
  120472. // Clear
  120473. if (this.autoClear && this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ALPHA_DISABLE) {
  120474. this._engine.clear(this.clearColor ? this.clearColor : scene.clearColor, scene._allowPostProcessClearColor, true, true);
  120475. }
  120476. if (this._reusable) {
  120477. this._currentRenderTextureInd = (this._currentRenderTextureInd + 1) % 2;
  120478. }
  120479. return target;
  120480. };
  120481. Object.defineProperty(PostProcess.prototype, "isSupported", {
  120482. /**
  120483. * If the post process is supported.
  120484. */
  120485. get: function () {
  120486. return this._effect.isSupported;
  120487. },
  120488. enumerable: true,
  120489. configurable: true
  120490. });
  120491. Object.defineProperty(PostProcess.prototype, "aspectRatio", {
  120492. /**
  120493. * The aspect ratio of the output texture.
  120494. */
  120495. get: function () {
  120496. if (this._shareOutputWithPostProcess) {
  120497. return this._shareOutputWithPostProcess.aspectRatio;
  120498. }
  120499. if (this._forcedOutputTexture) {
  120500. return this._forcedOutputTexture.width / this._forcedOutputTexture.height;
  120501. }
  120502. return this.width / this.height;
  120503. },
  120504. enumerable: true,
  120505. configurable: true
  120506. });
  120507. /**
  120508. * Get a value indicating if the post-process is ready to be used
  120509. * @returns true if the post-process is ready (shader is compiled)
  120510. */
  120511. PostProcess.prototype.isReady = function () {
  120512. return this._effect && this._effect.isReady();
  120513. };
  120514. /**
  120515. * Binds all textures and uniforms to the shader, this will be run on every pass.
  120516. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  120517. */
  120518. PostProcess.prototype.apply = function () {
  120519. // Check
  120520. if (!this._effect || !this._effect.isReady()) {
  120521. return null;
  120522. }
  120523. // States
  120524. this._engine.enableEffect(this._effect);
  120525. this._engine.setState(false);
  120526. this._engine.setDepthBuffer(false);
  120527. this._engine.setDepthWrite(false);
  120528. // Alpha
  120529. this._engine.setAlphaMode(this.alphaMode);
  120530. if (this.alphaConstants) {
  120531. this.getEngine().setAlphaConstants(this.alphaConstants.r, this.alphaConstants.g, this.alphaConstants.b, this.alphaConstants.a);
  120532. }
  120533. // Bind the output texture of the preivous post process as the input to this post process.
  120534. var source;
  120535. if (this._shareOutputWithPostProcess) {
  120536. source = this._shareOutputWithPostProcess.inputTexture;
  120537. }
  120538. else if (this._forcedOutputTexture) {
  120539. source = this._forcedOutputTexture;
  120540. }
  120541. else {
  120542. source = this.inputTexture;
  120543. }
  120544. this._effect._bindTexture("textureSampler", source);
  120545. // Parameters
  120546. this._effect.setVector2("scale", this._scaleRatio);
  120547. this.onApplyObservable.notifyObservers(this._effect);
  120548. return this._effect;
  120549. };
  120550. PostProcess.prototype._disposeTextures = function () {
  120551. if (this._shareOutputWithPostProcess || this._forcedOutputTexture) {
  120552. return;
  120553. }
  120554. if (this._textures.length > 0) {
  120555. for (var i = 0; i < this._textures.length; i++) {
  120556. this._engine._releaseTexture(this._textures.data[i]);
  120557. }
  120558. }
  120559. this._textures.dispose();
  120560. };
  120561. /**
  120562. * Disposes the post process.
  120563. * @param camera The camera to dispose the post process on.
  120564. */
  120565. PostProcess.prototype.dispose = function (camera) {
  120566. camera = camera || this._camera;
  120567. this._disposeTextures();
  120568. if (this._scene) {
  120569. var index_1 = this._scene.postProcesses.indexOf(this);
  120570. if (index_1 !== -1) {
  120571. this._scene.postProcesses.splice(index_1, 1);
  120572. }
  120573. }
  120574. else {
  120575. var index_2 = this._engine.postProcesses.indexOf(this);
  120576. if (index_2 !== -1) {
  120577. this._engine.postProcesses.splice(index_2, 1);
  120578. }
  120579. }
  120580. if (!camera) {
  120581. return;
  120582. }
  120583. camera.detachPostProcess(this);
  120584. var index = camera._postProcesses.indexOf(this);
  120585. if (index === 0 && camera._postProcesses.length > 0) {
  120586. var firstPostProcess = this._camera._getFirstPostProcess();
  120587. if (firstPostProcess) {
  120588. firstPostProcess.markTextureDirty();
  120589. }
  120590. }
  120591. this.onActivateObservable.clear();
  120592. this.onAfterRenderObservable.clear();
  120593. this.onApplyObservable.clear();
  120594. this.onBeforeRenderObservable.clear();
  120595. this.onSizeChangedObservable.clear();
  120596. };
  120597. return PostProcess;
  120598. }());
  120599. /***/ }),
  120600. /***/ "./PostProcesses/postProcessManager.ts":
  120601. /*!*********************************************!*\
  120602. !*** ./PostProcesses/postProcessManager.ts ***!
  120603. \*********************************************/
  120604. /*! exports provided: PostProcessManager */
  120605. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120606. "use strict";
  120607. __webpack_require__.r(__webpack_exports__);
  120608. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return PostProcessManager; });
  120609. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  120610. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  120611. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  120612. /**
  120613. * PostProcessManager is used to manage one or more post processes or post process pipelines
  120614. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  120615. */
  120616. var PostProcessManager = /** @class */ (function () {
  120617. /**
  120618. * Creates a new instance PostProcess
  120619. * @param scene The scene that the post process is associated with.
  120620. */
  120621. function PostProcessManager(scene) {
  120622. this._vertexBuffers = {};
  120623. this._scene = scene;
  120624. }
  120625. PostProcessManager.prototype._prepareBuffers = function () {
  120626. if (this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind]) {
  120627. return;
  120628. }
  120629. // VBO
  120630. var vertices = [];
  120631. vertices.push(1, 1);
  120632. vertices.push(-1, 1);
  120633. vertices.push(-1, -1);
  120634. vertices.push(1, -1);
  120635. 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);
  120636. this._buildIndexBuffer();
  120637. };
  120638. PostProcessManager.prototype._buildIndexBuffer = function () {
  120639. // Indices
  120640. var indices = [];
  120641. indices.push(0);
  120642. indices.push(1);
  120643. indices.push(2);
  120644. indices.push(0);
  120645. indices.push(2);
  120646. indices.push(3);
  120647. this._indexBuffer = this._scene.getEngine().createIndexBuffer(indices);
  120648. };
  120649. /**
  120650. * Rebuilds the vertex buffers of the manager.
  120651. * @hidden
  120652. */
  120653. PostProcessManager.prototype._rebuild = function () {
  120654. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  120655. if (!vb) {
  120656. return;
  120657. }
  120658. vb._rebuild();
  120659. this._buildIndexBuffer();
  120660. };
  120661. // Methods
  120662. /**
  120663. * Prepares a frame to be run through a post process.
  120664. * @param sourceTexture The input texture to the post procesess. (default: null)
  120665. * @param postProcesses An array of post processes to be run. (default: null)
  120666. * @returns True if the post processes were able to be run.
  120667. * @hidden
  120668. */
  120669. PostProcessManager.prototype._prepareFrame = function (sourceTexture, postProcesses) {
  120670. if (sourceTexture === void 0) { sourceTexture = null; }
  120671. if (postProcesses === void 0) { postProcesses = null; }
  120672. var camera = this._scene.activeCamera;
  120673. if (!camera) {
  120674. return false;
  120675. }
  120676. postProcesses = postProcesses || camera._postProcesses.filter(function (pp) { return pp != null; });
  120677. if (!postProcesses || postProcesses.length === 0 || !this._scene.postProcessesEnabled) {
  120678. return false;
  120679. }
  120680. postProcesses[0].activate(camera, sourceTexture, postProcesses !== null && postProcesses !== undefined);
  120681. return true;
  120682. };
  120683. /**
  120684. * Manually render a set of post processes to a texture.
  120685. * @param postProcesses An array of post processes to be run.
  120686. * @param targetTexture The target texture to render to.
  120687. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  120688. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  120689. * @param lodLevel defines which lod of the texture to render to
  120690. */
  120691. PostProcessManager.prototype.directRender = function (postProcesses, targetTexture, forceFullscreenViewport, faceIndex, lodLevel) {
  120692. if (targetTexture === void 0) { targetTexture = null; }
  120693. if (forceFullscreenViewport === void 0) { forceFullscreenViewport = false; }
  120694. if (faceIndex === void 0) { faceIndex = 0; }
  120695. if (lodLevel === void 0) { lodLevel = 0; }
  120696. var engine = this._scene.getEngine();
  120697. for (var index = 0; index < postProcesses.length; index++) {
  120698. if (index < postProcesses.length - 1) {
  120699. postProcesses[index + 1].activate(this._scene.activeCamera, targetTexture);
  120700. }
  120701. else {
  120702. if (targetTexture) {
  120703. engine.bindFramebuffer(targetTexture, faceIndex, undefined, undefined, forceFullscreenViewport, undefined, lodLevel);
  120704. }
  120705. else {
  120706. engine.restoreDefaultFramebuffer();
  120707. }
  120708. }
  120709. var pp = postProcesses[index];
  120710. var effect = pp.apply();
  120711. if (effect) {
  120712. pp.onBeforeRenderObservable.notifyObservers(effect);
  120713. // VBOs
  120714. this._prepareBuffers();
  120715. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  120716. // Draw order
  120717. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_0__["Material"].TriangleFillMode, 0, 6);
  120718. pp.onAfterRenderObservable.notifyObservers(effect);
  120719. }
  120720. }
  120721. // Restore depth buffer
  120722. engine.setDepthBuffer(true);
  120723. engine.setDepthWrite(true);
  120724. };
  120725. /**
  120726. * Finalize the result of the output of the postprocesses.
  120727. * @param doNotPresent If true the result will not be displayed to the screen.
  120728. * @param targetTexture The target texture to render to.
  120729. * @param faceIndex The index of the face to bind the target texture to.
  120730. * @param postProcesses The array of post processes to render.
  120731. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  120732. * @hidden
  120733. */
  120734. PostProcessManager.prototype._finalizeFrame = function (doNotPresent, targetTexture, faceIndex, postProcesses, forceFullscreenViewport) {
  120735. if (forceFullscreenViewport === void 0) { forceFullscreenViewport = false; }
  120736. var camera = this._scene.activeCamera;
  120737. if (!camera) {
  120738. return;
  120739. }
  120740. postProcesses = postProcesses || camera._postProcesses.filter(function (pp) { return pp != null; });
  120741. if (postProcesses.length === 0 || !this._scene.postProcessesEnabled) {
  120742. return;
  120743. }
  120744. var engine = this._scene.getEngine();
  120745. for (var index = 0, len = postProcesses.length; index < len; index++) {
  120746. var pp = postProcesses[index];
  120747. if (index < len - 1) {
  120748. pp._outputTexture = postProcesses[index + 1].activate(camera, targetTexture);
  120749. }
  120750. else {
  120751. if (targetTexture) {
  120752. engine.bindFramebuffer(targetTexture, faceIndex, undefined, undefined, forceFullscreenViewport);
  120753. pp._outputTexture = targetTexture;
  120754. }
  120755. else {
  120756. engine.restoreDefaultFramebuffer();
  120757. pp._outputTexture = null;
  120758. }
  120759. }
  120760. if (doNotPresent) {
  120761. break;
  120762. }
  120763. var effect = pp.apply();
  120764. if (effect) {
  120765. pp.onBeforeRenderObservable.notifyObservers(effect);
  120766. // VBOs
  120767. this._prepareBuffers();
  120768. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  120769. // Draw order
  120770. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_0__["Material"].TriangleFillMode, 0, 6);
  120771. pp.onAfterRenderObservable.notifyObservers(effect);
  120772. }
  120773. }
  120774. // Restore states
  120775. engine.setDepthBuffer(true);
  120776. engine.setDepthWrite(true);
  120777. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  120778. };
  120779. /**
  120780. * Disposes of the post process manager.
  120781. */
  120782. PostProcessManager.prototype.dispose = function () {
  120783. var buffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  120784. if (buffer) {
  120785. buffer.dispose();
  120786. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  120787. }
  120788. if (this._indexBuffer) {
  120789. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  120790. this._indexBuffer = null;
  120791. }
  120792. };
  120793. return PostProcessManager;
  120794. }());
  120795. /***/ }),
  120796. /***/ "./PostProcesses/refractionPostProcess.ts":
  120797. /*!************************************************!*\
  120798. !*** ./PostProcesses/refractionPostProcess.ts ***!
  120799. \************************************************/
  120800. /*! exports provided: RefractionPostProcess */
  120801. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120802. "use strict";
  120803. __webpack_require__.r(__webpack_exports__);
  120804. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return RefractionPostProcess; });
  120805. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  120806. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  120807. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  120808. /* harmony import */ var _Shaders_refraction_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/refraction.fragment */ "./Shaders/refraction.fragment.ts");
  120809. /**
  120810. * Post process which applies a refractin texture
  120811. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  120812. */
  120813. var RefractionPostProcess = /** @class */ (function (_super) {
  120814. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RefractionPostProcess, _super);
  120815. /**
  120816. * Initializes the RefractionPostProcess
  120817. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  120818. * @param name The name of the effect.
  120819. * @param refractionTextureUrl Url of the refraction texture to use
  120820. * @param color the base color of the refraction (used to taint the rendering)
  120821. * @param depth simulated refraction depth
  120822. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  120823. * @param camera The camera to apply the render pass to.
  120824. * @param options The required width/height ratio to downsize to before computing the render pass.
  120825. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120826. * @param engine The engine which the post process will be applied. (default: current engine)
  120827. * @param reusable If the post process can be reused on the same frame. (default: false)
  120828. */
  120829. function RefractionPostProcess(name, refractionTextureUrl,
  120830. /** the base color of the refraction (used to taint the rendering) */
  120831. color,
  120832. /** simulated refraction depth */
  120833. depth,
  120834. /** the coefficient of the base color (0 to remove base color tainting) */
  120835. colorLevel, options, camera, samplingMode, engine, reusable) {
  120836. var _this = _super.call(this, name, "refraction", ["baseColor", "depth", "colorLevel"], ["refractionSampler"], options, camera, samplingMode, engine, reusable) || this;
  120837. _this.color = color;
  120838. _this.depth = depth;
  120839. _this.colorLevel = colorLevel;
  120840. _this._ownRefractionTexture = true;
  120841. _this.onActivateObservable.add(function (cam) {
  120842. _this._refTexture = _this._refTexture || new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](refractionTextureUrl, cam.getScene());
  120843. });
  120844. _this.onApplyObservable.add(function (effect) {
  120845. effect.setColor3("baseColor", _this.color);
  120846. effect.setFloat("depth", _this.depth);
  120847. effect.setFloat("colorLevel", _this.colorLevel);
  120848. effect.setTexture("refractionSampler", _this._refTexture);
  120849. });
  120850. return _this;
  120851. }
  120852. Object.defineProperty(RefractionPostProcess.prototype, "refractionTexture", {
  120853. /**
  120854. * Gets or sets the refraction texture
  120855. * Please note that you are responsible for disposing the texture if you set it manually
  120856. */
  120857. get: function () {
  120858. return this._refTexture;
  120859. },
  120860. set: function (value) {
  120861. if (this._refTexture && this._ownRefractionTexture) {
  120862. this._refTexture.dispose();
  120863. }
  120864. this._refTexture = value;
  120865. this._ownRefractionTexture = false;
  120866. },
  120867. enumerable: true,
  120868. configurable: true
  120869. });
  120870. // Methods
  120871. /**
  120872. * Disposes of the post process
  120873. * @param camera Camera to dispose post process on
  120874. */
  120875. RefractionPostProcess.prototype.dispose = function (camera) {
  120876. if (this._refTexture && this._ownRefractionTexture) {
  120877. this._refTexture.dispose();
  120878. this._refTexture = null;
  120879. }
  120880. _super.prototype.dispose.call(this, camera);
  120881. };
  120882. return RefractionPostProcess;
  120883. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  120884. /***/ }),
  120885. /***/ "./PostProcesses/sharpenPostProcess.ts":
  120886. /*!*********************************************!*\
  120887. !*** ./PostProcesses/sharpenPostProcess.ts ***!
  120888. \*********************************************/
  120889. /*! exports provided: SharpenPostProcess */
  120890. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120891. "use strict";
  120892. __webpack_require__.r(__webpack_exports__);
  120893. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return SharpenPostProcess; });
  120894. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  120895. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  120896. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  120897. /* harmony import */ var _Shaders_sharpen_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/sharpen.fragment */ "./Shaders/sharpen.fragment.ts");
  120898. /**
  120899. * The SharpenPostProcess applies a sharpen kernel to every pixel
  120900. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  120901. */
  120902. var SharpenPostProcess = /** @class */ (function (_super) {
  120903. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SharpenPostProcess, _super);
  120904. /**
  120905. * Creates a new instance ConvolutionPostProcess
  120906. * @param name The name of the effect.
  120907. * @param options The required width/height ratio to downsize to before computing the render pass.
  120908. * @param camera The camera to apply the render pass to.
  120909. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120910. * @param engine The engine which the post process will be applied. (default: current engine)
  120911. * @param reusable If the post process can be reused on the same frame. (default: false)
  120912. * @param textureType Type of textures used when performing the post process. (default: 0)
  120913. * @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)
  120914. */
  120915. function SharpenPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  120916. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  120917. if (blockCompilation === void 0) { blockCompilation = false; }
  120918. var _this = _super.call(this, name, "sharpen", ["sharpnessAmounts", "screenSize"], null, options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  120919. /**
  120920. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  120921. */
  120922. _this.colorAmount = 1.0;
  120923. /**
  120924. * How much sharpness should be applied (default: 0.3)
  120925. */
  120926. _this.edgeAmount = 0.3;
  120927. _this.onApply = function (effect) {
  120928. effect.setFloat2("screenSize", _this.width, _this.height);
  120929. effect.setFloat2("sharpnessAmounts", _this.edgeAmount, _this.colorAmount);
  120930. };
  120931. return _this;
  120932. }
  120933. return SharpenPostProcess;
  120934. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  120935. /***/ }),
  120936. /***/ "./PostProcesses/stereoscopicInterlacePostProcess.ts":
  120937. /*!***********************************************************!*\
  120938. !*** ./PostProcesses/stereoscopicInterlacePostProcess.ts ***!
  120939. \***********************************************************/
  120940. /*! exports provided: StereoscopicInterlacePostProcess */
  120941. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120942. "use strict";
  120943. __webpack_require__.r(__webpack_exports__);
  120944. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return StereoscopicInterlacePostProcess; });
  120945. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  120946. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  120947. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  120948. /* harmony import */ var _Shaders_stereoscopicInterlace_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/stereoscopicInterlace.fragment */ "./Shaders/stereoscopicInterlace.fragment.ts");
  120949. /**
  120950. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  120951. */
  120952. var StereoscopicInterlacePostProcess = /** @class */ (function (_super) {
  120953. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicInterlacePostProcess, _super);
  120954. /**
  120955. * Initializes a StereoscopicInterlacePostProcess
  120956. * @param name The name of the effect.
  120957. * @param rigCameras The rig cameras to be appled to the post process
  120958. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  120959. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120960. * @param engine The engine which the post process will be applied. (default: current engine)
  120961. * @param reusable If the post process can be reused on the same frame. (default: false)
  120962. */
  120963. function StereoscopicInterlacePostProcess(name, rigCameras, isStereoscopicHoriz, samplingMode, engine, reusable) {
  120964. var _this = _super.call(this, name, "stereoscopicInterlace", ['stepSize'], ['camASampler'], 1, rigCameras[1], samplingMode, engine, reusable, isStereoscopicHoriz ? "#define IS_STEREOSCOPIC_HORIZ 1" : undefined) || this;
  120965. _this._passedProcess = rigCameras[0]._rigPostProcess;
  120966. _this._stepSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1 / _this.width, 1 / _this.height);
  120967. _this.onSizeChangedObservable.add(function () {
  120968. _this._stepSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1 / _this.width, 1 / _this.height);
  120969. });
  120970. _this.onApplyObservable.add(function (effect) {
  120971. effect.setTextureFromPostProcess("camASampler", _this._passedProcess);
  120972. effect.setFloat2("stepSize", _this._stepSize.x, _this._stepSize.y);
  120973. });
  120974. return _this;
  120975. }
  120976. return StereoscopicInterlacePostProcess;
  120977. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  120978. /***/ }),
  120979. /***/ "./PostProcesses/tonemapPostProcess.ts":
  120980. /*!*********************************************!*\
  120981. !*** ./PostProcesses/tonemapPostProcess.ts ***!
  120982. \*********************************************/
  120983. /*! exports provided: TonemappingOperator, TonemapPostProcess */
  120984. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120985. "use strict";
  120986. __webpack_require__.r(__webpack_exports__);
  120987. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return TonemappingOperator; });
  120988. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return TonemapPostProcess; });
  120989. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  120990. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  120991. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  120992. /* harmony import */ var _Shaders_tonemap_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/tonemap.fragment */ "./Shaders/tonemap.fragment.ts");
  120993. /** Defines operator used for tonemapping */
  120994. var TonemappingOperator;
  120995. (function (TonemappingOperator) {
  120996. /** Hable */
  120997. TonemappingOperator[TonemappingOperator["Hable"] = 0] = "Hable";
  120998. /** Reinhard */
  120999. TonemappingOperator[TonemappingOperator["Reinhard"] = 1] = "Reinhard";
  121000. /** HejiDawson */
  121001. TonemappingOperator[TonemappingOperator["HejiDawson"] = 2] = "HejiDawson";
  121002. /** Photographic */
  121003. TonemappingOperator[TonemappingOperator["Photographic"] = 3] = "Photographic";
  121004. })(TonemappingOperator || (TonemappingOperator = {}));
  121005. /**
  121006. * Defines a post process to apply tone mapping
  121007. */
  121008. var TonemapPostProcess = /** @class */ (function (_super) {
  121009. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TonemapPostProcess, _super);
  121010. /**
  121011. * Creates a new TonemapPostProcess
  121012. * @param name defines the name of the postprocess
  121013. * @param _operator defines the operator to use
  121014. * @param exposureAdjustment defines the required exposure adjustement
  121015. * @param camera defines the camera to use (can be null)
  121016. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  121017. * @param engine defines the hosting engine (can be ignore if camera is set)
  121018. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  121019. */
  121020. function TonemapPostProcess(name, _operator,
  121021. /** Defines the required exposure adjustement */
  121022. exposureAdjustment, camera, samplingMode, engine, textureFormat) {
  121023. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE; }
  121024. if (textureFormat === void 0) { textureFormat = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  121025. var _this = _super.call(this, name, "tonemap", ["_ExposureAdjustment"], null, 1.0, camera, samplingMode, engine, true, null, textureFormat) || this;
  121026. _this._operator = _operator;
  121027. _this.exposureAdjustment = exposureAdjustment;
  121028. var defines = "#define ";
  121029. if (_this._operator === TonemappingOperator.Hable) {
  121030. defines += "HABLE_TONEMAPPING";
  121031. }
  121032. else if (_this._operator === TonemappingOperator.Reinhard) {
  121033. defines += "REINHARD_TONEMAPPING";
  121034. }
  121035. else if (_this._operator === TonemappingOperator.HejiDawson) {
  121036. defines += "OPTIMIZED_HEJIDAWSON_TONEMAPPING";
  121037. }
  121038. else if (_this._operator === TonemappingOperator.Photographic) {
  121039. defines += "PHOTOGRAPHIC_TONEMAPPING";
  121040. }
  121041. //sadly a second call to create the effect.
  121042. _this.updateEffect(defines);
  121043. _this.onApply = function (effect) {
  121044. effect.setFloat("_ExposureAdjustment", _this.exposureAdjustment);
  121045. };
  121046. return _this;
  121047. }
  121048. return TonemapPostProcess;
  121049. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  121050. /***/ }),
  121051. /***/ "./PostProcesses/volumetricLightScatteringPostProcess.ts":
  121052. /*!***************************************************************!*\
  121053. !*** ./PostProcesses/volumetricLightScatteringPostProcess.ts ***!
  121054. \***************************************************************/
  121055. /*! exports provided: VolumetricLightScatteringPostProcess */
  121056. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121057. "use strict";
  121058. __webpack_require__.r(__webpack_exports__);
  121059. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return VolumetricLightScatteringPostProcess; });
  121060. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  121061. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  121062. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  121063. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  121064. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  121065. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  121066. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  121067. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  121068. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  121069. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  121070. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  121071. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  121072. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  121073. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  121074. /* harmony import */ var _Shaders_depth_vertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/depth.vertex */ "./Shaders/depth.vertex.ts");
  121075. /* harmony import */ var _Shaders_volumetricLightScattering_fragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Shaders/volumetricLightScattering.fragment */ "./Shaders/volumetricLightScattering.fragment.ts");
  121076. /* harmony import */ var _Shaders_volumetricLightScatteringPass_fragment__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Shaders/volumetricLightScatteringPass.fragment */ "./Shaders/volumetricLightScatteringPass.fragment.ts");
  121077. /**
  121078. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  121079. */
  121080. var VolumetricLightScatteringPostProcess = /** @class */ (function (_super) {
  121081. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VolumetricLightScatteringPostProcess, _super);
  121082. /**
  121083. * @constructor
  121084. * @param name The post-process name
  121085. * @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)
  121086. * @param camera The camera that the post-process will be attached to
  121087. * @param mesh The mesh used to create the light scattering
  121088. * @param samples The post-process quality, default 100
  121089. * @param samplingModeThe post-process filtering mode
  121090. * @param engine The babylon engine
  121091. * @param reusable If the post-process is reusable
  121092. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  121093. */
  121094. function VolumetricLightScatteringPostProcess(name, ratio, camera, mesh, samples, samplingMode, engine, reusable, scene) {
  121095. if (samples === void 0) { samples = 100; }
  121096. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].BILINEAR_SAMPLINGMODE; }
  121097. 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;
  121098. _this._screenCoordinates = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  121099. /**
  121100. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  121101. */
  121102. _this.customMeshPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  121103. /**
  121104. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  121105. */
  121106. _this.useCustomMeshPosition = false;
  121107. /**
  121108. * If the post-process should inverse the light scattering direction
  121109. */
  121110. _this.invert = true;
  121111. /**
  121112. * Array containing the excluded meshes not rendered in the internal pass
  121113. */
  121114. _this.excludedMeshes = new Array();
  121115. /**
  121116. * Controls the overall intensity of the post-process
  121117. */
  121118. _this.exposure = 0.3;
  121119. /**
  121120. * Dissipates each sample's contribution in range [0, 1]
  121121. */
  121122. _this.decay = 0.96815;
  121123. /**
  121124. * Controls the overall intensity of each sample
  121125. */
  121126. _this.weight = 0.58767;
  121127. /**
  121128. * Controls the density of each sample
  121129. */
  121130. _this.density = 0.926;
  121131. scene = ((camera === null) ? scene : camera.getScene()); // parameter "scene" can be null.
  121132. engine = scene.getEngine();
  121133. _this._viewPort = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Viewport"](0, 0, 1, 1).toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  121134. // Configure mesh
  121135. _this.mesh = ((mesh !== null) ? mesh : VolumetricLightScatteringPostProcess.CreateDefaultMesh("VolumetricLightScatteringMesh", scene));
  121136. // Configure
  121137. _this._createPass(scene, ratio.passRatio || ratio);
  121138. _this.onActivate = function (camera) {
  121139. if (!_this.isSupported) {
  121140. _this.dispose(camera);
  121141. }
  121142. _this.onActivate = null;
  121143. };
  121144. _this.onApplyObservable.add(function (effect) {
  121145. _this._updateMeshScreenCoordinates(scene);
  121146. effect.setTexture("lightScatteringSampler", _this._volumetricLightScatteringRTT);
  121147. effect.setFloat("exposure", _this.exposure);
  121148. effect.setFloat("decay", _this.decay);
  121149. effect.setFloat("weight", _this.weight);
  121150. effect.setFloat("density", _this.density);
  121151. effect.setVector2("meshPositionOnScreen", _this._screenCoordinates);
  121152. });
  121153. return _this;
  121154. }
  121155. Object.defineProperty(VolumetricLightScatteringPostProcess.prototype, "useDiffuseColor", {
  121156. /**
  121157. * @hidden
  121158. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  121159. */
  121160. get: function () {
  121161. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
  121162. return false;
  121163. },
  121164. set: function (useDiffuseColor) {
  121165. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
  121166. },
  121167. enumerable: true,
  121168. configurable: true
  121169. });
  121170. /**
  121171. * Returns the string "VolumetricLightScatteringPostProcess"
  121172. * @returns "VolumetricLightScatteringPostProcess"
  121173. */
  121174. VolumetricLightScatteringPostProcess.prototype.getClassName = function () {
  121175. return "VolumetricLightScatteringPostProcess";
  121176. };
  121177. VolumetricLightScatteringPostProcess.prototype._isReady = function (subMesh, useInstances) {
  121178. var mesh = subMesh.getMesh();
  121179. // Render this.mesh as default
  121180. if (mesh === this.mesh && mesh.material) {
  121181. return mesh.material.isReady(mesh);
  121182. }
  121183. var defines = [];
  121184. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind];
  121185. var material = subMesh.getMaterial();
  121186. // Alpha test
  121187. if (material) {
  121188. if (material.needAlphaTesting()) {
  121189. defines.push("#define ALPHATEST");
  121190. }
  121191. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind)) {
  121192. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  121193. defines.push("#define UV1");
  121194. }
  121195. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind)) {
  121196. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind);
  121197. defines.push("#define UV2");
  121198. }
  121199. }
  121200. // Bones
  121201. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  121202. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesKind);
  121203. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsKind);
  121204. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  121205. defines.push("#define BonesPerMesh " + (mesh.skeleton ? (mesh.skeleton.bones.length + 1) : 0));
  121206. }
  121207. else {
  121208. defines.push("#define NUM_BONE_INFLUENCERS 0");
  121209. }
  121210. // Instances
  121211. if (useInstances) {
  121212. defines.push("#define INSTANCES");
  121213. attribs.push("world0");
  121214. attribs.push("world1");
  121215. attribs.push("world2");
  121216. attribs.push("world3");
  121217. }
  121218. // Get correct effect
  121219. var join = defines.join("\n");
  121220. if (this._cachedDefines !== join) {
  121221. this._cachedDefines = join;
  121222. this._volumetricLightScatteringPass = mesh.getScene().getEngine().createEffect({ vertexElement: "depth", fragmentElement: "volumetricLightScatteringPass" }, attribs, ["world", "mBones", "viewProjection", "diffuseMatrix"], ["diffuseSampler"], join);
  121223. }
  121224. return this._volumetricLightScatteringPass.isReady();
  121225. };
  121226. /**
  121227. * Sets the new light position for light scattering effect
  121228. * @param position The new custom light position
  121229. */
  121230. VolumetricLightScatteringPostProcess.prototype.setCustomMeshPosition = function (position) {
  121231. this.customMeshPosition = position;
  121232. };
  121233. /**
  121234. * Returns the light position for light scattering effect
  121235. * @return Vector3 The custom light position
  121236. */
  121237. VolumetricLightScatteringPostProcess.prototype.getCustomMeshPosition = function () {
  121238. return this.customMeshPosition;
  121239. };
  121240. /**
  121241. * Disposes the internal assets and detaches the post-process from the camera
  121242. */
  121243. VolumetricLightScatteringPostProcess.prototype.dispose = function (camera) {
  121244. var rttIndex = camera.getScene().customRenderTargets.indexOf(this._volumetricLightScatteringRTT);
  121245. if (rttIndex !== -1) {
  121246. camera.getScene().customRenderTargets.splice(rttIndex, 1);
  121247. }
  121248. this._volumetricLightScatteringRTT.dispose();
  121249. _super.prototype.dispose.call(this, camera);
  121250. };
  121251. /**
  121252. * Returns the render target texture used by the post-process
  121253. * @return the render target texture used by the post-process
  121254. */
  121255. VolumetricLightScatteringPostProcess.prototype.getPass = function () {
  121256. return this._volumetricLightScatteringRTT;
  121257. };
  121258. // Private methods
  121259. VolumetricLightScatteringPostProcess.prototype._meshExcluded = function (mesh) {
  121260. if (this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {
  121261. return true;
  121262. }
  121263. return false;
  121264. };
  121265. VolumetricLightScatteringPostProcess.prototype._createPass = function (scene, ratio) {
  121266. var _this = this;
  121267. var engine = scene.getEngine();
  121268. 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);
  121269. this._volumetricLightScatteringRTT.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].CLAMP_ADDRESSMODE;
  121270. this._volumetricLightScatteringRTT.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].CLAMP_ADDRESSMODE;
  121271. this._volumetricLightScatteringRTT.renderList = null;
  121272. this._volumetricLightScatteringRTT.renderParticles = false;
  121273. this._volumetricLightScatteringRTT.ignoreCameraViewport = true;
  121274. var camera = this.getCamera();
  121275. if (camera) {
  121276. camera.customRenderTargets.push(this._volumetricLightScatteringRTT);
  121277. }
  121278. else {
  121279. scene.customRenderTargets.push(this._volumetricLightScatteringRTT);
  121280. }
  121281. // Custom render function for submeshes
  121282. var renderSubMesh = function (subMesh) {
  121283. var mesh = subMesh.getRenderingMesh();
  121284. if (_this._meshExcluded(mesh)) {
  121285. return;
  121286. }
  121287. var material = subMesh.getMaterial();
  121288. if (!material) {
  121289. return;
  121290. }
  121291. var scene = mesh.getScene();
  121292. var engine = scene.getEngine();
  121293. // Culling
  121294. engine.setState(material.backFaceCulling);
  121295. // Managing instances
  121296. var batch = mesh._getInstancesRenderList(subMesh._id);
  121297. if (batch.mustReturn) {
  121298. return;
  121299. }
  121300. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  121301. if (_this._isReady(subMesh, hardwareInstancedRendering)) {
  121302. var effect = _this._volumetricLightScatteringPass;
  121303. if (mesh === _this.mesh) {
  121304. if (subMesh.effect) {
  121305. effect = subMesh.effect;
  121306. }
  121307. else {
  121308. effect = material.getEffect();
  121309. }
  121310. }
  121311. engine.enableEffect(effect);
  121312. mesh._bind(subMesh, effect, _Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode);
  121313. if (mesh === _this.mesh) {
  121314. material.bind(mesh.getWorldMatrix(), mesh);
  121315. }
  121316. else {
  121317. _this._volumetricLightScatteringPass.setMatrix("viewProjection", scene.getTransformMatrix());
  121318. // Alpha test
  121319. if (material && material.needAlphaTesting()) {
  121320. var alphaTexture = material.getAlphaTestTexture();
  121321. _this._volumetricLightScatteringPass.setTexture("diffuseSampler", alphaTexture);
  121322. if (alphaTexture) {
  121323. _this._volumetricLightScatteringPass.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  121324. }
  121325. }
  121326. // Bones
  121327. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  121328. _this._volumetricLightScatteringPass.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  121329. }
  121330. }
  121331. // Draw
  121332. mesh._processRendering(subMesh, _this._volumetricLightScatteringPass, _Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return effect.setMatrix("world", world); });
  121333. }
  121334. };
  121335. // Render target texture callbacks
  121336. var savedSceneClearColor;
  121337. var sceneClearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0.0, 0.0, 0.0, 1.0);
  121338. this._volumetricLightScatteringRTT.onBeforeRenderObservable.add(function () {
  121339. savedSceneClearColor = scene.clearColor;
  121340. scene.clearColor = sceneClearColor;
  121341. });
  121342. this._volumetricLightScatteringRTT.onAfterRenderObservable.add(function () {
  121343. scene.clearColor = savedSceneClearColor;
  121344. });
  121345. this._volumetricLightScatteringRTT.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  121346. var engine = scene.getEngine();
  121347. var index;
  121348. if (depthOnlySubMeshes.length) {
  121349. engine.setColorWrite(false);
  121350. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  121351. renderSubMesh(depthOnlySubMeshes.data[index]);
  121352. }
  121353. engine.setColorWrite(true);
  121354. }
  121355. for (index = 0; index < opaqueSubMeshes.length; index++) {
  121356. renderSubMesh(opaqueSubMeshes.data[index]);
  121357. }
  121358. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  121359. renderSubMesh(alphaTestSubMeshes.data[index]);
  121360. }
  121361. if (transparentSubMeshes.length) {
  121362. // Sort sub meshes
  121363. for (index = 0; index < transparentSubMeshes.length; index++) {
  121364. var submesh = transparentSubMeshes.data[index];
  121365. var boundingInfo = submesh.getBoundingInfo();
  121366. if (boundingInfo && scene.activeCamera) {
  121367. submesh._alphaIndex = submesh.getMesh().alphaIndex;
  121368. submesh._distanceToCamera = boundingInfo.boundingSphere.centerWorld.subtract(scene.activeCamera.position).length();
  121369. }
  121370. }
  121371. var sortedArray = transparentSubMeshes.data.slice(0, transparentSubMeshes.length);
  121372. sortedArray.sort(function (a, b) {
  121373. // Alpha index first
  121374. if (a._alphaIndex > b._alphaIndex) {
  121375. return 1;
  121376. }
  121377. if (a._alphaIndex < b._alphaIndex) {
  121378. return -1;
  121379. }
  121380. // Then distance to camera
  121381. if (a._distanceToCamera < b._distanceToCamera) {
  121382. return 1;
  121383. }
  121384. if (a._distanceToCamera > b._distanceToCamera) {
  121385. return -1;
  121386. }
  121387. return 0;
  121388. });
  121389. // Render sub meshes
  121390. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_COMBINE);
  121391. for (index = 0; index < sortedArray.length; index++) {
  121392. renderSubMesh(sortedArray[index]);
  121393. }
  121394. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_DISABLE);
  121395. }
  121396. };
  121397. };
  121398. VolumetricLightScatteringPostProcess.prototype._updateMeshScreenCoordinates = function (scene) {
  121399. var transform = scene.getTransformMatrix();
  121400. var meshPosition;
  121401. if (this.useCustomMeshPosition) {
  121402. meshPosition = this.customMeshPosition;
  121403. }
  121404. else if (this.attachedNode) {
  121405. meshPosition = this.attachedNode.position;
  121406. }
  121407. else {
  121408. meshPosition = this.mesh.parent ? this.mesh.getAbsolutePosition() : this.mesh.position;
  121409. }
  121410. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Project(meshPosition, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity(), transform, this._viewPort);
  121411. this._screenCoordinates.x = pos.x / this._viewPort.width;
  121412. this._screenCoordinates.y = pos.y / this._viewPort.height;
  121413. if (this.invert) {
  121414. this._screenCoordinates.y = 1.0 - this._screenCoordinates.y;
  121415. }
  121416. };
  121417. // Static methods
  121418. /**
  121419. * Creates a default mesh for the Volumeric Light Scattering post-process
  121420. * @param name The mesh name
  121421. * @param scene The scene where to create the mesh
  121422. * @return the default mesh
  121423. */
  121424. VolumetricLightScatteringPostProcess.CreateDefaultMesh = function (name, scene) {
  121425. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_6__["Mesh"].CreatePlane(name, 1, scene);
  121426. mesh.billboardMode = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_5__["AbstractMesh"].BILLBOARDMODE_ALL;
  121427. var material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"](name + "Material", scene);
  121428. material.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  121429. mesh.material = material;
  121430. return mesh;
  121431. };
  121432. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121433. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  121434. ], VolumetricLightScatteringPostProcess.prototype, "customMeshPosition", void 0);
  121435. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121436. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121437. ], VolumetricLightScatteringPostProcess.prototype, "useCustomMeshPosition", void 0);
  121438. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121439. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121440. ], VolumetricLightScatteringPostProcess.prototype, "invert", void 0);
  121441. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121442. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])()
  121443. ], VolumetricLightScatteringPostProcess.prototype, "mesh", void 0);
  121444. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121445. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121446. ], VolumetricLightScatteringPostProcess.prototype, "excludedMeshes", void 0);
  121447. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121448. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121449. ], VolumetricLightScatteringPostProcess.prototype, "exposure", void 0);
  121450. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121451. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121452. ], VolumetricLightScatteringPostProcess.prototype, "decay", void 0);
  121453. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121454. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121455. ], VolumetricLightScatteringPostProcess.prototype, "weight", void 0);
  121456. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121457. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121458. ], VolumetricLightScatteringPostProcess.prototype, "density", void 0);
  121459. return VolumetricLightScatteringPostProcess;
  121460. }(_postProcess__WEBPACK_IMPORTED_MODULE_11__["PostProcess"]));
  121461. /***/ }),
  121462. /***/ "./PostProcesses/vrDistortionCorrectionPostProcess.ts":
  121463. /*!************************************************************!*\
  121464. !*** ./PostProcesses/vrDistortionCorrectionPostProcess.ts ***!
  121465. \************************************************************/
  121466. /*! exports provided: VRDistortionCorrectionPostProcess */
  121467. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121468. "use strict";
  121469. __webpack_require__.r(__webpack_exports__);
  121470. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return VRDistortionCorrectionPostProcess; });
  121471. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  121472. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  121473. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  121474. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  121475. /* harmony import */ var _Shaders_vrDistortionCorrection_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/vrDistortionCorrection.fragment */ "./Shaders/vrDistortionCorrection.fragment.ts");
  121476. /**
  121477. * VRDistortionCorrectionPostProcess used for mobile VR
  121478. */
  121479. var VRDistortionCorrectionPostProcess = /** @class */ (function (_super) {
  121480. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDistortionCorrectionPostProcess, _super);
  121481. /**
  121482. * Initializes the VRDistortionCorrectionPostProcess
  121483. * @param name The name of the effect.
  121484. * @param camera The camera to apply the render pass to.
  121485. * @param isRightEye If this is for the right eye distortion
  121486. * @param vrMetrics All the required metrics for the VR camera
  121487. */
  121488. function VRDistortionCorrectionPostProcess(name, camera, isRightEye, vrMetrics) {
  121489. var _this = _super.call(this, name, "vrDistortionCorrection", [
  121490. 'LensCenter',
  121491. 'Scale',
  121492. 'ScaleIn',
  121493. 'HmdWarpParam'
  121494. ], null, vrMetrics.postProcessScaleFactor, camera, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE) || this;
  121495. _this._isRightEye = isRightEye;
  121496. _this._distortionFactors = vrMetrics.distortionK;
  121497. _this._postProcessScaleFactor = vrMetrics.postProcessScaleFactor;
  121498. _this._lensCenterOffset = vrMetrics.lensCenterOffset;
  121499. _this.adaptScaleToCurrentViewport = true;
  121500. _this.onSizeChangedObservable.add(function () {
  121501. _this._scaleIn = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](2, 2 / _this.aspectRatio);
  121502. _this._scaleFactor = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](.5 * (1 / _this._postProcessScaleFactor), .5 * (1 / _this._postProcessScaleFactor) * _this.aspectRatio);
  121503. _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);
  121504. });
  121505. _this.onApplyObservable.add(function (effect) {
  121506. effect.setFloat2("LensCenter", _this._lensCenter.x, _this._lensCenter.y);
  121507. effect.setFloat2("Scale", _this._scaleFactor.x, _this._scaleFactor.y);
  121508. effect.setFloat2("ScaleIn", _this._scaleIn.x, _this._scaleIn.y);
  121509. effect.setFloat4("HmdWarpParam", _this._distortionFactors[0], _this._distortionFactors[1], _this._distortionFactors[2], _this._distortionFactors[3]);
  121510. });
  121511. return _this;
  121512. }
  121513. return VRDistortionCorrectionPostProcess;
  121514. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  121515. /***/ }),
  121516. /***/ "./Probes/index.ts":
  121517. /*!*************************!*\
  121518. !*** ./Probes/index.ts ***!
  121519. \*************************/
  121520. /*! exports provided: ReflectionProbe */
  121521. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121522. "use strict";
  121523. __webpack_require__.r(__webpack_exports__);
  121524. /* harmony import */ var _reflectionProbe__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./reflectionProbe */ "./Probes/reflectionProbe.ts");
  121525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _reflectionProbe__WEBPACK_IMPORTED_MODULE_0__["ReflectionProbe"]; });
  121526. /***/ }),
  121527. /***/ "./Probes/reflectionProbe.ts":
  121528. /*!***********************************!*\
  121529. !*** ./Probes/reflectionProbe.ts ***!
  121530. \***********************************/
  121531. /*! exports provided: ReflectionProbe */
  121532. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121533. "use strict";
  121534. __webpack_require__.r(__webpack_exports__);
  121535. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return ReflectionProbe; });
  121536. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  121537. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  121538. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  121539. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  121540. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  121541. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  121542. _abstractScene__WEBPACK_IMPORTED_MODULE_4__["AbstractScene"].prototype.removeReflectionProbe = function (toRemove) {
  121543. if (!this.reflectionProbes) {
  121544. return -1;
  121545. }
  121546. var index = this.reflectionProbes.indexOf(toRemove);
  121547. if (index !== -1) {
  121548. this.reflectionProbes.splice(index, 1);
  121549. }
  121550. return index;
  121551. };
  121552. _abstractScene__WEBPACK_IMPORTED_MODULE_4__["AbstractScene"].prototype.addReflectionProbe = function (newReflectionProbe) {
  121553. if (!this.reflectionProbes) {
  121554. this.reflectionProbes = [];
  121555. }
  121556. this.reflectionProbes.push(newReflectionProbe);
  121557. };
  121558. /**
  121559. * Class used to generate realtime reflection / refraction cube textures
  121560. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  121561. */
  121562. var ReflectionProbe = /** @class */ (function () {
  121563. /**
  121564. * Creates a new reflection probe
  121565. * @param name defines the name of the probe
  121566. * @param size defines the texture resolution (for each face)
  121567. * @param scene defines the hosting scene
  121568. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  121569. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  121570. */
  121571. function ReflectionProbe(
  121572. /** defines the name of the probe */
  121573. name, size, scene, generateMipMaps, useFloat) {
  121574. if (generateMipMaps === void 0) { generateMipMaps = true; }
  121575. if (useFloat === void 0) { useFloat = false; }
  121576. var _this = this;
  121577. this.name = name;
  121578. this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  121579. this._target = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  121580. this._add = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  121581. this._invertYAxis = false;
  121582. /** Gets or sets probe position (center of the cube map) */
  121583. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  121584. this._scene = scene;
  121585. // Create the scene field if not exist.
  121586. if (!this._scene.reflectionProbes) {
  121587. this._scene.reflectionProbes = new Array();
  121588. }
  121589. this._scene.reflectionProbes.push(this);
  121590. 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);
  121591. this._renderTargetTexture.onBeforeRenderObservable.add(function (faceIndex) {
  121592. switch (faceIndex) {
  121593. case 0:
  121594. _this._add.copyFromFloats(1, 0, 0);
  121595. break;
  121596. case 1:
  121597. _this._add.copyFromFloats(-1, 0, 0);
  121598. break;
  121599. case 2:
  121600. _this._add.copyFromFloats(0, _this._invertYAxis ? 1 : -1, 0);
  121601. break;
  121602. case 3:
  121603. _this._add.copyFromFloats(0, _this._invertYAxis ? -1 : 1, 0);
  121604. break;
  121605. case 4:
  121606. _this._add.copyFromFloats(0, 0, 1);
  121607. break;
  121608. case 5:
  121609. _this._add.copyFromFloats(0, 0, -1);
  121610. break;
  121611. }
  121612. if (_this._attachedMesh) {
  121613. _this.position.copyFrom(_this._attachedMesh.getAbsolutePosition());
  121614. }
  121615. _this.position.addToRef(_this._add, _this._target);
  121616. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(_this.position, _this._target, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up(), _this._viewMatrix);
  121617. if (scene.activeCamera) {
  121618. _this._projectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].PerspectiveFovLH(Math.PI / 2, 1, scene.activeCamera.minZ, scene.activeCamera.maxZ);
  121619. scene.setTransformMatrix(_this._viewMatrix, _this._projectionMatrix);
  121620. }
  121621. scene._forcedViewPosition = _this.position;
  121622. });
  121623. this._renderTargetTexture.onAfterUnbindObservable.add(function () {
  121624. scene._forcedViewPosition = null;
  121625. scene.updateTransformMatrix(true);
  121626. });
  121627. }
  121628. Object.defineProperty(ReflectionProbe.prototype, "samples", {
  121629. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  121630. get: function () {
  121631. return this._renderTargetTexture.samples;
  121632. },
  121633. set: function (value) {
  121634. this._renderTargetTexture.samples = value;
  121635. },
  121636. enumerable: true,
  121637. configurable: true
  121638. });
  121639. Object.defineProperty(ReflectionProbe.prototype, "refreshRate", {
  121640. /** Gets or sets the refresh rate to use (on every frame by default) */
  121641. get: function () {
  121642. return this._renderTargetTexture.refreshRate;
  121643. },
  121644. set: function (value) {
  121645. this._renderTargetTexture.refreshRate = value;
  121646. },
  121647. enumerable: true,
  121648. configurable: true
  121649. });
  121650. /**
  121651. * Gets the hosting scene
  121652. * @returns a Scene
  121653. */
  121654. ReflectionProbe.prototype.getScene = function () {
  121655. return this._scene;
  121656. };
  121657. Object.defineProperty(ReflectionProbe.prototype, "cubeTexture", {
  121658. /** Gets the internal CubeTexture used to render to */
  121659. get: function () {
  121660. return this._renderTargetTexture;
  121661. },
  121662. enumerable: true,
  121663. configurable: true
  121664. });
  121665. Object.defineProperty(ReflectionProbe.prototype, "renderList", {
  121666. /** Gets the list of meshes to render */
  121667. get: function () {
  121668. return this._renderTargetTexture.renderList;
  121669. },
  121670. enumerable: true,
  121671. configurable: true
  121672. });
  121673. /**
  121674. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  121675. * @param mesh defines the mesh to attach to
  121676. */
  121677. ReflectionProbe.prototype.attachToMesh = function (mesh) {
  121678. this._attachedMesh = mesh;
  121679. };
  121680. /**
  121681. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  121682. * @param renderingGroupId The rendering group id corresponding to its index
  121683. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  121684. */
  121685. ReflectionProbe.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil) {
  121686. this._renderTargetTexture.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil);
  121687. };
  121688. /**
  121689. * Clean all associated resources
  121690. */
  121691. ReflectionProbe.prototype.dispose = function () {
  121692. var index = this._scene.reflectionProbes.indexOf(this);
  121693. if (index !== -1) {
  121694. // Remove from the scene if found
  121695. this._scene.reflectionProbes.splice(index, 1);
  121696. }
  121697. if (this._renderTargetTexture) {
  121698. this._renderTargetTexture.dispose();
  121699. this._renderTargetTexture = null;
  121700. }
  121701. };
  121702. /**
  121703. * Converts the reflection probe information to a readable string for debug purpose.
  121704. * @param fullDetails Supports for multiple levels of logging within scene loading
  121705. * @returns the human readable reflection probe info
  121706. */
  121707. ReflectionProbe.prototype.toString = function (fullDetails) {
  121708. var ret = "Name: " + this.name;
  121709. if (fullDetails) {
  121710. ret += ", position: " + this.position.toString();
  121711. if (this._attachedMesh) {
  121712. ret += ", attached mesh: " + this._attachedMesh.name;
  121713. }
  121714. }
  121715. return ret;
  121716. };
  121717. /**
  121718. * Get the class name of the relfection probe.
  121719. * @returns "ReflectionProbe"
  121720. */
  121721. ReflectionProbe.prototype.getClassName = function () {
  121722. return "ReflectionProbe";
  121723. };
  121724. /**
  121725. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  121726. * @returns The JSON representation of the texture
  121727. */
  121728. ReflectionProbe.prototype.serialize = function () {
  121729. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this, this._renderTargetTexture.serialize());
  121730. serializationObject.isReflectionProbe = true;
  121731. return serializationObject;
  121732. };
  121733. /**
  121734. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  121735. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  121736. * @param scene Define the scene the parsed reflection probe should be instantiated in
  121737. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  121738. * @returns The parsed reflection probe if successful
  121739. */
  121740. ReflectionProbe.Parse = function (parsedReflectionProbe, scene, rootUrl) {
  121741. var reflectionProbe = null;
  121742. if (scene.reflectionProbes) {
  121743. for (var index = 0; index < scene.reflectionProbes.length; index++) {
  121744. var rp = scene.reflectionProbes[index];
  121745. if (rp.name === parsedReflectionProbe.name) {
  121746. reflectionProbe = rp;
  121747. break;
  121748. }
  121749. }
  121750. }
  121751. reflectionProbe = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return reflectionProbe || new ReflectionProbe(parsedReflectionProbe.name, parsedReflectionProbe.renderTargetSize, scene, parsedReflectionProbe._generateMipMaps); }, parsedReflectionProbe, scene, rootUrl);
  121752. reflectionProbe.cubeTexture._waitingRenderList = parsedReflectionProbe.renderList;
  121753. if (parsedReflectionProbe._attachedMesh) {
  121754. reflectionProbe.attachToMesh(scene.getMeshByID(parsedReflectionProbe._attachedMesh));
  121755. }
  121756. return reflectionProbe;
  121757. };
  121758. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121759. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])()
  121760. ], ReflectionProbe.prototype, "_attachedMesh", void 0);
  121761. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121762. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  121763. ], ReflectionProbe.prototype, "position", void 0);
  121764. return ReflectionProbe;
  121765. }());
  121766. /***/ }),
  121767. /***/ "./Rendering/boundingBoxRenderer.ts":
  121768. /*!******************************************!*\
  121769. !*** ./Rendering/boundingBoxRenderer.ts ***!
  121770. \******************************************/
  121771. /*! exports provided: BoundingBoxRenderer */
  121772. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121773. "use strict";
  121774. __webpack_require__.r(__webpack_exports__);
  121775. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return BoundingBoxRenderer; });
  121776. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  121777. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  121778. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  121779. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  121780. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  121781. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  121782. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  121783. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  121784. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  121785. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  121786. /* harmony import */ var _Shaders_color_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/color.fragment */ "./Shaders/color.fragment.ts");
  121787. /* harmony import */ var _Shaders_color_vertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/color.vertex */ "./Shaders/color.vertex.ts");
  121788. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "forceShowBoundingBoxes", {
  121789. get: function () {
  121790. return this._forceShowBoundingBoxes || false;
  121791. },
  121792. set: function (value) {
  121793. this._forceShowBoundingBoxes = value;
  121794. // Lazyly creates a BB renderer if needed.
  121795. if (value) {
  121796. this.getBoundingBoxRenderer();
  121797. }
  121798. },
  121799. enumerable: true,
  121800. configurable: true
  121801. });
  121802. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.getBoundingBoxRenderer = function () {
  121803. if (!this._boundingBoxRenderer) {
  121804. this._boundingBoxRenderer = new BoundingBoxRenderer(this);
  121805. }
  121806. return this._boundingBoxRenderer;
  121807. };
  121808. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "showBoundingBox", {
  121809. get: function () {
  121810. return this._showBoundingBox || false;
  121811. },
  121812. set: function (value) {
  121813. this._showBoundingBox = value;
  121814. // Lazyly creates a BB renderer if needed.
  121815. if (value) {
  121816. this.getScene().getBoundingBoxRenderer();
  121817. }
  121818. },
  121819. enumerable: true,
  121820. configurable: true
  121821. });
  121822. /**
  121823. * Component responsible of rendering the bounding box of the meshes in a scene.
  121824. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  121825. */
  121826. var BoundingBoxRenderer = /** @class */ (function () {
  121827. /**
  121828. * Instantiates a new bounding box renderer in a scene.
  121829. * @param scene the scene the renderer renders in
  121830. */
  121831. function BoundingBoxRenderer(scene) {
  121832. /**
  121833. * The component name helpfull to identify the component in the list of scene components.
  121834. */
  121835. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].NAME_BOUNDINGBOXRENDERER;
  121836. /**
  121837. * Color of the bounding box lines placed in front of an object
  121838. */
  121839. this.frontColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  121840. /**
  121841. * Color of the bounding box lines placed behind an object
  121842. */
  121843. this.backColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0.1, 0.1, 0.1);
  121844. /**
  121845. * Defines if the renderer should show the back lines or not
  121846. */
  121847. this.showBackLines = true;
  121848. /**
  121849. * @hidden
  121850. */
  121851. this.renderList = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_5__["SmartArray"](32);
  121852. this._vertexBuffers = {};
  121853. this.scene = scene;
  121854. scene._addComponent(this);
  121855. }
  121856. /**
  121857. * Registers the component in a given scene
  121858. */
  121859. BoundingBoxRenderer.prototype.register = function () {
  121860. this.scene._beforeEvaluateActiveMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER, this, this.reset);
  121861. this.scene._activeMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_ACTIVEMESH_BOUNDINGBOXRENDERER, this, this._activeMesh);
  121862. this.scene._evaluateSubMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER, this, this._evaluateSubMesh);
  121863. this.scene._afterRenderingGroupDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER, this, this.render);
  121864. };
  121865. BoundingBoxRenderer.prototype._evaluateSubMesh = function (mesh, subMesh) {
  121866. if (mesh.showSubMeshesBoundingBox) {
  121867. var boundingInfo = subMesh.getBoundingInfo();
  121868. if (boundingInfo !== null && boundingInfo !== undefined) {
  121869. boundingInfo.boundingBox._tag = mesh.renderingGroupId;
  121870. this.renderList.push(boundingInfo.boundingBox);
  121871. }
  121872. }
  121873. };
  121874. BoundingBoxRenderer.prototype._activeMesh = function (sourceMesh, mesh) {
  121875. if (sourceMesh.showBoundingBox || this.scene.forceShowBoundingBoxes) {
  121876. var boundingInfo = sourceMesh.getBoundingInfo();
  121877. boundingInfo.boundingBox._tag = mesh.renderingGroupId;
  121878. this.renderList.push(boundingInfo.boundingBox);
  121879. }
  121880. };
  121881. BoundingBoxRenderer.prototype._prepareRessources = function () {
  121882. if (this._colorShader) {
  121883. return;
  121884. }
  121885. this._colorShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_8__["ShaderMaterial"]("colorShader", this.scene, "color", {
  121886. attributes: [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind],
  121887. uniforms: ["world", "viewProjection", "color"]
  121888. });
  121889. var engine = this.scene.getEngine();
  121890. var boxdata = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateBox({ size: 1.0 });
  121891. 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);
  121892. this._createIndexBuffer();
  121893. };
  121894. BoundingBoxRenderer.prototype._createIndexBuffer = function () {
  121895. var engine = this.scene.getEngine();
  121896. 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]);
  121897. };
  121898. /**
  121899. * Rebuilds the elements related to this component in case of
  121900. * context lost for instance.
  121901. */
  121902. BoundingBoxRenderer.prototype.rebuild = function () {
  121903. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  121904. if (vb) {
  121905. vb._rebuild();
  121906. }
  121907. this._createIndexBuffer();
  121908. };
  121909. /**
  121910. * @hidden
  121911. */
  121912. BoundingBoxRenderer.prototype.reset = function () {
  121913. this.renderList.reset();
  121914. };
  121915. /**
  121916. * Render the bounding boxes of a specific rendering group
  121917. * @param renderingGroupId defines the rendering group to render
  121918. */
  121919. BoundingBoxRenderer.prototype.render = function (renderingGroupId) {
  121920. if (this.renderList.length === 0) {
  121921. return;
  121922. }
  121923. this._prepareRessources();
  121924. if (!this._colorShader.isReady()) {
  121925. return;
  121926. }
  121927. var engine = this.scene.getEngine();
  121928. engine.setDepthWrite(false);
  121929. this._colorShader._preBind();
  121930. for (var boundingBoxIndex = 0; boundingBoxIndex < this.renderList.length; boundingBoxIndex++) {
  121931. var boundingBox = this.renderList.data[boundingBoxIndex];
  121932. if (boundingBox._tag !== renderingGroupId) {
  121933. continue;
  121934. }
  121935. var min = boundingBox.minimum;
  121936. var max = boundingBox.maximum;
  121937. var diff = max.subtract(min);
  121938. var median = min.add(diff.scale(0.5));
  121939. var worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Scaling(diff.x, diff.y, diff.z)
  121940. .multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Translation(median.x, median.y, median.z))
  121941. .multiply(boundingBox.getWorldMatrix());
  121942. // VBOs
  121943. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect());
  121944. if (this.showBackLines) {
  121945. // Back
  121946. engine.setDepthFunctionToGreaterOrEqual();
  121947. this.scene.resetCachedMaterial();
  121948. this._colorShader.setColor4("color", this.backColor.toColor4());
  121949. this._colorShader.bind(worldMatrix);
  121950. // Draw order
  121951. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  121952. }
  121953. // Front
  121954. engine.setDepthFunctionToLess();
  121955. this.scene.resetCachedMaterial();
  121956. this._colorShader.setColor4("color", this.frontColor.toColor4());
  121957. this._colorShader.bind(worldMatrix);
  121958. // Draw order
  121959. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  121960. }
  121961. this._colorShader.unbind();
  121962. engine.setDepthFunctionToLessOrEqual();
  121963. engine.setDepthWrite(true);
  121964. };
  121965. /**
  121966. * In case of occlusion queries, we can render the occlusion bounding box through this method
  121967. * @param mesh Define the mesh to render the occlusion bounding box for
  121968. */
  121969. BoundingBoxRenderer.prototype.renderOcclusionBoundingBox = function (mesh) {
  121970. this._prepareRessources();
  121971. if (!this._colorShader.isReady() || !mesh._boundingInfo) {
  121972. return;
  121973. }
  121974. var engine = this.scene.getEngine();
  121975. engine.setDepthWrite(false);
  121976. engine.setColorWrite(false);
  121977. this._colorShader._preBind();
  121978. var boundingBox = mesh._boundingInfo.boundingBox;
  121979. var min = boundingBox.minimum;
  121980. var max = boundingBox.maximum;
  121981. var diff = max.subtract(min);
  121982. var median = min.add(diff.scale(0.5));
  121983. var worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Scaling(diff.x, diff.y, diff.z)
  121984. .multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Translation(median.x, median.y, median.z))
  121985. .multiply(boundingBox.getWorldMatrix());
  121986. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect());
  121987. engine.setDepthFunctionToLess();
  121988. this.scene.resetCachedMaterial();
  121989. this._colorShader.bind(worldMatrix);
  121990. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  121991. this._colorShader.unbind();
  121992. engine.setDepthFunctionToLessOrEqual();
  121993. engine.setDepthWrite(true);
  121994. engine.setColorWrite(true);
  121995. };
  121996. /**
  121997. * Dispose and release the resources attached to this renderer.
  121998. */
  121999. BoundingBoxRenderer.prototype.dispose = function () {
  122000. if (!this._colorShader) {
  122001. return;
  122002. }
  122003. this.renderList.dispose();
  122004. this._colorShader.dispose();
  122005. var buffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  122006. if (buffer) {
  122007. buffer.dispose();
  122008. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  122009. }
  122010. this.scene.getEngine()._releaseBuffer(this._indexBuffer);
  122011. };
  122012. return BoundingBoxRenderer;
  122013. }());
  122014. /***/ }),
  122015. /***/ "./Rendering/depthRenderer.ts":
  122016. /*!************************************!*\
  122017. !*** ./Rendering/depthRenderer.ts ***!
  122018. \************************************/
  122019. /*! exports provided: DepthRenderer */
  122020. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122021. "use strict";
  122022. __webpack_require__.r(__webpack_exports__);
  122023. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return DepthRenderer; });
  122024. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  122025. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  122026. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  122027. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  122028. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  122029. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  122030. /* harmony import */ var _Shaders_depth_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/depth.fragment */ "./Shaders/depth.fragment.ts");
  122031. /* harmony import */ var _Shaders_depth_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/depth.vertex */ "./Shaders/depth.vertex.ts");
  122032. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  122033. /**
  122034. * This represents a depth renderer in Babylon.
  122035. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  122036. */
  122037. var DepthRenderer = /** @class */ (function () {
  122038. /**
  122039. * Instantiates a depth renderer
  122040. * @param scene The scene the renderer belongs to
  122041. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  122042. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  122043. */
  122044. function DepthRenderer(scene, type, camera) {
  122045. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_FLOAT; }
  122046. if (camera === void 0) { camera = null; }
  122047. var _this = this;
  122048. /**
  122049. * Specifiess that the depth renderer will only be used within
  122050. * the camera it is created for.
  122051. * This can help forcing its rendering during the camera processing.
  122052. */
  122053. this.useOnlyInActiveCamera = false;
  122054. this._scene = scene;
  122055. DepthRenderer._SceneComponentInitialization(this._scene);
  122056. this._camera = camera;
  122057. var engine = scene.getEngine();
  122058. // Render target
  122059. this._depthMap = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__["RenderTargetTexture"]("depthMap", { width: engine.getRenderWidth(), height: engine.getRenderHeight() }, this._scene, false, true, type);
  122060. this._depthMap.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  122061. this._depthMap.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  122062. this._depthMap.refreshRate = 1;
  122063. this._depthMap.renderParticles = false;
  122064. this._depthMap.renderList = null;
  122065. // Camera to get depth map from to support multiple concurrent cameras
  122066. this._depthMap.activeCamera = this._camera;
  122067. this._depthMap.ignoreCameraViewport = true;
  122068. this._depthMap.useCameraPostProcesses = false;
  122069. // set default depth value to 1.0 (far away)
  122070. this._depthMap.onClearObservable.add(function (engine) {
  122071. engine.clear(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0), true, true, true);
  122072. });
  122073. // Custom render function
  122074. var renderSubMesh = function (subMesh) {
  122075. var mesh = subMesh.getRenderingMesh();
  122076. var scene = _this._scene;
  122077. var engine = scene.getEngine();
  122078. var material = subMesh.getMaterial();
  122079. if (!material) {
  122080. return;
  122081. }
  122082. // Culling and reverse (right handed system)
  122083. engine.setState(material.backFaceCulling, 0, false, scene.useRightHandedSystem);
  122084. // Managing instances
  122085. var batch = mesh._getInstancesRenderList(subMesh._id);
  122086. if (batch.mustReturn) {
  122087. return;
  122088. }
  122089. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  122090. var camera = _this._camera || scene.activeCamera;
  122091. if (_this.isReady(subMesh, hardwareInstancedRendering) && camera) {
  122092. engine.enableEffect(_this._effect);
  122093. mesh._bind(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode);
  122094. _this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  122095. _this._effect.setFloat2("depthValues", camera.minZ, camera.minZ + camera.maxZ);
  122096. // Alpha test
  122097. if (material && material.needAlphaTesting()) {
  122098. var alphaTexture = material.getAlphaTestTexture();
  122099. if (alphaTexture) {
  122100. _this._effect.setTexture("diffuseSampler", alphaTexture);
  122101. _this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  122102. }
  122103. }
  122104. // Bones
  122105. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  122106. _this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  122107. }
  122108. // Draw
  122109. mesh._processRendering(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  122110. }
  122111. };
  122112. this._depthMap.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  122113. var index;
  122114. if (depthOnlySubMeshes.length) {
  122115. engine.setColorWrite(false);
  122116. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  122117. renderSubMesh(depthOnlySubMeshes.data[index]);
  122118. }
  122119. engine.setColorWrite(true);
  122120. }
  122121. for (index = 0; index < opaqueSubMeshes.length; index++) {
  122122. renderSubMesh(opaqueSubMeshes.data[index]);
  122123. }
  122124. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  122125. renderSubMesh(alphaTestSubMeshes.data[index]);
  122126. }
  122127. };
  122128. }
  122129. /**
  122130. * Creates the depth rendering effect and checks if the effect is ready.
  122131. * @param subMesh The submesh to be used to render the depth map of
  122132. * @param useInstances If multiple world instances should be used
  122133. * @returns if the depth renderer is ready to render the depth map
  122134. */
  122135. DepthRenderer.prototype.isReady = function (subMesh, useInstances) {
  122136. var material = subMesh.getMaterial();
  122137. if (material.disableDepthWrite) {
  122138. return false;
  122139. }
  122140. var defines = [];
  122141. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  122142. var mesh = subMesh.getMesh();
  122143. // Alpha test
  122144. if (material && material.needAlphaTesting() && material.getAlphaTestTexture()) {
  122145. defines.push("#define ALPHATEST");
  122146. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  122147. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  122148. defines.push("#define UV1");
  122149. }
  122150. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  122151. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  122152. defines.push("#define UV2");
  122153. }
  122154. }
  122155. // Bones
  122156. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  122157. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  122158. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  122159. if (mesh.numBoneInfluencers > 4) {
  122160. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind);
  122161. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind);
  122162. }
  122163. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  122164. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  122165. }
  122166. else {
  122167. defines.push("#define NUM_BONE_INFLUENCERS 0");
  122168. }
  122169. // Instances
  122170. if (useInstances) {
  122171. defines.push("#define INSTANCES");
  122172. attribs.push("world0");
  122173. attribs.push("world1");
  122174. attribs.push("world2");
  122175. attribs.push("world3");
  122176. }
  122177. // Get correct effect
  122178. var join = defines.join("\n");
  122179. if (this._cachedDefines !== join) {
  122180. this._cachedDefines = join;
  122181. this._effect = this._scene.getEngine().createEffect("depth", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "depthValues"], ["diffuseSampler"], join);
  122182. }
  122183. return this._effect.isReady();
  122184. };
  122185. /**
  122186. * Gets the texture which the depth map will be written to.
  122187. * @returns The depth map texture
  122188. */
  122189. DepthRenderer.prototype.getDepthMap = function () {
  122190. return this._depthMap;
  122191. };
  122192. /**
  122193. * Disposes of the depth renderer.
  122194. */
  122195. DepthRenderer.prototype.dispose = function () {
  122196. this._depthMap.dispose();
  122197. };
  122198. /** @hidden */
  122199. DepthRenderer._SceneComponentInitialization = function (_) {
  122200. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("DepthRendererSceneComponent");
  122201. };
  122202. return DepthRenderer;
  122203. }());
  122204. /***/ }),
  122205. /***/ "./Rendering/depthRendererSceneComponent.ts":
  122206. /*!**************************************************!*\
  122207. !*** ./Rendering/depthRendererSceneComponent.ts ***!
  122208. \**************************************************/
  122209. /*! exports provided: DepthRendererSceneComponent */
  122210. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122211. "use strict";
  122212. __webpack_require__.r(__webpack_exports__);
  122213. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return DepthRendererSceneComponent; });
  122214. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  122215. /* harmony import */ var _depthRenderer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthRenderer */ "./Rendering/depthRenderer.ts");
  122216. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  122217. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  122218. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.enableDepthRenderer = function (camera) {
  122219. camera = camera || this.activeCamera;
  122220. if (!camera) {
  122221. throw "No camera available to enable depth renderer";
  122222. }
  122223. if (!this._depthRenderer) {
  122224. this._depthRenderer = {};
  122225. }
  122226. if (!this._depthRenderer[camera.id]) {
  122227. var textureType = 0;
  122228. if (this.getEngine().getCaps().textureHalfFloatRender) {
  122229. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  122230. }
  122231. else if (this.getEngine().getCaps().textureFloatRender) {
  122232. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  122233. }
  122234. else {
  122235. throw "Depth renderer does not support int texture type";
  122236. }
  122237. this._depthRenderer[camera.id] = new _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"](this, textureType, camera);
  122238. }
  122239. return this._depthRenderer[camera.id];
  122240. };
  122241. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.disableDepthRenderer = function (camera) {
  122242. camera = camera || this.activeCamera;
  122243. if (!camera || !this._depthRenderer || !this._depthRenderer[camera.id]) {
  122244. return;
  122245. }
  122246. this._depthRenderer[camera.id].dispose();
  122247. delete this._depthRenderer[camera.id];
  122248. };
  122249. /**
  122250. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  122251. * in several rendering techniques.
  122252. */
  122253. var DepthRendererSceneComponent = /** @class */ (function () {
  122254. /**
  122255. * Creates a new instance of the component for the given scene
  122256. * @param scene Defines the scene to register the component in
  122257. */
  122258. function DepthRendererSceneComponent(scene) {
  122259. /**
  122260. * The component name helpfull to identify the component in the list of scene components.
  122261. */
  122262. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_DEPTHRENDERER;
  122263. this.scene = scene;
  122264. }
  122265. /**
  122266. * Registers the component in a given scene
  122267. */
  122268. DepthRendererSceneComponent.prototype.register = function () {
  122269. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_DEPTHRENDERER, this, this._gatherRenderTargets);
  122270. this.scene._gatherActiveCameraRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER, this, this._gatherActiveCameraRenderTargets);
  122271. };
  122272. /**
  122273. * Rebuilds the elements related to this component in case of
  122274. * context lost for instance.
  122275. */
  122276. DepthRendererSceneComponent.prototype.rebuild = function () {
  122277. // Nothing to do for this component
  122278. };
  122279. /**
  122280. * Disposes the component and the associated ressources
  122281. */
  122282. DepthRendererSceneComponent.prototype.dispose = function () {
  122283. for (var key in this.scene._depthRenderer) {
  122284. this.scene._depthRenderer[key].dispose();
  122285. }
  122286. };
  122287. DepthRendererSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  122288. if (this.scene._depthRenderer) {
  122289. for (var key in this.scene._depthRenderer) {
  122290. var depthRenderer = this.scene._depthRenderer[key];
  122291. if (!depthRenderer.useOnlyInActiveCamera) {
  122292. renderTargets.push(depthRenderer.getDepthMap());
  122293. }
  122294. }
  122295. }
  122296. };
  122297. DepthRendererSceneComponent.prototype._gatherActiveCameraRenderTargets = function (renderTargets) {
  122298. if (this.scene._depthRenderer) {
  122299. for (var key in this.scene._depthRenderer) {
  122300. var depthRenderer = this.scene._depthRenderer[key];
  122301. if (depthRenderer.useOnlyInActiveCamera && this.scene.activeCamera.id === key) {
  122302. renderTargets.push(depthRenderer.getDepthMap());
  122303. }
  122304. }
  122305. }
  122306. };
  122307. return DepthRendererSceneComponent;
  122308. }());
  122309. _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"]._SceneComponentInitialization = function (scene) {
  122310. // Register the G Buffer component to the scene.
  122311. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_DEPTHRENDERER);
  122312. if (!component) {
  122313. component = new DepthRendererSceneComponent(scene);
  122314. scene._addComponent(component);
  122315. }
  122316. };
  122317. /***/ }),
  122318. /***/ "./Rendering/edgesRenderer.ts":
  122319. /*!************************************!*\
  122320. !*** ./Rendering/edgesRenderer.ts ***!
  122321. \************************************/
  122322. /*! exports provided: EdgesRenderer, LineEdgesRenderer */
  122323. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122324. "use strict";
  122325. __webpack_require__.r(__webpack_exports__);
  122326. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return EdgesRenderer; });
  122327. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return LineEdgesRenderer; });
  122328. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122329. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  122330. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  122331. /* harmony import */ var _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/linesMesh */ "./Meshes/linesMesh.ts");
  122332. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  122333. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  122334. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  122335. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  122336. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  122337. /* harmony import */ var _Shaders_line_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/line.fragment */ "./Shaders/line.fragment.ts");
  122338. /* harmony import */ var _Shaders_line_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/line.vertex */ "./Shaders/line.vertex.ts");
  122339. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.disableEdgesRendering = function () {
  122340. if (this._edgesRenderer) {
  122341. this._edgesRenderer.dispose();
  122342. this._edgesRenderer = null;
  122343. }
  122344. return this;
  122345. };
  122346. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  122347. if (epsilon === void 0) { epsilon = 0.95; }
  122348. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  122349. this.disableEdgesRendering();
  122350. this._edgesRenderer = new EdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices);
  122351. return this;
  122352. };
  122353. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "edgesRenderer", {
  122354. get: function () {
  122355. return this._edgesRenderer;
  122356. },
  122357. enumerable: true,
  122358. configurable: true
  122359. });
  122360. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  122361. if (epsilon === void 0) { epsilon = 0.95; }
  122362. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  122363. this.disableEdgesRendering();
  122364. this._edgesRenderer = new LineEdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices);
  122365. return this;
  122366. };
  122367. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["InstancedLinesMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  122368. if (epsilon === void 0) { epsilon = 0.95; }
  122369. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  122370. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"].prototype.enableEdgesRendering.apply(this, arguments);
  122371. return this;
  122372. };
  122373. /**
  122374. * FaceAdjacencies Helper class to generate edges
  122375. */
  122376. var FaceAdjacencies = /** @class */ (function () {
  122377. function FaceAdjacencies() {
  122378. this.edges = new Array();
  122379. this.edgesConnectedCount = 0;
  122380. }
  122381. return FaceAdjacencies;
  122382. }());
  122383. /**
  122384. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  122385. */
  122386. var EdgesRenderer = /** @class */ (function () {
  122387. /**
  122388. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  122389. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  122390. * @param source Mesh used to create edges
  122391. * @param epsilon sum of angles in adjacency to check for edge
  122392. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  122393. * @param generateEdgesLines - should generate Lines or only prepare resources.
  122394. */
  122395. function EdgesRenderer(source, epsilon, checkVerticesInsteadOfIndices, generateEdgesLines) {
  122396. if (epsilon === void 0) { epsilon = 0.95; }
  122397. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  122398. if (generateEdgesLines === void 0) { generateEdgesLines = true; }
  122399. var _this = this;
  122400. /**
  122401. * Define the size of the edges with an orthographic camera
  122402. */
  122403. this.edgesWidthScalerForOrthographic = 1000.0;
  122404. /**
  122405. * Define the size of the edges with a perspective camera
  122406. */
  122407. this.edgesWidthScalerForPerspective = 50.0;
  122408. this._linesPositions = new Array();
  122409. this._linesNormals = new Array();
  122410. this._linesIndices = new Array();
  122411. this._buffers = {};
  122412. this._checkVerticesInsteadOfIndices = false;
  122413. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  122414. this.isEnabled = true;
  122415. this._source = source;
  122416. this._checkVerticesInsteadOfIndices = checkVerticesInsteadOfIndices;
  122417. this._epsilon = epsilon;
  122418. this._prepareRessources();
  122419. if (generateEdgesLines) {
  122420. this._generateEdgesLines();
  122421. }
  122422. this._meshRebuildObserver = this._source.onRebuildObservable.add(function () {
  122423. _this._rebuild();
  122424. });
  122425. this._meshDisposeObserver = this._source.onDisposeObservable.add(function () {
  122426. _this.dispose();
  122427. });
  122428. }
  122429. EdgesRenderer.prototype._prepareRessources = function () {
  122430. if (this._lineShader) {
  122431. return;
  122432. }
  122433. this._lineShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__["ShaderMaterial"]("lineShader", this._source.getScene(), "line", {
  122434. attributes: ["position", "normal"],
  122435. uniforms: ["worldViewProjection", "color", "width", "aspectRatio"]
  122436. });
  122437. this._lineShader.disableDepthWrite = true;
  122438. this._lineShader.backFaceCulling = false;
  122439. };
  122440. /** @hidden */
  122441. EdgesRenderer.prototype._rebuild = function () {
  122442. var buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  122443. if (buffer) {
  122444. buffer._rebuild();
  122445. }
  122446. buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  122447. if (buffer) {
  122448. buffer._rebuild();
  122449. }
  122450. var scene = this._source.getScene();
  122451. var engine = scene.getEngine();
  122452. this._ib = engine.createIndexBuffer(this._linesIndices);
  122453. };
  122454. /**
  122455. * Releases the required resources for the edges renderer
  122456. */
  122457. EdgesRenderer.prototype.dispose = function () {
  122458. this._source.onRebuildObservable.remove(this._meshRebuildObserver);
  122459. this._source.onDisposeObservable.remove(this._meshDisposeObserver);
  122460. var buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  122461. if (buffer) {
  122462. buffer.dispose();
  122463. this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  122464. }
  122465. buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  122466. if (buffer) {
  122467. buffer.dispose();
  122468. this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind] = null;
  122469. }
  122470. this._source.getScene().getEngine()._releaseBuffer(this._ib);
  122471. this._lineShader.dispose();
  122472. };
  122473. EdgesRenderer.prototype._processEdgeForAdjacencies = function (pa, pb, p0, p1, p2) {
  122474. if (pa === p0 && pb === p1 || pa === p1 && pb === p0) {
  122475. return 0;
  122476. }
  122477. if (pa === p1 && pb === p2 || pa === p2 && pb === p1) {
  122478. return 1;
  122479. }
  122480. if (pa === p2 && pb === p0 || pa === p0 && pb === p2) {
  122481. return 2;
  122482. }
  122483. return -1;
  122484. };
  122485. EdgesRenderer.prototype._processEdgeForAdjacenciesWithVertices = function (pa, pb, p0, p1, p2) {
  122486. if (pa.equalsWithEpsilon(p0) && pb.equalsWithEpsilon(p1) || pa.equalsWithEpsilon(p1) && pb.equalsWithEpsilon(p0)) {
  122487. return 0;
  122488. }
  122489. if (pa.equalsWithEpsilon(p1) && pb.equalsWithEpsilon(p2) || pa.equalsWithEpsilon(p2) && pb.equalsWithEpsilon(p1)) {
  122490. return 1;
  122491. }
  122492. if (pa.equalsWithEpsilon(p2) && pb.equalsWithEpsilon(p0) || pa.equalsWithEpsilon(p0) && pb.equalsWithEpsilon(p2)) {
  122493. return 2;
  122494. }
  122495. return -1;
  122496. };
  122497. /**
  122498. * Checks if the pair of p0 and p1 is en edge
  122499. * @param faceIndex
  122500. * @param edge
  122501. * @param faceNormals
  122502. * @param p0
  122503. * @param p1
  122504. * @private
  122505. */
  122506. EdgesRenderer.prototype._checkEdge = function (faceIndex, edge, faceNormals, p0, p1) {
  122507. var needToCreateLine;
  122508. if (edge === undefined) {
  122509. needToCreateLine = true;
  122510. }
  122511. else {
  122512. var dotProduct = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Dot(faceNormals[faceIndex], faceNormals[edge]);
  122513. needToCreateLine = dotProduct < this._epsilon;
  122514. }
  122515. if (needToCreateLine) {
  122516. this.createLine(p0, p1, this._linesPositions.length / 3);
  122517. }
  122518. };
  122519. /**
  122520. * push line into the position, normal and index buffer
  122521. * @protected
  122522. */
  122523. EdgesRenderer.prototype.createLine = function (p0, p1, offset) {
  122524. // Positions
  122525. 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);
  122526. // Normals
  122527. 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);
  122528. // Indices
  122529. this._linesIndices.push(offset, offset + 1, offset + 2, offset, offset + 2, offset + 3);
  122530. };
  122531. /**
  122532. * Generates lines edges from adjacencjes
  122533. * @private
  122534. */
  122535. EdgesRenderer.prototype._generateEdgesLines = function () {
  122536. var positions = this._source.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  122537. var indices = this._source.getIndices();
  122538. if (!indices || !positions) {
  122539. return;
  122540. }
  122541. // First let's find adjacencies
  122542. var adjacencies = new Array();
  122543. var faceNormals = new Array();
  122544. var index;
  122545. var faceAdjacencies;
  122546. // Prepare faces
  122547. for (index = 0; index < indices.length; index += 3) {
  122548. faceAdjacencies = new FaceAdjacencies();
  122549. var p0Index = indices[index];
  122550. var p1Index = indices[index + 1];
  122551. var p2Index = indices[index + 2];
  122552. faceAdjacencies.p0 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p0Index * 3], positions[p0Index * 3 + 1], positions[p0Index * 3 + 2]);
  122553. faceAdjacencies.p1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p1Index * 3], positions[p1Index * 3 + 1], positions[p1Index * 3 + 2]);
  122554. faceAdjacencies.p2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p2Index * 3], positions[p2Index * 3 + 1], positions[p2Index * 3 + 2]);
  122555. var faceNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Cross(faceAdjacencies.p1.subtract(faceAdjacencies.p0), faceAdjacencies.p2.subtract(faceAdjacencies.p1));
  122556. faceNormal.normalize();
  122557. faceNormals.push(faceNormal);
  122558. adjacencies.push(faceAdjacencies);
  122559. }
  122560. // Scan
  122561. for (index = 0; index < adjacencies.length; index++) {
  122562. faceAdjacencies = adjacencies[index];
  122563. for (var otherIndex = index + 1; otherIndex < adjacencies.length; otherIndex++) {
  122564. var otherFaceAdjacencies = adjacencies[otherIndex];
  122565. if (faceAdjacencies.edgesConnectedCount === 3) { // Full
  122566. break;
  122567. }
  122568. if (otherFaceAdjacencies.edgesConnectedCount === 3) { // Full
  122569. continue;
  122570. }
  122571. var otherP0 = indices[otherIndex * 3];
  122572. var otherP1 = indices[otherIndex * 3 + 1];
  122573. var otherP2 = indices[otherIndex * 3 + 2];
  122574. for (var edgeIndex = 0; edgeIndex < 3; edgeIndex++) {
  122575. var otherEdgeIndex = 0;
  122576. if (faceAdjacencies.edges[edgeIndex] !== undefined) {
  122577. continue;
  122578. }
  122579. switch (edgeIndex) {
  122580. case 0:
  122581. if (this._checkVerticesInsteadOfIndices) {
  122582. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p0, faceAdjacencies.p1, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  122583. }
  122584. else {
  122585. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3], indices[index * 3 + 1], otherP0, otherP1, otherP2);
  122586. }
  122587. break;
  122588. case 1:
  122589. if (this._checkVerticesInsteadOfIndices) {
  122590. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p1, faceAdjacencies.p2, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  122591. }
  122592. else {
  122593. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3 + 1], indices[index * 3 + 2], otherP0, otherP1, otherP2);
  122594. }
  122595. break;
  122596. case 2:
  122597. if (this._checkVerticesInsteadOfIndices) {
  122598. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p2, faceAdjacencies.p0, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  122599. }
  122600. else {
  122601. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3 + 2], indices[index * 3], otherP0, otherP1, otherP2);
  122602. }
  122603. break;
  122604. }
  122605. if (otherEdgeIndex === -1) {
  122606. continue;
  122607. }
  122608. faceAdjacencies.edges[edgeIndex] = otherIndex;
  122609. otherFaceAdjacencies.edges[otherEdgeIndex] = index;
  122610. faceAdjacencies.edgesConnectedCount++;
  122611. otherFaceAdjacencies.edgesConnectedCount++;
  122612. if (faceAdjacencies.edgesConnectedCount === 3) {
  122613. break;
  122614. }
  122615. }
  122616. }
  122617. }
  122618. // Create lines
  122619. for (index = 0; index < adjacencies.length; index++) {
  122620. // 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
  122621. var current = adjacencies[index];
  122622. this._checkEdge(index, current.edges[0], faceNormals, current.p0, current.p1);
  122623. this._checkEdge(index, current.edges[1], faceNormals, current.p1, current.p2);
  122624. this._checkEdge(index, current.edges[2], faceNormals, current.p2, current.p0);
  122625. }
  122626. // Merge into a single mesh
  122627. var engine = this._source.getScene().getEngine();
  122628. 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);
  122629. 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);
  122630. this._ib = engine.createIndexBuffer(this._linesIndices);
  122631. this._indicesCount = this._linesIndices.length;
  122632. };
  122633. /**
  122634. * Checks wether or not the edges renderer is ready to render.
  122635. * @return true if ready, otherwise false.
  122636. */
  122637. EdgesRenderer.prototype.isReady = function () {
  122638. return this._lineShader.isReady();
  122639. };
  122640. /**
  122641. * Renders the edges of the attached mesh,
  122642. */
  122643. EdgesRenderer.prototype.render = function () {
  122644. var scene = this._source.getScene();
  122645. if (!this.isReady() || !scene.activeCamera) {
  122646. return;
  122647. }
  122648. var engine = scene.getEngine();
  122649. this._lineShader._preBind();
  122650. if (this._source.edgesColor.a !== 1) {
  122651. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE);
  122652. }
  122653. else {
  122654. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  122655. }
  122656. // VBOs
  122657. engine.bindBuffers(this._buffers, this._ib, this._lineShader.getEffect());
  122658. scene.resetCachedMaterial();
  122659. this._lineShader.setColor4("color", this._source.edgesColor);
  122660. if (scene.activeCamera.mode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_7__["Camera"].ORTHOGRAPHIC_CAMERA) {
  122661. this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForOrthographic);
  122662. }
  122663. else {
  122664. this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForPerspective);
  122665. }
  122666. this._lineShader.setFloat("aspectRatio", engine.getAspectRatio(scene.activeCamera));
  122667. this._lineShader.bind(this._source.getWorldMatrix());
  122668. // Draw order
  122669. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, this._indicesCount);
  122670. this._lineShader.unbind();
  122671. };
  122672. return EdgesRenderer;
  122673. }());
  122674. /**
  122675. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  122676. */
  122677. var LineEdgesRenderer = /** @class */ (function (_super) {
  122678. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LineEdgesRenderer, _super);
  122679. /**
  122680. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  122681. * @param source LineMesh used to generate edges
  122682. * @param epsilon not important (specified angle for edge detection)
  122683. * @param checkVerticesInsteadOfIndices not important for LineMesh
  122684. */
  122685. function LineEdgesRenderer(source, epsilon, checkVerticesInsteadOfIndices) {
  122686. if (epsilon === void 0) { epsilon = 0.95; }
  122687. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  122688. var _this = _super.call(this, source, epsilon, checkVerticesInsteadOfIndices, false) || this;
  122689. _this._generateEdgesLines();
  122690. return _this;
  122691. }
  122692. /**
  122693. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  122694. */
  122695. LineEdgesRenderer.prototype._generateEdgesLines = function () {
  122696. var positions = this._source.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  122697. var indices = this._source.getIndices();
  122698. if (!indices || !positions) {
  122699. return;
  122700. }
  122701. var p0 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[0];
  122702. var p1 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[1];
  122703. var len = indices.length - 1;
  122704. for (var i = 0, offset = 0; i < len; i += 2, offset += 4) {
  122705. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].FromArrayToRef(positions, 3 * indices[i], p0);
  122706. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].FromArrayToRef(positions, 3 * indices[i + 1], p1);
  122707. this.createLine(p0, p1, offset);
  122708. }
  122709. // Merge into a single mesh
  122710. var engine = this._source.getScene().getEngine();
  122711. 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);
  122712. 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);
  122713. this._ib = engine.createIndexBuffer(this._linesIndices);
  122714. this._indicesCount = this._linesIndices.length;
  122715. };
  122716. return LineEdgesRenderer;
  122717. }(EdgesRenderer));
  122718. /***/ }),
  122719. /***/ "./Rendering/geometryBufferRenderer.ts":
  122720. /*!*********************************************!*\
  122721. !*** ./Rendering/geometryBufferRenderer.ts ***!
  122722. \*********************************************/
  122723. /*! exports provided: GeometryBufferRenderer */
  122724. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122725. "use strict";
  122726. __webpack_require__.r(__webpack_exports__);
  122727. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return GeometryBufferRenderer; });
  122728. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  122729. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  122730. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  122731. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  122732. /* harmony import */ var _Materials_Textures_multiRenderTarget__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/multiRenderTarget */ "./Materials/Textures/multiRenderTarget.ts");
  122733. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  122734. /* harmony import */ var _Shaders_geometry_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/geometry.fragment */ "./Shaders/geometry.fragment.ts");
  122735. /* harmony import */ var _Shaders_geometry_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/geometry.vertex */ "./Shaders/geometry.vertex.ts");
  122736. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  122737. /**
  122738. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  122739. */
  122740. var GeometryBufferRenderer = /** @class */ (function () {
  122741. /**
  122742. * Creates a new G Buffer for the scene
  122743. * @param scene The scene the buffer belongs to
  122744. * @param ratio How big is the buffer related to the main canvas.
  122745. */
  122746. function GeometryBufferRenderer(scene, ratio) {
  122747. if (ratio === void 0) { ratio = 1; }
  122748. /**
  122749. * Dictionary used to store the previous transformation matrices of each rendered mesh
  122750. * in order to compute objects velocities when enableVelocity is set to "true"
  122751. * @hidden
  122752. */
  122753. this._previousTransformationMatrices = {};
  122754. this._enablePosition = false;
  122755. this._enableVelocity = false;
  122756. this._positionIndex = -1;
  122757. this._velocityIndex = -1;
  122758. this._scene = scene;
  122759. this._ratio = ratio;
  122760. GeometryBufferRenderer._SceneComponentInitialization(this._scene);
  122761. // Render target
  122762. this._createRenderTargets();
  122763. }
  122764. Object.defineProperty(GeometryBufferRenderer.prototype, "renderList", {
  122765. /**
  122766. * Set the render list (meshes to be rendered) used in the G buffer.
  122767. */
  122768. set: function (meshes) {
  122769. this._multiRenderTarget.renderList = meshes;
  122770. },
  122771. enumerable: true,
  122772. configurable: true
  122773. });
  122774. Object.defineProperty(GeometryBufferRenderer.prototype, "isSupported", {
  122775. /**
  122776. * Gets wether or not G buffer are supported by the running hardware.
  122777. * This requires draw buffer supports
  122778. */
  122779. get: function () {
  122780. return this._multiRenderTarget.isSupported;
  122781. },
  122782. enumerable: true,
  122783. configurable: true
  122784. });
  122785. /**
  122786. * Returns the index of the given texture type in the G-Buffer textures array
  122787. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  122788. * @returns the index of the given texture type in the G-Buffer textures array
  122789. */
  122790. GeometryBufferRenderer.prototype.getTextureIndex = function (textureType) {
  122791. switch (textureType) {
  122792. case GeometryBufferRenderer.POSITION_TEXTURE_TYPE: return this._positionIndex;
  122793. case GeometryBufferRenderer.VELOCITY_TEXTURE_TYPE: return this._velocityIndex;
  122794. default: return -1;
  122795. }
  122796. };
  122797. Object.defineProperty(GeometryBufferRenderer.prototype, "enablePosition", {
  122798. /**
  122799. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  122800. */
  122801. get: function () {
  122802. return this._enablePosition;
  122803. },
  122804. /**
  122805. * Sets whether or not objects positions are enabled for the G buffer.
  122806. */
  122807. set: function (enable) {
  122808. this._enablePosition = enable;
  122809. this.dispose();
  122810. this._createRenderTargets();
  122811. },
  122812. enumerable: true,
  122813. configurable: true
  122814. });
  122815. Object.defineProperty(GeometryBufferRenderer.prototype, "enableVelocity", {
  122816. /**
  122817. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  122818. */
  122819. get: function () {
  122820. return this._enableVelocity;
  122821. },
  122822. /**
  122823. * Sets wether or not objects velocities are enabled for the G buffer.
  122824. */
  122825. set: function (enable) {
  122826. this._enableVelocity = enable;
  122827. this.dispose();
  122828. this._createRenderTargets();
  122829. },
  122830. enumerable: true,
  122831. configurable: true
  122832. });
  122833. Object.defineProperty(GeometryBufferRenderer.prototype, "scene", {
  122834. /**
  122835. * Gets the scene associated with the buffer.
  122836. */
  122837. get: function () {
  122838. return this._scene;
  122839. },
  122840. enumerable: true,
  122841. configurable: true
  122842. });
  122843. Object.defineProperty(GeometryBufferRenderer.prototype, "ratio", {
  122844. /**
  122845. * Gets the ratio used by the buffer during its creation.
  122846. * How big is the buffer related to the main canvas.
  122847. */
  122848. get: function () {
  122849. return this._ratio;
  122850. },
  122851. enumerable: true,
  122852. configurable: true
  122853. });
  122854. /**
  122855. * Checks wether everything is ready to render a submesh to the G buffer.
  122856. * @param subMesh the submesh to check readiness for
  122857. * @param useInstances is the mesh drawn using instance or not
  122858. * @returns true if ready otherwise false
  122859. */
  122860. GeometryBufferRenderer.prototype.isReady = function (subMesh, useInstances) {
  122861. var material = subMesh.getMaterial();
  122862. if (material && material.disableDepthWrite) {
  122863. return false;
  122864. }
  122865. var defines = [];
  122866. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  122867. var mesh = subMesh.getMesh();
  122868. // Alpha test
  122869. if (material && material.needAlphaTesting()) {
  122870. defines.push("#define ALPHATEST");
  122871. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  122872. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  122873. defines.push("#define UV1");
  122874. }
  122875. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  122876. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  122877. defines.push("#define UV2");
  122878. }
  122879. }
  122880. // Buffers
  122881. if (this._enablePosition) {
  122882. defines.push("#define POSITION");
  122883. defines.push("#define POSITION_INDEX " + this._positionIndex);
  122884. }
  122885. if (this._enableVelocity) {
  122886. defines.push("#define VELOCITY");
  122887. defines.push("#define VELOCITY_INDEX " + this._velocityIndex);
  122888. }
  122889. // Bones
  122890. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  122891. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  122892. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  122893. if (mesh.numBoneInfluencers > 4) {
  122894. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind);
  122895. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind);
  122896. }
  122897. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  122898. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  122899. }
  122900. else {
  122901. defines.push("#define NUM_BONE_INFLUENCERS 0");
  122902. }
  122903. // Instances
  122904. if (useInstances) {
  122905. defines.push("#define INSTANCES");
  122906. attribs.push("world0");
  122907. attribs.push("world1");
  122908. attribs.push("world2");
  122909. attribs.push("world3");
  122910. }
  122911. // Setup textures count
  122912. defines.push("#define RENDER_TARGET_COUNT " + this._multiRenderTarget.textures.length);
  122913. // Get correct effect
  122914. var join = defines.join("\n");
  122915. if (this._cachedDefines !== join) {
  122916. this._cachedDefines = join;
  122917. this._effect = this._scene.getEngine().createEffect("geometry", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "view", "previousWorldViewProjection"], ["diffuseSampler"], join, undefined, undefined, undefined, { buffersCount: this._enablePosition ? 3 : 2 });
  122918. }
  122919. return this._effect.isReady();
  122920. };
  122921. /**
  122922. * Gets the current underlying G Buffer.
  122923. * @returns the buffer
  122924. */
  122925. GeometryBufferRenderer.prototype.getGBuffer = function () {
  122926. return this._multiRenderTarget;
  122927. };
  122928. Object.defineProperty(GeometryBufferRenderer.prototype, "samples", {
  122929. /**
  122930. * Gets the number of samples used to render the buffer (anti aliasing).
  122931. */
  122932. get: function () {
  122933. return this._multiRenderTarget.samples;
  122934. },
  122935. /**
  122936. * Sets the number of samples used to render the buffer (anti aliasing).
  122937. */
  122938. set: function (value) {
  122939. this._multiRenderTarget.samples = value;
  122940. },
  122941. enumerable: true,
  122942. configurable: true
  122943. });
  122944. /**
  122945. * Disposes the renderer and frees up associated resources.
  122946. */
  122947. GeometryBufferRenderer.prototype.dispose = function () {
  122948. this.getGBuffer().dispose();
  122949. };
  122950. GeometryBufferRenderer.prototype._createRenderTargets = function () {
  122951. var _this = this;
  122952. var engine = this._scene.getEngine();
  122953. var count = 2;
  122954. if (this._enablePosition) {
  122955. this._positionIndex = count;
  122956. count++;
  122957. }
  122958. if (this._enableVelocity) {
  122959. this._velocityIndex = count;
  122960. count++;
  122961. }
  122962. 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 });
  122963. if (!this.isSupported) {
  122964. return;
  122965. }
  122966. this._multiRenderTarget.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  122967. this._multiRenderTarget.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  122968. this._multiRenderTarget.refreshRate = 1;
  122969. this._multiRenderTarget.renderParticles = false;
  122970. this._multiRenderTarget.renderList = null;
  122971. // set default depth value to 1.0 (far away)
  122972. this._multiRenderTarget.onClearObservable.add(function (engine) {
  122973. engine.clear(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0.0, 0.0, 0.0, 1.0), true, true, true);
  122974. });
  122975. // Custom render function
  122976. var renderSubMesh = function (subMesh) {
  122977. var mesh = subMesh.getRenderingMesh();
  122978. var scene = _this._scene;
  122979. var engine = scene.getEngine();
  122980. var material = subMesh.getMaterial();
  122981. if (!material) {
  122982. return;
  122983. }
  122984. // Velocity
  122985. if (!_this._previousTransformationMatrices[mesh.uniqueId]) {
  122986. _this._previousTransformationMatrices[mesh.uniqueId] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity();
  122987. }
  122988. // Culling
  122989. engine.setState(material.backFaceCulling, 0, false, scene.useRightHandedSystem);
  122990. // Managing instances
  122991. var batch = mesh._getInstancesRenderList(subMesh._id);
  122992. if (batch.mustReturn) {
  122993. return;
  122994. }
  122995. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  122996. if (_this.isReady(subMesh, hardwareInstancedRendering)) {
  122997. engine.enableEffect(_this._effect);
  122998. mesh._bind(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode);
  122999. _this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  123000. _this._effect.setMatrix("view", scene.getViewMatrix());
  123001. // Alpha test
  123002. if (material && material.needAlphaTesting()) {
  123003. var alphaTexture = material.getAlphaTestTexture();
  123004. if (alphaTexture) {
  123005. _this._effect.setTexture("diffuseSampler", alphaTexture);
  123006. _this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  123007. }
  123008. }
  123009. // Bones
  123010. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  123011. _this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  123012. }
  123013. // Velocity
  123014. _this._effect.setMatrix("previousWorldViewProjection", _this._previousTransformationMatrices[mesh.uniqueId]);
  123015. // Draw
  123016. mesh._processRendering(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  123017. }
  123018. // Velocity
  123019. _this._previousTransformationMatrices[mesh.uniqueId] = mesh.getWorldMatrix().multiply(_this._scene.getTransformMatrix());
  123020. };
  123021. this._multiRenderTarget.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  123022. var index;
  123023. if (depthOnlySubMeshes.length) {
  123024. engine.setColorWrite(false);
  123025. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  123026. renderSubMesh(depthOnlySubMeshes.data[index]);
  123027. }
  123028. engine.setColorWrite(true);
  123029. }
  123030. for (index = 0; index < opaqueSubMeshes.length; index++) {
  123031. renderSubMesh(opaqueSubMeshes.data[index]);
  123032. }
  123033. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  123034. renderSubMesh(alphaTestSubMeshes.data[index]);
  123035. }
  123036. };
  123037. };
  123038. /**
  123039. * Constant used to retrieve the position texture index in the G-Buffer textures array
  123040. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  123041. */
  123042. GeometryBufferRenderer.POSITION_TEXTURE_TYPE = 1;
  123043. /**
  123044. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  123045. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  123046. */
  123047. GeometryBufferRenderer.VELOCITY_TEXTURE_TYPE = 2;
  123048. /** @hidden */
  123049. GeometryBufferRenderer._SceneComponentInitialization = function (_) {
  123050. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("GeometryBufferRendererSceneComponent");
  123051. };
  123052. return GeometryBufferRenderer;
  123053. }());
  123054. /***/ }),
  123055. /***/ "./Rendering/geometryBufferRendererSceneComponent.ts":
  123056. /*!***********************************************************!*\
  123057. !*** ./Rendering/geometryBufferRendererSceneComponent.ts ***!
  123058. \***********************************************************/
  123059. /*! exports provided: GeometryBufferRendererSceneComponent */
  123060. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123061. "use strict";
  123062. __webpack_require__.r(__webpack_exports__);
  123063. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return GeometryBufferRendererSceneComponent; });
  123064. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  123065. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  123066. /* harmony import */ var _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  123067. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "geometryBufferRenderer", {
  123068. get: function () {
  123069. this._geometryBufferRenderer;
  123070. },
  123071. set: function (value) {
  123072. if (value && value.isSupported) {
  123073. this._geometryBufferRenderer = value;
  123074. }
  123075. },
  123076. enumerable: true,
  123077. configurable: true
  123078. });
  123079. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.enableGeometryBufferRenderer = function (ratio) {
  123080. if (ratio === void 0) { ratio = 1; }
  123081. if (this._geometryBufferRenderer) {
  123082. return this._geometryBufferRenderer;
  123083. }
  123084. this._geometryBufferRenderer = new _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__["GeometryBufferRenderer"](this, ratio);
  123085. if (!this._geometryBufferRenderer.isSupported) {
  123086. this._geometryBufferRenderer = null;
  123087. }
  123088. return this._geometryBufferRenderer;
  123089. };
  123090. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.disableGeometryBufferRenderer = function () {
  123091. if (!this._geometryBufferRenderer) {
  123092. return;
  123093. }
  123094. this._geometryBufferRenderer.dispose();
  123095. this._geometryBufferRenderer = null;
  123096. };
  123097. /**
  123098. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  123099. * in several rendering techniques.
  123100. */
  123101. var GeometryBufferRendererSceneComponent = /** @class */ (function () {
  123102. /**
  123103. * Creates a new instance of the component for the given scene
  123104. * @param scene Defines the scene to register the component in
  123105. */
  123106. function GeometryBufferRendererSceneComponent(scene) {
  123107. /**
  123108. * The component name helpful to identify the component in the list of scene components.
  123109. */
  123110. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GEOMETRYBUFFERRENDERER;
  123111. this.scene = scene;
  123112. }
  123113. /**
  123114. * Registers the component in a given scene
  123115. */
  123116. GeometryBufferRendererSceneComponent.prototype.register = function () {
  123117. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER, this, this._gatherRenderTargets);
  123118. };
  123119. /**
  123120. * Rebuilds the elements related to this component in case of
  123121. * context lost for instance.
  123122. */
  123123. GeometryBufferRendererSceneComponent.prototype.rebuild = function () {
  123124. // Nothing to do for this component
  123125. };
  123126. /**
  123127. * Disposes the component and the associated ressources
  123128. */
  123129. GeometryBufferRendererSceneComponent.prototype.dispose = function () {
  123130. // Nothing to do for this component
  123131. };
  123132. GeometryBufferRendererSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  123133. if (this.scene._geometryBufferRenderer) {
  123134. renderTargets.push(this.scene._geometryBufferRenderer.getGBuffer());
  123135. }
  123136. };
  123137. return GeometryBufferRendererSceneComponent;
  123138. }());
  123139. _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__["GeometryBufferRenderer"]._SceneComponentInitialization = function (scene) {
  123140. // Register the G Buffer component to the scene.
  123141. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GEOMETRYBUFFERRENDERER);
  123142. if (!component) {
  123143. component = new GeometryBufferRendererSceneComponent(scene);
  123144. scene._addComponent(component);
  123145. }
  123146. };
  123147. /***/ }),
  123148. /***/ "./Rendering/index.ts":
  123149. /*!****************************!*\
  123150. !*** ./Rendering/index.ts ***!
  123151. \****************************/
  123152. /*! exports provided: BoundingBoxRenderer, DepthRenderer, DepthRendererSceneComponent, EdgesRenderer, LineEdgesRenderer, GeometryBufferRenderer, GeometryBufferRendererSceneComponent, OutlineRenderer, RenderingGroup, RenderingGroupInfo, RenderingManager, UtilityLayerRenderer */
  123153. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123154. "use strict";
  123155. __webpack_require__.r(__webpack_exports__);
  123156. /* harmony import */ var _boundingBoxRenderer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boundingBoxRenderer */ "./Rendering/boundingBoxRenderer.ts");
  123157. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _boundingBoxRenderer__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxRenderer"]; });
  123158. /* harmony import */ var _depthRenderer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthRenderer */ "./Rendering/depthRenderer.ts");
  123159. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"]; });
  123160. /* harmony import */ var _depthRendererSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./depthRendererSceneComponent */ "./Rendering/depthRendererSceneComponent.ts");
  123161. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _depthRendererSceneComponent__WEBPACK_IMPORTED_MODULE_2__["DepthRendererSceneComponent"]; });
  123162. /* harmony import */ var _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./edgesRenderer */ "./Rendering/edgesRenderer.ts");
  123163. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__["EdgesRenderer"]; });
  123164. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__["LineEdgesRenderer"]; });
  123165. /* harmony import */ var _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  123166. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_4__["GeometryBufferRenderer"]; });
  123167. /* harmony import */ var _geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./geometryBufferRendererSceneComponent */ "./Rendering/geometryBufferRendererSceneComponent.ts");
  123168. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_5__["GeometryBufferRendererSceneComponent"]; });
  123169. /* harmony import */ var _outlineRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./outlineRenderer */ "./Rendering/outlineRenderer.ts");
  123170. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _outlineRenderer__WEBPACK_IMPORTED_MODULE_6__["OutlineRenderer"]; });
  123171. /* harmony import */ var _renderingGroup__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./renderingGroup */ "./Rendering/renderingGroup.ts");
  123172. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _renderingGroup__WEBPACK_IMPORTED_MODULE_7__["RenderingGroup"]; });
  123173. /* harmony import */ var _renderingManager__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./renderingManager */ "./Rendering/renderingManager.ts");
  123174. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _renderingManager__WEBPACK_IMPORTED_MODULE_8__["RenderingGroupInfo"]; });
  123175. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _renderingManager__WEBPACK_IMPORTED_MODULE_8__["RenderingManager"]; });
  123176. /* harmony import */ var _utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  123177. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__["UtilityLayerRenderer"]; });
  123178. /***/ }),
  123179. /***/ "./Rendering/outlineRenderer.ts":
  123180. /*!**************************************!*\
  123181. !*** ./Rendering/outlineRenderer.ts ***!
  123182. \**************************************/
  123183. /*! exports provided: OutlineRenderer */
  123184. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123185. "use strict";
  123186. __webpack_require__.r(__webpack_exports__);
  123187. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return OutlineRenderer; });
  123188. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  123189. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  123190. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  123191. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  123192. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  123193. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  123194. /* harmony import */ var _Shaders_outline_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/outline.fragment */ "./Shaders/outline.fragment.ts");
  123195. /* harmony import */ var _Shaders_outline_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/outline.vertex */ "./Shaders/outline.vertex.ts");
  123196. /**
  123197. * Gets the outline renderer associated with the scene
  123198. * @returns a OutlineRenderer
  123199. */
  123200. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype.getOutlineRenderer = function () {
  123201. if (!this._outlineRenderer) {
  123202. this._outlineRenderer = new OutlineRenderer(this);
  123203. }
  123204. return this._outlineRenderer;
  123205. };
  123206. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "renderOutline", {
  123207. get: function () {
  123208. return this._renderOutline;
  123209. },
  123210. set: function (value) {
  123211. if (value) {
  123212. // Lazy Load the component.
  123213. this.getScene().getOutlineRenderer();
  123214. }
  123215. this._renderOutline = value;
  123216. },
  123217. enumerable: true,
  123218. configurable: true
  123219. });
  123220. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "renderOverlay", {
  123221. get: function () {
  123222. return this._renderOverlay;
  123223. },
  123224. set: function (value) {
  123225. if (value) {
  123226. // Lazy Load the component.
  123227. this.getScene().getOutlineRenderer();
  123228. }
  123229. this._renderOverlay = value;
  123230. },
  123231. enumerable: true,
  123232. configurable: true
  123233. });
  123234. /**
  123235. * This class is responsible to draw bothe outline/overlay of meshes.
  123236. * It should not be used directly but through the available method on mesh.
  123237. */
  123238. var OutlineRenderer = /** @class */ (function () {
  123239. /**
  123240. * Instantiates a new outline renderer. (There could be only one per scene).
  123241. * @param scene Defines the scene it belongs to
  123242. */
  123243. function OutlineRenderer(scene) {
  123244. /**
  123245. * The name of the component. Each component must have a unique name.
  123246. */
  123247. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OUTLINERENDERER;
  123248. /**
  123249. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  123250. */
  123251. this.zOffset = 1;
  123252. this.scene = scene;
  123253. this._engine = scene.getEngine();
  123254. this.scene._addComponent(this);
  123255. }
  123256. /**
  123257. * Register the component to one instance of a scene.
  123258. */
  123259. OutlineRenderer.prototype.register = function () {
  123260. this.scene._beforeRenderingMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_BEFORERENDERINGMESH_OUTLINE, this, this._beforeRenderingMesh);
  123261. this.scene._afterRenderingMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_AFTERRENDERINGMESH_OUTLINE, this, this._afterRenderingMesh);
  123262. };
  123263. /**
  123264. * Rebuilds the elements related to this component in case of
  123265. * context lost for instance.
  123266. */
  123267. OutlineRenderer.prototype.rebuild = function () {
  123268. // Nothing to do here.
  123269. };
  123270. /**
  123271. * Disposes the component and the associated ressources.
  123272. */
  123273. OutlineRenderer.prototype.dispose = function () {
  123274. // Nothing to do here.
  123275. };
  123276. /**
  123277. * Renders the outline in the canvas.
  123278. * @param subMesh Defines the sumesh to render
  123279. * @param batch Defines the batch of meshes in case of instances
  123280. * @param useOverlay Defines if the rendering is for the overlay or the outline
  123281. */
  123282. OutlineRenderer.prototype.render = function (subMesh, batch, useOverlay) {
  123283. var _this = this;
  123284. if (useOverlay === void 0) { useOverlay = false; }
  123285. var scene = this.scene;
  123286. var engine = scene.getEngine();
  123287. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  123288. if (!this.isReady(subMesh, hardwareInstancedRendering)) {
  123289. return;
  123290. }
  123291. var mesh = subMesh.getRenderingMesh();
  123292. var material = subMesh.getMaterial();
  123293. if (!material || !scene.activeCamera) {
  123294. return;
  123295. }
  123296. engine.enableEffect(this._effect);
  123297. // Logarithmic depth
  123298. if (material.useLogarithmicDepth) {
  123299. this._effect.setFloat("logarithmicDepthConstant", 2.0 / (Math.log(scene.activeCamera.maxZ + 1.0) / Math.LN2));
  123300. }
  123301. this._effect.setFloat("offset", useOverlay ? 0 : mesh.outlineWidth);
  123302. this._effect.setColor4("color", useOverlay ? mesh.overlayColor : mesh.outlineColor, useOverlay ? mesh.overlayAlpha : material.alpha);
  123303. this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  123304. // Bones
  123305. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  123306. this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  123307. }
  123308. mesh._bind(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode);
  123309. // Alpha test
  123310. if (material && material.needAlphaTesting()) {
  123311. var alphaTexture = material.getAlphaTestTexture();
  123312. if (alphaTexture) {
  123313. this._effect.setTexture("diffuseSampler", alphaTexture);
  123314. this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  123315. }
  123316. }
  123317. engine.setZOffset(-this.zOffset);
  123318. mesh._processRendering(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { _this._effect.setMatrix("world", world); });
  123319. engine.setZOffset(0);
  123320. };
  123321. /**
  123322. * Returns whether or not the outline renderer is ready for a given submesh.
  123323. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  123324. * @param subMesh Defines the submesh to check readyness for
  123325. * @param useInstances Defines wheter wee are trying to render instances or not
  123326. * @returns true if ready otherwise false
  123327. */
  123328. OutlineRenderer.prototype.isReady = function (subMesh, useInstances) {
  123329. var defines = [];
  123330. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].NormalKind];
  123331. var mesh = subMesh.getMesh();
  123332. var material = subMesh.getMaterial();
  123333. if (material) {
  123334. // Alpha test
  123335. if (material.needAlphaTesting()) {
  123336. defines.push("#define ALPHATEST");
  123337. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UVKind)) {
  123338. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UVKind);
  123339. defines.push("#define UV1");
  123340. }
  123341. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UV2Kind)) {
  123342. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UV2Kind);
  123343. defines.push("#define UV2");
  123344. }
  123345. }
  123346. //Logarithmic depth
  123347. if (material.useLogarithmicDepth) {
  123348. defines.push("#define LOGARITHMICDEPTH");
  123349. }
  123350. }
  123351. // Bones
  123352. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  123353. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesIndicesKind);
  123354. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesWeightsKind);
  123355. if (mesh.numBoneInfluencers > 4) {
  123356. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesIndicesExtraKind);
  123357. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesWeightsExtraKind);
  123358. }
  123359. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  123360. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  123361. }
  123362. else {
  123363. defines.push("#define NUM_BONE_INFLUENCERS 0");
  123364. }
  123365. // Instances
  123366. if (useInstances) {
  123367. defines.push("#define INSTANCES");
  123368. attribs.push("world0");
  123369. attribs.push("world1");
  123370. attribs.push("world2");
  123371. attribs.push("world3");
  123372. }
  123373. // Get correct effect
  123374. var join = defines.join("\n");
  123375. if (this._cachedDefines !== join) {
  123376. this._cachedDefines = join;
  123377. this._effect = this.scene.getEngine().createEffect("outline", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "offset", "color", "logarithmicDepthConstant"], ["diffuseSampler"], join);
  123378. }
  123379. return this._effect.isReady();
  123380. };
  123381. OutlineRenderer.prototype._beforeRenderingMesh = function (mesh, subMesh, batch) {
  123382. // Outline - step 1
  123383. this._savedDepthWrite = this._engine.getDepthWrite();
  123384. if (mesh.renderOutline) {
  123385. this._engine.setDepthWrite(false);
  123386. this.render(subMesh, batch);
  123387. this._engine.setDepthWrite(this._savedDepthWrite);
  123388. }
  123389. };
  123390. OutlineRenderer.prototype._afterRenderingMesh = function (mesh, subMesh, batch) {
  123391. // Outline - step 2
  123392. if (mesh.renderOutline && this._savedDepthWrite) {
  123393. this._engine.setDepthWrite(true);
  123394. this._engine.setColorWrite(false);
  123395. this.render(subMesh, batch);
  123396. this._engine.setColorWrite(true);
  123397. }
  123398. // Overlay
  123399. if (mesh.renderOverlay) {
  123400. var currentMode = this._engine.getAlphaMode();
  123401. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ALPHA_COMBINE);
  123402. this.render(subMesh, batch, true);
  123403. this._engine.setAlphaMode(currentMode);
  123404. }
  123405. };
  123406. return OutlineRenderer;
  123407. }());
  123408. /***/ }),
  123409. /***/ "./Rendering/renderingGroup.ts":
  123410. /*!*************************************!*\
  123411. !*** ./Rendering/renderingGroup.ts ***!
  123412. \*************************************/
  123413. /*! exports provided: RenderingGroup */
  123414. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123415. "use strict";
  123416. __webpack_require__.r(__webpack_exports__);
  123417. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return RenderingGroup; });
  123418. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  123419. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  123420. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  123421. /**
  123422. * This represents the object necessary to create a rendering group.
  123423. * This is exclusively used and created by the rendering manager.
  123424. * To modify the behavior, you use the available helpers in your scene or meshes.
  123425. * @hidden
  123426. */
  123427. var RenderingGroup = /** @class */ (function () {
  123428. /**
  123429. * Creates a new rendering group.
  123430. * @param index The rendering group index
  123431. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  123432. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  123433. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  123434. */
  123435. function RenderingGroup(index, scene, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  123436. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  123437. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  123438. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  123439. this.index = index;
  123440. this._opaqueSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  123441. this._transparentSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  123442. this._alphaTestSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  123443. this._depthOnlySubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  123444. this._particleSystems = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  123445. this._spriteManagers = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  123446. this._edgesRenderers = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](16);
  123447. this._scene = scene;
  123448. this.opaqueSortCompareFn = opaqueSortCompareFn;
  123449. this.alphaTestSortCompareFn = alphaTestSortCompareFn;
  123450. this.transparentSortCompareFn = transparentSortCompareFn;
  123451. }
  123452. Object.defineProperty(RenderingGroup.prototype, "opaqueSortCompareFn", {
  123453. /**
  123454. * Set the opaque sort comparison function.
  123455. * If null the sub meshes will be render in the order they were created
  123456. */
  123457. set: function (value) {
  123458. this._opaqueSortCompareFn = value;
  123459. if (value) {
  123460. this._renderOpaque = this.renderOpaqueSorted;
  123461. }
  123462. else {
  123463. this._renderOpaque = RenderingGroup.renderUnsorted;
  123464. }
  123465. },
  123466. enumerable: true,
  123467. configurable: true
  123468. });
  123469. Object.defineProperty(RenderingGroup.prototype, "alphaTestSortCompareFn", {
  123470. /**
  123471. * Set the alpha test sort comparison function.
  123472. * If null the sub meshes will be render in the order they were created
  123473. */
  123474. set: function (value) {
  123475. this._alphaTestSortCompareFn = value;
  123476. if (value) {
  123477. this._renderAlphaTest = this.renderAlphaTestSorted;
  123478. }
  123479. else {
  123480. this._renderAlphaTest = RenderingGroup.renderUnsorted;
  123481. }
  123482. },
  123483. enumerable: true,
  123484. configurable: true
  123485. });
  123486. Object.defineProperty(RenderingGroup.prototype, "transparentSortCompareFn", {
  123487. /**
  123488. * Set the transparent sort comparison function.
  123489. * If null the sub meshes will be render in the order they were created
  123490. */
  123491. set: function (value) {
  123492. if (value) {
  123493. this._transparentSortCompareFn = value;
  123494. }
  123495. else {
  123496. this._transparentSortCompareFn = RenderingGroup.defaultTransparentSortCompare;
  123497. }
  123498. this._renderTransparent = this.renderTransparentSorted;
  123499. },
  123500. enumerable: true,
  123501. configurable: true
  123502. });
  123503. /**
  123504. * Render all the sub meshes contained in the group.
  123505. * @param customRenderFunction Used to override the default render behaviour of the group.
  123506. * @returns true if rendered some submeshes.
  123507. */
  123508. RenderingGroup.prototype.render = function (customRenderFunction, renderSprites, renderParticles, activeMeshes) {
  123509. if (customRenderFunction) {
  123510. customRenderFunction(this._opaqueSubMeshes, this._alphaTestSubMeshes, this._transparentSubMeshes, this._depthOnlySubMeshes);
  123511. return;
  123512. }
  123513. var engine = this._scene.getEngine();
  123514. // Depth only
  123515. if (this._depthOnlySubMeshes.length !== 0) {
  123516. engine.setColorWrite(false);
  123517. this._renderAlphaTest(this._depthOnlySubMeshes);
  123518. engine.setColorWrite(true);
  123519. }
  123520. // Opaque
  123521. if (this._opaqueSubMeshes.length !== 0) {
  123522. this._renderOpaque(this._opaqueSubMeshes);
  123523. }
  123524. // Alpha test
  123525. if (this._alphaTestSubMeshes.length !== 0) {
  123526. this._renderAlphaTest(this._alphaTestSubMeshes);
  123527. }
  123528. var stencilState = engine.getStencilBuffer();
  123529. engine.setStencilBuffer(false);
  123530. // Sprites
  123531. if (renderSprites) {
  123532. this._renderSprites();
  123533. }
  123534. // Particles
  123535. if (renderParticles) {
  123536. this._renderParticles(activeMeshes);
  123537. }
  123538. if (this.onBeforeTransparentRendering) {
  123539. this.onBeforeTransparentRendering();
  123540. }
  123541. // Transparent
  123542. if (this._transparentSubMeshes.length !== 0) {
  123543. this._renderTransparent(this._transparentSubMeshes);
  123544. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  123545. }
  123546. // Set back stencil to false in case it changes before the edge renderer.
  123547. engine.setStencilBuffer(false);
  123548. // Edges
  123549. if (this._edgesRenderers.length) {
  123550. for (var edgesRendererIndex = 0; edgesRendererIndex < this._edgesRenderers.length; edgesRendererIndex++) {
  123551. this._edgesRenderers.data[edgesRendererIndex].render();
  123552. }
  123553. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  123554. }
  123555. // Restore Stencil state.
  123556. engine.setStencilBuffer(stencilState);
  123557. };
  123558. /**
  123559. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  123560. * @param subMeshes The submeshes to render
  123561. */
  123562. RenderingGroup.prototype.renderOpaqueSorted = function (subMeshes) {
  123563. return RenderingGroup.renderSorted(subMeshes, this._opaqueSortCompareFn, this._scene.activeCamera, false);
  123564. };
  123565. /**
  123566. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  123567. * @param subMeshes The submeshes to render
  123568. */
  123569. RenderingGroup.prototype.renderAlphaTestSorted = function (subMeshes) {
  123570. return RenderingGroup.renderSorted(subMeshes, this._alphaTestSortCompareFn, this._scene.activeCamera, false);
  123571. };
  123572. /**
  123573. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  123574. * @param subMeshes The submeshes to render
  123575. */
  123576. RenderingGroup.prototype.renderTransparentSorted = function (subMeshes) {
  123577. return RenderingGroup.renderSorted(subMeshes, this._transparentSortCompareFn, this._scene.activeCamera, true);
  123578. };
  123579. /**
  123580. * Renders the submeshes in a specified order.
  123581. * @param subMeshes The submeshes to sort before render
  123582. * @param sortCompareFn The comparison function use to sort
  123583. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  123584. * @param transparent Specifies to activate blending if true
  123585. */
  123586. RenderingGroup.renderSorted = function (subMeshes, sortCompareFn, camera, transparent) {
  123587. var subIndex = 0;
  123588. var subMesh;
  123589. var cameraPosition = camera ? camera.globalPosition : _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  123590. for (; subIndex < subMeshes.length; subIndex++) {
  123591. subMesh = subMeshes.data[subIndex];
  123592. subMesh._alphaIndex = subMesh.getMesh().alphaIndex;
  123593. subMesh._distanceToCamera = subMesh.getBoundingInfo().boundingSphere.centerWorld.subtract(cameraPosition).length();
  123594. }
  123595. var sortedArray = subMeshes.data.slice(0, subMeshes.length);
  123596. if (sortCompareFn) {
  123597. sortedArray.sort(sortCompareFn);
  123598. }
  123599. for (subIndex = 0; subIndex < sortedArray.length; subIndex++) {
  123600. subMesh = sortedArray[subIndex];
  123601. if (transparent) {
  123602. var material = subMesh.getMaterial();
  123603. if (material && material.needDepthPrePass) {
  123604. var engine = material.getScene().getEngine();
  123605. engine.setColorWrite(false);
  123606. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  123607. subMesh.render(false);
  123608. engine.setColorWrite(true);
  123609. }
  123610. }
  123611. subMesh.render(transparent);
  123612. }
  123613. };
  123614. /**
  123615. * Renders the submeshes in the order they were dispatched (no sort applied).
  123616. * @param subMeshes The submeshes to render
  123617. */
  123618. RenderingGroup.renderUnsorted = function (subMeshes) {
  123619. for (var subIndex = 0; subIndex < subMeshes.length; subIndex++) {
  123620. var submesh = subMeshes.data[subIndex];
  123621. submesh.render(false);
  123622. }
  123623. };
  123624. /**
  123625. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  123626. * are rendered back to front if in the same alpha index.
  123627. *
  123628. * @param a The first submesh
  123629. * @param b The second submesh
  123630. * @returns The result of the comparison
  123631. */
  123632. RenderingGroup.defaultTransparentSortCompare = function (a, b) {
  123633. // Alpha index first
  123634. if (a._alphaIndex > b._alphaIndex) {
  123635. return 1;
  123636. }
  123637. if (a._alphaIndex < b._alphaIndex) {
  123638. return -1;
  123639. }
  123640. // Then distance to camera
  123641. return RenderingGroup.backToFrontSortCompare(a, b);
  123642. };
  123643. /**
  123644. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  123645. * are rendered back to front.
  123646. *
  123647. * @param a The first submesh
  123648. * @param b The second submesh
  123649. * @returns The result of the comparison
  123650. */
  123651. RenderingGroup.backToFrontSortCompare = function (a, b) {
  123652. // Then distance to camera
  123653. if (a._distanceToCamera < b._distanceToCamera) {
  123654. return 1;
  123655. }
  123656. if (a._distanceToCamera > b._distanceToCamera) {
  123657. return -1;
  123658. }
  123659. return 0;
  123660. };
  123661. /**
  123662. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  123663. * are rendered front to back (prevent overdraw).
  123664. *
  123665. * @param a The first submesh
  123666. * @param b The second submesh
  123667. * @returns The result of the comparison
  123668. */
  123669. RenderingGroup.frontToBackSortCompare = function (a, b) {
  123670. // Then distance to camera
  123671. if (a._distanceToCamera < b._distanceToCamera) {
  123672. return -1;
  123673. }
  123674. if (a._distanceToCamera > b._distanceToCamera) {
  123675. return 1;
  123676. }
  123677. return 0;
  123678. };
  123679. /**
  123680. * Resets the different lists of submeshes to prepare a new frame.
  123681. */
  123682. RenderingGroup.prototype.prepare = function () {
  123683. this._opaqueSubMeshes.reset();
  123684. this._transparentSubMeshes.reset();
  123685. this._alphaTestSubMeshes.reset();
  123686. this._depthOnlySubMeshes.reset();
  123687. this._particleSystems.reset();
  123688. this._spriteManagers.reset();
  123689. this._edgesRenderers.reset();
  123690. };
  123691. RenderingGroup.prototype.dispose = function () {
  123692. this._opaqueSubMeshes.dispose();
  123693. this._transparentSubMeshes.dispose();
  123694. this._alphaTestSubMeshes.dispose();
  123695. this._depthOnlySubMeshes.dispose();
  123696. this._particleSystems.dispose();
  123697. this._spriteManagers.dispose();
  123698. this._edgesRenderers.dispose();
  123699. };
  123700. /**
  123701. * Inserts the submesh in its correct queue depending on its material.
  123702. * @param subMesh The submesh to dispatch
  123703. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  123704. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  123705. */
  123706. RenderingGroup.prototype.dispatch = function (subMesh, mesh, material) {
  123707. // Get mesh and materials if not provided
  123708. if (mesh === undefined) {
  123709. mesh = subMesh.getMesh();
  123710. }
  123711. if (material === undefined) {
  123712. material = subMesh.getMaterial();
  123713. }
  123714. if (material === null || material === undefined) {
  123715. return;
  123716. }
  123717. if (material.needAlphaBlendingForMesh(mesh)) { // Transparent
  123718. this._transparentSubMeshes.push(subMesh);
  123719. }
  123720. else if (material.needAlphaTesting()) { // Alpha test
  123721. if (material.needDepthPrePass) {
  123722. this._depthOnlySubMeshes.push(subMesh);
  123723. }
  123724. this._alphaTestSubMeshes.push(subMesh);
  123725. }
  123726. else {
  123727. if (material.needDepthPrePass) {
  123728. this._depthOnlySubMeshes.push(subMesh);
  123729. }
  123730. this._opaqueSubMeshes.push(subMesh); // Opaque
  123731. }
  123732. if (mesh._edgesRenderer && mesh._edgesRenderer.isEnabled) {
  123733. this._edgesRenderers.push(mesh._edgesRenderer);
  123734. }
  123735. };
  123736. RenderingGroup.prototype.dispatchSprites = function (spriteManager) {
  123737. this._spriteManagers.push(spriteManager);
  123738. };
  123739. RenderingGroup.prototype.dispatchParticles = function (particleSystem) {
  123740. this._particleSystems.push(particleSystem);
  123741. };
  123742. RenderingGroup.prototype._renderParticles = function (activeMeshes) {
  123743. if (this._particleSystems.length === 0) {
  123744. return;
  123745. }
  123746. // Particles
  123747. var activeCamera = this._scene.activeCamera;
  123748. this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);
  123749. for (var particleIndex = 0; particleIndex < this._particleSystems.length; particleIndex++) {
  123750. var particleSystem = this._particleSystems.data[particleIndex];
  123751. if ((activeCamera && activeCamera.layerMask & particleSystem.layerMask) === 0) {
  123752. continue;
  123753. }
  123754. var emitter = particleSystem.emitter;
  123755. if (!emitter.position || !activeMeshes || activeMeshes.indexOf(emitter) !== -1) {
  123756. this._scene._activeParticles.addCount(particleSystem.render(), false);
  123757. }
  123758. }
  123759. this._scene.onAfterParticlesRenderingObservable.notifyObservers(this._scene);
  123760. };
  123761. RenderingGroup.prototype._renderSprites = function () {
  123762. if (!this._scene.spritesEnabled || this._spriteManagers.length === 0) {
  123763. return;
  123764. }
  123765. // Sprites
  123766. var activeCamera = this._scene.activeCamera;
  123767. this._scene.onBeforeSpritesRenderingObservable.notifyObservers(this._scene);
  123768. for (var id = 0; id < this._spriteManagers.length; id++) {
  123769. var spriteManager = this._spriteManagers.data[id];
  123770. if (((activeCamera && activeCamera.layerMask & spriteManager.layerMask) !== 0)) {
  123771. spriteManager.render();
  123772. }
  123773. }
  123774. this._scene.onAfterSpritesRenderingObservable.notifyObservers(this._scene);
  123775. };
  123776. return RenderingGroup;
  123777. }());
  123778. /***/ }),
  123779. /***/ "./Rendering/renderingManager.ts":
  123780. /*!***************************************!*\
  123781. !*** ./Rendering/renderingManager.ts ***!
  123782. \***************************************/
  123783. /*! exports provided: RenderingGroupInfo, RenderingManager */
  123784. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123785. "use strict";
  123786. __webpack_require__.r(__webpack_exports__);
  123787. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return RenderingGroupInfo; });
  123788. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return RenderingManager; });
  123789. /* harmony import */ var _renderingGroup__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./renderingGroup */ "./Rendering/renderingGroup.ts");
  123790. /**
  123791. * This class is used by the onRenderingGroupObservable
  123792. */
  123793. var RenderingGroupInfo = /** @class */ (function () {
  123794. function RenderingGroupInfo() {
  123795. }
  123796. return RenderingGroupInfo;
  123797. }());
  123798. /**
  123799. * This is the manager responsible of all the rendering for meshes sprites and particles.
  123800. * It is enable to manage the different groups as well as the different necessary sort functions.
  123801. * This should not be used directly aside of the few static configurations
  123802. */
  123803. var RenderingManager = /** @class */ (function () {
  123804. /**
  123805. * Instantiates a new rendering group for a particular scene
  123806. * @param scene Defines the scene the groups belongs to
  123807. */
  123808. function RenderingManager(scene) {
  123809. /**
  123810. * @hidden
  123811. */
  123812. this._useSceneAutoClearSetup = false;
  123813. this._renderingGroups = new Array();
  123814. this._autoClearDepthStencil = {};
  123815. this._customOpaqueSortCompareFn = {};
  123816. this._customAlphaTestSortCompareFn = {};
  123817. this._customTransparentSortCompareFn = {};
  123818. this._renderingGroupInfo = new RenderingGroupInfo();
  123819. this._scene = scene;
  123820. for (var i = RenderingManager.MIN_RENDERINGGROUPS; i < RenderingManager.MAX_RENDERINGGROUPS; i++) {
  123821. this._autoClearDepthStencil[i] = { autoClear: true, depth: true, stencil: true };
  123822. }
  123823. }
  123824. RenderingManager.prototype._clearDepthStencilBuffer = function (depth, stencil) {
  123825. if (depth === void 0) { depth = true; }
  123826. if (stencil === void 0) { stencil = true; }
  123827. if (this._depthStencilBufferAlreadyCleaned) {
  123828. return;
  123829. }
  123830. this._scene.getEngine().clear(null, false, depth, stencil);
  123831. this._depthStencilBufferAlreadyCleaned = true;
  123832. };
  123833. /**
  123834. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  123835. * @hidden
  123836. */
  123837. RenderingManager.prototype.render = function (customRenderFunction, activeMeshes, renderParticles, renderSprites) {
  123838. // Update the observable context (not null as it only goes away on dispose)
  123839. var info = this._renderingGroupInfo;
  123840. info.scene = this._scene;
  123841. info.camera = this._scene.activeCamera;
  123842. // Dispatch sprites
  123843. if (this._scene.spriteManagers && renderSprites) {
  123844. for (var index = 0; index < this._scene.spriteManagers.length; index++) {
  123845. var manager = this._scene.spriteManagers[index];
  123846. this.dispatchSprites(manager);
  123847. }
  123848. }
  123849. // Render
  123850. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  123851. this._depthStencilBufferAlreadyCleaned = index === RenderingManager.MIN_RENDERINGGROUPS;
  123852. var renderingGroup = this._renderingGroups[index];
  123853. if (!renderingGroup) {
  123854. continue;
  123855. }
  123856. var renderingGroupMask = Math.pow(2, index);
  123857. info.renderingGroupId = index;
  123858. // Before Observable
  123859. this._scene.onBeforeRenderingGroupObservable.notifyObservers(info, renderingGroupMask);
  123860. // Clear depth/stencil if needed
  123861. if (RenderingManager.AUTOCLEAR) {
  123862. var autoClear = this._useSceneAutoClearSetup ?
  123863. this._scene.getAutoClearDepthStencilSetup(index) :
  123864. this._autoClearDepthStencil[index];
  123865. if (autoClear && autoClear.autoClear) {
  123866. this._clearDepthStencilBuffer(autoClear.depth, autoClear.stencil);
  123867. }
  123868. }
  123869. // Render
  123870. for (var _i = 0, _a = this._scene._beforeRenderingGroupDrawStage; _i < _a.length; _i++) {
  123871. var step = _a[_i];
  123872. step.action(index);
  123873. }
  123874. renderingGroup.render(customRenderFunction, renderSprites, renderParticles, activeMeshes);
  123875. for (var _b = 0, _c = this._scene._afterRenderingGroupDrawStage; _b < _c.length; _b++) {
  123876. var step = _c[_b];
  123877. step.action(index);
  123878. }
  123879. // After Observable
  123880. this._scene.onAfterRenderingGroupObservable.notifyObservers(info, renderingGroupMask);
  123881. }
  123882. };
  123883. /**
  123884. * Resets the different information of the group to prepare a new frame
  123885. * @hidden
  123886. */
  123887. RenderingManager.prototype.reset = function () {
  123888. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  123889. var renderingGroup = this._renderingGroups[index];
  123890. if (renderingGroup) {
  123891. renderingGroup.prepare();
  123892. }
  123893. }
  123894. };
  123895. /**
  123896. * Dispose and release the group and its associated resources.
  123897. * @hidden
  123898. */
  123899. RenderingManager.prototype.dispose = function () {
  123900. this.freeRenderingGroups();
  123901. this._renderingGroups.length = 0;
  123902. this._renderingGroupInfo = null;
  123903. };
  123904. /**
  123905. * Clear the info related to rendering groups preventing retention points during dispose.
  123906. */
  123907. RenderingManager.prototype.freeRenderingGroups = function () {
  123908. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  123909. var renderingGroup = this._renderingGroups[index];
  123910. if (renderingGroup) {
  123911. renderingGroup.dispose();
  123912. }
  123913. }
  123914. };
  123915. RenderingManager.prototype._prepareRenderingGroup = function (renderingGroupId) {
  123916. if (this._renderingGroups[renderingGroupId] === undefined) {
  123917. this._renderingGroups[renderingGroupId] = new _renderingGroup__WEBPACK_IMPORTED_MODULE_0__["RenderingGroup"](renderingGroupId, this._scene, this._customOpaqueSortCompareFn[renderingGroupId], this._customAlphaTestSortCompareFn[renderingGroupId], this._customTransparentSortCompareFn[renderingGroupId]);
  123918. }
  123919. };
  123920. /**
  123921. * Add a sprite manager to the rendering manager in order to render it this frame.
  123922. * @param spriteManager Define the sprite manager to render
  123923. */
  123924. RenderingManager.prototype.dispatchSprites = function (spriteManager) {
  123925. var renderingGroupId = spriteManager.renderingGroupId || 0;
  123926. this._prepareRenderingGroup(renderingGroupId);
  123927. this._renderingGroups[renderingGroupId].dispatchSprites(spriteManager);
  123928. };
  123929. /**
  123930. * Add a particle system to the rendering manager in order to render it this frame.
  123931. * @param particleSystem Define the particle system to render
  123932. */
  123933. RenderingManager.prototype.dispatchParticles = function (particleSystem) {
  123934. var renderingGroupId = particleSystem.renderingGroupId || 0;
  123935. this._prepareRenderingGroup(renderingGroupId);
  123936. this._renderingGroups[renderingGroupId].dispatchParticles(particleSystem);
  123937. };
  123938. /**
  123939. * Add a submesh to the manager in order to render it this frame
  123940. * @param subMesh The submesh to dispatch
  123941. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  123942. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  123943. */
  123944. RenderingManager.prototype.dispatch = function (subMesh, mesh, material) {
  123945. if (mesh === undefined) {
  123946. mesh = subMesh.getMesh();
  123947. }
  123948. var renderingGroupId = mesh.renderingGroupId || 0;
  123949. this._prepareRenderingGroup(renderingGroupId);
  123950. this._renderingGroups[renderingGroupId].dispatch(subMesh, mesh, material);
  123951. };
  123952. /**
  123953. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  123954. * This allowed control for front to back rendering or reversly depending of the special needs.
  123955. *
  123956. * @param renderingGroupId The rendering group id corresponding to its index
  123957. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  123958. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  123959. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  123960. */
  123961. RenderingManager.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  123962. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  123963. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  123964. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  123965. this._customOpaqueSortCompareFn[renderingGroupId] = opaqueSortCompareFn;
  123966. this._customAlphaTestSortCompareFn[renderingGroupId] = alphaTestSortCompareFn;
  123967. this._customTransparentSortCompareFn[renderingGroupId] = transparentSortCompareFn;
  123968. if (this._renderingGroups[renderingGroupId]) {
  123969. var group = this._renderingGroups[renderingGroupId];
  123970. group.opaqueSortCompareFn = this._customOpaqueSortCompareFn[renderingGroupId];
  123971. group.alphaTestSortCompareFn = this._customAlphaTestSortCompareFn[renderingGroupId];
  123972. group.transparentSortCompareFn = this._customTransparentSortCompareFn[renderingGroupId];
  123973. }
  123974. };
  123975. /**
  123976. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  123977. *
  123978. * @param renderingGroupId The rendering group id corresponding to its index
  123979. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  123980. * @param depth Automatically clears depth between groups if true and autoClear is true.
  123981. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  123982. */
  123983. RenderingManager.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil, depth, stencil) {
  123984. if (depth === void 0) { depth = true; }
  123985. if (stencil === void 0) { stencil = true; }
  123986. this._autoClearDepthStencil[renderingGroupId] = {
  123987. autoClear: autoClearDepthStencil,
  123988. depth: depth,
  123989. stencil: stencil
  123990. };
  123991. };
  123992. /**
  123993. * Gets the current auto clear configuration for one rendering group of the rendering
  123994. * manager.
  123995. * @param index the rendering group index to get the information for
  123996. * @returns The auto clear setup for the requested rendering group
  123997. */
  123998. RenderingManager.prototype.getAutoClearDepthStencilSetup = function (index) {
  123999. return this._autoClearDepthStencil[index];
  124000. };
  124001. /**
  124002. * The max id used for rendering groups (not included)
  124003. */
  124004. RenderingManager.MAX_RENDERINGGROUPS = 4;
  124005. /**
  124006. * The min id used for rendering groups (included)
  124007. */
  124008. RenderingManager.MIN_RENDERINGGROUPS = 0;
  124009. /**
  124010. * Used to globally prevent autoclearing scenes.
  124011. */
  124012. RenderingManager.AUTOCLEAR = true;
  124013. return RenderingManager;
  124014. }());
  124015. /***/ }),
  124016. /***/ "./Rendering/utilityLayerRenderer.ts":
  124017. /*!*******************************************!*\
  124018. !*** ./Rendering/utilityLayerRenderer.ts ***!
  124019. \*******************************************/
  124020. /*! exports provided: UtilityLayerRenderer */
  124021. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124022. "use strict";
  124023. __webpack_require__.r(__webpack_exports__);
  124024. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return UtilityLayerRenderer; });
  124025. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  124026. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  124027. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Events/pointerEvents */ "./Events/pointerEvents.ts");
  124028. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  124029. /**
  124030. * Renders a layer on top of an existing scene
  124031. */
  124032. var UtilityLayerRenderer = /** @class */ (function () {
  124033. /**
  124034. * Instantiates a UtilityLayerRenderer
  124035. * @param originalScene the original scene that will be rendered on top of
  124036. * @param handleEvents boolean indicating if the utility layer should handle events
  124037. */
  124038. function UtilityLayerRenderer(
  124039. /** the original scene that will be rendered on top of */
  124040. originalScene, handleEvents) {
  124041. if (handleEvents === void 0) { handleEvents = true; }
  124042. var _this = this;
  124043. this.originalScene = originalScene;
  124044. this._pointerCaptures = {};
  124045. this._lastPointerEvents = {};
  124046. /**
  124047. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  124048. */
  124049. this.pickUtilitySceneFirst = true;
  124050. /**
  124051. * If the utility layer should automatically be rendered on top of existing scene
  124052. */
  124053. this.shouldRender = true;
  124054. /**
  124055. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  124056. */
  124057. this.onlyCheckPointerDownEvents = true;
  124058. /**
  124059. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  124060. */
  124061. this.processAllEvents = false;
  124062. /**
  124063. * Observable raised when the pointer move from the utility layer scene to the main scene
  124064. */
  124065. this.onPointerOutObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  124066. // Create scene which will be rendered in the foreground and remove it from being referenced by engine to avoid interfering with existing app
  124067. this.utilityLayerScene = new _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"](originalScene.getEngine());
  124068. this.utilityLayerScene.useRightHandedSystem = originalScene.useRightHandedSystem;
  124069. this.utilityLayerScene._allowPostProcessClearColor = false;
  124070. originalScene.getEngine().scenes.pop();
  124071. // Detach controls on utility scene, events will be fired by logic below to handle picking priority
  124072. this.utilityLayerScene.detachControl();
  124073. if (handleEvents) {
  124074. this._originalPointerObserver = originalScene.onPrePointerObservable.add(function (prePointerInfo, eventState) {
  124075. if (!_this.utilityLayerScene.activeCamera) {
  124076. return;
  124077. }
  124078. if (!_this.processAllEvents) {
  124079. if (prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERMOVE
  124080. && prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP
  124081. && prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  124082. return;
  124083. }
  124084. }
  124085. _this.utilityLayerScene.pointerX = originalScene.pointerX;
  124086. _this.utilityLayerScene.pointerY = originalScene.pointerY;
  124087. var pointerEvent = (prePointerInfo.event);
  124088. if (originalScene.isPointerCaptured(pointerEvent.pointerId)) {
  124089. _this._pointerCaptures[pointerEvent.pointerId] = false;
  124090. return;
  124091. }
  124092. var utilityScenePick = prePointerInfo.ray ? _this.utilityLayerScene.pickWithRay(prePointerInfo.ray) : _this.utilityLayerScene.pick(originalScene.pointerX, originalScene.pointerY);
  124093. if (!prePointerInfo.ray && utilityScenePick) {
  124094. prePointerInfo.ray = utilityScenePick.ray;
  124095. }
  124096. // always fire the prepointer oversvable
  124097. _this.utilityLayerScene.onPrePointerObservable.notifyObservers(prePointerInfo);
  124098. // allow every non pointer down event to flow to the utility layer
  124099. if (_this.onlyCheckPointerDownEvents && prePointerInfo.type != _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  124100. if (!prePointerInfo.skipOnPointerObservable) {
  124101. _this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, utilityScenePick));
  124102. }
  124103. if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP && _this._pointerCaptures[pointerEvent.pointerId]) {
  124104. _this._pointerCaptures[pointerEvent.pointerId] = false;
  124105. }
  124106. return;
  124107. }
  124108. if (_this.utilityLayerScene.autoClearDepthAndStencil || _this.pickUtilitySceneFirst) {
  124109. // If this layer is an overlay, check if this layer was hit and if so, skip pointer events for the main scene
  124110. if (utilityScenePick && utilityScenePick.hit) {
  124111. if (!prePointerInfo.skipOnPointerObservable) {
  124112. _this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, utilityScenePick));
  124113. }
  124114. prePointerInfo.skipOnPointerObservable = true;
  124115. }
  124116. }
  124117. else {
  124118. var originalScenePick = prePointerInfo.ray ? originalScene.pickWithRay(prePointerInfo.ray) : originalScene.pick(originalScene.pointerX, originalScene.pointerY);
  124119. var pointerEvent_1 = (prePointerInfo.event);
  124120. // If the layer can be occluded by the original scene, only fire pointer events to the first layer that hit they ray
  124121. if (originalScenePick && utilityScenePick) {
  124122. // No pick in utility scene
  124123. if (utilityScenePick.distance === 0 && originalScenePick.pickedMesh) {
  124124. if (_this.mainSceneTrackerPredicate && _this.mainSceneTrackerPredicate(originalScenePick.pickedMesh)) {
  124125. // We touched an utility mesh present in the main scene
  124126. _this._notifyObservers(prePointerInfo, originalScenePick, pointerEvent_1);
  124127. prePointerInfo.skipOnPointerObservable = true;
  124128. }
  124129. else if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  124130. _this._pointerCaptures[pointerEvent_1.pointerId] = true;
  124131. }
  124132. else if (_this._lastPointerEvents[pointerEvent_1.pointerId]) {
  124133. // We need to send a last pointerup to the utilityLayerScene to make sure animations can complete
  124134. _this.onPointerOutObservable.notifyObservers(pointerEvent_1.pointerId);
  124135. delete _this._lastPointerEvents[pointerEvent_1.pointerId];
  124136. }
  124137. }
  124138. else if (!_this._pointerCaptures[pointerEvent_1.pointerId] && (utilityScenePick.distance < originalScenePick.distance || originalScenePick.distance === 0)) {
  124139. // We pick something in utility scene or the pick in utility is closer than the one in main scene
  124140. _this._notifyObservers(prePointerInfo, utilityScenePick, pointerEvent_1);
  124141. // If a previous utility layer set this, do not unset this
  124142. if (!prePointerInfo.skipOnPointerObservable) {
  124143. prePointerInfo.skipOnPointerObservable = utilityScenePick.distance > 0;
  124144. }
  124145. }
  124146. else if (!_this._pointerCaptures[pointerEvent_1.pointerId] && (utilityScenePick.distance > originalScenePick.distance)) {
  124147. // We have a pick in both scenes but main is closer than utility
  124148. // We touched an utility mesh present in the main scene
  124149. if (_this.mainSceneTrackerPredicate && _this.mainSceneTrackerPredicate(originalScenePick.pickedMesh)) {
  124150. _this._notifyObservers(prePointerInfo, originalScenePick, pointerEvent_1);
  124151. prePointerInfo.skipOnPointerObservable = true;
  124152. }
  124153. else if (_this._lastPointerEvents[pointerEvent_1.pointerId]) {
  124154. // We need to send a last pointerup to the utilityLayerScene to make sure animations can complete
  124155. _this.onPointerOutObservable.notifyObservers(pointerEvent_1.pointerId);
  124156. delete _this._lastPointerEvents[pointerEvent_1.pointerId];
  124157. }
  124158. }
  124159. if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP && _this._pointerCaptures[pointerEvent_1.pointerId]) {
  124160. _this._pointerCaptures[pointerEvent_1.pointerId] = false;
  124161. }
  124162. }
  124163. }
  124164. });
  124165. }
  124166. // Render directly on top of existing scene without clearing
  124167. this.utilityLayerScene.autoClear = false;
  124168. this._afterRenderObserver = this.originalScene.onAfterRenderObservable.add(function () {
  124169. if (_this.shouldRender) {
  124170. _this.render();
  124171. }
  124172. });
  124173. this._sceneDisposeObserver = this.originalScene.onDisposeObservable.add(function () {
  124174. _this.dispose();
  124175. });
  124176. this._updateCamera();
  124177. }
  124178. Object.defineProperty(UtilityLayerRenderer, "DefaultUtilityLayer", {
  124179. /**
  124180. * 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)
  124181. */
  124182. get: function () {
  124183. if (UtilityLayerRenderer._DefaultUtilityLayer == null) {
  124184. UtilityLayerRenderer._DefaultUtilityLayer = new UtilityLayerRenderer(_Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene);
  124185. UtilityLayerRenderer._DefaultUtilityLayer.originalScene.onDisposeObservable.addOnce(function () {
  124186. UtilityLayerRenderer._DefaultUtilityLayer = null;
  124187. });
  124188. }
  124189. return UtilityLayerRenderer._DefaultUtilityLayer;
  124190. },
  124191. enumerable: true,
  124192. configurable: true
  124193. });
  124194. Object.defineProperty(UtilityLayerRenderer, "DefaultKeepDepthUtilityLayer", {
  124195. /**
  124196. * 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)
  124197. */
  124198. get: function () {
  124199. if (UtilityLayerRenderer._DefaultKeepDepthUtilityLayer == null) {
  124200. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = new UtilityLayerRenderer(_Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene);
  124201. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  124202. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer.originalScene.onDisposeObservable.addOnce(function () {
  124203. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = null;
  124204. });
  124205. }
  124206. return UtilityLayerRenderer._DefaultKeepDepthUtilityLayer;
  124207. },
  124208. enumerable: true,
  124209. configurable: true
  124210. });
  124211. UtilityLayerRenderer.prototype._notifyObservers = function (prePointerInfo, pickInfo, pointerEvent) {
  124212. if (!prePointerInfo.skipOnPointerObservable) {
  124213. this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, pickInfo));
  124214. this._lastPointerEvents[pointerEvent.pointerId] = true;
  124215. }
  124216. };
  124217. /**
  124218. * Renders the utility layers scene on top of the original scene
  124219. */
  124220. UtilityLayerRenderer.prototype.render = function () {
  124221. this._updateCamera();
  124222. if (this.utilityLayerScene.activeCamera) {
  124223. // Set the camera's scene to utility layers scene
  124224. var oldScene = this.utilityLayerScene.activeCamera.getScene();
  124225. var camera = this.utilityLayerScene.activeCamera;
  124226. camera._scene = this.utilityLayerScene;
  124227. if (camera.leftCamera) {
  124228. camera.leftCamera._scene = this.utilityLayerScene;
  124229. }
  124230. if (camera.rightCamera) {
  124231. camera.rightCamera._scene = this.utilityLayerScene;
  124232. }
  124233. this.utilityLayerScene.render(false);
  124234. // Reset camera's scene back to original
  124235. camera._scene = oldScene;
  124236. if (camera.leftCamera) {
  124237. camera.leftCamera._scene = oldScene;
  124238. }
  124239. if (camera.rightCamera) {
  124240. camera.rightCamera._scene = oldScene;
  124241. }
  124242. }
  124243. };
  124244. /**
  124245. * Disposes of the renderer
  124246. */
  124247. UtilityLayerRenderer.prototype.dispose = function () {
  124248. this.onPointerOutObservable.clear();
  124249. if (this._afterRenderObserver) {
  124250. this.originalScene.onAfterRenderObservable.remove(this._afterRenderObserver);
  124251. }
  124252. if (this._sceneDisposeObserver) {
  124253. this.originalScene.onDisposeObservable.remove(this._sceneDisposeObserver);
  124254. }
  124255. if (this._originalPointerObserver) {
  124256. this.originalScene.onPrePointerObservable.remove(this._originalPointerObserver);
  124257. }
  124258. this.utilityLayerScene.dispose();
  124259. };
  124260. UtilityLayerRenderer.prototype._updateCamera = function () {
  124261. if (this.originalScene.activeCameras.length > 1) {
  124262. this.utilityLayerScene.activeCamera = this.originalScene.activeCameras[this.originalScene.activeCameras.length - 1];
  124263. }
  124264. else {
  124265. this.utilityLayerScene.activeCamera = this.originalScene.activeCamera;
  124266. }
  124267. };
  124268. UtilityLayerRenderer._DefaultUtilityLayer = null;
  124269. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = null;
  124270. return UtilityLayerRenderer;
  124271. }());
  124272. /***/ }),
  124273. /***/ "./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts":
  124274. /*!*****************************************************************!*\
  124275. !*** ./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts ***!
  124276. \*****************************************************************/
  124277. /*! exports provided: backgroundFragmentDeclaration */
  124278. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124279. "use strict";
  124280. __webpack_require__.r(__webpack_exports__);
  124281. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundFragmentDeclaration", function() { return backgroundFragmentDeclaration; });
  124282. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124283. var name = 'backgroundFragmentDeclaration';
  124284. 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";
  124285. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124286. /** @hidden */
  124287. var backgroundFragmentDeclaration = { name: name, shader: shader };
  124288. /***/ }),
  124289. /***/ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts":
  124290. /*!************************************************************!*\
  124291. !*** ./Shaders/ShadersInclude/backgroundUboDeclaration.ts ***!
  124292. \************************************************************/
  124293. /*! exports provided: backgroundUboDeclaration */
  124294. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124295. "use strict";
  124296. __webpack_require__.r(__webpack_exports__);
  124297. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundUboDeclaration", function() { return backgroundUboDeclaration; });
  124298. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124299. var name = 'backgroundUboDeclaration';
  124300. 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};";
  124301. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124302. /** @hidden */
  124303. var backgroundUboDeclaration = { name: name, shader: shader };
  124304. /***/ }),
  124305. /***/ "./Shaders/ShadersInclude/backgroundVertexDeclaration.ts":
  124306. /*!***************************************************************!*\
  124307. !*** ./Shaders/ShadersInclude/backgroundVertexDeclaration.ts ***!
  124308. \***************************************************************/
  124309. /*! exports provided: backgroundVertexDeclaration */
  124310. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124311. "use strict";
  124312. __webpack_require__.r(__webpack_exports__);
  124313. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundVertexDeclaration", function() { return backgroundVertexDeclaration; });
  124314. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124315. var name = 'backgroundVertexDeclaration';
  124316. 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";
  124317. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124318. /** @hidden */
  124319. var backgroundVertexDeclaration = { name: name, shader: shader };
  124320. /***/ }),
  124321. /***/ "./Shaders/ShadersInclude/bonesDeclaration.ts":
  124322. /*!****************************************************!*\
  124323. !*** ./Shaders/ShadersInclude/bonesDeclaration.ts ***!
  124324. \****************************************************/
  124325. /*! exports provided: bonesDeclaration */
  124326. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124327. "use strict";
  124328. __webpack_require__.r(__webpack_exports__);
  124329. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bonesDeclaration", function() { return bonesDeclaration; });
  124330. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124331. var name = 'bonesDeclaration';
  124332. 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";
  124333. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124334. /** @hidden */
  124335. var bonesDeclaration = { name: name, shader: shader };
  124336. /***/ }),
  124337. /***/ "./Shaders/ShadersInclude/bonesVertex.ts":
  124338. /*!***********************************************!*\
  124339. !*** ./Shaders/ShadersInclude/bonesVertex.ts ***!
  124340. \***********************************************/
  124341. /*! exports provided: bonesVertex */
  124342. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124343. "use strict";
  124344. __webpack_require__.r(__webpack_exports__);
  124345. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bonesVertex", function() { return bonesVertex; });
  124346. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124347. var name = 'bonesVertex';
  124348. 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";
  124349. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124350. /** @hidden */
  124351. var bonesVertex = { name: name, shader: shader };
  124352. /***/ }),
  124353. /***/ "./Shaders/ShadersInclude/bumpFragment.ts":
  124354. /*!************************************************!*\
  124355. !*** ./Shaders/ShadersInclude/bumpFragment.ts ***!
  124356. \************************************************/
  124357. /*! exports provided: bumpFragment */
  124358. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124359. "use strict";
  124360. __webpack_require__.r(__webpack_exports__);
  124361. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpFragment", function() { return bumpFragment; });
  124362. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124363. var name = 'bumpFragment';
  124364. var shader = "vec2 uvOffset=vec2(0.0,0.0);\n#if defined(BUMP) || defined(PARALLAX)\n#ifdef NORMALXYSCALE\nfloat normalScale=1.0;\n#else\nfloat normalScale=vBumpInfos.y;\n#endif\n#if defined(TANGENT) && defined(NORMAL)\nmat3 TBN=vTBN;\n#else\nmat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,vBumpUV);\n#endif\n#elif defined(ANISOTROPIC)\n#if defined(TANGENT) && defined(NORMAL)\nmat3 TBN=vTBN;\n#else\nmat3 TBN=cotangent_frame(normalW,vPositionW,vMainUV1,vec2(1.,1.));\n#endif\n#endif\n#ifdef PARALLAX\nmat3 invTBN=transposeMat3(TBN);\n#ifdef PARALLAXOCCLUSION\nuvOffset=parallaxOcclusion(invTBN*-viewDirectionW,invTBN*normalW,vBumpUV,vBumpInfos.z);\n#else\nuvOffset=parallaxOffset(invTBN*viewDirectionW,vBumpInfos.z);\n#endif\n#endif\n#ifdef BUMP\n#ifdef OBJECTSPACE_NORMALMAP\nnormalW=normalize(texture2D(bumpSampler,vBumpUV).xyz*2.0-1.0);\nnormalW=normalize(mat3(normalMatrix)*normalW);\n#else\nnormalW=perturbNormal(TBN,vBumpUV+uvOffset);\n#endif\n#endif";
  124365. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124366. /** @hidden */
  124367. var bumpFragment = { name: name, shader: shader };
  124368. /***/ }),
  124369. /***/ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts":
  124370. /*!*********************************************************!*\
  124371. !*** ./Shaders/ShadersInclude/bumpFragmentFunctions.ts ***!
  124372. \*********************************************************/
  124373. /*! exports provided: bumpFragmentFunctions */
  124374. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124375. "use strict";
  124376. __webpack_require__.r(__webpack_exports__);
  124377. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpFragmentFunctions", function() { return bumpFragmentFunctions; });
  124378. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124379. var name = 'bumpFragmentFunctions';
  124380. var shader = "#if defined(BUMP) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)\n#if defined(TANGENT) && defined(NORMAL)\nvarying mat3 vTBN;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\nuniform mat4 normalMatrix;\n#endif\nvec3 perturbNormal(mat3 cotangentFrame,vec2 uv,sampler2D textureSampler,float scale)\n{\nvec3 map=texture2D(textureSampler,uv).xyz;\nmap=map*2.0-1.0;\n#ifdef NORMALXYSCALE\nmap=normalize(map*vec3(scale,scale,1.0));\n#endif\nreturn normalize(cotangentFrame*map);\n}\n\nmat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv,vec2 tangentSpaceParams)\n{\n\nuv=gl_FrontFacing ? uv : -uv;\n\nvec3 dp1=dFdx(p);\nvec3 dp2=dFdy(p);\nvec2 duv1=dFdx(uv);\nvec2 duv2=dFdy(uv);\n\nvec3 dp2perp=cross(dp2,normal);\nvec3 dp1perp=cross(normal,dp1);\nvec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;\nvec3 bitangent=dp2perp*duv1.y+dp1perp*duv2.y;\n\ntangent*=tangentSpaceParams.x;\nbitangent*=tangentSpaceParams.y;\n\nfloat invmax=inversesqrt(max(dot(tangent,tangent),dot(bitangent,bitangent)));\nreturn mat3(tangent*invmax,bitangent*invmax,normal);\n}\n#endif\n#ifdef BUMP\n#if BUMPDIRECTUV == 1\n#define vBumpUV vMainUV1\n#elif BUMPDIRECTUV == 2\n#define vBumpUV vMainUV2\n#else\nvarying vec2 vBumpUV;\n#endif\nuniform sampler2D bumpSampler;\nvec3 perturbNormal(mat3 cotangentFrame,vec2 uv)\n{\nreturn perturbNormal(cotangentFrame,uv,bumpSampler,vBumpInfos.y);\n}\n\nmat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv)\n{\nreturn cotangent_frame(normal,p,uv,vTangentSpaceParams);\n}\n#endif\n#if defined(BUMP) && defined(PARALLAX)\nconst float minSamples=4.;\nconst float maxSamples=15.;\nconst int iMaxSamples=15;\n\nvec2 parallaxOcclusion(vec3 vViewDirCoT,vec3 vNormalCoT,vec2 texCoord,float parallaxScale) {\nfloat parallaxLimit=length(vViewDirCoT.xy)/vViewDirCoT.z;\nparallaxLimit*=parallaxScale;\nvec2 vOffsetDir=normalize(vViewDirCoT.xy);\nvec2 vMaxOffset=vOffsetDir*parallaxLimit;\nfloat numSamples=maxSamples+(dot(vViewDirCoT,vNormalCoT)*(minSamples-maxSamples));\nfloat stepSize=1.0/numSamples;\n\nfloat currRayHeight=1.0;\nvec2 vCurrOffset=vec2(0,0);\nvec2 vLastOffset=vec2(0,0);\nfloat lastSampledHeight=1.0;\nfloat currSampledHeight=1.0;\nfor (int i=0; i<iMaxSamples; i++)\n{\ncurrSampledHeight=texture2D(bumpSampler,vBumpUV+vCurrOffset).w;\n\nif (currSampledHeight>currRayHeight)\n{\nfloat delta1=currSampledHeight-currRayHeight;\nfloat delta2=(currRayHeight+stepSize)-lastSampledHeight;\nfloat ratio=delta1/(delta1+delta2);\nvCurrOffset=(ratio)* vLastOffset+(1.0-ratio)*vCurrOffset;\n\nbreak;\n}\nelse\n{\ncurrRayHeight-=stepSize;\nvLastOffset=vCurrOffset;\nvCurrOffset+=stepSize*vMaxOffset;\nlastSampledHeight=currSampledHeight;\n}\n}\nreturn vCurrOffset;\n}\nvec2 parallaxOffset(vec3 viewDir,float heightScale)\n{\n\nfloat height=texture2D(bumpSampler,vBumpUV).w;\nvec2 texCoordOffset=heightScale*viewDir.xy*height;\nreturn -texCoordOffset;\n}\n#endif";
  124381. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124382. /** @hidden */
  124383. var bumpFragmentFunctions = { name: name, shader: shader };
  124384. /***/ }),
  124385. /***/ "./Shaders/ShadersInclude/bumpVertex.ts":
  124386. /*!**********************************************!*\
  124387. !*** ./Shaders/ShadersInclude/bumpVertex.ts ***!
  124388. \**********************************************/
  124389. /*! exports provided: bumpVertex */
  124390. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124391. "use strict";
  124392. __webpack_require__.r(__webpack_exports__);
  124393. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpVertex", function() { return bumpVertex; });
  124394. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124395. var name = 'bumpVertex';
  124396. var shader = "#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP)\n#if defined(TANGENT) && defined(NORMAL)\nvec3 tbnNormal=normalize(normalUpdated);\nvec3 tbnTangent=normalize(tangentUpdated.xyz);\nvec3 tbnBitangent=cross(tbnNormal,tbnTangent)*tangentUpdated.w;\nvTBN=mat3(finalWorld)*mat3(tbnTangent,tbnBitangent,tbnNormal);\n#endif\n#endif";
  124397. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124398. /** @hidden */
  124399. var bumpVertex = { name: name, shader: shader };
  124400. /***/ }),
  124401. /***/ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts":
  124402. /*!*********************************************************!*\
  124403. !*** ./Shaders/ShadersInclude/bumpVertexDeclaration.ts ***!
  124404. \*********************************************************/
  124405. /*! exports provided: bumpVertexDeclaration */
  124406. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124407. "use strict";
  124408. __webpack_require__.r(__webpack_exports__);
  124409. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpVertexDeclaration", function() { return bumpVertexDeclaration; });
  124410. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124411. var name = 'bumpVertexDeclaration';
  124412. var shader = "#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP)\n#if defined(TANGENT) && defined(NORMAL)\nvarying mat3 vTBN;\n#endif\n#endif\n";
  124413. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124414. /** @hidden */
  124415. var bumpVertexDeclaration = { name: name, shader: shader };
  124416. /***/ }),
  124417. /***/ "./Shaders/ShadersInclude/clipPlaneFragment.ts":
  124418. /*!*****************************************************!*\
  124419. !*** ./Shaders/ShadersInclude/clipPlaneFragment.ts ***!
  124420. \*****************************************************/
  124421. /*! exports provided: clipPlaneFragment */
  124422. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124423. "use strict";
  124424. __webpack_require__.r(__webpack_exports__);
  124425. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragment", function() { return clipPlaneFragment; });
  124426. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124427. var name = 'clipPlaneFragment';
  124428. 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";
  124429. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124430. /** @hidden */
  124431. var clipPlaneFragment = { name: name, shader: shader };
  124432. /***/ }),
  124433. /***/ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts":
  124434. /*!****************************************************************!*\
  124435. !*** ./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts ***!
  124436. \****************************************************************/
  124437. /*! exports provided: clipPlaneFragmentDeclaration */
  124438. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124439. "use strict";
  124440. __webpack_require__.r(__webpack_exports__);
  124441. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragmentDeclaration", function() { return clipPlaneFragmentDeclaration; });
  124442. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124443. var name = 'clipPlaneFragmentDeclaration';
  124444. 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";
  124445. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124446. /** @hidden */
  124447. var clipPlaneFragmentDeclaration = { name: name, shader: shader };
  124448. /***/ }),
  124449. /***/ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts":
  124450. /*!*****************************************************************!*\
  124451. !*** ./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts ***!
  124452. \*****************************************************************/
  124453. /*! exports provided: clipPlaneFragmentDeclaration2 */
  124454. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124455. "use strict";
  124456. __webpack_require__.r(__webpack_exports__);
  124457. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragmentDeclaration2", function() { return clipPlaneFragmentDeclaration2; });
  124458. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124459. var name = 'clipPlaneFragmentDeclaration2';
  124460. 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";
  124461. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124462. /** @hidden */
  124463. var clipPlaneFragmentDeclaration2 = { name: name, shader: shader };
  124464. /***/ }),
  124465. /***/ "./Shaders/ShadersInclude/clipPlaneVertex.ts":
  124466. /*!***************************************************!*\
  124467. !*** ./Shaders/ShadersInclude/clipPlaneVertex.ts ***!
  124468. \***************************************************/
  124469. /*! exports provided: clipPlaneVertex */
  124470. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124471. "use strict";
  124472. __webpack_require__.r(__webpack_exports__);
  124473. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertex", function() { return clipPlaneVertex; });
  124474. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124475. var name = 'clipPlaneVertex';
  124476. 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";
  124477. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124478. /** @hidden */
  124479. var clipPlaneVertex = { name: name, shader: shader };
  124480. /***/ }),
  124481. /***/ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts":
  124482. /*!**************************************************************!*\
  124483. !*** ./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts ***!
  124484. \**************************************************************/
  124485. /*! exports provided: clipPlaneVertexDeclaration */
  124486. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124487. "use strict";
  124488. __webpack_require__.r(__webpack_exports__);
  124489. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertexDeclaration", function() { return clipPlaneVertexDeclaration; });
  124490. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124491. var name = 'clipPlaneVertexDeclaration';
  124492. 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";
  124493. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124494. /** @hidden */
  124495. var clipPlaneVertexDeclaration = { name: name, shader: shader };
  124496. /***/ }),
  124497. /***/ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts":
  124498. /*!***************************************************************!*\
  124499. !*** ./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts ***!
  124500. \***************************************************************/
  124501. /*! exports provided: clipPlaneVertexDeclaration2 */
  124502. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124503. "use strict";
  124504. __webpack_require__.r(__webpack_exports__);
  124505. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertexDeclaration2", function() { return clipPlaneVertexDeclaration2; });
  124506. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124507. var name = 'clipPlaneVertexDeclaration2';
  124508. 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";
  124509. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124510. /** @hidden */
  124511. var clipPlaneVertexDeclaration2 = { name: name, shader: shader };
  124512. /***/ }),
  124513. /***/ "./Shaders/ShadersInclude/defaultFragmentDeclaration.ts":
  124514. /*!**************************************************************!*\
  124515. !*** ./Shaders/ShadersInclude/defaultFragmentDeclaration.ts ***!
  124516. \**************************************************************/
  124517. /*! exports provided: defaultFragmentDeclaration */
  124518. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124519. "use strict";
  124520. __webpack_require__.r(__webpack_exports__);
  124521. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultFragmentDeclaration", function() { return defaultFragmentDeclaration; });
  124522. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124523. var name = 'defaultFragmentDeclaration';
  124524. 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";
  124525. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124526. /** @hidden */
  124527. var defaultFragmentDeclaration = { name: name, shader: shader };
  124528. /***/ }),
  124529. /***/ "./Shaders/ShadersInclude/defaultUboDeclaration.ts":
  124530. /*!*********************************************************!*\
  124531. !*** ./Shaders/ShadersInclude/defaultUboDeclaration.ts ***!
  124532. \*********************************************************/
  124533. /*! exports provided: defaultUboDeclaration */
  124534. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124535. "use strict";
  124536. __webpack_require__.r(__webpack_exports__);
  124537. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultUboDeclaration", function() { return defaultUboDeclaration; });
  124538. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124539. var name = 'defaultUboDeclaration';
  124540. var shader = "layout(std140,column_major) uniform;\nuniform Material\n{\nvec4 diffuseLeftColor;\nvec4 diffuseRightColor;\nvec4 opacityParts;\nvec4 reflectionLeftColor;\nvec4 reflectionRightColor;\nvec4 refractionLeftColor;\nvec4 refractionRightColor;\nvec4 emissiveLeftColor;\nvec4 emissiveRightColor;\nvec2 vDiffuseInfos;\nvec2 vAmbientInfos;\nvec2 vOpacityInfos;\nvec2 vReflectionInfos;\nvec3 vReflectionPosition;\nvec3 vReflectionSize;\nvec2 vEmissiveInfos;\nvec2 vLightmapInfos;\nvec2 vSpecularInfos;\nvec3 vBumpInfos;\nmat4 diffuseMatrix;\nmat4 ambientMatrix;\nmat4 opacityMatrix;\nmat4 reflectionMatrix;\nmat4 emissiveMatrix;\nmat4 lightmapMatrix;\nmat4 specularMatrix;\nmat4 bumpMatrix;\nvec2 vTangentSpaceParams;\nmat4 refractionMatrix;\nvec4 vRefractionInfos;\nvec4 vSpecularColor;\nvec3 vEmissiveColor;\nvec4 vDiffuseColor;\nfloat pointSize;\n};\nuniform Scene {\nmat4 viewProjection;\nmat4 view;\n};\n";
  124541. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124542. /** @hidden */
  124543. var defaultUboDeclaration = { name: name, shader: shader };
  124544. /***/ }),
  124545. /***/ "./Shaders/ShadersInclude/defaultVertexDeclaration.ts":
  124546. /*!************************************************************!*\
  124547. !*** ./Shaders/ShadersInclude/defaultVertexDeclaration.ts ***!
  124548. \************************************************************/
  124549. /*! exports provided: defaultVertexDeclaration */
  124550. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124551. "use strict";
  124552. __webpack_require__.r(__webpack_exports__);
  124553. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultVertexDeclaration", function() { return defaultVertexDeclaration; });
  124554. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124555. var name = 'defaultVertexDeclaration';
  124556. 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";
  124557. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124558. /** @hidden */
  124559. var defaultVertexDeclaration = { name: name, shader: shader };
  124560. /***/ }),
  124561. /***/ "./Shaders/ShadersInclude/depthPrePass.ts":
  124562. /*!************************************************!*\
  124563. !*** ./Shaders/ShadersInclude/depthPrePass.ts ***!
  124564. \************************************************/
  124565. /*! exports provided: depthPrePass */
  124566. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124567. "use strict";
  124568. __webpack_require__.r(__webpack_exports__);
  124569. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthPrePass", function() { return depthPrePass; });
  124570. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124571. var name = 'depthPrePass';
  124572. var shader = "#ifdef DEPTHPREPASS\ngl_FragColor=vec4(0.,0.,0.,1.0);\nreturn;\n#endif";
  124573. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124574. /** @hidden */
  124575. var depthPrePass = { name: name, shader: shader };
  124576. /***/ }),
  124577. /***/ "./Shaders/ShadersInclude/fogFragment.ts":
  124578. /*!***********************************************!*\
  124579. !*** ./Shaders/ShadersInclude/fogFragment.ts ***!
  124580. \***********************************************/
  124581. /*! exports provided: fogFragment */
  124582. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124583. "use strict";
  124584. __webpack_require__.r(__webpack_exports__);
  124585. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogFragment", function() { return fogFragment; });
  124586. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124587. var name = 'fogFragment';
  124588. var shader = "#ifdef FOG\nfloat fog=CalcFogFactor();\ncolor.rgb=fog*color.rgb+(1.0-fog)*vFogColor;\n#endif";
  124589. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124590. /** @hidden */
  124591. var fogFragment = { name: name, shader: shader };
  124592. /***/ }),
  124593. /***/ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts":
  124594. /*!**********************************************************!*\
  124595. !*** ./Shaders/ShadersInclude/fogFragmentDeclaration.ts ***!
  124596. \**********************************************************/
  124597. /*! exports provided: fogFragmentDeclaration */
  124598. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124599. "use strict";
  124600. __webpack_require__.r(__webpack_exports__);
  124601. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogFragmentDeclaration", function() { return fogFragmentDeclaration; });
  124602. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124603. var name = 'fogFragmentDeclaration';
  124604. 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";
  124605. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124606. /** @hidden */
  124607. var fogFragmentDeclaration = { name: name, shader: shader };
  124608. /***/ }),
  124609. /***/ "./Shaders/ShadersInclude/fogVertex.ts":
  124610. /*!*********************************************!*\
  124611. !*** ./Shaders/ShadersInclude/fogVertex.ts ***!
  124612. \*********************************************/
  124613. /*! exports provided: fogVertex */
  124614. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124615. "use strict";
  124616. __webpack_require__.r(__webpack_exports__);
  124617. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogVertex", function() { return fogVertex; });
  124618. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124619. var name = 'fogVertex';
  124620. var shader = "#ifdef FOG\nvFogDistance=(view*worldPos).xyz;\n#endif";
  124621. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124622. /** @hidden */
  124623. var fogVertex = { name: name, shader: shader };
  124624. /***/ }),
  124625. /***/ "./Shaders/ShadersInclude/fogVertexDeclaration.ts":
  124626. /*!********************************************************!*\
  124627. !*** ./Shaders/ShadersInclude/fogVertexDeclaration.ts ***!
  124628. \********************************************************/
  124629. /*! exports provided: fogVertexDeclaration */
  124630. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124631. "use strict";
  124632. __webpack_require__.r(__webpack_exports__);
  124633. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogVertexDeclaration", function() { return fogVertexDeclaration; });
  124634. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124635. var name = 'fogVertexDeclaration';
  124636. var shader = "#ifdef FOG\nvarying vec3 vFogDistance;\n#endif";
  124637. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124638. /** @hidden */
  124639. var fogVertexDeclaration = { name: name, shader: shader };
  124640. /***/ }),
  124641. /***/ "./Shaders/ShadersInclude/fresnelFunction.ts":
  124642. /*!***************************************************!*\
  124643. !*** ./Shaders/ShadersInclude/fresnelFunction.ts ***!
  124644. \***************************************************/
  124645. /*! exports provided: fresnelFunction */
  124646. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124647. "use strict";
  124648. __webpack_require__.r(__webpack_exports__);
  124649. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fresnelFunction", function() { return fresnelFunction; });
  124650. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124651. var name = 'fresnelFunction';
  124652. 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";
  124653. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124654. /** @hidden */
  124655. var fresnelFunction = { name: name, shader: shader };
  124656. /***/ }),
  124657. /***/ "./Shaders/ShadersInclude/harmonicsFunctions.ts":
  124658. /*!******************************************************!*\
  124659. !*** ./Shaders/ShadersInclude/harmonicsFunctions.ts ***!
  124660. \******************************************************/
  124661. /*! exports provided: harmonicsFunctions */
  124662. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124663. "use strict";
  124664. __webpack_require__.r(__webpack_exports__);
  124665. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "harmonicsFunctions", function() { return harmonicsFunctions; });
  124666. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124667. var name = 'harmonicsFunctions';
  124668. 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";
  124669. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124670. /** @hidden */
  124671. var harmonicsFunctions = { name: name, shader: shader };
  124672. /***/ }),
  124673. /***/ "./Shaders/ShadersInclude/helperFunctions.ts":
  124674. /*!***************************************************!*\
  124675. !*** ./Shaders/ShadersInclude/helperFunctions.ts ***!
  124676. \***************************************************/
  124677. /*! exports provided: helperFunctions */
  124678. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124679. "use strict";
  124680. __webpack_require__.r(__webpack_exports__);
  124681. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "helperFunctions", function() { return helperFunctions; });
  124682. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124683. var name = 'helperFunctions';
  124684. 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}";
  124685. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124686. /** @hidden */
  124687. var helperFunctions = { name: name, shader: shader };
  124688. /***/ }),
  124689. /***/ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts":
  124690. /*!**************************************************************!*\
  124691. !*** ./Shaders/ShadersInclude/imageProcessingDeclaration.ts ***!
  124692. \**************************************************************/
  124693. /*! exports provided: imageProcessingDeclaration */
  124694. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124695. "use strict";
  124696. __webpack_require__.r(__webpack_exports__);
  124697. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingDeclaration", function() { return imageProcessingDeclaration; });
  124698. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124699. var name = 'imageProcessingDeclaration';
  124700. 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";
  124701. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124702. /** @hidden */
  124703. var imageProcessingDeclaration = { name: name, shader: shader };
  124704. /***/ }),
  124705. /***/ "./Shaders/ShadersInclude/imageProcessingFunctions.ts":
  124706. /*!************************************************************!*\
  124707. !*** ./Shaders/ShadersInclude/imageProcessingFunctions.ts ***!
  124708. \************************************************************/
  124709. /*! exports provided: imageProcessingFunctions */
  124710. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124711. "use strict";
  124712. __webpack_require__.r(__webpack_exports__);
  124713. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingFunctions", function() { return imageProcessingFunctions; });
  124714. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124715. var name = 'imageProcessingFunctions';
  124716. 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}";
  124717. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124718. /** @hidden */
  124719. var imageProcessingFunctions = { name: name, shader: shader };
  124720. /***/ }),
  124721. /***/ "./Shaders/ShadersInclude/instancesDeclaration.ts":
  124722. /*!********************************************************!*\
  124723. !*** ./Shaders/ShadersInclude/instancesDeclaration.ts ***!
  124724. \********************************************************/
  124725. /*! exports provided: instancesDeclaration */
  124726. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124727. "use strict";
  124728. __webpack_require__.r(__webpack_exports__);
  124729. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "instancesDeclaration", function() { return instancesDeclaration; });
  124730. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124731. var name = 'instancesDeclaration';
  124732. var shader = "#ifdef INSTANCES\nattribute vec4 world0;\nattribute vec4 world1;\nattribute vec4 world2;\nattribute vec4 world3;\n#else\nuniform mat4 world;\n#endif";
  124733. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124734. /** @hidden */
  124735. var instancesDeclaration = { name: name, shader: shader };
  124736. /***/ }),
  124737. /***/ "./Shaders/ShadersInclude/instancesVertex.ts":
  124738. /*!***************************************************!*\
  124739. !*** ./Shaders/ShadersInclude/instancesVertex.ts ***!
  124740. \***************************************************/
  124741. /*! exports provided: instancesVertex */
  124742. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124743. "use strict";
  124744. __webpack_require__.r(__webpack_exports__);
  124745. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "instancesVertex", function() { return instancesVertex; });
  124746. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124747. var name = 'instancesVertex';
  124748. var shader = "#ifdef INSTANCES\nmat4 finalWorld=mat4(world0,world1,world2,world3);\n#else\nmat4 finalWorld=world;\n#endif";
  124749. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124750. /** @hidden */
  124751. var instancesVertex = { name: name, shader: shader };
  124752. /***/ }),
  124753. /***/ "./Shaders/ShadersInclude/kernelBlurFragment.ts":
  124754. /*!******************************************************!*\
  124755. !*** ./Shaders/ShadersInclude/kernelBlurFragment.ts ***!
  124756. \******************************************************/
  124757. /*! exports provided: kernelBlurFragment */
  124758. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124759. "use strict";
  124760. __webpack_require__.r(__webpack_exports__);
  124761. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurFragment", function() { return kernelBlurFragment; });
  124762. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124763. var name = 'kernelBlurFragment';
  124764. 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";
  124765. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124766. /** @hidden */
  124767. var kernelBlurFragment = { name: name, shader: shader };
  124768. /***/ }),
  124769. /***/ "./Shaders/ShadersInclude/kernelBlurFragment2.ts":
  124770. /*!*******************************************************!*\
  124771. !*** ./Shaders/ShadersInclude/kernelBlurFragment2.ts ***!
  124772. \*******************************************************/
  124773. /*! exports provided: kernelBlurFragment2 */
  124774. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124775. "use strict";
  124776. __webpack_require__.r(__webpack_exports__);
  124777. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurFragment2", function() { return kernelBlurFragment2; });
  124778. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124779. var name = 'kernelBlurFragment2';
  124780. 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";
  124781. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124782. /** @hidden */
  124783. var kernelBlurFragment2 = { name: name, shader: shader };
  124784. /***/ }),
  124785. /***/ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts":
  124786. /*!****************************************************************!*\
  124787. !*** ./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts ***!
  124788. \****************************************************************/
  124789. /*! exports provided: kernelBlurVaryingDeclaration */
  124790. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124791. "use strict";
  124792. __webpack_require__.r(__webpack_exports__);
  124793. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVaryingDeclaration", function() { return kernelBlurVaryingDeclaration; });
  124794. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124795. var name = 'kernelBlurVaryingDeclaration';
  124796. var shader = "varying vec2 sampleCoord{X};";
  124797. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124798. /** @hidden */
  124799. var kernelBlurVaryingDeclaration = { name: name, shader: shader };
  124800. /***/ }),
  124801. /***/ "./Shaders/ShadersInclude/kernelBlurVertex.ts":
  124802. /*!****************************************************!*\
  124803. !*** ./Shaders/ShadersInclude/kernelBlurVertex.ts ***!
  124804. \****************************************************/
  124805. /*! exports provided: kernelBlurVertex */
  124806. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124807. "use strict";
  124808. __webpack_require__.r(__webpack_exports__);
  124809. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVertex", function() { return kernelBlurVertex; });
  124810. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124811. var name = 'kernelBlurVertex';
  124812. var shader = "sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};";
  124813. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124814. /** @hidden */
  124815. var kernelBlurVertex = { name: name, shader: shader };
  124816. /***/ }),
  124817. /***/ "./Shaders/ShadersInclude/lightFragment.ts":
  124818. /*!*************************************************!*\
  124819. !*** ./Shaders/ShadersInclude/lightFragment.ts ***!
  124820. \*************************************************/
  124821. /*! exports provided: lightFragment */
  124822. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124823. "use strict";
  124824. __webpack_require__.r(__webpack_exports__);
  124825. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightFragment", function() { return lightFragment; });
  124826. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124827. var name = 'lightFragment';
  124828. var shader = "#ifdef LIGHT{X}\n#if defined(SHADOWONLY) || (defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X}))\n\n#else\n#ifdef PBR\n\n#ifdef SPOTLIGHT{X}\npreInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#elif defined(POINTLIGHT{X})\npreInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#elif defined(HEMILIGHT{X})\npreInfo=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#elif defined(DIRLIGHT{X})\npreInfo=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#endif\npreInfo.NdotV=NdotV;\n\n#ifdef SPOTLIGHT{X}\n#ifdef LIGHT_FALLOFF_GLTF{X}\npreInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);\npreInfo.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\npreInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);\npreInfo.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w);\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\npreInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);\npreInfo.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w);\n#else\npreInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);\npreInfo.attenuation*=computeDirectionalLightFalloff(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\n#endif\n#elif defined(POINTLIGHT{X})\n#ifdef LIGHT_FALLOFF_GLTF{X}\npreInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\npreInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\npreInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);\n#else\npreInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);\n#endif\n#else\npreInfo.attenuation=1.0;\n#endif\n\n\n#ifdef HEMILIGHT{X}\npreInfo.roughness=roughness;\n#else\npreInfo.roughness=adjustRoughnessFromLightProperties(roughness,light{X}.vLightDiffuse.a,preInfo.lightDistance);\n#endif\n\n#ifdef HEMILIGHT{X}\ninfo.diffuse=computeHemisphericDiffuseLighting(preInfo,light{X}.vLightDiffuse.rgb,light{X}.vLightGround);\n#else\ninfo.diffuse=computeDiffuseLighting(preInfo,light{X}.vLightDiffuse.rgb);\n#endif\n\n#ifdef SPECULARTERM\n#ifdef ANISOTROPIC\ninfo.specular=computeAnisotropicSpecularLighting(preInfo,viewDirectionW,normalW,normalize(TBN[0]),normalize(TBN[1]),anisotropy,specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);\n#else\ninfo.specular=computeSpecularLighting(preInfo,normalW,specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);\n#endif\n#endif\n\n#ifdef CLEARCOAT\n\n#ifdef HEMILIGHT{X}\npreInfo.roughness=clearCoatRoughness;\n#else\npreInfo.roughness=adjustRoughnessFromLightProperties(clearCoatRoughness,light{X}.vLightDiffuse.a,preInfo.lightDistance);\n#endif\ninfo.clearCoat=computeClearCoatLighting(preInfo,clearCoatNormalW,clearCoatAARoughnessFactors.x,clearCoatIntensity,light{X}.vLightDiffuse.rgb);\n#ifdef CLEARCOAT_TINT\n\nabsorption=computeClearCoatLightingAbsorption(clearCoatNdotVRefract,preInfo.L,clearCoatNormalW,clearCoatColor,clearCoatThickness,clearCoatIntensity);\ninfo.diffuse*=absorption;\n#ifdef SPECULARTERM\ninfo.specular*=absorption;\n#endif\n#endif\n\ninfo.diffuse*=info.clearCoat.w;\n#ifdef SPECULARTERM\ninfo.specular*=info.clearCoat.w*info.clearCoat.w;\n#endif\n#endif\n#else\n#ifdef SPOTLIGHT{X}\ninfo=computeSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,glossiness);\n#elif defined(HEMILIGHT{X})\ninfo=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightGround,glossiness);\n#elif defined(POINTLIGHT{X}) || defined(DIRLIGHT{X})\ninfo=computeLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,glossiness);\n#endif\n#endif\n#ifdef PROJECTEDLIGHTTEXTURE{X}\ninfo.diffuse*=computeProjectionTextureDiffuseLighting(projectionLightSampler{X},textureProjectionMatrix{X});\n#endif\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWCLOSEESM{X}\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithCloseESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);\n#else\nshadow=computeShadowWithCloseESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWESM{X})\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);\n#else\nshadow=computeShadowWithESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPOISSON{X})\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithPoissonSamplingCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.depthValues);\n#else\nshadow=computeShadowWithPoissonSampling(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPCF{X})\n#if defined(SHADOWLOWQUALITY{X})\nshadow=computeShadowWithPCF1(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#elif defined(SHADOWMEDIUMQUALITY{X})\nshadow=computeShadowWithPCF3(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#else\nshadow=computeShadowWithPCF5(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPCSS{X})\n#if defined(SHADOWLOWQUALITY{X})\nshadow=computeShadowWithPCSS16(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#elif defined(SHADOWMEDIUMQUALITY{X})\nshadow=computeShadowWithPCSS32(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#else\nshadow=computeShadowWithPCSS64(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#else\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.depthValues);\n#else\nshadow=computeShadow(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#endif\n#ifdef SHADOWONLY\n#ifndef SHADOWINUSE\n#define SHADOWINUSE\n#endif\nglobalShadow+=shadow;\nshadowLightCount+=1.0;\n#endif\n#else\nshadow=1.;\n#endif\n#ifndef SHADOWONLY\n#ifdef CUSTOMUSERLIGHTING\ndiffuseBase+=computeCustomDiffuseLighting(info,diffuseBase,shadow);\n#ifdef SPECULARTERM\nspecularBase+=computeCustomSpecularLighting(info,specularBase,shadow);\n#endif\n#elif defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X})\ndiffuseBase+=lightmapColor*shadow;\n#ifdef SPECULARTERM\n#ifndef LIGHTMAPNOSPECULAR{X}\nspecularBase+=info.specular*shadow*lightmapColor;\n#endif\n#endif\n#ifdef CLEARCOAT\n#ifndef LIGHTMAPNOSPECULAR{X}\nclearCoatBase+=info.clearCoat.rgb*shadow*lightmapColor;\n#endif\n#endif\n#else\ndiffuseBase+=info.diffuse*shadow;\n#ifdef SPECULARTERM\nspecularBase+=info.specular*shadow;\n#endif\n#ifdef CLEARCOAT\nclearCoatBase+=info.clearCoat.rgb*shadow;\n#endif\n#endif\n#endif\n#endif";
  124829. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124830. /** @hidden */
  124831. var lightFragment = { name: name, shader: shader };
  124832. /***/ }),
  124833. /***/ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts":
  124834. /*!************************************************************!*\
  124835. !*** ./Shaders/ShadersInclude/lightFragmentDeclaration.ts ***!
  124836. \************************************************************/
  124837. /*! exports provided: lightFragmentDeclaration */
  124838. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124839. "use strict";
  124840. __webpack_require__.r(__webpack_exports__);
  124841. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightFragmentDeclaration", function() { return lightFragmentDeclaration; });
  124842. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124843. var name = 'lightFragmentDeclaration';
  124844. 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";
  124845. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124846. /** @hidden */
  124847. var lightFragmentDeclaration = { name: name, shader: shader };
  124848. /***/ }),
  124849. /***/ "./Shaders/ShadersInclude/lightUboDeclaration.ts":
  124850. /*!*******************************************************!*\
  124851. !*** ./Shaders/ShadersInclude/lightUboDeclaration.ts ***!
  124852. \*******************************************************/
  124853. /*! exports provided: lightUboDeclaration */
  124854. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124855. "use strict";
  124856. __webpack_require__.r(__webpack_exports__);
  124857. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightUboDeclaration", function() { return lightUboDeclaration; });
  124858. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124859. var name = 'lightUboDeclaration';
  124860. 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";
  124861. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124862. /** @hidden */
  124863. var lightUboDeclaration = { name: name, shader: shader };
  124864. /***/ }),
  124865. /***/ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts":
  124866. /*!***********************************************************!*\
  124867. !*** ./Shaders/ShadersInclude/lightsFragmentFunctions.ts ***!
  124868. \***********************************************************/
  124869. /*! exports provided: lightsFragmentFunctions */
  124870. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124871. "use strict";
  124872. __webpack_require__.r(__webpack_exports__);
  124873. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightsFragmentFunctions", function() { return lightsFragmentFunctions; });
  124874. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124875. var name = 'lightsFragmentFunctions';
  124876. 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}";
  124877. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124878. /** @hidden */
  124879. var lightsFragmentFunctions = { name: name, shader: shader };
  124880. /***/ }),
  124881. /***/ "./Shaders/ShadersInclude/logDepthDeclaration.ts":
  124882. /*!*******************************************************!*\
  124883. !*** ./Shaders/ShadersInclude/logDepthDeclaration.ts ***!
  124884. \*******************************************************/
  124885. /*! exports provided: logDepthDeclaration */
  124886. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124887. "use strict";
  124888. __webpack_require__.r(__webpack_exports__);
  124889. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthDeclaration", function() { return logDepthDeclaration; });
  124890. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124891. var name = 'logDepthDeclaration';
  124892. var shader = "#ifdef LOGARITHMICDEPTH\nuniform float logarithmicDepthConstant;\nvarying float vFragmentDepth;\n#endif";
  124893. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124894. /** @hidden */
  124895. var logDepthDeclaration = { name: name, shader: shader };
  124896. /***/ }),
  124897. /***/ "./Shaders/ShadersInclude/logDepthFragment.ts":
  124898. /*!****************************************************!*\
  124899. !*** ./Shaders/ShadersInclude/logDepthFragment.ts ***!
  124900. \****************************************************/
  124901. /*! exports provided: logDepthFragment */
  124902. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124903. "use strict";
  124904. __webpack_require__.r(__webpack_exports__);
  124905. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthFragment", function() { return logDepthFragment; });
  124906. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124907. var name = 'logDepthFragment';
  124908. var shader = "#ifdef LOGARITHMICDEPTH\ngl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;\n#endif";
  124909. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124910. /** @hidden */
  124911. var logDepthFragment = { name: name, shader: shader };
  124912. /***/ }),
  124913. /***/ "./Shaders/ShadersInclude/logDepthVertex.ts":
  124914. /*!**************************************************!*\
  124915. !*** ./Shaders/ShadersInclude/logDepthVertex.ts ***!
  124916. \**************************************************/
  124917. /*! exports provided: logDepthVertex */
  124918. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124919. "use strict";
  124920. __webpack_require__.r(__webpack_exports__);
  124921. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthVertex", function() { return logDepthVertex; });
  124922. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124923. var name = 'logDepthVertex';
  124924. var shader = "#ifdef LOGARITHMICDEPTH\nvFragmentDepth=1.0+gl_Position.w;\ngl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;\n#endif";
  124925. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124926. /** @hidden */
  124927. var logDepthVertex = { name: name, shader: shader };
  124928. /***/ }),
  124929. /***/ "./Shaders/ShadersInclude/morphTargetsVertex.ts":
  124930. /*!******************************************************!*\
  124931. !*** ./Shaders/ShadersInclude/morphTargetsVertex.ts ***!
  124932. \******************************************************/
  124933. /*! exports provided: morphTargetsVertex */
  124934. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124935. "use strict";
  124936. __webpack_require__.r(__webpack_exports__);
  124937. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertex", function() { return morphTargetsVertex; });
  124938. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124939. var name = 'morphTargetsVertex';
  124940. 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";
  124941. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124942. /** @hidden */
  124943. var morphTargetsVertex = { name: name, shader: shader };
  124944. /***/ }),
  124945. /***/ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts":
  124946. /*!*****************************************************************!*\
  124947. !*** ./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts ***!
  124948. \*****************************************************************/
  124949. /*! exports provided: morphTargetsVertexDeclaration */
  124950. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124951. "use strict";
  124952. __webpack_require__.r(__webpack_exports__);
  124953. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertexDeclaration", function() { return morphTargetsVertexDeclaration; });
  124954. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124955. var name = 'morphTargetsVertexDeclaration';
  124956. 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";
  124957. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124958. /** @hidden */
  124959. var morphTargetsVertexDeclaration = { name: name, shader: shader };
  124960. /***/ }),
  124961. /***/ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts":
  124962. /*!***********************************************************************!*\
  124963. !*** ./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts ***!
  124964. \***********************************************************************/
  124965. /*! exports provided: morphTargetsVertexGlobalDeclaration */
  124966. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124967. "use strict";
  124968. __webpack_require__.r(__webpack_exports__);
  124969. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertexGlobalDeclaration", function() { return morphTargetsVertexGlobalDeclaration; });
  124970. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124971. var name = 'morphTargetsVertexGlobalDeclaration';
  124972. var shader = "#ifdef MORPHTARGETS\nuniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];\n#endif";
  124973. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124974. /** @hidden */
  124975. var morphTargetsVertexGlobalDeclaration = { name: name, shader: shader };
  124976. /***/ }),
  124977. /***/ "./Shaders/ShadersInclude/mrtFragmentDeclaration.ts":
  124978. /*!**********************************************************!*\
  124979. !*** ./Shaders/ShadersInclude/mrtFragmentDeclaration.ts ***!
  124980. \**********************************************************/
  124981. /*! exports provided: mrtFragmentDeclaration */
  124982. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124983. "use strict";
  124984. __webpack_require__.r(__webpack_exports__);
  124985. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mrtFragmentDeclaration", function() { return mrtFragmentDeclaration; });
  124986. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124987. var name = 'mrtFragmentDeclaration';
  124988. var shader = "#if __VERSION__>=200\nlayout(location=0) out vec4 glFragData[{X}];\n#endif\n";
  124989. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124990. /** @hidden */
  124991. var mrtFragmentDeclaration = { name: name, shader: shader };
  124992. /***/ }),
  124993. /***/ "./Shaders/ShadersInclude/pbrDebug.ts":
  124994. /*!********************************************!*\
  124995. !*** ./Shaders/ShadersInclude/pbrDebug.ts ***!
  124996. \********************************************/
  124997. /*! exports provided: pbrDebug */
  124998. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124999. "use strict";
  125000. __webpack_require__.r(__webpack_exports__);
  125001. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrDebug", function() { return pbrDebug; });
  125002. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125003. var name = 'pbrDebug';
  125004. var shader = "#if DEBUGMODE>0\nif (vClipSpacePosition.x/vClipSpacePosition.w<vDebugMode.x) {\nreturn;\n}\n\n#if DEBUGMODE == 1\ngl_FragColor.rgb=vPositionW.rgb;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 2 && defined(NORMAL)\ngl_FragColor.rgb=vNormalW.rgb;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 3 && (defined(BUMP) || defined(PARALLAX) || defined(ANISOTROPIC))\n\ngl_FragColor.rgb=TBN[0];\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 4 && (defined(BUMP) || defined(PARALLAX) || defined(ANISOTROPIC))\n\ngl_FragColor.rgb=TBN[1];\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 5\n\ngl_FragColor.rgb=normalW;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 6 && defined(MAINUV1)\ngl_FragColor.rgb=vec3(vMainUV1,0.0);\n#elif DEBUGMODE == 7 && defined(MAINUV2)\ngl_FragColor.rgb=vec3(vMainUV2,0.0);\n#elif DEBUGMODE == 8 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)\n\ngl_FragColor.rgb=TBNClearCoat[0];\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 9 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)\n\ngl_FragColor.rgb=TBNClearCoat[1];\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 10 && defined(CLEARCOAT)\n\ngl_FragColor.rgb=clearCoatNormalW;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 11 && defined(ANISOTROPIC)\ngl_FragColor.rgb=anisotropicNormal;\n#define DEBUGMODE_NORMALIZE\n\n#elif DEBUGMODE == 20 && defined(ALBEDO)\ngl_FragColor.rgb=albedoTexture.rgb;\n#elif DEBUGMODE == 21 && defined(AMBIENT)\ngl_FragColor.rgb=ambientOcclusionColorMap.rgb;\n#elif DEBUGMODE == 22 && defined(OPACITY)\ngl_FragColor.rgb=opacityMap.rgb;\n#elif DEBUGMODE == 23 && defined(EMISSIVE)\ngl_FragColor.rgb=emissiveColorTex.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 24 && defined(LIGHTMAP)\ngl_FragColor.rgb=lightmapColor.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 25 && defined(REFLECTIVITY) && defined(METALLICWORKFLOW)\ngl_FragColor.rgb=surfaceMetallicColorMap.rgb;\n#elif DEBUGMODE == 26 && defined(REFLECTIVITY) && !defined(METALLICWORKFLOW)\ngl_FragColor.rgb=surfaceReflectivityColorMap.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 27 && defined(CLEARCOAT) && defined(CLEARCOAT_TEXTURE)\ngl_FragColor.rgb=clearCoatMapData.rgb;\n#elif DEBUGMODE == 28 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)\ngl_FragColor.rgb=clearCoatTintMapData.rgb;\n\n#elif DEBUGMODE == 40 && defined(REFRACTION)\n\ngl_FragColor.rgb=environmentRefraction.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 41 && defined(REFLECTION)\ngl_FragColor.rgb=environmentRadiance.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 42 && defined(CLEARCOAT) && defined(REFLECTION)\ngl_FragColor.rgb=environmentClearCoatRadiance;\n#define DEBUGMODE_GAMMA\n\n#elif DEBUGMODE == 50\ngl_FragColor.rgb=diffuseBase.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 51 && defined(SPECULARTERM)\ngl_FragColor.rgb=specularBase.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 52 && defined(CLEARCOAT)\ngl_FragColor.rgb=clearCoatBase.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 53 && defined(REFLECTION)\ngl_FragColor.rgb=environmentIrradiance.rgb;\n#define DEBUGMODE_GAMMA\n\n#elif DEBUGMODE == 60\ngl_FragColor.rgb=surfaceAlbedo.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 61\ngl_FragColor.rgb=specularEnvironmentR0;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 62\ngl_FragColor.rgb=vec3(roughness);\n#elif DEBUGMODE == 63\ngl_FragColor.rgb=vec3(alphaG);\n#elif DEBUGMODE == 64\ngl_FragColor.rgb=vec3(NdotV);\n#elif DEBUGMODE == 65 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT)\ngl_FragColor.rgb=clearCoatColor.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 66 && defined(CLEARCOAT)\ngl_FragColor.rgb=vec3(clearCoatRoughness);\n#elif DEBUGMODE == 67 && defined(CLEARCOAT)\ngl_FragColor.rgb=vec3(clearCoatNdotV);\n\n#elif DEBUGMODE == 70 && defined(RADIANCEOCCLUSION)\ngl_FragColor.rgb=vec3(seo);\n#elif DEBUGMODE == 71 && defined(HORIZONOCCLUSION)\ngl_FragColor.rgb=vec3(eho);\n#elif DEBUGMODE == 72 && defined(MS_BRDF_ENERGY_CONSERVATION)\ngl_FragColor.rgb=vec3(energyConservationFactor);\n#elif DEBUGMODE == 73 && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\ngl_FragColor.rgb=specularEnvironmentReflectance;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 74 && defined(CLEARCOAT) && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\ngl_FragColor.rgb=clearCoatEnvironmentReflectance;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 75 && defined(ALPHABLEND)\ngl_FragColor.rgb=vec3(luminanceOverAlpha);\n#elif DEBUGMODE == 76\ngl_FragColor.rgb=vec3(alpha);\n#endif\ngl_FragColor.rgb*=vDebugMode.y;\n#ifdef DEBUGMODE_NORMALIZE\ngl_FragColor.rgb=normalize(gl_FragColor.rgb)*0.5+0.5;\n#endif\n#ifdef DEBUGMODE_GAMMA\ngl_FragColor.rgb=toGammaSpace(gl_FragColor.rgb);\n#endif\ngl_FragColor.a=1.0;\n#endif";
  125005. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125006. /** @hidden */
  125007. var pbrDebug = { name: name, shader: shader };
  125008. /***/ }),
  125009. /***/ "./Shaders/ShadersInclude/pbrFalloffLightingFunctions.ts":
  125010. /*!***************************************************************!*\
  125011. !*** ./Shaders/ShadersInclude/pbrFalloffLightingFunctions.ts ***!
  125012. \***************************************************************/
  125013. /*! exports provided: pbrFalloffLightingFunctions */
  125014. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125015. "use strict";
  125016. __webpack_require__.r(__webpack_exports__);
  125017. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFalloffLightingFunctions", function() { return pbrFalloffLightingFunctions; });
  125018. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125019. var name = 'pbrFalloffLightingFunctions';
  125020. var shader = "float computeDistanceLightFalloff_Standard(vec3 lightOffset,float range)\n{\nreturn max(0.,1.0-length(lightOffset)/range);\n}\nfloat computeDistanceLightFalloff_Physical(float lightDistanceSquared)\n{\nreturn 1.0/((lightDistanceSquared+0.001));\n}\nfloat computeDistanceLightFalloff_GLTF(float lightDistanceSquared,float inverseSquaredRange)\n{\nconst float minDistanceSquared=0.01*0.01;\nfloat lightDistanceFalloff=1.0/(max(lightDistanceSquared,minDistanceSquared));\nfloat factor=lightDistanceSquared*inverseSquaredRange;\nfloat attenuation=clamp(1.0-factor*factor,0.,1.);\nattenuation*=attenuation;\n\nlightDistanceFalloff*=attenuation;\nreturn lightDistanceFalloff;\n}\nfloat computeDistanceLightFalloff(vec3 lightOffset,float lightDistanceSquared,float range,float inverseSquaredRange)\n{\n#ifdef USEPHYSICALLIGHTFALLOFF\nreturn computeDistanceLightFalloff_Physical(lightDistanceSquared);\n#elif defined(USEGLTFLIGHTFALLOFF)\nreturn computeDistanceLightFalloff_GLTF(lightDistanceSquared,inverseSquaredRange);\n#else\nreturn computeDistanceLightFalloff_Standard(lightOffset,range);\n#endif\n}\nfloat computeDirectionalLightFalloff_Standard(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent)\n{\nfloat falloff=0.0;\nfloat cosAngle=max(0.000000000000001,dot(-lightDirection,directionToLightCenterW));\nif (cosAngle>=cosHalfAngle)\n{\nfalloff=max(0.,pow(cosAngle,exponent));\n}\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff_Physical(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle)\n{\nconst float kMinusLog2ConeAngleIntensityRatio=6.64385618977;\n\n\n\n\n\nfloat concentrationKappa=kMinusLog2ConeAngleIntensityRatio/(1.0-cosHalfAngle);\n\n\nvec4 lightDirectionSpreadSG=vec4(-lightDirection*concentrationKappa,-concentrationKappa);\nfloat falloff=exp2(dot(vec4(directionToLightCenterW,1.0),lightDirectionSpreadSG));\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff_GLTF(vec3 lightDirection,vec3 directionToLightCenterW,float lightAngleScale,float lightAngleOffset)\n{\n\n\n\nfloat cd=dot(-lightDirection,directionToLightCenterW);\nfloat falloff=clamp(cd*lightAngleScale+lightAngleOffset,0.,1.);\n\nfalloff*=falloff;\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent,float lightAngleScale,float lightAngleOffset)\n{\n#ifdef USEPHYSICALLIGHTFALLOFF\nreturn computeDirectionalLightFalloff_Physical(lightDirection,directionToLightCenterW,cosHalfAngle);\n#elif defined(USEGLTFLIGHTFALLOFF)\nreturn computeDirectionalLightFalloff_GLTF(lightDirection,directionToLightCenterW,lightAngleScale,lightAngleOffset);\n#else\nreturn computeDirectionalLightFalloff_Standard(lightDirection,directionToLightCenterW,cosHalfAngle,exponent);\n#endif\n}";
  125021. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125022. /** @hidden */
  125023. var pbrFalloffLightingFunctions = { name: name, shader: shader };
  125024. /***/ }),
  125025. /***/ "./Shaders/ShadersInclude/pbrFragmentDeclaration.ts":
  125026. /*!**********************************************************!*\
  125027. !*** ./Shaders/ShadersInclude/pbrFragmentDeclaration.ts ***!
  125028. \**********************************************************/
  125029. /*! exports provided: pbrFragmentDeclaration */
  125030. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125031. "use strict";
  125032. __webpack_require__.r(__webpack_exports__);
  125033. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFragmentDeclaration", function() { return pbrFragmentDeclaration; });
  125034. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125035. var name = 'pbrFragmentDeclaration';
  125036. var shader = "uniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\n\nuniform vec4 vLightingIntensity;\nuniform vec4 vReflectivityColor;\nuniform vec3 vEmissiveColor;\n\n#ifdef ALBEDO\nuniform vec2 vAlbedoInfos;\n#endif\n#ifdef AMBIENT\nuniform vec4 vAmbientInfos;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform vec2 vTangentSpaceParams;\n#endif\n#ifdef OPACITY\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\n#endif\n#ifdef REFLECTIVITY\nuniform vec3 vReflectivityInfos;\n#endif\n#ifdef MICROSURFACEMAP\nuniform vec2 vMicroSurfaceSamplerInfos;\n#endif\n\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)\nuniform mat4 view;\n#endif\n\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\nuniform vec3 vRefractionMicrosurfaceInfos;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\n#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize;\n#endif\n#endif\n\n#ifdef CLEARCOAT\nuniform vec2 vClearCoatParams;\nuniform vec4 vClearCoatRefractionParams;\n#ifdef CLEARCOAT_TEXTURE\nuniform vec2 vClearCoatInfos;\nuniform mat4 clearCoatMatrix;\n#endif\n#ifdef CLEARCOAT_BUMP\nuniform vec2 vClearCoatBumpInfos;\nuniform vec2 vClearCoatTangentSpaceParams;\nuniform mat4 clearCoatBumpMatrix;\n#endif\n#ifdef CLEARCOAT_TINT\nuniform vec4 vClearCoatTintParams;\nuniform float clearCoatColorAtDistance;\n#ifdef CLEARCOAT_TINT_TEXTURE\nuniform vec2 vClearCoatTintInfos;\nuniform mat4 clearCoatTintMatrix;\n#endif\n#endif\n#endif\n\n#ifdef ANISOTROPIC\nuniform float anisotropy;\n#endif";
  125037. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125038. /** @hidden */
  125039. var pbrFragmentDeclaration = { name: name, shader: shader };
  125040. /***/ }),
  125041. /***/ "./Shaders/ShadersInclude/pbrFunctions.ts":
  125042. /*!************************************************!*\
  125043. !*** ./Shaders/ShadersInclude/pbrFunctions.ts ***!
  125044. \************************************************/
  125045. /*! exports provided: pbrFunctions */
  125046. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125047. "use strict";
  125048. __webpack_require__.r(__webpack_exports__);
  125049. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFunctions", function() { return pbrFunctions; });
  125050. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125051. var name = 'pbrFunctions';
  125052. var shader = "\n#define RECIPROCAL_PI2 0.15915494\n#define RECIPROCAL_PI 0.31830988618\n#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\n\n#define MINIMUMVARIANCE 0.0005\n#define CLEARCOATREFLECTANCE90 1.0\nfloat convertRoughnessToAverageSlope(float roughness)\n{\n\nreturn square(roughness)+MINIMUMVARIANCE;\n}\nvec2 getAARoughnessFactors(vec3 normalVector) {\n#ifdef SPECULARAA\nvec3 nDfdx=dFdx(normalVector.xyz);\nvec3 nDfdy=dFdy(normalVector.xyz);\nfloat slopeSquare=max(dot(nDfdx,nDfdx),dot(nDfdy,nDfdy));\n\nfloat geometricRoughnessFactor=pow(clamp(slopeSquare ,0.,1.),0.333);\n\nfloat geometricAlphaGFactor=sqrt(slopeSquare);\n\ngeometricAlphaGFactor*=0.75;\nreturn vec2(geometricRoughnessFactor,geometricAlphaGFactor);\n#else\nreturn vec2(0.);\n#endif\n}\n#ifdef MS_BRDF_ENERGY_CONSERVATION\n\n\nvec3 getEnergyConservationFactor(const vec3 specularEnvironmentR0,vec2 environmentBrdf) {\nreturn 1.0+specularEnvironmentR0*(1.0/environmentBrdf.y-1.0);\n}\n#endif\nvec2 getBRDFLookup(float NdotV,float perceptualRoughness,sampler2D brdfSampler) {\n\nvec2 UV=vec2(NdotV,perceptualRoughness);\n\nvec2 brdfLookup=texture2D(brdfSampler,UV).xy;\nreturn brdfLookup;\n}\nvec3 getReflectanceFromBRDFLookup(const vec3 specularEnvironmentR0,vec2 environmentBrdf) {\n#ifdef BRDF_V_HEIGHT_CORRELATED\nvec3 reflectance=mix(environmentBrdf.xxx,environmentBrdf.yyy,specularEnvironmentR0);\n#else\nvec3 reflectance=specularEnvironmentR0*environmentBrdf.x+environmentBrdf.y;\n#endif\nreturn reflectance;\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n#ifdef CLEARCOAT\n\n\n\n\n\nvec3 getR0RemappedForClearCoat(vec3 f0) {\n#ifdef CLEARCOAT_DEFAULTIOR\n#ifdef MOBILE\nreturn clamp(f0*(f0*0.526868+0.529324)-0.0482256,0.,1.);\n#else\nreturn clamp(f0*(f0*(0.941892-0.263008*f0)+0.346479)-0.0285998,0.,1.);\n#endif\n#else\nvec3 s=sqrt(f0);\nvec3 t=(vClearCoatRefractionParams.z+vClearCoatRefractionParams.w*s)/(vClearCoatRefractionParams.w+vClearCoatRefractionParams.z*s);\nreturn t*t;\n#endif\n}\n#endif\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nfloat smithVisibilityG1_TrowbridgeReitzGGXFast(float dot,float alphaG)\n{\n#ifdef MOBILE\n\nreturn 1.0/(dot+alphaG+(1.0-alphaG)*dot ));\n#else\nfloat alphaSquared=alphaG*alphaG;\nreturn 1.0/(dot+sqrt(alphaSquared+(1.0-alphaSquared)*dot*dot));\n#endif\n}\nfloat smithVisibility_TrowbridgeReitzGGXFast(float NdotL,float NdotV,float alphaG)\n{\nfloat visibility=smithVisibilityG1_TrowbridgeReitzGGXFast(NdotL,alphaG)*smithVisibilityG1_TrowbridgeReitzGGXFast(NdotV,alphaG);\n\nreturn visibility;\n}\nfloat kelemenVisibility(float VdotH) {\n\n\n\nreturn 0.25/(VdotH*VdotH);\n}\n\n\nfloat normalDistributionFunction_TrowbridgeReitzGGX(float NdotH,float alphaG)\n{\n\n\n\nfloat a2=square(alphaG);\nfloat d=NdotH*NdotH*(a2-1.0)+1.0;\nreturn a2/(PI*d*d);\n}\n\n\nvec2 getAnisotropicRoughness(float alphaG,float anisotropy) {\nfloat alphaT=max(alphaG*(1.0+anisotropy),MINIMUMVARIANCE);\nfloat alphaB=max(alphaG*(1.0-anisotropy),MINIMUMVARIANCE);\nreturn vec2(alphaT,alphaB);\n}\n\n\nvec3 getAnisotropicBentNormals(const mat3 TBN,const vec3 V,const vec3 N,float anisotropy) {\nvec3 anisotropicFrameDirection=anisotropy>=0.0 ? TBN[1] : TBN[0];\nvec3 anisotropicFrameTangent=cross(normalize(anisotropicFrameDirection),V);\nvec3 anisotropicFrameNormal=cross(anisotropicFrameTangent,anisotropicFrameDirection);\nvec3 anisotropicNormal=normalize(mix(N,anisotropicFrameNormal,abs(anisotropy)));\nreturn anisotropicNormal;\n\n}\n\n\nfloat normalDistributionFunction_BurleyGGX_Anisotropic(float NdotH,float TdotH,float BdotH,const vec2 alphaTB) {\nfloat a2=alphaTB.x*alphaTB.y;\nvec3 v=vec3(alphaTB.y*TdotH,alphaTB.x*BdotH,a2*NdotH);\nfloat v2=dot(v,v);\nfloat w2=a2/v2;\nreturn a2*w2*w2*RECIPROCAL_PI;\n}\n\n\n\nfloat smithVisibility_GGXCorrelated(float NdotV,float NdotL,float alphaG) {\n#ifdef MOBILE\n\nfloat GGXV=NdotL*(NdotV*(1.0-alphaG)+alphaG);\nfloat GGXL=NdotV*(NdotL*(1.0-alphaG)+alphaG);\nreturn 0.5/(GGXV+GGXL);\n#else\nfloat a2=alphaG*alphaG;\nfloat GGXV=NdotL*sqrt(NdotV*NdotV*(1.0-a2)+a2);\nfloat GGXL=NdotV*sqrt(NdotL*NdotL*(1.0-a2)+a2);\nreturn 0.5/(GGXV+GGXL);\n#endif\n}\n\n\nfloat smithVisibility_GGXCorrelated_Anisotropic(float NdotV,float NdotL,float TdotV,float BdotV,float TdotL,float BdotL,const vec2 alphaTB) {\nfloat lambdaV=NdotL*length(vec3(alphaTB.x*TdotV,alphaTB.y*BdotV,NdotV));\nfloat lambdaL=NdotV*length(vec3(alphaTB.x*TdotL,alphaTB.y*BdotL,NdotL));\nfloat v=0.5/(lambdaV+lambdaL);\nreturn v;\n}\nvec3 fresnelSchlickGGX(float VdotH,vec3 reflectance0,vec3 reflectance90)\n{\nreturn reflectance0+(reflectance90-reflectance0)*pow(1.0-VdotH,5.0);\n}\nfloat fresnelSchlickGGX(float VdotH,float reflectance0,float reflectance90)\n{\nreturn reflectance0+(reflectance90-reflectance0)*pow(1.0-VdotH,5.0);\n}\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\n\n\n\nvec3 cocaLambert(float NdotVRefract,float NdotLRefract,vec3 alpha,float thickness) {\nreturn exp(alpha*-(thickness*((NdotLRefract+NdotVRefract)/(NdotLRefract*NdotVRefract))));\n}\n\nvec3 computeColorAtDistanceInMedia(vec3 color,float distance) {\nreturn -log(color)/distance;\n}\n\n\n\nfloat computeDiffuseTerm(float NdotL,float NdotV,float VdotH,float roughness) {\n\n\nfloat diffuseFresnelNV=pow(clamp(1.0-NdotL,0.000001,1.),5.0);\nfloat diffuseFresnelNL=pow(clamp(1.0-NdotV,0.000001,1.),5.0);\nfloat diffuseFresnel90=0.5+2.0*VdotH*VdotH*roughness;\nfloat fresnel =\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNL) *\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNV);\nreturn fresnel/PI;\n}\n\nvec3 computeSpecularTerm(float NdotH,float NdotL,float NdotV,float VdotH,float roughness,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor) {\nroughness=max(roughness,geometricRoughnessFactor);\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\nfloat distribution=normalDistributionFunction_TrowbridgeReitzGGX(NdotH,alphaG);\n#ifdef BRDF_V_HEIGHT_CORRELATED\nfloat visibility=smithVisibility_GGXCorrelated(NdotL,NdotV,alphaG);\n#else\nfloat visibility=smithVisibility_TrowbridgeReitzGGXFast(NdotL,NdotV,alphaG);\n#endif\nfloat specTerm=max(0.,visibility*distribution);\nvec3 fresnel=fresnelSchlickGGX(VdotH,reflectance0,reflectance90);\nreturn fresnel*specTerm;\n}\nvec3 computeAnisotropicSpecularTerm(float NdotH,float NdotL,float NdotV,float VdotH,float TdotH,float BdotH,float TdotV,float BdotV,float TdotL,float BdotL,float roughness,float anisotropy,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor) {\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\nvec2 alphaTB=getAnisotropicRoughness(alphaG,anisotropy);\nalphaTB=max(alphaTB,geometricRoughnessFactor*geometricRoughnessFactor);\nfloat distribution=normalDistributionFunction_BurleyGGX_Anisotropic(NdotH,TdotH,BdotH,alphaTB);\nfloat visibility=smithVisibility_GGXCorrelated_Anisotropic(NdotV,NdotL,TdotV,BdotV,TdotL,BdotL,alphaTB);\nfloat specTerm=max(0.,visibility*distribution);\nvec3 fresnel=fresnelSchlickGGX(VdotH,reflectance0,reflectance90);\nreturn fresnel*specTerm;\n}\n#ifdef CLEARCOAT\nvec2 computeClearCoatTerm(float NdotH,float VdotH,float clearCoatRoughness,float geometricRoughnessFactor,float clearCoatIntensity) {\nclearCoatRoughness=max(clearCoatRoughness,geometricRoughnessFactor);\nfloat alphaG=convertRoughnessToAverageSlope(clearCoatRoughness);\nfloat distribution=normalDistributionFunction_TrowbridgeReitzGGX(NdotH,alphaG);\nfloat visibility=kelemenVisibility(VdotH);\nfloat clearCoatTerm=max(0.,visibility*distribution);\nfloat fresnel=fresnelSchlickGGX(VdotH,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);\nfresnel*=clearCoatIntensity;\nreturn vec2(fresnel*clearCoatTerm,1.0-fresnel);\n}\nvec3 computeClearCoatAbsorption(float NdotVRefract,float NdotLRefract,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {\nvec3 clearCoatAbsorption=mix(vec3(1.0),\ncocaLambert(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness),\nclearCoatIntensity);\nreturn clearCoatAbsorption;\n}\n#endif\nfloat adjustRoughnessFromLightProperties(float roughness,float lightRadius,float lightDistance)\n{\n#if defined(USEPHYSICALLIGHTFALLOFF) || defined(USEGLTFLIGHTFALLOFF)\n\nfloat lightRoughness=lightRadius/lightDistance;\n\nfloat totalRoughness=clamp(lightRoughness+roughness,0.,1.);\nreturn totalRoughness;\n#else\nreturn roughness;\n#endif\n}\nfloat computeDefaultMicroSurface(float microSurface,vec3 reflectivityColor)\n{\nconst float kReflectivityNoAlphaWorkflow_SmoothnessMax=0.95;\nfloat reflectivityLuminance=getLuminance(reflectivityColor);\nfloat reflectivityLuma=sqrt(reflectivityLuminance);\nmicroSurface=reflectivityLuma*kReflectivityNoAlphaWorkflow_SmoothnessMax;\nreturn microSurface;\n}\n\n\nfloat fresnelGrazingReflectance(float reflectance0) {\nfloat reflectance90=clamp(reflectance0*25.0,0.0,1.0);\nreturn reflectance90;\n}\n\n\n#define UNPACK_LOD(x) (1.0-x)*255.0\nfloat getLodFromAlphaG(float cubeMapDimensionPixels,float alphaG,float NdotV) {\nfloat microsurfaceAverageSlope=alphaG;\n\n\n\n\n\n\nmicrosurfaceAverageSlope*=sqrt(abs(NdotV));\nfloat microsurfaceAverageSlopeTexels=microsurfaceAverageSlope*cubeMapDimensionPixels;\nfloat lod=log2(microsurfaceAverageSlopeTexels);\nreturn lod;\n}\nfloat environmentRadianceOcclusion(float ambientOcclusion,float NdotVUnclamped) {\n\n\nfloat temp=NdotVUnclamped+ambientOcclusion;\nreturn clamp(square(temp)-1.0+ambientOcclusion,0.0,1.0);\n}\nfloat environmentHorizonOcclusion(vec3 view,vec3 normal) {\n\nvec3 reflection=reflect(view,normal);\nfloat temp=clamp( 1.0+1.1*dot(reflection,normal),0.0,1.0);\nreturn square(temp);\n}";
  125053. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125054. /** @hidden */
  125055. var pbrFunctions = { name: name, shader: shader };
  125056. /***/ }),
  125057. /***/ "./Shaders/ShadersInclude/pbrLightingFunctions.ts":
  125058. /*!********************************************************!*\
  125059. !*** ./Shaders/ShadersInclude/pbrLightingFunctions.ts ***!
  125060. \********************************************************/
  125061. /*! exports provided: pbrLightingFunctions */
  125062. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125063. "use strict";
  125064. __webpack_require__.r(__webpack_exports__);
  125065. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrLightingFunctions", function() { return pbrLightingFunctions; });
  125066. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125067. var name = 'pbrLightingFunctions';
  125068. var shader = "\nstruct lightingInfo\n{\nvec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n#ifdef CLEARCOAT\n\n\nvec4 clearCoat;\n#endif\n};\nvec3 computeHemisphericDiffuseLighting(preLightingInfo info,vec3 lightColor,vec3 groundColor) {\nreturn mix(groundColor,lightColor,info.NdotL);\n}\nvec3 computeDiffuseLighting(preLightingInfo info,vec3 lightColor) {\nfloat diffuseTerm=computeDiffuseTerm(info.NdotL,info.NdotV,info.VdotH,info.roughness);\nreturn diffuseTerm*info.attenuation*info.NdotL*lightColor;\n}\nvec3 computeSpecularLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {\nfloat NdotH=clamp(dot(N,info.H),0.000000000001,1.0);\nvec3 specTerm=computeSpecularTerm(NdotH,info.NdotL,info.NdotV,info.VdotH,info.roughness,reflectance0,reflectance90,geometricRoughnessFactor);\nreturn specTerm*info.attenuation*info.NdotL*lightColor;\n}\nvec3 computeAnisotropicSpecularLighting(preLightingInfo info,vec3 V,vec3 N,vec3 T,vec3 B,float anisotropy,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {\nfloat NdotH=clamp(dot(N,info.H),0.000000000001,1.0);\nfloat TdotH=dot(T,info.H);\nfloat BdotH=dot(B,info.H);\nfloat TdotV=dot(T,V);\nfloat BdotV=dot(B,V);\nfloat TdotL=dot(T,info.L);\nfloat BdotL=dot(B,info.L);\nvec3 specTerm=computeAnisotropicSpecularTerm(NdotH,info.NdotL,info.NdotV,info.VdotH,TdotH,BdotH,TdotV,BdotV,TdotL,BdotL,info.roughness,anisotropy,reflectance0,reflectance90,geometricRoughnessFactor);\nreturn specTerm*info.attenuation*info.NdotL*lightColor;\n}\n#ifdef CLEARCOAT\nvec4 computeClearCoatLighting(preLightingInfo info,vec3 Ncc,float geometricRoughnessFactor,float clearCoatIntensity,vec3 lightColor) {\nfloat NccdotL=clamp(dot(Ncc,info.L),0.00000000001,1.0);\nfloat NccdotH=clamp(dot(Ncc,info.H),0.000000000001,1.0);\nvec2 clearCoatTerm=computeClearCoatTerm(NccdotH,info.VdotH,info.roughness,geometricRoughnessFactor,clearCoatIntensity);\nvec4 result=vec4(0.);\nresult.rgb=clearCoatTerm.x*info.attenuation*NccdotL*lightColor;\nresult.a=clearCoatTerm.y;\nreturn result;\n}\nvec3 computeClearCoatLightingAbsorption(float NdotVRefract,vec3 L,vec3 Ncc,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {\nvec3 LRefract=-refract(L,Ncc,vClearCoatRefractionParams.y);\nfloat NdotLRefract=clamp(dot(Ncc,LRefract),0.00000000001,1.0);\nvec3 absorption=computeClearCoatAbsorption(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness,clearCoatIntensity);\nreturn absorption;\n}\n#endif\nvec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix){\nvec4 strq=textureProjectionMatrix*vec4(vPositionW,1.0);\nstrq/=strq.w;\nvec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;\nreturn toLinearSpace(textureColor);\n}\n";
  125069. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125070. /** @hidden */
  125071. var pbrLightingFunctions = { name: name, shader: shader };
  125072. /***/ }),
  125073. /***/ "./Shaders/ShadersInclude/pbrPreLightingFunctions.ts":
  125074. /*!***********************************************************!*\
  125075. !*** ./Shaders/ShadersInclude/pbrPreLightingFunctions.ts ***!
  125076. \***********************************************************/
  125077. /*! exports provided: pbrPreLightingFunctions */
  125078. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125079. "use strict";
  125080. __webpack_require__.r(__webpack_exports__);
  125081. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrPreLightingFunctions", function() { return pbrPreLightingFunctions; });
  125082. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125083. var name = 'pbrPreLightingFunctions';
  125084. var shader = "\nstruct preLightingInfo\n{\n\nvec3 lightOffset;\nfloat lightDistanceSquared;\nfloat lightDistance;\n\nfloat attenuation;\n\nvec3 L;\nvec3 H;\nfloat NdotV;\nfloat NdotL;\nfloat VdotH;\nfloat roughness;\n};\npreLightingInfo computePointAndSpotPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {\npreLightingInfo result;\n\nresult.lightOffset=lightData.xyz-vPositionW;\nresult.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);\n\nresult.lightDistance=sqrt(result.lightDistanceSquared);\n\nresult.L=normalize(result.lightOffset);\nresult.H=normalize(V+result.L);\nresult.NdotL=clamp(dot(N,result.L),0.000000000001,1.0);\nresult.VdotH=clamp(dot(V,result.H),0.0,1.0);\nreturn result;\n}\npreLightingInfo computeDirectionalPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {\npreLightingInfo result;\n\nresult.lightDistance=length(-lightData.xyz);\n\nresult.L=normalize(-lightData.xyz);\nresult.H=normalize(V+result.L);\nresult.NdotL=clamp(dot(N,result.L),0.00000000001,1.0);\nresult.VdotH=clamp(dot(V,result.H),0.0,1.0);\nreturn result;\n}\npreLightingInfo computeHemisphericPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {\npreLightingInfo result;\n\nresult.NdotL=dot(N,lightData.xyz)*0.5+0.5;\nresult.NdotL=clamp(result.NdotL,0.000000000001,1.0);\n#ifdef SPECULARTERM\nresult.L=normalize(lightData.xyz);\nresult.H=normalize(V+result.L);\nresult.VdotH=clamp(dot(V,result.H),0.0,1.0);\n#endif\nreturn result;\n}";
  125085. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125086. /** @hidden */
  125087. var pbrPreLightingFunctions = { name: name, shader: shader };
  125088. /***/ }),
  125089. /***/ "./Shaders/ShadersInclude/pbrUboDeclaration.ts":
  125090. /*!*****************************************************!*\
  125091. !*** ./Shaders/ShadersInclude/pbrUboDeclaration.ts ***!
  125092. \*****************************************************/
  125093. /*! exports provided: pbrUboDeclaration */
  125094. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125095. "use strict";
  125096. __webpack_require__.r(__webpack_exports__);
  125097. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrUboDeclaration", function() { return pbrUboDeclaration; });
  125098. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125099. var name = 'pbrUboDeclaration';
  125100. var shader = "layout(std140,column_major) uniform;\nuniform Material\n{\nuniform vec2 vAlbedoInfos;\nuniform vec4 vAmbientInfos;\nuniform vec2 vOpacityInfos;\nuniform vec2 vEmissiveInfos;\nuniform vec2 vLightmapInfos;\nuniform vec3 vReflectivityInfos;\nuniform vec2 vMicroSurfaceSamplerInfos;\nuniform vec4 vRefractionInfos;\nuniform vec2 vReflectionInfos;\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize;\nuniform vec3 vBumpInfos;\nuniform mat4 albedoMatrix;\nuniform mat4 ambientMatrix;\nuniform mat4 opacityMatrix;\nuniform mat4 emissiveMatrix;\nuniform mat4 lightmapMatrix;\nuniform mat4 reflectivityMatrix;\nuniform mat4 microSurfaceSamplerMatrix;\nuniform mat4 bumpMatrix;\nuniform vec2 vTangentSpaceParams;\nuniform mat4 refractionMatrix;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\nuniform vec4 vLightingIntensity;\nuniform vec3 vRefractionMicrosurfaceInfos;\nuniform vec3 vReflectionMicrosurfaceInfos;\nuniform vec4 vReflectivityColor;\nuniform vec3 vEmissiveColor;\nuniform float pointSize;\nuniform vec2 vClearCoatParams;\nuniform vec4 vClearCoatRefractionParams;\nuniform vec2 vClearCoatInfos;\nuniform mat4 clearCoatMatrix;\nuniform vec2 vClearCoatBumpInfos;\nuniform vec2 vClearCoatTangentSpaceParams;\nuniform mat4 clearCoatBumpMatrix;\nuniform vec4 vClearCoatTintParams;\nuniform float clearCoatColorAtDistance;\nuniform vec2 vClearCoatTintInfos;\nuniform mat4 clearCoatTintMatrix;\nuniform float anisotropy;\n};\nuniform Scene {\nmat4 viewProjection;\nmat4 view;\n};";
  125101. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125102. /** @hidden */
  125103. var pbrUboDeclaration = { name: name, shader: shader };
  125104. /***/ }),
  125105. /***/ "./Shaders/ShadersInclude/pbrVertexDeclaration.ts":
  125106. /*!********************************************************!*\
  125107. !*** ./Shaders/ShadersInclude/pbrVertexDeclaration.ts ***!
  125108. \********************************************************/
  125109. /*! exports provided: pbrVertexDeclaration */
  125110. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125111. "use strict";
  125112. __webpack_require__.r(__webpack_exports__);
  125113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrVertexDeclaration", function() { return pbrVertexDeclaration; });
  125114. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125115. var name = 'pbrVertexDeclaration';
  125116. var shader = "uniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef ALBEDO\nuniform mat4 albedoMatrix;\nuniform vec2 vAlbedoInfos;\n#endif\n#ifdef AMBIENT\nuniform mat4 ambientMatrix;\nuniform vec4 vAmbientInfos;\n#endif\n#ifdef OPACITY\nuniform mat4 opacityMatrix;\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\nuniform mat4 emissiveMatrix;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\nuniform mat4 lightmapMatrix;\n#endif\n#ifdef REFLECTIVITY\nuniform vec3 vReflectivityInfos;\nuniform mat4 reflectivityMatrix;\n#endif\n#ifdef MICROSURFACEMAP\nuniform vec2 vMicroSurfaceSamplerInfos;\nuniform mat4 microSurfaceSamplerMatrix;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform mat4 bumpMatrix;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\nuniform vec3 vRefractionMicrosurfaceInfos;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\n#endif\n\n#ifdef CLEARCOAT\n#ifdef CLEARCOAT_TEXTURE\nuniform vec2 vClearCoatInfos;\nuniform mat4 clearCoatMatrix;\n#endif\n#ifdef CLEARCOAT_BUMP\nuniform vec2 vClearCoatBumpInfos;\nuniform mat4 clearCoatBumpMatrix;\n#endif\n#ifdef CLEARCOAT_TINT_TEXTURE\nuniform vec2 vClearCoatTintInfos;\nuniform mat4 clearCoatTintMatrix;\n#endif\n#endif\n";
  125117. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125118. /** @hidden */
  125119. var pbrVertexDeclaration = { name: name, shader: shader };
  125120. /***/ }),
  125121. /***/ "./Shaders/ShadersInclude/pointCloudVertex.ts":
  125122. /*!****************************************************!*\
  125123. !*** ./Shaders/ShadersInclude/pointCloudVertex.ts ***!
  125124. \****************************************************/
  125125. /*! exports provided: pointCloudVertex */
  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__, "pointCloudVertex", function() { return pointCloudVertex; });
  125130. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125131. var name = 'pointCloudVertex';
  125132. var shader = "#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif";
  125133. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125134. /** @hidden */
  125135. var pointCloudVertex = { name: name, shader: shader };
  125136. /***/ }),
  125137. /***/ "./Shaders/ShadersInclude/reflectionFunction.ts":
  125138. /*!******************************************************!*\
  125139. !*** ./Shaders/ShadersInclude/reflectionFunction.ts ***!
  125140. \******************************************************/
  125141. /*! exports provided: reflectionFunction */
  125142. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125143. "use strict";
  125144. __webpack_require__.r(__webpack_exports__);
  125145. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "reflectionFunction", function() { return reflectionFunction; });
  125146. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125147. var name = 'reflectionFunction';
  125148. 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}";
  125149. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125150. /** @hidden */
  125151. var reflectionFunction = { name: name, shader: shader };
  125152. /***/ }),
  125153. /***/ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts":
  125154. /*!************************************************************!*\
  125155. !*** ./Shaders/ShadersInclude/shadowsFragmentFunctions.ts ***!
  125156. \************************************************************/
  125157. /*! exports provided: shadowsFragmentFunctions */
  125158. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125159. "use strict";
  125160. __webpack_require__.r(__webpack_exports__);
  125161. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowsFragmentFunctions", function() { return shadowsFragmentFunctions; });
  125162. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125163. var name = 'shadowsFragmentFunctions';
  125164. 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";
  125165. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125166. /** @hidden */
  125167. var shadowsFragmentFunctions = { name: name, shader: shader };
  125168. /***/ }),
  125169. /***/ "./Shaders/ShadersInclude/shadowsVertex.ts":
  125170. /*!*************************************************!*\
  125171. !*** ./Shaders/ShadersInclude/shadowsVertex.ts ***!
  125172. \*************************************************/
  125173. /*! exports provided: shadowsVertex */
  125174. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125175. "use strict";
  125176. __webpack_require__.r(__webpack_exports__);
  125177. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowsVertex", function() { return shadowsVertex; });
  125178. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  125179. var name = 'shadowsVertex';
  125180. 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";
  125181. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  125182. /** @hidden */
  125183. var shadowsVertex = { name: name, shader: shader };
  125184. /***/ }),
  125185. /***/ "./Shaders/anaglyph.fragment.ts":
  125186. /*!**************************************!*\
  125187. !*** ./Shaders/anaglyph.fragment.ts ***!
  125188. \**************************************/
  125189. /*! exports provided: anaglyphPixelShader */
  125190. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125191. "use strict";
  125192. __webpack_require__.r(__webpack_exports__);
  125193. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "anaglyphPixelShader", function() { return anaglyphPixelShader; });
  125194. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125195. var name = 'anaglyphPixelShader';
  125196. 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}";
  125197. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125198. /** @hidden */
  125199. var anaglyphPixelShader = { name: name, shader: shader };
  125200. /***/ }),
  125201. /***/ "./Shaders/background.fragment.ts":
  125202. /*!****************************************!*\
  125203. !*** ./Shaders/background.fragment.ts ***!
  125204. \****************************************/
  125205. /*! exports provided: backgroundPixelShader */
  125206. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125207. "use strict";
  125208. __webpack_require__.r(__webpack_exports__);
  125209. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundPixelShader", function() { return backgroundPixelShader; });
  125210. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125211. /* harmony import */ var _ShadersInclude_backgroundFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/backgroundFragmentDeclaration */ "./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts");
  125212. /* harmony import */ var _ShadersInclude_backgroundUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/backgroundUboDeclaration */ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts");
  125213. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  125214. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  125215. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  125216. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  125217. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  125218. /* harmony import */ var _ShadersInclude_lightsFragmentFunctions__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/lightsFragmentFunctions */ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts");
  125219. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  125220. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  125221. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  125222. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  125223. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  125224. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  125225. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  125226. var name = 'backgroundPixelShader';
  125227. 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";
  125228. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125229. /** @hidden */
  125230. var backgroundPixelShader = { name: name, shader: shader };
  125231. /***/ }),
  125232. /***/ "./Shaders/background.vertex.ts":
  125233. /*!**************************************!*\
  125234. !*** ./Shaders/background.vertex.ts ***!
  125235. \**************************************/
  125236. /*! exports provided: backgroundVertexShader */
  125237. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125238. "use strict";
  125239. __webpack_require__.r(__webpack_exports__);
  125240. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundVertexShader", function() { return backgroundVertexShader; });
  125241. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125242. /* harmony import */ var _ShadersInclude_backgroundVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/backgroundVertexDeclaration */ "./Shaders/ShadersInclude/backgroundVertexDeclaration.ts");
  125243. /* harmony import */ var _ShadersInclude_backgroundUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/backgroundUboDeclaration */ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts");
  125244. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  125245. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  125246. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  125247. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  125248. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  125249. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  125250. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  125251. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  125252. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  125253. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  125254. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  125255. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  125256. var name = 'backgroundVertexShader';
  125257. 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";
  125258. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125259. /** @hidden */
  125260. var backgroundVertexShader = { name: name, shader: shader };
  125261. /***/ }),
  125262. /***/ "./Shaders/blackAndWhite.fragment.ts":
  125263. /*!*******************************************!*\
  125264. !*** ./Shaders/blackAndWhite.fragment.ts ***!
  125265. \*******************************************/
  125266. /*! exports provided: blackAndWhitePixelShader */
  125267. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125268. "use strict";
  125269. __webpack_require__.r(__webpack_exports__);
  125270. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "blackAndWhitePixelShader", function() { return blackAndWhitePixelShader; });
  125271. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125272. var name = 'blackAndWhitePixelShader';
  125273. 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}";
  125274. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125275. /** @hidden */
  125276. var blackAndWhitePixelShader = { name: name, shader: shader };
  125277. /***/ }),
  125278. /***/ "./Shaders/bloomMerge.fragment.ts":
  125279. /*!****************************************!*\
  125280. !*** ./Shaders/bloomMerge.fragment.ts ***!
  125281. \****************************************/
  125282. /*! exports provided: bloomMergePixelShader */
  125283. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125284. "use strict";
  125285. __webpack_require__.r(__webpack_exports__);
  125286. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bloomMergePixelShader", function() { return bloomMergePixelShader; });
  125287. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125288. var name = 'bloomMergePixelShader';
  125289. 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";
  125290. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125291. /** @hidden */
  125292. var bloomMergePixelShader = { name: name, shader: shader };
  125293. /***/ }),
  125294. /***/ "./Shaders/chromaticAberration.fragment.ts":
  125295. /*!*************************************************!*\
  125296. !*** ./Shaders/chromaticAberration.fragment.ts ***!
  125297. \*************************************************/
  125298. /*! exports provided: chromaticAberrationPixelShader */
  125299. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125300. "use strict";
  125301. __webpack_require__.r(__webpack_exports__);
  125302. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "chromaticAberrationPixelShader", function() { return chromaticAberrationPixelShader; });
  125303. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125304. var name = 'chromaticAberrationPixelShader';
  125305. 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}";
  125306. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125307. /** @hidden */
  125308. var chromaticAberrationPixelShader = { name: name, shader: shader };
  125309. /***/ }),
  125310. /***/ "./Shaders/circleOfConfusion.fragment.ts":
  125311. /*!***********************************************!*\
  125312. !*** ./Shaders/circleOfConfusion.fragment.ts ***!
  125313. \***********************************************/
  125314. /*! exports provided: circleOfConfusionPixelShader */
  125315. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125316. "use strict";
  125317. __webpack_require__.r(__webpack_exports__);
  125318. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "circleOfConfusionPixelShader", function() { return circleOfConfusionPixelShader; });
  125319. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125320. var name = 'circleOfConfusionPixelShader';
  125321. 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";
  125322. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125323. /** @hidden */
  125324. var circleOfConfusionPixelShader = { name: name, shader: shader };
  125325. /***/ }),
  125326. /***/ "./Shaders/color.fragment.ts":
  125327. /*!***********************************!*\
  125328. !*** ./Shaders/color.fragment.ts ***!
  125329. \***********************************/
  125330. /*! exports provided: colorPixelShader */
  125331. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125332. "use strict";
  125333. __webpack_require__.r(__webpack_exports__);
  125334. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorPixelShader", function() { return colorPixelShader; });
  125335. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125336. var name = 'colorPixelShader';
  125337. 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}";
  125338. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125339. /** @hidden */
  125340. var colorPixelShader = { name: name, shader: shader };
  125341. /***/ }),
  125342. /***/ "./Shaders/color.vertex.ts":
  125343. /*!*********************************!*\
  125344. !*** ./Shaders/color.vertex.ts ***!
  125345. \*********************************/
  125346. /*! exports provided: colorVertexShader */
  125347. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125348. "use strict";
  125349. __webpack_require__.r(__webpack_exports__);
  125350. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorVertexShader", function() { return colorVertexShader; });
  125351. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125352. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  125353. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  125354. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  125355. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  125356. var name = 'colorVertexShader';
  125357. 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}";
  125358. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125359. /** @hidden */
  125360. var colorVertexShader = { name: name, shader: shader };
  125361. /***/ }),
  125362. /***/ "./Shaders/colorCorrection.fragment.ts":
  125363. /*!*********************************************!*\
  125364. !*** ./Shaders/colorCorrection.fragment.ts ***!
  125365. \*********************************************/
  125366. /*! exports provided: colorCorrectionPixelShader */
  125367. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125368. "use strict";
  125369. __webpack_require__.r(__webpack_exports__);
  125370. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorCorrectionPixelShader", function() { return colorCorrectionPixelShader; });
  125371. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125372. var name = 'colorCorrectionPixelShader';
  125373. 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}";
  125374. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125375. /** @hidden */
  125376. var colorCorrectionPixelShader = { name: name, shader: shader };
  125377. /***/ }),
  125378. /***/ "./Shaders/convolution.fragment.ts":
  125379. /*!*****************************************!*\
  125380. !*** ./Shaders/convolution.fragment.ts ***!
  125381. \*****************************************/
  125382. /*! exports provided: convolutionPixelShader */
  125383. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125384. "use strict";
  125385. __webpack_require__.r(__webpack_exports__);
  125386. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "convolutionPixelShader", function() { return convolutionPixelShader; });
  125387. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125388. var name = 'convolutionPixelShader';
  125389. 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}";
  125390. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125391. /** @hidden */
  125392. var convolutionPixelShader = { name: name, shader: shader };
  125393. /***/ }),
  125394. /***/ "./Shaders/default.fragment.ts":
  125395. /*!*************************************!*\
  125396. !*** ./Shaders/default.fragment.ts ***!
  125397. \*************************************/
  125398. /*! exports provided: defaultPixelShader */
  125399. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125400. "use strict";
  125401. __webpack_require__.r(__webpack_exports__);
  125402. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultPixelShader", function() { return defaultPixelShader; });
  125403. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125404. /* harmony import */ var _ShadersInclude_defaultFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/defaultFragmentDeclaration */ "./Shaders/ShadersInclude/defaultFragmentDeclaration.ts");
  125405. /* harmony import */ var _ShadersInclude_defaultUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/defaultUboDeclaration */ "./Shaders/ShadersInclude/defaultUboDeclaration.ts");
  125406. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  125407. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  125408. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  125409. /* harmony import */ var _ShadersInclude_lightsFragmentFunctions__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/lightsFragmentFunctions */ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts");
  125410. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  125411. /* harmony import */ var _ShadersInclude_fresnelFunction__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/fresnelFunction */ "./Shaders/ShadersInclude/fresnelFunction.ts");
  125412. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  125413. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  125414. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  125415. /* harmony import */ var _ShadersInclude_bumpFragmentFunctions__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/bumpFragmentFunctions */ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts");
  125416. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  125417. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  125418. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  125419. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  125420. /* harmony import */ var _ShadersInclude_bumpFragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bumpFragment */ "./Shaders/ShadersInclude/bumpFragment.ts");
  125421. /* harmony import */ var _ShadersInclude_depthPrePass__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/depthPrePass */ "./Shaders/ShadersInclude/depthPrePass.ts");
  125422. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  125423. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  125424. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  125425. var name = 'defaultPixelShader';
  125426. 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";
  125427. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125428. /** @hidden */
  125429. var defaultPixelShader = { name: name, shader: shader };
  125430. /***/ }),
  125431. /***/ "./Shaders/default.vertex.ts":
  125432. /*!***********************************!*\
  125433. !*** ./Shaders/default.vertex.ts ***!
  125434. \***********************************/
  125435. /*! exports provided: defaultVertexShader */
  125436. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125437. "use strict";
  125438. __webpack_require__.r(__webpack_exports__);
  125439. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultVertexShader", function() { return defaultVertexShader; });
  125440. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125441. /* harmony import */ var _ShadersInclude_defaultVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/defaultVertexDeclaration */ "./Shaders/ShadersInclude/defaultVertexDeclaration.ts");
  125442. /* harmony import */ var _ShadersInclude_defaultUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/defaultUboDeclaration */ "./Shaders/ShadersInclude/defaultUboDeclaration.ts");
  125443. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  125444. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  125445. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  125446. /* harmony import */ var _ShadersInclude_bumpVertexDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/bumpVertexDeclaration */ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts");
  125447. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  125448. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  125449. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  125450. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  125451. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  125452. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  125453. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  125454. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  125455. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  125456. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  125457. /* harmony import */ var _ShadersInclude_bumpVertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bumpVertex */ "./Shaders/ShadersInclude/bumpVertex.ts");
  125458. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  125459. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  125460. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  125461. /* harmony import */ var _ShadersInclude_pointCloudVertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/pointCloudVertex */ "./Shaders/ShadersInclude/pointCloudVertex.ts");
  125462. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  125463. var name = 'defaultVertexShader';
  125464. 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";
  125465. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125466. /** @hidden */
  125467. var defaultVertexShader = { name: name, shader: shader };
  125468. /***/ }),
  125469. /***/ "./Shaders/depth.fragment.ts":
  125470. /*!***********************************!*\
  125471. !*** ./Shaders/depth.fragment.ts ***!
  125472. \***********************************/
  125473. /*! exports provided: depthPixelShader */
  125474. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125475. "use strict";
  125476. __webpack_require__.r(__webpack_exports__);
  125477. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthPixelShader", function() { return depthPixelShader; });
  125478. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125479. var name = 'depthPixelShader';
  125480. 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}";
  125481. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125482. /** @hidden */
  125483. var depthPixelShader = { name: name, shader: shader };
  125484. /***/ }),
  125485. /***/ "./Shaders/depth.vertex.ts":
  125486. /*!*********************************!*\
  125487. !*** ./Shaders/depth.vertex.ts ***!
  125488. \*********************************/
  125489. /*! exports provided: depthVertexShader */
  125490. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125491. "use strict";
  125492. __webpack_require__.r(__webpack_exports__);
  125493. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthVertexShader", function() { return depthVertexShader; });
  125494. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125495. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  125496. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  125497. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  125498. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  125499. var name = 'depthVertexShader';
  125500. 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}";
  125501. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125502. /** @hidden */
  125503. var depthVertexShader = { name: name, shader: shader };
  125504. /***/ }),
  125505. /***/ "./Shaders/depthBoxBlur.fragment.ts":
  125506. /*!******************************************!*\
  125507. !*** ./Shaders/depthBoxBlur.fragment.ts ***!
  125508. \******************************************/
  125509. /*! exports provided: depthBoxBlurPixelShader */
  125510. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125511. "use strict";
  125512. __webpack_require__.r(__webpack_exports__);
  125513. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthBoxBlurPixelShader", function() { return depthBoxBlurPixelShader; });
  125514. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125515. var name = 'depthBoxBlurPixelShader';
  125516. 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}";
  125517. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125518. /** @hidden */
  125519. var depthBoxBlurPixelShader = { name: name, shader: shader };
  125520. /***/ }),
  125521. /***/ "./Shaders/depthOfField.fragment.ts":
  125522. /*!******************************************!*\
  125523. !*** ./Shaders/depthOfField.fragment.ts ***!
  125524. \******************************************/
  125525. /*! exports provided: depthOfFieldPixelShader */
  125526. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125527. "use strict";
  125528. __webpack_require__.r(__webpack_exports__);
  125529. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthOfFieldPixelShader", function() { return depthOfFieldPixelShader; });
  125530. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125531. var name = 'depthOfFieldPixelShader';
  125532. 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";
  125533. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125534. /** @hidden */
  125535. var depthOfFieldPixelShader = { name: name, shader: shader };
  125536. /***/ }),
  125537. /***/ "./Shaders/depthOfFieldMerge.fragment.ts":
  125538. /*!***********************************************!*\
  125539. !*** ./Shaders/depthOfFieldMerge.fragment.ts ***!
  125540. \***********************************************/
  125541. /*! exports provided: depthOfFieldMergePixelShader */
  125542. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125543. "use strict";
  125544. __webpack_require__.r(__webpack_exports__);
  125545. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthOfFieldMergePixelShader", function() { return depthOfFieldMergePixelShader; });
  125546. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125547. var name = 'depthOfFieldMergePixelShader';
  125548. 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";
  125549. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125550. /** @hidden */
  125551. var depthOfFieldMergePixelShader = { name: name, shader: shader };
  125552. /***/ }),
  125553. /***/ "./Shaders/displayPass.fragment.ts":
  125554. /*!*****************************************!*\
  125555. !*** ./Shaders/displayPass.fragment.ts ***!
  125556. \*****************************************/
  125557. /*! exports provided: displayPassPixelShader */
  125558. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125559. "use strict";
  125560. __webpack_require__.r(__webpack_exports__);
  125561. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "displayPassPixelShader", function() { return displayPassPixelShader; });
  125562. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125563. var name = 'displayPassPixelShader';
  125564. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D passSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(passSampler,vUV);\n}";
  125565. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125566. /** @hidden */
  125567. var displayPassPixelShader = { name: name, shader: shader };
  125568. /***/ }),
  125569. /***/ "./Shaders/extractHighlights.fragment.ts":
  125570. /*!***********************************************!*\
  125571. !*** ./Shaders/extractHighlights.fragment.ts ***!
  125572. \***********************************************/
  125573. /*! exports provided: extractHighlightsPixelShader */
  125574. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125575. "use strict";
  125576. __webpack_require__.r(__webpack_exports__);
  125577. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "extractHighlightsPixelShader", function() { return extractHighlightsPixelShader; });
  125578. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125579. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  125580. var name = 'extractHighlightsPixelShader';
  125581. 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}";
  125582. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125583. /** @hidden */
  125584. var extractHighlightsPixelShader = { name: name, shader: shader };
  125585. /***/ }),
  125586. /***/ "./Shaders/filter.fragment.ts":
  125587. /*!************************************!*\
  125588. !*** ./Shaders/filter.fragment.ts ***!
  125589. \************************************/
  125590. /*! exports provided: filterPixelShader */
  125591. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125592. "use strict";
  125593. __webpack_require__.r(__webpack_exports__);
  125594. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "filterPixelShader", function() { return filterPixelShader; });
  125595. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125596. var name = 'filterPixelShader';
  125597. 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}";
  125598. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125599. /** @hidden */
  125600. var filterPixelShader = { name: name, shader: shader };
  125601. /***/ }),
  125602. /***/ "./Shaders/fxaa.fragment.ts":
  125603. /*!**********************************!*\
  125604. !*** ./Shaders/fxaa.fragment.ts ***!
  125605. \**********************************/
  125606. /*! exports provided: fxaaPixelShader */
  125607. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125608. "use strict";
  125609. __webpack_require__.r(__webpack_exports__);
  125610. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fxaaPixelShader", function() { return fxaaPixelShader; });
  125611. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125612. var name = 'fxaaPixelShader';
  125613. 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}";
  125614. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125615. /** @hidden */
  125616. var fxaaPixelShader = { name: name, shader: shader };
  125617. /***/ }),
  125618. /***/ "./Shaders/fxaa.vertex.ts":
  125619. /*!********************************!*\
  125620. !*** ./Shaders/fxaa.vertex.ts ***!
  125621. \********************************/
  125622. /*! exports provided: fxaaVertexShader */
  125623. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125624. "use strict";
  125625. __webpack_require__.r(__webpack_exports__);
  125626. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fxaaVertexShader", function() { return fxaaVertexShader; });
  125627. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125628. var name = 'fxaaVertexShader';
  125629. 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}";
  125630. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125631. /** @hidden */
  125632. var fxaaVertexShader = { name: name, shader: shader };
  125633. /***/ }),
  125634. /***/ "./Shaders/geometry.fragment.ts":
  125635. /*!**************************************!*\
  125636. !*** ./Shaders/geometry.fragment.ts ***!
  125637. \**************************************/
  125638. /*! exports provided: geometryPixelShader */
  125639. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125640. "use strict";
  125641. __webpack_require__.r(__webpack_exports__);
  125642. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "geometryPixelShader", function() { return geometryPixelShader; });
  125643. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125644. /* harmony import */ var _ShadersInclude_mrtFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/mrtFragmentDeclaration */ "./Shaders/ShadersInclude/mrtFragmentDeclaration.ts");
  125645. var name = 'geometryPixelShader';
  125646. 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}";
  125647. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125648. /** @hidden */
  125649. var geometryPixelShader = { name: name, shader: shader };
  125650. /***/ }),
  125651. /***/ "./Shaders/geometry.vertex.ts":
  125652. /*!************************************!*\
  125653. !*** ./Shaders/geometry.vertex.ts ***!
  125654. \************************************/
  125655. /*! exports provided: geometryVertexShader */
  125656. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125657. "use strict";
  125658. __webpack_require__.r(__webpack_exports__);
  125659. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "geometryVertexShader", function() { return geometryVertexShader; });
  125660. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125661. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  125662. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  125663. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  125664. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  125665. var name = 'geometryVertexShader';
  125666. 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}";
  125667. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125668. /** @hidden */
  125669. var geometryVertexShader = { name: name, shader: shader };
  125670. /***/ }),
  125671. /***/ "./Shaders/glowBlurPostProcess.fragment.ts":
  125672. /*!*************************************************!*\
  125673. !*** ./Shaders/glowBlurPostProcess.fragment.ts ***!
  125674. \*************************************************/
  125675. /*! exports provided: glowBlurPostProcessPixelShader */
  125676. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125677. "use strict";
  125678. __webpack_require__.r(__webpack_exports__);
  125679. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowBlurPostProcessPixelShader", function() { return glowBlurPostProcessPixelShader; });
  125680. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125681. var name = 'glowBlurPostProcessPixelShader';
  125682. 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}";
  125683. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125684. /** @hidden */
  125685. var glowBlurPostProcessPixelShader = { name: name, shader: shader };
  125686. /***/ }),
  125687. /***/ "./Shaders/glowMapGeneration.fragment.ts":
  125688. /*!***********************************************!*\
  125689. !*** ./Shaders/glowMapGeneration.fragment.ts ***!
  125690. \***********************************************/
  125691. /*! exports provided: glowMapGenerationPixelShader */
  125692. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125693. "use strict";
  125694. __webpack_require__.r(__webpack_exports__);
  125695. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapGenerationPixelShader", function() { return glowMapGenerationPixelShader; });
  125696. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125697. var name = 'glowMapGenerationPixelShader';
  125698. 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}";
  125699. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125700. /** @hidden */
  125701. var glowMapGenerationPixelShader = { name: name, shader: shader };
  125702. /***/ }),
  125703. /***/ "./Shaders/glowMapGeneration.vertex.ts":
  125704. /*!*********************************************!*\
  125705. !*** ./Shaders/glowMapGeneration.vertex.ts ***!
  125706. \*********************************************/
  125707. /*! exports provided: glowMapGenerationVertexShader */
  125708. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125709. "use strict";
  125710. __webpack_require__.r(__webpack_exports__);
  125711. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapGenerationVertexShader", function() { return glowMapGenerationVertexShader; });
  125712. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125713. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  125714. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  125715. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  125716. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  125717. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  125718. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  125719. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  125720. var name = 'glowMapGenerationVertexShader';
  125721. 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}";
  125722. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125723. /** @hidden */
  125724. var glowMapGenerationVertexShader = { name: name, shader: shader };
  125725. /***/ }),
  125726. /***/ "./Shaders/glowMapMerge.fragment.ts":
  125727. /*!******************************************!*\
  125728. !*** ./Shaders/glowMapMerge.fragment.ts ***!
  125729. \******************************************/
  125730. /*! exports provided: glowMapMergePixelShader */
  125731. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125732. "use strict";
  125733. __webpack_require__.r(__webpack_exports__);
  125734. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapMergePixelShader", function() { return glowMapMergePixelShader; });
  125735. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125736. var name = 'glowMapMergePixelShader';
  125737. 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}";
  125738. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125739. /** @hidden */
  125740. var glowMapMergePixelShader = { name: name, shader: shader };
  125741. /***/ }),
  125742. /***/ "./Shaders/glowMapMerge.vertex.ts":
  125743. /*!****************************************!*\
  125744. !*** ./Shaders/glowMapMerge.vertex.ts ***!
  125745. \****************************************/
  125746. /*! exports provided: glowMapMergeVertexShader */
  125747. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125748. "use strict";
  125749. __webpack_require__.r(__webpack_exports__);
  125750. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapMergeVertexShader", function() { return glowMapMergeVertexShader; });
  125751. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125752. var name = 'glowMapMergeVertexShader';
  125753. 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}";
  125754. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125755. /** @hidden */
  125756. var glowMapMergeVertexShader = { name: name, shader: shader };
  125757. /***/ }),
  125758. /***/ "./Shaders/gpuRenderParticles.fragment.ts":
  125759. /*!************************************************!*\
  125760. !*** ./Shaders/gpuRenderParticles.fragment.ts ***!
  125761. \************************************************/
  125762. /*! exports provided: gpuRenderParticlesPixelShader */
  125763. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125764. "use strict";
  125765. __webpack_require__.r(__webpack_exports__);
  125766. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuRenderParticlesPixelShader", function() { return gpuRenderParticlesPixelShader; });
  125767. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125768. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration2 */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts");
  125769. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  125770. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  125771. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  125772. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  125773. var name = 'gpuRenderParticlesPixelShader';
  125774. 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";
  125775. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125776. /** @hidden */
  125777. var gpuRenderParticlesPixelShader = { name: name, shader: shader };
  125778. /***/ }),
  125779. /***/ "./Shaders/gpuRenderParticles.vertex.ts":
  125780. /*!**********************************************!*\
  125781. !*** ./Shaders/gpuRenderParticles.vertex.ts ***!
  125782. \**********************************************/
  125783. /*! exports provided: gpuRenderParticlesVertexShader */
  125784. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125785. "use strict";
  125786. __webpack_require__.r(__webpack_exports__);
  125787. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuRenderParticlesVertexShader", function() { return gpuRenderParticlesVertexShader; });
  125788. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125789. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration2 */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts");
  125790. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  125791. var name = 'gpuRenderParticlesVertexShader';
  125792. var shader = "#version 300 es\nuniform mat4 view;\nuniform mat4 projection;\nuniform vec2 translationPivot;\nuniform vec3 worldOffset;\n\nin vec3 position;\nin float age;\nin float life;\nin vec3 size;\n#ifndef BILLBOARD\nin vec3 initialDirection;\n#endif\n#ifdef BILLBOARDSTRETCHED\nin vec3 direction;\n#endif\nin float angle;\n#ifdef ANIMATESHEET\nin float cellIndex;\n#endif\nin vec2 offset;\nin vec2 uv;\nout vec2 vUV;\nout vec4 vColor;\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4)\nuniform mat4 invView;\n#endif\n#include<clipPlaneVertexDeclaration2>\n#ifdef COLORGRADIENTS\nuniform sampler2D colorGradientSampler;\n#else\nuniform vec4 colorDead;\nin vec4 color;\n#endif\n#ifdef ANIMATESHEET\nuniform vec3 sheetInfos;\n#endif\n#ifdef BILLBOARD\nuniform vec3 eyePosition;\n#endif\nvec3 rotate(vec3 yaxis,vec3 rotatedCorner) {\nvec3 xaxis=normalize(cross(vec3(0.,1.0,0.),yaxis));\nvec3 zaxis=normalize(cross(yaxis,xaxis));\nvec3 row0=vec3(xaxis.x,xaxis.y,xaxis.z);\nvec3 row1=vec3(yaxis.x,yaxis.y,yaxis.z);\nvec3 row2=vec3(zaxis.x,zaxis.y,zaxis.z);\nmat3 rotMatrix=mat3(row0,row1,row2);\nvec3 alignedCorner=rotMatrix*rotatedCorner;\nreturn (position+worldOffset)+alignedCorner;\n}\n#ifdef BILLBOARDSTRETCHED\nvec3 rotateAlign(vec3 toCamera,vec3 rotatedCorner) {\nvec3 normalizedToCamera=normalize(toCamera);\nvec3 normalizedCrossDirToCamera=normalize(cross(normalize(direction),normalizedToCamera));\nvec3 crossProduct=normalize(cross(normalizedToCamera,normalizedCrossDirToCamera));\nvec3 row0=vec3(normalizedCrossDirToCamera.x,normalizedCrossDirToCamera.y,normalizedCrossDirToCamera.z);\nvec3 row1=vec3(crossProduct.x,crossProduct.y,crossProduct.z);\nvec3 row2=vec3(normalizedToCamera.x,normalizedToCamera.y,normalizedToCamera.z);\nmat3 rotMatrix=mat3(row0,row1,row2);\nvec3 alignedCorner=rotMatrix*rotatedCorner;\nreturn (position+worldOffset)+alignedCorner;\n}\n#endif\nvoid main() {\n#ifdef ANIMATESHEET\nfloat rowOffset=floor(cellIndex/sheetInfos.z);\nfloat columnOffset=cellIndex-rowOffset*sheetInfos.z;\nvec2 uvScale=sheetInfos.xy;\nvec2 uvOffset=vec2(uv.x ,1.0-uv.y);\nvUV=(uvOffset+vec2(columnOffset,rowOffset))*uvScale;\n#else\nvUV=uv;\n#endif\nfloat ratio=age/life;\n#ifdef COLORGRADIENTS\nvColor=texture(colorGradientSampler,vec2(ratio,0));\n#else\nvColor=color*vec4(1.0-ratio)+colorDead*vec4(ratio);\n#endif\nvec2 cornerPos=(offset-translationPivot)*size.yz*size.x+translationPivot;\n#ifdef BILLBOARD\nvec4 rotatedCorner;\nrotatedCorner.w=0.;\n#ifdef BILLBOARDY\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.y=0.;\nvec3 yaxis=(position+worldOffset)-eyePosition;\nyaxis.y=0.;\nvec3 worldPos=rotate(normalize(yaxis),rotatedCorner.xyz);\nvec4 viewPosition=(view*vec4(worldPos,1.0));\n#elif defined(BILLBOARDSTRETCHED)\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\nvec3 toCamera=(position+worldOffset)-eyePosition;\nvec3 worldPos=rotateAlign(toCamera,rotatedCorner.xyz);\nvec4 viewPosition=(view*vec4(worldPos,1.0));\n#else\n\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\n\nvec4 viewPosition=view*vec4((position+worldOffset),1.0)+rotatedCorner;\n#endif\n#else\n\nvec3 rotatedCorner;\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=0.;\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nvec3 yaxis=normalize(initialDirection);\nvec3 worldPos=rotate(yaxis,rotatedCorner);\n\nvec4 viewPosition=view*vec4(worldPos,1.0);\n#endif\ngl_Position=projection*viewPosition;\n\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4)\nvec4 worldPos=invView*viewPosition;\n#endif\n#include<clipPlaneVertex>\n}";
  125793. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125794. /** @hidden */
  125795. var gpuRenderParticlesVertexShader = { name: name, shader: shader };
  125796. /***/ }),
  125797. /***/ "./Shaders/gpuUpdateParticles.fragment.ts":
  125798. /*!************************************************!*\
  125799. !*** ./Shaders/gpuUpdateParticles.fragment.ts ***!
  125800. \************************************************/
  125801. /*! exports provided: gpuUpdateParticlesPixelShader */
  125802. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125803. "use strict";
  125804. __webpack_require__.r(__webpack_exports__);
  125805. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuUpdateParticlesPixelShader", function() { return gpuUpdateParticlesPixelShader; });
  125806. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125807. var name = 'gpuUpdateParticlesPixelShader';
  125808. var shader = "#version 300 es\nvoid main() {\ndiscard;\n}\n";
  125809. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125810. /** @hidden */
  125811. var gpuUpdateParticlesPixelShader = { name: name, shader: shader };
  125812. /***/ }),
  125813. /***/ "./Shaders/gpuUpdateParticles.vertex.ts":
  125814. /*!**********************************************!*\
  125815. !*** ./Shaders/gpuUpdateParticles.vertex.ts ***!
  125816. \**********************************************/
  125817. /*! exports provided: gpuUpdateParticlesVertexShader */
  125818. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125819. "use strict";
  125820. __webpack_require__.r(__webpack_exports__);
  125821. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuUpdateParticlesVertexShader", function() { return gpuUpdateParticlesVertexShader; });
  125822. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125823. var name = 'gpuUpdateParticlesVertexShader';
  125824. 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}";
  125825. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125826. /** @hidden */
  125827. var gpuUpdateParticlesVertexShader = { name: name, shader: shader };
  125828. /***/ }),
  125829. /***/ "./Shaders/grain.fragment.ts":
  125830. /*!***********************************!*\
  125831. !*** ./Shaders/grain.fragment.ts ***!
  125832. \***********************************/
  125833. /*! exports provided: grainPixelShader */
  125834. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125835. "use strict";
  125836. __webpack_require__.r(__webpack_exports__);
  125837. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "grainPixelShader", function() { return grainPixelShader; });
  125838. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125839. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  125840. var name = 'grainPixelShader';
  125841. 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}";
  125842. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125843. /** @hidden */
  125844. var grainPixelShader = { name: name, shader: shader };
  125845. /***/ }),
  125846. /***/ "./Shaders/highlights.fragment.ts":
  125847. /*!****************************************!*\
  125848. !*** ./Shaders/highlights.fragment.ts ***!
  125849. \****************************************/
  125850. /*! exports provided: highlightsPixelShader */
  125851. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125852. "use strict";
  125853. __webpack_require__.r(__webpack_exports__);
  125854. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "highlightsPixelShader", function() { return highlightsPixelShader; });
  125855. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125856. var name = 'highlightsPixelShader';
  125857. 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}";
  125858. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125859. /** @hidden */
  125860. var highlightsPixelShader = { name: name, shader: shader };
  125861. /***/ }),
  125862. /***/ "./Shaders/imageProcessing.fragment.ts":
  125863. /*!*********************************************!*\
  125864. !*** ./Shaders/imageProcessing.fragment.ts ***!
  125865. \*********************************************/
  125866. /*! exports provided: imageProcessingPixelShader */
  125867. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125868. "use strict";
  125869. __webpack_require__.r(__webpack_exports__);
  125870. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingPixelShader", function() { return imageProcessingPixelShader; });
  125871. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125872. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  125873. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  125874. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  125875. var name = 'imageProcessingPixelShader';
  125876. 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}";
  125877. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125878. /** @hidden */
  125879. var imageProcessingPixelShader = { name: name, shader: shader };
  125880. /***/ }),
  125881. /***/ "./Shaders/kernelBlur.fragment.ts":
  125882. /*!****************************************!*\
  125883. !*** ./Shaders/kernelBlur.fragment.ts ***!
  125884. \****************************************/
  125885. /*! exports provided: kernelBlurPixelShader */
  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__, "kernelBlurPixelShader", function() { return kernelBlurPixelShader; });
  125890. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125891. /* harmony import */ var _ShadersInclude_kernelBlurVaryingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVaryingDeclaration */ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts");
  125892. /* harmony import */ var _ShadersInclude_kernelBlurFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurFragment */ "./Shaders/ShadersInclude/kernelBlurFragment.ts");
  125893. /* harmony import */ var _ShadersInclude_kernelBlurFragment2__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurFragment2 */ "./Shaders/ShadersInclude/kernelBlurFragment2.ts");
  125894. var name = 'kernelBlurPixelShader';
  125895. 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}";
  125896. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125897. /** @hidden */
  125898. var kernelBlurPixelShader = { name: name, shader: shader };
  125899. /***/ }),
  125900. /***/ "./Shaders/kernelBlur.vertex.ts":
  125901. /*!**************************************!*\
  125902. !*** ./Shaders/kernelBlur.vertex.ts ***!
  125903. \**************************************/
  125904. /*! exports provided: kernelBlurVertexShader */
  125905. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125906. "use strict";
  125907. __webpack_require__.r(__webpack_exports__);
  125908. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVertexShader", function() { return kernelBlurVertexShader; });
  125909. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125910. /* harmony import */ var _ShadersInclude_kernelBlurVaryingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVaryingDeclaration */ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts");
  125911. /* harmony import */ var _ShadersInclude_kernelBlurVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVertex */ "./Shaders/ShadersInclude/kernelBlurVertex.ts");
  125912. var name = 'kernelBlurVertexShader';
  125913. 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}";
  125914. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125915. /** @hidden */
  125916. var kernelBlurVertexShader = { name: name, shader: shader };
  125917. /***/ }),
  125918. /***/ "./Shaders/layer.fragment.ts":
  125919. /*!***********************************!*\
  125920. !*** ./Shaders/layer.fragment.ts ***!
  125921. \***********************************/
  125922. /*! exports provided: layerPixelShader */
  125923. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125924. "use strict";
  125925. __webpack_require__.r(__webpack_exports__);
  125926. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "layerPixelShader", function() { return layerPixelShader; });
  125927. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125928. var name = 'layerPixelShader';
  125929. 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}";
  125930. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125931. /** @hidden */
  125932. var layerPixelShader = { name: name, shader: shader };
  125933. /***/ }),
  125934. /***/ "./Shaders/layer.vertex.ts":
  125935. /*!*********************************!*\
  125936. !*** ./Shaders/layer.vertex.ts ***!
  125937. \*********************************/
  125938. /*! exports provided: layerVertexShader */
  125939. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125940. "use strict";
  125941. __webpack_require__.r(__webpack_exports__);
  125942. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "layerVertexShader", function() { return layerVertexShader; });
  125943. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125944. var name = 'layerVertexShader';
  125945. 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}";
  125946. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125947. /** @hidden */
  125948. var layerVertexShader = { name: name, shader: shader };
  125949. /***/ }),
  125950. /***/ "./Shaders/lensFlare.fragment.ts":
  125951. /*!***************************************!*\
  125952. !*** ./Shaders/lensFlare.fragment.ts ***!
  125953. \***************************************/
  125954. /*! exports provided: lensFlarePixelShader */
  125955. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125956. "use strict";
  125957. __webpack_require__.r(__webpack_exports__);
  125958. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensFlarePixelShader", function() { return lensFlarePixelShader; });
  125959. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125960. var name = 'lensFlarePixelShader';
  125961. 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}";
  125962. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125963. /** @hidden */
  125964. var lensFlarePixelShader = { name: name, shader: shader };
  125965. /***/ }),
  125966. /***/ "./Shaders/lensFlare.vertex.ts":
  125967. /*!*************************************!*\
  125968. !*** ./Shaders/lensFlare.vertex.ts ***!
  125969. \*************************************/
  125970. /*! exports provided: lensFlareVertexShader */
  125971. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125972. "use strict";
  125973. __webpack_require__.r(__webpack_exports__);
  125974. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensFlareVertexShader", function() { return lensFlareVertexShader; });
  125975. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125976. var name = 'lensFlareVertexShader';
  125977. 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}";
  125978. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125979. /** @hidden */
  125980. var lensFlareVertexShader = { name: name, shader: shader };
  125981. /***/ }),
  125982. /***/ "./Shaders/lensHighlights.fragment.ts":
  125983. /*!********************************************!*\
  125984. !*** ./Shaders/lensHighlights.fragment.ts ***!
  125985. \********************************************/
  125986. /*! exports provided: lensHighlightsPixelShader */
  125987. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125988. "use strict";
  125989. __webpack_require__.r(__webpack_exports__);
  125990. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensHighlightsPixelShader", function() { return lensHighlightsPixelShader; });
  125991. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125992. var name = 'lensHighlightsPixelShader';
  125993. 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}";
  125994. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125995. /** @hidden */
  125996. var lensHighlightsPixelShader = { name: name, shader: shader };
  125997. /***/ }),
  125998. /***/ "./Shaders/line.fragment.ts":
  125999. /*!**********************************!*\
  126000. !*** ./Shaders/line.fragment.ts ***!
  126001. \**********************************/
  126002. /*! exports provided: linePixelShader */
  126003. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126004. "use strict";
  126005. __webpack_require__.r(__webpack_exports__);
  126006. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "linePixelShader", function() { return linePixelShader; });
  126007. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126008. var name = 'linePixelShader';
  126009. var shader = "uniform vec4 color;\nvoid main(void) {\ngl_FragColor=color;\n}";
  126010. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126011. /** @hidden */
  126012. var linePixelShader = { name: name, shader: shader };
  126013. /***/ }),
  126014. /***/ "./Shaders/line.vertex.ts":
  126015. /*!********************************!*\
  126016. !*** ./Shaders/line.vertex.ts ***!
  126017. \********************************/
  126018. /*! exports provided: lineVertexShader */
  126019. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126020. "use strict";
  126021. __webpack_require__.r(__webpack_exports__);
  126022. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lineVertexShader", function() { return lineVertexShader; });
  126023. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126024. var name = 'lineVertexShader';
  126025. 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}";
  126026. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126027. /** @hidden */
  126028. var lineVertexShader = { name: name, shader: shader };
  126029. /***/ }),
  126030. /***/ "./Shaders/motionBlur.fragment.ts":
  126031. /*!****************************************!*\
  126032. !*** ./Shaders/motionBlur.fragment.ts ***!
  126033. \****************************************/
  126034. /*! exports provided: motionBlurPixelShader */
  126035. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126036. "use strict";
  126037. __webpack_require__.r(__webpack_exports__);
  126038. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "motionBlurPixelShader", function() { return motionBlurPixelShader; });
  126039. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126040. var name = 'motionBlurPixelShader';
  126041. 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";
  126042. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126043. /** @hidden */
  126044. var motionBlurPixelShader = { name: name, shader: shader };
  126045. /***/ }),
  126046. /***/ "./Shaders/noise.fragment.ts":
  126047. /*!***********************************!*\
  126048. !*** ./Shaders/noise.fragment.ts ***!
  126049. \***********************************/
  126050. /*! exports provided: noisePixelShader */
  126051. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126052. "use strict";
  126053. __webpack_require__.r(__webpack_exports__);
  126054. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "noisePixelShader", function() { return noisePixelShader; });
  126055. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126056. var name = 'noisePixelShader';
  126057. 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";
  126058. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126059. /** @hidden */
  126060. var noisePixelShader = { name: name, shader: shader };
  126061. /***/ }),
  126062. /***/ "./Shaders/outline.fragment.ts":
  126063. /*!*************************************!*\
  126064. !*** ./Shaders/outline.fragment.ts ***!
  126065. \*************************************/
  126066. /*! exports provided: outlinePixelShader */
  126067. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126068. "use strict";
  126069. __webpack_require__.r(__webpack_exports__);
  126070. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "outlinePixelShader", function() { return outlinePixelShader; });
  126071. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126072. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  126073. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  126074. var name = 'outlinePixelShader';
  126075. 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}";
  126076. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126077. /** @hidden */
  126078. var outlinePixelShader = { name: name, shader: shader };
  126079. /***/ }),
  126080. /***/ "./Shaders/outline.vertex.ts":
  126081. /*!***********************************!*\
  126082. !*** ./Shaders/outline.vertex.ts ***!
  126083. \***********************************/
  126084. /*! exports provided: outlineVertexShader */
  126085. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126086. "use strict";
  126087. __webpack_require__.r(__webpack_exports__);
  126088. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "outlineVertexShader", function() { return outlineVertexShader; });
  126089. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126090. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  126091. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  126092. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  126093. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  126094. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  126095. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  126096. var name = 'outlineVertexShader';
  126097. 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";
  126098. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126099. /** @hidden */
  126100. var outlineVertexShader = { name: name, shader: shader };
  126101. /***/ }),
  126102. /***/ "./Shaders/particles.fragment.ts":
  126103. /*!***************************************!*\
  126104. !*** ./Shaders/particles.fragment.ts ***!
  126105. \***************************************/
  126106. /*! exports provided: particlesPixelShader */
  126107. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126108. "use strict";
  126109. __webpack_require__.r(__webpack_exports__);
  126110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "particlesPixelShader", function() { return particlesPixelShader; });
  126111. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126112. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  126113. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  126114. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  126115. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  126116. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  126117. var name = 'particlesPixelShader';
  126118. 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}";
  126119. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126120. /** @hidden */
  126121. var particlesPixelShader = { name: name, shader: shader };
  126122. /***/ }),
  126123. /***/ "./Shaders/particles.vertex.ts":
  126124. /*!*************************************!*\
  126125. !*** ./Shaders/particles.vertex.ts ***!
  126126. \*************************************/
  126127. /*! exports provided: particlesVertexShader */
  126128. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126129. "use strict";
  126130. __webpack_require__.r(__webpack_exports__);
  126131. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "particlesVertexShader", function() { return particlesVertexShader; });
  126132. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126133. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  126134. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  126135. var name = 'particlesVertexShader';
  126136. 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}";
  126137. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126138. /** @hidden */
  126139. var particlesVertexShader = { name: name, shader: shader };
  126140. /***/ }),
  126141. /***/ "./Shaders/pass.fragment.ts":
  126142. /*!**********************************!*\
  126143. !*** ./Shaders/pass.fragment.ts ***!
  126144. \**********************************/
  126145. /*! exports provided: passPixelShader */
  126146. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126147. "use strict";
  126148. __webpack_require__.r(__webpack_exports__);
  126149. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "passPixelShader", function() { return passPixelShader; });
  126150. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126151. var name = 'passPixelShader';
  126152. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(textureSampler,vUV);\n}";
  126153. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126154. /** @hidden */
  126155. var passPixelShader = { name: name, shader: shader };
  126156. /***/ }),
  126157. /***/ "./Shaders/passCube.fragment.ts":
  126158. /*!**************************************!*\
  126159. !*** ./Shaders/passCube.fragment.ts ***!
  126160. \**************************************/
  126161. /*! exports provided: passCubePixelShader */
  126162. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126163. "use strict";
  126164. __webpack_require__.r(__webpack_exports__);
  126165. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "passCubePixelShader", function() { return passCubePixelShader; });
  126166. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126167. var name = 'passCubePixelShader';
  126168. 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}";
  126169. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126170. /** @hidden */
  126171. var passCubePixelShader = { name: name, shader: shader };
  126172. /***/ }),
  126173. /***/ "./Shaders/pbr.fragment.ts":
  126174. /*!*********************************!*\
  126175. !*** ./Shaders/pbr.fragment.ts ***!
  126176. \*********************************/
  126177. /*! exports provided: pbrPixelShader */
  126178. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126179. "use strict";
  126180. __webpack_require__.r(__webpack_exports__);
  126181. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrPixelShader", function() { return pbrPixelShader; });
  126182. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126183. /* harmony import */ var _ShadersInclude_pbrFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/pbrFragmentDeclaration */ "./Shaders/ShadersInclude/pbrFragmentDeclaration.ts");
  126184. /* harmony import */ var _ShadersInclude_pbrUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/pbrUboDeclaration */ "./Shaders/ShadersInclude/pbrUboDeclaration.ts");
  126185. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  126186. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  126187. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  126188. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  126189. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  126190. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  126191. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  126192. /* harmony import */ var _ShadersInclude_pbrFunctions__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/pbrFunctions */ "./Shaders/ShadersInclude/pbrFunctions.ts");
  126193. /* harmony import */ var _ShadersInclude_harmonicsFunctions__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/harmonicsFunctions */ "./Shaders/ShadersInclude/harmonicsFunctions.ts");
  126194. /* harmony import */ var _ShadersInclude_pbrPreLightingFunctions__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/pbrPreLightingFunctions */ "./Shaders/ShadersInclude/pbrPreLightingFunctions.ts");
  126195. /* harmony import */ var _ShadersInclude_pbrFalloffLightingFunctions__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/pbrFalloffLightingFunctions */ "./Shaders/ShadersInclude/pbrFalloffLightingFunctions.ts");
  126196. /* harmony import */ var _ShadersInclude_pbrLightingFunctions__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/pbrLightingFunctions */ "./Shaders/ShadersInclude/pbrLightingFunctions.ts");
  126197. /* harmony import */ var _ShadersInclude_bumpFragmentFunctions__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/bumpFragmentFunctions */ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts");
  126198. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  126199. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  126200. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  126201. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  126202. /* harmony import */ var _ShadersInclude_bumpFragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/bumpFragment */ "./Shaders/ShadersInclude/bumpFragment.ts");
  126203. /* harmony import */ var _ShadersInclude_depthPrePass__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/depthPrePass */ "./Shaders/ShadersInclude/depthPrePass.ts");
  126204. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  126205. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  126206. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  126207. /* harmony import */ var _ShadersInclude_pbrDebug__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./ShadersInclude/pbrDebug */ "./Shaders/ShadersInclude/pbrDebug.ts");
  126208. var name = 'pbrPixelShader';
  126209. var shader = "#if defined(BUMP) || !defined(NORMAL) || defined(FORCENORMALFORWARD) || defined(SPECULARAA) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#ifdef LODBASEDMICROSFURACE\n#extension GL_EXT_shader_texture_lod : enable\n#endif\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\nprecision highp float;\n#include<__decl__pbrFragment>\nuniform vec4 vEyePosition;\nuniform vec3 vAmbientColor;\nuniform vec4 vCameraInfos;\n\nvarying vec3 vPositionW;\n#if DEBUGMODE>0\nuniform vec2 vDebugMode;\nvarying vec4 vClipSpacePosition;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvarying vec3 vEnvironmentIrradiance;\n#endif\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n\n#ifdef ALBEDO\n#if ALBEDODIRECTUV == 1\n#define vAlbedoUV vMainUV1\n#elif ALBEDODIRECTUV == 2\n#define vAlbedoUV vMainUV2\n#else\nvarying vec2 vAlbedoUV;\n#endif\nuniform sampler2D albedoSampler;\n#endif\n#ifdef AMBIENT\n#if AMBIENTDIRECTUV == 1\n#define vAmbientUV vMainUV1\n#elif AMBIENTDIRECTUV == 2\n#define vAmbientUV vMainUV2\n#else\nvarying vec2 vAmbientUV;\n#endif\nuniform sampler2D ambientSampler;\n#endif\n#ifdef OPACITY\n#if OPACITYDIRECTUV == 1\n#define vOpacityUV vMainUV1\n#elif OPACITYDIRECTUV == 2\n#define vOpacityUV vMainUV2\n#else\nvarying vec2 vOpacityUV;\n#endif\nuniform sampler2D opacitySampler;\n#endif\n#ifdef EMISSIVE\n#if EMISSIVEDIRECTUV == 1\n#define vEmissiveUV vMainUV1\n#elif EMISSIVEDIRECTUV == 2\n#define vEmissiveUV vMainUV2\n#else\nvarying vec2 vEmissiveUV;\n#endif\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\n#if LIGHTMAPDIRECTUV == 1\n#define vLightmapUV vMainUV1\n#elif LIGHTMAPDIRECTUV == 2\n#define vLightmapUV vMainUV2\n#else\nvarying vec2 vLightmapUV;\n#endif\nuniform sampler2D lightmapSampler;\n#endif\n#ifdef REFLECTIVITY\n#if REFLECTIVITYDIRECTUV == 1\n#define vReflectivityUV vMainUV1\n#elif REFLECTIVITYDIRECTUV == 2\n#define vReflectivityUV vMainUV2\n#else\nvarying vec2 vReflectivityUV;\n#endif\nuniform sampler2D reflectivitySampler;\n#endif\n#ifdef MICROSURFACEMAP\n#if MICROSURFACEMAPDIRECTUV == 1\n#define vMicroSurfaceSamplerUV vMainUV1\n#elif MICROSURFACEMAPDIRECTUV == 2\n#define vMicroSurfaceSamplerUV vMainUV2\n#else\nvarying vec2 vMicroSurfaceSamplerUV;\n#endif\nuniform sampler2D microSurfaceSampler;\n#endif\n#ifdef CLEARCOAT\n#ifdef CLEARCOAT_TEXTURE\n#if CLEARCOAT_TEXTUREDIRECTUV == 1\n#define vClearCoatUV vMainUV1\n#elif CLEARCOAT_TEXTUREDIRECTUV == 2\n#define vClearCoatUV vMainUV2\n#else\nvarying vec2 vClearCoatUV;\n#endif\nuniform sampler2D clearCoatSampler;\n#endif\n#ifdef CLEARCOAT_BUMP\n#if CLEARCOAT_BUMPDIRECTUV == 1\n#define vClearCoatBumpUV vMainUV1\n#elif CLEARCOAT_BUMPDIRECTUV == 2\n#define vClearCoatBumpUV vMainUV2\n#else\nvarying vec2 vClearCoatBumpUV;\n#endif\nuniform sampler2D clearCoatBumpSampler;\n#endif\n#ifdef CLEARCOAT_TINT_TEXTURE\n#if CLEARCOAT_TINT_TEXTUREDIRECTUV == 1\n#define vClearCoatTintUV vMainUV1\n#elif CLEARCOAT_TINT_TEXTUREDIRECTUV == 2\n#define vClearCoatTintUV vMainUV2\n#else\nvarying vec2 vClearCoatTintUV;\n#endif\nuniform sampler2D clearCoatTintSampler;\n#endif\n#endif\n\n#ifdef REFRACTION\n#ifdef REFRACTIONMAP_3D\n#define sampleRefraction(s,c) textureCube(s,c)\nuniform samplerCube refractionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleRefractionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube refractionSamplerLow;\nuniform samplerCube refractionSamplerHigh;\n#endif\n#else\n#define sampleRefraction(s,c) texture2D(s,c)\nuniform sampler2D refractionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleRefractionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube refractionSamplerLow;\nuniform samplerCube refractionSamplerHigh;\n#endif\n#endif\n#endif\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\n#define sampleReflection(s,c) textureCube(s,c)\nuniform samplerCube reflectionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#else\n#define sampleReflection(s,c) texture2D(s,c)\nuniform sampler2D reflectionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include<reflectionFunction>\n#endif\n#ifdef ENVIRONMENTBRDF\nuniform sampler2D environmentBrdfSampler;\n#endif\n\n#ifndef FROMLINEARSPACE\n#define FROMLINEARSPACE;\n#endif\n#include<imageProcessingDeclaration>\n#include<helperFunctions>\n#include<imageProcessingFunctions>\n\n#include<shadowsFragmentFunctions>\n#include<pbrFunctions>\n#include<harmonicsFunctions>\n#include<pbrPreLightingFunctions>\n#include<pbrFalloffLightingFunctions>\n#include<pbrLightingFunctions>\n#include<bumpFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n\n#include<fogFragmentDeclaration>\nvoid main(void) {\n#include<clipPlaneFragment>\n\n\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;\n#endif\n#ifdef CLEARCOAT\n\nvec3 clearCoatNormalW=normalW;\n#endif\n#include<bumpFragment>\n#if defined(FORCENORMALFORWARD) && defined(NORMAL)\nvec3 faceNormal=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;\n#if defined(TWOSIDEDLIGHTING)\nfaceNormal=gl_FrontFacing ? faceNormal : -faceNormal;\n#endif\nnormalW*=sign(dot(normalW,faceNormal));\n#endif\n#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)\nnormalW=gl_FrontFacing ? normalW : -normalW;\n#endif\n\n\nvec3 surfaceAlbedo=vAlbedoColor.rgb;\n\nfloat alpha=vAlbedoColor.a;\n#ifdef ALBEDO\nvec4 albedoTexture=texture2D(albedoSampler,vAlbedoUV+uvOffset);\n#if defined(ALPHAFROMALBEDO) || defined(ALPHATEST)\nalpha*=albedoTexture.a;\n#endif\nsurfaceAlbedo*=toLinearSpace(albedoTexture.rgb);\nsurfaceAlbedo*=vAlbedoInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nsurfaceAlbedo*=vColor.rgb;\n#endif\n\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\n#ifdef OPACITYRGB\nalpha=getLuminance(opacityMap.rgb);\n#else\nalpha*=opacityMap.a;\n#endif\nalpha*=vOpacityInfos.y;\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#if !defined(LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL)\n#ifdef ALPHATEST\nif (alpha<ALPHATESTVALUE)\ndiscard;\n#ifndef ALPHABLEND\n\nalpha=1.0;\n#endif\n#endif\n#endif\n#include<depthPrePass>\n\nvec3 ambientOcclusionColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nvec3 ambientOcclusionColorMap=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\n#ifdef AMBIENTINGRAYSCALE\nambientOcclusionColorMap=vec3(ambientOcclusionColorMap.r,ambientOcclusionColorMap.r,ambientOcclusionColorMap.r);\n#endif\nambientOcclusionColor=mix(ambientOcclusionColor,ambientOcclusionColorMap,vAmbientInfos.z);\n#endif\n#ifdef UNLIT\nvec3 diffuseBase=vec3(1.,1.,1.);\n#else\n\nfloat microSurface=vReflectivityColor.a;\nvec3 surfaceReflectivityColor=vReflectivityColor.rgb;\n#ifdef METALLICWORKFLOW\nvec2 metallicRoughness=surfaceReflectivityColor.rg;\n#ifdef REFLECTIVITY\nvec4 surfaceMetallicColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\n#ifdef AOSTOREINMETALMAPRED\nvec3 aoStoreInMetalMap=vec3(surfaceMetallicColorMap.r,surfaceMetallicColorMap.r,surfaceMetallicColorMap.r);\nambientOcclusionColor=mix(ambientOcclusionColor,aoStoreInMetalMap,vReflectivityInfos.z);\n#endif\n#ifdef METALLNESSSTOREINMETALMAPBLUE\nmetallicRoughness.r*=surfaceMetallicColorMap.b;\n#else\nmetallicRoughness.r*=surfaceMetallicColorMap.r;\n#endif\n#ifdef ROUGHNESSSTOREINMETALMAPALPHA\nmetallicRoughness.g*=surfaceMetallicColorMap.a;\n#else\n#ifdef ROUGHNESSSTOREINMETALMAPGREEN\nmetallicRoughness.g*=surfaceMetallicColorMap.g;\n#endif\n#endif\n#endif\n#ifdef MICROSURFACEMAP\nvec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;\nmetallicRoughness.g*=microSurfaceTexel.r;\n#endif\n\nmicroSurface=1.0-metallicRoughness.g;\n\nvec3 baseColor=surfaceAlbedo;\n#ifdef REFLECTANCE\n\n\n\n\n\nsurfaceAlbedo=baseColor.rgb*(1.0-metallicRoughness.r);\n\nsurfaceReflectivityColor=mix(0.16*reflectance*reflectance,baseColor,metallicRoughness.r);\n#else\n\n\n\nconst vec3 DefaultSpecularReflectanceDielectric=vec3(0.04,0.04,0.04);\n\nsurfaceAlbedo=mix(baseColor.rgb*(1.0-DefaultSpecularReflectanceDielectric.r),vec3(0.,0.,0.),metallicRoughness.r);\n\nsurfaceReflectivityColor=mix(DefaultSpecularReflectanceDielectric,baseColor,metallicRoughness.r);\n#endif\n#else\n#ifdef REFLECTIVITY\nvec4 surfaceReflectivityColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\nsurfaceReflectivityColor*=toLinearSpace(surfaceReflectivityColorMap.rgb);\nsurfaceReflectivityColor*=vReflectivityInfos.y;\n#ifdef MICROSURFACEFROMREFLECTIVITYMAP\nmicroSurface*=surfaceReflectivityColorMap.a;\nmicroSurface*=vReflectivityInfos.z;\n#else\n#ifdef MICROSURFACEAUTOMATIC\nmicroSurface*=computeDefaultMicroSurface(microSurface,surfaceReflectivityColor);\n#endif\n#ifdef MICROSURFACEMAP\nvec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;\nmicroSurface*=microSurfaceTexel.r;\n#endif\n#endif\n#endif\n#endif\n\nmicroSurface=clamp(microSurface,0.,1.);\n\nfloat roughness=1.-microSurface;\n\n#ifdef ALPHAFRESNEL\n#if defined(ALPHATEST) || defined(ALPHABLEND)\n\n\n\nfloat opacityPerceptual=alpha;\n#ifdef LINEARALPHAFRESNEL\nfloat opacity0=opacityPerceptual;\n#else\nfloat opacity0=opacityPerceptual*opacityPerceptual;\n#endif\nfloat opacity90=fresnelGrazingReflectance(opacity0);\nvec3 normalForward=faceforward(normalW,-viewDirectionW,normalW);\n\nalpha=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\nfloat NdotVUnclamped=dot(normalW,viewDirectionW);\nfloat NdotV=clamp(NdotVUnclamped,0.,1.)+0.00001;\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\nvec2 AARoughnessFactors=getAARoughnessFactors(normalW.xyz);\n#ifdef SPECULARAA\n\nalphaG+=AARoughnessFactors.y;\n#endif\n#ifdef ANISOTROPIC\nvec3 anisotropicNormal=getAnisotropicBentNormals(TBN,viewDirectionW,normalW,anisotropy);\n#endif\n\n#ifdef REFRACTION\nvec4 environmentRefraction=vec4(0.,0.,0.,0.);\n#ifdef ANISOTROPIC\nvec3 refractionVector=refract(-viewDirectionW,anisotropicNormal,vRefractionInfos.y);\n#else\nvec3 refractionVector=refract(-viewDirectionW,normalW,vRefractionInfos.y);\n#endif\n#ifdef REFRACTIONMAP_OPPOSITEZ\nrefractionVector.z*=-1.0;\n#endif\n\n#ifdef REFRACTIONMAP_3D\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\nvec3 refractionCoords=refractionVector;\nrefractionCoords=vec3(refractionMatrix*vec4(refractionCoords,0));\n#else\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));\nvec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;\nrefractionCoords.y=1.0-refractionCoords.y;\n#endif\n#ifdef LODINREFRACTIONALPHA\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);\n#else\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG,1.0);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nrefractionLOD=refractionLOD*vRefractionMicrosurfaceInfos.y+vRefractionMicrosurfaceInfos.z;\n#ifdef LODINREFRACTIONALPHA\n\n\n\n\n\n\n\n\n\nfloat automaticRefractionLOD=UNPACK_LOD(sampleRefraction(refractionSampler,refractionCoords).a);\nfloat requestedRefractionLOD=max(automaticRefractionLOD,refractionLOD);\n#else\nfloat requestedRefractionLOD=refractionLOD;\n#endif\nenvironmentRefraction=sampleRefractionLod(refractionSampler,refractionCoords,requestedRefractionLOD);\n#else\nfloat lodRefractionNormalized=clamp(refractionLOD/log2(vRefractionMicrosurfaceInfos.x),0.,1.);\nfloat lodRefractionNormalizedDoubled=lodRefractionNormalized*2.0;\nvec4 environmentRefractionMid=sampleRefraction(refractionSampler,refractionCoords);\nif(lodRefractionNormalizedDoubled<1.0){\nenvironmentRefraction=mix(\nsampleRefraction(refractionSamplerHigh,refractionCoords),\nenvironmentRefractionMid,\nlodRefractionNormalizedDoubled\n);\n}else{\nenvironmentRefraction=mix(\nenvironmentRefractionMid,\nsampleRefraction(refractionSamplerLow,refractionCoords),\nlodRefractionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef RGBDREFRACTION\nenvironmentRefraction.rgb=fromRGBD(environmentRefraction);\n#endif\n#ifdef GAMMAREFRACTION\nenvironmentRefraction.rgb=toLinearSpace(environmentRefraction.rgb);\n#endif\n\nenvironmentRefraction.rgb*=vRefractionInfos.x;\n#endif\n\n#ifdef REFLECTION\nvec4 environmentRadiance=vec4(0.,0.,0.,0.);\nvec3 environmentIrradiance=vec3(0.,0.,0.);\n#ifdef ANISOTROPIC\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),anisotropicNormal);\n#else\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#endif\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\n\n#ifdef REFLECTIONMAP_3D\nvec3 reflectionCoords=reflectionVector;\n#else\nvec2 reflectionCoords=reflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nreflectionCoords/=reflectionVector.z;\n#endif\nreflectionCoords.y=1.0-reflectionCoords.y;\n#endif\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);\n#else\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,1.);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nreflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\n#ifdef LODINREFLECTIONALPHA\n\n\n\n\n\n\n\n\n\nfloat automaticReflectionLOD=UNPACK_LOD(sampleReflection(reflectionSampler,reflectionCoords).a);\nfloat requestedReflectionLOD=max(automaticReflectionLOD,reflectionLOD);\n#else\nfloat requestedReflectionLOD=reflectionLOD;\n#endif\nenvironmentRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,requestedReflectionLOD);\n#else\nfloat lodReflectionNormalized=clamp(reflectionLOD/log2(vReflectionMicrosurfaceInfos.x),0.,1.);\nfloat lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;\nvec4 environmentSpecularMid=sampleReflection(reflectionSampler,reflectionCoords);\nif(lodReflectionNormalizedDoubled<1.0){\nenvironmentRadiance=mix(\nsampleReflection(reflectionSamplerHigh,reflectionCoords),\nenvironmentSpecularMid,\nlodReflectionNormalizedDoubled\n);\n}else{\nenvironmentRadiance=mix(\nenvironmentSpecularMid,\nsampleReflection(reflectionSamplerLow,reflectionCoords),\nlodReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef RGBDREFLECTION\nenvironmentRadiance.rgb=fromRGBD(environmentRadiance);\n#endif\n#ifdef GAMMAREFLECTION\nenvironmentRadiance.rgb=toLinearSpace(environmentRadiance.rgb);\n#endif\n\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#if defined(NORMAL) && defined(USESPHERICALINVERTEX)\nenvironmentIrradiance=vEnvironmentIrradiance;\n#else\n#ifdef ANISOTROPIC\nvec3 irradianceVector=vec3(reflectionMatrix*vec4(anisotropicNormal,0)).xyz;\n#else\nvec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;\n#endif\n#ifdef REFLECTIONMAP_OPPOSITEZ\nirradianceVector.z*=-1.0;\n#endif\nenvironmentIrradiance=environmentIrradianceJones(irradianceVector);\n#endif\n#endif\n\nenvironmentRadiance.rgb*=vReflectionInfos.x;\nenvironmentRadiance.rgb*=vReflectionColor.rgb;\nenvironmentIrradiance*=vReflectionColor.rgb;\n#endif\n\nfloat reflectance=max(max(surfaceReflectivityColor.r,surfaceReflectivityColor.g),surfaceReflectivityColor.b);\nfloat reflectance90=fresnelGrazingReflectance(reflectance);\nvec3 specularEnvironmentR0=surfaceReflectivityColor.rgb;\nvec3 specularEnvironmentR90=vec3(1.0,1.0,1.0)*reflectance90;\n\n#ifdef CLEARCOAT\n\nfloat clearCoatIntensity=vClearCoatParams.x;\nfloat clearCoatRoughness=vClearCoatParams.y;\n#ifdef CLEARCOAT_TEXTURE\nvec2 clearCoatMapData=texture2D(clearCoatSampler,vClearCoatUV+uvOffset).rg*vClearCoatInfos.y;\nclearCoatIntensity*=clearCoatMapData.x;\nclearCoatRoughness*=clearCoatMapData.y;\n#endif\n#ifdef CLEARCOAT_TINT\nvec3 clearCoatColor=vClearCoatTintParams.rgb;\nfloat clearCoatThickness=vClearCoatTintParams.a;\n#ifdef CLEARCOAT_TINT_TEXTURE\nvec4 clearCoatTintMapData=texture2D(clearCoatTintSampler,vClearCoatTintUV+uvOffset);\nclearCoatColor*=toLinearSpace(clearCoatTintMapData.rgb);\nclearCoatThickness*=clearCoatTintMapData.a;\n#endif\nclearCoatColor=computeColorAtDistanceInMedia(clearCoatColor,clearCoatColorAtDistance);\n#endif\n\n\n\n\nvec3 specularEnvironmentR0Updated=getR0RemappedForClearCoat(specularEnvironmentR0);\nspecularEnvironmentR0=mix(specularEnvironmentR0,specularEnvironmentR0Updated,clearCoatIntensity);\n#ifdef CLEARCOAT_BUMP\n#ifdef NORMALXYSCALE\nfloat clearCoatNormalScale=1.0;\n#else\nfloat clearCoatNormalScale=vClearCoatBumpInfos.y;\n#endif\n#if defined(TANGENT) && defined(NORMAL)\nmat3 TBNClearCoat=vTBN;\n#else\nmat3 TBNClearCoat=cotangent_frame(clearCoatNormalW*clearCoatNormalScale,vPositionW,vClearCoatBumpUV,vClearCoatTangentSpaceParams);\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\nclearCoatNormalW=normalize(texture2D(clearCoatBumpSampler,vClearCoatBumpUV+uvOffset).xyz*2.0-1.0);\nclearCoatNormalW=normalize(mat3(normalMatrix)*clearCoatNormalW);\n#else\nclearCoatNormalW=perturbNormal(TBN,vClearCoatBumpUV+uvOffset,clearCoatBumpSampler,vClearCoatBumpInfos.y);\n#endif\n#endif\n#if defined(FORCENORMALFORWARD) && defined(NORMAL)\nclearCoatNormalW*=sign(dot(clearCoatNormalW,faceNormal));\n#endif\n#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)\nclearCoatNormalW=gl_FrontFacing ? clearCoatNormalW : -clearCoatNormalW;\n#endif\n#ifdef SPECULARAA\n\nvec2 clearCoatAARoughnessFactors=getAARoughnessFactors(clearCoatNormalW.xyz);\n#endif\n\nfloat clearCoatNdotVUnclamped=dot(clearCoatNormalW,viewDirectionW);\nfloat clearCoatNdotV=clamp(clearCoatNdotVUnclamped,0.,1.)+0.00001;\n\n#if defined(REFLECTION)\nfloat clearCoatAlphaG=convertRoughnessToAverageSlope(clearCoatRoughness);\n#ifdef SPECULARAA\n\nclearCoatAlphaG+=clearCoatAARoughnessFactors.y;\n#endif\nvec4 environmentClearCoatRadiance=vec4(0.,0.,0.,0.);\nvec3 clearCoatReflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),clearCoatNormalW);\n#ifdef REFLECTIONMAP_OPPOSITEZ\nclearCoatReflectionVector.z*=-1.0;\n#endif\n\n#ifdef REFLECTIONMAP_3D\nvec3 clearCoatReflectionCoords=clearCoatReflectionVector;\n#else\nvec2 clearCoatReflectionCoords=clearCoatReflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nclearCoatReflectionCoords/=clearCoatReflectionVector.z;\n#endif\nclearCoatReflectionCoords.y=1.0-clearCoatReflectionCoords.y;\n#endif\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nfloat clearCoatReflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,clearCoatAlphaG,clearCoatNdotVUnclamped);\n#else\nfloat clearCoatReflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,clearCoatAlphaG,1.);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nclearCoatReflectionLOD=clearCoatReflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\nfloat requestedClearCoatReflectionLOD=clearCoatReflectionLOD;\nenvironmentClearCoatRadiance=sampleReflectionLod(reflectionSampler,clearCoatReflectionCoords,requestedClearCoatReflectionLOD);\n#else\nfloat lodClearCoatReflectionNormalized=clamp(clearCoatReflectionLOD/log2(vReflectionMicrosurfaceInfos.x),0.,1.);\nfloat lodClearCoatReflectionNormalizedDoubled=lodClearCoatReflectionNormalized*2.0;\nvec4 environmentClearCoatMid=sampleReflection(reflectionSampler,reflectionCoords);\nif(lodClearCoatReflectionNormalizedDoubled<1.0){\nenvironmentClearCoatRadiance=mix(\nsampleReflection(reflectionSamplerHigh,clearCoatReflectionCoords),\nenvironmentClearCoatMid,\nlodClearCoatReflectionNormalizedDoubled\n);\n}else{\nenvironmentClearCoatRadiance=mix(\nenvironmentClearCoatMid,\nsampleReflection(reflectionSamplerLow,clearCoatReflectionCoords),\nlodClearCoatReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef RGBDREFLECTION\nenvironmentClearCoatRadiance.rgb=fromRGBD(environmentClearCoatRadiance);\n#endif\n#ifdef GAMMAREFLECTION\nenvironmentClearCoatRadiance.rgb=toLinearSpace(environmentClearCoatRadiance.rgb);\n#endif\n#ifdef CLEARCOAT_TINT\n\nvec3 clearCoatVRefract=-refract(vPositionW,clearCoatNormalW,vClearCoatRefractionParams.y);\nfloat clearCoatNdotVRefract=clamp(dot(clearCoatNormalW,clearCoatVRefract),0.00000000001,1.0);\nvec3 absorption=vec3(0.);\n#endif\n\nenvironmentClearCoatRadiance.rgb*=vReflectionInfos.x;\nenvironmentClearCoatRadiance.rgb*=vReflectionColor.rgb;\n#endif\n#endif\n#if defined(ENVIRONMENTBRDF)\n\nvec2 environmentBrdf=getBRDFLookup(NdotV,roughness,environmentBrdfSampler);\n#ifdef MS_BRDF_ENERGY_CONSERVATION\nvec3 energyConservationFactor=getEnergyConservationFactor(specularEnvironmentR0,environmentBrdf);\n#endif\n#endif\n\n\nvec3 diffuseBase=vec3(0.,0.,0.);\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#ifdef CLEARCOAT\nvec3 clearCoatBase=vec3(0.,0.,0.);\n#endif\n#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb;\n#ifdef GAMMALIGHTMAP\nlightmapColor=toLinearSpace(lightmapColor);\n#endif\nlightmapColor*=vLightmapInfos.y;\n#endif\n\npreLightingInfo preInfo;\nlightingInfo info;\nfloat shadow=1.;\n#include<lightFragment>[0..maxSimultaneousLights]\n\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\nvec3 specularEnvironmentReflectance=getReflectanceFromBRDFLookup(specularEnvironmentR0,environmentBrdf);\n#ifdef RADIANCEOCCLUSION\n#ifdef AMBIENTINGRAYSCALE\nfloat ambientMonochrome=ambientOcclusionColor.r;\n#else\nfloat ambientMonochrome=getLuminance(ambientOcclusionColor);\n#endif\nfloat seo=environmentRadianceOcclusion(ambientMonochrome,NdotVUnclamped);\nspecularEnvironmentReflectance*=seo;\n#endif\n#ifdef HORIZONOCCLUSION\n#ifdef BUMP\n#ifdef REFLECTIONMAP_3D\nfloat eho=environmentHorizonOcclusion(-viewDirectionW,normalW);\nspecularEnvironmentReflectance*=eho;\n#endif\n#endif\n#endif\n#else\n\nvec3 specularEnvironmentReflectance=fresnelSchlickEnvironmentGGX(NdotV,specularEnvironmentR0,specularEnvironmentR90,sqrt(microSurface));\n#endif\n\n#ifdef CLEARCOAT\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\n\nvec2 environmentClearCoatBrdf=getBRDFLookup(clearCoatNdotV,clearCoatRoughness,environmentBrdfSampler);\nvec3 clearCoatEnvironmentReflectance=getReflectanceFromBRDFLookup(vec3(vClearCoatRefractionParams.x),environmentClearCoatBrdf);\n#ifdef RADIANCEOCCLUSION\nfloat clearCoatSeo=environmentRadianceOcclusion(ambientMonochrome,clearCoatNdotVUnclamped);\nclearCoatEnvironmentReflectance*=clearCoatSeo;\n#endif\n#ifdef HORIZONOCCLUSION\n#ifdef BUMP\n#ifdef REFLECTIONMAP_3D\nfloat clearCoatEho=environmentHorizonOcclusion(-viewDirectionW,clearCoatNormalW);\nclearCoatEnvironmentReflectance*=clearCoatEho;\n#endif\n#endif\n#endif\n#else\n\nvec3 clearCoatEnvironmentReflectance=fresnelSchlickEnvironmentGGX(clearCoatNdotV,vec3(1.),vec3(1.),sqrt(1.-clearCoatRoughness));\n#endif\nclearCoatEnvironmentReflectance*=clearCoatIntensity;\n#ifdef CLEARCOAT_TINT\n\nabsorption=computeClearCoatAbsorption(clearCoatNdotVRefract,clearCoatNdotVRefract,clearCoatColor,clearCoatThickness,clearCoatIntensity);\n#ifdef REFLECTION\nenvironmentIrradiance*=absorption;\n#endif\nspecularEnvironmentReflectance*=absorption;\n#endif\n\nfloat fresnelIBLClearCoat=fresnelSchlickGGX(clearCoatNdotV,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);\nfresnelIBLClearCoat*=clearCoatIntensity;\nfloat conservationFactor=(1.-fresnelIBLClearCoat);\n#ifdef REFLECTION\nenvironmentIrradiance*=conservationFactor;\n#endif\nspecularEnvironmentReflectance*=(conservationFactor*conservationFactor);\n#endif\n\n#ifdef REFRACTION\nvec3 refractance=vec3(0.0,0.0,0.0);\nvec3 transmission=vec3(1.0,1.0,1.0);\n#ifdef LINKREFRACTIONTOTRANSPARENCY\n\ntransmission*=(1.0-alpha);\n\n\nvec3 mixedAlbedo=surfaceAlbedo;\nfloat maxChannel=max(max(mixedAlbedo.r,mixedAlbedo.g),mixedAlbedo.b);\nvec3 tint=clamp(maxChannel*mixedAlbedo,0.0,1.0);\n\nsurfaceAlbedo*=alpha;\n\nenvironmentIrradiance*=alpha;\n\nenvironmentRefraction.rgb*=tint;\n\nalpha=1.0;\n#endif\n\nvec3 bounceSpecularEnvironmentReflectance=(2.0*specularEnvironmentReflectance)/(1.0+specularEnvironmentReflectance);\nspecularEnvironmentReflectance=mix(bounceSpecularEnvironmentReflectance,specularEnvironmentReflectance,alpha);\n\ntransmission*=1.0-specularEnvironmentReflectance;\n\nrefractance=transmission;\n#endif\n\n\n\n\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#ifdef MS_BRDF_ENERGY_CONSERVATION\nfinalSpecularScaled*=energyConservationFactor;\n#endif\n#endif\n\n#ifdef REFLECTION\nvec3 finalRadiance=environmentRadiance.rgb;\nfinalRadiance*=specularEnvironmentReflectance;\n\nvec3 finalRadianceScaled=finalRadiance*vLightingIntensity.z;\n#ifdef MS_BRDF_ENERGY_CONSERVATION\nfinalRadianceScaled*=energyConservationFactor;\n#endif\n#endif\n\n#ifdef REFRACTION\nvec3 finalRefraction=environmentRefraction.rgb;\nfinalRefraction*=refractance;\n#endif\n\n#ifdef CLEARCOAT\nvec3 finalClearCoat=clearCoatBase;\nfinalClearCoat=max(finalClearCoat,0.0);\n\nvec3 finalClearCoatScaled=finalClearCoat*vLightingIntensity.x*vLightingIntensity.w;\n#ifdef MS_BRDF_ENERGY_CONSERVATION\nfinalClearCoatScaled*=energyConservationFactor;\n#endif\n\n#ifdef REFLECTION\nvec3 finalClearCoatRadiance=environmentClearCoatRadiance.rgb;\nfinalClearCoatRadiance*=clearCoatEnvironmentReflectance;\n\nvec3 finalClearCoatRadianceScaled=finalClearCoatRadiance*vLightingIntensity.z;\n#endif\n#ifdef REFRACTION\nfinalRefraction*=(conservationFactor*conservationFactor);\n#ifdef CLEARCOAT_TINT\nfinalRefraction*=absorption;\n#endif\n#endif\n#endif\n\n#ifdef ALPHABLEND\nfloat luminanceOverAlpha=0.0;\n#if defined(REFLECTION) && defined(RADIANCEOVERALPHA)\nluminanceOverAlpha+=getLuminance(finalRadianceScaled);\n#if defined(CLEARCOAT)\nluminanceOverAlpha+=getLuminance(finalClearCoatRadianceScaled);\n#endif\n#endif\n#if defined(SPECULARTERM) && defined(SPECULAROVERALPHA)\nluminanceOverAlpha+=getLuminance(finalSpecularScaled);\n#endif\n#if defined(CLEARCOAT) && defined(CLEARCOATOVERALPHA)\nluminanceOverAlpha+=getLuminance(finalClearCoatScaled);\n#endif\n#if defined(RADIANCEOVERALPHA) || defined(SPECULAROVERALPHA)\nalpha=clamp(alpha+luminanceOverAlpha*luminanceOverAlpha,0.,1.);\n#endif\n#endif\n#endif\n\n\nvec3 finalDiffuse=diffuseBase;\nfinalDiffuse*=surfaceAlbedo.rgb;\nfinalDiffuse=max(finalDiffuse,0.0);\n\nvec3 finalEmissive=vEmissiveColor;\n#ifdef EMISSIVE\nvec3 emissiveColorTex=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb;\nfinalEmissive*=toLinearSpace(emissiveColorTex.rgb);\nfinalEmissive*=vEmissiveInfos.y;\n#endif\n\n#ifdef AMBIENT\nvec3 ambientOcclusionForDirectDiffuse=mix(vec3(1.),ambientOcclusionColor,vAmbientInfos.w);\n#else\nvec3 ambientOcclusionForDirectDiffuse=ambientOcclusionColor;\n#endif\n\n\n\nvec4 finalColor=vec4(\nvAmbientColor*ambientOcclusionColor +\nfinalDiffuse*ambientOcclusionForDirectDiffuse*vLightingIntensity.x +\n#ifndef UNLIT\n#ifdef REFLECTION\nfinalIrradiance*ambientOcclusionColor*vLightingIntensity.z +\n#endif\n#ifdef SPECULARTERM\n\n\nfinalSpecularScaled +\n#endif\n#ifdef CLEARCOAT\n\n\nfinalClearCoatScaled +\n#endif\n#ifdef REFLECTION\n\n\nfinalRadianceScaled +\n#ifdef CLEARCOAT\n\n\nfinalClearCoatRadianceScaled +\n#endif\n#endif\n#ifdef REFRACTION\nfinalRefraction*vLightingIntensity.z +\n#endif\n#endif\nfinalEmissive*vLightingIntensity.y,\nalpha);\n\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\nfinalColor.rgb*=lightmapColor;\n#else\nfinalColor.rgb+=lightmapColor;\n#endif\n#endif\n#endif\n\nfinalColor=max(finalColor,0.0);\n#include<logDepthFragment>\n#include<fogFragment>(color,finalColor)\n#ifdef IMAGEPROCESSINGPOSTPROCESS\n\n\nfinalColor.rgb=clamp(finalColor.rgb,0.,30.0);\n#else\n\nfinalColor=applyImageProcessing(finalColor);\n#endif\n#ifdef PREMULTIPLYALPHA\n\nfinalColor.rgb*=finalColor.a;\n#endif\ngl_FragColor=finalColor;\n#include<pbrDebug>\n}\n";
  126210. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126211. /** @hidden */
  126212. var pbrPixelShader = { name: name, shader: shader };
  126213. /***/ }),
  126214. /***/ "./Shaders/pbr.vertex.ts":
  126215. /*!*******************************!*\
  126216. !*** ./Shaders/pbr.vertex.ts ***!
  126217. \*******************************/
  126218. /*! exports provided: pbrVertexShader */
  126219. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126220. "use strict";
  126221. __webpack_require__.r(__webpack_exports__);
  126222. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrVertexShader", function() { return pbrVertexShader; });
  126223. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126224. /* harmony import */ var _ShadersInclude_pbrVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/pbrVertexDeclaration */ "./Shaders/ShadersInclude/pbrVertexDeclaration.ts");
  126225. /* harmony import */ var _ShadersInclude_pbrUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/pbrUboDeclaration */ "./Shaders/ShadersInclude/pbrUboDeclaration.ts");
  126226. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  126227. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  126228. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  126229. /* harmony import */ var _ShadersInclude_harmonicsFunctions__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/harmonicsFunctions */ "./Shaders/ShadersInclude/harmonicsFunctions.ts");
  126230. /* harmony import */ var _ShadersInclude_bumpVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/bumpVertexDeclaration */ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts");
  126231. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  126232. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  126233. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  126234. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  126235. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  126236. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  126237. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  126238. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  126239. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  126240. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  126241. /* harmony import */ var _ShadersInclude_bumpVertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/bumpVertex */ "./Shaders/ShadersInclude/bumpVertex.ts");
  126242. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  126243. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  126244. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  126245. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  126246. var name = 'pbrVertexShader';
  126247. var shader = "precision highp float;\n#include<__decl__pbrVertex>\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef TANGENT\nattribute vec4 tangent;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<helperFunctions>\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\n#if defined(ALBEDO) && ALBEDODIRECTUV == 0\nvarying vec2 vAlbedoUV;\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nvarying vec2 vAmbientUV;\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nvarying vec2 vOpacityUV;\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nvarying vec2 vEmissiveUV;\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nvarying vec2 vLightmapUV;\n#endif\n#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0\nvarying vec2 vReflectivityUV;\n#endif\n#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0\nvarying vec2 vMicroSurfaceSamplerUV;\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nvarying vec2 vBumpUV;\n#endif\n#ifdef CLEARCOAT\n#if defined(CLEARCOAT_TEXTURE) && CLEARCOAT_TEXTUREDIRECTUV == 0\nvarying vec2 vClearCoatUV;\n#endif\n#if defined(CLEARCOAT_BUMP) && CLEARCOAT_BUMPDIRECTUV == 0\nvarying vec2 vClearCoatBumpUV;\n#endif\n#if defined(CLEARCOAT_TINT_TEXTURE) && CLEARCOAT_TINT_TEXTUREDIRECTUV == 0\nvarying vec2 vClearCoatTintUV;\n#endif\n#endif\n\nvarying vec3 vPositionW;\n#if DEBUGMODE>0\nvarying vec4 vClipSpacePosition;\n#endif\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvarying vec3 vEnvironmentIrradiance;\n#include<harmonicsFunctions>\n#endif\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<bumpVertexDeclaration>\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#include<logDepthDeclaration>\nvoid main(void) {\nvec3 positionUpdated=position;\n#ifdef NORMAL\nvec3 normalUpdated=normal;\n#endif\n#ifdef TANGENT\nvec4 tangentUpdated=tangent;\n#endif\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\n#ifdef REFLECTIONMAP_SKYBOX_TRANSFORMED\nvPositionUVW=(reflectionMatrix*vec4(positionUpdated,1.0)).xyz;\n#else\nvPositionUVW=positionUpdated;\n#endif\n#endif\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\n#if DEBUGMODE>0\nvClipSpacePosition=gl_Position;\n#endif\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normalUpdated);\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvec3 reflectionVector=vec3(reflectionMatrix*vec4(vNormalW,0)).xyz;\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\nvEnvironmentIrradiance=environmentIrradianceJones(reflectionVector);\n#endif\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif\n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(ALBEDO) && ALBEDODIRECTUV == 0\nif (vAlbedoInfos.x == 0.)\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nif (vAmbientInfos.x == 0.)\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nif (vOpacityInfos.x == 0.)\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nif (vEmissiveInfos.x == 0.)\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nif (vLightmapInfos.x == 0.)\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0\nif (vReflectivityInfos.x == 0.)\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0\nif (vMicroSurfaceSamplerInfos.x == 0.)\n{\nvMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nif (vBumpInfos.x == 0.)\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef CLEARCOAT\n#if defined(CLEARCOAT_TEXTURE) && CLEARCOAT_TEXTUREDIRECTUV == 0\nif (vClearCoatInfos.x == 0.)\n{\nvClearCoatUV=vec2(clearCoatMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvClearCoatUV=vec2(clearCoatMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(CLEARCOAT_BUMP) && CLEARCOAT_BUMPDIRECTUV == 0\nif (vClearCoatBumpInfos.x == 0.)\n{\nvClearCoatBumpUV=vec2(clearCoatBumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvClearCoatBumpUV=vec2(clearCoatBumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(CLEARCOAT_TINT_TEXTURE) && CLEARCOAT_TINT_TEXTUREDIRECTUV == 0\nif (vClearCoatTintInfos.x == 0.)\n{\nvClearCoatTintUV=vec2(clearCoatTintMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvClearCoatTintUV=vec2(clearCoatTintMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#endif\n\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}";
  126248. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126249. /** @hidden */
  126250. var pbrVertexShader = { name: name, shader: shader };
  126251. /***/ }),
  126252. /***/ "./Shaders/postprocess.vertex.ts":
  126253. /*!***************************************!*\
  126254. !*** ./Shaders/postprocess.vertex.ts ***!
  126255. \***************************************/
  126256. /*! exports provided: postprocessVertexShader */
  126257. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126258. "use strict";
  126259. __webpack_require__.r(__webpack_exports__);
  126260. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "postprocessVertexShader", function() { return postprocessVertexShader; });
  126261. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126262. var name = 'postprocessVertexShader';
  126263. 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}";
  126264. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126265. /** @hidden */
  126266. var postprocessVertexShader = { name: name, shader: shader };
  126267. /***/ }),
  126268. /***/ "./Shaders/procedural.vertex.ts":
  126269. /*!**************************************!*\
  126270. !*** ./Shaders/procedural.vertex.ts ***!
  126271. \**************************************/
  126272. /*! exports provided: proceduralVertexShader */
  126273. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126274. "use strict";
  126275. __webpack_require__.r(__webpack_exports__);
  126276. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "proceduralVertexShader", function() { return proceduralVertexShader; });
  126277. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126278. var name = 'proceduralVertexShader';
  126279. 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}";
  126280. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126281. /** @hidden */
  126282. var proceduralVertexShader = { name: name, shader: shader };
  126283. /***/ }),
  126284. /***/ "./Shaders/refraction.fragment.ts":
  126285. /*!****************************************!*\
  126286. !*** ./Shaders/refraction.fragment.ts ***!
  126287. \****************************************/
  126288. /*! exports provided: refractionPixelShader */
  126289. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126290. "use strict";
  126291. __webpack_require__.r(__webpack_exports__);
  126292. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "refractionPixelShader", function() { return refractionPixelShader; });
  126293. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126294. var name = 'refractionPixelShader';
  126295. 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}";
  126296. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126297. /** @hidden */
  126298. var refractionPixelShader = { name: name, shader: shader };
  126299. /***/ }),
  126300. /***/ "./Shaders/rgbdDecode.fragment.ts":
  126301. /*!****************************************!*\
  126302. !*** ./Shaders/rgbdDecode.fragment.ts ***!
  126303. \****************************************/
  126304. /*! exports provided: rgbdDecodePixelShader */
  126305. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126306. "use strict";
  126307. __webpack_require__.r(__webpack_exports__);
  126308. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rgbdDecodePixelShader", function() { return rgbdDecodePixelShader; });
  126309. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126310. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  126311. var name = 'rgbdDecodePixelShader';
  126312. 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}";
  126313. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126314. /** @hidden */
  126315. var rgbdDecodePixelShader = { name: name, shader: shader };
  126316. /***/ }),
  126317. /***/ "./Shaders/rgbdEncode.fragment.ts":
  126318. /*!****************************************!*\
  126319. !*** ./Shaders/rgbdEncode.fragment.ts ***!
  126320. \****************************************/
  126321. /*! exports provided: rgbdEncodePixelShader */
  126322. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126323. "use strict";
  126324. __webpack_require__.r(__webpack_exports__);
  126325. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rgbdEncodePixelShader", function() { return rgbdEncodePixelShader; });
  126326. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126327. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  126328. var name = 'rgbdEncodePixelShader';
  126329. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n#include<helperFunctions>\nvoid main(void)\n{\ngl_FragColor=toRGBD(texture2D(textureSampler,vUV).rgb);\n}";
  126330. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126331. /** @hidden */
  126332. var rgbdEncodePixelShader = { name: name, shader: shader };
  126333. /***/ }),
  126334. /***/ "./Shaders/shadowMap.fragment.ts":
  126335. /*!***************************************!*\
  126336. !*** ./Shaders/shadowMap.fragment.ts ***!
  126337. \***************************************/
  126338. /*! exports provided: shadowMapPixelShader */
  126339. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126340. "use strict";
  126341. __webpack_require__.r(__webpack_exports__);
  126342. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowMapPixelShader", function() { return shadowMapPixelShader; });
  126343. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126344. var name = 'shadowMapPixelShader';
  126345. 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}";
  126346. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126347. /** @hidden */
  126348. var shadowMapPixelShader = { name: name, shader: shader };
  126349. /***/ }),
  126350. /***/ "./Shaders/shadowMap.vertex.ts":
  126351. /*!*************************************!*\
  126352. !*** ./Shaders/shadowMap.vertex.ts ***!
  126353. \*************************************/
  126354. /*! exports provided: shadowMapVertexShader */
  126355. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126356. "use strict";
  126357. __webpack_require__.r(__webpack_exports__);
  126358. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowMapVertexShader", function() { return shadowMapVertexShader; });
  126359. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126360. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  126361. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  126362. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  126363. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  126364. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  126365. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  126366. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  126367. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  126368. var name = 'shadowMapVertexShader';
  126369. 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}";
  126370. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126371. /** @hidden */
  126372. var shadowMapVertexShader = { name: name, shader: shader };
  126373. /***/ }),
  126374. /***/ "./Shaders/sharpen.fragment.ts":
  126375. /*!*************************************!*\
  126376. !*** ./Shaders/sharpen.fragment.ts ***!
  126377. \*************************************/
  126378. /*! exports provided: sharpenPixelShader */
  126379. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126380. "use strict";
  126381. __webpack_require__.r(__webpack_exports__);
  126382. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sharpenPixelShader", function() { return sharpenPixelShader; });
  126383. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126384. var name = 'sharpenPixelShader';
  126385. 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}";
  126386. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126387. /** @hidden */
  126388. var sharpenPixelShader = { name: name, shader: shader };
  126389. /***/ }),
  126390. /***/ "./Shaders/sprites.fragment.ts":
  126391. /*!*************************************!*\
  126392. !*** ./Shaders/sprites.fragment.ts ***!
  126393. \*************************************/
  126394. /*! exports provided: spritesPixelShader */
  126395. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126396. "use strict";
  126397. __webpack_require__.r(__webpack_exports__);
  126398. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "spritesPixelShader", function() { return spritesPixelShader; });
  126399. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126400. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  126401. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  126402. var name = 'spritesPixelShader';
  126403. 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}";
  126404. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126405. /** @hidden */
  126406. var spritesPixelShader = { name: name, shader: shader };
  126407. /***/ }),
  126408. /***/ "./Shaders/sprites.vertex.ts":
  126409. /*!***********************************!*\
  126410. !*** ./Shaders/sprites.vertex.ts ***!
  126411. \***********************************/
  126412. /*! exports provided: spritesVertexShader */
  126413. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126414. "use strict";
  126415. __webpack_require__.r(__webpack_exports__);
  126416. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "spritesVertexShader", function() { return spritesVertexShader; });
  126417. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126418. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  126419. var name = 'spritesVertexShader';
  126420. 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}";
  126421. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126422. /** @hidden */
  126423. var spritesVertexShader = { name: name, shader: shader };
  126424. /***/ }),
  126425. /***/ "./Shaders/ssao.fragment.ts":
  126426. /*!**********************************!*\
  126427. !*** ./Shaders/ssao.fragment.ts ***!
  126428. \**********************************/
  126429. /*! exports provided: ssaoPixelShader */
  126430. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126431. "use strict";
  126432. __webpack_require__.r(__webpack_exports__);
  126433. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssaoPixelShader", function() { return ssaoPixelShader; });
  126434. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126435. var name = 'ssaoPixelShader';
  126436. 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";
  126437. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126438. /** @hidden */
  126439. var ssaoPixelShader = { name: name, shader: shader };
  126440. /***/ }),
  126441. /***/ "./Shaders/ssao2.fragment.ts":
  126442. /*!***********************************!*\
  126443. !*** ./Shaders/ssao2.fragment.ts ***!
  126444. \***********************************/
  126445. /*! exports provided: ssao2PixelShader */
  126446. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126447. "use strict";
  126448. __webpack_require__.r(__webpack_exports__);
  126449. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssao2PixelShader", function() { return ssao2PixelShader; });
  126450. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126451. var name = 'ssao2PixelShader';
  126452. 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";
  126453. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126454. /** @hidden */
  126455. var ssao2PixelShader = { name: name, shader: shader };
  126456. /***/ }),
  126457. /***/ "./Shaders/ssaoCombine.fragment.ts":
  126458. /*!*****************************************!*\
  126459. !*** ./Shaders/ssaoCombine.fragment.ts ***!
  126460. \*****************************************/
  126461. /*! exports provided: ssaoCombinePixelShader */
  126462. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126463. "use strict";
  126464. __webpack_require__.r(__webpack_exports__);
  126465. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssaoCombinePixelShader", function() { return ssaoCombinePixelShader; });
  126466. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126467. var name = 'ssaoCombinePixelShader';
  126468. 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";
  126469. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126470. /** @hidden */
  126471. var ssaoCombinePixelShader = { name: name, shader: shader };
  126472. /***/ }),
  126473. /***/ "./Shaders/standard.fragment.ts":
  126474. /*!**************************************!*\
  126475. !*** ./Shaders/standard.fragment.ts ***!
  126476. \**************************************/
  126477. /*! exports provided: standardPixelShader */
  126478. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126479. "use strict";
  126480. __webpack_require__.r(__webpack_exports__);
  126481. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "standardPixelShader", function() { return standardPixelShader; });
  126482. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126483. var name = 'standardPixelShader';
  126484. 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";
  126485. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126486. /** @hidden */
  126487. var standardPixelShader = { name: name, shader: shader };
  126488. /***/ }),
  126489. /***/ "./Shaders/stereoscopicInterlace.fragment.ts":
  126490. /*!***************************************************!*\
  126491. !*** ./Shaders/stereoscopicInterlace.fragment.ts ***!
  126492. \***************************************************/
  126493. /*! exports provided: stereoscopicInterlacePixelShader */
  126494. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126495. "use strict";
  126496. __webpack_require__.r(__webpack_exports__);
  126497. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "stereoscopicInterlacePixelShader", function() { return stereoscopicInterlacePixelShader; });
  126498. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126499. var name = 'stereoscopicInterlacePixelShader';
  126500. 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}";
  126501. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126502. /** @hidden */
  126503. var stereoscopicInterlacePixelShader = { name: name, shader: shader };
  126504. /***/ }),
  126505. /***/ "./Shaders/tonemap.fragment.ts":
  126506. /*!*************************************!*\
  126507. !*** ./Shaders/tonemap.fragment.ts ***!
  126508. \*************************************/
  126509. /*! exports provided: tonemapPixelShader */
  126510. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126511. "use strict";
  126512. __webpack_require__.r(__webpack_exports__);
  126513. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "tonemapPixelShader", function() { return tonemapPixelShader; });
  126514. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126515. var name = 'tonemapPixelShader';
  126516. 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}";
  126517. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126518. /** @hidden */
  126519. var tonemapPixelShader = { name: name, shader: shader };
  126520. /***/ }),
  126521. /***/ "./Shaders/volumetricLightScattering.fragment.ts":
  126522. /*!*******************************************************!*\
  126523. !*** ./Shaders/volumetricLightScattering.fragment.ts ***!
  126524. \*******************************************************/
  126525. /*! exports provided: volumetricLightScatteringPixelShader */
  126526. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126527. "use strict";
  126528. __webpack_require__.r(__webpack_exports__);
  126529. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "volumetricLightScatteringPixelShader", function() { return volumetricLightScatteringPixelShader; });
  126530. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126531. var name = 'volumetricLightScatteringPixelShader';
  126532. 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";
  126533. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126534. /** @hidden */
  126535. var volumetricLightScatteringPixelShader = { name: name, shader: shader };
  126536. /***/ }),
  126537. /***/ "./Shaders/volumetricLightScatteringPass.fragment.ts":
  126538. /*!***********************************************************!*\
  126539. !*** ./Shaders/volumetricLightScatteringPass.fragment.ts ***!
  126540. \***********************************************************/
  126541. /*! exports provided: volumetricLightScatteringPassPixelShader */
  126542. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126543. "use strict";
  126544. __webpack_require__.r(__webpack_exports__);
  126545. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "volumetricLightScatteringPassPixelShader", function() { return volumetricLightScatteringPassPixelShader; });
  126546. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126547. var name = 'volumetricLightScatteringPassPixelShader';
  126548. 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";
  126549. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126550. /** @hidden */
  126551. var volumetricLightScatteringPassPixelShader = { name: name, shader: shader };
  126552. /***/ }),
  126553. /***/ "./Shaders/vrDistortionCorrection.fragment.ts":
  126554. /*!****************************************************!*\
  126555. !*** ./Shaders/vrDistortionCorrection.fragment.ts ***!
  126556. \****************************************************/
  126557. /*! exports provided: vrDistortionCorrectionPixelShader */
  126558. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126559. "use strict";
  126560. __webpack_require__.r(__webpack_exports__);
  126561. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "vrDistortionCorrectionPixelShader", function() { return vrDistortionCorrectionPixelShader; });
  126562. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  126563. var name = 'vrDistortionCorrectionPixelShader';
  126564. 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}";
  126565. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  126566. /** @hidden */
  126567. var vrDistortionCorrectionPixelShader = { name: name, shader: shader };
  126568. /***/ }),
  126569. /***/ "./Sprites/index.ts":
  126570. /*!**************************!*\
  126571. !*** ./Sprites/index.ts ***!
  126572. \**************************/
  126573. /*! exports provided: Sprite, SpriteManager, SpriteSceneComponent */
  126574. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126575. "use strict";
  126576. __webpack_require__.r(__webpack_exports__);
  126577. /* harmony import */ var _sprite__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sprite */ "./Sprites/sprite.ts");
  126578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _sprite__WEBPACK_IMPORTED_MODULE_0__["Sprite"]; });
  126579. /* harmony import */ var _spriteManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./spriteManager */ "./Sprites/spriteManager.ts");
  126580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _spriteManager__WEBPACK_IMPORTED_MODULE_1__["SpriteManager"]; });
  126581. /* harmony import */ var _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./spriteSceneComponent */ "./Sprites/spriteSceneComponent.ts");
  126582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_2__["SpriteSceneComponent"]; });
  126583. /***/ }),
  126584. /***/ "./Sprites/sprite.ts":
  126585. /*!***************************!*\
  126586. !*** ./Sprites/sprite.ts ***!
  126587. \***************************/
  126588. /*! exports provided: Sprite */
  126589. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126590. "use strict";
  126591. __webpack_require__.r(__webpack_exports__);
  126592. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return Sprite; });
  126593. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  126594. /**
  126595. * Class used to represent a sprite
  126596. * @see http://doc.babylonjs.com/babylon101/sprites
  126597. */
  126598. var Sprite = /** @class */ (function () {
  126599. /**
  126600. * Creates a new Sprite
  126601. * @param name defines the name
  126602. * @param manager defines the manager
  126603. */
  126604. function Sprite(
  126605. /** defines the name */
  126606. name, manager) {
  126607. this.name = name;
  126608. /** Gets or sets the main color */
  126609. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  126610. /** Gets or sets the width */
  126611. this.width = 1.0;
  126612. /** Gets or sets the height */
  126613. this.height = 1.0;
  126614. /** Gets or sets rotation angle */
  126615. this.angle = 0;
  126616. /** Gets or sets the cell index in the sprite sheet */
  126617. this.cellIndex = 0;
  126618. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  126619. this.invertU = 0;
  126620. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  126621. this.invertV = 0;
  126622. /** Gets the list of attached animations */
  126623. this.animations = new Array();
  126624. /** Gets or sets a boolean indicating if the sprite can be picked */
  126625. this.isPickable = false;
  126626. this._animationStarted = false;
  126627. this._loopAnimation = false;
  126628. this._fromIndex = 0;
  126629. this._toIndex = 0;
  126630. this._delay = 0;
  126631. this._direction = 1;
  126632. this._time = 0;
  126633. /**
  126634. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  126635. */
  126636. this.isVisible = true;
  126637. this._manager = manager;
  126638. this._manager.sprites.push(this);
  126639. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  126640. }
  126641. Object.defineProperty(Sprite.prototype, "size", {
  126642. /**
  126643. * Gets or sets the sprite size
  126644. */
  126645. get: function () {
  126646. return this.width;
  126647. },
  126648. set: function (value) {
  126649. this.width = value;
  126650. this.height = value;
  126651. },
  126652. enumerable: true,
  126653. configurable: true
  126654. });
  126655. /**
  126656. * Starts an animation
  126657. * @param from defines the initial key
  126658. * @param to defines the end key
  126659. * @param loop defines if the animation must loop
  126660. * @param delay defines the start delay (in ms)
  126661. * @param onAnimationEnd defines a callback to call when animation ends
  126662. */
  126663. Sprite.prototype.playAnimation = function (from, to, loop, delay, onAnimationEnd) {
  126664. this._fromIndex = from;
  126665. this._toIndex = to;
  126666. this._loopAnimation = loop;
  126667. this._delay = delay;
  126668. this._animationStarted = true;
  126669. this._direction = from < to ? 1 : -1;
  126670. this.cellIndex = from;
  126671. this._time = 0;
  126672. this._onAnimationEnd = onAnimationEnd;
  126673. };
  126674. /** Stops current animation (if any) */
  126675. Sprite.prototype.stopAnimation = function () {
  126676. this._animationStarted = false;
  126677. };
  126678. /** @hidden */
  126679. Sprite.prototype._animate = function (deltaTime) {
  126680. if (!this._animationStarted) {
  126681. return;
  126682. }
  126683. this._time += deltaTime;
  126684. if (this._time > this._delay) {
  126685. this._time = this._time % this._delay;
  126686. this.cellIndex += this._direction;
  126687. if (this.cellIndex > this._toIndex) {
  126688. if (this._loopAnimation) {
  126689. this.cellIndex = this._fromIndex;
  126690. }
  126691. else {
  126692. this.cellIndex = this._toIndex;
  126693. this._animationStarted = false;
  126694. if (this._onAnimationEnd) {
  126695. this._onAnimationEnd();
  126696. }
  126697. if (this.disposeWhenFinishedAnimating) {
  126698. this.dispose();
  126699. }
  126700. }
  126701. }
  126702. }
  126703. };
  126704. /** Release associated resources */
  126705. Sprite.prototype.dispose = function () {
  126706. for (var i = 0; i < this._manager.sprites.length; i++) {
  126707. if (this._manager.sprites[i] == this) {
  126708. this._manager.sprites.splice(i, 1);
  126709. }
  126710. }
  126711. };
  126712. return Sprite;
  126713. }());
  126714. /***/ }),
  126715. /***/ "./Sprites/spriteManager.ts":
  126716. /*!**********************************!*\
  126717. !*** ./Sprites/spriteManager.ts ***!
  126718. \**********************************/
  126719. /*! exports provided: SpriteManager */
  126720. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126721. "use strict";
  126722. __webpack_require__.r(__webpack_exports__);
  126723. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return SpriteManager; });
  126724. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  126725. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  126726. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  126727. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  126728. /* harmony import */ var _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./spriteSceneComponent */ "./Sprites/spriteSceneComponent.ts");
  126729. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  126730. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  126731. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  126732. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  126733. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  126734. /* harmony import */ var _Shaders_sprites_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/sprites.fragment */ "./Shaders/sprites.fragment.ts");
  126735. /* harmony import */ var _Shaders_sprites_vertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/sprites.vertex */ "./Shaders/sprites.vertex.ts");
  126736. /**
  126737. * Class used to manage multiple sprites on the same spritesheet
  126738. * @see http://doc.babylonjs.com/babylon101/sprites
  126739. */
  126740. var SpriteManager = /** @class */ (function () {
  126741. /**
  126742. * Creates a new sprite manager
  126743. * @param name defines the manager's name
  126744. * @param imgUrl defines the sprite sheet url
  126745. * @param capacity defines the maximum allowed number of sprites
  126746. * @param cellSize defines the size of a sprite cell
  126747. * @param scene defines the hosting scene
  126748. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  126749. * @param samplingMode defines the smapling mode to use with spritesheet
  126750. */
  126751. function SpriteManager(
  126752. /** defines the manager's name */
  126753. name, imgUrl, capacity, cellSize, scene, epsilon, samplingMode) {
  126754. if (epsilon === void 0) { epsilon = 0.01; }
  126755. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].TRILINEAR_SAMPLINGMODE; }
  126756. this.name = name;
  126757. /** Gets the list of sprites */
  126758. this.sprites = new Array();
  126759. /** Gets or sets the rendering group id (0 by default) */
  126760. this.renderingGroupId = 0;
  126761. /** Gets or sets camera layer mask */
  126762. this.layerMask = 0x0FFFFFFF;
  126763. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  126764. this.fogEnabled = true;
  126765. /** Gets or sets a boolean indicating if the sprites are pickable */
  126766. this.isPickable = false;
  126767. /**
  126768. * An event triggered when the manager is disposed.
  126769. */
  126770. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  126771. this._vertexBuffers = {};
  126772. if (!scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_8__["SceneComponentConstants"].NAME_SPRITE)) {
  126773. scene._addComponent(new _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_4__["SpriteSceneComponent"](scene));
  126774. }
  126775. this._capacity = capacity;
  126776. this._spriteTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"](imgUrl, scene, true, false, samplingMode);
  126777. this._spriteTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  126778. this._spriteTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  126779. if (cellSize.width && cellSize.height) {
  126780. this.cellWidth = cellSize.width;
  126781. this.cellHeight = cellSize.height;
  126782. }
  126783. else if (cellSize !== undefined) {
  126784. this.cellWidth = cellSize;
  126785. this.cellHeight = cellSize;
  126786. }
  126787. else {
  126788. return;
  126789. }
  126790. this._epsilon = epsilon;
  126791. this._scene = scene;
  126792. this._scene.spriteManagers.push(this);
  126793. var indices = [];
  126794. var index = 0;
  126795. for (var count = 0; count < capacity; count++) {
  126796. indices.push(index);
  126797. indices.push(index + 1);
  126798. indices.push(index + 2);
  126799. indices.push(index);
  126800. indices.push(index + 2);
  126801. indices.push(index + 3);
  126802. index += 4;
  126803. }
  126804. this._indexBuffer = scene.getEngine().createIndexBuffer(indices);
  126805. // VBO
  126806. // 16 floats per sprite (x, y, z, angle, sizeX, sizeY, offsetX, offsetY, invertU, invertV, cellIndexX, cellIndexY, color r, color g, color b, color a)
  126807. this._vertexData = new Float32Array(capacity * 16 * 4);
  126808. this._buffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["Buffer"](scene.getEngine(), this._vertexData, true, 16);
  126809. var positions = this._buffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, 0, 4);
  126810. var options = this._buffer.createVertexBuffer("options", 4, 4);
  126811. var cellInfo = this._buffer.createVertexBuffer("cellInfo", 8, 4);
  126812. var colors = this._buffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, 12, 4);
  126813. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind] = positions;
  126814. this._vertexBuffers["options"] = options;
  126815. this._vertexBuffers["cellInfo"] = cellInfo;
  126816. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind] = colors;
  126817. // Effects
  126818. 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"], "");
  126819. 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");
  126820. }
  126821. Object.defineProperty(SpriteManager.prototype, "onDispose", {
  126822. /**
  126823. * Callback called when the manager is disposed
  126824. */
  126825. set: function (callback) {
  126826. if (this._onDisposeObserver) {
  126827. this.onDisposeObservable.remove(this._onDisposeObserver);
  126828. }
  126829. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  126830. },
  126831. enumerable: true,
  126832. configurable: true
  126833. });
  126834. Object.defineProperty(SpriteManager.prototype, "texture", {
  126835. /**
  126836. * Gets or sets the spritesheet texture
  126837. */
  126838. get: function () {
  126839. return this._spriteTexture;
  126840. },
  126841. set: function (value) {
  126842. this._spriteTexture = value;
  126843. },
  126844. enumerable: true,
  126845. configurable: true
  126846. });
  126847. SpriteManager.prototype._appendSpriteVertex = function (index, sprite, offsetX, offsetY, rowSize) {
  126848. var arrayOffset = index * 16;
  126849. if (offsetX === 0) {
  126850. offsetX = this._epsilon;
  126851. }
  126852. else if (offsetX === 1) {
  126853. offsetX = 1 - this._epsilon;
  126854. }
  126855. if (offsetY === 0) {
  126856. offsetY = this._epsilon;
  126857. }
  126858. else if (offsetY === 1) {
  126859. offsetY = 1 - this._epsilon;
  126860. }
  126861. this._vertexData[arrayOffset] = sprite.position.x;
  126862. this._vertexData[arrayOffset + 1] = sprite.position.y;
  126863. this._vertexData[arrayOffset + 2] = sprite.position.z;
  126864. this._vertexData[arrayOffset + 3] = sprite.angle;
  126865. this._vertexData[arrayOffset + 4] = sprite.width;
  126866. this._vertexData[arrayOffset + 5] = sprite.height;
  126867. this._vertexData[arrayOffset + 6] = offsetX;
  126868. this._vertexData[arrayOffset + 7] = offsetY;
  126869. this._vertexData[arrayOffset + 8] = sprite.invertU ? 1 : 0;
  126870. this._vertexData[arrayOffset + 9] = sprite.invertV ? 1 : 0;
  126871. var offset = (sprite.cellIndex / rowSize) >> 0;
  126872. this._vertexData[arrayOffset + 10] = sprite.cellIndex - offset * rowSize;
  126873. this._vertexData[arrayOffset + 11] = offset;
  126874. // Color
  126875. this._vertexData[arrayOffset + 12] = sprite.color.r;
  126876. this._vertexData[arrayOffset + 13] = sprite.color.g;
  126877. this._vertexData[arrayOffset + 14] = sprite.color.b;
  126878. this._vertexData[arrayOffset + 15] = sprite.color.a;
  126879. };
  126880. /**
  126881. * Intersects the sprites with a ray
  126882. * @param ray defines the ray to intersect with
  126883. * @param camera defines the current active camera
  126884. * @param predicate defines a predicate used to select candidate sprites
  126885. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  126886. * @returns null if no hit or a PickingInfo
  126887. */
  126888. SpriteManager.prototype.intersects = function (ray, camera, predicate, fastCheck) {
  126889. var count = Math.min(this._capacity, this.sprites.length);
  126890. var min = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  126891. var max = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  126892. var distance = Number.MAX_VALUE;
  126893. var currentSprite = null;
  126894. var cameraSpacePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  126895. var cameraView = camera.getViewMatrix();
  126896. for (var index = 0; index < count; index++) {
  126897. var sprite = this.sprites[index];
  126898. if (!sprite) {
  126899. continue;
  126900. }
  126901. if (predicate) {
  126902. if (!predicate(sprite)) {
  126903. continue;
  126904. }
  126905. }
  126906. else if (!sprite.isPickable) {
  126907. continue;
  126908. }
  126909. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(sprite.position, cameraView, cameraSpacePosition);
  126910. min.copyFromFloats(cameraSpacePosition.x - sprite.width / 2, cameraSpacePosition.y - sprite.height / 2, cameraSpacePosition.z);
  126911. max.copyFromFloats(cameraSpacePosition.x + sprite.width / 2, cameraSpacePosition.y + sprite.height / 2, cameraSpacePosition.z);
  126912. if (ray.intersectsBoxMinMax(min, max)) {
  126913. var currentDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(cameraSpacePosition, ray.origin);
  126914. if (distance > currentDistance) {
  126915. distance = currentDistance;
  126916. currentSprite = sprite;
  126917. if (fastCheck) {
  126918. break;
  126919. }
  126920. }
  126921. }
  126922. }
  126923. if (currentSprite) {
  126924. var result = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_5__["PickingInfo"]();
  126925. result.hit = true;
  126926. result.pickedSprite = currentSprite;
  126927. result.distance = distance;
  126928. return result;
  126929. }
  126930. return null;
  126931. };
  126932. /**
  126933. * Render all child sprites
  126934. */
  126935. SpriteManager.prototype.render = function () {
  126936. // Check
  126937. if (!this._effectBase.isReady() || !this._effectFog.isReady() || !this._spriteTexture
  126938. || !this._spriteTexture.isReady() || !this.sprites.length) {
  126939. return;
  126940. }
  126941. var engine = this._scene.getEngine();
  126942. var baseSize = this._spriteTexture.getBaseSize();
  126943. // Sprites
  126944. var deltaTime = engine.getDeltaTime();
  126945. var max = Math.min(this._capacity, this.sprites.length);
  126946. var rowSize = baseSize.width / this.cellWidth;
  126947. var offset = 0;
  126948. for (var index = 0; index < max; index++) {
  126949. var sprite = this.sprites[index];
  126950. if (!sprite || !sprite.isVisible) {
  126951. continue;
  126952. }
  126953. sprite._animate(deltaTime);
  126954. this._appendSpriteVertex(offset++, sprite, 0, 0, rowSize);
  126955. this._appendSpriteVertex(offset++, sprite, 1, 0, rowSize);
  126956. this._appendSpriteVertex(offset++, sprite, 1, 1, rowSize);
  126957. this._appendSpriteVertex(offset++, sprite, 0, 1, rowSize);
  126958. }
  126959. this._buffer.update(this._vertexData);
  126960. // Render
  126961. var effect = this._effectBase;
  126962. if (this._scene.fogEnabled && this._scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].FOGMODE_NONE && this.fogEnabled) {
  126963. effect = this._effectFog;
  126964. }
  126965. engine.enableEffect(effect);
  126966. var viewMatrix = this._scene.getViewMatrix();
  126967. effect.setTexture("diffuseSampler", this._spriteTexture);
  126968. effect.setMatrix("view", viewMatrix);
  126969. effect.setMatrix("projection", this._scene.getProjectionMatrix());
  126970. effect.setFloat2("textureInfos", this.cellWidth / baseSize.width, this.cellHeight / baseSize.height);
  126971. // Fog
  126972. if (this._scene.fogEnabled && this._scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].FOGMODE_NONE && this.fogEnabled) {
  126973. effect.setFloat4("vFogInfos", this._scene.fogMode, this._scene.fogStart, this._scene.fogEnd, this._scene.fogDensity);
  126974. effect.setColor3("vFogColor", this._scene.fogColor);
  126975. }
  126976. // VBOs
  126977. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  126978. // Draw order
  126979. engine.setDepthFunctionToLessOrEqual();
  126980. effect.setBool("alphaTest", true);
  126981. engine.setColorWrite(false);
  126982. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, (offset / 4) * 6);
  126983. engine.setColorWrite(true);
  126984. effect.setBool("alphaTest", false);
  126985. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].ALPHA_COMBINE);
  126986. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, (offset / 4) * 6);
  126987. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].ALPHA_DISABLE);
  126988. };
  126989. /**
  126990. * Release associated resources
  126991. */
  126992. SpriteManager.prototype.dispose = function () {
  126993. if (this._buffer) {
  126994. this._buffer.dispose();
  126995. this._buffer = null;
  126996. }
  126997. if (this._indexBuffer) {
  126998. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  126999. this._indexBuffer = null;
  127000. }
  127001. if (this._spriteTexture) {
  127002. this._spriteTexture.dispose();
  127003. this._spriteTexture = null;
  127004. }
  127005. // Remove from scene
  127006. var index = this._scene.spriteManagers.indexOf(this);
  127007. this._scene.spriteManagers.splice(index, 1);
  127008. // Callback
  127009. this.onDisposeObservable.notifyObservers(this);
  127010. this.onDisposeObservable.clear();
  127011. };
  127012. return SpriteManager;
  127013. }());
  127014. /***/ }),
  127015. /***/ "./Sprites/spriteSceneComponent.ts":
  127016. /*!*****************************************!*\
  127017. !*** ./Sprites/spriteSceneComponent.ts ***!
  127018. \*****************************************/
  127019. /*! exports provided: SpriteSceneComponent */
  127020. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127021. "use strict";
  127022. __webpack_require__.r(__webpack_exports__);
  127023. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return SpriteSceneComponent; });
  127024. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  127025. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  127026. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  127027. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  127028. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  127029. /* harmony import */ var _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Actions/actionEvent */ "./Actions/actionEvent.ts");
  127030. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  127031. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype._internalPickSprites = function (ray, predicate, fastCheck, camera) {
  127032. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__["PickingInfo"]) {
  127033. return null;
  127034. }
  127035. var pickingInfo = null;
  127036. if (!camera) {
  127037. if (!this.activeCamera) {
  127038. return null;
  127039. }
  127040. camera = this.activeCamera;
  127041. }
  127042. if (this.spriteManagers.length > 0) {
  127043. for (var spriteIndex = 0; spriteIndex < this.spriteManagers.length; spriteIndex++) {
  127044. var spriteManager = this.spriteManagers[spriteIndex];
  127045. if (!spriteManager.isPickable) {
  127046. continue;
  127047. }
  127048. var result = spriteManager.intersects(ray, camera, predicate, fastCheck);
  127049. if (!result || !result.hit) {
  127050. continue;
  127051. }
  127052. if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) {
  127053. continue;
  127054. }
  127055. pickingInfo = result;
  127056. if (fastCheck) {
  127057. break;
  127058. }
  127059. }
  127060. }
  127061. return pickingInfo || new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__["PickingInfo"]();
  127062. };
  127063. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.pickSprite = function (x, y, predicate, fastCheck, camera) {
  127064. this.createPickingRayInCameraSpaceToRef(x, y, this._tempSpritePickingRay, camera);
  127065. return this._internalPickSprites(this._tempSpritePickingRay, predicate, fastCheck, camera);
  127066. };
  127067. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.pickSpriteWithRay = function (ray, predicate, fastCheck, camera) {
  127068. if (!this._tempSpritePickingRay) {
  127069. return null;
  127070. }
  127071. if (!camera) {
  127072. if (!this.activeCamera) {
  127073. return null;
  127074. }
  127075. camera = this.activeCamera;
  127076. }
  127077. _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"].TransformToRef(ray, camera.getViewMatrix(), this._tempSpritePickingRay);
  127078. return this._internalPickSprites(this._tempSpritePickingRay, predicate, fastCheck, camera);
  127079. };
  127080. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.setPointerOverSprite = function (sprite) {
  127081. if (this._pointerOverSprite === sprite) {
  127082. return;
  127083. }
  127084. if (this._pointerOverSprite && this._pointerOverSprite.actionManager) {
  127085. this._pointerOverSprite.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].ACTION_OnPointerOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__["ActionEvent"].CreateNewFromSprite(this._pointerOverSprite, this));
  127086. }
  127087. this._pointerOverSprite = sprite;
  127088. if (this._pointerOverSprite && this._pointerOverSprite.actionManager) {
  127089. this._pointerOverSprite.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].ACTION_OnPointerOverTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__["ActionEvent"].CreateNewFromSprite(this._pointerOverSprite, this));
  127090. }
  127091. };
  127092. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.getPointerOverSprite = function () {
  127093. return this._pointerOverSprite;
  127094. };
  127095. /**
  127096. * Defines the sprite scene component responsible to manage sprites
  127097. * in a given scene.
  127098. */
  127099. var SpriteSceneComponent = /** @class */ (function () {
  127100. /**
  127101. * Creates a new instance of the component for the given scene
  127102. * @param scene Defines the scene to register the component in
  127103. */
  127104. function SpriteSceneComponent(scene) {
  127105. /**
  127106. * The component name helpfull to identify the component in the list of scene components.
  127107. */
  127108. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_SPRITE;
  127109. this.scene = scene;
  127110. this.scene.spriteManagers = new Array();
  127111. this.scene._tempSpritePickingRay = _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"] ? _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"].Zero() : null;
  127112. this.scene.onBeforeSpritesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  127113. this.scene.onAfterSpritesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  127114. this._spritePredicate = function (sprite) {
  127115. if (!sprite.actionManager) {
  127116. return false;
  127117. }
  127118. return sprite.isPickable && sprite.actionManager.hasPointerTriggers;
  127119. };
  127120. }
  127121. /**
  127122. * Registers the component in a given scene
  127123. */
  127124. SpriteSceneComponent.prototype.register = function () {
  127125. this.scene._pointerMoveStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERMOVE_SPRITE, this, this._pointerMove);
  127126. this.scene._pointerDownStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERDOWN_SPRITE, this, this._pointerDown);
  127127. this.scene._pointerUpStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERUP_SPRITE, this, this._pointerUp);
  127128. };
  127129. /**
  127130. * Rebuilds the elements related to this component in case of
  127131. * context lost for instance.
  127132. */
  127133. SpriteSceneComponent.prototype.rebuild = function () {
  127134. /** Nothing to do for sprites */
  127135. };
  127136. /**
  127137. * Disposes the component and the associated ressources.
  127138. */
  127139. SpriteSceneComponent.prototype.dispose = function () {
  127140. this.scene.onBeforeSpritesRenderingObservable.clear();
  127141. this.scene.onAfterSpritesRenderingObservable.clear();
  127142. var spriteManagers = this.scene.spriteManagers;
  127143. while (spriteManagers.length) {
  127144. spriteManagers[0].dispose();
  127145. }
  127146. };
  127147. SpriteSceneComponent.prototype._pickSpriteButKeepRay = function (originalPointerInfo, x, y, fastCheck, camera) {
  127148. var result = this.scene.pickSprite(x, y, this._spritePredicate, fastCheck, camera);
  127149. if (result) {
  127150. result.ray = originalPointerInfo ? originalPointerInfo.ray : null;
  127151. }
  127152. return result;
  127153. };
  127154. SpriteSceneComponent.prototype._pointerMove = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, isMeshPicked, canvas) {
  127155. var scene = this.scene;
  127156. if (isMeshPicked) {
  127157. scene.setPointerOverSprite(null);
  127158. }
  127159. else {
  127160. pickResult = this._pickSpriteButKeepRay(pickResult, unTranslatedPointerX, unTranslatedPointerY, false, scene.cameraToUseForPointers || undefined);
  127161. if (pickResult && pickResult.hit && pickResult.pickedSprite) {
  127162. scene.setPointerOverSprite(pickResult.pickedSprite);
  127163. if (scene._pointerOverSprite && scene._pointerOverSprite.actionManager && scene._pointerOverSprite.actionManager.hoverCursor) {
  127164. canvas.style.cursor = scene._pointerOverSprite.actionManager.hoverCursor;
  127165. }
  127166. else {
  127167. canvas.style.cursor = scene.hoverCursor;
  127168. }
  127169. }
  127170. else {
  127171. scene.setPointerOverSprite(null);
  127172. }
  127173. }
  127174. return pickResult;
  127175. };
  127176. SpriteSceneComponent.prototype._pointerDown = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, evt) {
  127177. var scene = this.scene;
  127178. scene._pickedDownSprite = null;
  127179. if (scene.spriteManagers.length > 0) {
  127180. pickResult = scene.pickSprite(unTranslatedPointerX, unTranslatedPointerY, this._spritePredicate, false, scene.cameraToUseForPointers || undefined);
  127181. if (pickResult && pickResult.hit && pickResult.pickedSprite) {
  127182. if (pickResult.pickedSprite.actionManager) {
  127183. scene._pickedDownSprite = pickResult.pickedSprite;
  127184. switch (evt.button) {
  127185. case 0:
  127186. 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));
  127187. break;
  127188. case 1:
  127189. 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));
  127190. break;
  127191. case 2:
  127192. 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));
  127193. break;
  127194. }
  127195. if (pickResult.pickedSprite.actionManager) {
  127196. 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));
  127197. }
  127198. }
  127199. }
  127200. }
  127201. return pickResult;
  127202. };
  127203. SpriteSceneComponent.prototype._pointerUp = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, evt) {
  127204. var scene = this.scene;
  127205. if (scene.spriteManagers.length > 0) {
  127206. var spritePickResult = scene.pickSprite(unTranslatedPointerX, unTranslatedPointerY, this._spritePredicate, false, scene.cameraToUseForPointers || undefined);
  127207. if (spritePickResult) {
  127208. if (spritePickResult.hit && spritePickResult.pickedSprite) {
  127209. if (spritePickResult.pickedSprite.actionManager) {
  127210. 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));
  127211. if (spritePickResult.pickedSprite.actionManager) {
  127212. if (!this.scene._isPointerSwiping()) {
  127213. 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));
  127214. }
  127215. }
  127216. }
  127217. }
  127218. if (scene._pickedDownSprite && scene._pickedDownSprite.actionManager && scene._pickedDownSprite !== spritePickResult.pickedSprite) {
  127219. 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));
  127220. }
  127221. }
  127222. }
  127223. return pickResult;
  127224. };
  127225. return SpriteSceneComponent;
  127226. }());
  127227. /***/ }),
  127228. /***/ "./States/alphaCullingState.ts":
  127229. /*!*************************************!*\
  127230. !*** ./States/alphaCullingState.ts ***!
  127231. \*************************************/
  127232. /*! exports provided: _AlphaState */
  127233. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127234. "use strict";
  127235. __webpack_require__.r(__webpack_exports__);
  127236. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _AlphaState; });
  127237. /**
  127238. * @hidden
  127239. **/
  127240. var _AlphaState = /** @class */ (function () {
  127241. /**
  127242. * Initializes the state.
  127243. */
  127244. function _AlphaState() {
  127245. this._isAlphaBlendDirty = false;
  127246. this._isBlendFunctionParametersDirty = false;
  127247. this._isBlendEquationParametersDirty = false;
  127248. this._isBlendConstantsDirty = false;
  127249. this._alphaBlend = false;
  127250. this._blendFunctionParameters = new Array(4);
  127251. this._blendEquationParameters = new Array(2);
  127252. this._blendConstants = new Array(4);
  127253. this.reset();
  127254. }
  127255. Object.defineProperty(_AlphaState.prototype, "isDirty", {
  127256. get: function () {
  127257. return this._isAlphaBlendDirty || this._isBlendFunctionParametersDirty;
  127258. },
  127259. enumerable: true,
  127260. configurable: true
  127261. });
  127262. Object.defineProperty(_AlphaState.prototype, "alphaBlend", {
  127263. get: function () {
  127264. return this._alphaBlend;
  127265. },
  127266. set: function (value) {
  127267. if (this._alphaBlend === value) {
  127268. return;
  127269. }
  127270. this._alphaBlend = value;
  127271. this._isAlphaBlendDirty = true;
  127272. },
  127273. enumerable: true,
  127274. configurable: true
  127275. });
  127276. _AlphaState.prototype.setAlphaBlendConstants = function (r, g, b, a) {
  127277. if (this._blendConstants[0] === r &&
  127278. this._blendConstants[1] === g &&
  127279. this._blendConstants[2] === b &&
  127280. this._blendConstants[3] === a) {
  127281. return;
  127282. }
  127283. this._blendConstants[0] = r;
  127284. this._blendConstants[1] = g;
  127285. this._blendConstants[2] = b;
  127286. this._blendConstants[3] = a;
  127287. this._isBlendConstantsDirty = true;
  127288. };
  127289. _AlphaState.prototype.setAlphaBlendFunctionParameters = function (value0, value1, value2, value3) {
  127290. if (this._blendFunctionParameters[0] === value0 &&
  127291. this._blendFunctionParameters[1] === value1 &&
  127292. this._blendFunctionParameters[2] === value2 &&
  127293. this._blendFunctionParameters[3] === value3) {
  127294. return;
  127295. }
  127296. this._blendFunctionParameters[0] = value0;
  127297. this._blendFunctionParameters[1] = value1;
  127298. this._blendFunctionParameters[2] = value2;
  127299. this._blendFunctionParameters[3] = value3;
  127300. this._isBlendFunctionParametersDirty = true;
  127301. };
  127302. _AlphaState.prototype.setAlphaEquationParameters = function (rgb, alpha) {
  127303. if (this._blendEquationParameters[0] === rgb &&
  127304. this._blendEquationParameters[1] === alpha) {
  127305. return;
  127306. }
  127307. this._blendEquationParameters[0] = rgb;
  127308. this._blendEquationParameters[1] = alpha;
  127309. this._isBlendEquationParametersDirty = true;
  127310. };
  127311. _AlphaState.prototype.reset = function () {
  127312. this._alphaBlend = false;
  127313. this._blendFunctionParameters[0] = null;
  127314. this._blendFunctionParameters[1] = null;
  127315. this._blendFunctionParameters[2] = null;
  127316. this._blendFunctionParameters[3] = null;
  127317. this._blendEquationParameters[0] = null;
  127318. this._blendEquationParameters[1] = null;
  127319. this._blendConstants[0] = null;
  127320. this._blendConstants[1] = null;
  127321. this._blendConstants[2] = null;
  127322. this._blendConstants[3] = null;
  127323. this._isAlphaBlendDirty = true;
  127324. this._isBlendFunctionParametersDirty = false;
  127325. this._isBlendEquationParametersDirty = false;
  127326. this._isBlendConstantsDirty = false;
  127327. };
  127328. _AlphaState.prototype.apply = function (gl) {
  127329. if (!this.isDirty) {
  127330. return;
  127331. }
  127332. // Alpha blend
  127333. if (this._isAlphaBlendDirty) {
  127334. if (this._alphaBlend) {
  127335. gl.enable(gl.BLEND);
  127336. }
  127337. else {
  127338. gl.disable(gl.BLEND);
  127339. }
  127340. this._isAlphaBlendDirty = false;
  127341. }
  127342. // Alpha function
  127343. if (this._isBlendFunctionParametersDirty) {
  127344. gl.blendFuncSeparate(this._blendFunctionParameters[0], this._blendFunctionParameters[1], this._blendFunctionParameters[2], this._blendFunctionParameters[3]);
  127345. this._isBlendFunctionParametersDirty = false;
  127346. }
  127347. // Alpha equation
  127348. if (this._isBlendEquationParametersDirty) {
  127349. gl.blendEquationSeparate(this._blendEquationParameters[0], this._blendEquationParameters[1]);
  127350. this._isBlendEquationParametersDirty = false;
  127351. }
  127352. // Constants
  127353. if (this._isBlendConstantsDirty) {
  127354. gl.blendColor(this._blendConstants[0], this._blendConstants[1], this._blendConstants[2], this._blendConstants[3]);
  127355. this._isBlendConstantsDirty = false;
  127356. }
  127357. };
  127358. return _AlphaState;
  127359. }());
  127360. /***/ }),
  127361. /***/ "./States/depthCullingState.ts":
  127362. /*!*************************************!*\
  127363. !*** ./States/depthCullingState.ts ***!
  127364. \*************************************/
  127365. /*! exports provided: _DepthCullingState */
  127366. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127367. "use strict";
  127368. __webpack_require__.r(__webpack_exports__);
  127369. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _DepthCullingState; });
  127370. /**
  127371. * @hidden
  127372. **/
  127373. var _DepthCullingState = /** @class */ (function () {
  127374. /**
  127375. * Initializes the state.
  127376. */
  127377. function _DepthCullingState() {
  127378. this._isDepthTestDirty = false;
  127379. this._isDepthMaskDirty = false;
  127380. this._isDepthFuncDirty = false;
  127381. this._isCullFaceDirty = false;
  127382. this._isCullDirty = false;
  127383. this._isZOffsetDirty = false;
  127384. this._isFrontFaceDirty = false;
  127385. this.reset();
  127386. }
  127387. Object.defineProperty(_DepthCullingState.prototype, "isDirty", {
  127388. get: function () {
  127389. return this._isDepthFuncDirty || this._isDepthTestDirty || this._isDepthMaskDirty || this._isCullFaceDirty || this._isCullDirty || this._isZOffsetDirty || this._isFrontFaceDirty;
  127390. },
  127391. enumerable: true,
  127392. configurable: true
  127393. });
  127394. Object.defineProperty(_DepthCullingState.prototype, "zOffset", {
  127395. get: function () {
  127396. return this._zOffset;
  127397. },
  127398. set: function (value) {
  127399. if (this._zOffset === value) {
  127400. return;
  127401. }
  127402. this._zOffset = value;
  127403. this._isZOffsetDirty = true;
  127404. },
  127405. enumerable: true,
  127406. configurable: true
  127407. });
  127408. Object.defineProperty(_DepthCullingState.prototype, "cullFace", {
  127409. get: function () {
  127410. return this._cullFace;
  127411. },
  127412. set: function (value) {
  127413. if (this._cullFace === value) {
  127414. return;
  127415. }
  127416. this._cullFace = value;
  127417. this._isCullFaceDirty = true;
  127418. },
  127419. enumerable: true,
  127420. configurable: true
  127421. });
  127422. Object.defineProperty(_DepthCullingState.prototype, "cull", {
  127423. get: function () {
  127424. return this._cull;
  127425. },
  127426. set: function (value) {
  127427. if (this._cull === value) {
  127428. return;
  127429. }
  127430. this._cull = value;
  127431. this._isCullDirty = true;
  127432. },
  127433. enumerable: true,
  127434. configurable: true
  127435. });
  127436. Object.defineProperty(_DepthCullingState.prototype, "depthFunc", {
  127437. get: function () {
  127438. return this._depthFunc;
  127439. },
  127440. set: function (value) {
  127441. if (this._depthFunc === value) {
  127442. return;
  127443. }
  127444. this._depthFunc = value;
  127445. this._isDepthFuncDirty = true;
  127446. },
  127447. enumerable: true,
  127448. configurable: true
  127449. });
  127450. Object.defineProperty(_DepthCullingState.prototype, "depthMask", {
  127451. get: function () {
  127452. return this._depthMask;
  127453. },
  127454. set: function (value) {
  127455. if (this._depthMask === value) {
  127456. return;
  127457. }
  127458. this._depthMask = value;
  127459. this._isDepthMaskDirty = true;
  127460. },
  127461. enumerable: true,
  127462. configurable: true
  127463. });
  127464. Object.defineProperty(_DepthCullingState.prototype, "depthTest", {
  127465. get: function () {
  127466. return this._depthTest;
  127467. },
  127468. set: function (value) {
  127469. if (this._depthTest === value) {
  127470. return;
  127471. }
  127472. this._depthTest = value;
  127473. this._isDepthTestDirty = true;
  127474. },
  127475. enumerable: true,
  127476. configurable: true
  127477. });
  127478. Object.defineProperty(_DepthCullingState.prototype, "frontFace", {
  127479. get: function () {
  127480. return this._frontFace;
  127481. },
  127482. set: function (value) {
  127483. if (this._frontFace === value) {
  127484. return;
  127485. }
  127486. this._frontFace = value;
  127487. this._isFrontFaceDirty = true;
  127488. },
  127489. enumerable: true,
  127490. configurable: true
  127491. });
  127492. _DepthCullingState.prototype.reset = function () {
  127493. this._depthMask = true;
  127494. this._depthTest = true;
  127495. this._depthFunc = null;
  127496. this._cullFace = null;
  127497. this._cull = null;
  127498. this._zOffset = 0;
  127499. this._frontFace = null;
  127500. this._isDepthTestDirty = true;
  127501. this._isDepthMaskDirty = true;
  127502. this._isDepthFuncDirty = false;
  127503. this._isCullFaceDirty = false;
  127504. this._isCullDirty = false;
  127505. this._isZOffsetDirty = false;
  127506. this._isFrontFaceDirty = false;
  127507. };
  127508. _DepthCullingState.prototype.apply = function (gl) {
  127509. if (!this.isDirty) {
  127510. return;
  127511. }
  127512. // Cull
  127513. if (this._isCullDirty) {
  127514. if (this.cull) {
  127515. gl.enable(gl.CULL_FACE);
  127516. }
  127517. else {
  127518. gl.disable(gl.CULL_FACE);
  127519. }
  127520. this._isCullDirty = false;
  127521. }
  127522. // Cull face
  127523. if (this._isCullFaceDirty) {
  127524. gl.cullFace(this.cullFace);
  127525. this._isCullFaceDirty = false;
  127526. }
  127527. // Depth mask
  127528. if (this._isDepthMaskDirty) {
  127529. gl.depthMask(this.depthMask);
  127530. this._isDepthMaskDirty = false;
  127531. }
  127532. // Depth test
  127533. if (this._isDepthTestDirty) {
  127534. if (this.depthTest) {
  127535. gl.enable(gl.DEPTH_TEST);
  127536. }
  127537. else {
  127538. gl.disable(gl.DEPTH_TEST);
  127539. }
  127540. this._isDepthTestDirty = false;
  127541. }
  127542. // Depth func
  127543. if (this._isDepthFuncDirty) {
  127544. gl.depthFunc(this.depthFunc);
  127545. this._isDepthFuncDirty = false;
  127546. }
  127547. // zOffset
  127548. if (this._isZOffsetDirty) {
  127549. if (this.zOffset) {
  127550. gl.enable(gl.POLYGON_OFFSET_FILL);
  127551. gl.polygonOffset(this.zOffset, 0);
  127552. }
  127553. else {
  127554. gl.disable(gl.POLYGON_OFFSET_FILL);
  127555. }
  127556. this._isZOffsetDirty = false;
  127557. }
  127558. // Front face
  127559. if (this._isFrontFaceDirty) {
  127560. gl.frontFace(this.frontFace);
  127561. this._isFrontFaceDirty = false;
  127562. }
  127563. };
  127564. return _DepthCullingState;
  127565. }());
  127566. /***/ }),
  127567. /***/ "./States/index.ts":
  127568. /*!*************************!*\
  127569. !*** ./States/index.ts ***!
  127570. \*************************/
  127571. /*! exports provided: _AlphaState, _DepthCullingState, _StencilState */
  127572. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127573. "use strict";
  127574. __webpack_require__.r(__webpack_exports__);
  127575. /* harmony import */ var _alphaCullingState__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./alphaCullingState */ "./States/alphaCullingState.ts");
  127576. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _alphaCullingState__WEBPACK_IMPORTED_MODULE_0__["_AlphaState"]; });
  127577. /* harmony import */ var _depthCullingState__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthCullingState */ "./States/depthCullingState.ts");
  127578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _depthCullingState__WEBPACK_IMPORTED_MODULE_1__["_DepthCullingState"]; });
  127579. /* harmony import */ var _stencilState__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stencilState */ "./States/stencilState.ts");
  127580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _stencilState__WEBPACK_IMPORTED_MODULE_2__["_StencilState"]; });
  127581. /***/ }),
  127582. /***/ "./States/stencilState.ts":
  127583. /*!********************************!*\
  127584. !*** ./States/stencilState.ts ***!
  127585. \********************************/
  127586. /*! exports provided: _StencilState */
  127587. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127588. "use strict";
  127589. __webpack_require__.r(__webpack_exports__);
  127590. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _StencilState; });
  127591. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  127592. /**
  127593. * @hidden
  127594. **/
  127595. var _StencilState = /** @class */ (function () {
  127596. function _StencilState() {
  127597. this._isStencilTestDirty = false;
  127598. this._isStencilMaskDirty = false;
  127599. this._isStencilFuncDirty = false;
  127600. this._isStencilOpDirty = false;
  127601. this.reset();
  127602. }
  127603. Object.defineProperty(_StencilState.prototype, "isDirty", {
  127604. get: function () {
  127605. return this._isStencilTestDirty || this._isStencilMaskDirty || this._isStencilFuncDirty || this._isStencilOpDirty;
  127606. },
  127607. enumerable: true,
  127608. configurable: true
  127609. });
  127610. Object.defineProperty(_StencilState.prototype, "stencilFunc", {
  127611. get: function () {
  127612. return this._stencilFunc;
  127613. },
  127614. set: function (value) {
  127615. if (this._stencilFunc === value) {
  127616. return;
  127617. }
  127618. this._stencilFunc = value;
  127619. this._isStencilFuncDirty = true;
  127620. },
  127621. enumerable: true,
  127622. configurable: true
  127623. });
  127624. Object.defineProperty(_StencilState.prototype, "stencilFuncRef", {
  127625. get: function () {
  127626. return this._stencilFuncRef;
  127627. },
  127628. set: function (value) {
  127629. if (this._stencilFuncRef === value) {
  127630. return;
  127631. }
  127632. this._stencilFuncRef = value;
  127633. this._isStencilFuncDirty = true;
  127634. },
  127635. enumerable: true,
  127636. configurable: true
  127637. });
  127638. Object.defineProperty(_StencilState.prototype, "stencilFuncMask", {
  127639. get: function () {
  127640. return this._stencilFuncMask;
  127641. },
  127642. set: function (value) {
  127643. if (this._stencilFuncMask === value) {
  127644. return;
  127645. }
  127646. this._stencilFuncMask = value;
  127647. this._isStencilFuncDirty = true;
  127648. },
  127649. enumerable: true,
  127650. configurable: true
  127651. });
  127652. Object.defineProperty(_StencilState.prototype, "stencilOpStencilFail", {
  127653. get: function () {
  127654. return this._stencilOpStencilFail;
  127655. },
  127656. set: function (value) {
  127657. if (this._stencilOpStencilFail === value) {
  127658. return;
  127659. }
  127660. this._stencilOpStencilFail = value;
  127661. this._isStencilOpDirty = true;
  127662. },
  127663. enumerable: true,
  127664. configurable: true
  127665. });
  127666. Object.defineProperty(_StencilState.prototype, "stencilOpDepthFail", {
  127667. get: function () {
  127668. return this._stencilOpDepthFail;
  127669. },
  127670. set: function (value) {
  127671. if (this._stencilOpDepthFail === value) {
  127672. return;
  127673. }
  127674. this._stencilOpDepthFail = value;
  127675. this._isStencilOpDirty = true;
  127676. },
  127677. enumerable: true,
  127678. configurable: true
  127679. });
  127680. Object.defineProperty(_StencilState.prototype, "stencilOpStencilDepthPass", {
  127681. get: function () {
  127682. return this._stencilOpStencilDepthPass;
  127683. },
  127684. set: function (value) {
  127685. if (this._stencilOpStencilDepthPass === value) {
  127686. return;
  127687. }
  127688. this._stencilOpStencilDepthPass = value;
  127689. this._isStencilOpDirty = true;
  127690. },
  127691. enumerable: true,
  127692. configurable: true
  127693. });
  127694. Object.defineProperty(_StencilState.prototype, "stencilMask", {
  127695. get: function () {
  127696. return this._stencilMask;
  127697. },
  127698. set: function (value) {
  127699. if (this._stencilMask === value) {
  127700. return;
  127701. }
  127702. this._stencilMask = value;
  127703. this._isStencilMaskDirty = true;
  127704. },
  127705. enumerable: true,
  127706. configurable: true
  127707. });
  127708. Object.defineProperty(_StencilState.prototype, "stencilTest", {
  127709. get: function () {
  127710. return this._stencilTest;
  127711. },
  127712. set: function (value) {
  127713. if (this._stencilTest === value) {
  127714. return;
  127715. }
  127716. this._stencilTest = value;
  127717. this._isStencilTestDirty = true;
  127718. },
  127719. enumerable: true,
  127720. configurable: true
  127721. });
  127722. _StencilState.prototype.reset = function () {
  127723. this._stencilTest = false;
  127724. this._stencilMask = 0xFF;
  127725. this._stencilFunc = _StencilState.ALWAYS;
  127726. this._stencilFuncRef = 1;
  127727. this._stencilFuncMask = 0xFF;
  127728. this._stencilOpStencilFail = _StencilState.KEEP;
  127729. this._stencilOpDepthFail = _StencilState.KEEP;
  127730. this._stencilOpStencilDepthPass = _StencilState.REPLACE;
  127731. this._isStencilTestDirty = true;
  127732. this._isStencilMaskDirty = true;
  127733. this._isStencilFuncDirty = true;
  127734. this._isStencilOpDirty = true;
  127735. };
  127736. _StencilState.prototype.apply = function (gl) {
  127737. if (!this.isDirty) {
  127738. return;
  127739. }
  127740. // Stencil test
  127741. if (this._isStencilTestDirty) {
  127742. if (this.stencilTest) {
  127743. gl.enable(gl.STENCIL_TEST);
  127744. }
  127745. else {
  127746. gl.disable(gl.STENCIL_TEST);
  127747. }
  127748. this._isStencilTestDirty = false;
  127749. }
  127750. // Stencil mask
  127751. if (this._isStencilMaskDirty) {
  127752. gl.stencilMask(this.stencilMask);
  127753. this._isStencilMaskDirty = false;
  127754. }
  127755. // Stencil func
  127756. if (this._isStencilFuncDirty) {
  127757. gl.stencilFunc(this.stencilFunc, this.stencilFuncRef, this.stencilFuncMask);
  127758. this._isStencilFuncDirty = false;
  127759. }
  127760. // Stencil op
  127761. if (this._isStencilOpDirty) {
  127762. gl.stencilOp(this.stencilOpStencilFail, this.stencilOpDepthFail, this.stencilOpStencilDepthPass);
  127763. this._isStencilOpDirty = false;
  127764. }
  127765. };
  127766. /** 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 */
  127767. _StencilState.ALWAYS = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].ALWAYS;
  127768. /** Passed to stencilOperation to specify that stencil value must be kept */
  127769. _StencilState.KEEP = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].KEEP;
  127770. /** Passed to stencilOperation to specify that stencil value must be replaced */
  127771. _StencilState.REPLACE = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].REPLACE;
  127772. return _StencilState;
  127773. }());
  127774. /***/ }),
  127775. /***/ "./abstractScene.ts":
  127776. /*!**************************!*\
  127777. !*** ./abstractScene.ts ***!
  127778. \**************************/
  127779. /*! exports provided: AbstractScene */
  127780. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127781. "use strict";
  127782. __webpack_require__.r(__webpack_exports__);
  127783. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return AbstractScene; });
  127784. /**
  127785. * Base class of the scene acting as a container for the different elements composing a scene.
  127786. * This class is dynamically extended by the different components of the scene increasing
  127787. * flexibility and reducing coupling
  127788. */
  127789. var AbstractScene = /** @class */ (function () {
  127790. function AbstractScene() {
  127791. /**
  127792. * Gets the list of root nodes (ie. nodes with no parent)
  127793. */
  127794. this.rootNodes = new Array();
  127795. /** All of the cameras added to this scene
  127796. * @see http://doc.babylonjs.com/babylon101/cameras
  127797. */
  127798. this.cameras = new Array();
  127799. /**
  127800. * All of the lights added to this scene
  127801. * @see http://doc.babylonjs.com/babylon101/lights
  127802. */
  127803. this.lights = new Array();
  127804. /**
  127805. * All of the (abstract) meshes added to this scene
  127806. */
  127807. this.meshes = new Array();
  127808. /**
  127809. * The list of skeletons added to the scene
  127810. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  127811. */
  127812. this.skeletons = new Array();
  127813. /**
  127814. * All of the particle systems added to this scene
  127815. * @see http://doc.babylonjs.com/babylon101/particles
  127816. */
  127817. this.particleSystems = new Array();
  127818. /**
  127819. * Gets a list of Animations associated with the scene
  127820. */
  127821. this.animations = [];
  127822. /**
  127823. * All of the animation groups added to this scene
  127824. * @see http://doc.babylonjs.com/how_to/group
  127825. */
  127826. this.animationGroups = new Array();
  127827. /**
  127828. * All of the multi-materials added to this scene
  127829. * @see http://doc.babylonjs.com/how_to/multi_materials
  127830. */
  127831. this.multiMaterials = new Array();
  127832. /**
  127833. * All of the materials added to this scene
  127834. * In the context of a Scene, it is not supposed to be modified manually.
  127835. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  127836. * Note also that the order of the Material wihin the array is not significant and might change.
  127837. * @see http://doc.babylonjs.com/babylon101/materials
  127838. */
  127839. this.materials = new Array();
  127840. /**
  127841. * The list of morph target managers added to the scene
  127842. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  127843. */
  127844. this.morphTargetManagers = new Array();
  127845. /**
  127846. * The list of geometries used in the scene.
  127847. */
  127848. this.geometries = new Array();
  127849. /**
  127850. * All of the tranform nodes added to this scene
  127851. * In the context of a Scene, it is not supposed to be modified manually.
  127852. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  127853. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  127854. * @see http://doc.babylonjs.com/how_to/transformnode
  127855. */
  127856. this.transformNodes = new Array();
  127857. /**
  127858. * ActionManagers available on the scene.
  127859. */
  127860. this.actionManagers = new Array();
  127861. /**
  127862. * Textures to keep.
  127863. */
  127864. this.textures = new Array();
  127865. }
  127866. /**
  127867. * Adds a parser in the list of available ones
  127868. * @param name Defines the name of the parser
  127869. * @param parser Defines the parser to add
  127870. */
  127871. AbstractScene.AddParser = function (name, parser) {
  127872. this._BabylonFileParsers[name] = parser;
  127873. };
  127874. /**
  127875. * Gets a general parser from the list of avaialble ones
  127876. * @param name Defines the name of the parser
  127877. * @returns the requested parser or null
  127878. */
  127879. AbstractScene.GetParser = function (name) {
  127880. if (this._BabylonFileParsers[name]) {
  127881. return this._BabylonFileParsers[name];
  127882. }
  127883. return null;
  127884. };
  127885. /**
  127886. * Adds n individual parser in the list of available ones
  127887. * @param name Defines the name of the parser
  127888. * @param parser Defines the parser to add
  127889. */
  127890. AbstractScene.AddIndividualParser = function (name, parser) {
  127891. this._IndividualBabylonFileParsers[name] = parser;
  127892. };
  127893. /**
  127894. * Gets an individual parser from the list of avaialble ones
  127895. * @param name Defines the name of the parser
  127896. * @returns the requested parser or null
  127897. */
  127898. AbstractScene.GetIndividualParser = function (name) {
  127899. if (this._IndividualBabylonFileParsers[name]) {
  127900. return this._IndividualBabylonFileParsers[name];
  127901. }
  127902. return null;
  127903. };
  127904. /**
  127905. * Parser json data and populate both a scene and its associated container object
  127906. * @param jsonData Defines the data to parse
  127907. * @param scene Defines the scene to parse the data for
  127908. * @param container Defines the container attached to the parsing sequence
  127909. * @param rootUrl Defines the root url of the data
  127910. */
  127911. AbstractScene.Parse = function (jsonData, scene, container, rootUrl) {
  127912. for (var parserName in this._BabylonFileParsers) {
  127913. if (this._BabylonFileParsers.hasOwnProperty(parserName)) {
  127914. this._BabylonFileParsers[parserName](jsonData, scene, container, rootUrl);
  127915. }
  127916. }
  127917. };
  127918. /**
  127919. * Stores the list of available parsers in the application.
  127920. */
  127921. AbstractScene._BabylonFileParsers = {};
  127922. /**
  127923. * Stores the list of available individual parsers in the application.
  127924. */
  127925. AbstractScene._IndividualBabylonFileParsers = {};
  127926. return AbstractScene;
  127927. }());
  127928. /***/ }),
  127929. /***/ "./assetContainer.ts":
  127930. /*!***************************!*\
  127931. !*** ./assetContainer.ts ***!
  127932. \***************************/
  127933. /*! exports provided: KeepAssets, AssetContainer */
  127934. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127935. "use strict";
  127936. __webpack_require__.r(__webpack_exports__);
  127937. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return KeepAssets; });
  127938. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return AssetContainer; });
  127939. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  127940. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  127941. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Meshes/mesh */ "./Meshes/mesh.ts");
  127942. /**
  127943. * Set of assets to keep when moving a scene into an asset container.
  127944. */
  127945. var KeepAssets = /** @class */ (function (_super) {
  127946. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](KeepAssets, _super);
  127947. function KeepAssets() {
  127948. return _super !== null && _super.apply(this, arguments) || this;
  127949. }
  127950. return KeepAssets;
  127951. }(_abstractScene__WEBPACK_IMPORTED_MODULE_1__["AbstractScene"]));
  127952. /**
  127953. * Container with a set of assets that can be added or removed from a scene.
  127954. */
  127955. var AssetContainer = /** @class */ (function (_super) {
  127956. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AssetContainer, _super);
  127957. /**
  127958. * Instantiates an AssetContainer.
  127959. * @param scene The scene the AssetContainer belongs to.
  127960. */
  127961. function AssetContainer(scene) {
  127962. var _this = _super.call(this) || this;
  127963. _this.scene = scene;
  127964. _this["sounds"] = [];
  127965. _this["effectLayers"] = [];
  127966. _this["layers"] = [];
  127967. _this["lensFlareSystems"] = [];
  127968. _this["proceduralTextures"] = [];
  127969. _this["reflectionProbes"] = [];
  127970. return _this;
  127971. }
  127972. /**
  127973. * Adds all the assets from the container to the scene.
  127974. */
  127975. AssetContainer.prototype.addAllToScene = function () {
  127976. var _this = this;
  127977. this.cameras.forEach(function (o) {
  127978. _this.scene.addCamera(o);
  127979. });
  127980. this.lights.forEach(function (o) {
  127981. _this.scene.addLight(o);
  127982. });
  127983. this.meshes.forEach(function (o) {
  127984. _this.scene.addMesh(o);
  127985. });
  127986. this.skeletons.forEach(function (o) {
  127987. _this.scene.addSkeleton(o);
  127988. });
  127989. this.animations.forEach(function (o) {
  127990. _this.scene.addAnimation(o);
  127991. });
  127992. this.animationGroups.forEach(function (o) {
  127993. _this.scene.addAnimationGroup(o);
  127994. });
  127995. this.multiMaterials.forEach(function (o) {
  127996. _this.scene.addMultiMaterial(o);
  127997. });
  127998. this.materials.forEach(function (o) {
  127999. _this.scene.addMaterial(o);
  128000. });
  128001. this.morphTargetManagers.forEach(function (o) {
  128002. _this.scene.addMorphTargetManager(o);
  128003. });
  128004. this.geometries.forEach(function (o) {
  128005. _this.scene.addGeometry(o);
  128006. });
  128007. this.transformNodes.forEach(function (o) {
  128008. _this.scene.addTransformNode(o);
  128009. });
  128010. this.actionManagers.forEach(function (o) {
  128011. _this.scene.addActionManager(o);
  128012. });
  128013. this.textures.forEach(function (o) {
  128014. _this.scene.addTexture(o);
  128015. });
  128016. this.reflectionProbes.forEach(function (o) {
  128017. _this.scene.addReflectionProbe(o);
  128018. });
  128019. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  128020. var component = _a[_i];
  128021. component.addFromContainer(this);
  128022. }
  128023. };
  128024. /**
  128025. * Removes all the assets in the container from the scene
  128026. */
  128027. AssetContainer.prototype.removeAllFromScene = function () {
  128028. var _this = this;
  128029. this.cameras.forEach(function (o) {
  128030. _this.scene.removeCamera(o);
  128031. });
  128032. this.lights.forEach(function (o) {
  128033. _this.scene.removeLight(o);
  128034. });
  128035. this.meshes.forEach(function (o) {
  128036. _this.scene.removeMesh(o);
  128037. });
  128038. this.skeletons.forEach(function (o) {
  128039. _this.scene.removeSkeleton(o);
  128040. });
  128041. this.animations.forEach(function (o) {
  128042. _this.scene.removeAnimation(o);
  128043. });
  128044. this.animationGroups.forEach(function (o) {
  128045. _this.scene.removeAnimationGroup(o);
  128046. });
  128047. this.multiMaterials.forEach(function (o) {
  128048. _this.scene.removeMultiMaterial(o);
  128049. });
  128050. this.materials.forEach(function (o) {
  128051. _this.scene.removeMaterial(o);
  128052. });
  128053. this.morphTargetManagers.forEach(function (o) {
  128054. _this.scene.removeMorphTargetManager(o);
  128055. });
  128056. this.geometries.forEach(function (o) {
  128057. _this.scene.removeGeometry(o);
  128058. });
  128059. this.transformNodes.forEach(function (o) {
  128060. _this.scene.removeTransformNode(o);
  128061. });
  128062. this.actionManagers.forEach(function (o) {
  128063. _this.scene.removeActionManager(o);
  128064. });
  128065. this.textures.forEach(function (o) {
  128066. _this.scene.removeTexture(o);
  128067. });
  128068. this.reflectionProbes.forEach(function (o) {
  128069. _this.scene.removeReflectionProbe(o);
  128070. });
  128071. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  128072. var component = _a[_i];
  128073. component.removeFromContainer(this);
  128074. }
  128075. };
  128076. /**
  128077. * Disposes all the assets in the container
  128078. */
  128079. AssetContainer.prototype.dispose = function () {
  128080. this.cameras.forEach(function (o) {
  128081. o.dispose();
  128082. });
  128083. this.lights.forEach(function (o) {
  128084. o.dispose();
  128085. });
  128086. this.meshes.forEach(function (o) {
  128087. o.dispose();
  128088. });
  128089. this.skeletons.forEach(function (o) {
  128090. o.dispose();
  128091. });
  128092. this.animationGroups.forEach(function (o) {
  128093. o.dispose();
  128094. });
  128095. this.multiMaterials.forEach(function (o) {
  128096. o.dispose();
  128097. });
  128098. this.materials.forEach(function (o) {
  128099. o.dispose();
  128100. });
  128101. this.geometries.forEach(function (o) {
  128102. o.dispose();
  128103. });
  128104. this.transformNodes.forEach(function (o) {
  128105. o.dispose();
  128106. });
  128107. this.actionManagers.forEach(function (o) {
  128108. o.dispose();
  128109. });
  128110. this.textures.forEach(function (o) {
  128111. o.dispose();
  128112. });
  128113. this.reflectionProbes.forEach(function (o) {
  128114. o.dispose();
  128115. });
  128116. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  128117. var component = _a[_i];
  128118. component.dispose();
  128119. }
  128120. };
  128121. AssetContainer.prototype._moveAssets = function (sourceAssets, targetAssets, keepAssets) {
  128122. if (!sourceAssets) {
  128123. return;
  128124. }
  128125. for (var _i = 0, sourceAssets_1 = sourceAssets; _i < sourceAssets_1.length; _i++) {
  128126. var asset = sourceAssets_1[_i];
  128127. var move = true;
  128128. if (keepAssets) {
  128129. for (var _a = 0, keepAssets_1 = keepAssets; _a < keepAssets_1.length; _a++) {
  128130. var keepAsset = keepAssets_1[_a];
  128131. if (asset === keepAsset) {
  128132. move = false;
  128133. break;
  128134. }
  128135. }
  128136. }
  128137. if (move) {
  128138. targetAssets.push(asset);
  128139. }
  128140. }
  128141. };
  128142. /**
  128143. * Removes all the assets contained in the scene and adds them to the container.
  128144. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  128145. */
  128146. AssetContainer.prototype.moveAllFromScene = function (keepAssets) {
  128147. if (keepAssets === undefined) {
  128148. keepAssets = new KeepAssets();
  128149. }
  128150. for (var key in this) {
  128151. if (this.hasOwnProperty(key)) {
  128152. this[key] = this[key] || [];
  128153. this._moveAssets(this.scene[key], this[key], keepAssets[key]);
  128154. }
  128155. }
  128156. this.removeAllFromScene();
  128157. };
  128158. /**
  128159. * 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.
  128160. * @returns the root mesh
  128161. */
  128162. AssetContainer.prototype.createRootMesh = function () {
  128163. var rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("assetContainerRootMesh", this.scene);
  128164. this.meshes.forEach(function (m) {
  128165. if (!m.parent) {
  128166. rootMesh.addChild(m);
  128167. }
  128168. });
  128169. this.meshes.unshift(rootMesh);
  128170. return rootMesh;
  128171. };
  128172. return AssetContainer;
  128173. }(_abstractScene__WEBPACK_IMPORTED_MODULE_1__["AbstractScene"]));
  128174. /***/ }),
  128175. /***/ "./index.ts":
  128176. /*!******************!*\
  128177. !*** ./index.ts ***!
  128178. \******************/
  128179. /*! 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, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad, AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, LightGizmo, EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome, EngineInstrumentation, SceneInstrumentation, _TimeToken, EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent, LensFlare, LensFlareSystem, LensFlareSystemSceneComponent, Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, ColorCurves, EffectFallbacks, EffectCreationOptions, Effect, FresnelParameters, ImageProcessingConfigurationDefines, ImageProcessingConfiguration, Material, MaterialDefines, MaterialHelper, MultiMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, DynamicTexture, InternalTexture, MirrorTexture, RawTexture, RenderTargetTexture, Texture, UniformBuffer, MaterialFlags, Scalar, ToGammaSpace, ToLinearSpace, Epsilon, Color3, Color4, Vector2, Vector3, Vector4, Size, Quaternion, Matrix, Plane, Viewport, Frustum, Space, Axis, BezierCurve, Orientation, Angle, Arc2, Path2, Path3D, Curve3, PositionNormalVertex, PositionNormalTextureVertex, Tmp, SphericalPolynomial, SphericalHarmonics, AbstractMesh, Buffer, VertexBuffer, CSG, Geometry, GroundMesh, TrailMesh, InstancedMesh, LinesMesh, InstancedLinesMesh, MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh, VertexData, MeshBuilder, SimplificationSettings, SimplificationQueue, SimplificationType, SimplicationQueueSceneComponent, Polygon, PolygonMeshBuilder, BaseSubMesh, SubMesh, TransformNode, BoxBuilder, SphereBuilder, CylinderBuilder, TorusBuilder, LinesBuilder, PlaneBuilder, GroundBuilder, 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, FollowCameraKeyboardMoveInput, FollowCameraMouseWheelInput, FollowCameraPointersInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput, AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera, VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, OnAfterEnteringVRObservableEvent, VRExperienceHelper, WebVRFreeCamera, WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager, Octree, OctreeBlock, OctreeSceneComponent, _OcclusionDataStorage, _forceTransformFeedbackToBundle, DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, ShadowGenerator, ShadowGeneratorSceneComponent, _BabylonLoaderRegistered, BackgroundMaterial, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, HDRCubeTexture, DummyInternalTextureTracker, MultiRenderTarget, RawCubeTexture, RawTexture3D, RefractionTexture, VideoTexture, DracoCompression, DiscBuilder, RibbonBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, 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, ProceduralTexture, ProceduralTextureSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  128180. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128181. "use strict";
  128182. __webpack_require__.r(__webpack_exports__);
  128183. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  128184. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return _abstractScene__WEBPACK_IMPORTED_MODULE_0__["AbstractScene"]; });
  128185. /* harmony import */ var _Actions_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Actions/index */ "./Actions/index.ts");
  128186. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["Action"]; });
  128187. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ActionEvent"]; });
  128188. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ActionManager"]; });
  128189. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["Condition"]; });
  128190. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ValueCondition"]; });
  128191. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PredicateCondition"]; });
  128192. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StateCondition"]; });
  128193. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SwitchBooleanAction"]; });
  128194. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetStateAction"]; });
  128195. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetValueAction"]; });
  128196. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["IncrementValueAction"]; });
  128197. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PlayAnimationAction"]; });
  128198. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StopAnimationAction"]; });
  128199. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["DoNothingAction"]; });
  128200. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["CombineAction"]; });
  128201. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ExecuteCodeAction"]; });
  128202. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetParentAction"]; });
  128203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PlaySoundAction"]; });
  128204. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StopSoundAction"]; });
  128205. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["InterpolateValueAction"]; });
  128206. /* harmony import */ var _Animations_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Animations/index */ "./Animations/index.ts");
  128207. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["Animatable"]; });
  128208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["Animation"]; });
  128209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["TargetedAnimation"]; });
  128210. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationGroup"]; });
  128211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationPropertiesOverride"]; });
  128212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["EasingFunction"]; });
  128213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["CircleEase"]; });
  128214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BackEase"]; });
  128215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BounceEase"]; });
  128216. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["CubicEase"]; });
  128217. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["ElasticEase"]; });
  128218. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["ExponentialEase"]; });
  128219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["PowerEase"]; });
  128220. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuadraticEase"]; });
  128221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuarticEase"]; });
  128222. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuinticEase"]; });
  128223. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["SineEase"]; });
  128224. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BezierCurveEase"]; });
  128225. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["RuntimeAnimation"]; });
  128226. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationEvent"]; });
  128227. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationKeyInterpolation"]; });
  128228. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationRange"]; });
  128229. /* harmony import */ var _assetContainer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./assetContainer */ "./assetContainer.ts");
  128230. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return _assetContainer__WEBPACK_IMPORTED_MODULE_3__["KeepAssets"]; });
  128231. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return _assetContainer__WEBPACK_IMPORTED_MODULE_3__["AssetContainer"]; });
  128232. /* harmony import */ var _Audio_index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Audio/index */ "./Audio/index.ts");
  128233. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["Analyser"]; });
  128234. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["AudioEngine"]; });
  128235. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["AudioSceneComponent"]; });
  128236. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["Sound"]; });
  128237. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["SoundTrack"]; });
  128238. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["WeightedSound"]; });
  128239. /* harmony import */ var _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Behaviors/index */ "./Behaviors/index.ts");
  128240. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["AutoRotationBehavior"]; });
  128241. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["BouncingBehavior"]; });
  128242. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["FramingBehavior"]; });
  128243. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["AttachToBoxBehavior"]; });
  128244. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["FadeInOutBehavior"]; });
  128245. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["MultiPointerScaleBehavior"]; });
  128246. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]; });
  128247. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["SixDofDragBehavior"]; });
  128248. /* harmony import */ var _Bones_index__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Bones/index */ "./Bones/index.ts");
  128249. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["Bone"]; });
  128250. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["BoneIKController"]; });
  128251. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["BoneLookController"]; });
  128252. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["Skeleton"]; });
  128253. /* harmony import */ var _Cameras_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Cameras/index */ "./Cameras/index.ts");
  128254. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["CameraInputTypes"]; });
  128255. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["CameraInputsManager"]; });
  128256. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["Camera"]; });
  128257. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["TargetCamera"]; });
  128258. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCamera"]; });
  128259. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraInputsManager"]; });
  128260. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["TouchCamera"]; });
  128261. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCamera"]; });
  128262. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraInputsManager"]; });
  128263. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["DeviceOrientationCamera"]; });
  128264. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCamera"]; });
  128265. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraInputsManager"]; });
  128266. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCamera"]; });
  128267. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcFollowCamera"]; });
  128268. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["GamepadCamera"]; });
  128269. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["UniversalCamera"]; });
  128270. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VirtualJoysticksCamera"]; });
  128271. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraGamepadInput"]; });
  128272. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraKeyboardMoveInput"]; });
  128273. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraMouseWheelInput"]; });
  128274. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraPointersInput"]; });
  128275. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraVRDeviceOrientationInput"]; });
  128276. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraKeyboardInput"]; });
  128277. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraMouseInput"]; });
  128278. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCameraKeyboardMoveInput"]; });
  128279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCameraMouseWheelInput"]; });
  128280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCameraPointersInput"]; });
  128281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraDeviceOrientationInput"]; });
  128282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraGamepadInput"]; });
  128283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraKeyboardMoveInput"]; });
  128284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraMouseInput"]; });
  128285. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraTouchInput"]; });
  128286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraVirtualJoystickInput"]; });
  128287. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphArcRotateCamera"]; });
  128288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphFreeCamera"]; });
  128289. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphGamepadCamera"]; });
  128290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphUniversalCamera"]; });
  128291. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicArcRotateCamera"]; });
  128292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicFreeCamera"]; });
  128293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicGamepadCamera"]; });
  128294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicUniversalCamera"]; });
  128295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRCameraMetrics"]; });
  128296. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationArcRotateCamera"]; });
  128297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationFreeCamera"]; });
  128298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationGamepadCamera"]; });
  128299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["OnAfterEnteringVRObservableEvent"]; });
  128300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRExperienceHelper"]; });
  128301. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebVRFreeCamera"]; });
  128302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRCamera"]; });
  128303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUIButton"]; });
  128304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUIOptions"]; });
  128305. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUI"]; });
  128306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRState"]; });
  128307. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRExperienceHelper"]; });
  128308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRController"]; });
  128309. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRInput"]; });
  128310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRManagedOutputCanvas"]; });
  128311. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRSessionManager"]; });
  128312. /* harmony import */ var _Collisions_index__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Collisions/index */ "./Collisions/index.ts");
  128313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["Collider"]; });
  128314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["DefaultCollisionCoordinator"]; });
  128315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["PickingInfo"]; });
  128316. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["IntersectionInfo"]; });
  128317. /* harmony import */ var _Culling_index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Culling/index */ "./Culling/index.ts");
  128318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingBox"]; });
  128319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"]; });
  128320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingSphere"]; });
  128321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["Ray"]; });
  128322. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["Octree"]; });
  128323. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["OctreeBlock"]; });
  128324. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["OctreeSceneComponent"]; });
  128325. /* harmony import */ var _Debug_index__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Debug/index */ "./Debug/index.ts");
  128326. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["AxesViewer"]; });
  128327. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["BoneAxesViewer"]; });
  128328. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["DebugLayer"]; });
  128329. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["PhysicsViewer"]; });
  128330. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["RayHelper"]; });
  128331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["SkeletonViewer"]; });
  128332. /* harmony import */ var _Engines_index__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Engines/index */ "./Engines/index.ts");
  128333. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["Constants"]; });
  128334. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["InstancingAttributeInfo"]; });
  128335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["DepthTextureCreationOptions"]; });
  128336. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["EngineCapabilities"]; });
  128337. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["Engine"]; });
  128338. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["EngineStore"]; });
  128339. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["NullEngineOptions"]; });
  128340. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["NullEngine"]; });
  128341. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["_OcclusionDataStorage"]; });
  128342. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["_forceTransformFeedbackToBundle"]; });
  128343. /* harmony import */ var _Events_index__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Events/index */ "./Events/index.ts");
  128344. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardEventTypes"]; });
  128345. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardInfo"]; });
  128346. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardInfoPre"]; });
  128347. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerEventTypes"]; });
  128348. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfoBase"]; });
  128349. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfoPre"]; });
  128350. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfo"]; });
  128351. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["ClipboardEventTypes"]; });
  128352. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["ClipboardInfo"]; });
  128353. /* harmony import */ var _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Gamepads/index */ "./Gamepads/index.ts");
  128354. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["StickValues"]; });
  128355. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Gamepad"]; });
  128356. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GenericPad"]; });
  128357. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GamepadManager"]; });
  128358. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GamepadSystemSceneComponent"]; });
  128359. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"]; });
  128360. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Dpad"]; });
  128361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Pad"]; });
  128362. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["DaydreamController"]; });
  128363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GearVRController"]; });
  128364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GenericController"]; });
  128365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["OculusTouchController"]; });
  128366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledControllerType"]; });
  128367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledControllerHelper"]; });
  128368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledController"]; });
  128369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["ViveController"]; });
  128370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["WebVRController"]; });
  128371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["WindowsMotionController"]; });
  128372. /* harmony import */ var _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Gizmos/index */ "./Gizmos/index.ts");
  128373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["AxisDragGizmo"]; });
  128374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["AxisScaleGizmo"]; });
  128375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["BoundingBoxGizmo"]; });
  128376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["Gizmo"]; });
  128377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["GizmoManager"]; });
  128378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["PlaneRotationGizmo"]; });
  128379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["PositionGizmo"]; });
  128380. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["RotationGizmo"]; });
  128381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["ScaleGizmo"]; });
  128382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["LightGizmo"]; });
  128383. /* harmony import */ var _Helpers_index__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Helpers/index */ "./Helpers/index.ts");
  128384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["EnvironmentHelper"]; });
  128385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["PhotoDome"]; });
  128386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["_forceSceneHelpersToBundle"]; });
  128387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["VideoDome"]; });
  128388. /* harmony import */ var _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Instrumentation/index */ "./Instrumentation/index.ts");
  128389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["EngineInstrumentation"]; });
  128390. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["SceneInstrumentation"]; });
  128391. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["_TimeToken"]; });
  128392. /* harmony import */ var _Layers_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Layers/index */ "./Layers/index.ts");
  128393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["EffectLayer"]; });
  128394. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["EffectLayerSceneComponent"]; });
  128395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["GlowLayer"]; });
  128396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["HighlightLayer"]; });
  128397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["Layer"]; });
  128398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["LayerSceneComponent"]; });
  128399. /* harmony import */ var _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./LensFlares/index */ "./LensFlares/index.ts");
  128400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlare"]; });
  128401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlareSystem"]; });
  128402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlareSystemSceneComponent"]; });
  128403. /* harmony import */ var _Lights_index__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./Lights/index */ "./Lights/index.ts");
  128404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["Light"]; });
  128405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowLight"]; });
  128406. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["DirectionalLight"]; });
  128407. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["HemisphericLight"]; });
  128408. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["PointLight"]; });
  128409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["SpotLight"]; });
  128410. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowGenerator"]; });
  128411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowGeneratorSceneComponent"]; });
  128412. /* harmony import */ var _Loading_index__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./Loading/index */ "./Loading/index.ts");
  128413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["DefaultLoadingScreen"]; });
  128414. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoaderProgressEvent"]; });
  128415. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoader"]; });
  128416. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoaderFlags"]; });
  128417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["_BabylonLoaderRegistered"]; });
  128418. /* harmony import */ var _Materials_index__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./Materials/index */ "./Materials/index.ts");
  128419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ColorCurves"]; });
  128420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EffectFallbacks"]; });
  128421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EffectCreationOptions"]; });
  128422. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Effect"]; });
  128423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["FresnelParameters"]; });
  128424. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ImageProcessingConfigurationDefines"]; });
  128425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ImageProcessingConfiguration"]; });
  128426. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Material"]; });
  128427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialDefines"]; });
  128428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialHelper"]; });
  128429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MultiMaterial"]; });
  128430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PushMaterial"]; });
  128431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ShaderMaterial"]; });
  128432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["StandardMaterialDefines"]; });
  128433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["StandardMaterial"]; });
  128434. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["BaseTexture"]; });
  128435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["CubeTexture"]; });
  128436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["DynamicTexture"]; });
  128437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["InternalTexture"]; });
  128438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MirrorTexture"]; });
  128439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawTexture"]; });
  128440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RenderTargetTexture"]; });
  128441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Texture"]; });
  128442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["UniformBuffer"]; });
  128443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialFlags"]; });
  128444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["BackgroundMaterial"]; });
  128445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRBaseMaterial"]; });
  128446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRBaseSimpleMaterial"]; });
  128447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRMaterial"]; });
  128448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRMetallicRoughnessMaterial"]; });
  128449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRSpecularGlossinessMaterial"]; });
  128450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ColorGradingTexture"]; });
  128451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["HDRCubeTexture"]; });
  128452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["DummyInternalTextureTracker"]; });
  128453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MultiRenderTarget"]; });
  128454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawCubeTexture"]; });
  128455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawTexture3D"]; });
  128456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RefractionTexture"]; });
  128457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["VideoTexture"]; });
  128458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_DDSTextureLoader"]; });
  128459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_ENVTextureLoader"]; });
  128460. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_KTXTextureLoader"]; });
  128461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_TGATextureLoader"]; });
  128462. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["CustomProceduralTexture"]; });
  128463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["NoiseProceduralTexture"]; });
  128464. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ProceduralTexture"]; });
  128465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ProceduralTextureSceneComponent"]; });
  128466. /* harmony import */ var _Maths_index__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./Maths/index */ "./Maths/index.ts");
  128467. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Scalar"]; });
  128468. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["ToGammaSpace"]; });
  128469. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["ToLinearSpace"]; });
  128470. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Epsilon"]; });
  128471. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Color3"]; });
  128472. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Color4"]; });
  128473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector2"]; });
  128474. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector3"]; });
  128475. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector4"]; });
  128476. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Size"]; });
  128477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Quaternion"]; });
  128478. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Matrix"]; });
  128479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Plane"]; });
  128480. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Viewport"]; });
  128481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Frustum"]; });
  128482. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Space"]; });
  128483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Axis"]; });
  128484. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["BezierCurve"]; });
  128485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Orientation"]; });
  128486. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Angle"]; });
  128487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Arc2"]; });
  128488. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Path2"]; });
  128489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Path3D"]; });
  128490. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Curve3"]; });
  128491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["PositionNormalVertex"]; });
  128492. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["PositionNormalTextureVertex"]; });
  128493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Tmp"]; });
  128494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["SphericalPolynomial"]; });
  128495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["SphericalHarmonics"]; });
  128496. /* harmony import */ var _Meshes_index__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./Meshes/index */ "./Meshes/index.ts");
  128497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["AbstractMesh"]; });
  128498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Buffer"]; });
  128499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["VertexBuffer"]; });
  128500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["CSG"]; });
  128501. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Geometry"]; });
  128502. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["GroundMesh"]; });
  128503. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TrailMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TrailMesh"]; });
  128504. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["InstancedMesh"]; });
  128505. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LinesMesh"]; });
  128506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["InstancedLinesMesh"]; });
  128507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["MeshLODLevel"]; });
  128508. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["_CreationDataStorage"]; });
  128509. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["_InstancesBatch"]; });
  128510. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Mesh"]; });
  128511. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["VertexData"]; });
  128512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["MeshBuilder"]; });
  128513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationSettings"]; });
  128514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationQueue"]; });
  128515. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationType"]; });
  128516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplicationQueueSceneComponent"]; });
  128517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Polygon"]; });
  128518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolygonMeshBuilder"]; });
  128519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["BaseSubMesh"]; });
  128520. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SubMesh"]; });
  128521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TransformNode"]; });
  128522. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["BoxBuilder"]; });
  128523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SphereBuilder"]; });
  128524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["CylinderBuilder"]; });
  128525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TorusBuilder"]; });
  128526. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LinesBuilder"]; });
  128527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PlaneBuilder"]; });
  128528. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["GroundBuilder"]; });
  128529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DracoCompression"]; });
  128530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DiscBuilder"]; });
  128531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["RibbonBuilder"]; });
  128532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TorusKnotBuilder"]; });
  128533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolygonBuilder"]; });
  128534. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["ShapeBuilder"]; });
  128535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LatheBuilder"]; });
  128536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TubeBuilder"]; });
  128537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolyhedronBuilder"]; });
  128538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["IcoSphereBuilder"]; });
  128539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DecalBuilder"]; });
  128540. /* harmony import */ var _Morph_index__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./Morph/index */ "./Morph/index.ts");
  128541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _Morph_index__WEBPACK_IMPORTED_MODULE_24__["MorphTarget"]; });
  128542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _Morph_index__WEBPACK_IMPORTED_MODULE_24__["MorphTargetManager"]; });
  128543. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./node */ "./node.ts");
  128544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return _node__WEBPACK_IMPORTED_MODULE_25__["Node"]; });
  128545. /* harmony import */ var _Offline_index__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./Offline/index */ "./Offline/index.ts");
  128546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _Offline_index__WEBPACK_IMPORTED_MODULE_26__["Database"]; });
  128547. /* harmony import */ var _Particles_index__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./Particles/index */ "./Particles/index.ts");
  128548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["BaseParticleSystem"]; });
  128549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["GPUParticleSystem"]; });
  128550. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["Particle"]; });
  128551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleHelper"]; });
  128552. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleSystem"]; });
  128553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["_IDoNeedToBeInTheBuild"]; });
  128554. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleSystemSet"]; });
  128555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SolidParticle"]; });
  128556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ModelShape"]; });
  128557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["DepthSortedParticle"]; });
  128558. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SolidParticleSystem"]; });
  128559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SubEmitterType"]; });
  128560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SubEmitter"]; });
  128561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["BoxParticleEmitter"]; });
  128562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ConeParticleEmitter"]; });
  128563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["CylinderParticleEmitter"]; });
  128564. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["CylinderDirectedParticleEmitter"]; });
  128565. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["HemisphericParticleEmitter"]; });
  128566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["PointParticleEmitter"]; });
  128567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SphereParticleEmitter"]; });
  128568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SphereDirectedParticleEmitter"]; });
  128569. /* harmony import */ var _Physics_index__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./Physics/index */ "./Physics/index.ts");
  128570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsEngine"]; });
  128571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsEngineSceneComponent"]; });
  128572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsHelper"]; });
  128573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEvent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsRadialExplosionEvent"]; });
  128574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsGravitationalFieldEvent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsGravitationalFieldEvent"]; });
  128575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEvent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsUpdraftEvent"]; });
  128576. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEvent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsVortexEvent"]; });
  128577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsRadialImpulseFalloff"]; });
  128578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsUpdraftMode"]; });
  128579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsImpostor"]; });
  128580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsJoint"]; });
  128581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["DistanceJoint"]; });
  128582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["MotorEnabledJoint"]; });
  128583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["HingeJoint"]; });
  128584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["Hinge2Joint"]; });
  128585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["CannonJSPlugin"]; });
  128586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["AmmoJSPlugin"]; });
  128587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["OimoJSPlugin"]; });
  128588. /* harmony import */ var _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./PostProcesses/index */ "./PostProcesses/index.ts");
  128589. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["AnaglyphPostProcess"]; });
  128590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BlackAndWhitePostProcess"]; });
  128591. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BloomEffect"]; });
  128592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BloomMergePostProcess"]; });
  128593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BlurPostProcess"]; });
  128594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ChromaticAberrationPostProcess"]; });
  128595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["CircleOfConfusionPostProcess"]; });
  128596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ColorCorrectionPostProcess"]; });
  128597. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ConvolutionPostProcess"]; });
  128598. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldBlurPostProcess"]; });
  128599. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldEffectBlurLevel"]; });
  128600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldEffect"]; });
  128601. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldMergePostProcessOptions"]; });
  128602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldMergePostProcess"]; });
  128603. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DisplayPassPostProcess"]; });
  128604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ExtractHighlightsPostProcess"]; });
  128605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["FilterPostProcess"]; });
  128606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["FxaaPostProcess"]; });
  128607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["GrainPostProcess"]; });
  128608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["HighlightsPostProcess"]; });
  128609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ImageProcessingPostProcess"]; });
  128610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["MotionBlurPostProcess"]; });
  128611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PassPostProcess"]; });
  128612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PassCubePostProcess"]; });
  128613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcess"]; });
  128614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessManager"]; });
  128615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["RefractionPostProcess"]; });
  128616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SharpenPostProcess"]; });
  128617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["StereoscopicInterlacePostProcess"]; });
  128618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["TonemappingOperator"]; });
  128619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["TonemapPostProcess"]; });
  128620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["VolumetricLightScatteringPostProcess"]; });
  128621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["VRDistortionCorrectionPostProcess"]; });
  128622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderEffect"]; });
  128623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipeline"]; });
  128624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipelineManager"]; });
  128625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipelineManagerSceneComponent"]; });
  128626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DefaultRenderingPipeline"]; });
  128627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["LensRenderingPipeline"]; });
  128628. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SSAO2RenderingPipeline"]; });
  128629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SSAORenderingPipeline"]; });
  128630. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["StandardRenderingPipeline"]; });
  128631. /* harmony import */ var _Probes_index__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./Probes/index */ "./Probes/index.ts");
  128632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _Probes_index__WEBPACK_IMPORTED_MODULE_30__["ReflectionProbe"]; });
  128633. /* harmony import */ var _Rendering_index__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./Rendering/index */ "./Rendering/index.ts");
  128634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["BoundingBoxRenderer"]; });
  128635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["DepthRenderer"]; });
  128636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["DepthRendererSceneComponent"]; });
  128637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["EdgesRenderer"]; });
  128638. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["LineEdgesRenderer"]; });
  128639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["GeometryBufferRenderer"]; });
  128640. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["GeometryBufferRendererSceneComponent"]; });
  128641. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["OutlineRenderer"]; });
  128642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingGroup"]; });
  128643. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingGroupInfo"]; });
  128644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingManager"]; });
  128645. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["UtilityLayerRenderer"]; });
  128646. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./scene */ "./scene.ts");
  128647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return _scene__WEBPACK_IMPORTED_MODULE_32__["Scene"]; });
  128648. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ./sceneComponent */ "./sceneComponent.ts");
  128649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return _sceneComponent__WEBPACK_IMPORTED_MODULE_33__["SceneComponentConstants"]; });
  128650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return _sceneComponent__WEBPACK_IMPORTED_MODULE_33__["Stage"]; });
  128651. /* harmony import */ var _Sprites_index__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! ./Sprites/index */ "./Sprites/index.ts");
  128652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["Sprite"]; });
  128653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["SpriteManager"]; });
  128654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["SpriteSceneComponent"]; });
  128655. /* harmony import */ var _States_index__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ./States/index */ "./States/index.ts");
  128656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_AlphaState"]; });
  128657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_DepthCullingState"]; });
  128658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_StencilState"]; });
  128659. /* harmony import */ var _Misc_index__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ./Misc/index */ "./Misc/index.ts");
  128660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AndOrNotEvaluator"]; });
  128661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetTaskState"]; });
  128662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AbstractAssetTask"]; });
  128663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetsProgressEvent"]; });
  128664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MeshAssetTask"]; });
  128665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextFileAssetTask"]; });
  128666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["BinaryFileAssetTask"]; });
  128667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ImageAssetTask"]; });
  128668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureAssetTask"]; });
  128669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CubeTextureAssetTask"]; });
  128670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HDRCubeTextureAssetTask"]; });
  128671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetsManager"]; });
  128672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["DDSTools"]; });
  128673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["expandToProperty"]; });
  128674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serialize"]; });
  128675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsTexture"]; });
  128676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColor3"]; });
  128677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsFresnelParameters"]; });
  128678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsVector2"]; });
  128679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsVector3"]; });
  128680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsMeshReference"]; });
  128681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColorCurves"]; });
  128682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColor4"]; });
  128683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsImageProcessingConfiguration"]; });
  128684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsQuaternion"]; });
  128685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsCameraReference"]; });
  128686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SerializationHelper"]; });
  128687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Deferred"]; });
  128688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["EnvironmentTextureTools"]; });
  128689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FilesInput"]; });
  128690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["KhronosTextureContainer"]; });
  128691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["EventState"]; });
  128692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Observer"]; });
  128693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MultiObserver"]; });
  128694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Observable"]; });
  128695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PerformanceMonitor"]; });
  128696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RollingAverage"]; });
  128697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PromisePolyfill"]; });
  128698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimization"]; });
  128699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureOptimization"]; });
  128700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HardwareScalingOptimization"]; });
  128701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ShadowsOptimization"]; });
  128702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PostProcessesOptimization"]; });
  128703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["LensFlaresOptimization"]; });
  128704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CustomOptimization"]; });
  128705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ParticlesOptimization"]; });
  128706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RenderTargetsOptimization"]; });
  128707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MergeMeshesOptimization"]; });
  128708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimizerOptions"]; });
  128709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimizer"]; });
  128710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneSerializer"]; });
  128711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SmartArray"]; });
  128712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SmartArrayNoDuplicate"]; });
  128713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["StringDictionary"]; });
  128714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Tags"]; });
  128715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureTools"]; });
  128716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TGATools"]; });
  128717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ColorGradient"]; });
  128718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Color3Gradient"]; });
  128719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FactorGradient"]; });
  128720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["LoadFileError"]; });
  128721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RetryStrategy"]; });
  128722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Tools"]; });
  128723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PerfCounter"]; });
  128724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["className"]; });
  128725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AsyncLoop"]; });
  128726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["VideoRecorder"]; });
  128727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["JoystickAxis"]; });
  128728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["VirtualJoystick"]; });
  128729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["WorkerPool"]; });
  128730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Logger"]; });
  128731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["_TypeStore"]; });
  128732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FilesInputStore"]; });
  128733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["DeepCopier"]; });
  128734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PivotTools"]; });
  128735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PrecisionDate"]; });
  128736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ScreenshotTools"]; });
  128737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CubeMapToSphericalPolynomialTools"]; });
  128738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HDRTools"]; });
  128739. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PanoramaToCubeMapTools"]; });
  128740. /***/ }),
  128741. /***/ "./node.ts":
  128742. /*!*****************!*\
  128743. !*** ./node.ts ***!
  128744. \*****************/
  128745. /*! exports provided: Node */
  128746. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128747. "use strict";
  128748. __webpack_require__.r(__webpack_exports__);
  128749. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return Node; });
  128750. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  128751. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Maths/math */ "./Maths/math.ts");
  128752. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Misc/decorators */ "./Misc/decorators.ts");
  128753. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Misc/observable */ "./Misc/observable.ts");
  128754. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Engines/engineStore */ "./Engines/engineStore.ts");
  128755. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Misc/devTools */ "./Misc/devTools.ts");
  128756. /**
  128757. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  128758. */
  128759. var Node = /** @class */ (function () {
  128760. /**
  128761. * Creates a new Node
  128762. * @param name the name and id to be given to this node
  128763. * @param scene the scene this node will be added to
  128764. * @param addToRootNodes the node will be added to scene.rootNodes
  128765. */
  128766. function Node(name, scene, addToRootNodes) {
  128767. if (scene === void 0) { scene = null; }
  128768. if (addToRootNodes === void 0) { addToRootNodes = true; }
  128769. /**
  128770. * Gets or sets a string used to store user defined state for the node
  128771. */
  128772. this.state = "";
  128773. /**
  128774. * Gets or sets an object used to store user defined information for the node
  128775. */
  128776. this.metadata = null;
  128777. /**
  128778. * For internal use only. Please do not use.
  128779. */
  128780. this.reservedDataStore = null;
  128781. /**
  128782. * Gets or sets a boolean used to define if the node must be serialized
  128783. */
  128784. this.doNotSerialize = false;
  128785. /** @hidden */
  128786. this._isDisposed = false;
  128787. /**
  128788. * Gets a list of Animations associated with the node
  128789. */
  128790. this.animations = new Array();
  128791. this._ranges = {};
  128792. this._isEnabled = true;
  128793. this._isParentEnabled = true;
  128794. this._isReady = true;
  128795. /** @hidden */
  128796. this._currentRenderId = -1;
  128797. this._parentRenderId = -1;
  128798. this._childRenderId = -1;
  128799. /** @hidden */
  128800. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  128801. /** @hidden */
  128802. this._worldMatrixDeterminant = 0;
  128803. /** @hidden */
  128804. this._sceneRootNodesIndex = -1;
  128805. this._animationPropertiesOverride = null;
  128806. /** @hidden */
  128807. this._isNode = true;
  128808. /**
  128809. * An event triggered when the mesh is disposed
  128810. */
  128811. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128812. // Behaviors
  128813. this._behaviors = new Array();
  128814. this.name = name;
  128815. this.id = name;
  128816. this._scene = (scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene);
  128817. this.uniqueId = this._scene.getUniqueId();
  128818. this._initCache();
  128819. if (addToRootNodes) {
  128820. this.addToSceneRootNodes();
  128821. }
  128822. }
  128823. /**
  128824. * Add a new node constructor
  128825. * @param type defines the type name of the node to construct
  128826. * @param constructorFunc defines the constructor function
  128827. */
  128828. Node.AddNodeConstructor = function (type, constructorFunc) {
  128829. this._NodeConstructors[type] = constructorFunc;
  128830. };
  128831. /**
  128832. * Returns a node constructor based on type name
  128833. * @param type defines the type name
  128834. * @param name defines the new node name
  128835. * @param scene defines the hosting scene
  128836. * @param options defines optional options to transmit to constructors
  128837. * @returns the new constructor or null
  128838. */
  128839. Node.Construct = function (type, name, scene, options) {
  128840. var constructorFunc = this._NodeConstructors[type];
  128841. if (!constructorFunc) {
  128842. return null;
  128843. }
  128844. return constructorFunc(name, scene, options);
  128845. };
  128846. /**
  128847. * Gets a boolean indicating if the node has been disposed
  128848. * @returns true if the node was disposed
  128849. */
  128850. Node.prototype.isDisposed = function () {
  128851. return this._isDisposed;
  128852. };
  128853. Object.defineProperty(Node.prototype, "parent", {
  128854. get: function () {
  128855. return this._parentNode;
  128856. },
  128857. /**
  128858. * Gets or sets the parent of the node
  128859. */
  128860. set: function (parent) {
  128861. if (this._parentNode === parent) {
  128862. return;
  128863. }
  128864. var previousParentNode = this._parentNode;
  128865. // Remove self from list of children of parent
  128866. if (this._parentNode && this._parentNode._children !== undefined && this._parentNode._children !== null) {
  128867. var index = this._parentNode._children.indexOf(this);
  128868. if (index !== -1) {
  128869. this._parentNode._children.splice(index, 1);
  128870. }
  128871. if (!parent && !this._isDisposed) {
  128872. this.addToSceneRootNodes();
  128873. }
  128874. }
  128875. // Store new parent
  128876. this._parentNode = parent;
  128877. // Add as child to new parent
  128878. if (this._parentNode) {
  128879. if (this._parentNode._children === undefined || this._parentNode._children === null) {
  128880. this._parentNode._children = new Array();
  128881. }
  128882. this._parentNode._children.push(this);
  128883. if (!previousParentNode) {
  128884. this.removeFromSceneRootNodes();
  128885. }
  128886. }
  128887. // Enabled state
  128888. this._syncParentEnabledState();
  128889. },
  128890. enumerable: true,
  128891. configurable: true
  128892. });
  128893. Node.prototype.addToSceneRootNodes = function () {
  128894. if (this._sceneRootNodesIndex === -1) {
  128895. this._sceneRootNodesIndex = this._scene.rootNodes.length;
  128896. this._scene.rootNodes.push(this);
  128897. }
  128898. };
  128899. Node.prototype.removeFromSceneRootNodes = function () {
  128900. if (this._sceneRootNodesIndex !== -1) {
  128901. var rootNodes = this._scene.rootNodes;
  128902. var lastIdx = rootNodes.length - 1;
  128903. rootNodes[this._sceneRootNodesIndex] = rootNodes[lastIdx];
  128904. rootNodes[this._sceneRootNodesIndex]._sceneRootNodesIndex = this._sceneRootNodesIndex;
  128905. this._scene.rootNodes.pop();
  128906. this._sceneRootNodesIndex = -1;
  128907. }
  128908. };
  128909. Object.defineProperty(Node.prototype, "animationPropertiesOverride", {
  128910. /**
  128911. * Gets or sets the animation properties override
  128912. */
  128913. get: function () {
  128914. if (!this._animationPropertiesOverride) {
  128915. return this._scene.animationPropertiesOverride;
  128916. }
  128917. return this._animationPropertiesOverride;
  128918. },
  128919. set: function (value) {
  128920. this._animationPropertiesOverride = value;
  128921. },
  128922. enumerable: true,
  128923. configurable: true
  128924. });
  128925. /**
  128926. * Gets a string idenfifying the name of the class
  128927. * @returns "Node" string
  128928. */
  128929. Node.prototype.getClassName = function () {
  128930. return "Node";
  128931. };
  128932. Object.defineProperty(Node.prototype, "onDispose", {
  128933. /**
  128934. * Sets a callback that will be raised when the node will be disposed
  128935. */
  128936. set: function (callback) {
  128937. if (this._onDisposeObserver) {
  128938. this.onDisposeObservable.remove(this._onDisposeObserver);
  128939. }
  128940. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  128941. },
  128942. enumerable: true,
  128943. configurable: true
  128944. });
  128945. /**
  128946. * Gets the scene of the node
  128947. * @returns a scene
  128948. */
  128949. Node.prototype.getScene = function () {
  128950. return this._scene;
  128951. };
  128952. /**
  128953. * Gets the engine of the node
  128954. * @returns a Engine
  128955. */
  128956. Node.prototype.getEngine = function () {
  128957. return this._scene.getEngine();
  128958. };
  128959. /**
  128960. * Attach a behavior to the node
  128961. * @see http://doc.babylonjs.com/features/behaviour
  128962. * @param behavior defines the behavior to attach
  128963. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  128964. * @returns the current Node
  128965. */
  128966. Node.prototype.addBehavior = function (behavior, attachImmediately) {
  128967. var _this = this;
  128968. if (attachImmediately === void 0) { attachImmediately = false; }
  128969. var index = this._behaviors.indexOf(behavior);
  128970. if (index !== -1) {
  128971. return this;
  128972. }
  128973. behavior.init();
  128974. if (this._scene.isLoading && !attachImmediately) {
  128975. // We defer the attach when the scene will be loaded
  128976. this._scene.onDataLoadedObservable.addOnce(function () {
  128977. behavior.attach(_this);
  128978. });
  128979. }
  128980. else {
  128981. behavior.attach(this);
  128982. }
  128983. this._behaviors.push(behavior);
  128984. return this;
  128985. };
  128986. /**
  128987. * Remove an attached behavior
  128988. * @see http://doc.babylonjs.com/features/behaviour
  128989. * @param behavior defines the behavior to attach
  128990. * @returns the current Node
  128991. */
  128992. Node.prototype.removeBehavior = function (behavior) {
  128993. var index = this._behaviors.indexOf(behavior);
  128994. if (index === -1) {
  128995. return this;
  128996. }
  128997. this._behaviors[index].detach();
  128998. this._behaviors.splice(index, 1);
  128999. return this;
  129000. };
  129001. Object.defineProperty(Node.prototype, "behaviors", {
  129002. /**
  129003. * Gets the list of attached behaviors
  129004. * @see http://doc.babylonjs.com/features/behaviour
  129005. */
  129006. get: function () {
  129007. return this._behaviors;
  129008. },
  129009. enumerable: true,
  129010. configurable: true
  129011. });
  129012. /**
  129013. * Gets an attached behavior by name
  129014. * @param name defines the name of the behavior to look for
  129015. * @see http://doc.babylonjs.com/features/behaviour
  129016. * @returns null if behavior was not found else the requested behavior
  129017. */
  129018. Node.prototype.getBehaviorByName = function (name) {
  129019. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  129020. var behavior = _a[_i];
  129021. if (behavior.name === name) {
  129022. return behavior;
  129023. }
  129024. }
  129025. return null;
  129026. };
  129027. /**
  129028. * Returns the latest update of the World matrix
  129029. * @returns a Matrix
  129030. */
  129031. Node.prototype.getWorldMatrix = function () {
  129032. if (this._currentRenderId !== this._scene.getRenderId()) {
  129033. this.computeWorldMatrix();
  129034. }
  129035. return this._worldMatrix;
  129036. };
  129037. /** @hidden */
  129038. Node.prototype._getWorldMatrixDeterminant = function () {
  129039. return this._worldMatrixDeterminant;
  129040. };
  129041. Object.defineProperty(Node.prototype, "worldMatrixFromCache", {
  129042. /**
  129043. * Returns directly the latest state of the mesh World matrix.
  129044. * A Matrix is returned.
  129045. */
  129046. get: function () {
  129047. return this._worldMatrix;
  129048. },
  129049. enumerable: true,
  129050. configurable: true
  129051. });
  129052. // override it in derived class if you add new variables to the cache
  129053. // and call the parent class method
  129054. /** @hidden */
  129055. Node.prototype._initCache = function () {
  129056. this._cache = {};
  129057. this._cache.parent = undefined;
  129058. };
  129059. /** @hidden */
  129060. Node.prototype.updateCache = function (force) {
  129061. if (!force && this.isSynchronized()) {
  129062. return;
  129063. }
  129064. this._cache.parent = this.parent;
  129065. this._updateCache();
  129066. };
  129067. /** @hidden */
  129068. Node.prototype._getActionManagerForTrigger = function (trigger, initialCall) {
  129069. if (initialCall === void 0) { initialCall = true; }
  129070. if (!this.parent) {
  129071. return null;
  129072. }
  129073. return this.parent._getActionManagerForTrigger(trigger, false);
  129074. };
  129075. // override it in derived class if you add new variables to the cache
  129076. // and call the parent class method if !ignoreParentClass
  129077. /** @hidden */
  129078. Node.prototype._updateCache = function (ignoreParentClass) {
  129079. };
  129080. // override it in derived class if you add new variables to the cache
  129081. /** @hidden */
  129082. Node.prototype._isSynchronized = function () {
  129083. return true;
  129084. };
  129085. /** @hidden */
  129086. Node.prototype._markSyncedWithParent = function () {
  129087. if (this._parentNode) {
  129088. this._parentRenderId = this._parentNode._childRenderId;
  129089. }
  129090. };
  129091. /** @hidden */
  129092. Node.prototype.isSynchronizedWithParent = function () {
  129093. if (!this._parentNode) {
  129094. return true;
  129095. }
  129096. if (this._parentRenderId !== this._parentNode._childRenderId) {
  129097. return false;
  129098. }
  129099. return this._parentNode.isSynchronized();
  129100. };
  129101. /** @hidden */
  129102. Node.prototype.isSynchronized = function () {
  129103. if (this._cache.parent != this._parentNode) {
  129104. this._cache.parent = this._parentNode;
  129105. return false;
  129106. }
  129107. if (this._parentNode && !this.isSynchronizedWithParent()) {
  129108. return false;
  129109. }
  129110. return this._isSynchronized();
  129111. };
  129112. /**
  129113. * Is this node ready to be used/rendered
  129114. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  129115. * @return true if the node is ready
  129116. */
  129117. Node.prototype.isReady = function (completeCheck) {
  129118. if (completeCheck === void 0) { completeCheck = false; }
  129119. return this._isReady;
  129120. };
  129121. /**
  129122. * Is this node enabled?
  129123. * 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
  129124. * @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
  129125. * @return whether this node (and its parent) is enabled
  129126. */
  129127. Node.prototype.isEnabled = function (checkAncestors) {
  129128. if (checkAncestors === void 0) { checkAncestors = true; }
  129129. if (checkAncestors === false) {
  129130. return this._isEnabled;
  129131. }
  129132. if (!this._isEnabled) {
  129133. return false;
  129134. }
  129135. return this._isParentEnabled;
  129136. };
  129137. /** @hidden */
  129138. Node.prototype._syncParentEnabledState = function () {
  129139. this._isParentEnabled = this._parentNode ? this._parentNode.isEnabled() : true;
  129140. if (this._children) {
  129141. this._children.forEach(function (c) {
  129142. c._syncParentEnabledState(); // Force children to update accordingly
  129143. });
  129144. }
  129145. };
  129146. /**
  129147. * Set the enabled state of this node
  129148. * @param value defines the new enabled state
  129149. */
  129150. Node.prototype.setEnabled = function (value) {
  129151. this._isEnabled = value;
  129152. this._syncParentEnabledState();
  129153. };
  129154. /**
  129155. * Is this node a descendant of the given node?
  129156. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  129157. * @param ancestor defines the parent node to inspect
  129158. * @returns a boolean indicating if this node is a descendant of the given node
  129159. */
  129160. Node.prototype.isDescendantOf = function (ancestor) {
  129161. if (this.parent) {
  129162. if (this.parent === ancestor) {
  129163. return true;
  129164. }
  129165. return this.parent.isDescendantOf(ancestor);
  129166. }
  129167. return false;
  129168. };
  129169. /** @hidden */
  129170. Node.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  129171. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  129172. if (!this._children) {
  129173. return;
  129174. }
  129175. for (var index = 0; index < this._children.length; index++) {
  129176. var item = this._children[index];
  129177. if (!predicate || predicate(item)) {
  129178. results.push(item);
  129179. }
  129180. if (!directDescendantsOnly) {
  129181. item._getDescendants(results, false, predicate);
  129182. }
  129183. }
  129184. };
  129185. /**
  129186. * Will return all nodes that have this node as ascendant
  129187. * @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
  129188. * @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
  129189. * @return all children nodes of all types
  129190. */
  129191. Node.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  129192. var results = new Array();
  129193. this._getDescendants(results, directDescendantsOnly, predicate);
  129194. return results;
  129195. };
  129196. /**
  129197. * Get all child-meshes of this node
  129198. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  129199. * @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
  129200. * @returns an array of AbstractMesh
  129201. */
  129202. Node.prototype.getChildMeshes = function (directDescendantsOnly, predicate) {
  129203. var results = [];
  129204. this._getDescendants(results, directDescendantsOnly, function (node) {
  129205. return ((!predicate || predicate(node)) && (node.cullingStrategy !== undefined));
  129206. });
  129207. return results;
  129208. };
  129209. /**
  129210. * Get all direct children of this node
  129211. * @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
  129212. * @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)
  129213. * @returns an array of Node
  129214. */
  129215. Node.prototype.getChildren = function (predicate, directDescendantsOnly) {
  129216. if (directDescendantsOnly === void 0) { directDescendantsOnly = true; }
  129217. return this.getDescendants(directDescendantsOnly, predicate);
  129218. };
  129219. /** @hidden */
  129220. Node.prototype._setReady = function (state) {
  129221. if (state === this._isReady) {
  129222. return;
  129223. }
  129224. if (!state) {
  129225. this._isReady = false;
  129226. return;
  129227. }
  129228. if (this.onReady) {
  129229. this.onReady(this);
  129230. }
  129231. this._isReady = true;
  129232. };
  129233. /**
  129234. * Get an animation by name
  129235. * @param name defines the name of the animation to look for
  129236. * @returns null if not found else the requested animation
  129237. */
  129238. Node.prototype.getAnimationByName = function (name) {
  129239. for (var i = 0; i < this.animations.length; i++) {
  129240. var animation = this.animations[i];
  129241. if (animation.name === name) {
  129242. return animation;
  129243. }
  129244. }
  129245. return null;
  129246. };
  129247. /**
  129248. * Creates an animation range for this node
  129249. * @param name defines the name of the range
  129250. * @param from defines the starting key
  129251. * @param to defines the end key
  129252. */
  129253. Node.prototype.createAnimationRange = function (name, from, to) {
  129254. // check name not already in use
  129255. if (!this._ranges[name]) {
  129256. this._ranges[name] = Node._AnimationRangeFactory(name, from, to);
  129257. for (var i = 0, nAnimations = this.animations.length; i < nAnimations; i++) {
  129258. if (this.animations[i]) {
  129259. this.animations[i].createRange(name, from, to);
  129260. }
  129261. }
  129262. }
  129263. };
  129264. /**
  129265. * Delete a specific animation range
  129266. * @param name defines the name of the range to delete
  129267. * @param deleteFrames defines if animation frames from the range must be deleted as well
  129268. */
  129269. Node.prototype.deleteAnimationRange = function (name, deleteFrames) {
  129270. if (deleteFrames === void 0) { deleteFrames = true; }
  129271. for (var i = 0, nAnimations = this.animations.length; i < nAnimations; i++) {
  129272. if (this.animations[i]) {
  129273. this.animations[i].deleteRange(name, deleteFrames);
  129274. }
  129275. }
  129276. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  129277. };
  129278. /**
  129279. * Get an animation range by name
  129280. * @param name defines the name of the animation range to look for
  129281. * @returns null if not found else the requested animation range
  129282. */
  129283. Node.prototype.getAnimationRange = function (name) {
  129284. return this._ranges[name];
  129285. };
  129286. /**
  129287. * Gets the list of all animation ranges defined on this node
  129288. * @returns an array
  129289. */
  129290. Node.prototype.getAnimationRanges = function () {
  129291. var animationRanges = [];
  129292. var name;
  129293. for (name in this._ranges) {
  129294. animationRanges.push(this._ranges[name]);
  129295. }
  129296. return animationRanges;
  129297. };
  129298. /**
  129299. * Will start the animation sequence
  129300. * @param name defines the range frames for animation sequence
  129301. * @param loop defines if the animation should loop (false by default)
  129302. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  129303. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  129304. * @returns the object created for this animation. If range does not exist, it will return null
  129305. */
  129306. Node.prototype.beginAnimation = function (name, loop, speedRatio, onAnimationEnd) {
  129307. var range = this.getAnimationRange(name);
  129308. if (!range) {
  129309. return null;
  129310. }
  129311. return this._scene.beginAnimation(this, range.from, range.to, loop, speedRatio, onAnimationEnd);
  129312. };
  129313. /**
  129314. * Serialize animation ranges into a JSON compatible object
  129315. * @returns serialization object
  129316. */
  129317. Node.prototype.serializeAnimationRanges = function () {
  129318. var serializationRanges = [];
  129319. for (var name in this._ranges) {
  129320. var localRange = this._ranges[name];
  129321. if (!localRange) {
  129322. continue;
  129323. }
  129324. var range = {};
  129325. range.name = name;
  129326. range.from = localRange.from;
  129327. range.to = localRange.to;
  129328. serializationRanges.push(range);
  129329. }
  129330. return serializationRanges;
  129331. };
  129332. /**
  129333. * Computes the world matrix of the node
  129334. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  129335. * @returns the world matrix
  129336. */
  129337. Node.prototype.computeWorldMatrix = function (force) {
  129338. if (!this._worldMatrix) {
  129339. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  129340. }
  129341. return this._worldMatrix;
  129342. };
  129343. /**
  129344. * Releases resources associated with this node.
  129345. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  129346. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  129347. */
  129348. Node.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  129349. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  129350. this._isDisposed = true;
  129351. if (!doNotRecurse) {
  129352. var nodes = this.getDescendants(true);
  129353. for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
  129354. var node = nodes_1[_i];
  129355. node.dispose(doNotRecurse, disposeMaterialAndTextures);
  129356. }
  129357. }
  129358. if (!this.parent) {
  129359. this.removeFromSceneRootNodes();
  129360. }
  129361. else {
  129362. this.parent = null;
  129363. }
  129364. // Callback
  129365. this.onDisposeObservable.notifyObservers(this);
  129366. this.onDisposeObservable.clear();
  129367. // Behaviors
  129368. for (var _a = 0, _b = this._behaviors; _a < _b.length; _a++) {
  129369. var behavior = _b[_a];
  129370. behavior.detach();
  129371. }
  129372. this._behaviors = [];
  129373. };
  129374. /**
  129375. * Parse animation range data from a serialization object and store them into a given node
  129376. * @param node defines where to store the animation ranges
  129377. * @param parsedNode defines the serialization object to read data from
  129378. * @param scene defines the hosting scene
  129379. */
  129380. Node.ParseAnimationRanges = function (node, parsedNode, scene) {
  129381. if (parsedNode.ranges) {
  129382. for (var index = 0; index < parsedNode.ranges.length; index++) {
  129383. var data = parsedNode.ranges[index];
  129384. node.createAnimationRange(data.name, data.from, data.to);
  129385. }
  129386. }
  129387. };
  129388. /** @hidden */
  129389. Node._AnimationRangeFactory = function (name, from, to) {
  129390. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__["_DevTools"].WarnImport("AnimationRange");
  129391. };
  129392. Node._NodeConstructors = {};
  129393. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  129394. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  129395. ], Node.prototype, "name", void 0);
  129396. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  129397. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  129398. ], Node.prototype, "id", void 0);
  129399. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  129400. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  129401. ], Node.prototype, "uniqueId", void 0);
  129402. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  129403. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  129404. ], Node.prototype, "state", void 0);
  129405. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  129406. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  129407. ], Node.prototype, "metadata", void 0);
  129408. return Node;
  129409. }());
  129410. /***/ }),
  129411. /***/ "./scene.ts":
  129412. /*!******************!*\
  129413. !*** ./scene.ts ***!
  129414. \******************/
  129415. /*! exports provided: Scene */
  129416. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129417. "use strict";
  129418. __webpack_require__.r(__webpack_exports__);
  129419. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return Scene; });
  129420. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  129421. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Misc/tools */ "./Misc/tools.ts");
  129422. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Misc/precisionDate */ "./Misc/precisionDate.ts");
  129423. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Misc/observable */ "./Misc/observable.ts");
  129424. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Misc/smartArray */ "./Misc/smartArray.ts");
  129425. /* harmony import */ var _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Misc/stringDictionary */ "./Misc/stringDictionary.ts");
  129426. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Misc/tags */ "./Misc/tags.ts");
  129427. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Maths/math */ "./Maths/math.ts");
  129428. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  129429. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Cameras/camera */ "./Cameras/camera.ts");
  129430. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  129431. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  129432. /* harmony import */ var _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Materials/uniformBuffer */ "./Materials/uniformBuffer.ts");
  129433. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Lights/light */ "./Lights/light.ts");
  129434. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  129435. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Events/pointerEvents */ "./Events/pointerEvents.ts");
  129436. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  129437. /* harmony import */ var _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Actions/actionEvent */ "./Actions/actionEvent.ts");
  129438. /* harmony import */ var _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./PostProcesses/postProcessManager */ "./PostProcesses/postProcessManager.ts");
  129439. /* harmony import */ var _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./Rendering/renderingManager */ "./Rendering/renderingManager.ts");
  129440. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sceneComponent */ "./sceneComponent.ts");
  129441. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./Engines/constants */ "./Engines/constants.ts");
  129442. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./Misc/domManagement */ "./Misc/domManagement.ts");
  129443. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./Misc/logger */ "./Misc/logger.ts");
  129444. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./Engines/engineStore */ "./Engines/engineStore.ts");
  129445. /* harmony import */ var _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./Actions/abstractActionManager */ "./Actions/abstractActionManager.ts");
  129446. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./Misc/devTools */ "./Misc/devTools.ts");
  129447. /** @hidden */
  129448. var ClickInfo = /** @class */ (function () {
  129449. function ClickInfo() {
  129450. this._singleClick = false;
  129451. this._doubleClick = false;
  129452. this._hasSwiped = false;
  129453. this._ignore = false;
  129454. }
  129455. Object.defineProperty(ClickInfo.prototype, "singleClick", {
  129456. get: function () {
  129457. return this._singleClick;
  129458. },
  129459. set: function (b) {
  129460. this._singleClick = b;
  129461. },
  129462. enumerable: true,
  129463. configurable: true
  129464. });
  129465. Object.defineProperty(ClickInfo.prototype, "doubleClick", {
  129466. get: function () {
  129467. return this._doubleClick;
  129468. },
  129469. set: function (b) {
  129470. this._doubleClick = b;
  129471. },
  129472. enumerable: true,
  129473. configurable: true
  129474. });
  129475. Object.defineProperty(ClickInfo.prototype, "hasSwiped", {
  129476. get: function () {
  129477. return this._hasSwiped;
  129478. },
  129479. set: function (b) {
  129480. this._hasSwiped = b;
  129481. },
  129482. enumerable: true,
  129483. configurable: true
  129484. });
  129485. Object.defineProperty(ClickInfo.prototype, "ignore", {
  129486. get: function () {
  129487. return this._ignore;
  129488. },
  129489. set: function (b) {
  129490. this._ignore = b;
  129491. },
  129492. enumerable: true,
  129493. configurable: true
  129494. });
  129495. return ClickInfo;
  129496. }());
  129497. /**
  129498. * Represents a scene to be rendered by the engine.
  129499. * @see http://doc.babylonjs.com/features/scene
  129500. */
  129501. var Scene = /** @class */ (function (_super) {
  129502. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Scene, _super);
  129503. /**
  129504. * Creates a new Scene
  129505. * @param engine defines the engine to use to render this scene
  129506. * @param options defines the scene options
  129507. */
  129508. function Scene(engine, options) {
  129509. var _this = _super.call(this) || this;
  129510. // Members
  129511. /** @hidden */
  129512. _this._isScene = true;
  129513. /**
  129514. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  129515. */
  129516. _this.autoClear = true;
  129517. /**
  129518. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  129519. */
  129520. _this.autoClearDepthAndStencil = true;
  129521. /**
  129522. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  129523. */
  129524. _this.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color4"](0.2, 0.2, 0.3, 1.0);
  129525. /**
  129526. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  129527. */
  129528. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color3"](0, 0, 0);
  129529. _this._forceWireframe = false;
  129530. _this._forcePointsCloud = false;
  129531. /**
  129532. * Gets or sets a boolean indicating if animations are enabled
  129533. */
  129534. _this.animationsEnabled = true;
  129535. _this._animationPropertiesOverride = null;
  129536. /**
  129537. * Gets or sets a boolean indicating if a constant deltatime has to be used
  129538. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  129539. */
  129540. _this.useConstantAnimationDeltaTime = false;
  129541. /**
  129542. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  129543. * Please note that it requires to run a ray cast through the scene on every frame
  129544. */
  129545. _this.constantlyUpdateMeshUnderPointer = false;
  129546. /**
  129547. * Defines the HTML cursor to use when hovering over interactive elements
  129548. */
  129549. _this.hoverCursor = "pointer";
  129550. /**
  129551. * Defines the HTML default cursor to use (empty by default)
  129552. */
  129553. _this.defaultCursor = "";
  129554. /**
  129555. * This is used to call preventDefault() on pointer down
  129556. * in order to block unwanted artifacts like system double clicks
  129557. */
  129558. _this.preventDefaultOnPointerDown = true;
  129559. /**
  129560. * This is used to call preventDefault() on pointer up
  129561. * in order to block unwanted artifacts like system double clicks
  129562. */
  129563. _this.preventDefaultOnPointerUp = true;
  129564. // Metadata
  129565. /**
  129566. * Gets or sets user defined metadata
  129567. */
  129568. _this.metadata = null;
  129569. /**
  129570. * For internal use only. Please do not use.
  129571. */
  129572. _this.reservedDataStore = null;
  129573. /**
  129574. * Use this array to add regular expressions used to disable offline support for specific urls
  129575. */
  129576. _this.disableOfflineSupportExceptionRules = new Array();
  129577. /**
  129578. * An event triggered when the scene is disposed.
  129579. */
  129580. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  129581. _this._onDisposeObserver = null;
  129582. /**
  129583. * An event triggered before rendering the scene (right after animations and physics)
  129584. */
  129585. _this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  129586. _this._onBeforeRenderObserver = null;
  129587. /**
  129588. * An event triggered after rendering the scene
  129589. */
  129590. _this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  129591. _this._onAfterRenderObserver = null;
  129592. /**
  129593. * An event triggered before animating the scene
  129594. */
  129595. _this.onBeforeAnimationsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  129596. /**
  129597. * An event triggered after animations processing
  129598. */
  129599. _this.onAfterAnimationsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  129600. /**
  129601. * An event triggered before draw calls are ready to be sent
  129602. */
  129603. _this.onBeforeDrawPhaseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  129604. /**
  129605. * An event triggered after draw calls have been sent
  129606. */
  129607. _this.onAfterDrawPhaseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  129608. /**
  129609. * An event triggered when the scene is ready
  129610. */
  129611. _this.onReadyObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  129612. /**
  129613. * An event triggered before rendering a camera
  129614. */
  129615. _this.onBeforeCameraRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  129616. _this._onBeforeCameraRenderObserver = null;
  129617. /**
  129618. * An event triggered after rendering a camera
  129619. */
  129620. _this.onAfterCameraRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  129621. _this._onAfterCameraRenderObserver = null;
  129622. /**
  129623. * An event triggered when active meshes evaluation is about to start
  129624. */
  129625. _this.onBeforeActiveMeshesEvaluationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  129626. /**
  129627. * An event triggered when active meshes evaluation is done
  129628. */
  129629. _this.onAfterActiveMeshesEvaluationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  129630. /**
  129631. * An event triggered when particles rendering is about to start
  129632. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  129633. */
  129634. _this.onBeforeParticlesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  129635. /**
  129636. * An event triggered when particles rendering is done
  129637. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  129638. */
  129639. _this.onAfterParticlesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  129640. /**
  129641. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  129642. */
  129643. _this.onDataLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  129644. /**
  129645. * An event triggered when a camera is created
  129646. */
  129647. _this.onNewCameraAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  129648. /**
  129649. * An event triggered when a camera is removed
  129650. */
  129651. _this.onCameraRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  129652. /**
  129653. * An event triggered when a light is created
  129654. */
  129655. _this.onNewLightAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  129656. /**
  129657. * An event triggered when a light is removed
  129658. */
  129659. _this.onLightRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  129660. /**
  129661. * An event triggered when a geometry is created
  129662. */
  129663. _this.onNewGeometryAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  129664. /**
  129665. * An event triggered when a geometry is removed
  129666. */
  129667. _this.onGeometryRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  129668. /**
  129669. * An event triggered when a transform node is created
  129670. */
  129671. _this.onNewTransformNodeAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  129672. /**
  129673. * An event triggered when a transform node is removed
  129674. */
  129675. _this.onTransformNodeRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  129676. /**
  129677. * An event triggered when a mesh is created
  129678. */
  129679. _this.onNewMeshAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  129680. /**
  129681. * An event triggered when a mesh is removed
  129682. */
  129683. _this.onMeshRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  129684. /**
  129685. * An event triggered when a material is created
  129686. */
  129687. _this.onNewMaterialAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  129688. /**
  129689. * An event triggered when a material is removed
  129690. */
  129691. _this.onMaterialRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  129692. /**
  129693. * An event triggered when a texture is created
  129694. */
  129695. _this.onNewTextureAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  129696. /**
  129697. * An event triggered when a texture is removed
  129698. */
  129699. _this.onTextureRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  129700. /**
  129701. * An event triggered when render targets are about to be rendered
  129702. * Can happen multiple times per frame.
  129703. */
  129704. _this.onBeforeRenderTargetsRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  129705. /**
  129706. * An event triggered when render targets were rendered.
  129707. * Can happen multiple times per frame.
  129708. */
  129709. _this.onAfterRenderTargetsRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  129710. /**
  129711. * An event triggered before calculating deterministic simulation step
  129712. */
  129713. _this.onBeforeStepObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  129714. /**
  129715. * An event triggered after calculating deterministic simulation step
  129716. */
  129717. _this.onAfterStepObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  129718. /**
  129719. * An event triggered when the activeCamera property is updated
  129720. */
  129721. _this.onActiveCameraChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  129722. /**
  129723. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  129724. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  129725. * 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)
  129726. */
  129727. _this.onBeforeRenderingGroupObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  129728. /**
  129729. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  129730. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  129731. * 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)
  129732. */
  129733. _this.onAfterRenderingGroupObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  129734. /**
  129735. * This Observable will when a mesh has been imported into the scene.
  129736. */
  129737. _this.onMeshImportedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  129738. // Animations
  129739. /** @hidden */
  129740. _this._registeredForLateAnimationBindings = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  129741. /**
  129742. * 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).
  129743. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  129744. */
  129745. _this.onPrePointerObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  129746. /**
  129747. * Observable event triggered each time an input event is received from the rendering canvas
  129748. */
  129749. _this.onPointerObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  129750. _this._meshPickProceed = false;
  129751. _this._currentPickResult = null;
  129752. _this._previousPickResult = null;
  129753. _this._totalPointersPressed = 0;
  129754. _this._doubleClickOccured = false;
  129755. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  129756. _this.cameraToUseForPointers = null;
  129757. _this._pointerX = 0;
  129758. _this._pointerY = 0;
  129759. _this._startingPointerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](0, 0);
  129760. _this._previousStartingPointerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](0, 0);
  129761. _this._startingPointerTime = 0;
  129762. _this._previousStartingPointerTime = 0;
  129763. _this._pointerCaptures = {};
  129764. // Deterministic lockstep
  129765. _this._timeAccumulator = 0;
  129766. _this._currentStepId = 0;
  129767. _this._currentInternalStep = 0;
  129768. // Keyboard
  129769. /**
  129770. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  129771. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  129772. */
  129773. _this.onPreKeyboardObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  129774. /**
  129775. * Observable event triggered each time an keyboard event is received from the hosting window
  129776. */
  129777. _this.onKeyboardObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  129778. // Coordinates system
  129779. _this._useRightHandedSystem = false;
  129780. // Fog
  129781. _this._fogEnabled = true;
  129782. _this._fogMode = Scene.FOGMODE_NONE;
  129783. /**
  129784. * Gets or sets the fog color to use
  129785. * @see http://doc.babylonjs.com/babylon101/environment#fog
  129786. * (Default is Color3(0.2, 0.2, 0.3))
  129787. */
  129788. _this.fogColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color3"](0.2, 0.2, 0.3);
  129789. /**
  129790. * Gets or sets the fog density to use
  129791. * @see http://doc.babylonjs.com/babylon101/environment#fog
  129792. * (Default is 0.1)
  129793. */
  129794. _this.fogDensity = 0.1;
  129795. /**
  129796. * Gets or sets the fog start distance to use
  129797. * @see http://doc.babylonjs.com/babylon101/environment#fog
  129798. * (Default is 0)
  129799. */
  129800. _this.fogStart = 0;
  129801. /**
  129802. * Gets or sets the fog end distance to use
  129803. * @see http://doc.babylonjs.com/babylon101/environment#fog
  129804. * (Default is 1000)
  129805. */
  129806. _this.fogEnd = 1000.0;
  129807. // Lights
  129808. _this._shadowsEnabled = true;
  129809. _this._lightsEnabled = true;
  129810. /** All of the active cameras added to this scene. */
  129811. _this.activeCameras = new Array();
  129812. // Textures
  129813. _this._texturesEnabled = true;
  129814. // Particles
  129815. /**
  129816. * Gets or sets a boolean indicating if particles are enabled on this scene
  129817. */
  129818. _this.particlesEnabled = true;
  129819. // Sprites
  129820. /**
  129821. * Gets or sets a boolean indicating if sprites are enabled on this scene
  129822. */
  129823. _this.spritesEnabled = true;
  129824. // Skeletons
  129825. _this._skeletonsEnabled = true;
  129826. // Lens flares
  129827. /**
  129828. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  129829. */
  129830. _this.lensFlaresEnabled = true;
  129831. // Collisions
  129832. /**
  129833. * Gets or sets a boolean indicating if collisions are enabled on this scene
  129834. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  129835. */
  129836. _this.collisionsEnabled = true;
  129837. /**
  129838. * Defines the gravity applied to this scene (used only for collisions)
  129839. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  129840. */
  129841. _this.gravity = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](0, -9.807, 0);
  129842. // Postprocesses
  129843. /**
  129844. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  129845. */
  129846. _this.postProcessesEnabled = true;
  129847. /**
  129848. * The list of postprocesses added to the scene
  129849. */
  129850. _this.postProcesses = new Array();
  129851. // Customs render targets
  129852. /**
  129853. * Gets or sets a boolean indicating if render targets are enabled on this scene
  129854. */
  129855. _this.renderTargetsEnabled = true;
  129856. /**
  129857. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  129858. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  129859. */
  129860. _this.dumpNextRenderTargets = false;
  129861. /**
  129862. * The list of user defined render targets added to the scene
  129863. */
  129864. _this.customRenderTargets = new Array();
  129865. /**
  129866. * Gets the list of meshes imported to the scene through SceneLoader
  129867. */
  129868. _this.importedMeshesFiles = new Array();
  129869. // Probes
  129870. /**
  129871. * Gets or sets a boolean indicating if probes are enabled on this scene
  129872. */
  129873. _this.probesEnabled = true;
  129874. _this._meshesForIntersections = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  129875. // Procedural textures
  129876. /**
  129877. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  129878. */
  129879. _this.proceduralTexturesEnabled = true;
  129880. // Performance counters
  129881. _this._totalVertices = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  129882. /** @hidden */
  129883. _this._activeIndices = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  129884. /** @hidden */
  129885. _this._activeParticles = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  129886. /** @hidden */
  129887. _this._activeBones = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  129888. /** @hidden */
  129889. _this._animationTime = 0;
  129890. /**
  129891. * Gets or sets a general scale for animation speed
  129892. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  129893. */
  129894. _this.animationTimeScale = 1;
  129895. _this._renderId = 0;
  129896. _this._frameId = 0;
  129897. _this._executeWhenReadyTimeoutId = -1;
  129898. _this._intermediateRendering = false;
  129899. _this._viewUpdateFlag = -1;
  129900. _this._projectionUpdateFlag = -1;
  129901. _this._alternateViewUpdateFlag = -1;
  129902. _this._alternateProjectionUpdateFlag = -1;
  129903. /** @hidden */
  129904. _this._toBeDisposed = new Array(256);
  129905. _this._activeRequests = new Array();
  129906. /** @hidden */
  129907. _this._pendingData = new Array();
  129908. _this._isDisposed = false;
  129909. /**
  129910. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  129911. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  129912. */
  129913. _this.dispatchAllSubMeshesOfActiveMeshes = false;
  129914. _this._activeMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  129915. _this._processedMaterials = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  129916. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  129917. /** @hidden */
  129918. _this._activeParticleSystems = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  129919. _this._activeSkeletons = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](32);
  129920. _this._softwareSkinnedMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](32);
  129921. /** @hidden */
  129922. _this._activeAnimatables = new Array();
  129923. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Zero();
  129924. _this._useAlternateCameraConfiguration = false;
  129925. _this._alternateRendering = false;
  129926. _this._wheelEventName = "";
  129927. /**
  129928. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  129929. * This is useful if there are more lights that the maximum simulteanous authorized
  129930. */
  129931. _this.requireLightSorting = false;
  129932. /**
  129933. * @hidden
  129934. * Backing store of defined scene components.
  129935. */
  129936. _this._components = [];
  129937. /**
  129938. * @hidden
  129939. * Backing store of defined scene components.
  129940. */
  129941. _this._serializableComponents = [];
  129942. /**
  129943. * List of components to register on the next registration step.
  129944. */
  129945. _this._transientComponents = [];
  129946. /**
  129947. * @hidden
  129948. * Defines the actions happening before camera updates.
  129949. */
  129950. _this._beforeCameraUpdateStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  129951. /**
  129952. * @hidden
  129953. * Defines the actions happening before clear the canvas.
  129954. */
  129955. _this._beforeClearStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  129956. /**
  129957. * @hidden
  129958. * Defines the actions when collecting render targets for the frame.
  129959. */
  129960. _this._gatherRenderTargetsStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  129961. /**
  129962. * @hidden
  129963. * Defines the actions happening for one camera in the frame.
  129964. */
  129965. _this._gatherActiveCameraRenderTargetsStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  129966. /**
  129967. * @hidden
  129968. * Defines the actions happening during the per mesh ready checks.
  129969. */
  129970. _this._isReadyForMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  129971. /**
  129972. * @hidden
  129973. * Defines the actions happening before evaluate active mesh checks.
  129974. */
  129975. _this._beforeEvaluateActiveMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  129976. /**
  129977. * @hidden
  129978. * Defines the actions happening during the evaluate sub mesh checks.
  129979. */
  129980. _this._evaluateSubMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  129981. /**
  129982. * @hidden
  129983. * Defines the actions happening during the active mesh stage.
  129984. */
  129985. _this._activeMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  129986. /**
  129987. * @hidden
  129988. * Defines the actions happening during the per camera render target step.
  129989. */
  129990. _this._cameraDrawRenderTargetStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  129991. /**
  129992. * @hidden
  129993. * Defines the actions happening just before the active camera is drawing.
  129994. */
  129995. _this._beforeCameraDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  129996. /**
  129997. * @hidden
  129998. * Defines the actions happening just before a render target is drawing.
  129999. */
  130000. _this._beforeRenderTargetDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  130001. /**
  130002. * @hidden
  130003. * Defines the actions happening just before a rendering group is drawing.
  130004. */
  130005. _this._beforeRenderingGroupDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  130006. /**
  130007. * @hidden
  130008. * Defines the actions happening just before a mesh is drawing.
  130009. */
  130010. _this._beforeRenderingMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  130011. /**
  130012. * @hidden
  130013. * Defines the actions happening just after a mesh has been drawn.
  130014. */
  130015. _this._afterRenderingMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  130016. /**
  130017. * @hidden
  130018. * Defines the actions happening just after a rendering group has been drawn.
  130019. */
  130020. _this._afterRenderingGroupDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  130021. /**
  130022. * @hidden
  130023. * Defines the actions happening just after the active camera has been drawn.
  130024. */
  130025. _this._afterCameraDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  130026. /**
  130027. * @hidden
  130028. * Defines the actions happening just after a render target has been drawn.
  130029. */
  130030. _this._afterRenderTargetDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  130031. /**
  130032. * @hidden
  130033. * Defines the actions happening just after rendering all cameras and computing intersections.
  130034. */
  130035. _this._afterRenderStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  130036. /**
  130037. * @hidden
  130038. * Defines the actions happening when a pointer move event happens.
  130039. */
  130040. _this._pointerMoveStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  130041. /**
  130042. * @hidden
  130043. * Defines the actions happening when a pointer down event happens.
  130044. */
  130045. _this._pointerDownStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  130046. /**
  130047. * @hidden
  130048. * Defines the actions happening when a pointer up event happens.
  130049. */
  130050. _this._pointerUpStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  130051. /**
  130052. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  130053. */
  130054. _this.geometriesByUniqueId = null;
  130055. _this._defaultMeshCandidates = {
  130056. data: [],
  130057. length: 0
  130058. };
  130059. _this._defaultSubMeshCandidates = {
  130060. data: [],
  130061. length: 0
  130062. };
  130063. _this._preventFreeActiveMeshesAndRenderingGroups = false;
  130064. _this._activeMeshesFrozen = false;
  130065. /** @hidden */
  130066. _this._allowPostProcessClearColor = true;
  130067. /**
  130068. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  130069. */
  130070. _this.getDeterministicFrameTime = function () {
  130071. return 1000.0 / 60.0; // frame time in ms
  130072. };
  130073. _this._blockMaterialDirtyMechanism = false;
  130074. _this._engine = engine || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_24__["EngineStore"].LastCreatedEngine;
  130075. _this._engine.scenes.push(_this);
  130076. _this._uid = null;
  130077. _this._renderingManager = new _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_19__["RenderingManager"](_this);
  130078. if (_PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_18__["PostProcessManager"]) {
  130079. _this.postProcessManager = new _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_18__["PostProcessManager"](_this);
  130080. }
  130081. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_22__["DomManagement"].IsWindowObjectExist()) {
  130082. _this.attachControl();
  130083. }
  130084. // Uniform Buffer
  130085. _this._createUbo();
  130086. // Default Image processing definition
  130087. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__["ImageProcessingConfiguration"]) {
  130088. _this._imageProcessingConfiguration = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__["ImageProcessingConfiguration"]();
  130089. }
  130090. _this.setDefaultCandidateProviders();
  130091. if (options && options.useGeometryUniqueIdsMap === true) {
  130092. _this.geometriesByUniqueId = {};
  130093. }
  130094. _this.useMaterialMeshMap = options && options.useGeometryUniqueIdsMap || false;
  130095. _this.useClonedMeshhMap = options && options.useClonedMeshhMap || false;
  130096. _this._engine.onNewSceneAddedObservable.notifyObservers(_this);
  130097. return _this;
  130098. }
  130099. /**
  130100. * Factory used to create the default material.
  130101. * @param name The name of the material to create
  130102. * @param scene The scene to create the material for
  130103. * @returns The default material
  130104. */
  130105. Scene.DefaultMaterialFactory = function (scene) {
  130106. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("StandardMaterial");
  130107. };
  130108. /**
  130109. * Factory used to create the a collision coordinator.
  130110. * @returns The collision coordinator
  130111. */
  130112. Scene.CollisionCoordinatorFactory = function () {
  130113. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("DefaultCollisionCoordinator");
  130114. };
  130115. Object.defineProperty(Scene.prototype, "environmentTexture", {
  130116. /**
  130117. * Texture used in all pbr material as the reflection texture.
  130118. * As in the majority of the scene they are the same (exception for multi room and so on),
  130119. * this is easier to reference from here than from all the materials.
  130120. */
  130121. get: function () {
  130122. return this._environmentTexture;
  130123. },
  130124. /**
  130125. * Texture used in all pbr material as the reflection texture.
  130126. * As in the majority of the scene they are the same (exception for multi room and so on),
  130127. * this is easier to set here than in all the materials.
  130128. */
  130129. set: function (value) {
  130130. if (this._environmentTexture === value) {
  130131. return;
  130132. }
  130133. this._environmentTexture = value;
  130134. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_TextureDirtyFlag);
  130135. },
  130136. enumerable: true,
  130137. configurable: true
  130138. });
  130139. Object.defineProperty(Scene.prototype, "imageProcessingConfiguration", {
  130140. /**
  130141. * Default image processing configuration used either in the rendering
  130142. * Forward main pass or through the imageProcessingPostProcess if present.
  130143. * As in the majority of the scene they are the same (exception for multi camera),
  130144. * this is easier to reference from here than from all the materials and post process.
  130145. *
  130146. * No setter as we it is a shared configuration, you can set the values instead.
  130147. */
  130148. get: function () {
  130149. return this._imageProcessingConfiguration;
  130150. },
  130151. enumerable: true,
  130152. configurable: true
  130153. });
  130154. Object.defineProperty(Scene.prototype, "forceWireframe", {
  130155. get: function () {
  130156. return this._forceWireframe;
  130157. },
  130158. /**
  130159. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  130160. */
  130161. set: function (value) {
  130162. if (this._forceWireframe === value) {
  130163. return;
  130164. }
  130165. this._forceWireframe = value;
  130166. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  130167. },
  130168. enumerable: true,
  130169. configurable: true
  130170. });
  130171. Object.defineProperty(Scene.prototype, "forcePointsCloud", {
  130172. get: function () {
  130173. return this._forcePointsCloud;
  130174. },
  130175. /**
  130176. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  130177. */
  130178. set: function (value) {
  130179. if (this._forcePointsCloud === value) {
  130180. return;
  130181. }
  130182. this._forcePointsCloud = value;
  130183. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  130184. },
  130185. enumerable: true,
  130186. configurable: true
  130187. });
  130188. Object.defineProperty(Scene.prototype, "animationPropertiesOverride", {
  130189. /**
  130190. * Gets or sets the animation properties override
  130191. */
  130192. get: function () {
  130193. return this._animationPropertiesOverride;
  130194. },
  130195. set: function (value) {
  130196. this._animationPropertiesOverride = value;
  130197. },
  130198. enumerable: true,
  130199. configurable: true
  130200. });
  130201. Object.defineProperty(Scene.prototype, "onDispose", {
  130202. /** Sets a function to be executed when this scene is disposed. */
  130203. set: function (callback) {
  130204. if (this._onDisposeObserver) {
  130205. this.onDisposeObservable.remove(this._onDisposeObserver);
  130206. }
  130207. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  130208. },
  130209. enumerable: true,
  130210. configurable: true
  130211. });
  130212. Object.defineProperty(Scene.prototype, "beforeRender", {
  130213. /** Sets a function to be executed before rendering this scene */
  130214. set: function (callback) {
  130215. if (this._onBeforeRenderObserver) {
  130216. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  130217. }
  130218. if (callback) {
  130219. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  130220. }
  130221. },
  130222. enumerable: true,
  130223. configurable: true
  130224. });
  130225. Object.defineProperty(Scene.prototype, "afterRender", {
  130226. /** Sets a function to be executed after rendering this scene */
  130227. set: function (callback) {
  130228. if (this._onAfterRenderObserver) {
  130229. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  130230. }
  130231. if (callback) {
  130232. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  130233. }
  130234. },
  130235. enumerable: true,
  130236. configurable: true
  130237. });
  130238. Object.defineProperty(Scene.prototype, "beforeCameraRender", {
  130239. /** Sets a function to be executed before rendering a camera*/
  130240. set: function (callback) {
  130241. if (this._onBeforeCameraRenderObserver) {
  130242. this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  130243. }
  130244. this._onBeforeCameraRenderObserver = this.onBeforeCameraRenderObservable.add(callback);
  130245. },
  130246. enumerable: true,
  130247. configurable: true
  130248. });
  130249. Object.defineProperty(Scene.prototype, "afterCameraRender", {
  130250. /** Sets a function to be executed after rendering a camera*/
  130251. set: function (callback) {
  130252. if (this._onAfterCameraRenderObserver) {
  130253. this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  130254. }
  130255. this._onAfterCameraRenderObserver = this.onAfterCameraRenderObservable.add(callback);
  130256. },
  130257. enumerable: true,
  130258. configurable: true
  130259. });
  130260. Object.defineProperty(Scene.prototype, "unTranslatedPointer", {
  130261. /**
  130262. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  130263. */
  130264. get: function () {
  130265. return new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](this._unTranslatedPointerX, this._unTranslatedPointerY);
  130266. },
  130267. enumerable: true,
  130268. configurable: true
  130269. });
  130270. Object.defineProperty(Scene.prototype, "useRightHandedSystem", {
  130271. get: function () {
  130272. return this._useRightHandedSystem;
  130273. },
  130274. /**
  130275. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  130276. */
  130277. set: function (value) {
  130278. if (this._useRightHandedSystem === value) {
  130279. return;
  130280. }
  130281. this._useRightHandedSystem = value;
  130282. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  130283. },
  130284. enumerable: true,
  130285. configurable: true
  130286. });
  130287. /**
  130288. * Sets the step Id used by deterministic lock step
  130289. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130290. * @param newStepId defines the step Id
  130291. */
  130292. Scene.prototype.setStepId = function (newStepId) {
  130293. this._currentStepId = newStepId;
  130294. };
  130295. /**
  130296. * Gets the step Id used by deterministic lock step
  130297. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130298. * @returns the step Id
  130299. */
  130300. Scene.prototype.getStepId = function () {
  130301. return this._currentStepId;
  130302. };
  130303. /**
  130304. * Gets the internal step used by deterministic lock step
  130305. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130306. * @returns the internal step
  130307. */
  130308. Scene.prototype.getInternalStep = function () {
  130309. return this._currentInternalStep;
  130310. };
  130311. Object.defineProperty(Scene.prototype, "fogEnabled", {
  130312. get: function () {
  130313. return this._fogEnabled;
  130314. },
  130315. /**
  130316. * Gets or sets a boolean indicating if fog is enabled on this scene
  130317. * @see http://doc.babylonjs.com/babylon101/environment#fog
  130318. * (Default is true)
  130319. */
  130320. set: function (value) {
  130321. if (this._fogEnabled === value) {
  130322. return;
  130323. }
  130324. this._fogEnabled = value;
  130325. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  130326. },
  130327. enumerable: true,
  130328. configurable: true
  130329. });
  130330. Object.defineProperty(Scene.prototype, "fogMode", {
  130331. get: function () {
  130332. return this._fogMode;
  130333. },
  130334. /**
  130335. * Gets or sets the fog mode to use
  130336. * @see http://doc.babylonjs.com/babylon101/environment#fog
  130337. * | mode | value |
  130338. * | --- | --- |
  130339. * | FOGMODE_NONE | 0 |
  130340. * | FOGMODE_EXP | 1 |
  130341. * | FOGMODE_EXP2 | 2 |
  130342. * | FOGMODE_LINEAR | 3 |
  130343. */
  130344. set: function (value) {
  130345. if (this._fogMode === value) {
  130346. return;
  130347. }
  130348. this._fogMode = value;
  130349. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  130350. },
  130351. enumerable: true,
  130352. configurable: true
  130353. });
  130354. Object.defineProperty(Scene.prototype, "shadowsEnabled", {
  130355. get: function () {
  130356. return this._shadowsEnabled;
  130357. },
  130358. /**
  130359. * Gets or sets a boolean indicating if shadows are enabled on this scene
  130360. */
  130361. set: function (value) {
  130362. if (this._shadowsEnabled === value) {
  130363. return;
  130364. }
  130365. this._shadowsEnabled = value;
  130366. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_LightDirtyFlag);
  130367. },
  130368. enumerable: true,
  130369. configurable: true
  130370. });
  130371. Object.defineProperty(Scene.prototype, "lightsEnabled", {
  130372. get: function () {
  130373. return this._lightsEnabled;
  130374. },
  130375. /**
  130376. * Gets or sets a boolean indicating if lights are enabled on this scene
  130377. */
  130378. set: function (value) {
  130379. if (this._lightsEnabled === value) {
  130380. return;
  130381. }
  130382. this._lightsEnabled = value;
  130383. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_LightDirtyFlag);
  130384. },
  130385. enumerable: true,
  130386. configurable: true
  130387. });
  130388. Object.defineProperty(Scene.prototype, "activeCamera", {
  130389. /** Gets or sets the current active camera */
  130390. get: function () {
  130391. return this._activeCamera;
  130392. },
  130393. set: function (value) {
  130394. if (value === this._activeCamera) {
  130395. return;
  130396. }
  130397. this._activeCamera = value;
  130398. this.onActiveCameraChanged.notifyObservers(this);
  130399. },
  130400. enumerable: true,
  130401. configurable: true
  130402. });
  130403. Object.defineProperty(Scene.prototype, "defaultMaterial", {
  130404. /** The default material used on meshes when no material is affected */
  130405. get: function () {
  130406. if (!this._defaultMaterial) {
  130407. this._defaultMaterial = Scene.DefaultMaterialFactory(this);
  130408. }
  130409. return this._defaultMaterial;
  130410. },
  130411. /** The default material used on meshes when no material is affected */
  130412. set: function (value) {
  130413. this._defaultMaterial = value;
  130414. },
  130415. enumerable: true,
  130416. configurable: true
  130417. });
  130418. Object.defineProperty(Scene.prototype, "texturesEnabled", {
  130419. get: function () {
  130420. return this._texturesEnabled;
  130421. },
  130422. /**
  130423. * Gets or sets a boolean indicating if textures are enabled on this scene
  130424. */
  130425. set: function (value) {
  130426. if (this._texturesEnabled === value) {
  130427. return;
  130428. }
  130429. this._texturesEnabled = value;
  130430. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_TextureDirtyFlag);
  130431. },
  130432. enumerable: true,
  130433. configurable: true
  130434. });
  130435. Object.defineProperty(Scene.prototype, "skeletonsEnabled", {
  130436. get: function () {
  130437. return this._skeletonsEnabled;
  130438. },
  130439. /**
  130440. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  130441. */
  130442. set: function (value) {
  130443. if (this._skeletonsEnabled === value) {
  130444. return;
  130445. }
  130446. this._skeletonsEnabled = value;
  130447. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_AttributesDirtyFlag);
  130448. },
  130449. enumerable: true,
  130450. configurable: true
  130451. });
  130452. Object.defineProperty(Scene.prototype, "collisionCoordinator", {
  130453. /** @hidden */
  130454. get: function () {
  130455. if (!this._collisionCoordinator) {
  130456. this._collisionCoordinator = Scene.CollisionCoordinatorFactory();
  130457. this._collisionCoordinator.init(this);
  130458. }
  130459. return this._collisionCoordinator;
  130460. },
  130461. enumerable: true,
  130462. configurable: true
  130463. });
  130464. Object.defineProperty(Scene.prototype, "_isAlternateRenderingEnabled", {
  130465. /** @hidden */
  130466. get: function () {
  130467. return this._alternateRendering;
  130468. },
  130469. enumerable: true,
  130470. configurable: true
  130471. });
  130472. Object.defineProperty(Scene.prototype, "frustumPlanes", {
  130473. /**
  130474. * Gets the list of frustum planes (built from the active camera)
  130475. */
  130476. get: function () {
  130477. return this._frustumPlanes;
  130478. },
  130479. enumerable: true,
  130480. configurable: true
  130481. });
  130482. /**
  130483. * Registers the transient components if needed.
  130484. */
  130485. Scene.prototype._registerTransientComponents = function () {
  130486. // Register components that have been associated lately to the scene.
  130487. if (this._transientComponents.length > 0) {
  130488. for (var _i = 0, _a = this._transientComponents; _i < _a.length; _i++) {
  130489. var component = _a[_i];
  130490. component.register();
  130491. }
  130492. this._transientComponents = [];
  130493. }
  130494. };
  130495. /**
  130496. * @hidden
  130497. * Add a component to the scene.
  130498. * Note that the ccomponent could be registered on th next frame if this is called after
  130499. * the register component stage.
  130500. * @param component Defines the component to add to the scene
  130501. */
  130502. Scene.prototype._addComponent = function (component) {
  130503. this._components.push(component);
  130504. this._transientComponents.push(component);
  130505. var serializableComponent = component;
  130506. if (serializableComponent.addFromContainer) {
  130507. this._serializableComponents.push(serializableComponent);
  130508. }
  130509. };
  130510. /**
  130511. * @hidden
  130512. * Gets a component from the scene.
  130513. * @param name defines the name of the component to retrieve
  130514. * @returns the component or null if not present
  130515. */
  130516. Scene.prototype._getComponent = function (name) {
  130517. for (var _i = 0, _a = this._components; _i < _a.length; _i++) {
  130518. var component = _a[_i];
  130519. if (component.name === name) {
  130520. return component;
  130521. }
  130522. }
  130523. return null;
  130524. };
  130525. /**
  130526. * @hidden
  130527. */
  130528. Scene.prototype._getDefaultMeshCandidates = function () {
  130529. this._defaultMeshCandidates.data = this.meshes;
  130530. this._defaultMeshCandidates.length = this.meshes.length;
  130531. return this._defaultMeshCandidates;
  130532. };
  130533. /**
  130534. * @hidden
  130535. */
  130536. Scene.prototype._getDefaultSubMeshCandidates = function (mesh) {
  130537. this._defaultSubMeshCandidates.data = mesh.subMeshes;
  130538. this._defaultSubMeshCandidates.length = mesh.subMeshes.length;
  130539. return this._defaultSubMeshCandidates;
  130540. };
  130541. /**
  130542. * Sets the default candidate providers for the scene.
  130543. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  130544. * and getCollidingSubMeshCandidates to their default function
  130545. */
  130546. Scene.prototype.setDefaultCandidateProviders = function () {
  130547. this.getActiveMeshCandidates = this._getDefaultMeshCandidates.bind(this);
  130548. this.getActiveSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  130549. this.getIntersectingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  130550. this.getCollidingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  130551. };
  130552. Object.defineProperty(Scene.prototype, "meshUnderPointer", {
  130553. /**
  130554. * Gets the mesh that is currently under the pointer
  130555. */
  130556. get: function () {
  130557. return this._pointerOverMesh;
  130558. },
  130559. enumerable: true,
  130560. configurable: true
  130561. });
  130562. Object.defineProperty(Scene.prototype, "pointerX", {
  130563. /**
  130564. * Gets or sets the current on-screen X position of the pointer
  130565. */
  130566. get: function () {
  130567. return this._pointerX;
  130568. },
  130569. set: function (value) {
  130570. this._pointerX = value;
  130571. },
  130572. enumerable: true,
  130573. configurable: true
  130574. });
  130575. Object.defineProperty(Scene.prototype, "pointerY", {
  130576. /**
  130577. * Gets or sets the current on-screen Y position of the pointer
  130578. */
  130579. get: function () {
  130580. return this._pointerY;
  130581. },
  130582. set: function (value) {
  130583. this._pointerY = value;
  130584. },
  130585. enumerable: true,
  130586. configurable: true
  130587. });
  130588. /**
  130589. * Gets the cached material (ie. the latest rendered one)
  130590. * @returns the cached material
  130591. */
  130592. Scene.prototype.getCachedMaterial = function () {
  130593. return this._cachedMaterial;
  130594. };
  130595. /**
  130596. * Gets the cached effect (ie. the latest rendered one)
  130597. * @returns the cached effect
  130598. */
  130599. Scene.prototype.getCachedEffect = function () {
  130600. return this._cachedEffect;
  130601. };
  130602. /**
  130603. * Gets the cached visibility state (ie. the latest rendered one)
  130604. * @returns the cached visibility state
  130605. */
  130606. Scene.prototype.getCachedVisibility = function () {
  130607. return this._cachedVisibility;
  130608. };
  130609. /**
  130610. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  130611. * @param material defines the current material
  130612. * @param effect defines the current effect
  130613. * @param visibility defines the current visibility state
  130614. * @returns true if one parameter is not cached
  130615. */
  130616. Scene.prototype.isCachedMaterialInvalid = function (material, effect, visibility) {
  130617. if (visibility === void 0) { visibility = 1; }
  130618. return this._cachedEffect !== effect || this._cachedMaterial !== material || this._cachedVisibility !== visibility;
  130619. };
  130620. /**
  130621. * Gets the engine associated with the scene
  130622. * @returns an Engine
  130623. */
  130624. Scene.prototype.getEngine = function () {
  130625. return this._engine;
  130626. };
  130627. /**
  130628. * Gets the total number of vertices rendered per frame
  130629. * @returns the total number of vertices rendered per frame
  130630. */
  130631. Scene.prototype.getTotalVertices = function () {
  130632. return this._totalVertices.current;
  130633. };
  130634. Object.defineProperty(Scene.prototype, "totalVerticesPerfCounter", {
  130635. /**
  130636. * Gets the performance counter for total vertices
  130637. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  130638. */
  130639. get: function () {
  130640. return this._totalVertices;
  130641. },
  130642. enumerable: true,
  130643. configurable: true
  130644. });
  130645. /**
  130646. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  130647. * @returns the total number of active indices rendered per frame
  130648. */
  130649. Scene.prototype.getActiveIndices = function () {
  130650. return this._activeIndices.current;
  130651. };
  130652. Object.defineProperty(Scene.prototype, "totalActiveIndicesPerfCounter", {
  130653. /**
  130654. * Gets the performance counter for active indices
  130655. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  130656. */
  130657. get: function () {
  130658. return this._activeIndices;
  130659. },
  130660. enumerable: true,
  130661. configurable: true
  130662. });
  130663. /**
  130664. * Gets the total number of active particles rendered per frame
  130665. * @returns the total number of active particles rendered per frame
  130666. */
  130667. Scene.prototype.getActiveParticles = function () {
  130668. return this._activeParticles.current;
  130669. };
  130670. Object.defineProperty(Scene.prototype, "activeParticlesPerfCounter", {
  130671. /**
  130672. * Gets the performance counter for active particles
  130673. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  130674. */
  130675. get: function () {
  130676. return this._activeParticles;
  130677. },
  130678. enumerable: true,
  130679. configurable: true
  130680. });
  130681. /**
  130682. * Gets the total number of active bones rendered per frame
  130683. * @returns the total number of active bones rendered per frame
  130684. */
  130685. Scene.prototype.getActiveBones = function () {
  130686. return this._activeBones.current;
  130687. };
  130688. Object.defineProperty(Scene.prototype, "activeBonesPerfCounter", {
  130689. /**
  130690. * Gets the performance counter for active bones
  130691. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  130692. */
  130693. get: function () {
  130694. return this._activeBones;
  130695. },
  130696. enumerable: true,
  130697. configurable: true
  130698. });
  130699. /**
  130700. * Gets the array of active meshes
  130701. * @returns an array of AbstractMesh
  130702. */
  130703. Scene.prototype.getActiveMeshes = function () {
  130704. return this._activeMeshes;
  130705. };
  130706. /**
  130707. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  130708. * @returns a number
  130709. */
  130710. Scene.prototype.getAnimationRatio = function () {
  130711. return this._animationRatio !== undefined ? this._animationRatio : 1;
  130712. };
  130713. /**
  130714. * Gets an unique Id for the current render phase
  130715. * @returns a number
  130716. */
  130717. Scene.prototype.getRenderId = function () {
  130718. return this._renderId;
  130719. };
  130720. /**
  130721. * Gets an unique Id for the current frame
  130722. * @returns a number
  130723. */
  130724. Scene.prototype.getFrameId = function () {
  130725. return this._frameId;
  130726. };
  130727. /** Call this function if you want to manually increment the render Id*/
  130728. Scene.prototype.incrementRenderId = function () {
  130729. this._renderId++;
  130730. };
  130731. Scene.prototype._updatePointerPosition = function (evt) {
  130732. var canvasRect = this._engine.getRenderingCanvasClientRect();
  130733. if (!canvasRect) {
  130734. return;
  130735. }
  130736. this._pointerX = evt.clientX - canvasRect.left;
  130737. this._pointerY = evt.clientY - canvasRect.top;
  130738. this._unTranslatedPointerX = this._pointerX;
  130739. this._unTranslatedPointerY = this._pointerY;
  130740. };
  130741. Scene.prototype._createUbo = function () {
  130742. this._sceneUbo = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_12__["UniformBuffer"](this._engine, undefined, true);
  130743. this._sceneUbo.addUniform("viewProjection", 16);
  130744. this._sceneUbo.addUniform("view", 16);
  130745. };
  130746. Scene.prototype._createAlternateUbo = function () {
  130747. this._alternateSceneUbo = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_12__["UniformBuffer"](this._engine, undefined, true);
  130748. this._alternateSceneUbo.addUniform("viewProjection", 16);
  130749. this._alternateSceneUbo.addUniform("view", 16);
  130750. };
  130751. // Pointers handling
  130752. Scene.prototype._setRayOnPointerInfo = function (pointerInfo) {
  130753. if (pointerInfo.pickInfo && !pointerInfo.pickInfo._pickingUnavailable) {
  130754. if (!pointerInfo.pickInfo.ray) {
  130755. pointerInfo.pickInfo.ray = this.createPickingRay(pointerInfo.event.offsetX, pointerInfo.event.offsetY, _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Identity(), this.activeCamera);
  130756. }
  130757. }
  130758. };
  130759. /**
  130760. * Use this method to simulate a pointer move on a mesh
  130761. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  130762. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  130763. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  130764. * @returns the current scene
  130765. */
  130766. Scene.prototype.simulatePointerMove = function (pickResult, pointerEventInit) {
  130767. var evt = new PointerEvent("pointermove", pointerEventInit);
  130768. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERMOVE)) {
  130769. return this;
  130770. }
  130771. return this._processPointerMove(pickResult, evt);
  130772. };
  130773. Scene.prototype._processPointerMove = function (pickResult, evt) {
  130774. var canvas = this._engine.getRenderingCanvas();
  130775. if (!canvas) {
  130776. return this;
  130777. }
  130778. // Restore pointer
  130779. canvas.style.cursor = this.defaultCursor;
  130780. var isMeshPicked = (pickResult && pickResult.hit && pickResult.pickedMesh) ? true : false;
  130781. if (isMeshPicked) {
  130782. this.setPointerOverMesh(pickResult.pickedMesh);
  130783. if (this._pointerOverMesh && this._pointerOverMesh.actionManager && this._pointerOverMesh.actionManager.hasPointerTriggers) {
  130784. if (this._pointerOverMesh.actionManager.hoverCursor) {
  130785. canvas.style.cursor = this._pointerOverMesh.actionManager.hoverCursor;
  130786. }
  130787. else {
  130788. canvas.style.cursor = this.hoverCursor;
  130789. }
  130790. }
  130791. }
  130792. else {
  130793. this.setPointerOverMesh(null);
  130794. }
  130795. for (var _i = 0, _a = this._pointerMoveStage; _i < _a.length; _i++) {
  130796. var step = _a[_i];
  130797. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, isMeshPicked, canvas);
  130798. }
  130799. if (pickResult) {
  130800. var type = evt.type === this._wheelEventName ? _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERWHEEL : _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERMOVE;
  130801. if (this.onPointerMove) {
  130802. this.onPointerMove(evt, pickResult, type);
  130803. }
  130804. if (this.onPointerObservable.hasObservers()) {
  130805. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type, evt, pickResult);
  130806. this._setRayOnPointerInfo(pi);
  130807. this.onPointerObservable.notifyObservers(pi, type);
  130808. }
  130809. }
  130810. return this;
  130811. };
  130812. Scene.prototype._checkPrePointerObservable = function (pickResult, evt, type) {
  130813. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfoPre"](type, evt, this._unTranslatedPointerX, this._unTranslatedPointerY);
  130814. if (pickResult) {
  130815. pi.ray = pickResult.ray;
  130816. }
  130817. this.onPrePointerObservable.notifyObservers(pi, type);
  130818. if (pi.skipOnPointerObservable) {
  130819. return true;
  130820. }
  130821. else {
  130822. return false;
  130823. }
  130824. };
  130825. /**
  130826. * Use this method to simulate a pointer down on a mesh
  130827. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  130828. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  130829. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  130830. * @returns the current scene
  130831. */
  130832. Scene.prototype.simulatePointerDown = function (pickResult, pointerEventInit) {
  130833. var evt = new PointerEvent("pointerdown", pointerEventInit);
  130834. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOWN)) {
  130835. return this;
  130836. }
  130837. return this._processPointerDown(pickResult, evt);
  130838. };
  130839. Scene.prototype._processPointerDown = function (pickResult, evt) {
  130840. var _this = this;
  130841. if (pickResult && pickResult.hit && pickResult.pickedMesh) {
  130842. this._pickedDownMesh = pickResult.pickedMesh;
  130843. var actionManager = pickResult.pickedMesh.actionManager;
  130844. if (actionManager) {
  130845. if (actionManager.hasPickTriggers) {
  130846. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickDownTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  130847. switch (evt.button) {
  130848. case 0:
  130849. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnLeftPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  130850. break;
  130851. case 1:
  130852. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnCenterPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  130853. break;
  130854. case 2:
  130855. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnRightPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  130856. break;
  130857. }
  130858. }
  130859. if (actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnLongPressTrigger)) {
  130860. window.setTimeout(function () {
  130861. 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);
  130862. if (pickResult && pickResult.hit && pickResult.pickedMesh && actionManager) {
  130863. if (_this._totalPointersPressed !== 0 &&
  130864. ((Date.now() - _this._startingPointerTime) > Scene.LongPressDelay) &&
  130865. !_this._isPointerSwiping()) {
  130866. _this._startingPointerTime = 0;
  130867. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnLongPressTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  130868. }
  130869. }
  130870. }, Scene.LongPressDelay);
  130871. }
  130872. }
  130873. }
  130874. else {
  130875. for (var _i = 0, _a = this._pointerDownStage; _i < _a.length; _i++) {
  130876. var step = _a[_i];
  130877. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, evt);
  130878. }
  130879. }
  130880. if (pickResult) {
  130881. var type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOWN;
  130882. if (this.onPointerDown) {
  130883. this.onPointerDown(evt, pickResult, type);
  130884. }
  130885. if (this.onPointerObservable.hasObservers()) {
  130886. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type, evt, pickResult);
  130887. this._setRayOnPointerInfo(pi);
  130888. this.onPointerObservable.notifyObservers(pi, type);
  130889. }
  130890. }
  130891. return this;
  130892. };
  130893. /**
  130894. * Use this method to simulate a pointer up on a mesh
  130895. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  130896. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  130897. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  130898. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  130899. * @returns the current scene
  130900. */
  130901. Scene.prototype.simulatePointerUp = function (pickResult, pointerEventInit, doubleTap) {
  130902. var evt = new PointerEvent("pointerup", pointerEventInit);
  130903. var clickInfo = new ClickInfo();
  130904. if (doubleTap) {
  130905. clickInfo.doubleClick = true;
  130906. }
  130907. else {
  130908. clickInfo.singleClick = true;
  130909. }
  130910. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERUP)) {
  130911. return this;
  130912. }
  130913. return this._processPointerUp(pickResult, evt, clickInfo);
  130914. };
  130915. Scene.prototype._processPointerUp = function (pickResult, evt, clickInfo) {
  130916. if (pickResult && pickResult && pickResult.pickedMesh) {
  130917. this._pickedUpMesh = pickResult.pickedMesh;
  130918. if (this._pickedDownMesh === this._pickedUpMesh) {
  130919. if (this.onPointerPick) {
  130920. this.onPointerPick(evt, pickResult);
  130921. }
  130922. if (clickInfo.singleClick && !clickInfo.ignore && this.onPointerObservable.hasObservers()) {
  130923. var type_1 = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERPICK;
  130924. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type_1, evt, pickResult);
  130925. this._setRayOnPointerInfo(pi);
  130926. this.onPointerObservable.notifyObservers(pi, type_1);
  130927. }
  130928. }
  130929. var actionManager = pickResult.pickedMesh._getActionManagerForTrigger();
  130930. if (actionManager && !clickInfo.ignore) {
  130931. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickUpTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  130932. if (!clickInfo.hasSwiped && clickInfo.singleClick) {
  130933. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  130934. }
  130935. var doubleClickActionManager = pickResult.pickedMesh._getActionManagerForTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger);
  130936. if (clickInfo.doubleClick && doubleClickActionManager) {
  130937. doubleClickActionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  130938. }
  130939. }
  130940. }
  130941. else {
  130942. if (!clickInfo.ignore) {
  130943. for (var _i = 0, _a = this._pointerUpStage; _i < _a.length; _i++) {
  130944. var step = _a[_i];
  130945. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, evt);
  130946. }
  130947. }
  130948. }
  130949. if (this._pickedDownMesh && this._pickedDownMesh !== this._pickedUpMesh) {
  130950. var pickedDownActionManager = this._pickedDownMesh._getActionManagerForTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickOutTrigger);
  130951. if (pickedDownActionManager) {
  130952. pickedDownActionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(this._pickedDownMesh, evt));
  130953. }
  130954. }
  130955. var type = 0;
  130956. if (this.onPointerObservable.hasObservers()) {
  130957. if (!clickInfo.ignore && !clickInfo.hasSwiped) {
  130958. if (clickInfo.singleClick && this.onPointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP)) {
  130959. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP;
  130960. }
  130961. else if (clickInfo.doubleClick && this.onPointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP)) {
  130962. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP;
  130963. }
  130964. if (type) {
  130965. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type, evt, pickResult);
  130966. this._setRayOnPointerInfo(pi);
  130967. this.onPointerObservable.notifyObservers(pi, type);
  130968. }
  130969. }
  130970. if (!clickInfo.ignore) {
  130971. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERUP;
  130972. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type, evt, pickResult);
  130973. this._setRayOnPointerInfo(pi);
  130974. this.onPointerObservable.notifyObservers(pi, type);
  130975. }
  130976. }
  130977. if (this.onPointerUp && !clickInfo.ignore) {
  130978. this.onPointerUp(evt, pickResult, type);
  130979. }
  130980. return this;
  130981. };
  130982. /**
  130983. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  130984. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  130985. * @returns true if the pointer was captured
  130986. */
  130987. Scene.prototype.isPointerCaptured = function (pointerId) {
  130988. if (pointerId === void 0) { pointerId = 0; }
  130989. return this._pointerCaptures[pointerId];
  130990. };
  130991. /** @hidden */
  130992. Scene.prototype._isPointerSwiping = function () {
  130993. return Math.abs(this._startingPointerPosition.x - this._pointerX) > Scene.DragMovementThreshold ||
  130994. Math.abs(this._startingPointerPosition.y - this._pointerY) > Scene.DragMovementThreshold;
  130995. };
  130996. /**
  130997. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  130998. * @param attachUp defines if you want to attach events to pointerup
  130999. * @param attachDown defines if you want to attach events to pointerdown
  131000. * @param attachMove defines if you want to attach events to pointermove
  131001. */
  131002. Scene.prototype.attachControl = function (attachUp, attachDown, attachMove) {
  131003. var _this = this;
  131004. if (attachUp === void 0) { attachUp = true; }
  131005. if (attachDown === void 0) { attachDown = true; }
  131006. if (attachMove === void 0) { attachMove = true; }
  131007. this._initActionManager = function (act, clickInfo) {
  131008. if (!_this._meshPickProceed) {
  131009. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerDownPredicate, false, _this.cameraToUseForPointers);
  131010. _this._currentPickResult = pickResult;
  131011. if (pickResult) {
  131012. act = (pickResult.hit && pickResult.pickedMesh) ? pickResult.pickedMesh.actionManager : null;
  131013. }
  131014. _this._meshPickProceed = true;
  131015. }
  131016. return act;
  131017. };
  131018. this._delayedSimpleClick = function (btn, clickInfo, cb) {
  131019. // double click delay is over and that no double click has been raised since, or the 2 consecutive keys pressed are different
  131020. if ((Date.now() - _this._previousStartingPointerTime > Scene.DoubleClickDelay && !_this._doubleClickOccured) ||
  131021. btn !== _this._previousButtonPressed) {
  131022. _this._doubleClickOccured = false;
  131023. clickInfo.singleClick = true;
  131024. clickInfo.ignore = false;
  131025. cb(clickInfo, _this._currentPickResult);
  131026. }
  131027. };
  131028. this._initClickEvent = function (obs1, obs2, evt, cb) {
  131029. var clickInfo = new ClickInfo();
  131030. _this._currentPickResult = null;
  131031. var act = null;
  131032. var checkPicking = obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERPICK) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERPICK)
  131033. || obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP)
  131034. || obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP);
  131035. if (!checkPicking && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"]) {
  131036. act = _this._initActionManager(act, clickInfo);
  131037. if (act) {
  131038. checkPicking = act.hasPickTriggers;
  131039. }
  131040. }
  131041. var needToIgnoreNext = false;
  131042. if (checkPicking) {
  131043. var btn = evt.button;
  131044. clickInfo.hasSwiped = _this._isPointerSwiping();
  131045. if (!clickInfo.hasSwiped) {
  131046. var checkSingleClickImmediately = !Scene.ExclusiveDoubleClickMode;
  131047. if (!checkSingleClickImmediately) {
  131048. checkSingleClickImmediately = !obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP) &&
  131049. !obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP);
  131050. if (checkSingleClickImmediately && !_Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"].HasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger)) {
  131051. act = _this._initActionManager(act, clickInfo);
  131052. if (act) {
  131053. checkSingleClickImmediately = !act.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger);
  131054. }
  131055. }
  131056. }
  131057. if (checkSingleClickImmediately) {
  131058. // single click detected if double click delay is over or two different successive keys pressed without exclusive double click or no double click required
  131059. if (Date.now() - _this._previousStartingPointerTime > Scene.DoubleClickDelay ||
  131060. btn !== _this._previousButtonPressed) {
  131061. clickInfo.singleClick = true;
  131062. cb(clickInfo, _this._currentPickResult);
  131063. needToIgnoreNext = true;
  131064. }
  131065. }
  131066. // at least one double click is required to be check and exclusive double click is enabled
  131067. else {
  131068. // wait that no double click has been raised during the double click delay
  131069. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  131070. _this._delayedSimpleClickTimeout = window.setTimeout(_this._delayedSimpleClick.bind(_this, btn, clickInfo, cb), Scene.DoubleClickDelay);
  131071. }
  131072. var checkDoubleClick = obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP) ||
  131073. obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP);
  131074. if (!checkDoubleClick && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"].HasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger)) {
  131075. act = _this._initActionManager(act, clickInfo);
  131076. if (act) {
  131077. checkDoubleClick = act.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger);
  131078. }
  131079. }
  131080. if (checkDoubleClick) {
  131081. // two successive keys pressed are equal, double click delay is not over and double click has not just occurred
  131082. if (btn === _this._previousButtonPressed &&
  131083. Date.now() - _this._previousStartingPointerTime < Scene.DoubleClickDelay &&
  131084. !_this._doubleClickOccured) {
  131085. // pointer has not moved for 2 clicks, it's a double click
  131086. if (!clickInfo.hasSwiped &&
  131087. !_this._isPointerSwiping()) {
  131088. _this._previousStartingPointerTime = 0;
  131089. _this._doubleClickOccured = true;
  131090. clickInfo.doubleClick = true;
  131091. clickInfo.ignore = false;
  131092. if (Scene.ExclusiveDoubleClickMode && _this._previousDelayedSimpleClickTimeout) {
  131093. clearTimeout(_this._previousDelayedSimpleClickTimeout);
  131094. }
  131095. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  131096. cb(clickInfo, _this._currentPickResult);
  131097. }
  131098. // if the two successive clicks are too far, it's just two simple clicks
  131099. else {
  131100. _this._doubleClickOccured = false;
  131101. _this._previousStartingPointerTime = _this._startingPointerTime;
  131102. _this._previousStartingPointerPosition.x = _this._startingPointerPosition.x;
  131103. _this._previousStartingPointerPosition.y = _this._startingPointerPosition.y;
  131104. _this._previousButtonPressed = btn;
  131105. if (Scene.ExclusiveDoubleClickMode) {
  131106. if (_this._previousDelayedSimpleClickTimeout) {
  131107. clearTimeout(_this._previousDelayedSimpleClickTimeout);
  131108. }
  131109. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  131110. cb(clickInfo, _this._previousPickResult);
  131111. }
  131112. else {
  131113. cb(clickInfo, _this._currentPickResult);
  131114. }
  131115. }
  131116. needToIgnoreNext = true;
  131117. }
  131118. // just the first click of the double has been raised
  131119. else {
  131120. _this._doubleClickOccured = false;
  131121. _this._previousStartingPointerTime = _this._startingPointerTime;
  131122. _this._previousStartingPointerPosition.x = _this._startingPointerPosition.x;
  131123. _this._previousStartingPointerPosition.y = _this._startingPointerPosition.y;
  131124. _this._previousButtonPressed = btn;
  131125. }
  131126. }
  131127. }
  131128. }
  131129. if (!needToIgnoreNext) {
  131130. cb(clickInfo, _this._currentPickResult);
  131131. }
  131132. };
  131133. this._onPointerMove = function (evt) {
  131134. _this._updatePointerPosition(evt);
  131135. // PreObservable support
  131136. 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)) {
  131137. return;
  131138. }
  131139. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  131140. return;
  131141. }
  131142. if (!_this.pointerMovePredicate) {
  131143. _this.pointerMovePredicate = function (mesh) { return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled() && (mesh.enablePointerMoveEvents || _this.constantlyUpdateMeshUnderPointer || (mesh.actionManager !== null && mesh.actionManager !== undefined)); };
  131144. }
  131145. // Meshes
  131146. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerMovePredicate, false, _this.cameraToUseForPointers);
  131147. _this._processPointerMove(pickResult, evt);
  131148. };
  131149. this._onPointerDown = function (evt) {
  131150. _this._totalPointersPressed++;
  131151. _this._pickedDownMesh = null;
  131152. _this._meshPickProceed = false;
  131153. _this._updatePointerPosition(evt);
  131154. if (_this.preventDefaultOnPointerDown && canvas) {
  131155. evt.preventDefault();
  131156. canvas.focus();
  131157. }
  131158. _this._startingPointerPosition.x = _this._pointerX;
  131159. _this._startingPointerPosition.y = _this._pointerY;
  131160. _this._startingPointerTime = Date.now();
  131161. // PreObservable support
  131162. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOWN)) {
  131163. return;
  131164. }
  131165. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  131166. return;
  131167. }
  131168. _this._pointerCaptures[evt.pointerId] = true;
  131169. if (!_this.pointerDownPredicate) {
  131170. _this.pointerDownPredicate = function (mesh) {
  131171. return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled();
  131172. };
  131173. }
  131174. // Meshes
  131175. _this._pickedDownMesh = null;
  131176. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerDownPredicate, false, _this.cameraToUseForPointers);
  131177. _this._processPointerDown(pickResult, evt);
  131178. };
  131179. this._onPointerUp = function (evt) {
  131180. if (_this._totalPointersPressed === 0) { // We are attaching the pointer up to windows because of a bug in FF
  131181. return; // So we need to test it the pointer down was pressed before.
  131182. }
  131183. _this._totalPointersPressed--;
  131184. _this._pickedUpMesh = null;
  131185. _this._meshPickProceed = false;
  131186. _this._updatePointerPosition(evt);
  131187. if (_this.preventDefaultOnPointerUp && canvas) {
  131188. evt.preventDefault();
  131189. canvas.focus();
  131190. }
  131191. _this._initClickEvent(_this.onPrePointerObservable, _this.onPointerObservable, evt, function (clickInfo, pickResult) {
  131192. // PreObservable support
  131193. if (_this.onPrePointerObservable.hasObservers()) {
  131194. if (!clickInfo.ignore) {
  131195. if (!clickInfo.hasSwiped) {
  131196. if (clickInfo.singleClick && _this.onPrePointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP)) {
  131197. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP)) {
  131198. return;
  131199. }
  131200. }
  131201. if (clickInfo.doubleClick && _this.onPrePointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP)) {
  131202. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP)) {
  131203. return;
  131204. }
  131205. }
  131206. }
  131207. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERUP)) {
  131208. return;
  131209. }
  131210. }
  131211. }
  131212. _this._pointerCaptures[evt.pointerId] = false;
  131213. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  131214. return;
  131215. }
  131216. if (!_this.pointerUpPredicate) {
  131217. _this.pointerUpPredicate = function (mesh) {
  131218. return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled();
  131219. };
  131220. }
  131221. // Meshes
  131222. if (!_this._meshPickProceed && (_Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"] && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"].HasTriggers || _this.onPointerObservable.hasObservers())) {
  131223. _this._initActionManager(null, clickInfo);
  131224. }
  131225. if (!pickResult) {
  131226. pickResult = _this._currentPickResult;
  131227. }
  131228. _this._processPointerUp(pickResult, evt, clickInfo);
  131229. _this._previousPickResult = _this._currentPickResult;
  131230. });
  131231. };
  131232. this._onKeyDown = function (evt) {
  131233. var type = _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardEventTypes"].KEYDOWN;
  131234. if (_this.onPreKeyboardObservable.hasObservers()) {
  131235. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardInfoPre"](type, evt);
  131236. _this.onPreKeyboardObservable.notifyObservers(pi, type);
  131237. if (pi.skipOnPointerObservable) {
  131238. return;
  131239. }
  131240. }
  131241. if (_this.onKeyboardObservable.hasObservers()) {
  131242. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardInfo"](type, evt);
  131243. _this.onKeyboardObservable.notifyObservers(pi, type);
  131244. }
  131245. if (_this.actionManager) {
  131246. _this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnKeyDownTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNewFromScene(_this, evt));
  131247. }
  131248. };
  131249. this._onKeyUp = function (evt) {
  131250. var type = _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardEventTypes"].KEYUP;
  131251. if (_this.onPreKeyboardObservable.hasObservers()) {
  131252. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardInfoPre"](type, evt);
  131253. _this.onPreKeyboardObservable.notifyObservers(pi, type);
  131254. if (pi.skipOnPointerObservable) {
  131255. return;
  131256. }
  131257. }
  131258. if (_this.onKeyboardObservable.hasObservers()) {
  131259. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardInfo"](type, evt);
  131260. _this.onKeyboardObservable.notifyObservers(pi, type);
  131261. }
  131262. if (_this.actionManager) {
  131263. _this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnKeyUpTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNewFromScene(_this, evt));
  131264. }
  131265. };
  131266. var engine = this.getEngine();
  131267. this._onCanvasFocusObserver = engine.onCanvasFocusObservable.add(function () {
  131268. if (!canvas) {
  131269. return;
  131270. }
  131271. canvas.addEventListener("keydown", _this._onKeyDown, false);
  131272. canvas.addEventListener("keyup", _this._onKeyUp, false);
  131273. });
  131274. this._onCanvasBlurObserver = engine.onCanvasBlurObservable.add(function () {
  131275. if (!canvas) {
  131276. return;
  131277. }
  131278. canvas.removeEventListener("keydown", _this._onKeyDown);
  131279. canvas.removeEventListener("keyup", _this._onKeyUp);
  131280. });
  131281. var eventPrefix = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetPointerPrefix();
  131282. var canvas = this._engine.getRenderingCanvas();
  131283. if (!canvas) {
  131284. return;
  131285. }
  131286. if (attachMove) {
  131287. canvas.addEventListener(eventPrefix + "move", this._onPointerMove, false);
  131288. // Wheel
  131289. this._wheelEventName = "onwheel" in document.createElement("div") ? "wheel" : // Modern browsers support "wheel"
  131290. document.onmousewheel !== undefined ? "mousewheel" : // Webkit and IE support at least "mousewheel"
  131291. "DOMMouseScroll"; // let's assume that remaining browsers are older Firefox
  131292. canvas.addEventListener(this._wheelEventName, this._onPointerMove, false);
  131293. }
  131294. if (attachDown) {
  131295. canvas.addEventListener(eventPrefix + "down", this._onPointerDown, false);
  131296. }
  131297. if (attachUp) {
  131298. window.addEventListener(eventPrefix + "up", this._onPointerUp, false);
  131299. }
  131300. canvas.tabIndex = 1;
  131301. };
  131302. /** Detaches all event handlers*/
  131303. Scene.prototype.detachControl = function () {
  131304. var engine = this.getEngine();
  131305. var eventPrefix = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetPointerPrefix();
  131306. var canvas = engine.getRenderingCanvas();
  131307. if (!canvas) {
  131308. return;
  131309. }
  131310. canvas.removeEventListener(eventPrefix + "move", this._onPointerMove);
  131311. canvas.removeEventListener(eventPrefix + "down", this._onPointerDown);
  131312. window.removeEventListener(eventPrefix + "up", this._onPointerUp);
  131313. if (this._onCanvasBlurObserver) {
  131314. engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  131315. }
  131316. if (this._onCanvasFocusObserver) {
  131317. engine.onCanvasFocusObservable.remove(this._onCanvasFocusObserver);
  131318. }
  131319. // Wheel
  131320. canvas.removeEventListener(this._wheelEventName, this._onPointerMove);
  131321. // Keyboard
  131322. canvas.removeEventListener("keydown", this._onKeyDown);
  131323. canvas.removeEventListener("keyup", this._onKeyUp);
  131324. // Observables
  131325. this.onKeyboardObservable.clear();
  131326. this.onPreKeyboardObservable.clear();
  131327. this.onPointerObservable.clear();
  131328. this.onPrePointerObservable.clear();
  131329. };
  131330. /**
  131331. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  131332. * Delay loaded resources are not taking in account
  131333. * @return true if all required resources are ready
  131334. */
  131335. Scene.prototype.isReady = function () {
  131336. if (this._isDisposed) {
  131337. return false;
  131338. }
  131339. var index;
  131340. var engine = this.getEngine();
  131341. // Effects
  131342. if (!engine.areAllEffectsReady()) {
  131343. return false;
  131344. }
  131345. // Pending data
  131346. if (this._pendingData.length > 0) {
  131347. return false;
  131348. }
  131349. // Meshes
  131350. for (index = 0; index < this.meshes.length; index++) {
  131351. var mesh = this.meshes[index];
  131352. if (!mesh.isEnabled()) {
  131353. continue;
  131354. }
  131355. if (!mesh.subMeshes || mesh.subMeshes.length === 0) {
  131356. continue;
  131357. }
  131358. if (!mesh.isReady(true)) {
  131359. return false;
  131360. }
  131361. var hardwareInstancedRendering = mesh.getClassName() === "InstancedMesh" || mesh.getClassName() === "InstancedLinesMesh" || engine.getCaps().instancedArrays && mesh.instances.length > 0;
  131362. // Is Ready For Mesh
  131363. for (var _i = 0, _a = this._isReadyForMeshStage; _i < _a.length; _i++) {
  131364. var step = _a[_i];
  131365. if (!step.action(mesh, hardwareInstancedRendering)) {
  131366. return false;
  131367. }
  131368. }
  131369. }
  131370. // Geometries
  131371. for (index = 0; index < this.geometries.length; index++) {
  131372. var geometry = this.geometries[index];
  131373. if (geometry.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].DELAYLOADSTATE_LOADING) {
  131374. return false;
  131375. }
  131376. }
  131377. // Post-processes
  131378. if (this.activeCameras && this.activeCameras.length > 0) {
  131379. for (var _b = 0, _c = this.activeCameras; _b < _c.length; _b++) {
  131380. var camera = _c[_b];
  131381. if (!camera.isReady(true)) {
  131382. return false;
  131383. }
  131384. }
  131385. }
  131386. else if (this.activeCamera) {
  131387. if (!this.activeCamera.isReady(true)) {
  131388. return false;
  131389. }
  131390. }
  131391. // Particles
  131392. for (var _d = 0, _e = this.particleSystems; _d < _e.length; _d++) {
  131393. var particleSystem = _e[_d];
  131394. if (!particleSystem.isReady()) {
  131395. return false;
  131396. }
  131397. }
  131398. return true;
  131399. };
  131400. /** Resets all cached information relative to material (including effect and visibility) */
  131401. Scene.prototype.resetCachedMaterial = function () {
  131402. this._cachedMaterial = null;
  131403. this._cachedEffect = null;
  131404. this._cachedVisibility = null;
  131405. };
  131406. /**
  131407. * Registers a function to be called before every frame render
  131408. * @param func defines the function to register
  131409. */
  131410. Scene.prototype.registerBeforeRender = function (func) {
  131411. this.onBeforeRenderObservable.add(func);
  131412. };
  131413. /**
  131414. * Unregisters a function called before every frame render
  131415. * @param func defines the function to unregister
  131416. */
  131417. Scene.prototype.unregisterBeforeRender = function (func) {
  131418. this.onBeforeRenderObservable.removeCallback(func);
  131419. };
  131420. /**
  131421. * Registers a function to be called after every frame render
  131422. * @param func defines the function to register
  131423. */
  131424. Scene.prototype.registerAfterRender = function (func) {
  131425. this.onAfterRenderObservable.add(func);
  131426. };
  131427. /**
  131428. * Unregisters a function called after every frame render
  131429. * @param func defines the function to unregister
  131430. */
  131431. Scene.prototype.unregisterAfterRender = function (func) {
  131432. this.onAfterRenderObservable.removeCallback(func);
  131433. };
  131434. Scene.prototype._executeOnceBeforeRender = function (func) {
  131435. var _this = this;
  131436. var execFunc = function () {
  131437. func();
  131438. setTimeout(function () {
  131439. _this.unregisterBeforeRender(execFunc);
  131440. });
  131441. };
  131442. this.registerBeforeRender(execFunc);
  131443. };
  131444. /**
  131445. * The provided function will run before render once and will be disposed afterwards.
  131446. * A timeout delay can be provided so that the function will be executed in N ms.
  131447. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  131448. * @param func The function to be executed.
  131449. * @param timeout optional delay in ms
  131450. */
  131451. Scene.prototype.executeOnceBeforeRender = function (func, timeout) {
  131452. var _this = this;
  131453. if (timeout !== undefined) {
  131454. setTimeout(function () {
  131455. _this._executeOnceBeforeRender(func);
  131456. }, timeout);
  131457. }
  131458. else {
  131459. this._executeOnceBeforeRender(func);
  131460. }
  131461. };
  131462. /** @hidden */
  131463. Scene.prototype._addPendingData = function (data) {
  131464. this._pendingData.push(data);
  131465. };
  131466. /** @hidden */
  131467. Scene.prototype._removePendingData = function (data) {
  131468. var wasLoading = this.isLoading;
  131469. var index = this._pendingData.indexOf(data);
  131470. if (index !== -1) {
  131471. this._pendingData.splice(index, 1);
  131472. }
  131473. if (wasLoading && !this.isLoading) {
  131474. this.onDataLoadedObservable.notifyObservers(this);
  131475. }
  131476. };
  131477. /**
  131478. * Returns the number of items waiting to be loaded
  131479. * @returns the number of items waiting to be loaded
  131480. */
  131481. Scene.prototype.getWaitingItemsCount = function () {
  131482. return this._pendingData.length;
  131483. };
  131484. Object.defineProperty(Scene.prototype, "isLoading", {
  131485. /**
  131486. * Returns a boolean indicating if the scene is still loading data
  131487. */
  131488. get: function () {
  131489. return this._pendingData.length > 0;
  131490. },
  131491. enumerable: true,
  131492. configurable: true
  131493. });
  131494. /**
  131495. * Registers a function to be executed when the scene is ready
  131496. * @param {Function} func - the function to be executed
  131497. */
  131498. Scene.prototype.executeWhenReady = function (func) {
  131499. var _this = this;
  131500. this.onReadyObservable.add(func);
  131501. if (this._executeWhenReadyTimeoutId !== -1) {
  131502. return;
  131503. }
  131504. this._executeWhenReadyTimeoutId = setTimeout(function () {
  131505. _this._checkIsReady();
  131506. }, 150);
  131507. };
  131508. /**
  131509. * Returns a promise that resolves when the scene is ready
  131510. * @returns A promise that resolves when the scene is ready
  131511. */
  131512. Scene.prototype.whenReadyAsync = function () {
  131513. var _this = this;
  131514. return new Promise(function (resolve) {
  131515. _this.executeWhenReady(function () {
  131516. resolve();
  131517. });
  131518. });
  131519. };
  131520. /** @hidden */
  131521. Scene.prototype._checkIsReady = function () {
  131522. var _this = this;
  131523. this._registerTransientComponents();
  131524. if (this.isReady()) {
  131525. this.onReadyObservable.notifyObservers(this);
  131526. this.onReadyObservable.clear();
  131527. this._executeWhenReadyTimeoutId = -1;
  131528. return;
  131529. }
  131530. this._executeWhenReadyTimeoutId = setTimeout(function () {
  131531. _this._checkIsReady();
  131532. }, 150);
  131533. };
  131534. Object.defineProperty(Scene.prototype, "animatables", {
  131535. /**
  131536. * Gets all animatable attached to the scene
  131537. */
  131538. get: function () {
  131539. return this._activeAnimatables;
  131540. },
  131541. enumerable: true,
  131542. configurable: true
  131543. });
  131544. /**
  131545. * Resets the last animation time frame.
  131546. * Useful to override when animations start running when loading a scene for the first time.
  131547. */
  131548. Scene.prototype.resetLastAnimationTimeFrame = function () {
  131549. this._animationTimeLast = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_2__["PrecisionDate"].Now;
  131550. };
  131551. // Matrix
  131552. /** @hidden */
  131553. Scene.prototype._switchToAlternateCameraConfiguration = function (active) {
  131554. this._useAlternateCameraConfiguration = active;
  131555. };
  131556. /**
  131557. * Gets the current view matrix
  131558. * @returns a Matrix
  131559. */
  131560. Scene.prototype.getViewMatrix = function () {
  131561. return this._useAlternateCameraConfiguration ? this._alternateViewMatrix : this._viewMatrix;
  131562. };
  131563. /**
  131564. * Gets the current projection matrix
  131565. * @returns a Matrix
  131566. */
  131567. Scene.prototype.getProjectionMatrix = function () {
  131568. return this._useAlternateCameraConfiguration ? this._alternateProjectionMatrix : this._projectionMatrix;
  131569. };
  131570. /**
  131571. * Gets the current transform matrix
  131572. * @returns a Matrix made of View * Projection
  131573. */
  131574. Scene.prototype.getTransformMatrix = function () {
  131575. return this._useAlternateCameraConfiguration ? this._alternateTransformMatrix : this._transformMatrix;
  131576. };
  131577. /**
  131578. * Sets the current transform matrix
  131579. * @param view defines the View matrix to use
  131580. * @param projection defines the Projection matrix to use
  131581. */
  131582. Scene.prototype.setTransformMatrix = function (view, projection) {
  131583. if (this._viewUpdateFlag === view.updateFlag && this._projectionUpdateFlag === projection.updateFlag) {
  131584. return;
  131585. }
  131586. this._viewUpdateFlag = view.updateFlag;
  131587. this._projectionUpdateFlag = projection.updateFlag;
  131588. this._viewMatrix = view;
  131589. this._projectionMatrix = projection;
  131590. this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  131591. // Update frustum
  131592. if (!this._frustumPlanes) {
  131593. this._frustumPlanes = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Frustum"].GetPlanes(this._transformMatrix);
  131594. }
  131595. else {
  131596. _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Frustum"].GetPlanesToRef(this._transformMatrix, this._frustumPlanes);
  131597. }
  131598. if (this.activeCamera && this.activeCamera._alternateCamera) {
  131599. var otherCamera = this.activeCamera._alternateCamera;
  131600. otherCamera.getViewMatrix().multiplyToRef(otherCamera.getProjectionMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Tmp"].Matrix[0]);
  131601. _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
  131602. }
  131603. if (this._sceneUbo.useUbo) {
  131604. this._sceneUbo.updateMatrix("viewProjection", this._transformMatrix);
  131605. this._sceneUbo.updateMatrix("view", this._viewMatrix);
  131606. this._sceneUbo.update();
  131607. }
  131608. };
  131609. /** @hidden */
  131610. Scene.prototype._setAlternateTransformMatrix = function (view, projection) {
  131611. if (this._alternateViewUpdateFlag === view.updateFlag && this._alternateProjectionUpdateFlag === projection.updateFlag) {
  131612. return;
  131613. }
  131614. this._alternateViewUpdateFlag = view.updateFlag;
  131615. this._alternateProjectionUpdateFlag = projection.updateFlag;
  131616. this._alternateViewMatrix = view;
  131617. this._alternateProjectionMatrix = projection;
  131618. if (!this._alternateTransformMatrix) {
  131619. this._alternateTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Zero();
  131620. }
  131621. this._alternateViewMatrix.multiplyToRef(this._alternateProjectionMatrix, this._alternateTransformMatrix);
  131622. if (!this._alternateSceneUbo) {
  131623. this._createAlternateUbo();
  131624. }
  131625. if (this._alternateSceneUbo.useUbo) {
  131626. this._alternateSceneUbo.updateMatrix("viewProjection", this._alternateTransformMatrix);
  131627. this._alternateSceneUbo.updateMatrix("view", this._alternateViewMatrix);
  131628. this._alternateSceneUbo.update();
  131629. }
  131630. };
  131631. /**
  131632. * Gets the uniform buffer used to store scene data
  131633. * @returns a UniformBuffer
  131634. */
  131635. Scene.prototype.getSceneUniformBuffer = function () {
  131636. return this._useAlternateCameraConfiguration ? this._alternateSceneUbo : this._sceneUbo;
  131637. };
  131638. /**
  131639. * Gets an unique (relatively to the current scene) Id
  131640. * @returns an unique number for the scene
  131641. */
  131642. Scene.prototype.getUniqueId = function () {
  131643. var result = Scene._uniqueIdCounter;
  131644. Scene._uniqueIdCounter++;
  131645. return result;
  131646. };
  131647. /**
  131648. * Add a mesh to the list of scene's meshes
  131649. * @param newMesh defines the mesh to add
  131650. * @param recursive if all child meshes should also be added to the scene
  131651. */
  131652. Scene.prototype.addMesh = function (newMesh, recursive) {
  131653. var _this = this;
  131654. if (recursive === void 0) { recursive = false; }
  131655. this.meshes.push(newMesh);
  131656. newMesh._resyncLightSources();
  131657. this.onNewMeshAddedObservable.notifyObservers(newMesh);
  131658. if (recursive) {
  131659. newMesh.getChildMeshes().forEach(function (m) {
  131660. _this.addMesh(m);
  131661. });
  131662. }
  131663. };
  131664. /**
  131665. * Remove a mesh for the list of scene's meshes
  131666. * @param toRemove defines the mesh to remove
  131667. * @param recursive if all child meshes should also be removed from the scene
  131668. * @returns the index where the mesh was in the mesh list
  131669. */
  131670. Scene.prototype.removeMesh = function (toRemove, recursive) {
  131671. var _this = this;
  131672. if (recursive === void 0) { recursive = false; }
  131673. var index = this.meshes.indexOf(toRemove);
  131674. if (index !== -1) {
  131675. // Remove from the scene if mesh found
  131676. this.meshes[index] = this.meshes[this.meshes.length - 1];
  131677. this.meshes.pop();
  131678. }
  131679. this.onMeshRemovedObservable.notifyObservers(toRemove);
  131680. if (recursive) {
  131681. toRemove.getChildMeshes().forEach(function (m) {
  131682. _this.removeMesh(m);
  131683. });
  131684. }
  131685. return index;
  131686. };
  131687. /**
  131688. * Add a transform node to the list of scene's transform nodes
  131689. * @param newTransformNode defines the transform node to add
  131690. */
  131691. Scene.prototype.addTransformNode = function (newTransformNode) {
  131692. newTransformNode._indexInSceneTransformNodesArray = this.transformNodes.length;
  131693. this.transformNodes.push(newTransformNode);
  131694. this.onNewTransformNodeAddedObservable.notifyObservers(newTransformNode);
  131695. };
  131696. /**
  131697. * Remove a transform node for the list of scene's transform nodes
  131698. * @param toRemove defines the transform node to remove
  131699. * @returns the index where the transform node was in the transform node list
  131700. */
  131701. Scene.prototype.removeTransformNode = function (toRemove) {
  131702. var index = toRemove._indexInSceneTransformNodesArray;
  131703. if (index !== -1) {
  131704. if (index !== this.transformNodes.length - 1) {
  131705. var lastNode = this.transformNodes[this.transformNodes.length - 1];
  131706. this.transformNodes[index] = lastNode;
  131707. lastNode._indexInSceneTransformNodesArray = index;
  131708. }
  131709. toRemove._indexInSceneTransformNodesArray = -1;
  131710. this.transformNodes.pop();
  131711. }
  131712. this.onTransformNodeRemovedObservable.notifyObservers(toRemove);
  131713. return index;
  131714. };
  131715. /**
  131716. * Remove a skeleton for the list of scene's skeletons
  131717. * @param toRemove defines the skeleton to remove
  131718. * @returns the index where the skeleton was in the skeleton list
  131719. */
  131720. Scene.prototype.removeSkeleton = function (toRemove) {
  131721. var index = this.skeletons.indexOf(toRemove);
  131722. if (index !== -1) {
  131723. // Remove from the scene if found
  131724. this.skeletons.splice(index, 1);
  131725. }
  131726. return index;
  131727. };
  131728. /**
  131729. * Remove a morph target for the list of scene's morph targets
  131730. * @param toRemove defines the morph target to remove
  131731. * @returns the index where the morph target was in the morph target list
  131732. */
  131733. Scene.prototype.removeMorphTargetManager = function (toRemove) {
  131734. var index = this.morphTargetManagers.indexOf(toRemove);
  131735. if (index !== -1) {
  131736. // Remove from the scene if found
  131737. this.morphTargetManagers.splice(index, 1);
  131738. }
  131739. return index;
  131740. };
  131741. /**
  131742. * Remove a light for the list of scene's lights
  131743. * @param toRemove defines the light to remove
  131744. * @returns the index where the light was in the light list
  131745. */
  131746. Scene.prototype.removeLight = function (toRemove) {
  131747. var index = this.lights.indexOf(toRemove);
  131748. if (index !== -1) {
  131749. // Remove from meshes
  131750. for (var _i = 0, _a = this.meshes; _i < _a.length; _i++) {
  131751. var mesh = _a[_i];
  131752. mesh._removeLightSource(toRemove);
  131753. }
  131754. // Remove from the scene if mesh found
  131755. this.lights.splice(index, 1);
  131756. this.sortLightsByPriority();
  131757. }
  131758. this.onLightRemovedObservable.notifyObservers(toRemove);
  131759. return index;
  131760. };
  131761. /**
  131762. * Remove a camera for the list of scene's cameras
  131763. * @param toRemove defines the camera to remove
  131764. * @returns the index where the camera was in the camera list
  131765. */
  131766. Scene.prototype.removeCamera = function (toRemove) {
  131767. var index = this.cameras.indexOf(toRemove);
  131768. if (index !== -1) {
  131769. // Remove from the scene if mesh found
  131770. this.cameras.splice(index, 1);
  131771. }
  131772. // Remove from activeCameras
  131773. var index2 = this.activeCameras.indexOf(toRemove);
  131774. if (index2 !== -1) {
  131775. // Remove from the scene if mesh found
  131776. this.activeCameras.splice(index2, 1);
  131777. }
  131778. // Reset the activeCamera
  131779. if (this.activeCamera === toRemove) {
  131780. if (this.cameras.length > 0) {
  131781. this.activeCamera = this.cameras[0];
  131782. }
  131783. else {
  131784. this.activeCamera = null;
  131785. }
  131786. }
  131787. this.onCameraRemovedObservable.notifyObservers(toRemove);
  131788. return index;
  131789. };
  131790. /**
  131791. * Remove a particle system for the list of scene's particle systems
  131792. * @param toRemove defines the particle system to remove
  131793. * @returns the index where the particle system was in the particle system list
  131794. */
  131795. Scene.prototype.removeParticleSystem = function (toRemove) {
  131796. var index = this.particleSystems.indexOf(toRemove);
  131797. if (index !== -1) {
  131798. this.particleSystems.splice(index, 1);
  131799. }
  131800. return index;
  131801. };
  131802. /**
  131803. * Remove a animation for the list of scene's animations
  131804. * @param toRemove defines the animation to remove
  131805. * @returns the index where the animation was in the animation list
  131806. */
  131807. Scene.prototype.removeAnimation = function (toRemove) {
  131808. var index = this.animations.indexOf(toRemove);
  131809. if (index !== -1) {
  131810. this.animations.splice(index, 1);
  131811. }
  131812. return index;
  131813. };
  131814. /**
  131815. * Removes the given animation group from this scene.
  131816. * @param toRemove The animation group to remove
  131817. * @returns The index of the removed animation group
  131818. */
  131819. Scene.prototype.removeAnimationGroup = function (toRemove) {
  131820. var index = this.animationGroups.indexOf(toRemove);
  131821. if (index !== -1) {
  131822. this.animationGroups.splice(index, 1);
  131823. }
  131824. return index;
  131825. };
  131826. /**
  131827. * Removes the given multi-material from this scene.
  131828. * @param toRemove The multi-material to remove
  131829. * @returns The index of the removed multi-material
  131830. */
  131831. Scene.prototype.removeMultiMaterial = function (toRemove) {
  131832. var index = this.multiMaterials.indexOf(toRemove);
  131833. if (index !== -1) {
  131834. this.multiMaterials.splice(index, 1);
  131835. }
  131836. return index;
  131837. };
  131838. /**
  131839. * Removes the given material from this scene.
  131840. * @param toRemove The material to remove
  131841. * @returns The index of the removed material
  131842. */
  131843. Scene.prototype.removeMaterial = function (toRemove) {
  131844. var index = toRemove._indexInSceneMaterialArray;
  131845. if (index !== -1 && index < this.materials.length) {
  131846. if (index !== this.materials.length - 1) {
  131847. var lastMaterial = this.materials[this.materials.length - 1];
  131848. this.materials[index] = lastMaterial;
  131849. lastMaterial._indexInSceneMaterialArray = index;
  131850. }
  131851. toRemove._indexInSceneMaterialArray = -1;
  131852. this.materials.pop();
  131853. }
  131854. this.onMaterialRemovedObservable.notifyObservers(toRemove);
  131855. return index;
  131856. };
  131857. /**
  131858. * Removes the given action manager from this scene.
  131859. * @param toRemove The action manager to remove
  131860. * @returns The index of the removed action manager
  131861. */
  131862. Scene.prototype.removeActionManager = function (toRemove) {
  131863. var index = this.actionManagers.indexOf(toRemove);
  131864. if (index !== -1) {
  131865. this.actionManagers.splice(index, 1);
  131866. }
  131867. return index;
  131868. };
  131869. /**
  131870. * Removes the given texture from this scene.
  131871. * @param toRemove The texture to remove
  131872. * @returns The index of the removed texture
  131873. */
  131874. Scene.prototype.removeTexture = function (toRemove) {
  131875. var index = this.textures.indexOf(toRemove);
  131876. if (index !== -1) {
  131877. this.textures.splice(index, 1);
  131878. }
  131879. this.onTextureRemovedObservable.notifyObservers(toRemove);
  131880. return index;
  131881. };
  131882. /**
  131883. * Adds the given light to this scene
  131884. * @param newLight The light to add
  131885. */
  131886. Scene.prototype.addLight = function (newLight) {
  131887. this.lights.push(newLight);
  131888. this.sortLightsByPriority();
  131889. // Add light to all meshes (To support if the light is removed and then readded)
  131890. for (var _i = 0, _a = this.meshes; _i < _a.length; _i++) {
  131891. var mesh = _a[_i];
  131892. if (mesh._lightSources.indexOf(newLight) === -1) {
  131893. mesh._lightSources.push(newLight);
  131894. mesh._resyncLightSources();
  131895. }
  131896. }
  131897. this.onNewLightAddedObservable.notifyObservers(newLight);
  131898. };
  131899. /**
  131900. * Sorts the list list based on light priorities
  131901. */
  131902. Scene.prototype.sortLightsByPriority = function () {
  131903. if (this.requireLightSorting) {
  131904. this.lights.sort(_Lights_light__WEBPACK_IMPORTED_MODULE_13__["Light"].CompareLightsPriority);
  131905. }
  131906. };
  131907. /**
  131908. * Adds the given camera to this scene
  131909. * @param newCamera The camera to add
  131910. */
  131911. Scene.prototype.addCamera = function (newCamera) {
  131912. this.cameras.push(newCamera);
  131913. this.onNewCameraAddedObservable.notifyObservers(newCamera);
  131914. };
  131915. /**
  131916. * Adds the given skeleton to this scene
  131917. * @param newSkeleton The skeleton to add
  131918. */
  131919. Scene.prototype.addSkeleton = function (newSkeleton) {
  131920. this.skeletons.push(newSkeleton);
  131921. };
  131922. /**
  131923. * Adds the given particle system to this scene
  131924. * @param newParticleSystem The particle system to add
  131925. */
  131926. Scene.prototype.addParticleSystem = function (newParticleSystem) {
  131927. this.particleSystems.push(newParticleSystem);
  131928. };
  131929. /**
  131930. * Adds the given animation to this scene
  131931. * @param newAnimation The animation to add
  131932. */
  131933. Scene.prototype.addAnimation = function (newAnimation) {
  131934. this.animations.push(newAnimation);
  131935. };
  131936. /**
  131937. * Adds the given animation group to this scene.
  131938. * @param newAnimationGroup The animation group to add
  131939. */
  131940. Scene.prototype.addAnimationGroup = function (newAnimationGroup) {
  131941. this.animationGroups.push(newAnimationGroup);
  131942. };
  131943. /**
  131944. * Adds the given multi-material to this scene
  131945. * @param newMultiMaterial The multi-material to add
  131946. */
  131947. Scene.prototype.addMultiMaterial = function (newMultiMaterial) {
  131948. this.multiMaterials.push(newMultiMaterial);
  131949. };
  131950. /**
  131951. * Adds the given material to this scene
  131952. * @param newMaterial The material to add
  131953. */
  131954. Scene.prototype.addMaterial = function (newMaterial) {
  131955. newMaterial._indexInSceneMaterialArray = this.materials.length;
  131956. this.materials.push(newMaterial);
  131957. this.onNewMaterialAddedObservable.notifyObservers(newMaterial);
  131958. };
  131959. /**
  131960. * Adds the given morph target to this scene
  131961. * @param newMorphTargetManager The morph target to add
  131962. */
  131963. Scene.prototype.addMorphTargetManager = function (newMorphTargetManager) {
  131964. this.morphTargetManagers.push(newMorphTargetManager);
  131965. };
  131966. /**
  131967. * Adds the given geometry to this scene
  131968. * @param newGeometry The geometry to add
  131969. */
  131970. Scene.prototype.addGeometry = function (newGeometry) {
  131971. if (this.geometriesByUniqueId) {
  131972. this.geometriesByUniqueId[newGeometry.uniqueId] = this.geometries.length;
  131973. }
  131974. this.geometries.push(newGeometry);
  131975. };
  131976. /**
  131977. * Adds the given action manager to this scene
  131978. * @param newActionManager The action manager to add
  131979. */
  131980. Scene.prototype.addActionManager = function (newActionManager) {
  131981. this.actionManagers.push(newActionManager);
  131982. };
  131983. /**
  131984. * Adds the given texture to this scene.
  131985. * @param newTexture The texture to add
  131986. */
  131987. Scene.prototype.addTexture = function (newTexture) {
  131988. this.textures.push(newTexture);
  131989. this.onNewTextureAddedObservable.notifyObservers(newTexture);
  131990. };
  131991. /**
  131992. * Switch active camera
  131993. * @param newCamera defines the new active camera
  131994. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  131995. */
  131996. Scene.prototype.switchActiveCamera = function (newCamera, attachControl) {
  131997. if (attachControl === void 0) { attachControl = true; }
  131998. var canvas = this._engine.getRenderingCanvas();
  131999. if (!canvas) {
  132000. return;
  132001. }
  132002. if (this.activeCamera) {
  132003. this.activeCamera.detachControl(canvas);
  132004. }
  132005. this.activeCamera = newCamera;
  132006. if (attachControl) {
  132007. newCamera.attachControl(canvas);
  132008. }
  132009. };
  132010. /**
  132011. * sets the active camera of the scene using its ID
  132012. * @param id defines the camera's ID
  132013. * @return the new active camera or null if none found.
  132014. */
  132015. Scene.prototype.setActiveCameraByID = function (id) {
  132016. var camera = this.getCameraByID(id);
  132017. if (camera) {
  132018. this.activeCamera = camera;
  132019. return camera;
  132020. }
  132021. return null;
  132022. };
  132023. /**
  132024. * sets the active camera of the scene using its name
  132025. * @param name defines the camera's name
  132026. * @returns the new active camera or null if none found.
  132027. */
  132028. Scene.prototype.setActiveCameraByName = function (name) {
  132029. var camera = this.getCameraByName(name);
  132030. if (camera) {
  132031. this.activeCamera = camera;
  132032. return camera;
  132033. }
  132034. return null;
  132035. };
  132036. /**
  132037. * get an animation group using its name
  132038. * @param name defines the material's name
  132039. * @return the animation group or null if none found.
  132040. */
  132041. Scene.prototype.getAnimationGroupByName = function (name) {
  132042. for (var index = 0; index < this.animationGroups.length; index++) {
  132043. if (this.animationGroups[index].name === name) {
  132044. return this.animationGroups[index];
  132045. }
  132046. }
  132047. return null;
  132048. };
  132049. /**
  132050. * get a material using its id
  132051. * @param id defines the material's ID
  132052. * @return the material or null if none found.
  132053. */
  132054. Scene.prototype.getMaterialByID = function (id) {
  132055. for (var index = 0; index < this.materials.length; index++) {
  132056. if (this.materials[index].id === id) {
  132057. return this.materials[index];
  132058. }
  132059. }
  132060. return null;
  132061. };
  132062. /**
  132063. * Gets a material using its name
  132064. * @param name defines the material's name
  132065. * @return the material or null if none found.
  132066. */
  132067. Scene.prototype.getMaterialByName = function (name) {
  132068. for (var index = 0; index < this.materials.length; index++) {
  132069. if (this.materials[index].name === name) {
  132070. return this.materials[index];
  132071. }
  132072. }
  132073. return null;
  132074. };
  132075. /**
  132076. * Gets a camera using its id
  132077. * @param id defines the id to look for
  132078. * @returns the camera or null if not found
  132079. */
  132080. Scene.prototype.getCameraByID = function (id) {
  132081. for (var index = 0; index < this.cameras.length; index++) {
  132082. if (this.cameras[index].id === id) {
  132083. return this.cameras[index];
  132084. }
  132085. }
  132086. return null;
  132087. };
  132088. /**
  132089. * Gets a camera using its unique id
  132090. * @param uniqueId defines the unique id to look for
  132091. * @returns the camera or null if not found
  132092. */
  132093. Scene.prototype.getCameraByUniqueID = function (uniqueId) {
  132094. for (var index = 0; index < this.cameras.length; index++) {
  132095. if (this.cameras[index].uniqueId === uniqueId) {
  132096. return this.cameras[index];
  132097. }
  132098. }
  132099. return null;
  132100. };
  132101. /**
  132102. * Gets a camera using its name
  132103. * @param name defines the camera's name
  132104. * @return the camera or null if none found.
  132105. */
  132106. Scene.prototype.getCameraByName = function (name) {
  132107. for (var index = 0; index < this.cameras.length; index++) {
  132108. if (this.cameras[index].name === name) {
  132109. return this.cameras[index];
  132110. }
  132111. }
  132112. return null;
  132113. };
  132114. /**
  132115. * Gets a bone using its id
  132116. * @param id defines the bone's id
  132117. * @return the bone or null if not found
  132118. */
  132119. Scene.prototype.getBoneByID = function (id) {
  132120. for (var skeletonIndex = 0; skeletonIndex < this.skeletons.length; skeletonIndex++) {
  132121. var skeleton = this.skeletons[skeletonIndex];
  132122. for (var boneIndex = 0; boneIndex < skeleton.bones.length; boneIndex++) {
  132123. if (skeleton.bones[boneIndex].id === id) {
  132124. return skeleton.bones[boneIndex];
  132125. }
  132126. }
  132127. }
  132128. return null;
  132129. };
  132130. /**
  132131. * Gets a bone using its id
  132132. * @param name defines the bone's name
  132133. * @return the bone or null if not found
  132134. */
  132135. Scene.prototype.getBoneByName = function (name) {
  132136. for (var skeletonIndex = 0; skeletonIndex < this.skeletons.length; skeletonIndex++) {
  132137. var skeleton = this.skeletons[skeletonIndex];
  132138. for (var boneIndex = 0; boneIndex < skeleton.bones.length; boneIndex++) {
  132139. if (skeleton.bones[boneIndex].name === name) {
  132140. return skeleton.bones[boneIndex];
  132141. }
  132142. }
  132143. }
  132144. return null;
  132145. };
  132146. /**
  132147. * Gets a light node using its name
  132148. * @param name defines the the light's name
  132149. * @return the light or null if none found.
  132150. */
  132151. Scene.prototype.getLightByName = function (name) {
  132152. for (var index = 0; index < this.lights.length; index++) {
  132153. if (this.lights[index].name === name) {
  132154. return this.lights[index];
  132155. }
  132156. }
  132157. return null;
  132158. };
  132159. /**
  132160. * Gets a light node using its id
  132161. * @param id defines the light's id
  132162. * @return the light or null if none found.
  132163. */
  132164. Scene.prototype.getLightByID = function (id) {
  132165. for (var index = 0; index < this.lights.length; index++) {
  132166. if (this.lights[index].id === id) {
  132167. return this.lights[index];
  132168. }
  132169. }
  132170. return null;
  132171. };
  132172. /**
  132173. * Gets a light node using its scene-generated unique ID
  132174. * @param uniqueId defines the light's unique id
  132175. * @return the light or null if none found.
  132176. */
  132177. Scene.prototype.getLightByUniqueID = function (uniqueId) {
  132178. for (var index = 0; index < this.lights.length; index++) {
  132179. if (this.lights[index].uniqueId === uniqueId) {
  132180. return this.lights[index];
  132181. }
  132182. }
  132183. return null;
  132184. };
  132185. /**
  132186. * Gets a particle system by id
  132187. * @param id defines the particle system id
  132188. * @return the corresponding system or null if none found
  132189. */
  132190. Scene.prototype.getParticleSystemByID = function (id) {
  132191. for (var index = 0; index < this.particleSystems.length; index++) {
  132192. if (this.particleSystems[index].id === id) {
  132193. return this.particleSystems[index];
  132194. }
  132195. }
  132196. return null;
  132197. };
  132198. /**
  132199. * Gets a geometry using its ID
  132200. * @param id defines the geometry's id
  132201. * @return the geometry or null if none found.
  132202. */
  132203. Scene.prototype.getGeometryByID = function (id) {
  132204. for (var index = 0; index < this.geometries.length; index++) {
  132205. if (this.geometries[index].id === id) {
  132206. return this.geometries[index];
  132207. }
  132208. }
  132209. return null;
  132210. };
  132211. Scene.prototype._getGeometryByUniqueID = function (uniqueId) {
  132212. if (this.geometriesByUniqueId) {
  132213. var index_1 = this.geometriesByUniqueId[uniqueId];
  132214. if (index_1 !== undefined) {
  132215. return this.geometries[index_1];
  132216. }
  132217. }
  132218. else {
  132219. for (var index = 0; index < this.geometries.length; index++) {
  132220. if (this.geometries[index].uniqueId === uniqueId) {
  132221. return this.geometries[index];
  132222. }
  132223. }
  132224. }
  132225. return null;
  132226. };
  132227. /**
  132228. * Add a new geometry to this scene
  132229. * @param geometry defines the geometry to be added to the scene.
  132230. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  132231. * @return a boolean defining if the geometry was added or not
  132232. */
  132233. Scene.prototype.pushGeometry = function (geometry, force) {
  132234. if (!force && this._getGeometryByUniqueID(geometry.uniqueId)) {
  132235. return false;
  132236. }
  132237. this.addGeometry(geometry);
  132238. this.onNewGeometryAddedObservable.notifyObservers(geometry);
  132239. return true;
  132240. };
  132241. /**
  132242. * Removes an existing geometry
  132243. * @param geometry defines the geometry to be removed from the scene
  132244. * @return a boolean defining if the geometry was removed or not
  132245. */
  132246. Scene.prototype.removeGeometry = function (geometry) {
  132247. var index;
  132248. if (this.geometriesByUniqueId) {
  132249. index = this.geometriesByUniqueId[geometry.uniqueId];
  132250. if (index === undefined) {
  132251. return false;
  132252. }
  132253. }
  132254. else {
  132255. index = this.geometries.indexOf(geometry);
  132256. if (index < 0) {
  132257. return false;
  132258. }
  132259. }
  132260. if (index !== this.geometries.length - 1) {
  132261. var lastGeometry = this.geometries[this.geometries.length - 1];
  132262. this.geometries[index] = lastGeometry;
  132263. if (this.geometriesByUniqueId) {
  132264. this.geometriesByUniqueId[lastGeometry.uniqueId] = index;
  132265. this.geometriesByUniqueId[geometry.uniqueId] = undefined;
  132266. }
  132267. }
  132268. this.geometries.pop();
  132269. this.onGeometryRemovedObservable.notifyObservers(geometry);
  132270. return true;
  132271. };
  132272. /**
  132273. * Gets the list of geometries attached to the scene
  132274. * @returns an array of Geometry
  132275. */
  132276. Scene.prototype.getGeometries = function () {
  132277. return this.geometries;
  132278. };
  132279. /**
  132280. * Gets the first added mesh found of a given ID
  132281. * @param id defines the id to search for
  132282. * @return the mesh found or null if not found at all
  132283. */
  132284. Scene.prototype.getMeshByID = function (id) {
  132285. for (var index = 0; index < this.meshes.length; index++) {
  132286. if (this.meshes[index].id === id) {
  132287. return this.meshes[index];
  132288. }
  132289. }
  132290. return null;
  132291. };
  132292. /**
  132293. * Gets a list of meshes using their id
  132294. * @param id defines the id to search for
  132295. * @returns a list of meshes
  132296. */
  132297. Scene.prototype.getMeshesByID = function (id) {
  132298. return this.meshes.filter(function (m) {
  132299. return m.id === id;
  132300. });
  132301. };
  132302. /**
  132303. * Gets the first added transform node found of a given ID
  132304. * @param id defines the id to search for
  132305. * @return the found transform node or null if not found at all.
  132306. */
  132307. Scene.prototype.getTransformNodeByID = function (id) {
  132308. for (var index = 0; index < this.transformNodes.length; index++) {
  132309. if (this.transformNodes[index].id === id) {
  132310. return this.transformNodes[index];
  132311. }
  132312. }
  132313. return null;
  132314. };
  132315. /**
  132316. * Gets a list of transform nodes using their id
  132317. * @param id defines the id to search for
  132318. * @returns a list of transform nodes
  132319. */
  132320. Scene.prototype.getTransformNodesByID = function (id) {
  132321. return this.transformNodes.filter(function (m) {
  132322. return m.id === id;
  132323. });
  132324. };
  132325. /**
  132326. * Gets a mesh with its auto-generated unique id
  132327. * @param uniqueId defines the unique id to search for
  132328. * @return the found mesh or null if not found at all.
  132329. */
  132330. Scene.prototype.getMeshByUniqueID = function (uniqueId) {
  132331. for (var index = 0; index < this.meshes.length; index++) {
  132332. if (this.meshes[index].uniqueId === uniqueId) {
  132333. return this.meshes[index];
  132334. }
  132335. }
  132336. return null;
  132337. };
  132338. /**
  132339. * Gets a the last added mesh using a given id
  132340. * @param id defines the id to search for
  132341. * @return the found mesh or null if not found at all.
  132342. */
  132343. Scene.prototype.getLastMeshByID = function (id) {
  132344. for (var index = this.meshes.length - 1; index >= 0; index--) {
  132345. if (this.meshes[index].id === id) {
  132346. return this.meshes[index];
  132347. }
  132348. }
  132349. return null;
  132350. };
  132351. /**
  132352. * Gets a the last added node (Mesh, Camera, Light) using a given id
  132353. * @param id defines the id to search for
  132354. * @return the found node or null if not found at all
  132355. */
  132356. Scene.prototype.getLastEntryByID = function (id) {
  132357. var index;
  132358. for (index = this.meshes.length - 1; index >= 0; index--) {
  132359. if (this.meshes[index].id === id) {
  132360. return this.meshes[index];
  132361. }
  132362. }
  132363. for (index = this.transformNodes.length - 1; index >= 0; index--) {
  132364. if (this.transformNodes[index].id === id) {
  132365. return this.transformNodes[index];
  132366. }
  132367. }
  132368. for (index = this.cameras.length - 1; index >= 0; index--) {
  132369. if (this.cameras[index].id === id) {
  132370. return this.cameras[index];
  132371. }
  132372. }
  132373. for (index = this.lights.length - 1; index >= 0; index--) {
  132374. if (this.lights[index].id === id) {
  132375. return this.lights[index];
  132376. }
  132377. }
  132378. return null;
  132379. };
  132380. /**
  132381. * Gets a node (Mesh, Camera, Light) using a given id
  132382. * @param id defines the id to search for
  132383. * @return the found node or null if not found at all
  132384. */
  132385. Scene.prototype.getNodeByID = function (id) {
  132386. var mesh = this.getMeshByID(id);
  132387. if (mesh) {
  132388. return mesh;
  132389. }
  132390. var transformNode = this.getTransformNodeByID(id);
  132391. if (transformNode) {
  132392. return transformNode;
  132393. }
  132394. var light = this.getLightByID(id);
  132395. if (light) {
  132396. return light;
  132397. }
  132398. var camera = this.getCameraByID(id);
  132399. if (camera) {
  132400. return camera;
  132401. }
  132402. var bone = this.getBoneByID(id);
  132403. if (bone) {
  132404. return bone;
  132405. }
  132406. return null;
  132407. };
  132408. /**
  132409. * Gets a node (Mesh, Camera, Light) using a given name
  132410. * @param name defines the name to search for
  132411. * @return the found node or null if not found at all.
  132412. */
  132413. Scene.prototype.getNodeByName = function (name) {
  132414. var mesh = this.getMeshByName(name);
  132415. if (mesh) {
  132416. return mesh;
  132417. }
  132418. var transformNode = this.getTransformNodeByName(name);
  132419. if (transformNode) {
  132420. return transformNode;
  132421. }
  132422. var light = this.getLightByName(name);
  132423. if (light) {
  132424. return light;
  132425. }
  132426. var camera = this.getCameraByName(name);
  132427. if (camera) {
  132428. return camera;
  132429. }
  132430. var bone = this.getBoneByName(name);
  132431. if (bone) {
  132432. return bone;
  132433. }
  132434. return null;
  132435. };
  132436. /**
  132437. * Gets a mesh using a given name
  132438. * @param name defines the name to search for
  132439. * @return the found mesh or null if not found at all.
  132440. */
  132441. Scene.prototype.getMeshByName = function (name) {
  132442. for (var index = 0; index < this.meshes.length; index++) {
  132443. if (this.meshes[index].name === name) {
  132444. return this.meshes[index];
  132445. }
  132446. }
  132447. return null;
  132448. };
  132449. /**
  132450. * Gets a transform node using a given name
  132451. * @param name defines the name to search for
  132452. * @return the found transform node or null if not found at all.
  132453. */
  132454. Scene.prototype.getTransformNodeByName = function (name) {
  132455. for (var index = 0; index < this.transformNodes.length; index++) {
  132456. if (this.transformNodes[index].name === name) {
  132457. return this.transformNodes[index];
  132458. }
  132459. }
  132460. return null;
  132461. };
  132462. /**
  132463. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  132464. * @param id defines the id to search for
  132465. * @return the found skeleton or null if not found at all.
  132466. */
  132467. Scene.prototype.getLastSkeletonByID = function (id) {
  132468. for (var index = this.skeletons.length - 1; index >= 0; index--) {
  132469. if (this.skeletons[index].id === id) {
  132470. return this.skeletons[index];
  132471. }
  132472. }
  132473. return null;
  132474. };
  132475. /**
  132476. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  132477. * @param id defines the id to search for
  132478. * @return the found skeleton or null if not found at all.
  132479. */
  132480. Scene.prototype.getSkeletonById = function (id) {
  132481. for (var index = 0; index < this.skeletons.length; index++) {
  132482. if (this.skeletons[index].id === id) {
  132483. return this.skeletons[index];
  132484. }
  132485. }
  132486. return null;
  132487. };
  132488. /**
  132489. * Gets a skeleton using a given name
  132490. * @param name defines the name to search for
  132491. * @return the found skeleton or null if not found at all.
  132492. */
  132493. Scene.prototype.getSkeletonByName = function (name) {
  132494. for (var index = 0; index < this.skeletons.length; index++) {
  132495. if (this.skeletons[index].name === name) {
  132496. return this.skeletons[index];
  132497. }
  132498. }
  132499. return null;
  132500. };
  132501. /**
  132502. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  132503. * @param id defines the id to search for
  132504. * @return the found morph target manager or null if not found at all.
  132505. */
  132506. Scene.prototype.getMorphTargetManagerById = function (id) {
  132507. for (var index = 0; index < this.morphTargetManagers.length; index++) {
  132508. if (this.morphTargetManagers[index].uniqueId === id) {
  132509. return this.morphTargetManagers[index];
  132510. }
  132511. }
  132512. return null;
  132513. };
  132514. /**
  132515. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  132516. * @param id defines the id to search for
  132517. * @return the found morph target or null if not found at all.
  132518. */
  132519. Scene.prototype.getMorphTargetById = function (id) {
  132520. for (var managerIndex = 0; managerIndex < this.morphTargetManagers.length; ++managerIndex) {
  132521. var morphTargetManager = this.morphTargetManagers[managerIndex];
  132522. for (var index = 0; index < morphTargetManager.numTargets; ++index) {
  132523. var target = morphTargetManager.getTarget(index);
  132524. if (target.id === id) {
  132525. return target;
  132526. }
  132527. }
  132528. }
  132529. return null;
  132530. };
  132531. /**
  132532. * Gets a boolean indicating if the given mesh is active
  132533. * @param mesh defines the mesh to look for
  132534. * @returns true if the mesh is in the active list
  132535. */
  132536. Scene.prototype.isActiveMesh = function (mesh) {
  132537. return (this._activeMeshes.indexOf(mesh) !== -1);
  132538. };
  132539. Object.defineProperty(Scene.prototype, "uid", {
  132540. /**
  132541. * Return a unique id as a string which can serve as an identifier for the scene
  132542. */
  132543. get: function () {
  132544. if (!this._uid) {
  132545. this._uid = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].RandomId();
  132546. }
  132547. return this._uid;
  132548. },
  132549. enumerable: true,
  132550. configurable: true
  132551. });
  132552. /**
  132553. * Add an externaly attached data from its key.
  132554. * This method call will fail and return false, if such key already exists.
  132555. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  132556. * @param key the unique key that identifies the data
  132557. * @param data the data object to associate to the key for this Engine instance
  132558. * @return true if no such key were already present and the data was added successfully, false otherwise
  132559. */
  132560. Scene.prototype.addExternalData = function (key, data) {
  132561. if (!this._externalData) {
  132562. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__["StringDictionary"]();
  132563. }
  132564. return this._externalData.add(key, data);
  132565. };
  132566. /**
  132567. * Get an externaly attached data from its key
  132568. * @param key the unique key that identifies the data
  132569. * @return the associated data, if present (can be null), or undefined if not present
  132570. */
  132571. Scene.prototype.getExternalData = function (key) {
  132572. if (!this._externalData) {
  132573. return null;
  132574. }
  132575. return this._externalData.get(key);
  132576. };
  132577. /**
  132578. * Get an externaly attached data from its key, create it using a factory if it's not already present
  132579. * @param key the unique key that identifies the data
  132580. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  132581. * @return the associated data, can be null if the factory returned null.
  132582. */
  132583. Scene.prototype.getOrAddExternalDataWithFactory = function (key, factory) {
  132584. if (!this._externalData) {
  132585. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__["StringDictionary"]();
  132586. }
  132587. return this._externalData.getOrAddWithFactory(key, factory);
  132588. };
  132589. /**
  132590. * Remove an externaly attached data from the Engine instance
  132591. * @param key the unique key that identifies the data
  132592. * @return true if the data was successfully removed, false if it doesn't exist
  132593. */
  132594. Scene.prototype.removeExternalData = function (key) {
  132595. return this._externalData.remove(key);
  132596. };
  132597. Scene.prototype._evaluateSubMesh = function (subMesh, mesh) {
  132598. if (this.dispatchAllSubMeshesOfActiveMeshes || mesh.alwaysSelectAsActiveMesh || mesh.subMeshes.length === 1 || subMesh.isInFrustum(this._frustumPlanes)) {
  132599. for (var _i = 0, _a = this._evaluateSubMeshStage; _i < _a.length; _i++) {
  132600. var step = _a[_i];
  132601. step.action(mesh, subMesh);
  132602. }
  132603. var material = subMesh.getMaterial();
  132604. if (material !== null && material !== undefined) {
  132605. // Render targets
  132606. if (material.hasRenderTargetTextures && material.getRenderTargetTextures !== undefined) {
  132607. if (this._processedMaterials.indexOf(material) === -1) {
  132608. this._processedMaterials.push(material);
  132609. this._renderTargets.concatWithNoDuplicate(material.getRenderTargetTextures());
  132610. }
  132611. }
  132612. // Dispatch
  132613. this._activeIndices.addCount(subMesh.indexCount, false);
  132614. this._renderingManager.dispatch(subMesh, mesh, material);
  132615. }
  132616. }
  132617. };
  132618. /**
  132619. * Clear the processed materials smart array preventing retention point in material dispose.
  132620. */
  132621. Scene.prototype.freeProcessedMaterials = function () {
  132622. this._processedMaterials.dispose();
  132623. };
  132624. Object.defineProperty(Scene.prototype, "blockfreeActiveMeshesAndRenderingGroups", {
  132625. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  132626. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  132627. * when disposing several meshes in a row or a hierarchy of meshes.
  132628. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  132629. */
  132630. get: function () {
  132631. return this._preventFreeActiveMeshesAndRenderingGroups;
  132632. },
  132633. set: function (value) {
  132634. if (this._preventFreeActiveMeshesAndRenderingGroups === value) {
  132635. return;
  132636. }
  132637. if (value) {
  132638. this.freeActiveMeshes();
  132639. this.freeRenderingGroups();
  132640. }
  132641. this._preventFreeActiveMeshesAndRenderingGroups = value;
  132642. },
  132643. enumerable: true,
  132644. configurable: true
  132645. });
  132646. /**
  132647. * Clear the active meshes smart array preventing retention point in mesh dispose.
  132648. */
  132649. Scene.prototype.freeActiveMeshes = function () {
  132650. if (this.blockfreeActiveMeshesAndRenderingGroups) {
  132651. return;
  132652. }
  132653. this._activeMeshes.dispose();
  132654. if (this.activeCamera && this.activeCamera._activeMeshes) {
  132655. this.activeCamera._activeMeshes.dispose();
  132656. }
  132657. if (this.activeCameras) {
  132658. for (var i = 0; i < this.activeCameras.length; i++) {
  132659. var activeCamera = this.activeCameras[i];
  132660. if (activeCamera && activeCamera._activeMeshes) {
  132661. activeCamera._activeMeshes.dispose();
  132662. }
  132663. }
  132664. }
  132665. };
  132666. /**
  132667. * Clear the info related to rendering groups preventing retention points during dispose.
  132668. */
  132669. Scene.prototype.freeRenderingGroups = function () {
  132670. if (this.blockfreeActiveMeshesAndRenderingGroups) {
  132671. return;
  132672. }
  132673. if (this._renderingManager) {
  132674. this._renderingManager.freeRenderingGroups();
  132675. }
  132676. if (this.textures) {
  132677. for (var i = 0; i < this.textures.length; i++) {
  132678. var texture = this.textures[i];
  132679. if (texture && texture.renderList) {
  132680. texture.freeRenderingGroups();
  132681. }
  132682. }
  132683. }
  132684. };
  132685. /** @hidden */
  132686. Scene.prototype._isInIntermediateRendering = function () {
  132687. return this._intermediateRendering;
  132688. };
  132689. /**
  132690. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  132691. * @returns the current scene
  132692. */
  132693. Scene.prototype.freezeActiveMeshes = function () {
  132694. if (!this.activeCamera) {
  132695. return this;
  132696. }
  132697. if (!this._frustumPlanes) {
  132698. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix());
  132699. }
  132700. this._evaluateActiveMeshes();
  132701. this._activeMeshesFrozen = true;
  132702. return this;
  132703. };
  132704. /**
  132705. * Use this function to restart evaluating active meshes on every frame
  132706. * @returns the current scene
  132707. */
  132708. Scene.prototype.unfreezeActiveMeshes = function () {
  132709. this._activeMeshesFrozen = false;
  132710. return this;
  132711. };
  132712. Scene.prototype._evaluateActiveMeshes = function () {
  132713. if (this._activeMeshesFrozen && this._activeMeshes.length) {
  132714. return;
  132715. }
  132716. if (!this.activeCamera) {
  132717. return;
  132718. }
  132719. this.onBeforeActiveMeshesEvaluationObservable.notifyObservers(this);
  132720. this.activeCamera._activeMeshes.reset();
  132721. this._activeMeshes.reset();
  132722. this._renderingManager.reset();
  132723. this._processedMaterials.reset();
  132724. this._activeParticleSystems.reset();
  132725. this._activeSkeletons.reset();
  132726. this._softwareSkinnedMeshes.reset();
  132727. for (var _i = 0, _a = this._beforeEvaluateActiveMeshStage; _i < _a.length; _i++) {
  132728. var step = _a[_i];
  132729. step.action();
  132730. }
  132731. // Determine mesh candidates
  132732. var meshes = this.getActiveMeshCandidates();
  132733. // Check each mesh
  132734. var len = meshes.length;
  132735. for (var i = 0; i < len; i++) {
  132736. var mesh = meshes.data[i];
  132737. if (mesh.isBlocked) {
  132738. continue;
  132739. }
  132740. this._totalVertices.addCount(mesh.getTotalVertices(), false);
  132741. if (!mesh.isReady() || !mesh.isEnabled()) {
  132742. continue;
  132743. }
  132744. mesh.computeWorldMatrix();
  132745. // Intersections
  132746. if (mesh.actionManager && mesh.actionManager.hasSpecificTriggers2(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionEnterTrigger, _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger)) {
  132747. this._meshesForIntersections.pushNoDuplicate(mesh);
  132748. }
  132749. // Switch to current LOD
  132750. var meshLOD = this.customLODSelector ? this.customLODSelector(mesh, this.activeCamera) : mesh.getLOD(this.activeCamera);
  132751. if (meshLOD === undefined || meshLOD === null) {
  132752. continue;
  132753. }
  132754. mesh._preActivate();
  132755. if (mesh.isVisible && mesh.visibility > 0 && ((mesh.layerMask & this.activeCamera.layerMask) !== 0) && (mesh.alwaysSelectAsActiveMesh || mesh.isInFrustum(this._frustumPlanes))) {
  132756. this._activeMeshes.push(mesh);
  132757. this.activeCamera._activeMeshes.push(mesh);
  132758. mesh._activate(this._renderId);
  132759. if (meshLOD !== mesh) {
  132760. meshLOD._activate(this._renderId);
  132761. }
  132762. this._activeMesh(mesh, meshLOD);
  132763. }
  132764. }
  132765. this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this);
  132766. // Particle systems
  132767. if (this.particlesEnabled) {
  132768. this.onBeforeParticlesRenderingObservable.notifyObservers(this);
  132769. for (var particleIndex = 0; particleIndex < this.particleSystems.length; particleIndex++) {
  132770. var particleSystem = this.particleSystems[particleIndex];
  132771. if (!particleSystem.isStarted() || !particleSystem.emitter) {
  132772. continue;
  132773. }
  132774. var emitter = particleSystem.emitter;
  132775. if (!emitter.position || emitter.isEnabled()) {
  132776. this._activeParticleSystems.push(particleSystem);
  132777. particleSystem.animate();
  132778. this._renderingManager.dispatchParticles(particleSystem);
  132779. }
  132780. }
  132781. this.onAfterParticlesRenderingObservable.notifyObservers(this);
  132782. }
  132783. };
  132784. Scene.prototype._activeMesh = function (sourceMesh, mesh) {
  132785. if (this._skeletonsEnabled && mesh.skeleton !== null && mesh.skeleton !== undefined) {
  132786. if (this._activeSkeletons.pushNoDuplicate(mesh.skeleton)) {
  132787. mesh.skeleton.prepare();
  132788. }
  132789. if (!mesh.computeBonesUsingShaders) {
  132790. this._softwareSkinnedMeshes.pushNoDuplicate(mesh);
  132791. }
  132792. }
  132793. for (var _i = 0, _a = this._activeMeshStage; _i < _a.length; _i++) {
  132794. var step = _a[_i];
  132795. step.action(sourceMesh, mesh);
  132796. }
  132797. if (mesh !== undefined && mesh !== null
  132798. && mesh.subMeshes !== undefined && mesh.subMeshes !== null && mesh.subMeshes.length > 0) {
  132799. var subMeshes = this.getActiveSubMeshCandidates(mesh);
  132800. var len = subMeshes.length;
  132801. for (var i = 0; i < len; i++) {
  132802. var subMesh = subMeshes.data[i];
  132803. this._evaluateSubMesh(subMesh, mesh);
  132804. }
  132805. }
  132806. };
  132807. /**
  132808. * Update the transform matrix to update from the current active camera
  132809. * @param force defines a boolean used to force the update even if cache is up to date
  132810. */
  132811. Scene.prototype.updateTransformMatrix = function (force) {
  132812. if (!this.activeCamera) {
  132813. return;
  132814. }
  132815. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(force));
  132816. };
  132817. /**
  132818. * 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)
  132819. * @param alternateCamera defines the camera to use
  132820. */
  132821. Scene.prototype.updateAlternateTransformMatrix = function (alternateCamera) {
  132822. this._setAlternateTransformMatrix(alternateCamera.getViewMatrix(), alternateCamera.getProjectionMatrix());
  132823. };
  132824. Scene.prototype._renderForCamera = function (camera, rigParent) {
  132825. if (camera && camera._skipRendering) {
  132826. return;
  132827. }
  132828. var engine = this._engine;
  132829. // Use _activeCamera instead of activeCamera to avoid onActiveCameraChanged
  132830. this._activeCamera = camera;
  132831. if (!this.activeCamera) {
  132832. throw new Error("Active camera not set");
  132833. }
  132834. // Viewport
  132835. engine.setViewport(this.activeCamera.viewport);
  132836. // Camera
  132837. this.resetCachedMaterial();
  132838. this._renderId++;
  132839. this.updateTransformMatrix();
  132840. if (camera._alternateCamera) {
  132841. this.updateAlternateTransformMatrix(camera._alternateCamera);
  132842. this._alternateRendering = true;
  132843. }
  132844. this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera);
  132845. // Meshes
  132846. this._evaluateActiveMeshes();
  132847. // Software skinning
  132848. for (var softwareSkinnedMeshIndex = 0; softwareSkinnedMeshIndex < this._softwareSkinnedMeshes.length; softwareSkinnedMeshIndex++) {
  132849. var mesh = this._softwareSkinnedMeshes.data[softwareSkinnedMeshIndex];
  132850. mesh.applySkeleton(mesh.skeleton);
  132851. }
  132852. // Render targets
  132853. this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
  132854. if (camera.customRenderTargets && camera.customRenderTargets.length > 0) {
  132855. this._renderTargets.concatWithNoDuplicate(camera.customRenderTargets);
  132856. }
  132857. if (rigParent && rigParent.customRenderTargets && rigParent.customRenderTargets.length > 0) {
  132858. this._renderTargets.concatWithNoDuplicate(rigParent.customRenderTargets);
  132859. }
  132860. // Collects render targets from external components.
  132861. for (var _i = 0, _a = this._gatherActiveCameraRenderTargetsStage; _i < _a.length; _i++) {
  132862. var step = _a[_i];
  132863. step.action(this._renderTargets);
  132864. }
  132865. if (this.renderTargetsEnabled) {
  132866. this._intermediateRendering = true;
  132867. if (this._renderTargets.length > 0) {
  132868. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].StartPerformanceCounter("Render targets", this._renderTargets.length > 0);
  132869. for (var renderIndex = 0; renderIndex < this._renderTargets.length; renderIndex++) {
  132870. var renderTarget = this._renderTargets.data[renderIndex];
  132871. if (renderTarget._shouldRender()) {
  132872. this._renderId++;
  132873. var hasSpecialRenderTargetCamera = renderTarget.activeCamera && renderTarget.activeCamera !== this.activeCamera;
  132874. renderTarget.render(hasSpecialRenderTargetCamera, this.dumpNextRenderTargets);
  132875. }
  132876. }
  132877. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].EndPerformanceCounter("Render targets", this._renderTargets.length > 0);
  132878. this._renderId++;
  132879. }
  132880. for (var _b = 0, _c = this._cameraDrawRenderTargetStage; _b < _c.length; _b++) {
  132881. var step = _c[_b];
  132882. step.action(this.activeCamera);
  132883. }
  132884. this._intermediateRendering = false;
  132885. if (this.activeCamera.outputRenderTarget) {
  132886. var internalTexture = this.activeCamera.outputRenderTarget.getInternalTexture();
  132887. if (internalTexture) {
  132888. engine.bindFramebuffer(internalTexture);
  132889. }
  132890. else {
  132891. _Misc_logger__WEBPACK_IMPORTED_MODULE_23__["Logger"].Error("Camera contains invalid customDefaultRenderTarget");
  132892. }
  132893. }
  132894. else {
  132895. engine.restoreDefaultFramebuffer(); // Restore back buffer if needed
  132896. }
  132897. }
  132898. this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
  132899. // Prepare Frame
  132900. if (this.postProcessManager) {
  132901. this.postProcessManager._prepareFrame();
  132902. }
  132903. // Before Camera Draw
  132904. for (var _d = 0, _e = this._beforeCameraDrawStage; _d < _e.length; _d++) {
  132905. var step = _e[_d];
  132906. step.action(this.activeCamera);
  132907. }
  132908. // Render
  132909. this.onBeforeDrawPhaseObservable.notifyObservers(this);
  132910. this._renderingManager.render(null, null, true, true);
  132911. this.onAfterDrawPhaseObservable.notifyObservers(this);
  132912. // After Camera Draw
  132913. for (var _f = 0, _g = this._afterCameraDrawStage; _f < _g.length; _f++) {
  132914. var step = _g[_f];
  132915. step.action(this.activeCamera);
  132916. }
  132917. // Finalize frame
  132918. if (this.postProcessManager) {
  132919. this.postProcessManager._finalizeFrame(camera.isIntermediate);
  132920. }
  132921. // Reset some special arrays
  132922. this._renderTargets.reset();
  132923. this._alternateRendering = false;
  132924. this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera);
  132925. };
  132926. Scene.prototype._processSubCameras = function (camera) {
  132927. if (camera.cameraRigMode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_NONE) {
  132928. this._renderForCamera(camera);
  132929. return;
  132930. }
  132931. // rig cameras
  132932. for (var index = 0; index < camera._rigCameras.length; index++) {
  132933. this._renderForCamera(camera._rigCameras[index], camera);
  132934. }
  132935. // Use _activeCamera instead of activeCamera to avoid onActiveCameraChanged
  132936. this._activeCamera = camera;
  132937. this.setTransformMatrix(this._activeCamera.getViewMatrix(), this._activeCamera.getProjectionMatrix());
  132938. };
  132939. Scene.prototype._checkIntersections = function () {
  132940. for (var index = 0; index < this._meshesForIntersections.length; index++) {
  132941. var sourceMesh = this._meshesForIntersections.data[index];
  132942. if (!sourceMesh.actionManager) {
  132943. continue;
  132944. }
  132945. for (var actionIndex = 0; actionIndex < sourceMesh.actionManager.actions.length; actionIndex++) {
  132946. var action = sourceMesh.actionManager.actions[actionIndex];
  132947. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionEnterTrigger || action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger) {
  132948. var parameters = action.getTriggerParameter();
  132949. var otherMesh = parameters instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_8__["AbstractMesh"] ? parameters : parameters.mesh;
  132950. var areIntersecting = otherMesh.intersectsMesh(sourceMesh, parameters.usePreciseIntersection);
  132951. var currentIntersectionInProgress = sourceMesh._intersectionsInProgress.indexOf(otherMesh);
  132952. if (areIntersecting && currentIntersectionInProgress === -1) {
  132953. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionEnterTrigger) {
  132954. action._executeCurrent(_Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(sourceMesh, undefined, otherMesh));
  132955. sourceMesh._intersectionsInProgress.push(otherMesh);
  132956. }
  132957. else if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger) {
  132958. sourceMesh._intersectionsInProgress.push(otherMesh);
  132959. }
  132960. }
  132961. else if (!areIntersecting && currentIntersectionInProgress > -1) {
  132962. //They intersected, and now they don't.
  132963. //is this trigger an exit trigger? execute an event.
  132964. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger) {
  132965. action._executeCurrent(_Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(sourceMesh, undefined, otherMesh));
  132966. }
  132967. //if this is an exit trigger, or no exit trigger exists, remove the id from the intersection in progress array.
  132968. if (!sourceMesh.actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger, function (parameter) {
  132969. var parameterMesh = parameter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_8__["AbstractMesh"] ? parameter : parameter.mesh;
  132970. return otherMesh === parameterMesh;
  132971. }) || action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger) {
  132972. sourceMesh._intersectionsInProgress.splice(currentIntersectionInProgress, 1);
  132973. }
  132974. }
  132975. }
  132976. }
  132977. }
  132978. };
  132979. /** @hidden */
  132980. Scene.prototype._advancePhysicsEngineStep = function (step) {
  132981. // Do nothing. Code will be replaced if physics engine component is referenced
  132982. };
  132983. /** @hidden */
  132984. Scene.prototype._animate = function () {
  132985. // Nothing to do as long as Animatable have not been imported.
  132986. };
  132987. /**
  132988. * Render the scene
  132989. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  132990. */
  132991. Scene.prototype.render = function (updateCameras) {
  132992. if (updateCameras === void 0) { updateCameras = true; }
  132993. if (this.isDisposed) {
  132994. return;
  132995. }
  132996. this._frameId++;
  132997. // Register components that have been associated lately to the scene.
  132998. this._registerTransientComponents();
  132999. this._activeParticles.fetchNewFrame();
  133000. this._totalVertices.fetchNewFrame();
  133001. this._activeIndices.fetchNewFrame();
  133002. this._activeBones.fetchNewFrame();
  133003. this._meshesForIntersections.reset();
  133004. this.resetCachedMaterial();
  133005. this.onBeforeAnimationsObservable.notifyObservers(this);
  133006. // Actions
  133007. if (this.actionManager) {
  133008. this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnEveryFrameTrigger);
  133009. }
  133010. if (this._engine.isDeterministicLockStep()) {
  133011. var deltaTime = Math.max(Scene.MinDeltaTime, Math.min(this._engine.getDeltaTime(), Scene.MaxDeltaTime)) + this._timeAccumulator;
  133012. var defaultFPS = (60.0 / 1000.0);
  133013. var defaultFrameTime = this.getDeterministicFrameTime();
  133014. var stepsTaken = 0;
  133015. var maxSubSteps = this._engine.getLockstepMaxSteps();
  133016. var internalSteps = Math.floor(deltaTime / (1000 * defaultFPS));
  133017. internalSteps = Math.min(internalSteps, maxSubSteps);
  133018. do {
  133019. this.onBeforeStepObservable.notifyObservers(this);
  133020. // Animations
  133021. this._animationRatio = defaultFrameTime * defaultFPS;
  133022. this._animate();
  133023. this.onAfterAnimationsObservable.notifyObservers(this);
  133024. // Physics
  133025. this._advancePhysicsEngineStep(defaultFrameTime);
  133026. this.onAfterStepObservable.notifyObservers(this);
  133027. this._currentStepId++;
  133028. stepsTaken++;
  133029. deltaTime -= defaultFrameTime;
  133030. } while (deltaTime > 0 && stepsTaken < internalSteps);
  133031. this._timeAccumulator = deltaTime < 0 ? 0 : deltaTime;
  133032. }
  133033. else {
  133034. // Animations
  133035. var deltaTime = this.useConstantAnimationDeltaTime ? 16 : Math.max(Scene.MinDeltaTime, Math.min(this._engine.getDeltaTime(), Scene.MaxDeltaTime));
  133036. this._animationRatio = deltaTime * (60.0 / 1000.0);
  133037. this._animate();
  133038. this.onAfterAnimationsObservable.notifyObservers(this);
  133039. // Physics
  133040. this._advancePhysicsEngineStep(deltaTime);
  133041. }
  133042. // Before camera update steps
  133043. for (var _i = 0, _a = this._beforeCameraUpdateStage; _i < _a.length; _i++) {
  133044. var step = _a[_i];
  133045. step.action();
  133046. }
  133047. // Update Cameras
  133048. if (updateCameras) {
  133049. if (this.activeCameras.length > 0) {
  133050. for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
  133051. var camera = this.activeCameras[cameraIndex];
  133052. camera.update();
  133053. if (camera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_NONE) {
  133054. // rig cameras
  133055. for (var index = 0; index < camera._rigCameras.length; index++) {
  133056. camera._rigCameras[index].update();
  133057. }
  133058. }
  133059. }
  133060. }
  133061. else if (this.activeCamera) {
  133062. this.activeCamera.update();
  133063. if (this.activeCamera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_NONE) {
  133064. // rig cameras
  133065. for (var index = 0; index < this.activeCamera._rigCameras.length; index++) {
  133066. this.activeCamera._rigCameras[index].update();
  133067. }
  133068. }
  133069. }
  133070. }
  133071. // Before render
  133072. this.onBeforeRenderObservable.notifyObservers(this);
  133073. // Customs render targets
  133074. this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
  133075. var engine = this.getEngine();
  133076. var currentActiveCamera = this.activeCamera;
  133077. if (this.renderTargetsEnabled) {
  133078. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].StartPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0);
  133079. this._intermediateRendering = true;
  133080. for (var customIndex = 0; customIndex < this.customRenderTargets.length; customIndex++) {
  133081. var renderTarget = this.customRenderTargets[customIndex];
  133082. if (renderTarget._shouldRender()) {
  133083. this._renderId++;
  133084. this.activeCamera = renderTarget.activeCamera || this.activeCamera;
  133085. if (!this.activeCamera) {
  133086. throw new Error("Active camera not set");
  133087. }
  133088. // Viewport
  133089. engine.setViewport(this.activeCamera.viewport);
  133090. // Camera
  133091. this.updateTransformMatrix();
  133092. renderTarget.render(currentActiveCamera !== this.activeCamera, this.dumpNextRenderTargets);
  133093. }
  133094. }
  133095. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].EndPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0);
  133096. this._intermediateRendering = false;
  133097. this._renderId++;
  133098. }
  133099. // Restore back buffer
  133100. if (this.customRenderTargets.length > 0) {
  133101. engine.restoreDefaultFramebuffer();
  133102. }
  133103. this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
  133104. this.activeCamera = currentActiveCamera;
  133105. for (var _b = 0, _c = this._beforeClearStage; _b < _c.length; _b++) {
  133106. var step = _c[_b];
  133107. step.action();
  133108. }
  133109. // Clear
  133110. if (this.autoClearDepthAndStencil || this.autoClear) {
  133111. this._engine.clear(this.clearColor, this.autoClear || this.forceWireframe || this.forcePointsCloud, this.autoClearDepthAndStencil, this.autoClearDepthAndStencil);
  133112. }
  133113. // Collects render targets from external components.
  133114. for (var _d = 0, _e = this._gatherRenderTargetsStage; _d < _e.length; _d++) {
  133115. var step = _e[_d];
  133116. step.action(this._renderTargets);
  133117. }
  133118. // Multi-cameras?
  133119. if (this.activeCameras.length > 0) {
  133120. for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
  133121. if (cameraIndex > 0) {
  133122. this._engine.clear(null, false, true, true);
  133123. }
  133124. this._processSubCameras(this.activeCameras[cameraIndex]);
  133125. }
  133126. }
  133127. else {
  133128. if (!this.activeCamera) {
  133129. throw new Error("No camera defined");
  133130. }
  133131. this._processSubCameras(this.activeCamera);
  133132. }
  133133. // Intersection checks
  133134. this._checkIntersections();
  133135. // Executes the after render stage actions.
  133136. for (var _f = 0, _g = this._afterRenderStage; _f < _g.length; _f++) {
  133137. var step = _g[_f];
  133138. step.action();
  133139. }
  133140. // After render
  133141. if (this.afterRender) {
  133142. this.afterRender();
  133143. }
  133144. this.onAfterRenderObservable.notifyObservers(this);
  133145. // Cleaning
  133146. if (this._toBeDisposed.length) {
  133147. for (var index = 0; index < this._toBeDisposed.length; index++) {
  133148. var data = this._toBeDisposed[index];
  133149. if (data) {
  133150. data.dispose();
  133151. }
  133152. }
  133153. this._toBeDisposed = [];
  133154. }
  133155. if (this.dumpNextRenderTargets) {
  133156. this.dumpNextRenderTargets = false;
  133157. }
  133158. this._activeBones.addCount(0, true);
  133159. this._activeIndices.addCount(0, true);
  133160. this._activeParticles.addCount(0, true);
  133161. };
  133162. /**
  133163. * Freeze all materials
  133164. * A frozen material will not be updatable but should be faster to render
  133165. */
  133166. Scene.prototype.freezeMaterials = function () {
  133167. for (var i = 0; i < this.materials.length; i++) {
  133168. this.materials[i].freeze();
  133169. }
  133170. };
  133171. /**
  133172. * Unfreeze all materials
  133173. * A frozen material will not be updatable but should be faster to render
  133174. */
  133175. Scene.prototype.unfreezeMaterials = function () {
  133176. for (var i = 0; i < this.materials.length; i++) {
  133177. this.materials[i].unfreeze();
  133178. }
  133179. };
  133180. /**
  133181. * Releases all held ressources
  133182. */
  133183. Scene.prototype.dispose = function () {
  133184. this.beforeRender = null;
  133185. this.afterRender = null;
  133186. this.skeletons = [];
  133187. this.morphTargetManagers = [];
  133188. this._transientComponents = [];
  133189. this._isReadyForMeshStage.clear();
  133190. this._beforeEvaluateActiveMeshStage.clear();
  133191. this._evaluateSubMeshStage.clear();
  133192. this._activeMeshStage.clear();
  133193. this._cameraDrawRenderTargetStage.clear();
  133194. this._beforeCameraDrawStage.clear();
  133195. this._beforeRenderTargetDrawStage.clear();
  133196. this._beforeRenderingGroupDrawStage.clear();
  133197. this._beforeRenderingMeshStage.clear();
  133198. this._afterRenderingMeshStage.clear();
  133199. this._afterRenderingGroupDrawStage.clear();
  133200. this._afterCameraDrawStage.clear();
  133201. this._afterRenderTargetDrawStage.clear();
  133202. this._afterRenderStage.clear();
  133203. this._beforeCameraUpdateStage.clear();
  133204. this._beforeClearStage.clear();
  133205. this._gatherRenderTargetsStage.clear();
  133206. this._gatherActiveCameraRenderTargetsStage.clear();
  133207. this._pointerMoveStage.clear();
  133208. this._pointerDownStage.clear();
  133209. this._pointerUpStage.clear();
  133210. for (var _i = 0, _a = this._components; _i < _a.length; _i++) {
  133211. var component = _a[_i];
  133212. component.dispose();
  133213. }
  133214. this.importedMeshesFiles = new Array();
  133215. this.stopAllAnimations();
  133216. this.resetCachedMaterial();
  133217. // Smart arrays
  133218. if (this.activeCamera) {
  133219. this.activeCamera._activeMeshes.dispose();
  133220. this.activeCamera = null;
  133221. }
  133222. this._activeMeshes.dispose();
  133223. this._renderingManager.dispose();
  133224. this._processedMaterials.dispose();
  133225. this._activeParticleSystems.dispose();
  133226. this._activeSkeletons.dispose();
  133227. this._softwareSkinnedMeshes.dispose();
  133228. this._renderTargets.dispose();
  133229. this._registeredForLateAnimationBindings.dispose();
  133230. this._meshesForIntersections.dispose();
  133231. this._toBeDisposed = [];
  133232. // Abort active requests
  133233. for (var _b = 0, _c = this._activeRequests; _b < _c.length; _b++) {
  133234. var request = _c[_b];
  133235. request.abort();
  133236. }
  133237. // Events
  133238. this.onDisposeObservable.notifyObservers(this);
  133239. this.onDisposeObservable.clear();
  133240. this.onBeforeRenderObservable.clear();
  133241. this.onAfterRenderObservable.clear();
  133242. this.onBeforeRenderTargetsRenderObservable.clear();
  133243. this.onAfterRenderTargetsRenderObservable.clear();
  133244. this.onAfterStepObservable.clear();
  133245. this.onBeforeStepObservable.clear();
  133246. this.onBeforeActiveMeshesEvaluationObservable.clear();
  133247. this.onAfterActiveMeshesEvaluationObservable.clear();
  133248. this.onBeforeParticlesRenderingObservable.clear();
  133249. this.onAfterParticlesRenderingObservable.clear();
  133250. this.onBeforeDrawPhaseObservable.clear();
  133251. this.onAfterDrawPhaseObservable.clear();
  133252. this.onBeforeAnimationsObservable.clear();
  133253. this.onAfterAnimationsObservable.clear();
  133254. this.onDataLoadedObservable.clear();
  133255. this.onBeforeRenderingGroupObservable.clear();
  133256. this.onAfterRenderingGroupObservable.clear();
  133257. this.onMeshImportedObservable.clear();
  133258. this.onBeforeCameraRenderObservable.clear();
  133259. this.onAfterCameraRenderObservable.clear();
  133260. this.onReadyObservable.clear();
  133261. this.onNewCameraAddedObservable.clear();
  133262. this.onCameraRemovedObservable.clear();
  133263. this.onNewLightAddedObservable.clear();
  133264. this.onLightRemovedObservable.clear();
  133265. this.onNewGeometryAddedObservable.clear();
  133266. this.onGeometryRemovedObservable.clear();
  133267. this.onNewTransformNodeAddedObservable.clear();
  133268. this.onTransformNodeRemovedObservable.clear();
  133269. this.onNewMeshAddedObservable.clear();
  133270. this.onMeshRemovedObservable.clear();
  133271. this.onNewMaterialAddedObservable.clear();
  133272. this.onMaterialRemovedObservable.clear();
  133273. this.onNewTextureAddedObservable.clear();
  133274. this.onTextureRemovedObservable.clear();
  133275. this.onPrePointerObservable.clear();
  133276. this.onPointerObservable.clear();
  133277. this.onPreKeyboardObservable.clear();
  133278. this.onKeyboardObservable.clear();
  133279. this.onActiveCameraChanged.clear();
  133280. this.detachControl();
  133281. // Detach cameras
  133282. var canvas = this._engine.getRenderingCanvas();
  133283. if (canvas) {
  133284. var index;
  133285. for (index = 0; index < this.cameras.length; index++) {
  133286. this.cameras[index].detachControl(canvas);
  133287. }
  133288. }
  133289. // Release animation groups
  133290. while (this.animationGroups.length) {
  133291. this.animationGroups[0].dispose();
  133292. }
  133293. // Release lights
  133294. while (this.lights.length) {
  133295. this.lights[0].dispose();
  133296. }
  133297. // Release meshes
  133298. while (this.meshes.length) {
  133299. this.meshes[0].dispose(true);
  133300. }
  133301. while (this.transformNodes.length) {
  133302. this.transformNodes[0].dispose(true);
  133303. }
  133304. // Release cameras
  133305. while (this.cameras.length) {
  133306. this.cameras[0].dispose();
  133307. }
  133308. // Release materials
  133309. if (this.defaultMaterial) {
  133310. this.defaultMaterial.dispose();
  133311. }
  133312. while (this.multiMaterials.length) {
  133313. this.multiMaterials[0].dispose();
  133314. }
  133315. while (this.materials.length) {
  133316. this.materials[0].dispose();
  133317. }
  133318. // Release particles
  133319. while (this.particleSystems.length) {
  133320. this.particleSystems[0].dispose();
  133321. }
  133322. // Release postProcesses
  133323. while (this.postProcesses.length) {
  133324. this.postProcesses[0].dispose();
  133325. }
  133326. // Release textures
  133327. while (this.textures.length) {
  133328. this.textures[0].dispose();
  133329. }
  133330. // Release UBO
  133331. this._sceneUbo.dispose();
  133332. if (this._alternateSceneUbo) {
  133333. this._alternateSceneUbo.dispose();
  133334. }
  133335. // Post-processes
  133336. this.postProcessManager.dispose();
  133337. // Remove from engine
  133338. index = this._engine.scenes.indexOf(this);
  133339. if (index > -1) {
  133340. this._engine.scenes.splice(index, 1);
  133341. }
  133342. this._engine.wipeCaches(true);
  133343. this._isDisposed = true;
  133344. };
  133345. Object.defineProperty(Scene.prototype, "isDisposed", {
  133346. /**
  133347. * Gets if the scene is already disposed
  133348. */
  133349. get: function () {
  133350. return this._isDisposed;
  133351. },
  133352. enumerable: true,
  133353. configurable: true
  133354. });
  133355. /**
  133356. * Call this function to reduce memory footprint of the scene.
  133357. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  133358. */
  133359. Scene.prototype.clearCachedVertexData = function () {
  133360. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  133361. var mesh = this.meshes[meshIndex];
  133362. var geometry = mesh.geometry;
  133363. if (geometry) {
  133364. geometry._indices = [];
  133365. for (var vbName in geometry._vertexBuffers) {
  133366. if (!geometry._vertexBuffers.hasOwnProperty(vbName)) {
  133367. continue;
  133368. }
  133369. geometry._vertexBuffers[vbName]._buffer._data = null;
  133370. }
  133371. }
  133372. }
  133373. };
  133374. /**
  133375. * This function will remove the local cached buffer data from texture.
  133376. * It will save memory but will prevent the texture from being rebuilt
  133377. */
  133378. Scene.prototype.cleanCachedTextureBuffer = function () {
  133379. for (var _i = 0, _a = this.textures; _i < _a.length; _i++) {
  133380. var baseTexture = _a[_i];
  133381. var buffer = baseTexture._buffer;
  133382. if (buffer) {
  133383. baseTexture._buffer = null;
  133384. }
  133385. }
  133386. };
  133387. /**
  133388. * Get the world extend vectors with an optional filter
  133389. *
  133390. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  133391. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  133392. */
  133393. Scene.prototype.getWorldExtends = function (filterPredicate) {
  133394. var min = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  133395. var max = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  133396. filterPredicate = filterPredicate || (function () { return true; });
  133397. this.meshes.filter(filterPredicate).forEach(function (mesh) {
  133398. mesh.computeWorldMatrix(true);
  133399. if (!mesh.subMeshes || mesh.subMeshes.length === 0 || mesh.infiniteDistance) {
  133400. return;
  133401. }
  133402. var boundingInfo = mesh.getBoundingInfo();
  133403. var minBox = boundingInfo.boundingBox.minimumWorld;
  133404. var maxBox = boundingInfo.boundingBox.maximumWorld;
  133405. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(minBox, min, max);
  133406. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(maxBox, min, max);
  133407. });
  133408. return {
  133409. min: min,
  133410. max: max
  133411. };
  133412. };
  133413. // Picking
  133414. /**
  133415. * Creates a ray that can be used to pick in the scene
  133416. * @param x defines the x coordinate of the origin (on-screen)
  133417. * @param y defines the y coordinate of the origin (on-screen)
  133418. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  133419. * @param camera defines the camera to use for the picking
  133420. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  133421. * @returns a Ray
  133422. */
  133423. Scene.prototype.createPickingRay = function (x, y, world, camera, cameraViewSpace) {
  133424. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  133425. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  133426. };
  133427. /**
  133428. * Creates a ray that can be used to pick in the scene
  133429. * @param x defines the x coordinate of the origin (on-screen)
  133430. * @param y defines the y coordinate of the origin (on-screen)
  133431. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  133432. * @param result defines the ray where to store the picking ray
  133433. * @param camera defines the camera to use for the picking
  133434. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  133435. * @returns the current scene
  133436. */
  133437. Scene.prototype.createPickingRayToRef = function (x, y, world, result, camera, cameraViewSpace) {
  133438. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  133439. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  133440. };
  133441. /**
  133442. * Creates a ray that can be used to pick in the scene
  133443. * @param x defines the x coordinate of the origin (on-screen)
  133444. * @param y defines the y coordinate of the origin (on-screen)
  133445. * @param camera defines the camera to use for the picking
  133446. * @returns a Ray
  133447. */
  133448. Scene.prototype.createPickingRayInCameraSpace = function (x, y, camera) {
  133449. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  133450. };
  133451. /**
  133452. * Creates a ray that can be used to pick in the scene
  133453. * @param x defines the x coordinate of the origin (on-screen)
  133454. * @param y defines the y coordinate of the origin (on-screen)
  133455. * @param result defines the ray where to store the picking ray
  133456. * @param camera defines the camera to use for the picking
  133457. * @returns the current scene
  133458. */
  133459. Scene.prototype.createPickingRayInCameraSpaceToRef = function (x, y, result, camera) {
  133460. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  133461. };
  133462. /** Launch a ray to try to pick a mesh in the scene
  133463. * @param x position on screen
  133464. * @param y position on screen
  133465. * @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
  133466. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  133467. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  133468. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  133469. * @returns a PickingInfo
  133470. */
  133471. Scene.prototype.pick = function (x, y, predicate, fastCheck, camera, trianglePredicate) {
  133472. // Dummy info if picking as not been imported
  133473. var pi = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_14__["PickingInfo"]();
  133474. pi._pickingUnavailable = true;
  133475. return pi;
  133476. };
  133477. /** Use the given ray to pick a mesh in the scene
  133478. * @param ray The ray to use to pick meshes
  133479. * @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
  133480. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  133481. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  133482. * @returns a PickingInfo
  133483. */
  133484. Scene.prototype.pickWithRay = function (ray, predicate, fastCheck, trianglePredicate) {
  133485. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  133486. };
  133487. /**
  133488. * Launch a ray to try to pick a mesh in the scene
  133489. * @param x X position on screen
  133490. * @param y Y position on screen
  133491. * @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
  133492. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  133493. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  133494. * @returns an array of PickingInfo
  133495. */
  133496. Scene.prototype.multiPick = function (x, y, predicate, camera, trianglePredicate) {
  133497. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  133498. };
  133499. /**
  133500. * Launch a ray to try to pick a mesh in the scene
  133501. * @param ray Ray to use
  133502. * @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
  133503. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  133504. * @returns an array of PickingInfo
  133505. */
  133506. Scene.prototype.multiPickWithRay = function (ray, predicate, trianglePredicate) {
  133507. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  133508. };
  133509. /**
  133510. * Force the value of meshUnderPointer
  133511. * @param mesh defines the mesh to use
  133512. */
  133513. Scene.prototype.setPointerOverMesh = function (mesh) {
  133514. if (this._pointerOverMesh === mesh) {
  133515. return;
  133516. }
  133517. var actionManager;
  133518. if (this._pointerOverMesh) {
  133519. actionManager = this._pointerOverMesh._getActionManagerForTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPointerOutTrigger);
  133520. if (actionManager) {
  133521. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPointerOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(this._pointerOverMesh));
  133522. }
  133523. }
  133524. this._pointerOverMesh = mesh;
  133525. if (this._pointerOverMesh) {
  133526. actionManager = this._pointerOverMesh._getActionManagerForTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPointerOverTrigger);
  133527. if (actionManager) {
  133528. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPointerOverTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(this._pointerOverMesh));
  133529. }
  133530. }
  133531. };
  133532. /**
  133533. * Gets the mesh under the pointer
  133534. * @returns a Mesh or null if no mesh is under the pointer
  133535. */
  133536. Scene.prototype.getPointerOverMesh = function () {
  133537. return this._pointerOverMesh;
  133538. };
  133539. // Misc.
  133540. /** @hidden */
  133541. Scene.prototype._rebuildGeometries = function () {
  133542. for (var _i = 0, _a = this.geometries; _i < _a.length; _i++) {
  133543. var geometry = _a[_i];
  133544. geometry._rebuild();
  133545. }
  133546. for (var _b = 0, _c = this.meshes; _b < _c.length; _b++) {
  133547. var mesh = _c[_b];
  133548. mesh._rebuild();
  133549. }
  133550. if (this.postProcessManager) {
  133551. this.postProcessManager._rebuild();
  133552. }
  133553. for (var _d = 0, _e = this._components; _d < _e.length; _d++) {
  133554. var component = _e[_d];
  133555. component.rebuild();
  133556. }
  133557. for (var _f = 0, _g = this.particleSystems; _f < _g.length; _f++) {
  133558. var system = _g[_f];
  133559. system.rebuild();
  133560. }
  133561. };
  133562. /** @hidden */
  133563. Scene.prototype._rebuildTextures = function () {
  133564. for (var _i = 0, _a = this.textures; _i < _a.length; _i++) {
  133565. var texture = _a[_i];
  133566. texture._rebuild();
  133567. }
  133568. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_TextureDirtyFlag);
  133569. };
  133570. // Tags
  133571. Scene.prototype._getByTags = function (list, tagsQuery, forEach) {
  133572. if (tagsQuery === undefined) {
  133573. // returns the complete list (could be done with Tags.MatchesQuery but no need to have a for-loop here)
  133574. return list;
  133575. }
  133576. var listByTags = [];
  133577. forEach = forEach || (function (item) { return; });
  133578. for (var i in list) {
  133579. var item = list[i];
  133580. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_6__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_6__["Tags"].MatchesQuery(item, tagsQuery)) {
  133581. listByTags.push(item);
  133582. forEach(item);
  133583. }
  133584. }
  133585. return listByTags;
  133586. };
  133587. /**
  133588. * Get a list of meshes by tags
  133589. * @param tagsQuery defines the tags query to use
  133590. * @param forEach defines a predicate used to filter results
  133591. * @returns an array of Mesh
  133592. */
  133593. Scene.prototype.getMeshesByTags = function (tagsQuery, forEach) {
  133594. return this._getByTags(this.meshes, tagsQuery, forEach);
  133595. };
  133596. /**
  133597. * Get a list of cameras by tags
  133598. * @param tagsQuery defines the tags query to use
  133599. * @param forEach defines a predicate used to filter results
  133600. * @returns an array of Camera
  133601. */
  133602. Scene.prototype.getCamerasByTags = function (tagsQuery, forEach) {
  133603. return this._getByTags(this.cameras, tagsQuery, forEach);
  133604. };
  133605. /**
  133606. * Get a list of lights by tags
  133607. * @param tagsQuery defines the tags query to use
  133608. * @param forEach defines a predicate used to filter results
  133609. * @returns an array of Light
  133610. */
  133611. Scene.prototype.getLightsByTags = function (tagsQuery, forEach) {
  133612. return this._getByTags(this.lights, tagsQuery, forEach);
  133613. };
  133614. /**
  133615. * Get a list of materials by tags
  133616. * @param tagsQuery defines the tags query to use
  133617. * @param forEach defines a predicate used to filter results
  133618. * @returns an array of Material
  133619. */
  133620. Scene.prototype.getMaterialByTags = function (tagsQuery, forEach) {
  133621. return this._getByTags(this.materials, tagsQuery, forEach).concat(this._getByTags(this.multiMaterials, tagsQuery, forEach));
  133622. };
  133623. /**
  133624. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  133625. * This allowed control for front to back rendering or reversly depending of the special needs.
  133626. *
  133627. * @param renderingGroupId The rendering group id corresponding to its index
  133628. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  133629. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  133630. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  133631. */
  133632. Scene.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  133633. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  133634. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  133635. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  133636. this._renderingManager.setRenderingOrder(renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn);
  133637. };
  133638. /**
  133639. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  133640. *
  133641. * @param renderingGroupId The rendering group id corresponding to its index
  133642. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  133643. * @param depth Automatically clears depth between groups if true and autoClear is true.
  133644. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  133645. */
  133646. Scene.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil, depth, stencil) {
  133647. if (depth === void 0) { depth = true; }
  133648. if (stencil === void 0) { stencil = true; }
  133649. this._renderingManager.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil, depth, stencil);
  133650. };
  133651. /**
  133652. * Gets the current auto clear configuration for one rendering group of the rendering
  133653. * manager.
  133654. * @param index the rendering group index to get the information for
  133655. * @returns The auto clear setup for the requested rendering group
  133656. */
  133657. Scene.prototype.getAutoClearDepthStencilSetup = function (index) {
  133658. return this._renderingManager.getAutoClearDepthStencilSetup(index);
  133659. };
  133660. Object.defineProperty(Scene.prototype, "blockMaterialDirtyMechanism", {
  133661. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  133662. get: function () {
  133663. return this._blockMaterialDirtyMechanism;
  133664. },
  133665. set: function (value) {
  133666. if (this._blockMaterialDirtyMechanism === value) {
  133667. return;
  133668. }
  133669. this._blockMaterialDirtyMechanism = value;
  133670. if (!value) { // Do a complete update
  133671. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_AllDirtyFlag);
  133672. }
  133673. },
  133674. enumerable: true,
  133675. configurable: true
  133676. });
  133677. /**
  133678. * Will flag all materials as dirty to trigger new shader compilation
  133679. * @param flag defines the flag used to specify which material part must be marked as dirty
  133680. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  133681. */
  133682. Scene.prototype.markAllMaterialsAsDirty = function (flag, predicate) {
  133683. if (this._blockMaterialDirtyMechanism) {
  133684. return;
  133685. }
  133686. for (var _i = 0, _a = this.materials; _i < _a.length; _i++) {
  133687. var material = _a[_i];
  133688. if (predicate && !predicate(material)) {
  133689. continue;
  133690. }
  133691. material.markAsDirty(flag);
  133692. }
  133693. };
  133694. /** @hidden */
  133695. Scene.prototype._loadFile = function (url, onSuccess, onProgress, useOfflineSupport, useArrayBuffer, onError) {
  133696. var _this = this;
  133697. var request = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].LoadFile(url, onSuccess, onProgress, useOfflineSupport ? this.offlineProvider : undefined, useArrayBuffer, onError);
  133698. this._activeRequests.push(request);
  133699. request.onCompleteObservable.add(function (request) {
  133700. _this._activeRequests.splice(_this._activeRequests.indexOf(request), 1);
  133701. });
  133702. return request;
  133703. };
  133704. /** @hidden */
  133705. Scene.prototype._loadFileAsync = function (url, useOfflineSupport, useArrayBuffer) {
  133706. var _this = this;
  133707. return new Promise(function (resolve, reject) {
  133708. _this._loadFile(url, function (data) {
  133709. resolve(data);
  133710. }, undefined, useOfflineSupport, useArrayBuffer, function (request, exception) {
  133711. reject(exception);
  133712. });
  133713. });
  133714. };
  133715. // Statics
  133716. Scene._uniqueIdCounter = 0;
  133717. /** The fog is deactivated */
  133718. Scene.FOGMODE_NONE = 0;
  133719. /** The fog density is following an exponential function */
  133720. Scene.FOGMODE_EXP = 1;
  133721. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  133722. Scene.FOGMODE_EXP2 = 2;
  133723. /** The fog density is following a linear function. */
  133724. Scene.FOGMODE_LINEAR = 3;
  133725. /**
  133726. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  133727. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  133728. */
  133729. Scene.MinDeltaTime = 1.0;
  133730. /**
  133731. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  133732. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  133733. */
  133734. Scene.MaxDeltaTime = 1000.0;
  133735. /** The distance in pixel that you have to move to prevent some events */
  133736. Scene.DragMovementThreshold = 10; // in pixels
  133737. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  133738. Scene.LongPressDelay = 500; // in milliseconds
  133739. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  133740. Scene.DoubleClickDelay = 300; // in milliseconds
  133741. /** If you need to check double click without raising a single click at first click, enable this flag */
  133742. Scene.ExclusiveDoubleClickMode = false;
  133743. return Scene;
  133744. }(_abstractScene__WEBPACK_IMPORTED_MODULE_10__["AbstractScene"]));
  133745. /***/ }),
  133746. /***/ "./sceneComponent.ts":
  133747. /*!***************************!*\
  133748. !*** ./sceneComponent.ts ***!
  133749. \***************************/
  133750. /*! exports provided: SceneComponentConstants, Stage */
  133751. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  133752. "use strict";
  133753. __webpack_require__.r(__webpack_exports__);
  133754. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return SceneComponentConstants; });
  133755. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return Stage; });
  133756. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  133757. /**
  133758. * Groups all the scene component constants in one place to ease maintenance.
  133759. * @hidden
  133760. */
  133761. var SceneComponentConstants = /** @class */ (function () {
  133762. function SceneComponentConstants() {
  133763. }
  133764. SceneComponentConstants.NAME_EFFECTLAYER = "EffectLayer";
  133765. SceneComponentConstants.NAME_LAYER = "Layer";
  133766. SceneComponentConstants.NAME_LENSFLARESYSTEM = "LensFlareSystem";
  133767. SceneComponentConstants.NAME_BOUNDINGBOXRENDERER = "BoundingBoxRenderer";
  133768. SceneComponentConstants.NAME_PARTICLESYSTEM = "ParticleSystem";
  133769. SceneComponentConstants.NAME_GAMEPAD = "Gamepad";
  133770. SceneComponentConstants.NAME_SIMPLIFICATIONQUEUE = "SimplificationQueue";
  133771. SceneComponentConstants.NAME_GEOMETRYBUFFERRENDERER = "GeometryBufferRenderer";
  133772. SceneComponentConstants.NAME_DEPTHRENDERER = "DepthRenderer";
  133773. SceneComponentConstants.NAME_POSTPROCESSRENDERPIPELINEMANAGER = "PostProcessRenderPipelineManager";
  133774. SceneComponentConstants.NAME_SPRITE = "Sprite";
  133775. SceneComponentConstants.NAME_OUTLINERENDERER = "Outline";
  133776. SceneComponentConstants.NAME_PROCEDURALTEXTURE = "ProceduralTexture";
  133777. SceneComponentConstants.NAME_SHADOWGENERATOR = "ShadowGenerator";
  133778. SceneComponentConstants.NAME_OCTREE = "Octree";
  133779. SceneComponentConstants.NAME_PHYSICSENGINE = "PhysicsEngine";
  133780. SceneComponentConstants.NAME_AUDIO = "Audio";
  133781. SceneComponentConstants.STEP_ISREADYFORMESH_EFFECTLAYER = 0;
  133782. SceneComponentConstants.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER = 0;
  133783. SceneComponentConstants.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER = 0;
  133784. SceneComponentConstants.STEP_ACTIVEMESH_BOUNDINGBOXRENDERER = 0;
  133785. SceneComponentConstants.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER = 1;
  133786. SceneComponentConstants.STEP_BEFORECAMERADRAW_EFFECTLAYER = 0;
  133787. SceneComponentConstants.STEP_BEFORECAMERADRAW_LAYER = 1;
  133788. SceneComponentConstants.STEP_BEFORERENDERTARGETDRAW_LAYER = 0;
  133789. SceneComponentConstants.STEP_BEFORERENDERINGMESH_OUTLINE = 0;
  133790. SceneComponentConstants.STEP_AFTERRENDERINGMESH_OUTLINE = 0;
  133791. SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW = 0;
  133792. SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER = 1;
  133793. SceneComponentConstants.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE = 0;
  133794. SceneComponentConstants.STEP_BEFORECAMERAUPDATE_GAMEPAD = 1;
  133795. SceneComponentConstants.STEP_BEFORECLEAR_PROCEDURALTEXTURE = 0;
  133796. SceneComponentConstants.STEP_AFTERRENDERTARGETDRAW_LAYER = 0;
  133797. SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER = 0;
  133798. SceneComponentConstants.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM = 1;
  133799. SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW = 2;
  133800. SceneComponentConstants.STEP_AFTERCAMERADRAW_LAYER = 3;
  133801. SceneComponentConstants.STEP_AFTERRENDER_AUDIO = 0;
  133802. SceneComponentConstants.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR = 0;
  133803. SceneComponentConstants.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER = 1;
  133804. SceneComponentConstants.STEP_GATHERRENDERTARGETS_DEPTHRENDERER = 2;
  133805. SceneComponentConstants.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER = 3;
  133806. SceneComponentConstants.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER = 0;
  133807. SceneComponentConstants.STEP_POINTERMOVE_SPRITE = 0;
  133808. SceneComponentConstants.STEP_POINTERDOWN_SPRITE = 0;
  133809. SceneComponentConstants.STEP_POINTERUP_SPRITE = 0;
  133810. return SceneComponentConstants;
  133811. }());
  133812. /**
  133813. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  133814. * @hidden
  133815. */
  133816. var Stage = /** @class */ (function (_super) {
  133817. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Stage, _super);
  133818. /**
  133819. * Hide ctor from the rest of the world.
  133820. * @param items The items to add.
  133821. */
  133822. function Stage(items) {
  133823. return _super.apply(this, items) || this;
  133824. }
  133825. /**
  133826. * Creates a new Stage.
  133827. * @returns A new instance of a Stage
  133828. */
  133829. Stage.Create = function () {
  133830. return Object.create(Stage.prototype);
  133831. };
  133832. /**
  133833. * Registers a step in an ordered way in the targeted stage.
  133834. * @param index Defines the position to register the step in
  133835. * @param component Defines the component attached to the step
  133836. * @param action Defines the action to launch during the step
  133837. */
  133838. Stage.prototype.registerStep = function (index, component, action) {
  133839. var i = 0;
  133840. var maxIndex = Number.MAX_VALUE;
  133841. for (; i < this.length; i++) {
  133842. var step = this[i];
  133843. maxIndex = step.index;
  133844. if (index < maxIndex) {
  133845. break;
  133846. }
  133847. }
  133848. this.splice(i, 0, { index: index, component: component, action: action.bind(component) });
  133849. };
  133850. /**
  133851. * Clears all the steps from the stage.
  133852. */
  133853. Stage.prototype.clear = function () {
  133854. this.length = 0;
  133855. };
  133856. return Stage;
  133857. }(Array));
  133858. /***/ })
  133859. /******/ });
  133860. });
  133861. //# sourceMappingURL=babylon.max.js.map